From b05da647fe35c5545ab3e68c78157bbcd5f2b624 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 20 May 2016 15:20:08 +0300 Subject: [PATCH] Moving labels and curves did not call resizing scene. --HG-- branch : develop --- .../vtools/tools/drawTools/toolcurve/vtoolspline.cpp | 4 ++-- .../tools/drawTools/toolcurve/vtoolsplinepath.cpp | 4 ++-- src/libs/vtools/tools/vtooldetail.cpp | 2 +- .../vtools/undocommands/label/moveabstractlabel.cpp | 7 ++++++- .../vtools/undocommands/label/moveabstractlabel.h | 5 +++++ src/libs/vtools/undocommands/movedetail.cpp | 6 +++--- src/libs/vtools/undocommands/movedetail.h | 2 +- src/libs/vtools/undocommands/movespline.cpp | 11 ++++++++--- src/libs/vtools/undocommands/movespline.h | 2 +- src/libs/vtools/undocommands/movesplinepath.cpp | 9 +++++++-- src/libs/vtools/undocommands/movesplinepath.h | 2 +- 11 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp index b074d6260..71404d2b5 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp @@ -247,7 +247,7 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp const QSharedPointer spline = VAbstractTool::data.GeometricObject(id); const VSpline spl = CorrectedSpline(*spline, position, pos); - MoveSpline *moveSpl = new MoveSpline(doc, spline.data(), spl, id, this->scene()); + MoveSpline *moveSpl = new MoveSpline(doc, spline.data(), spl, id); connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); qApp->getUndoStack()->push(moveSpl); } @@ -407,7 +407,7 @@ void VToolSpline::mouseMoveEvent(QGraphicsSceneMouseEvent *event) VSpline spl = VSpline(spline->GetP1(), p2, p3, spline->GetP4()); - MoveSpline *moveSpl = new MoveSpline(doc, spline.data(), spl, id, this->scene()); + MoveSpline *moveSpl = new MoveSpline(doc, spline.data(), spl, id); connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); qApp->getUndoStack()->push(moveSpl); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp index 917b2757c..1ebb410b0 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp @@ -230,7 +230,7 @@ void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, cons const VSpline spl = CorrectedSpline(newSplPath.GetSpline(indexSpline), position, pos); UpdateControlPoints(spl, newSplPath, indexSpline); - MoveSplinePath *moveSplPath = new MoveSplinePath(doc, oldSplPath, newSplPath, id, this->scene()); + MoveSplinePath *moveSplPath = new MoveSplinePath(doc, oldSplPath, newSplPath, id); connect(moveSplPath, &VUndoCommand::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); qApp->getUndoStack()->push(moveSplPath); } @@ -521,7 +521,7 @@ void VToolSplinePath::mouseMoveEvent(QGraphicsSceneMouseEvent *event) UpdateControlPoints(spl, newSplPath, splIndex); - MoveSplinePath *moveSplPath = new MoveSplinePath(doc, oldSplPath, newSplPath, id, this->scene()); + MoveSplinePath *moveSplPath = new MoveSplinePath(doc, oldSplPath, newSplPath, id); connect(moveSplPath, &VUndoCommand::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); qApp->getUndoStack()->push(moveSplPath); diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index 8938d0904..ba0c053ee 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -376,7 +376,7 @@ QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const // value - this is new position. const QPointF newPos = value.toPointF(); - MoveDetail *moveDet = new MoveDetail(doc, newPos.x(), newPos.y(), id, scene()); + MoveDetail *moveDet = new MoveDetail(doc, newPos.x(), newPos.y(), id); connect(moveDet, &MoveDetail::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); qApp->getUndoStack()->push(moveDet); diff --git a/src/libs/vtools/undocommands/label/moveabstractlabel.cpp b/src/libs/vtools/undocommands/label/moveabstractlabel.cpp index c44a1868d..1ba5c0d39 100644 --- a/src/libs/vtools/undocommands/label/moveabstractlabel.cpp +++ b/src/libs/vtools/undocommands/label/moveabstractlabel.cpp @@ -27,6 +27,8 @@ *************************************************************************/ #include "moveabstractlabel.h" +#include "../vwidgets/vmaingraphicsview.h" +#include "../vmisc/vabstractapplication.h" //--------------------------------------------------------------------------------------------------------------------- MoveAbstractLabel::MoveAbstractLabel(VAbstractPattern *doc, quint32 pointId, double x, double y, @@ -36,7 +38,8 @@ MoveAbstractLabel::MoveAbstractLabel(VAbstractPattern *doc, quint32 pointId, dou m_oldMy(0.0), m_newMx(x), m_newMy(y), - m_isRedo(false) + m_isRedo(false), + m_scene(qApp->getCurrentScene()) { nodeId = pointId; qCDebug(vUndo, "Point id %u", nodeId); @@ -56,6 +59,7 @@ void MoveAbstractLabel::undo() qCDebug(vUndo, "Undo."); Do(m_oldMx, m_oldMy); + VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView()); m_isRedo = true; emit ChangePosition(nodeId, m_oldMx, m_oldMy); } @@ -66,6 +70,7 @@ void MoveAbstractLabel::redo() qCDebug(vUndo, "Redo."); Do(m_newMx, m_newMy); + VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView()); if (m_isRedo) { emit ChangePosition(nodeId, m_newMx, m_newMy); diff --git a/src/libs/vtools/undocommands/label/moveabstractlabel.h b/src/libs/vtools/undocommands/label/moveabstractlabel.h index da52003f9..5aa885955 100644 --- a/src/libs/vtools/undocommands/label/moveabstractlabel.h +++ b/src/libs/vtools/undocommands/label/moveabstractlabel.h @@ -31,6 +31,9 @@ #include "../vundocommand.h" +class QGraphicsScene; +class QGraphicsView; + class MoveAbstractLabel : public VUndoCommand { Q_OBJECT @@ -53,6 +56,8 @@ protected: double m_newMx; double m_newMy; bool m_isRedo; + //Need for resizing scene rect + QGraphicsScene *m_scene; virtual void Do(double mx, double my)=0; private: diff --git a/src/libs/vtools/undocommands/movedetail.cpp b/src/libs/vtools/undocommands/movedetail.cpp index 2b809e8b3..a7390230a 100644 --- a/src/libs/vtools/undocommands/movedetail.cpp +++ b/src/libs/vtools/undocommands/movedetail.cpp @@ -28,15 +28,15 @@ #include "movedetail.h" #include "../tools/vabstracttool.h" -#include "../../vwidgets/vmaingraphicsview.h" +#include "../vwidgets/vmaingraphicsview.h" #include #include //--------------------------------------------------------------------------------------------------------------------- MoveDetail::MoveDetail(VAbstractPattern *doc, const double &x, const double &y, const quint32 &id, - QGraphicsScene *scene, QUndoCommand *parent) - : VUndoCommand(QDomElement(), doc, parent), oldX(0.0), oldY(0.0), newX(x), newY(y), scene(scene) + QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), oldX(0.0), oldY(0.0), newX(x), newY(y), scene(qApp->getCurrentScene()) { setText(QObject::tr("move detail")); nodeId = id; diff --git a/src/libs/vtools/undocommands/movedetail.h b/src/libs/vtools/undocommands/movedetail.h index a8e306c4d..d5d9ebdd1 100644 --- a/src/libs/vtools/undocommands/movedetail.h +++ b/src/libs/vtools/undocommands/movedetail.h @@ -37,7 +37,7 @@ class MoveDetail : public VUndoCommand { Q_OBJECT public: - MoveDetail(VAbstractPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, + MoveDetail(VAbstractPattern *doc, const double &x, const double &y, const quint32 &id, QUndoCommand *parent = 0); virtual ~MoveDetail() Q_DECL_OVERRIDE; virtual void undo() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/undocommands/movespline.cpp b/src/libs/vtools/undocommands/movespline.cpp index 6d36394aa..4c1a4702d 100644 --- a/src/libs/vtools/undocommands/movespline.cpp +++ b/src/libs/vtools/undocommands/movespline.cpp @@ -28,15 +28,18 @@ #include "movespline.h" #include "../tools/vabstracttool.h" -#include "../../vwidgets/vmaingraphicsview.h" +#include "../vwidgets/vmaingraphicsview.h" #include #include //--------------------------------------------------------------------------------------------------------------------- MoveSpline::MoveSpline(VAbstractPattern *doc, const VSpline *oldSpl, const VSpline &newSpl, const quint32 &id, - QGraphicsScene *scene, QUndoCommand *parent) - : VUndoCommand(QDomElement(), doc, parent), oldSpline(*oldSpl), newSpline(newSpl), scene(scene) + QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), + oldSpline(*oldSpl), + newSpline(newSpl), + scene(qApp->getCurrentScene()) { setText(tr("move spline")); nodeId = id; @@ -54,6 +57,7 @@ void MoveSpline::undo() qCDebug(vUndo, "Undo."); Do(oldSpline); + VMainGraphicsView::NewSceneRect(scene, qApp->getSceneView()); } //--------------------------------------------------------------------------------------------------------------------- @@ -62,6 +66,7 @@ void MoveSpline::redo() qCDebug(vUndo, "Redo."); Do(newSpline); + VMainGraphicsView::NewSceneRect(scene, qApp->getSceneView()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/undocommands/movespline.h b/src/libs/vtools/undocommands/movespline.h index cce2787b1..fa067771d 100644 --- a/src/libs/vtools/undocommands/movespline.h +++ b/src/libs/vtools/undocommands/movespline.h @@ -39,7 +39,7 @@ class MoveSpline : public VUndoCommand Q_OBJECT public: MoveSpline(VAbstractPattern *doc, const VSpline *oldSpl, const VSpline &spl, const quint32 &id, - QGraphicsScene *scene, QUndoCommand *parent = 0); + QUndoCommand *parent = nullptr); virtual ~MoveSpline() Q_DECL_OVERRIDE; virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/undocommands/movesplinepath.cpp b/src/libs/vtools/undocommands/movesplinepath.cpp index f744fa770..7109bbc93 100644 --- a/src/libs/vtools/undocommands/movesplinepath.cpp +++ b/src/libs/vtools/undocommands/movesplinepath.cpp @@ -32,8 +32,11 @@ //--------------------------------------------------------------------------------------------------------------------- MoveSplinePath::MoveSplinePath(VAbstractPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath, - const quint32 &id, QGraphicsScene *scene, QUndoCommand *parent) - : VUndoCommand(QDomElement(), doc, parent), oldSplinePath(oldSplPath), newSplinePath(newSplPath), scene(scene) + const quint32 &id, QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), + oldSplinePath(oldSplPath), + newSplinePath(newSplPath), + scene(qApp->getCurrentScene()) { setText(tr("move spline path")); nodeId = id; @@ -51,6 +54,7 @@ void MoveSplinePath::undo() qCDebug(vUndo, "Undo."); Do(oldSplinePath); + VMainGraphicsView::NewSceneRect(scene, qApp->getSceneView()); } //--------------------------------------------------------------------------------------------------------------------- @@ -59,6 +63,7 @@ void MoveSplinePath::redo() qCDebug(vUndo, "Redo."); Do(newSplinePath); + VMainGraphicsView::NewSceneRect(scene, qApp->getSceneView()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/undocommands/movesplinepath.h b/src/libs/vtools/undocommands/movesplinepath.h index 2dd7a82a5..445b03c9b 100644 --- a/src/libs/vtools/undocommands/movesplinepath.h +++ b/src/libs/vtools/undocommands/movesplinepath.h @@ -39,7 +39,7 @@ class MoveSplinePath : public VUndoCommand Q_OBJECT public: MoveSplinePath(VAbstractPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath, - const quint32 &id, QGraphicsScene *scene, QUndoCommand *parent = 0); + const quint32 &id, QUndoCommand *parent = nullptr); virtual ~MoveSplinePath() Q_DECL_OVERRIDE; virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE;