Resolved issue #765. New feature. Free curve mode.
--HG-- branch : develop
This commit is contained in:
parent
f636a3899f
commit
daa539378f
|
@ -24,6 +24,7 @@
|
||||||
- [#758] Intersection Passmark - select which side is shown.
|
- [#758] Intersection Passmark - select which side is shown.
|
||||||
- New math parser function "r2cm". Round to up to 1 decimal.
|
- New math parser function "r2cm". Round to up to 1 decimal.
|
||||||
- Two new shortcut sequences: Ctrl+PgDown and Ctrl+PgUp to switch to next and previous pattern piece.
|
- Two new shortcut sequences: Ctrl+PgDown and Ctrl+PgUp to switch to next and previous pattern piece.
|
||||||
|
- [#765] New feature. Free curve mode.
|
||||||
|
|
||||||
# Version 0.5.1
|
# Version 0.5.1
|
||||||
- [#683] Tool Seam allowance's dialog is off screen on small resolutions.
|
- [#683] Tool Seam allowance's dialog is off screen on small resolutions.
|
||||||
|
|
|
@ -108,6 +108,8 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
|
||||||
settings->SetConfirmFormatRewriting(true);
|
settings->SetConfirmFormatRewriting(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ui->checkBoxFreeCurve->setChecked(qApp->ValentinaSettings()->IsFreeCurveMode());
|
||||||
|
|
||||||
//----------------------- Toolbar
|
//----------------------- Toolbar
|
||||||
ui->toolBarStyleCheck->setChecked(qApp->ValentinaSettings()->GetToolBarStyle());
|
ui->toolBarStyleCheck->setChecked(qApp->ValentinaSettings()->GetToolBarStyle());
|
||||||
}
|
}
|
||||||
|
@ -132,6 +134,7 @@ void PreferencesConfigurationPage::Apply()
|
||||||
|
|
||||||
settings->SetOsSeparator(ui->osOptionCheck->isChecked());
|
settings->SetOsSeparator(ui->osOptionCheck->isChecked());
|
||||||
settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked());
|
settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked());
|
||||||
|
settings->SetFreeCurveMode(ui->checkBoxFreeCurve->isChecked());
|
||||||
|
|
||||||
if (m_langChanged || m_systemChanged)
|
if (m_langChanged || m_systemChanged)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>501</width>
|
<width>501</width>
|
||||||
<height>559</height>
|
<height>582</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -187,6 +187,19 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBoxFreeCurve">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Update a pattern only after a curve release</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Free curve mode</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -61,6 +61,7 @@ const QString settingConfigurationUnit = QStringLiteral("confi
|
||||||
const QString settingConfigurationConfirmItemDeletion = QStringLiteral("configuration/confirm_item_deletion");
|
const QString settingConfigurationConfirmItemDeletion = QStringLiteral("configuration/confirm_item_deletion");
|
||||||
const QString settingConfigurationConfirmFormatRewriting = QStringLiteral("configuration/confirm_format_rewriting");
|
const QString settingConfigurationConfirmFormatRewriting = QStringLiteral("configuration/confirm_format_rewriting");
|
||||||
const QString settingConfigurationToolBarStyle = QStringLiteral("configuration/tool_bar_style");
|
const QString settingConfigurationToolBarStyle = QStringLiteral("configuration/tool_bar_style");
|
||||||
|
const QString settingConfigurationFreeCurveMode = QStringLiteral("configuration/freeCurveMode");
|
||||||
|
|
||||||
const QString settingPatternUndo = QStringLiteral("pattern/undo");
|
const QString settingPatternUndo = QStringLiteral("pattern/undo");
|
||||||
const QString settingPatternForbidFlipping = QStringLiteral("pattern/forbidFlipping");
|
const QString settingPatternForbidFlipping = QStringLiteral("pattern/forbidFlipping");
|
||||||
|
@ -478,6 +479,18 @@ void VCommonSettings::SetToolBarStyle(const bool &value)
|
||||||
setValue(settingConfigurationToolBarStyle, value);
|
setValue(settingConfigurationToolBarStyle, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VCommonSettings::IsFreeCurveMode() const
|
||||||
|
{
|
||||||
|
return value(settingConfigurationFreeCurveMode, 1).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VCommonSettings::SetFreeCurveMode(bool value)
|
||||||
|
{
|
||||||
|
setValue(settingConfigurationFreeCurveMode, value);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
int VCommonSettings::GetUndoCount() const
|
int VCommonSettings::GetUndoCount() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -99,6 +99,9 @@ public:
|
||||||
bool GetToolBarStyle() const;
|
bool GetToolBarStyle() const;
|
||||||
void SetToolBarStyle(const bool &value);
|
void SetToolBarStyle(const bool &value);
|
||||||
|
|
||||||
|
bool IsFreeCurveMode() const;
|
||||||
|
void SetFreeCurveMode(bool value);
|
||||||
|
|
||||||
int GetUndoCount() const;
|
int GetUndoCount() const;
|
||||||
void SetUndoCount(const int &value);
|
void SetUndoCount(const int &value);
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,6 @@
|
||||||
#include "../vgeometry/vabstractcurve.h"
|
#include "../vgeometry/vabstractcurve.h"
|
||||||
#include "../vgeometry/vgobject.h"
|
#include "../vgeometry/vgobject.h"
|
||||||
#include "../vgeometry/vpointf.h"
|
#include "../vgeometry/vpointf.h"
|
||||||
#include "../vgeometry/vspline.h"
|
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
#include "../vmisc/vmath.h"
|
#include "../vmisc/vmath.h"
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
|
@ -79,7 +78,10 @@ const QString VToolSpline::OldToolType = QStringLiteral("simple");
|
||||||
*/
|
*/
|
||||||
VToolSpline::VToolSpline(VToolSplineInitData initData, QGraphicsItem *parent)
|
VToolSpline::VToolSpline(VToolSplineInitData initData, QGraphicsItem *parent)
|
||||||
: VAbstractSpline(initData.doc, initData.data, initData.id, parent),
|
: VAbstractSpline(initData.doc, initData.data, initData.id, parent),
|
||||||
oldPosition()
|
oldPosition(),
|
||||||
|
moved(false),
|
||||||
|
oldMoveSpline(),
|
||||||
|
newMoveSpline()
|
||||||
{
|
{
|
||||||
sceneType = SceneObject::Spline;
|
sceneType = SceneObject::Spline;
|
||||||
|
|
||||||
|
@ -88,6 +90,16 @@ VToolSpline::VToolSpline(VToolSplineInitData initData, QGraphicsItem *parent)
|
||||||
|
|
||||||
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(initData.id);
|
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(initData.id);
|
||||||
|
|
||||||
|
auto InitControlPoint = [this](VControlPointSpline* cPoint)
|
||||||
|
{
|
||||||
|
connect(cPoint, &VControlPointSpline::ControlPointChangePosition, this,
|
||||||
|
&VToolSpline::ControlPointChangePosition);
|
||||||
|
connect(this, &VToolSpline::setEnabledPoint, cPoint, &VControlPointSpline::setEnabledPoint);
|
||||||
|
connect(cPoint, &VControlPointSpline::ShowContextMenu, this, &VToolSpline::contextMenuEvent);
|
||||||
|
connect(cPoint, &VControlPointSpline::Released, this, &VToolSpline::CurveReleased);
|
||||||
|
controlPoints.append(cPoint);
|
||||||
|
};
|
||||||
|
|
||||||
const bool freeAngle1 = qmu::QmuTokenParser::IsSingle(spl->GetStartAngleFormula());
|
const bool freeAngle1 = qmu::QmuTokenParser::IsSingle(spl->GetStartAngleFormula());
|
||||||
const bool freeLength1 = qmu::QmuTokenParser::IsSingle(spl->GetC1LengthFormula());
|
const bool freeLength1 = qmu::QmuTokenParser::IsSingle(spl->GetC1LengthFormula());
|
||||||
|
|
||||||
|
@ -95,11 +107,7 @@ VToolSpline::VToolSpline(VToolSplineInitData initData, QGraphicsItem *parent)
|
||||||
static_cast<QPointF>(spl->GetP2()),
|
static_cast<QPointF>(spl->GetP2()),
|
||||||
static_cast<QPointF>(spl->GetP1()),
|
static_cast<QPointF>(spl->GetP1()),
|
||||||
freeAngle1, freeLength1, this);
|
freeAngle1, freeLength1, this);
|
||||||
connect(controlPoint1, &VControlPointSpline::ControlPointChangePosition, this,
|
InitControlPoint(controlPoint1);
|
||||||
&VToolSpline::ControlPointChangePosition);
|
|
||||||
connect(this, &VToolSpline::setEnabledPoint, controlPoint1, &VControlPointSpline::setEnabledPoint);
|
|
||||||
connect(controlPoint1, &VControlPointSpline::ShowContextMenu, this, &VToolSpline::contextMenuEvent);
|
|
||||||
controlPoints.append(controlPoint1);
|
|
||||||
|
|
||||||
const bool freeAngle2 = qmu::QmuTokenParser::IsSingle(spl->GetEndAngleFormula());
|
const bool freeAngle2 = qmu::QmuTokenParser::IsSingle(spl->GetEndAngleFormula());
|
||||||
const bool freeLength2 = qmu::QmuTokenParser::IsSingle(spl->GetC2LengthFormula());
|
const bool freeLength2 = qmu::QmuTokenParser::IsSingle(spl->GetC2LengthFormula());
|
||||||
|
@ -108,11 +116,7 @@ VToolSpline::VToolSpline(VToolSplineInitData initData, QGraphicsItem *parent)
|
||||||
static_cast<QPointF>(spl->GetP3()),
|
static_cast<QPointF>(spl->GetP3()),
|
||||||
static_cast<QPointF>(spl->GetP4()),
|
static_cast<QPointF>(spl->GetP4()),
|
||||||
freeAngle2, freeLength2, this);
|
freeAngle2, freeLength2, this);
|
||||||
connect(controlPoint2, &VControlPointSpline::ControlPointChangePosition, this,
|
InitControlPoint(controlPoint2);
|
||||||
&VToolSpline::ControlPointChangePosition);
|
|
||||||
connect(this, &VToolSpline::setEnabledPoint, controlPoint2, &VControlPointSpline::setEnabledPoint);
|
|
||||||
connect(controlPoint2, &VControlPointSpline::ShowContextMenu, this, &VToolSpline::contextMenuEvent);
|
|
||||||
controlPoints.append(controlPoint2);
|
|
||||||
|
|
||||||
ShowHandles(false);
|
ShowHandles(false);
|
||||||
|
|
||||||
|
@ -267,11 +271,30 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp
|
||||||
{
|
{
|
||||||
Q_UNUSED(indexSpline)
|
Q_UNUSED(indexSpline)
|
||||||
const QSharedPointer<VSpline> spline = VAbstractTool::data.GeometricObject<VSpline>(m_id);
|
const QSharedPointer<VSpline> spline = VAbstractTool::data.GeometricObject<VSpline>(m_id);
|
||||||
|
|
||||||
|
if (qApp->Settings()->IsFreeCurveMode() && not moved)
|
||||||
|
{
|
||||||
|
oldMoveSpline = spline;
|
||||||
|
moved = true;
|
||||||
|
}
|
||||||
|
|
||||||
const VSpline spl = CorrectedSpline(*spline, position, pos);
|
const VSpline spl = CorrectedSpline(*spline, position, pos);
|
||||||
|
|
||||||
MoveSpline *moveSpl = new MoveSpline(doc, spline.data(), spl, m_id);
|
if (not qApp->Settings()->IsFreeCurveMode())
|
||||||
connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
{
|
||||||
qApp->getUndoStack()->push(moveSpl);
|
UndoCommandMove(*spline, spl);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newMoveSpline = QSharedPointer<VSpline>(new VSpline(spl));
|
||||||
|
VAbstractTool::data.UpdateGObject(m_id, newMoveSpline);
|
||||||
|
RefreshGeometry();
|
||||||
|
|
||||||
|
if (QGraphicsScene *sc = scene())
|
||||||
|
{
|
||||||
|
VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -355,6 +378,8 @@ void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (IsMovable())
|
if (IsMovable())
|
||||||
{
|
{
|
||||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||||
|
|
||||||
|
CurveReleased();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,6 +400,13 @@ void VToolSpline::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
// among the handles; 0 = front handle only, 1 = back handle only.
|
// among the handles; 0 = front handle only, 1 = back handle only.
|
||||||
|
|
||||||
const auto spline = VAbstractTool::data.GeometricObject<VSpline>(m_id);
|
const auto spline = VAbstractTool::data.GeometricObject<VSpline>(m_id);
|
||||||
|
|
||||||
|
if (qApp->Settings()->IsFreeCurveMode() && not moved)
|
||||||
|
{
|
||||||
|
oldMoveSpline = spline;
|
||||||
|
moved = true;
|
||||||
|
}
|
||||||
|
|
||||||
const qreal t = spline->ParamT(oldPosition);
|
const qreal t = spline->ParamT(oldPosition);
|
||||||
|
|
||||||
if (qFloor(t) == -1)
|
if (qFloor(t) == -1)
|
||||||
|
@ -409,11 +441,22 @@ void VToolSpline::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
|
||||||
oldPosition = event->scenePos(); // Now mouse here
|
oldPosition = event->scenePos(); // Now mouse here
|
||||||
|
|
||||||
VSpline spl = VSpline(spline->GetP1(), p2, p3, spline->GetP4());
|
newMoveSpline = QSharedPointer<VSpline>(new VSpline(spline->GetP1(), p2, p3, spline->GetP4()));
|
||||||
|
|
||||||
MoveSpline *moveSpl = new MoveSpline(doc, spline.data(), spl, m_id);
|
if (not qApp->Settings()->IsFreeCurveMode())
|
||||||
connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
{
|
||||||
qApp->getUndoStack()->push(moveSpl);
|
UndoCommandMove(*spline, *newMoveSpline);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VAbstractTool::data.UpdateGObject(m_id, newMoveSpline);
|
||||||
|
RefreshGeometry();
|
||||||
|
|
||||||
|
if (QGraphicsScene *sc = scene())
|
||||||
|
{
|
||||||
|
VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Each time we move something we call recalculation scene rect. In some cases this can cause moving
|
// Each time we move something we call recalculation scene rect. In some cases this can cause moving
|
||||||
// objects positions. And this cause infinite redrawing. That's why we wait the finish of saving the last move.
|
// objects positions. And this cause infinite redrawing. That's why we wait the finish of saving the last move.
|
||||||
|
@ -543,6 +586,20 @@ void VToolSpline::RefreshCtrlPoints()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolSpline::CurveReleased()
|
||||||
|
{
|
||||||
|
if (qApp->Settings()->IsFreeCurveMode() && moved)
|
||||||
|
{
|
||||||
|
UndoCommandMove(*oldMoveSpline, *newMoveSpline);
|
||||||
|
|
||||||
|
oldMoveSpline.clear();
|
||||||
|
newMoveSpline.clear();
|
||||||
|
|
||||||
|
moved = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolSpline::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
void VToolSpline::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||||
{
|
{
|
||||||
|
@ -598,3 +655,11 @@ void VToolSpline::SetSplineAttributes(QDomElement &domElement, const VSpline &sp
|
||||||
domElement.removeAttribute(AttrKAsm2);
|
domElement.removeAttribute(AttrKAsm2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolSpline::UndoCommandMove(const VSpline &oldSpl, const VSpline &newSpl)
|
||||||
|
{
|
||||||
|
MoveSpline *moveSpl = new MoveSpline(doc, oldSpl, newSpl, m_id);
|
||||||
|
connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||||
|
qApp->getUndoStack()->push(moveSpl);
|
||||||
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "../ifc/xml/vabstractpattern.h"
|
#include "../ifc/xml/vabstractpattern.h"
|
||||||
#include "vabstractspline.h"
|
#include "vabstractspline.h"
|
||||||
|
#include "../vgeometry/vspline.h"
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
@ -105,14 +106,22 @@ protected:
|
||||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
||||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||||
virtual void RefreshCtrlPoints() Q_DECL_OVERRIDE;
|
virtual void RefreshCtrlPoints() Q_DECL_OVERRIDE;
|
||||||
|
private slots:
|
||||||
|
void CurveReleased();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VToolSpline)
|
Q_DISABLE_COPY(VToolSpline)
|
||||||
QPointF oldPosition;
|
QPointF oldPosition;
|
||||||
|
|
||||||
|
bool moved;
|
||||||
|
QSharedPointer<VSpline> oldMoveSpline;
|
||||||
|
QSharedPointer<VSpline> newMoveSpline;
|
||||||
|
|
||||||
VToolSpline (VToolSplineInitData initData, QGraphicsItem *parent = nullptr );
|
VToolSpline (VToolSplineInitData initData, QGraphicsItem *parent = nullptr );
|
||||||
|
|
||||||
bool IsMovable() const;
|
bool IsMovable() const;
|
||||||
void SetSplineAttributes(QDomElement &domElement, const VSpline &spl);
|
void SetSplineAttributes(QDomElement &domElement, const VSpline &spl);
|
||||||
|
|
||||||
|
void UndoCommandMove(const VSpline &oldSpl, const VSpline &newSpl);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLSPLINE_H
|
#endif // VTOOLSPLINE_H
|
||||||
|
|
|
@ -85,13 +85,25 @@ const QString VToolSplinePath::OldToolType = QStringLiteral("path");
|
||||||
VToolSplinePath::VToolSplinePath(const VToolSplinePathInitData &initData, QGraphicsItem *parent)
|
VToolSplinePath::VToolSplinePath(const VToolSplinePathInitData &initData, QGraphicsItem *parent)
|
||||||
: VAbstractSpline(initData.doc, initData.data, initData.id, parent),
|
: VAbstractSpline(initData.doc, initData.data, initData.id, parent),
|
||||||
oldPosition(),
|
oldPosition(),
|
||||||
splIndex(-1)
|
splIndex(-1),
|
||||||
|
moved(false),
|
||||||
|
oldMoveSplinePath(),
|
||||||
|
newMoveSplinePath()
|
||||||
{
|
{
|
||||||
sceneType = SceneObject::SplinePath;
|
sceneType = SceneObject::SplinePath;
|
||||||
|
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||||
|
|
||||||
|
auto InitControlPoint = [this](VControlPointSpline* cPoint)
|
||||||
|
{
|
||||||
|
connect(cPoint, &VControlPointSpline::ControlPointChangePosition, this,
|
||||||
|
&VToolSplinePath::ControlPointChangePosition);
|
||||||
|
connect(this, &VToolSplinePath::setEnabledPoint, cPoint, &VControlPointSpline::setEnabledPoint);
|
||||||
|
connect(cPoint, &VControlPointSpline::ShowContextMenu, this, &VToolSplinePath::contextMenuEvent);
|
||||||
|
controlPoints.append(cPoint);
|
||||||
|
};
|
||||||
|
|
||||||
const QSharedPointer<VSplinePath> splPath = initData.data->GeometricObject<VSplinePath>(initData.id);
|
const QSharedPointer<VSplinePath> splPath = initData.data->GeometricObject<VSplinePath>(initData.id);
|
||||||
for (qint32 i = 1; i<=splPath->CountSubSpl(); ++i)
|
for (qint32 i = 1; i<=splPath->CountSubSpl(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -104,22 +116,14 @@ VToolSplinePath::VToolSplinePath(const VToolSplinePathInitData &initData, QGraph
|
||||||
static_cast<QPointF>(spl.GetP2()),
|
static_cast<QPointF>(spl.GetP2()),
|
||||||
static_cast<QPointF>(spl.GetP1()),
|
static_cast<QPointF>(spl.GetP1()),
|
||||||
freeAngle1, freeLength1, this);
|
freeAngle1, freeLength1, this);
|
||||||
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
|
InitControlPoint(controlPoint);
|
||||||
&VToolSplinePath::ControlPointChangePosition);
|
|
||||||
connect(this, &VToolSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint);
|
|
||||||
connect(controlPoint, &VControlPointSpline::ShowContextMenu, this, &VToolSplinePath::contextMenuEvent);
|
|
||||||
controlPoints.append(controlPoint);
|
|
||||||
|
|
||||||
const bool freeAngle2 = qmu::QmuTokenParser::IsSingle(spl.GetEndAngleFormula());
|
const bool freeAngle2 = qmu::QmuTokenParser::IsSingle(spl.GetEndAngleFormula());
|
||||||
const bool freeLength2 = qmu::QmuTokenParser::IsSingle(spl.GetC2LengthFormula());
|
const bool freeLength2 = qmu::QmuTokenParser::IsSingle(spl.GetC2LengthFormula());
|
||||||
|
|
||||||
controlPoint = new VControlPointSpline(i, SplinePointPosition::LastPoint, static_cast<QPointF>(spl.GetP3()),
|
controlPoint = new VControlPointSpline(i, SplinePointPosition::LastPoint, static_cast<QPointF>(spl.GetP3()),
|
||||||
static_cast<QPointF>(spl.GetP4()), freeAngle2, freeLength2, this);
|
static_cast<QPointF>(spl.GetP4()), freeAngle2, freeLength2, this);
|
||||||
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
|
InitControlPoint(controlPoint);
|
||||||
&VToolSplinePath::ControlPointChangePosition);
|
|
||||||
connect(this, &VToolSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint);
|
|
||||||
connect(controlPoint, &VControlPointSpline::ShowContextMenu, this, &VToolSplinePath::contextMenuEvent);
|
|
||||||
controlPoints.append(controlPoint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowHandles(false);
|
ShowHandles(false);
|
||||||
|
@ -258,14 +262,34 @@ VToolSplinePath *VToolSplinePath::Create(VToolSplinePathInitData &initData)
|
||||||
void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position,
|
void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position,
|
||||||
const QPointF &pos)
|
const QPointF &pos)
|
||||||
{
|
{
|
||||||
const VSplinePath oldSplPath = *VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
const QSharedPointer<VSplinePath> oldSplPath = VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
||||||
VSplinePath newSplPath = oldSplPath;
|
|
||||||
const VSpline spl = CorrectedSpline(newSplPath.GetSpline(indexSpline), position, pos);
|
if (qApp->Settings()->IsFreeCurveMode() && not moved)
|
||||||
|
{
|
||||||
|
oldMoveSplinePath = oldSplPath;
|
||||||
|
moved = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSharedPointer<VSplinePath> newSplPath = oldSplPath;
|
||||||
|
const VSpline spl = CorrectedSpline(newSplPath->GetSpline(indexSpline), position, pos);
|
||||||
|
|
||||||
UpdateControlPoints(spl, newSplPath, indexSpline);
|
UpdateControlPoints(spl, newSplPath, indexSpline);
|
||||||
|
|
||||||
MoveSplinePath *moveSplPath = new MoveSplinePath(doc, oldSplPath, newSplPath, m_id);
|
if (not qApp->Settings()->IsFreeCurveMode())
|
||||||
connect(moveSplPath, &VUndoCommand::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
{
|
||||||
qApp->getUndoStack()->push(moveSplPath);
|
UndoCommandMove(*oldSplPath, *newSplPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newMoveSplinePath = newSplPath;
|
||||||
|
VAbstractTool::data.UpdateGObject(m_id, newMoveSplinePath);
|
||||||
|
RefreshGeometry();
|
||||||
|
|
||||||
|
if (QGraphicsScene *sc = scene())
|
||||||
|
{
|
||||||
|
VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -296,17 +320,18 @@ void VToolSplinePath::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, qui
|
||||||
* @param splPath spline path.
|
* @param splPath spline path.
|
||||||
* @param indexSpline index spline in spline path.
|
* @param indexSpline index spline in spline path.
|
||||||
*/
|
*/
|
||||||
void VToolSplinePath::UpdateControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) const
|
void VToolSplinePath::UpdateControlPoints(const VSpline &spl, QSharedPointer<VSplinePath> &splPath,
|
||||||
|
qint32 indexSpline) const
|
||||||
{
|
{
|
||||||
VSplinePoint p = splPath.GetSplinePoint(indexSpline, SplinePointPosition::FirstPoint);
|
VSplinePoint p = splPath->GetSplinePoint(indexSpline, SplinePointPosition::FirstPoint);
|
||||||
p.SetAngle2(spl.GetStartAngle(), spl.GetStartAngleFormula());
|
p.SetAngle2(spl.GetStartAngle(), spl.GetStartAngleFormula());
|
||||||
p.SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
|
p.SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
|
||||||
splPath.UpdatePoint(indexSpline, SplinePointPosition::FirstPoint, p);
|
splPath->UpdatePoint(indexSpline, SplinePointPosition::FirstPoint, p);
|
||||||
|
|
||||||
p = splPath.GetSplinePoint(indexSpline, SplinePointPosition::LastPoint);
|
p = splPath->GetSplinePoint(indexSpline, SplinePointPosition::LastPoint);
|
||||||
p.SetAngle1(spl.GetEndAngle(), spl.GetEndAngleFormula());
|
p.SetAngle1(spl.GetEndAngle(), spl.GetEndAngleFormula());
|
||||||
p.SetLength1(spl.GetC2Length(), spl.GetC2LengthFormula());
|
p.SetLength1(spl.GetC2Length(), spl.GetC2LengthFormula());
|
||||||
splPath.UpdatePoint(indexSpline, SplinePointPosition::LastPoint, p);
|
splPath->UpdatePoint(indexSpline, SplinePointPosition::LastPoint, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -334,6 +359,14 @@ void VToolSplinePath::SetSplinePathAttributes(QDomElement &domElement, const VSp
|
||||||
UpdatePathPoints(doc, domElement, path);
|
UpdatePathPoints(doc, domElement, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolSplinePath::UndoCommandMove(const VSplinePath &oldPath, const VSplinePath &newPath)
|
||||||
|
{
|
||||||
|
MoveSplinePath *moveSplPath = new MoveSplinePath(doc, oldPath, newPath, m_id);
|
||||||
|
connect(moveSplPath, &VUndoCommand::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||||
|
qApp->getUndoStack()->push(moveSplPath);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief UpdatePathPoints update spline path in pattern file.
|
* @brief UpdatePathPoints update spline path in pattern file.
|
||||||
|
@ -491,6 +524,8 @@ void VToolSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
oldPosition = event->scenePos();
|
oldPosition = event->scenePos();
|
||||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||||
|
|
||||||
|
CurveReleased();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VAbstractSpline::mouseReleaseEvent(event);
|
VAbstractSpline::mouseReleaseEvent(event);
|
||||||
|
@ -505,10 +540,17 @@ void VToolSplinePath::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
|
||||||
if (IsMovable(splIndex))
|
if (IsMovable(splIndex))
|
||||||
{
|
{
|
||||||
VSplinePath oldSplPath = *VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
const auto oldSplPath = VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
||||||
VSplinePath newSplPath = oldSplPath;
|
|
||||||
|
|
||||||
VSpline spline = newSplPath.GetSpline(splIndex);
|
if (qApp->Settings()->IsFreeCurveMode() && not moved)
|
||||||
|
{
|
||||||
|
oldMoveSplinePath = oldSplPath;
|
||||||
|
moved = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
newMoveSplinePath = oldSplPath;
|
||||||
|
|
||||||
|
VSpline spline = newMoveSplinePath->GetSpline(splIndex);
|
||||||
const qreal t = spline.ParamT(oldPosition);
|
const qreal t = spline.ParamT(oldPosition);
|
||||||
|
|
||||||
if (qFloor(t) == -1)
|
if (qFloor(t) == -1)
|
||||||
|
@ -549,11 +591,22 @@ void VToolSplinePath::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
|
||||||
const VSpline spl = VSpline(spline.GetP1(), p2, p3, spline.GetP4());
|
const VSpline spl = VSpline(spline.GetP1(), p2, p3, spline.GetP4());
|
||||||
|
|
||||||
UpdateControlPoints(spl, newSplPath, splIndex);
|
UpdateControlPoints(spl, newMoveSplinePath, splIndex);
|
||||||
|
|
||||||
MoveSplinePath *moveSplPath = new MoveSplinePath(doc, oldSplPath, newSplPath, m_id);
|
if (not qApp->Settings()->IsFreeCurveMode())
|
||||||
connect(moveSplPath, &VUndoCommand::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
{
|
||||||
qApp->getUndoStack()->push(moveSplPath);
|
UndoCommandMove(*oldSplPath, *newMoveSplinePath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VAbstractTool::data.UpdateGObject(m_id, newMoveSplinePath);
|
||||||
|
RefreshGeometry();
|
||||||
|
|
||||||
|
if (QGraphicsScene *sc = scene())
|
||||||
|
{
|
||||||
|
VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Each time we move something we call recalculation scene rect. In some cases this can cause moving
|
// Each time we move something we call recalculation scene rect. In some cases this can cause moving
|
||||||
// objects positions. And this cause infinite redrawing. That's why we wait the finish of saving the last move.
|
// objects positions. And this cause infinite redrawing. That's why we wait the finish of saving the last move.
|
||||||
|
@ -688,3 +741,17 @@ void VToolSplinePath::RefreshCtrlPoints()
|
||||||
point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolSplinePath::CurveReleased()
|
||||||
|
{
|
||||||
|
if (qApp->Settings()->IsFreeCurveMode() && moved)
|
||||||
|
{
|
||||||
|
UndoCommandMove(*oldMoveSplinePath, *newMoveSplinePath);
|
||||||
|
|
||||||
|
oldMoveSplinePath.clear();
|
||||||
|
newMoveSplinePath.clear();
|
||||||
|
|
||||||
|
moved = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -117,17 +117,26 @@ protected:
|
||||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
||||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||||
virtual void RefreshCtrlPoints() Q_DECL_OVERRIDE;
|
virtual void RefreshCtrlPoints() Q_DECL_OVERRIDE;
|
||||||
|
private slots:
|
||||||
|
void CurveReleased();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VToolSplinePath)
|
Q_DISABLE_COPY(VToolSplinePath)
|
||||||
QPointF oldPosition;
|
QPointF oldPosition;
|
||||||
int splIndex;
|
int splIndex;
|
||||||
|
|
||||||
|
bool moved;
|
||||||
|
QSharedPointer<VSplinePath> oldMoveSplinePath;
|
||||||
|
QSharedPointer<VSplinePath> newMoveSplinePath;
|
||||||
|
|
||||||
VToolSplinePath(const VToolSplinePathInitData &initData, QGraphicsItem *parent = nullptr);
|
VToolSplinePath(const VToolSplinePathInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
|
|
||||||
bool IsMovable(int index) const;
|
bool IsMovable(int index) const;
|
||||||
static void AddPathPoint(VAbstractPattern *doc, QDomElement &domElement, const VSplinePoint &splPoint);
|
static void AddPathPoint(VAbstractPattern *doc, QDomElement &domElement, const VSplinePoint &splPoint);
|
||||||
void UpdateControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) const;
|
void UpdateControlPoints(const VSpline &spl, QSharedPointer<VSplinePath> &splPath,
|
||||||
|
qint32 indexSpline) const;
|
||||||
void SetSplinePathAttributes(QDomElement &domElement, const VSplinePath &path);
|
void SetSplinePathAttributes(QDomElement &domElement, const VSplinePath &path);
|
||||||
|
|
||||||
|
void UndoCommandMove(const VSplinePath &oldPath, const VSplinePath &newPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLSPLINEPATH_H
|
#endif // VTOOLSPLINEPATH_H
|
||||||
|
|
|
@ -41,10 +41,10 @@
|
||||||
#include "vundocommand.h"
|
#include "vundocommand.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
MoveSpline::MoveSpline(VAbstractPattern *doc, const VSpline *oldSpl, const VSpline &newSpl, const quint32 &id,
|
MoveSpline::MoveSpline(VAbstractPattern *doc, const VSpline &oldSpl, const VSpline &newSpl, const quint32 &id,
|
||||||
QUndoCommand *parent)
|
QUndoCommand *parent)
|
||||||
: VUndoCommand(QDomElement(), doc, parent),
|
: VUndoCommand(QDomElement(), doc, parent),
|
||||||
oldSpline(*oldSpl),
|
oldSpline(oldSpl),
|
||||||
newSpline(newSpl),
|
newSpline(newSpl),
|
||||||
scene(qApp->getCurrentScene())
|
scene(qApp->getCurrentScene())
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,7 +44,7 @@ class MoveSpline : public VUndoCommand
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
MoveSpline(VAbstractPattern *doc, const VSpline *oldSpl, const VSpline &newSpl, const quint32 &id,
|
MoveSpline(VAbstractPattern *doc, const VSpline &oldSpl, const VSpline &newSpl, const quint32 &id,
|
||||||
QUndoCommand *parent = nullptr);
|
QUndoCommand *parent = nullptr);
|
||||||
virtual ~MoveSpline() Q_DECL_OVERRIDE;
|
virtual ~MoveSpline() Q_DECL_OVERRIDE;
|
||||||
virtual void undo() Q_DECL_OVERRIDE;
|
virtual void undo() Q_DECL_OVERRIDE;
|
||||||
|
|
|
@ -234,6 +234,7 @@ void VControlPointSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (freeAngle || freeLength)
|
if (freeAngle || freeLength)
|
||||||
{
|
{
|
||||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||||
|
emit Released();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VScenePoint::mouseReleaseEvent(event);
|
VScenePoint::mouseReleaseEvent(event);
|
||||||
|
|
|
@ -74,6 +74,7 @@ signals:
|
||||||
* @param event context menu event.
|
* @param event context menu event.
|
||||||
*/
|
*/
|
||||||
void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
|
void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
|
||||||
|
void Released();
|
||||||
public slots:
|
public slots:
|
||||||
void RefreshCtrlPoint(const qint32 &indexSpline, SplinePointPosition pos, const QPointF &controlPoint,
|
void RefreshCtrlPoint(const qint32 &indexSpline, SplinePointPosition pos, const QPointF &controlPoint,
|
||||||
const QPointF &splinePoint, bool freeAngle = true, bool freeLength = true);
|
const QPointF &splinePoint, bool freeAngle = true, bool freeLength = true);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user