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.
|
||||
- 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.
|
||||
- [#765] New feature. Free curve mode.
|
||||
|
||||
# Version 0.5.1
|
||||
- [#683] Tool Seam allowance's dialog is off screen on small resolutions.
|
||||
|
|
|
@ -108,6 +108,8 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
|
|||
settings->SetConfirmFormatRewriting(true);
|
||||
});
|
||||
|
||||
ui->checkBoxFreeCurve->setChecked(qApp->ValentinaSettings()->IsFreeCurveMode());
|
||||
|
||||
//----------------------- Toolbar
|
||||
ui->toolBarStyleCheck->setChecked(qApp->ValentinaSettings()->GetToolBarStyle());
|
||||
}
|
||||
|
@ -132,6 +134,7 @@ void PreferencesConfigurationPage::Apply()
|
|||
|
||||
settings->SetOsSeparator(ui->osOptionCheck->isChecked());
|
||||
settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked());
|
||||
settings->SetFreeCurveMode(ui->checkBoxFreeCurve->isChecked());
|
||||
|
||||
if (m_langChanged || m_systemChanged)
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>501</width>
|
||||
<height>559</height>
|
||||
<height>582</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -187,6 +187,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -61,6 +61,7 @@ const QString settingConfigurationUnit = QStringLiteral("confi
|
|||
const QString settingConfigurationConfirmItemDeletion = QStringLiteral("configuration/confirm_item_deletion");
|
||||
const QString settingConfigurationConfirmFormatRewriting = QStringLiteral("configuration/confirm_format_rewriting");
|
||||
const QString settingConfigurationToolBarStyle = QStringLiteral("configuration/tool_bar_style");
|
||||
const QString settingConfigurationFreeCurveMode = QStringLiteral("configuration/freeCurveMode");
|
||||
|
||||
const QString settingPatternUndo = QStringLiteral("pattern/undo");
|
||||
const QString settingPatternForbidFlipping = QStringLiteral("pattern/forbidFlipping");
|
||||
|
@ -478,6 +479,18 @@ void VCommonSettings::SetToolBarStyle(const bool &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
|
||||
{
|
||||
|
|
|
@ -99,6 +99,9 @@ public:
|
|||
bool GetToolBarStyle() const;
|
||||
void SetToolBarStyle(const bool &value);
|
||||
|
||||
bool IsFreeCurveMode() const;
|
||||
void SetFreeCurveMode(bool value);
|
||||
|
||||
int GetUndoCount() const;
|
||||
void SetUndoCount(const int &value);
|
||||
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
#include "../vgeometry/vabstractcurve.h"
|
||||
#include "../vgeometry/vgobject.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../vgeometry/vspline.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vmisc/vmath.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
|
@ -79,7 +78,10 @@ const QString VToolSpline::OldToolType = QStringLiteral("simple");
|
|||
*/
|
||||
VToolSpline::VToolSpline(VToolSplineInitData initData, QGraphicsItem *parent)
|
||||
: VAbstractSpline(initData.doc, initData.data, initData.id, parent),
|
||||
oldPosition()
|
||||
oldPosition(),
|
||||
moved(false),
|
||||
oldMoveSpline(),
|
||||
newMoveSpline()
|
||||
{
|
||||
sceneType = SceneObject::Spline;
|
||||
|
||||
|
@ -88,6 +90,16 @@ VToolSpline::VToolSpline(VToolSplineInitData initData, QGraphicsItem *parent)
|
|||
|
||||
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 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->GetP1()),
|
||||
freeAngle1, freeLength1, this);
|
||||
connect(controlPoint1, &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSpline::ControlPointChangePosition);
|
||||
connect(this, &VToolSpline::setEnabledPoint, controlPoint1, &VControlPointSpline::setEnabledPoint);
|
||||
connect(controlPoint1, &VControlPointSpline::ShowContextMenu, this, &VToolSpline::contextMenuEvent);
|
||||
controlPoints.append(controlPoint1);
|
||||
InitControlPoint(controlPoint1);
|
||||
|
||||
const bool freeAngle2 = qmu::QmuTokenParser::IsSingle(spl->GetEndAngleFormula());
|
||||
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->GetP4()),
|
||||
freeAngle2, freeLength2, this);
|
||||
connect(controlPoint2, &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSpline::ControlPointChangePosition);
|
||||
connect(this, &VToolSpline::setEnabledPoint, controlPoint2, &VControlPointSpline::setEnabledPoint);
|
||||
connect(controlPoint2, &VControlPointSpline::ShowContextMenu, this, &VToolSpline::contextMenuEvent);
|
||||
controlPoints.append(controlPoint2);
|
||||
InitControlPoint(controlPoint2);
|
||||
|
||||
ShowHandles(false);
|
||||
|
||||
|
@ -267,11 +271,30 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp
|
|||
{
|
||||
Q_UNUSED(indexSpline)
|
||||
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);
|
||||
|
||||
MoveSpline *moveSpl = new MoveSpline(doc, spline.data(), spl, m_id);
|
||||
connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
qApp->getUndoStack()->push(moveSpl);
|
||||
if (not qApp->Settings()->IsFreeCurveMode())
|
||||
{
|
||||
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())
|
||||
{
|
||||
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.
|
||||
|
||||
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);
|
||||
|
||||
if (qFloor(t) == -1)
|
||||
|
@ -409,11 +441,22 @@ void VToolSpline::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
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);
|
||||
connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
qApp->getUndoStack()->push(moveSpl);
|
||||
if (not qApp->Settings()->IsFreeCurveMode())
|
||||
{
|
||||
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
|
||||
// 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)
|
||||
{
|
||||
|
@ -598,3 +655,11 @@ void VToolSpline::SetSplineAttributes(QDomElement &domElement, const VSpline &sp
|
|||
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 "../ifc/xml/vabstractpattern.h"
|
||||
#include "vabstractspline.h"
|
||||
#include "../vgeometry/vspline.h"
|
||||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
|
@ -105,14 +106,22 @@ protected:
|
|||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||
virtual void RefreshCtrlPoints() Q_DECL_OVERRIDE;
|
||||
private slots:
|
||||
void CurveReleased();
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolSpline)
|
||||
QPointF oldPosition;
|
||||
|
||||
bool moved;
|
||||
QSharedPointer<VSpline> oldMoveSpline;
|
||||
QSharedPointer<VSpline> newMoveSpline;
|
||||
|
||||
VToolSpline (VToolSplineInitData initData, QGraphicsItem *parent = nullptr );
|
||||
|
||||
bool IsMovable() const;
|
||||
void SetSplineAttributes(QDomElement &domElement, const VSpline &spl);
|
||||
|
||||
void UndoCommandMove(const VSpline &oldSpl, const VSpline &newSpl);
|
||||
};
|
||||
|
||||
#endif // VTOOLSPLINE_H
|
||||
|
|
|
@ -85,13 +85,25 @@ const QString VToolSplinePath::OldToolType = QStringLiteral("path");
|
|||
VToolSplinePath::VToolSplinePath(const VToolSplinePathInitData &initData, QGraphicsItem *parent)
|
||||
: VAbstractSpline(initData.doc, initData.data, initData.id, parent),
|
||||
oldPosition(),
|
||||
splIndex(-1)
|
||||
splIndex(-1),
|
||||
moved(false),
|
||||
oldMoveSplinePath(),
|
||||
newMoveSplinePath()
|
||||
{
|
||||
sceneType = SceneObject::SplinePath;
|
||||
|
||||
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||
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);
|
||||
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.GetP1()),
|
||||
freeAngle1, freeLength1, this);
|
||||
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSplinePath::ControlPointChangePosition);
|
||||
connect(this, &VToolSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint);
|
||||
connect(controlPoint, &VControlPointSpline::ShowContextMenu, this, &VToolSplinePath::contextMenuEvent);
|
||||
controlPoints.append(controlPoint);
|
||||
InitControlPoint(controlPoint);
|
||||
|
||||
const bool freeAngle2 = qmu::QmuTokenParser::IsSingle(spl.GetEndAngleFormula());
|
||||
const bool freeLength2 = qmu::QmuTokenParser::IsSingle(spl.GetC2LengthFormula());
|
||||
|
||||
controlPoint = new VControlPointSpline(i, SplinePointPosition::LastPoint, static_cast<QPointF>(spl.GetP3()),
|
||||
static_cast<QPointF>(spl.GetP4()), freeAngle2, freeLength2, this);
|
||||
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSplinePath::ControlPointChangePosition);
|
||||
connect(this, &VToolSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint);
|
||||
connect(controlPoint, &VControlPointSpline::ShowContextMenu, this, &VToolSplinePath::contextMenuEvent);
|
||||
controlPoints.append(controlPoint);
|
||||
InitControlPoint(controlPoint);
|
||||
}
|
||||
|
||||
ShowHandles(false);
|
||||
|
@ -258,14 +262,34 @@ VToolSplinePath *VToolSplinePath::Create(VToolSplinePathInitData &initData)
|
|||
void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position,
|
||||
const QPointF &pos)
|
||||
{
|
||||
const VSplinePath oldSplPath = *VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
||||
VSplinePath newSplPath = oldSplPath;
|
||||
const VSpline spl = CorrectedSpline(newSplPath.GetSpline(indexSpline), position, pos);
|
||||
const QSharedPointer<VSplinePath> oldSplPath = VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
||||
|
||||
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);
|
||||
|
||||
MoveSplinePath *moveSplPath = new MoveSplinePath(doc, oldSplPath, newSplPath, m_id);
|
||||
connect(moveSplPath, &VUndoCommand::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
qApp->getUndoStack()->push(moveSplPath);
|
||||
if (not qApp->Settings()->IsFreeCurveMode())
|
||||
{
|
||||
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 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.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.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);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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.
|
||||
|
@ -491,6 +524,8 @@ void VToolSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
{
|
||||
oldPosition = event->scenePos();
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
|
||||
CurveReleased();
|
||||
}
|
||||
}
|
||||
VAbstractSpline::mouseReleaseEvent(event);
|
||||
|
@ -505,10 +540,17 @@ void VToolSplinePath::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
if (IsMovable(splIndex))
|
||||
{
|
||||
VSplinePath oldSplPath = *VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
||||
VSplinePath newSplPath = oldSplPath;
|
||||
const auto oldSplPath = VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
||||
|
||||
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);
|
||||
|
||||
if (qFloor(t) == -1)
|
||||
|
@ -549,11 +591,22 @@ void VToolSplinePath::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
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);
|
||||
connect(moveSplPath, &VUndoCommand::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
qApp->getUndoStack()->push(moveSplPath);
|
||||
if (not qApp->Settings()->IsFreeCurveMode())
|
||||
{
|
||||
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
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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 SetVisualization() Q_DECL_OVERRIDE;
|
||||
virtual void RefreshCtrlPoints() Q_DECL_OVERRIDE;
|
||||
private slots:
|
||||
void CurveReleased();
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolSplinePath)
|
||||
QPointF oldPosition;
|
||||
int splIndex;
|
||||
|
||||
bool moved;
|
||||
QSharedPointer<VSplinePath> oldMoveSplinePath;
|
||||
QSharedPointer<VSplinePath> newMoveSplinePath;
|
||||
|
||||
VToolSplinePath(const VToolSplinePathInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
|
||||
bool IsMovable(int index) const;
|
||||
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 UndoCommandMove(const VSplinePath &oldPath, const VSplinePath &newPath);
|
||||
};
|
||||
|
||||
#endif // VTOOLSPLINEPATH_H
|
||||
|
|
|
@ -41,10 +41,10 @@
|
|||
#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)
|
||||
: VUndoCommand(QDomElement(), doc, parent),
|
||||
oldSpline(*oldSpl),
|
||||
oldSpline(oldSpl),
|
||||
newSpline(newSpl),
|
||||
scene(qApp->getCurrentScene())
|
||||
{
|
||||
|
|
|
@ -44,7 +44,7 @@ class MoveSpline : public VUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
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);
|
||||
virtual ~MoveSpline() Q_DECL_OVERRIDE;
|
||||
virtual void undo() Q_DECL_OVERRIDE;
|
||||
|
|
|
@ -234,6 +234,7 @@ void VControlPointSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
if (freeAngle || freeLength)
|
||||
{
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
emit Released();
|
||||
}
|
||||
}
|
||||
VScenePoint::mouseReleaseEvent(event);
|
||||
|
|
|
@ -74,6 +74,7 @@ signals:
|
|||
* @param event context menu event.
|
||||
*/
|
||||
void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
|
||||
void Released();
|
||||
public slots:
|
||||
void RefreshCtrlPoint(const qint32 &indexSpline, SplinePointPosition pos, const QPointF &controlPoint,
|
||||
const QPointF &splinePoint, bool freeAngle = true, bool freeLength = true);
|
||||
|
|
Loading…
Reference in New Issue
Block a user