Refactoring undocommands. Fix deletion node.
--HG-- branch : develop
This commit is contained in:
parent
d3624f7060
commit
d7dfcb8898
|
@ -183,7 +183,7 @@ void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, cons
|
||||||
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, this->scene());
|
||||||
connect(moveSplPath, &MoveSplinePath::NeedLiteParsing, doc, &VPattern::LiteParseTree);
|
connect(moveSplPath, &VUndoCommand::NeedLiteParsing, doc, &VPattern::LiteParseTree);
|
||||||
qApp->getUndoStack()->push(moveSplPath);
|
qApp->getUndoStack()->push(moveSplPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,10 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
AddDet::AddDet(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
AddDet::AddDet(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
||||||
: QObject(), QUndoCommand(parent), xml(xml), doc(doc), redoFlag(false)
|
: VUndoCommand(xml, doc, parent)
|
||||||
{
|
{
|
||||||
setText(tr("Add detail"));
|
setText(tr("Add detail"));
|
||||||
|
nodeId = doc->GetParametrId(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -47,7 +48,20 @@ void AddDet::undo()
|
||||||
QDomElement element;
|
QDomElement element;
|
||||||
if (doc->GetActivNodeElement(VPattern::TagDetails, element))
|
if (doc->GetActivNodeElement(VPattern::TagDetails, element))
|
||||||
{
|
{
|
||||||
element.removeChild(xml);
|
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||||
|
if (domElement.isElement())
|
||||||
|
{
|
||||||
|
if (element.removeChild(domElement).isNull())
|
||||||
|
{
|
||||||
|
qDebug()<<"Can't delete node";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug()<<"Can't get node by id = "<<nodeId<<Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -71,9 +85,5 @@ void AddDet::redo()
|
||||||
qDebug()<<"Can't find tag"<<VPattern::TagDetails<< Q_FUNC_INFO;
|
qDebug()<<"Can't find tag"<<VPattern::TagDetails<< Q_FUNC_INFO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (redoFlag)
|
RedoFullParsing();
|
||||||
{
|
|
||||||
emit NeedFullParsing();
|
|
||||||
}
|
|
||||||
redoFlag = true;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,11 @@
|
||||||
#ifndef ADDDET_H
|
#ifndef ADDDET_H
|
||||||
#define ADDDET_H
|
#define ADDDET_H
|
||||||
|
|
||||||
#include <QDomElement>
|
#include "vundocommand.h"
|
||||||
#include <QUndoCommand>
|
|
||||||
|
|
||||||
class VPattern;
|
class VPattern;
|
||||||
|
|
||||||
class AddDet : public QObject, public QUndoCommand
|
class AddDet : public VUndoCommand
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -44,13 +43,8 @@ public:
|
||||||
virtual void undo();
|
virtual void undo();
|
||||||
// cppcheck-suppress unusedFunction
|
// cppcheck-suppress unusedFunction
|
||||||
virtual void redo();
|
virtual void redo();
|
||||||
signals:
|
|
||||||
void NeedFullParsing();
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(AddDet)
|
Q_DISABLE_COPY(AddDet)
|
||||||
const QDomElement xml;
|
|
||||||
VPattern *doc;
|
|
||||||
bool redoFlag;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ADDDET_H
|
#endif // ADDDET_H
|
||||||
|
|
|
@ -31,9 +31,10 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
AddDetNode::AddDetNode(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
AddDetNode::AddDetNode(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
||||||
: QUndoCommand(parent), xml(xml), doc(doc)
|
: VUndoCommand(xml, doc, parent)
|
||||||
{
|
{
|
||||||
setText(QObject::tr("Add node"));
|
setText(QObject::tr("Add node"));
|
||||||
|
nodeId = doc->GetParametrId(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -46,7 +47,20 @@ void AddDetNode::undo()
|
||||||
QDomElement modelingElement;
|
QDomElement modelingElement;
|
||||||
if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement))
|
if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement))
|
||||||
{
|
{
|
||||||
modelingElement.removeChild(xml);
|
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||||
|
if (domElement.isElement())
|
||||||
|
{
|
||||||
|
if (modelingElement.removeChild(domElement).isNull())
|
||||||
|
{
|
||||||
|
qDebug()<<"Can't delete node";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug()<<"Can't get node by id = "<<nodeId<<Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,13 +29,11 @@
|
||||||
#ifndef ADDDETNODE_H
|
#ifndef ADDDETNODE_H
|
||||||
#define ADDDETNODE_H
|
#define ADDDETNODE_H
|
||||||
|
|
||||||
#include <QDomElement>
|
#include "vundocommand.h"
|
||||||
#include <QUndoCommand>
|
|
||||||
|
|
||||||
class VPattern;
|
class AddDetNode : public VUndoCommand
|
||||||
|
|
||||||
class AddDetNode : public QUndoCommand
|
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AddDetNode(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0);
|
AddDetNode(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0);
|
||||||
virtual ~AddDetNode();
|
virtual ~AddDetNode();
|
||||||
|
@ -43,8 +41,6 @@ public:
|
||||||
virtual void redo();
|
virtual void redo();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(AddDetNode)
|
Q_DISABLE_COPY(AddDetNode)
|
||||||
const QDomElement xml;
|
|
||||||
VPattern *doc;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ADDDETNODE_H
|
#endif // ADDDETNODE_H
|
||||||
|
|
|
@ -32,9 +32,8 @@
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
AddPatternPiece::AddPatternPiece(const QDomElement &xml, VPattern *doc, const QString &namePP, const QString &mPath,
|
AddPatternPiece::AddPatternPiece(const QDomElement &xml, VPattern *doc, const QString &namePP, const QString &mPath,
|
||||||
QUndoCommand *parent)
|
QUndoCommand *parent)
|
||||||
: QObject(), QUndoCommand(parent), xml(xml), doc(doc), namePP(namePP), redoFlag(false), mPath(mPath)
|
: VUndoCommand(xml, doc, parent), namePP(namePP), mPath(mPath)
|
||||||
{
|
{
|
||||||
SCASSERT(xml.isNull() == false);
|
|
||||||
SCASSERT(namePP.isEmpty() == false);
|
SCASSERT(namePP.isEmpty() == false);
|
||||||
SCASSERT(mPath.isEmpty() == false);
|
SCASSERT(mPath.isEmpty() == false);
|
||||||
setText(tr("Add pattern piece %1").arg(namePP));
|
setText(tr("Add pattern piece %1").arg(namePP));
|
||||||
|
@ -72,9 +71,5 @@ void AddPatternPiece::redo()
|
||||||
|
|
||||||
rootElement.appendChild(xml);
|
rootElement.appendChild(xml);
|
||||||
|
|
||||||
if (redoFlag)
|
RedoFullParsing();
|
||||||
{
|
|
||||||
emit NeedFullParsing();
|
|
||||||
}
|
|
||||||
redoFlag = true;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,9 @@
|
||||||
#ifndef ADDPATTERNPIECE_H
|
#ifndef ADDPATTERNPIECE_H
|
||||||
#define ADDPATTERNPIECE_H
|
#define ADDPATTERNPIECE_H
|
||||||
|
|
||||||
#include <QDomElement>
|
#include "vundocommand.h"
|
||||||
#include <QUndoCommand>
|
|
||||||
|
|
||||||
class VPattern;
|
class AddPatternPiece : public VUndoCommand
|
||||||
|
|
||||||
class AddPatternPiece : public QObject, public QUndoCommand
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -43,15 +40,9 @@ public:
|
||||||
virtual ~AddPatternPiece();
|
virtual ~AddPatternPiece();
|
||||||
virtual void undo();
|
virtual void undo();
|
||||||
virtual void redo();
|
virtual void redo();
|
||||||
signals:
|
|
||||||
void ClearScene();
|
|
||||||
void NeedFullParsing();
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(AddPatternPiece)
|
Q_DISABLE_COPY(AddPatternPiece)
|
||||||
const QDomElement xml;
|
|
||||||
VPattern *doc;
|
|
||||||
QString namePP;
|
QString namePP;
|
||||||
bool redoFlag;
|
|
||||||
QString mPath;
|
QString mPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,10 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
AddToCalc::AddToCalc(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
AddToCalc::AddToCalc(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
||||||
: QObject(), QUndoCommand(parent), xml(xml), doc(doc), nameActivDraw(doc->GetNameActivDraw()),
|
: VUndoCommand(xml, doc, parent), nameActivDraw(doc->GetNameActivDraw()), cursor(doc->getCursor())
|
||||||
cursor(doc->getCursor()), redoFlag(false)
|
|
||||||
{
|
{
|
||||||
setText(tr("Add object"));
|
setText(tr("Add object"));
|
||||||
|
nodeId = doc->GetParametrId(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -50,10 +50,19 @@ void AddToCalc::undo()
|
||||||
QDomElement calcElement;
|
QDomElement calcElement;
|
||||||
if (doc->GetActivNodeElement(VPattern::TagCalculation, calcElement))
|
if (doc->GetActivNodeElement(VPattern::TagCalculation, calcElement))
|
||||||
{
|
{
|
||||||
calcElement.removeChild(xml);
|
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||||
if (cursor > 0)
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->setCursor(0);
|
if (calcElement.removeChild(domElement).isNull())
|
||||||
|
{
|
||||||
|
qDebug()<<"Can't delete node";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug()<<"Can't get tool by id = "<<nodeId<<Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -61,6 +70,10 @@ void AddToCalc::undo()
|
||||||
qDebug()<<"Can't find tag Calculation"<< Q_FUNC_INFO;
|
qDebug()<<"Can't find tag Calculation"<< Q_FUNC_INFO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (cursor > 0)
|
||||||
|
{
|
||||||
|
doc->setCursor(0);
|
||||||
|
}
|
||||||
emit NeedFullParsing();
|
emit NeedFullParsing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,9 +110,5 @@ void AddToCalc::redo()
|
||||||
qDebug()<<"Can't find tag Calculation"<< Q_FUNC_INFO;
|
qDebug()<<"Can't find tag Calculation"<< Q_FUNC_INFO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (redoFlag)
|
RedoFullParsing();
|
||||||
{
|
|
||||||
emit NeedFullParsing();
|
|
||||||
}
|
|
||||||
redoFlag = true;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,9 @@
|
||||||
#ifndef ADDTOCALC_H
|
#ifndef ADDTOCALC_H
|
||||||
#define ADDTOCALC_H
|
#define ADDTOCALC_H
|
||||||
|
|
||||||
#include <QDomElement>
|
#include "vundocommand.h"
|
||||||
#include <QUndoCommand>
|
|
||||||
|
|
||||||
class VPattern;
|
class AddToCalc : public VUndoCommand
|
||||||
|
|
||||||
class AddToCalc : public QObject, public QUndoCommand
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -42,15 +39,10 @@ public:
|
||||||
virtual ~AddToCalc();
|
virtual ~AddToCalc();
|
||||||
virtual void undo();
|
virtual void undo();
|
||||||
virtual void redo();
|
virtual void redo();
|
||||||
signals:
|
|
||||||
void NeedFullParsing();
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(AddToCalc)
|
Q_DISABLE_COPY(AddToCalc)
|
||||||
const QDomElement xml;
|
const QString nameActivDraw;
|
||||||
VPattern *doc;
|
quint32 cursor;
|
||||||
const QString nameActivDraw;
|
|
||||||
quint32 cursor;
|
|
||||||
bool redoFlag;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ADDTOCALC_H
|
#endif // ADDTOCALC_H
|
||||||
|
|
|
@ -31,9 +31,10 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
AddUnionDetails::AddUnionDetails(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
AddUnionDetails::AddUnionDetails(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
||||||
: QObject(), QUndoCommand(parent), xml(xml), doc(doc), redoFlag(false)
|
: VUndoCommand(xml, doc, parent)
|
||||||
{
|
{
|
||||||
setText(tr("Add union details"));
|
setText(tr("Add union details"));
|
||||||
|
nodeId = doc->GetParametrId(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -46,7 +47,20 @@ void AddUnionDetails::undo()
|
||||||
QDomElement modelingElement;
|
QDomElement modelingElement;
|
||||||
if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement))
|
if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement))
|
||||||
{
|
{
|
||||||
modelingElement.removeChild(xml);
|
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||||
|
if (domElement.isElement())
|
||||||
|
{
|
||||||
|
if (modelingElement.removeChild(domElement).isNull())
|
||||||
|
{
|
||||||
|
qDebug()<<"Can't delete node";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug()<<"Can't get node by id = "<<nodeId<<Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -69,9 +83,5 @@ void AddUnionDetails::redo()
|
||||||
qDebug()<<"Can't find tag"<<VPattern::TagModeling<< Q_FUNC_INFO;
|
qDebug()<<"Can't find tag"<<VPattern::TagModeling<< Q_FUNC_INFO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (redoFlag)
|
RedoFullParsing();
|
||||||
{
|
|
||||||
emit NeedFullParsing();
|
|
||||||
}
|
|
||||||
redoFlag = true;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,9 @@
|
||||||
#ifndef ADDUNIONDETAILS_H
|
#ifndef ADDUNIONDETAILS_H
|
||||||
#define ADDUNIONDETAILS_H
|
#define ADDUNIONDETAILS_H
|
||||||
|
|
||||||
#include <QDomElement>
|
#include "vundocommand.h"
|
||||||
#include <QUndoCommand>
|
|
||||||
|
|
||||||
class VPattern;
|
class AddUnionDetails : public VUndoCommand
|
||||||
|
|
||||||
class AddUnionDetails : public QObject, public QUndoCommand
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -42,13 +39,8 @@ public:
|
||||||
virtual ~AddUnionDetails();
|
virtual ~AddUnionDetails();
|
||||||
virtual void undo();
|
virtual void undo();
|
||||||
virtual void redo();
|
virtual void redo();
|
||||||
signals:
|
|
||||||
void NeedFullParsing();
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(AddUnionDetails)
|
Q_DISABLE_COPY(AddUnionDetails)
|
||||||
const QDomElement xml;
|
|
||||||
VPattern *doc;
|
|
||||||
bool redoFlag;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ADDUNIONDETAILS_H
|
#endif // ADDUNIONDETAILS_H
|
||||||
|
|
|
@ -32,9 +32,10 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DeleteDetail::DeleteDetail(VPattern *doc, quint32 id, QUndoCommand *parent)
|
DeleteDetail::DeleteDetail(VPattern *doc, quint32 id, QUndoCommand *parent)
|
||||||
: QObject(), QUndoCommand(parent), xml(QDomElement()), doc(doc), detId(id), parentNode(QDomNode())
|
: VUndoCommand(xml, doc, parent), parentNode(QDomNode())
|
||||||
{
|
{
|
||||||
setText(tr("Delete tool"));
|
setText(tr("Delete tool"));
|
||||||
|
nodeId = id;
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
|
@ -43,7 +44,7 @@ DeleteDetail::DeleteDetail(VPattern *doc, quint32 id, QUndoCommand *parent)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't get detail by id = "<<detId<<Q_FUNC_INFO;
|
qDebug()<<"Can't get detail by id = "<<nodeId<<Q_FUNC_INFO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +63,7 @@ void DeleteDetail::undo()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DeleteDetail::redo()
|
void DeleteDetail::redo()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(detId));
|
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
parentNode.removeChild(domElement);
|
parentNode.removeChild(domElement);
|
||||||
|
@ -70,7 +71,7 @@ void DeleteDetail::redo()
|
||||||
//When UnionDetail delete detail we can't use FullParsing. So we hide detail on scene directly.
|
//When UnionDetail delete detail we can't use FullParsing. So we hide detail on scene directly.
|
||||||
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
||||||
SCASSERT(tools != nullptr);
|
SCASSERT(tools != nullptr);
|
||||||
VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(detId));
|
VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(nodeId));
|
||||||
SCASSERT(toolDet != nullptr);
|
SCASSERT(toolDet != nullptr);
|
||||||
toolDet->hide();
|
toolDet->hide();
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ void DeleteDetail::redo()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't get detail by id = "<<detId<<Q_FUNC_INFO;
|
qDebug()<<"Can't get detail by id = "<<nodeId<<Q_FUNC_INFO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,13 +29,10 @@
|
||||||
#ifndef DELETEDETAIL_H
|
#ifndef DELETEDETAIL_H
|
||||||
#define DELETEDETAIL_H
|
#define DELETEDETAIL_H
|
||||||
|
|
||||||
#include <QDomElement>
|
#include "vundocommand.h"
|
||||||
#include <QUndoCommand>
|
|
||||||
|
|
||||||
class VPattern;
|
|
||||||
class QGraphicsItem;
|
class QGraphicsItem;
|
||||||
|
|
||||||
class DeleteDetail : public QObject, public QUndoCommand
|
class DeleteDetail : public VUndoCommand
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -43,13 +40,8 @@ public:
|
||||||
virtual ~DeleteDetail();
|
virtual ~DeleteDetail();
|
||||||
virtual void undo();
|
virtual void undo();
|
||||||
virtual void redo();
|
virtual void redo();
|
||||||
signals:
|
|
||||||
void NeedFullParsing();
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DeleteDetail)
|
Q_DISABLE_COPY(DeleteDetail)
|
||||||
QDomElement xml;
|
|
||||||
VPattern *doc;
|
|
||||||
quint32 detId;
|
|
||||||
QDomNode parentNode;
|
QDomNode parentNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,15 +32,16 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DeletePatternPiece::DeletePatternPiece(VPattern *doc, const QString &namePP, QUndoCommand *parent)
|
DeletePatternPiece::DeletePatternPiece(VPattern *doc, const QString &namePP, QUndoCommand *parent)
|
||||||
: QObject(), QUndoCommand(parent), doc(doc), namePP(namePP), patternPiece(QDomElement()), mPath(QString()),
|
: VUndoCommand(QDomElement(), doc, parent), namePP(namePP), patternPiece(QDomElement()), mPath(QString()),
|
||||||
previousNode(QDomNode())
|
previousPPName(QString())
|
||||||
{
|
{
|
||||||
setText(tr("Delete pattern piece %1").arg(namePP));
|
setText(tr("Delete pattern piece %1").arg(namePP));
|
||||||
|
|
||||||
QDomElement patternP= doc->GetPPElement(namePP);
|
QDomElement patternP = doc->GetPPElement(namePP);
|
||||||
patternPiece = patternP.cloneNode().toElement();
|
patternPiece = patternP.cloneNode().toElement();
|
||||||
mPath = doc->MPath();
|
mPath = doc->MPath();
|
||||||
previousNode = patternP.previousSibling();//find previous pattern piece
|
QDomNode previousPP = patternP.previousSibling();//find previous pattern piece
|
||||||
|
previousPPName = doc->GetParametrString(previousPP.toElement(), VPattern::AttrName, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -51,7 +52,8 @@ DeletePatternPiece::~DeletePatternPiece()
|
||||||
void DeletePatternPiece::undo()
|
void DeletePatternPiece::undo()
|
||||||
{
|
{
|
||||||
QDomElement rootElement = doc->documentElement();
|
QDomElement rootElement = doc->documentElement();
|
||||||
rootElement.insertAfter(patternPiece, previousNode);
|
QDomNode previousPP = doc->GetPPElement(previousPPName);
|
||||||
|
rootElement.insertAfter(patternPiece, previousPP);
|
||||||
|
|
||||||
emit NeedFullParsing();
|
emit NeedFullParsing();
|
||||||
doc->ChangedActivPP(namePP);
|
doc->ChangedActivPP(namePP);
|
||||||
|
|
|
@ -29,12 +29,9 @@
|
||||||
#ifndef DELETEPATTERNPIECE_H
|
#ifndef DELETEPATTERNPIECE_H
|
||||||
#define DELETEPATTERNPIECE_H
|
#define DELETEPATTERNPIECE_H
|
||||||
|
|
||||||
#include <QDomElement>
|
#include "vundocommand.h"
|
||||||
#include <QUndoCommand>
|
|
||||||
|
|
||||||
class VPattern;
|
class DeletePatternPiece : public VUndoCommand
|
||||||
|
|
||||||
class DeletePatternPiece : public QObject, public QUndoCommand
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -42,15 +39,12 @@ public:
|
||||||
virtual ~DeletePatternPiece();
|
virtual ~DeletePatternPiece();
|
||||||
virtual void undo();
|
virtual void undo();
|
||||||
virtual void redo();
|
virtual void redo();
|
||||||
signals:
|
|
||||||
void NeedFullParsing();
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DeletePatternPiece)
|
Q_DISABLE_COPY(DeletePatternPiece)
|
||||||
VPattern *doc;
|
|
||||||
QString namePP;
|
QString namePP;
|
||||||
QDomElement patternPiece;
|
QDomElement patternPiece;
|
||||||
QString mPath;
|
QString mPath;
|
||||||
QDomNode previousNode;
|
QString previousPPName;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DELETEPATTERNPIECE_H
|
#endif // DELETEPATTERNPIECE_H
|
||||||
|
|
|
@ -33,10 +33,10 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DelTool::DelTool(VPattern *doc, quint32 id, QUndoCommand *parent)
|
DelTool::DelTool(VPattern *doc, quint32 id, QUndoCommand *parent)
|
||||||
: QObject(), QUndoCommand(parent), xml(QDomElement()), parentNode(QDomNode()), doc(doc), toolId(id),
|
: VUndoCommand(QDomElement(), doc, parent), parentNode(QDomNode()), cursor(doc->getCursor())
|
||||||
cursor(doc->getCursor())
|
|
||||||
{
|
{
|
||||||
setText(tr("Delete tool"));
|
setText(tr("Delete tool"));
|
||||||
|
nodeId = id;
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@ DelTool::DelTool(VPattern *doc, quint32 id, QUndoCommand *parent)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't get tool by id = "<<toolId<<Q_FUNC_INFO;
|
qDebug()<<"Can't get tool by id = "<<nodeId<<Q_FUNC_INFO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ void DelTool::undo()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DelTool::redo()
|
void DelTool::redo()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(toolId));
|
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
parentNode.removeChild(domElement);
|
parentNode.removeChild(domElement);
|
||||||
|
@ -83,7 +83,7 @@ void DelTool::redo()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't get tool by id = "<<toolId<<Q_FUNC_INFO;
|
qDebug()<<"Can't get tool by id = "<<nodeId<<Q_FUNC_INFO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,13 +29,10 @@
|
||||||
#ifndef DELTOOL_H
|
#ifndef DELTOOL_H
|
||||||
#define DELTOOL_H
|
#define DELTOOL_H
|
||||||
|
|
||||||
#include <QDomElement>
|
#include "vundocommand.h"
|
||||||
#include <QUndoCommand>
|
|
||||||
|
|
||||||
class VPattern;
|
|
||||||
class QGraphicsItem;
|
class QGraphicsItem;
|
||||||
|
|
||||||
class DelTool : public QObject, public QUndoCommand
|
class DelTool : public VUndoCommand
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -43,14 +40,9 @@ public:
|
||||||
virtual ~DelTool();
|
virtual ~DelTool();
|
||||||
virtual void undo();
|
virtual void undo();
|
||||||
virtual void redo();
|
virtual void redo();
|
||||||
signals:
|
|
||||||
void NeedFullParsing();
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DelTool)
|
Q_DISABLE_COPY(DelTool)
|
||||||
QDomElement xml;
|
|
||||||
QDomNode parentNode;
|
QDomNode parentNode;
|
||||||
VPattern *doc;
|
|
||||||
quint32 toolId;
|
|
||||||
quint32 cursor;
|
quint32 cursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,15 +32,14 @@
|
||||||
#include "../xml/vpattern.h"
|
#include "../xml/vpattern.h"
|
||||||
#include "../tools/vabstracttool.h"
|
#include "../tools/vabstracttool.h"
|
||||||
#include "../widgets/vapplication.h"
|
#include "../widgets/vapplication.h"
|
||||||
#include "undocommands.h"
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
MoveDetail::MoveDetail(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene,
|
MoveDetail::MoveDetail(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene,
|
||||||
QUndoCommand *parent)
|
QUndoCommand *parent)
|
||||||
: QObject(), QUndoCommand(parent), doc(doc), oldX(0.0), oldY(0.0), newX(x), newY(y), detId(id), scene(scene),
|
: VUndoCommand(QDomElement(), doc, parent), oldX(0.0), oldY(0.0), newX(x), newY(y), scene(scene)
|
||||||
redoFlag(false)
|
|
||||||
{
|
{
|
||||||
setText(QObject::tr("Move detail"));
|
setText(QObject::tr("Move detail"));
|
||||||
|
nodeId = id;
|
||||||
|
|
||||||
SCASSERT(scene != nullptr);
|
SCASSERT(scene != nullptr);
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
@ -51,7 +50,7 @@ MoveDetail::MoveDetail(VPattern *doc, const double &x, const double &y, const qu
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO;
|
qDebug()<<"Can't find detail with id ="<< nodeId << Q_FUNC_INFO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,11 +62,10 @@ MoveDetail::~MoveDetail()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MoveDetail::undo()
|
void MoveDetail::undo()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(detId));
|
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrMx, QString().setNum(qApp->fromPixel(oldX)));
|
SaveCoordinates(domElement, oldX, oldY);
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrMy, QString().setNum(qApp->fromPixel(oldY)));
|
|
||||||
|
|
||||||
emit NeedLiteParsing();
|
emit NeedLiteParsing();
|
||||||
|
|
||||||
|
@ -76,7 +74,7 @@ void MoveDetail::undo()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO;
|
qDebug()<<"Can't find detail with id ="<< nodeId << Q_FUNC_INFO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,11 +82,10 @@ void MoveDetail::undo()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MoveDetail::redo()
|
void MoveDetail::redo()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(detId));
|
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrMx, QString().setNum(qApp->fromPixel(newX)));
|
SaveCoordinates(domElement, newX, newY);
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrMy, QString().setNum(qApp->fromPixel(newY)));
|
|
||||||
|
|
||||||
if (redoFlag)
|
if (redoFlag)
|
||||||
{
|
{
|
||||||
|
@ -101,7 +98,7 @@ void MoveDetail::redo()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO;
|
qDebug()<<"Can't find detail with id ="<< nodeId << Q_FUNC_INFO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +111,7 @@ bool MoveDetail::mergeWith(const QUndoCommand *command)
|
||||||
SCASSERT(moveCommand != nullptr);
|
SCASSERT(moveCommand != nullptr);
|
||||||
const quint32 id = moveCommand->getDetId();
|
const quint32 id = moveCommand->getDetId();
|
||||||
|
|
||||||
if (id != detId)
|
if (id != nodeId)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -129,3 +126,10 @@ int MoveDetail::id() const
|
||||||
{
|
{
|
||||||
return static_cast<int>(UndoCommand::MoveDetail);
|
return static_cast<int>(UndoCommand::MoveDetail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void MoveDetail::SaveCoordinates(QDomElement &domElement, double x, double y)
|
||||||
|
{
|
||||||
|
doc->SetAttribute(domElement, VAbstractTool::AttrMx, QString().setNum(qApp->fromPixel(x)));
|
||||||
|
doc->SetAttribute(domElement, VAbstractTool::AttrMy, QString().setNum(qApp->fromPixel(y)));
|
||||||
|
}
|
||||||
|
|
|
@ -29,12 +29,11 @@
|
||||||
#ifndef MOVEDETAIL_H
|
#ifndef MOVEDETAIL_H
|
||||||
#define MOVEDETAIL_H
|
#define MOVEDETAIL_H
|
||||||
|
|
||||||
#include <QUndoCommand>
|
#include "vundocommand.h"
|
||||||
|
|
||||||
class VPattern;
|
|
||||||
class QGraphicsScene;
|
class QGraphicsScene;
|
||||||
|
|
||||||
class MoveDetail : public QObject, public QUndoCommand
|
class MoveDetail : public VUndoCommand
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -49,24 +48,20 @@ public:
|
||||||
quint32 getDetId() const;
|
quint32 getDetId() const;
|
||||||
double getNewX() const;
|
double getNewX() const;
|
||||||
double getNewY() const;
|
double getNewY() const;
|
||||||
signals:
|
|
||||||
void NeedLiteParsing();
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(MoveDetail)
|
Q_DISABLE_COPY(MoveDetail)
|
||||||
VPattern *doc;
|
|
||||||
double oldX;
|
double oldX;
|
||||||
double oldY;
|
double oldY;
|
||||||
double newX;
|
double newX;
|
||||||
double newY;
|
double newY;
|
||||||
quint32 detId;
|
|
||||||
QGraphicsScene *scene;
|
QGraphicsScene *scene;
|
||||||
bool redoFlag;
|
void SaveCoordinates(QDomElement &domElement, double x, double y);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline quint32 MoveDetail::getDetId() const
|
inline quint32 MoveDetail::getDetId() const
|
||||||
{
|
{
|
||||||
return detId;
|
return nodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -31,14 +31,14 @@
|
||||||
#include <QDomElement>
|
#include <QDomElement>
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include "../xml/vpattern.h"
|
#include "../xml/vpattern.h"
|
||||||
#include "undocommands.h"
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
MoveSpline::MoveSpline(VPattern *doc, const VSpline *oldSpl, const VSpline &newSpl, const quint32 &id,
|
MoveSpline::MoveSpline(VPattern *doc, const VSpline *oldSpl, const VSpline &newSpl, const quint32 &id,
|
||||||
QGraphicsScene *scene, QUndoCommand *parent)
|
QGraphicsScene *scene, QUndoCommand *parent)
|
||||||
: QObject(), QUndoCommand(parent), doc(doc), oldSpline(*oldSpl), newSpline(newSpl), splineId(id), scene(scene)
|
: VUndoCommand(QDomElement(), doc, parent), oldSpline(*oldSpl), newSpline(newSpl), scene(scene)
|
||||||
{
|
{
|
||||||
setText(tr("Move spline"));
|
setText(tr("Move spline"));
|
||||||
|
nodeId = id;
|
||||||
|
|
||||||
SCASSERT(scene != nullptr);
|
SCASSERT(scene != nullptr);
|
||||||
}
|
}
|
||||||
|
@ -50,49 +50,13 @@ MoveSpline::~MoveSpline()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MoveSpline::undo()
|
void MoveSpline::undo()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(splineId));
|
Do(oldSpline);
|
||||||
if (domElement.isElement())
|
|
||||||
{
|
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrAngle1, QString().setNum(oldSpline.GetAngle1()));
|
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrAngle2, QString().setNum(oldSpline.GetAngle2()));
|
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrKAsm1, QString().setNum(oldSpline.GetKasm1()));
|
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrKAsm2, QString().setNum(oldSpline.GetKasm2()));
|
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrKCurve, QString().setNum(oldSpline.GetKcurve()));
|
|
||||||
|
|
||||||
emit NeedLiteParsing();
|
|
||||||
|
|
||||||
QList<QGraphicsView*> list = scene->views();
|
|
||||||
VAbstractTool::NewSceneRect(scene, list[0]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qDebug()<<"Can't find spline with id ="<< splineId << Q_FUNC_INFO;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MoveSpline::redo()
|
void MoveSpline::redo()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(splineId));
|
Do(newSpline);
|
||||||
if (domElement.isElement())
|
|
||||||
{
|
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrAngle1, QString().setNum(newSpline.GetAngle1()));
|
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrAngle2, QString().setNum(newSpline.GetAngle2()));
|
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrKAsm1, QString().setNum(newSpline.GetKasm1()));
|
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrKAsm2, QString().setNum(newSpline.GetKasm2()));
|
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrKCurve, QString().setNum(newSpline.GetKcurve()));
|
|
||||||
|
|
||||||
emit NeedLiteParsing();
|
|
||||||
|
|
||||||
QList<QGraphicsView*> list = scene->views();
|
|
||||||
VAbstractTool::NewSceneRect(scene, list[0]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qDebug()<<"Can't find spline with id ="<< splineId << Q_FUNC_INFO;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -102,7 +66,7 @@ bool MoveSpline::mergeWith(const QUndoCommand *command)
|
||||||
SCASSERT(moveCommand != nullptr);
|
SCASSERT(moveCommand != nullptr);
|
||||||
const quint32 id = moveCommand->getSplineId();
|
const quint32 id = moveCommand->getSplineId();
|
||||||
|
|
||||||
if (id != splineId)
|
if (id != nodeId)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -116,3 +80,27 @@ int MoveSpline::id() const
|
||||||
{
|
{
|
||||||
return static_cast<int>(UndoCommand::MoveSpline);
|
return static_cast<int>(UndoCommand::MoveSpline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void MoveSpline::Do(const VSpline &spl)
|
||||||
|
{
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||||
|
if (domElement.isElement())
|
||||||
|
{
|
||||||
|
doc->SetAttribute(domElement, VAbstractTool::AttrAngle1, QString().setNum(spl.GetAngle1()));
|
||||||
|
doc->SetAttribute(domElement, VAbstractTool::AttrAngle2, QString().setNum(spl.GetAngle2()));
|
||||||
|
doc->SetAttribute(domElement, VAbstractTool::AttrKAsm1, QString().setNum(spl.GetKasm1()));
|
||||||
|
doc->SetAttribute(domElement, VAbstractTool::AttrKAsm2, QString().setNum(spl.GetKasm2()));
|
||||||
|
doc->SetAttribute(domElement, VAbstractTool::AttrKCurve, QString().setNum(spl.GetKcurve()));
|
||||||
|
|
||||||
|
emit NeedLiteParsing();
|
||||||
|
|
||||||
|
QList<QGraphicsView*> list = scene->views();
|
||||||
|
VAbstractTool::NewSceneRect(scene, list[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug()<<"Can't find spline with id ="<< nodeId << Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -29,13 +29,12 @@
|
||||||
#ifndef MOVESPLINE_H
|
#ifndef MOVESPLINE_H
|
||||||
#define MOVESPLINE_H
|
#define MOVESPLINE_H
|
||||||
|
|
||||||
#include <QUndoCommand>
|
#include "vundocommand.h"
|
||||||
#include "../geometry/vspline.h"
|
#include "../geometry/vspline.h"
|
||||||
|
|
||||||
class VPattern;
|
|
||||||
class QGraphicsScene;
|
class QGraphicsScene;
|
||||||
|
|
||||||
class MoveSpline : public QObject, public QUndoCommand
|
class MoveSpline : public VUndoCommand
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -48,21 +47,18 @@ public:
|
||||||
virtual int id() const;
|
virtual int id() const;
|
||||||
quint32 getSplineId() const;
|
quint32 getSplineId() const;
|
||||||
VSpline getNewSpline() const;
|
VSpline getNewSpline() const;
|
||||||
signals:
|
|
||||||
void NeedLiteParsing();
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(MoveSpline)
|
Q_DISABLE_COPY(MoveSpline)
|
||||||
VPattern *doc;
|
|
||||||
VSpline oldSpline;
|
VSpline oldSpline;
|
||||||
VSpline newSpline;
|
VSpline newSpline;
|
||||||
quint32 splineId;
|
|
||||||
QGraphicsScene *scene;
|
QGraphicsScene *scene;
|
||||||
|
void Do(const VSpline &spl);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline quint32 MoveSpline::getSplineId() const
|
inline quint32 MoveSpline::getSplineId() const
|
||||||
{
|
{
|
||||||
return splineId;
|
return nodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -29,15 +29,14 @@
|
||||||
#include "movesplinepath.h"
|
#include "movesplinepath.h"
|
||||||
#include <QDomElement>
|
#include <QDomElement>
|
||||||
#include "../tools/drawTools/vtoolsplinepath.h"
|
#include "../tools/drawTools/vtoolsplinepath.h"
|
||||||
#include "undocommands.h"
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
MoveSplinePath::MoveSplinePath(VPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath,
|
MoveSplinePath::MoveSplinePath(VPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath,
|
||||||
const quint32 &id, QGraphicsScene *scene, QUndoCommand *parent)
|
const quint32 &id, QGraphicsScene *scene, QUndoCommand *parent)
|
||||||
: QObject(), QUndoCommand(parent), doc(doc), oldSplinePath(oldSplPath), newSplinePath(newSplPath), splinePathId(id),
|
: VUndoCommand(QDomElement(), doc, parent), oldSplinePath(oldSplPath), newSplinePath(newSplPath), scene(scene)
|
||||||
scene(scene)
|
|
||||||
{
|
{
|
||||||
setText(tr("Move spline path"));
|
setText(tr("Move spline path"));
|
||||||
|
nodeId = id;
|
||||||
|
|
||||||
SCASSERT(scene != nullptr);
|
SCASSERT(scene != nullptr);
|
||||||
}
|
}
|
||||||
|
@ -49,43 +48,13 @@ MoveSplinePath::~MoveSplinePath()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MoveSplinePath::undo()
|
void MoveSplinePath::undo()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(splinePathId));
|
Do(oldSplinePath);
|
||||||
if (domElement.isElement())
|
|
||||||
{
|
|
||||||
doc->SetAttribute(domElement, VToolSplinePath::AttrKCurve, QString().setNum(oldSplinePath.getKCurve()));
|
|
||||||
VToolSplinePath::UpdatePathPoint(doc, domElement, oldSplinePath);
|
|
||||||
|
|
||||||
emit NeedLiteParsing();
|
|
||||||
|
|
||||||
QList<QGraphicsView*> list = scene->views();
|
|
||||||
VAbstractTool::NewSceneRect(scene, list[0]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qDebug()<<"Can't find spline path with id ="<< splinePathId << Q_FUNC_INFO;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MoveSplinePath::redo()
|
void MoveSplinePath::redo()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(splinePathId));
|
Do(newSplinePath);
|
||||||
if (domElement.isElement())
|
|
||||||
{
|
|
||||||
doc->SetAttribute(domElement, VToolSplinePath::AttrKCurve, QString().setNum(newSplinePath.getKCurve()));
|
|
||||||
VToolSplinePath::UpdatePathPoint(doc, domElement, newSplinePath);
|
|
||||||
|
|
||||||
emit NeedLiteParsing();
|
|
||||||
|
|
||||||
QList<QGraphicsView*> list = scene->views();
|
|
||||||
VAbstractTool::NewSceneRect(scene, list[0]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qDebug()<<"Can't find spline path with id ="<< splinePathId << Q_FUNC_INFO;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -95,7 +64,7 @@ bool MoveSplinePath::mergeWith(const QUndoCommand *command)
|
||||||
SCASSERT(moveCommand != nullptr);
|
SCASSERT(moveCommand != nullptr);
|
||||||
const quint32 id = moveCommand->getSplinePathId();
|
const quint32 id = moveCommand->getSplinePathId();
|
||||||
|
|
||||||
if (id != splinePathId)
|
if (id != nodeId)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -109,3 +78,24 @@ int MoveSplinePath::id() const
|
||||||
{
|
{
|
||||||
return static_cast<int>(UndoCommand::MoveSplinePath);
|
return static_cast<int>(UndoCommand::MoveSplinePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void MoveSplinePath::Do(const VSplinePath &splPath)
|
||||||
|
{
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||||
|
if (domElement.isElement())
|
||||||
|
{
|
||||||
|
doc->SetAttribute(domElement, VToolSplinePath::AttrKCurve, QString().setNum(splPath.getKCurve()));
|
||||||
|
VToolSplinePath::UpdatePathPoint(doc, domElement, splPath);
|
||||||
|
|
||||||
|
emit NeedLiteParsing();
|
||||||
|
|
||||||
|
QList<QGraphicsView*> list = scene->views();
|
||||||
|
VAbstractTool::NewSceneRect(scene, list[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug()<<"Can't find spline path with id ="<< nodeId << Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -29,13 +29,12 @@
|
||||||
#ifndef MOVESPLINEPATH_H
|
#ifndef MOVESPLINEPATH_H
|
||||||
#define MOVESPLINEPATH_H
|
#define MOVESPLINEPATH_H
|
||||||
|
|
||||||
#include <QUndoCommand>
|
#include "vundocommand.h"
|
||||||
#include "../geometry/vsplinepath.h"
|
#include "../geometry/vsplinepath.h"
|
||||||
|
|
||||||
class VPattern;
|
|
||||||
class QGraphicsScene;
|
class QGraphicsScene;
|
||||||
|
|
||||||
class MoveSplinePath : public QObject, public QUndoCommand
|
class MoveSplinePath : public VUndoCommand
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -48,21 +47,18 @@ public:
|
||||||
virtual int id() const;
|
virtual int id() const;
|
||||||
quint32 getSplinePathId() const;
|
quint32 getSplinePathId() const;
|
||||||
VSplinePath getNewSplinePath() const;
|
VSplinePath getNewSplinePath() const;
|
||||||
signals:
|
|
||||||
void NeedLiteParsing();
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(MoveSplinePath)
|
Q_DISABLE_COPY(MoveSplinePath)
|
||||||
VPattern *doc;
|
|
||||||
VSplinePath oldSplinePath;
|
VSplinePath oldSplinePath;
|
||||||
VSplinePath newSplinePath;
|
VSplinePath newSplinePath;
|
||||||
quint32 splinePathId;
|
|
||||||
QGraphicsScene *scene;
|
QGraphicsScene *scene;
|
||||||
|
void Do(const VSplinePath &splPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline quint32 MoveSplinePath::getSplinePathId() const
|
inline quint32 MoveSplinePath::getSplinePathId() const
|
||||||
{
|
{
|
||||||
return splinePathId;
|
return nodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -32,14 +32,14 @@
|
||||||
#include "../xml/vpattern.h"
|
#include "../xml/vpattern.h"
|
||||||
#include "../tools/vabstracttool.h"
|
#include "../tools/vabstracttool.h"
|
||||||
#include "../widgets/vapplication.h"
|
#include "../widgets/vapplication.h"
|
||||||
#include "undocommands.h"
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
MoveSPoint::MoveSPoint(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene,
|
MoveSPoint::MoveSPoint(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene,
|
||||||
QUndoCommand *parent)
|
QUndoCommand *parent)
|
||||||
: QObject(), QUndoCommand(parent), doc(doc), oldX(0.0), oldY(0.0), newX(x), newY(y), sPointId(id), scene(scene)
|
: VUndoCommand(QDomElement(), doc, parent), oldX(0.0), oldY(0.0), newX(x), newY(y), scene(scene)
|
||||||
{
|
{
|
||||||
setText(tr("Move single point"));
|
setText(tr("Move single point"));
|
||||||
|
nodeId = id;
|
||||||
|
|
||||||
SCASSERT(scene != nullptr);
|
SCASSERT(scene != nullptr);
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
@ -50,7 +50,7 @@ MoveSPoint::MoveSPoint(VPattern *doc, const double &x, const double &y, const qu
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find spoint with id ="<< sPointId << Q_FUNC_INFO;
|
qDebug()<<"Can't find spoint with id ="<< nodeId << Q_FUNC_INFO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,43 +62,13 @@ MoveSPoint::~MoveSPoint()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MoveSPoint::undo()
|
void MoveSPoint::undo()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(sPointId));
|
Do(oldX, oldY);
|
||||||
if (domElement.isElement())
|
|
||||||
{
|
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrX, QString().setNum(qApp->fromPixel(oldX)));
|
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrY, QString().setNum(qApp->fromPixel(oldY)));
|
|
||||||
|
|
||||||
emit NeedLiteParsing();
|
|
||||||
|
|
||||||
QList<QGraphicsView*> list = scene->views();
|
|
||||||
VAbstractTool::NewSceneRect(scene, list[0]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qDebug()<<"Can't find spoint with id ="<< sPointId << Q_FUNC_INFO;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MoveSPoint::redo()
|
void MoveSPoint::redo()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(sPointId));
|
Do(newX, newY);
|
||||||
if (domElement.isElement())
|
|
||||||
{
|
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrX, QString().setNum(qApp->fromPixel(newX)));
|
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrY, QString().setNum(qApp->fromPixel(newY)));
|
|
||||||
|
|
||||||
emit NeedLiteParsing();
|
|
||||||
|
|
||||||
QList<QGraphicsView*> list = scene->views();
|
|
||||||
VAbstractTool::NewSceneRect(scene, list[0]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qDebug()<<"Can't find spoint with id ="<< sPointId << Q_FUNC_INFO;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -108,7 +78,7 @@ bool MoveSPoint::mergeWith(const QUndoCommand *command)
|
||||||
SCASSERT(moveCommand != nullptr);
|
SCASSERT(moveCommand != nullptr);
|
||||||
const quint32 id = moveCommand->getSPointId();
|
const quint32 id = moveCommand->getSPointId();
|
||||||
|
|
||||||
if (id != sPointId)
|
if (id != nodeId)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -123,3 +93,24 @@ int MoveSPoint::id() const
|
||||||
{
|
{
|
||||||
return static_cast<int>(UndoCommand::MoveSPoint);
|
return static_cast<int>(UndoCommand::MoveSPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void MoveSPoint::Do(double x, double y)
|
||||||
|
{
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||||
|
if (domElement.isElement())
|
||||||
|
{
|
||||||
|
doc->SetAttribute(domElement, VAbstractTool::AttrX, QString().setNum(qApp->fromPixel(x)));
|
||||||
|
doc->SetAttribute(domElement, VAbstractTool::AttrY, QString().setNum(qApp->fromPixel(y)));
|
||||||
|
|
||||||
|
emit NeedLiteParsing();
|
||||||
|
|
||||||
|
QList<QGraphicsView*> list = scene->views();
|
||||||
|
VAbstractTool::NewSceneRect(scene, list[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug()<<"Can't find spoint with id ="<< nodeId << Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -29,12 +29,11 @@
|
||||||
#ifndef MOVESPOINT_H
|
#ifndef MOVESPOINT_H
|
||||||
#define MOVESPOINT_H
|
#define MOVESPOINT_H
|
||||||
|
|
||||||
#include <QUndoCommand>
|
#include "vundocommand.h"
|
||||||
|
|
||||||
class VPattern;
|
|
||||||
class QGraphicsScene;
|
class QGraphicsScene;
|
||||||
|
|
||||||
class MoveSPoint : public QObject, public QUndoCommand
|
class MoveSPoint : public VUndoCommand
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -48,23 +47,20 @@ public:
|
||||||
quint32 getSPointId() const;
|
quint32 getSPointId() const;
|
||||||
double getNewX() const;
|
double getNewX() const;
|
||||||
double getNewY() const;
|
double getNewY() const;
|
||||||
signals:
|
void Do(double x, double y);
|
||||||
void NeedLiteParsing();
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(MoveSPoint)
|
Q_DISABLE_COPY(MoveSPoint)
|
||||||
VPattern *doc;
|
|
||||||
double oldX;
|
double oldX;
|
||||||
double oldY;
|
double oldY;
|
||||||
double newX;
|
double newX;
|
||||||
double newY;
|
double newY;
|
||||||
quint32 sPointId;
|
|
||||||
QGraphicsScene *scene;
|
QGraphicsScene *scene;
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline quint32 MoveSPoint::getSPointId() const
|
inline quint32 MoveSPoint::getSPointId() const
|
||||||
{
|
{
|
||||||
return sPointId;
|
return nodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -27,15 +27,15 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "savedetailoptions.h"
|
#include "savedetailoptions.h"
|
||||||
#include "undocommands.h"
|
|
||||||
#include "../tools/nodeDetails/vabstractnode.h"
|
#include "../tools/nodeDetails/vabstractnode.h"
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
|
|
||||||
SaveDetailOptions::SaveDetailOptions(const VDetail &oldDet, const VDetail &newDet, VPattern *doc, const quint32 &id,
|
SaveDetailOptions::SaveDetailOptions(const VDetail &oldDet, const VDetail &newDet, VPattern *doc, const quint32 &id,
|
||||||
QGraphicsScene *scene, QUndoCommand *parent)
|
QGraphicsScene *scene, QUndoCommand *parent)
|
||||||
: QObject(), QUndoCommand(parent), oldDet(oldDet), newDet(newDet), doc(doc), detId(id), scene(scene)
|
: VUndoCommand(QDomElement(), doc, parent), oldDet(oldDet), newDet(newDet), scene(scene)
|
||||||
{
|
{
|
||||||
setText(tr("Save detail option"));
|
setText(tr("Save detail option"));
|
||||||
|
nodeId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -45,13 +45,10 @@ SaveDetailOptions::~SaveDetailOptions()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void SaveDetailOptions::undo()
|
void SaveDetailOptions::undo()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(detId));
|
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrName, oldDet.getName());
|
SaveDet(domElement, oldDet);
|
||||||
doc->SetAttribute(domElement, VToolDetail::AttrSupplement, QString().setNum(oldDet.getSeamAllowance()));
|
|
||||||
doc->SetAttribute(domElement, VToolDetail::AttrClosed, QString().setNum(oldDet.getClosed()));
|
|
||||||
doc->SetAttribute(domElement, VToolDetail::AttrWidth, QString().setNum(oldDet.getWidth()));
|
|
||||||
doc->RemoveAllChild(domElement);
|
doc->RemoveAllChild(domElement);
|
||||||
for (ptrdiff_t i = 0; i < oldDet.CountNode(); ++i)
|
for (ptrdiff_t i = 0; i < oldDet.CountNode(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -75,7 +72,7 @@ void SaveDetailOptions::undo()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO;
|
qDebug()<<"Can't find detail with id ="<< nodeId << Q_FUNC_INFO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,13 +80,10 @@ void SaveDetailOptions::undo()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void SaveDetailOptions::redo()
|
void SaveDetailOptions::redo()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(detId));
|
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->SetAttribute(domElement, VAbstractTool::AttrName, newDet.getName());
|
SaveDet(domElement, newDet);
|
||||||
doc->SetAttribute(domElement, VToolDetail::AttrSupplement, QString().setNum(newDet.getSeamAllowance()));
|
|
||||||
doc->SetAttribute(domElement, VToolDetail::AttrClosed, QString().setNum(newDet.getClosed()));
|
|
||||||
doc->SetAttribute(domElement, VToolDetail::AttrWidth, QString().setNum(newDet.getWidth()));
|
|
||||||
doc->RemoveAllChild(domElement);
|
doc->RemoveAllChild(domElement);
|
||||||
for (ptrdiff_t i = 0; i < newDet.CountNode(); ++i)
|
for (ptrdiff_t i = 0; i < newDet.CountNode(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -113,7 +107,7 @@ void SaveDetailOptions::redo()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO;
|
qDebug()<<"Can't find detail with id ="<< nodeId << Q_FUNC_INFO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +119,7 @@ bool SaveDetailOptions::mergeWith(const QUndoCommand *command)
|
||||||
SCASSERT(saveCommand != nullptr);
|
SCASSERT(saveCommand != nullptr);
|
||||||
const quint32 id = saveCommand->getDetId();
|
const quint32 id = saveCommand->getDetId();
|
||||||
|
|
||||||
if (id != detId)
|
if (id != nodeId)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -139,3 +133,12 @@ int SaveDetailOptions::id() const
|
||||||
{
|
{
|
||||||
return static_cast<int>(UndoCommand::SaveDetailOptions);
|
return static_cast<int>(UndoCommand::SaveDetailOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void SaveDetailOptions::SaveDet(QDomElement &domElement, const VDetail &det)
|
||||||
|
{
|
||||||
|
doc->SetAttribute(domElement, VAbstractTool::AttrName, det.getName());
|
||||||
|
doc->SetAttribute(domElement, VToolDetail::AttrSupplement, QString().setNum(det.getSeamAllowance()));
|
||||||
|
doc->SetAttribute(domElement, VToolDetail::AttrClosed, QString().setNum(det.getClosed()));
|
||||||
|
doc->SetAttribute(domElement, VToolDetail::AttrWidth, QString().setNum(det.getWidth()));
|
||||||
|
}
|
||||||
|
|
|
@ -29,14 +29,12 @@
|
||||||
#ifndef SAVEDETAILOPTIONS_H
|
#ifndef SAVEDETAILOPTIONS_H
|
||||||
#define SAVEDETAILOPTIONS_H
|
#define SAVEDETAILOPTIONS_H
|
||||||
|
|
||||||
#include <QUndoCommand>
|
#include "vundocommand.h"
|
||||||
#include <QDomElement>
|
|
||||||
#include "../tools/vtooldetail.h"
|
#include "../tools/vtooldetail.h"
|
||||||
|
|
||||||
class VPattern;
|
|
||||||
class QGraphicsScene;
|
class QGraphicsScene;
|
||||||
|
|
||||||
class SaveDetailOptions : public QObject, public QUndoCommand
|
class SaveDetailOptions : public VUndoCommand
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -49,21 +47,18 @@ public:
|
||||||
virtual int id() const;
|
virtual int id() const;
|
||||||
quint32 getDetId() const;
|
quint32 getDetId() const;
|
||||||
VDetail getNewDet() const;
|
VDetail getNewDet() const;
|
||||||
signals:
|
|
||||||
void NeedLiteParsing();
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(SaveDetailOptions)
|
Q_DISABLE_COPY(SaveDetailOptions)
|
||||||
const VDetail oldDet;
|
const VDetail oldDet;
|
||||||
VDetail newDet;
|
VDetail newDet;
|
||||||
VPattern *doc;
|
|
||||||
const quint32 detId;
|
|
||||||
QGraphicsScene *scene;
|
QGraphicsScene *scene;
|
||||||
|
void SaveDet(QDomElement &domElement, const VDetail &det);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline quint32 SaveDetailOptions::getDetId() const
|
inline quint32 SaveDetailOptions::getDetId() const
|
||||||
{
|
{
|
||||||
return detId;
|
return nodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -29,14 +29,14 @@
|
||||||
#include "savetooloptions.h"
|
#include "savetooloptions.h"
|
||||||
#include "../options.h"
|
#include "../options.h"
|
||||||
#include "../xml/vpattern.h"
|
#include "../xml/vpattern.h"
|
||||||
#include "undocommands.h"
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
SaveToolOptions::SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, VPattern *doc, const quint32 &id,
|
SaveToolOptions::SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, VPattern *doc, const quint32 &id,
|
||||||
QUndoCommand *parent)
|
QUndoCommand *parent)
|
||||||
: QObject(), QUndoCommand(parent), oldXml(oldXml), newXml(newXml), doc(doc), toolId(id)
|
: VUndoCommand(QDomElement(), doc, parent), oldXml(oldXml), newXml(newXml)
|
||||||
{
|
{
|
||||||
setText(tr("Save tool option"));
|
setText(tr("Save tool option"));
|
||||||
|
nodeId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -46,7 +46,7 @@ SaveToolOptions::~SaveToolOptions()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void SaveToolOptions::undo()
|
void SaveToolOptions::undo()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(toolId));
|
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
domElement.parentNode().replaceChild(oldXml, domElement);
|
domElement.parentNode().replaceChild(oldXml, domElement);
|
||||||
|
@ -55,7 +55,7 @@ void SaveToolOptions::undo()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find tool with id ="<< toolId << Q_FUNC_INFO;
|
qDebug()<<"Can't find tool with id ="<< nodeId << Q_FUNC_INFO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ void SaveToolOptions::undo()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void SaveToolOptions::redo()
|
void SaveToolOptions::redo()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(toolId));
|
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
domElement.parentNode().replaceChild(newXml, domElement);
|
domElement.parentNode().replaceChild(newXml, domElement);
|
||||||
|
@ -72,7 +72,7 @@ void SaveToolOptions::redo()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find tool with id ="<< toolId << Q_FUNC_INFO;
|
qDebug()<<"Can't find tool with id ="<< nodeId << Q_FUNC_INFO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ bool SaveToolOptions::mergeWith(const QUndoCommand *command)
|
||||||
SCASSERT(saveCommand != nullptr);
|
SCASSERT(saveCommand != nullptr);
|
||||||
const quint32 id = saveCommand->getToolId();
|
const quint32 id = saveCommand->getToolId();
|
||||||
|
|
||||||
if (id != toolId)
|
if (id != nodeId)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,9 @@
|
||||||
#ifndef SAVETOOLOPTIONS_H
|
#ifndef SAVETOOLOPTIONS_H
|
||||||
#define SAVETOOLOPTIONS_H
|
#define SAVETOOLOPTIONS_H
|
||||||
|
|
||||||
#include <QUndoCommand>
|
#include "vundocommand.h"
|
||||||
#include <QDomElement>
|
|
||||||
|
|
||||||
class VPattern;
|
class SaveToolOptions : public VUndoCommand
|
||||||
|
|
||||||
class SaveToolOptions : public QObject, public QUndoCommand
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -53,8 +50,6 @@ private:
|
||||||
Q_DISABLE_COPY(SaveToolOptions)
|
Q_DISABLE_COPY(SaveToolOptions)
|
||||||
const QDomElement oldXml;
|
const QDomElement oldXml;
|
||||||
QDomElement newXml;
|
QDomElement newXml;
|
||||||
VPattern *doc;
|
|
||||||
const quint32 toolId;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -66,7 +61,7 @@ inline QDomElement SaveToolOptions::getNewXml() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline quint32 SaveToolOptions::getToolId() const
|
inline quint32 SaveToolOptions::getToolId() const
|
||||||
{
|
{
|
||||||
return toolId;
|
return nodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SAVETOOLOPTIONS_H
|
#endif // SAVETOOLOPTIONS_H
|
||||||
|
|
|
@ -5,7 +5,6 @@ HEADERS += \
|
||||||
undocommands/movespline.h \
|
undocommands/movespline.h \
|
||||||
undocommands/movesplinepath.h \
|
undocommands/movesplinepath.h \
|
||||||
undocommands/savetooloptions.h \
|
undocommands/savetooloptions.h \
|
||||||
undocommands/undocommands.h \
|
|
||||||
undocommands/savedetailoptions.h \
|
undocommands/savedetailoptions.h \
|
||||||
undocommands/movedetail.h \
|
undocommands/movedetail.h \
|
||||||
undocommands/deltool.h \
|
undocommands/deltool.h \
|
||||||
|
@ -13,7 +12,8 @@ HEADERS += \
|
||||||
undocommands/adddetnode.h \
|
undocommands/adddetnode.h \
|
||||||
undocommands/adddet.h \
|
undocommands/adddet.h \
|
||||||
undocommands/adduniondetails.h \
|
undocommands/adduniondetails.h \
|
||||||
undocommands/deletedetail.h
|
undocommands/deletedetail.h \
|
||||||
|
undocommands/vundocommand.h
|
||||||
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
@ -30,5 +30,6 @@ SOURCES += \
|
||||||
undocommands/adddetnode.cpp \
|
undocommands/adddetnode.cpp \
|
||||||
undocommands/adddet.cpp \
|
undocommands/adddet.cpp \
|
||||||
undocommands/adduniondetails.cpp \
|
undocommands/adduniondetails.cpp \
|
||||||
undocommands/deletedetail.cpp
|
undocommands/deletedetail.cpp \
|
||||||
|
undocommands/vundocommand.cpp
|
||||||
|
|
||||||
|
|
54
src/app/undocommands/vundocommand.cpp
Normal file
54
src/app/undocommands/vundocommand.cpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vundocommand.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 16 7, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2014 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "vundocommand.h"
|
||||||
|
#include "../xml/vpattern.h"
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VUndoCommand::VUndoCommand(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
||||||
|
:QObject(), QUndoCommand(parent), xml(xml), doc(doc), nodeId(0), redoFlag(false)
|
||||||
|
{
|
||||||
|
SCASSERT(xml.isNull() == false);
|
||||||
|
SCASSERT(doc != nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VUndoCommand::~VUndoCommand()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VUndoCommand::RedoFullParsing()
|
||||||
|
{
|
||||||
|
if (redoFlag)
|
||||||
|
{
|
||||||
|
emit NeedFullParsing();
|
||||||
|
}
|
||||||
|
redoFlag = true;
|
||||||
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file undocommands.h
|
** @file vundocommand.h
|
||||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
** @date 11 6, 2014
|
** @date 16 7, 2014
|
||||||
**
|
**
|
||||||
** @brief
|
** @brief
|
||||||
** @copyright
|
** @copyright
|
||||||
|
@ -26,8 +26,11 @@
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef UNDOCOMMANDS_H
|
#ifndef VUNDOCOMMAND_H
|
||||||
#define UNDOCOMMANDS_H
|
#define VUNDOCOMMAND_H
|
||||||
|
|
||||||
|
#include <QUndoCommand>
|
||||||
|
#include <QDomElement>
|
||||||
|
|
||||||
enum class UndoCommand: char { AddPatternPiece,
|
enum class UndoCommand: char { AddPatternPiece,
|
||||||
AddToCalc,
|
AddToCalc,
|
||||||
|
@ -41,4 +44,26 @@ enum class UndoCommand: char { AddPatternPiece,
|
||||||
DeletePatternPiece
|
DeletePatternPiece
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UNDOCOMMANDS_H
|
class VPattern;
|
||||||
|
|
||||||
|
class VUndoCommand : public QObject, public QUndoCommand
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VUndoCommand(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0);
|
||||||
|
virtual ~VUndoCommand();
|
||||||
|
signals:
|
||||||
|
void ClearScene();
|
||||||
|
void NeedFullParsing();
|
||||||
|
void NeedLiteParsing();
|
||||||
|
protected:
|
||||||
|
QDomElement xml;
|
||||||
|
VPattern *doc;
|
||||||
|
quint32 nodeId;
|
||||||
|
bool redoFlag;
|
||||||
|
void RedoFullParsing();
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(VUndoCommand)
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VUNDOCOMMAND_H
|
|
@ -112,6 +112,7 @@ public:
|
||||||
bool CheckNamePP(const QString& name) const;
|
bool CheckNamePP(const QString& name) const;
|
||||||
int CountPP() const;
|
int CountPP() const;
|
||||||
QRectF ActiveDrawBoundingRect() const;
|
QRectF ActiveDrawBoundingRect() const;
|
||||||
|
quint32 GetParametrId(const QDomElement& domElement) const;
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* @brief ChangedActivDraw change active pattern peace.
|
* @brief ChangedActivDraw change active pattern peace.
|
||||||
|
@ -198,7 +199,6 @@ private:
|
||||||
void ParseToolsElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
void ParseToolsElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
||||||
const Document &parse, const QString& type);
|
const Document &parse, const QString& type);
|
||||||
void ParseIncrementsElement(const QDomNode& node);
|
void ParseIncrementsElement(const QDomNode& node);
|
||||||
quint32 GetParametrId(const QDomElement& domElement) const;
|
|
||||||
void CollectId(const QDomElement &node, QVector<quint32> &vector)const;
|
void CollectId(const QDomElement &node, QVector<quint32> &vector)const;
|
||||||
void PrepareForParse(const Document &parse);
|
void PrepareForParse(const Document &parse);
|
||||||
void UpdateMeasurements();
|
void UpdateMeasurements();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user