Moving labels and curves did not call resizing scene.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-05-20 15:20:08 +03:00
parent 7aca6d8179
commit b05da647fe
11 changed files with 37 additions and 17 deletions

View File

@ -247,7 +247,7 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp
const QSharedPointer<VSpline> spline = VAbstractTool::data.GeometricObject<VSpline>(id); const QSharedPointer<VSpline> spline = VAbstractTool::data.GeometricObject<VSpline>(id);
const VSpline spl = CorrectedSpline(*spline, position, pos); 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); connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
qApp->getUndoStack()->push(moveSpl); qApp->getUndoStack()->push(moveSpl);
} }
@ -407,7 +407,7 @@ void VToolSpline::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
VSpline spl = VSpline(spline->GetP1(), p2, p3, spline->GetP4()); 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); connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
qApp->getUndoStack()->push(moveSpl); qApp->getUndoStack()->push(moveSpl);

View File

@ -230,7 +230,7 @@ void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, cons
const VSpline spl = CorrectedSpline(newSplPath.GetSpline(indexSpline), position, pos); const VSpline spl = CorrectedSpline(newSplPath.GetSpline(indexSpline), position, pos);
UpdateControlPoints(spl, newSplPath, indexSpline); 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); connect(moveSplPath, &VUndoCommand::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
qApp->getUndoStack()->push(moveSplPath); qApp->getUndoStack()->push(moveSplPath);
} }
@ -521,7 +521,7 @@ void VToolSplinePath::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
UpdateControlPoints(spl, newSplPath, splIndex); 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); connect(moveSplPath, &VUndoCommand::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
qApp->getUndoStack()->push(moveSplPath); qApp->getUndoStack()->push(moveSplPath);

View File

@ -376,7 +376,7 @@ QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const
// value - this is new position. // value - this is new position.
const QPointF newPos = value.toPointF(); 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); connect(moveDet, &MoveDetail::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
qApp->getUndoStack()->push(moveDet); qApp->getUndoStack()->push(moveDet);

View File

@ -27,6 +27,8 @@
*************************************************************************/ *************************************************************************/
#include "moveabstractlabel.h" #include "moveabstractlabel.h"
#include "../vwidgets/vmaingraphicsview.h"
#include "../vmisc/vabstractapplication.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
MoveAbstractLabel::MoveAbstractLabel(VAbstractPattern *doc, quint32 pointId, double x, double y, 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_oldMy(0.0),
m_newMx(x), m_newMx(x),
m_newMy(y), m_newMy(y),
m_isRedo(false) m_isRedo(false),
m_scene(qApp->getCurrentScene())
{ {
nodeId = pointId; nodeId = pointId;
qCDebug(vUndo, "Point id %u", nodeId); qCDebug(vUndo, "Point id %u", nodeId);
@ -56,6 +59,7 @@ void MoveAbstractLabel::undo()
qCDebug(vUndo, "Undo."); qCDebug(vUndo, "Undo.");
Do(m_oldMx, m_oldMy); Do(m_oldMx, m_oldMy);
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
m_isRedo = true; m_isRedo = true;
emit ChangePosition(nodeId, m_oldMx, m_oldMy); emit ChangePosition(nodeId, m_oldMx, m_oldMy);
} }
@ -66,6 +70,7 @@ void MoveAbstractLabel::redo()
qCDebug(vUndo, "Redo."); qCDebug(vUndo, "Redo.");
Do(m_newMx, m_newMy); Do(m_newMx, m_newMy);
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
if (m_isRedo) if (m_isRedo)
{ {
emit ChangePosition(nodeId, m_newMx, m_newMy); emit ChangePosition(nodeId, m_newMx, m_newMy);

View File

@ -31,6 +31,9 @@
#include "../vundocommand.h" #include "../vundocommand.h"
class QGraphicsScene;
class QGraphicsView;
class MoveAbstractLabel : public VUndoCommand class MoveAbstractLabel : public VUndoCommand
{ {
Q_OBJECT Q_OBJECT
@ -53,6 +56,8 @@ protected:
double m_newMx; double m_newMx;
double m_newMy; double m_newMy;
bool m_isRedo; bool m_isRedo;
//Need for resizing scene rect
QGraphicsScene *m_scene;
virtual void Do(double mx, double my)=0; virtual void Do(double mx, double my)=0;
private: private:

View File

@ -28,15 +28,15 @@
#include "movedetail.h" #include "movedetail.h"
#include "../tools/vabstracttool.h" #include "../tools/vabstracttool.h"
#include "../../vwidgets/vmaingraphicsview.h" #include "../vwidgets/vmaingraphicsview.h"
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QDomElement> #include <QDomElement>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
MoveDetail::MoveDetail(VAbstractPattern *doc, const double &x, const double &y, const quint32 &id, MoveDetail::MoveDetail(VAbstractPattern *doc, const double &x, const double &y, const quint32 &id,
QGraphicsScene *scene, QUndoCommand *parent) QUndoCommand *parent)
: VUndoCommand(QDomElement(), doc, parent), oldX(0.0), oldY(0.0), newX(x), newY(y), scene(scene) : VUndoCommand(QDomElement(), doc, parent), oldX(0.0), oldY(0.0), newX(x), newY(y), scene(qApp->getCurrentScene())
{ {
setText(QObject::tr("move detail")); setText(QObject::tr("move detail"));
nodeId = id; nodeId = id;

View File

@ -37,7 +37,7 @@ class MoveDetail : public VUndoCommand
{ {
Q_OBJECT Q_OBJECT
public: 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); QUndoCommand *parent = 0);
virtual ~MoveDetail() Q_DECL_OVERRIDE; virtual ~MoveDetail() Q_DECL_OVERRIDE;
virtual void undo() Q_DECL_OVERRIDE; virtual void undo() Q_DECL_OVERRIDE;

View File

@ -28,15 +28,18 @@
#include "movespline.h" #include "movespline.h"
#include "../tools/vabstracttool.h" #include "../tools/vabstracttool.h"
#include "../../vwidgets/vmaingraphicsview.h" #include "../vwidgets/vmaingraphicsview.h"
#include <QDomElement> #include <QDomElement>
#include <QGraphicsView> #include <QGraphicsView>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
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,
QGraphicsScene *scene, QUndoCommand *parent) QUndoCommand *parent)
: VUndoCommand(QDomElement(), doc, parent), oldSpline(*oldSpl), newSpline(newSpl), scene(scene) : VUndoCommand(QDomElement(), doc, parent),
oldSpline(*oldSpl),
newSpline(newSpl),
scene(qApp->getCurrentScene())
{ {
setText(tr("move spline")); setText(tr("move spline"));
nodeId = id; nodeId = id;
@ -54,6 +57,7 @@ void MoveSpline::undo()
qCDebug(vUndo, "Undo."); qCDebug(vUndo, "Undo.");
Do(oldSpline); Do(oldSpline);
VMainGraphicsView::NewSceneRect(scene, qApp->getSceneView());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -62,6 +66,7 @@ void MoveSpline::redo()
qCDebug(vUndo, "Redo."); qCDebug(vUndo, "Redo.");
Do(newSpline); Do(newSpline);
VMainGraphicsView::NewSceneRect(scene, qApp->getSceneView());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -39,7 +39,7 @@ class MoveSpline : public VUndoCommand
Q_OBJECT Q_OBJECT
public: public:
MoveSpline(VAbstractPattern *doc, const VSpline *oldSpl, const VSpline &spl, const quint32 &id, 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 ~MoveSpline() Q_DECL_OVERRIDE;
virtual void undo() Q_DECL_OVERRIDE; virtual void undo() Q_DECL_OVERRIDE;
virtual void redo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE;

View File

@ -32,8 +32,11 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
MoveSplinePath::MoveSplinePath(VAbstractPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath, MoveSplinePath::MoveSplinePath(VAbstractPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath,
const quint32 &id, QGraphicsScene *scene, QUndoCommand *parent) const quint32 &id, QUndoCommand *parent)
: VUndoCommand(QDomElement(), doc, parent), oldSplinePath(oldSplPath), newSplinePath(newSplPath), scene(scene) : VUndoCommand(QDomElement(), doc, parent),
oldSplinePath(oldSplPath),
newSplinePath(newSplPath),
scene(qApp->getCurrentScene())
{ {
setText(tr("move spline path")); setText(tr("move spline path"));
nodeId = id; nodeId = id;
@ -51,6 +54,7 @@ void MoveSplinePath::undo()
qCDebug(vUndo, "Undo."); qCDebug(vUndo, "Undo.");
Do(oldSplinePath); Do(oldSplinePath);
VMainGraphicsView::NewSceneRect(scene, qApp->getSceneView());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -59,6 +63,7 @@ void MoveSplinePath::redo()
qCDebug(vUndo, "Redo."); qCDebug(vUndo, "Redo.");
Do(newSplinePath); Do(newSplinePath);
VMainGraphicsView::NewSceneRect(scene, qApp->getSceneView());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -39,7 +39,7 @@ class MoveSplinePath : public VUndoCommand
Q_OBJECT Q_OBJECT
public: public:
MoveSplinePath(VAbstractPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath, 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 ~MoveSplinePath() Q_DECL_OVERRIDE;
virtual void undo() Q_DECL_OVERRIDE; virtual void undo() Q_DECL_OVERRIDE;
virtual void redo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE;