Refactoring UndoCommands.
--HG-- branch : feature
This commit is contained in:
parent
3bf2e056c0
commit
f166f2521b
|
@ -30,8 +30,8 @@
|
|||
#include "../tools/drawTools/drawtools.h"
|
||||
#include "../core/vapplication.h"
|
||||
#include "vmaingraphicsview.h"
|
||||
#include "../visualization/vgraphicssimpletextitem.h"
|
||||
#include "../visualization/vcontrolpointspline.h"
|
||||
#include "../../libs/vwidgets/vgraphicssimpletextitem.h"
|
||||
#include "../../libs/vwidgets/vcontrolpointspline.h"
|
||||
#include "../../libs/vpropertyexplorer/vproperties.h"
|
||||
#include "vformulaproperty.h"
|
||||
#include "../core/vformula.h"
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include "vdrawtool.h"
|
||||
#include <QGraphicsPathItem>
|
||||
#include "../../visualization/vcontrolpointspline.h"
|
||||
#include "../libs/vwidgets/vcontrolpointspline.h"
|
||||
|
||||
class VAbstractSpline:public VDrawTool, public QGraphicsPathItem
|
||||
{
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "vtoolpoint.h"
|
||||
#include "../vmisc/logging.h"
|
||||
#include "../../libs/vgeometry/vpointf.h"
|
||||
#include "../../visualization/vgraphicssimpletextitem.h"
|
||||
#include "../../libs/vwidgets/vgraphicssimpletextitem.h"
|
||||
#include "../../undocommands/movelabel.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include "vtoolsinglepoint.h"
|
||||
#include "../../dialogs/tools/dialogsinglepoint.h"
|
||||
#include "../../visualization/vgraphicssimpletextitem.h"
|
||||
#include "../../libs/vwidgets/vgraphicssimpletextitem.h"
|
||||
#include "../../undocommands/movespoint.h"
|
||||
#include "../../undocommands/addpatternpiece.h"
|
||||
#include "../../undocommands/deletepatternpiece.h"
|
||||
|
|
|
@ -271,7 +271,7 @@ void VToolSplinePath::RefreshSplinePath(VSplinePath &splPath)
|
|||
* @param node tag in file.
|
||||
* @param path spline path.
|
||||
*/
|
||||
void VToolSplinePath::UpdatePathPoint(VPattern *doc, QDomNode& node, const VSplinePath &path)
|
||||
void VToolSplinePath::UpdatePathPoint(VAbstractPattern *doc, QDomNode& node, const VSplinePath &path)
|
||||
{
|
||||
SCASSERT(doc != nullptr);
|
||||
QDomElement element = node.toElement();
|
||||
|
@ -344,7 +344,7 @@ void VToolSplinePath::RefreshDataInFile()
|
|||
* @param domElement dom element.
|
||||
* @param splPoint spline path point.
|
||||
*/
|
||||
void VToolSplinePath::AddPathPoint(VPattern *doc, QDomElement &domElement, const VSplinePoint &splPoint)
|
||||
void VToolSplinePath::AddPathPoint(VAbstractPattern *doc, QDomElement &domElement, const VSplinePoint &splPoint)
|
||||
{
|
||||
SCASSERT(doc != nullptr);
|
||||
QDomElement pathPoint = doc->createElement(AttrPathPoint);
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static const QString ToolType;
|
||||
static void UpdatePathPoint(VPattern *doc, QDomNode& node, const VSplinePath &path);
|
||||
static void UpdatePathPoint(VAbstractPattern *doc, QDomNode& node, const VSplinePath &path);
|
||||
virtual int type() const {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::SplinePath)};
|
||||
|
||||
|
@ -91,7 +91,7 @@ private:
|
|||
QPointF oldPosition;
|
||||
|
||||
void RefreshGeometry();
|
||||
static void AddPathPoint(VPattern *doc, QDomElement &domElement, const VSplinePoint &splPoint);
|
||||
static void AddPathPoint(VAbstractPattern *doc, QDomElement &domElement, const VSplinePoint &splPoint);
|
||||
void UpdateControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) const;
|
||||
void RefreshSplinePath(VSplinePath &splPath);
|
||||
};
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include "../../core/vapplication.h"
|
||||
#include "../../libs/vgeometry/vpointf.h"
|
||||
#include "../../visualization/vgraphicssimpletextitem.h"
|
||||
#include "../../libs/vwidgets/vgraphicssimpletextitem.h"
|
||||
#include <QPen>
|
||||
#include <QBrush>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
|
|
@ -442,7 +442,7 @@ void VToolDetail::RemoveReferens()
|
|||
* @param domElement tag in xml tree.
|
||||
* @param node node of detail.
|
||||
*/
|
||||
void VToolDetail::AddNode(VPattern *doc, QDomElement &domElement, const VNodeDetail &node)
|
||||
void VToolDetail::AddNode(VAbstractPattern *doc, QDomElement &domElement, const VNodeDetail &node)
|
||||
{
|
||||
QDomElement nod = doc->createElement(TagNode);
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ public:
|
|||
static const QString NodeSpline;
|
||||
static const QString NodeSplinePath;
|
||||
void Remove(bool ask);
|
||||
static void AddNode(VPattern *doc, QDomElement &domElement, const VNodeDetail &node);
|
||||
static void AddNode(VAbstractPattern *doc, QDomElement &domElement, const VNodeDetail &node);
|
||||
virtual int type() const {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::Detail)};
|
||||
virtual QString getTagName() const;
|
||||
|
|
|
@ -27,10 +27,9 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "adddet.h"
|
||||
#include "../xml/vpattern.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
AddDet::AddDet(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
||||
AddDet::AddDet(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent)
|
||||
: VUndoCommand(xml, doc, parent)
|
||||
{
|
||||
setText(tr("Add detail"));
|
||||
|
@ -48,7 +47,7 @@ void AddDet::undo()
|
|||
qCDebug(vUndo, "Undo.");
|
||||
|
||||
QDomElement element;
|
||||
if (doc->GetActivNodeElement(VPattern::TagDetails, element))
|
||||
if (doc->GetActivNodeElement(VAbstractPattern::TagDetails, element))
|
||||
{
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
|
@ -67,7 +66,7 @@ void AddDet::undo()
|
|||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't find tag %s.", VPattern::TagDetails.toUtf8().constData());
|
||||
qCDebug(vUndo, "Can't find tag %s.", VAbstractPattern::TagDetails.toUtf8().constData());
|
||||
return;
|
||||
}
|
||||
emit NeedFullParsing();
|
||||
|
@ -80,13 +79,13 @@ void AddDet::redo()
|
|||
qCDebug(vUndo, "Redo.");
|
||||
|
||||
QDomElement element;
|
||||
if (doc->GetActivNodeElement(VPattern::TagDetails, element))
|
||||
if (doc->GetActivNodeElement(VAbstractPattern::TagDetails, element))
|
||||
{
|
||||
element.appendChild(xml);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't find tag %s.", VPattern::TagDetails.toUtf8().constData());
|
||||
qCDebug(vUndo, "Can't find tag %s.", VAbstractPattern::TagDetails.toUtf8().constData());
|
||||
return;
|
||||
}
|
||||
RedoFullParsing();
|
||||
|
|
|
@ -31,13 +31,11 @@
|
|||
|
||||
#include "vundocommand.h"
|
||||
|
||||
class VPattern;
|
||||
|
||||
class AddDet : public VUndoCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AddDet(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0);
|
||||
AddDet(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = 0);
|
||||
virtual ~AddDet();
|
||||
// cppcheck-suppress unusedFunction
|
||||
virtual void undo();
|
||||
|
|
|
@ -27,10 +27,9 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "adddetnode.h"
|
||||
#include "../xml/vpattern.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
AddDetNode::AddDetNode(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
||||
AddDetNode::AddDetNode(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent)
|
||||
: VUndoCommand(xml, doc, parent)
|
||||
{
|
||||
setText(QObject::tr("Add node"));
|
||||
|
@ -47,7 +46,7 @@ void AddDetNode::undo()
|
|||
qCDebug(vUndo, "Undo.");
|
||||
|
||||
QDomElement modelingElement;
|
||||
if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement))
|
||||
if (doc->GetActivNodeElement(VAbstractPattern::TagModeling, modelingElement))
|
||||
{
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
|
@ -66,7 +65,7 @@ void AddDetNode::undo()
|
|||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't find tag %s.", VPattern::TagModeling.toUtf8().constData());
|
||||
qCDebug(vUndo, "Can't find tag %s.", VAbstractPattern::TagModeling.toUtf8().constData());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -77,13 +76,13 @@ void AddDetNode::redo()
|
|||
qCDebug(vUndo, "Redo.");
|
||||
|
||||
QDomElement modelingElement;
|
||||
if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement))
|
||||
if (doc->GetActivNodeElement(VAbstractPattern::TagModeling, modelingElement))
|
||||
{
|
||||
modelingElement.appendChild(xml);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't find tag %s.", VPattern::TagModeling.toUtf8().constData());
|
||||
qCDebug(vUndo, "Can't find tag %s.", VAbstractPattern::TagModeling.toUtf8().constData());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class AddDetNode : public VUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AddDetNode(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0);
|
||||
AddDetNode(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = 0);
|
||||
virtual ~AddDetNode();
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
|
|
|
@ -27,11 +27,10 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "addpatternpiece.h"
|
||||
#include "../xml/vpattern.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
AddPatternPiece::AddPatternPiece(const QDomElement &xml, VPattern *doc, const QString &namePP, const QString &mPath,
|
||||
QUndoCommand *parent)
|
||||
AddPatternPiece::AddPatternPiece(const QDomElement &xml, VAbstractPattern *doc, const QString &namePP,
|
||||
const QString &mPath, QUndoCommand *parent)
|
||||
: VUndoCommand(xml, doc, parent), namePP(namePP), mPath(mPath)
|
||||
{
|
||||
SCASSERT(namePP.isEmpty() == false);
|
||||
|
|
|
@ -35,7 +35,7 @@ class AddPatternPiece : public VUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AddPatternPiece(const QDomElement &xml, VPattern *doc, const QString &namePP, const QString &mPath,
|
||||
AddPatternPiece(const QDomElement &xml, VAbstractPattern *doc, const QString &namePP, const QString &mPath,
|
||||
QUndoCommand *parent = 0);
|
||||
virtual ~AddPatternPiece();
|
||||
virtual void undo();
|
||||
|
|
|
@ -27,14 +27,13 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "addtocalc.h"
|
||||
#include "../xml/vpattern.h"
|
||||
#include "../tools/vabstracttool.h"
|
||||
#include "../core/vapplication.h"
|
||||
#include "../libs/vwidgets/vmaingraphicsscene.h"
|
||||
#include "../libs/vwidgets/vmaingraphicsview.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
AddToCalc::AddToCalc(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
||||
AddToCalc::AddToCalc(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent)
|
||||
: VUndoCommand(xml, doc, parent), nameActivDraw(doc->GetNameActivPP()), cursor(doc->getCursor())
|
||||
{
|
||||
setText(tr("Add object"));
|
||||
|
|
|
@ -35,7 +35,7 @@ class AddToCalc : public VUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AddToCalc(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0);
|
||||
AddToCalc(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = 0);
|
||||
virtual ~AddToCalc();
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
|
|
|
@ -27,10 +27,9 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "adduniondetails.h"
|
||||
#include "../xml/vpattern.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
AddUnionDetails::AddUnionDetails(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
||||
AddUnionDetails::AddUnionDetails(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent)
|
||||
: VUndoCommand(xml, doc, parent)
|
||||
{
|
||||
setText(tr("Add union details"));
|
||||
|
@ -47,7 +46,7 @@ void AddUnionDetails::undo()
|
|||
qCDebug(vUndo, "Undo.");
|
||||
|
||||
QDomElement modelingElement;
|
||||
if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement))
|
||||
if (doc->GetActivNodeElement(VAbstractPattern::TagModeling, modelingElement))
|
||||
{
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
|
@ -66,7 +65,7 @@ void AddUnionDetails::undo()
|
|||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't find tag %s.", VPattern::TagModeling.toUtf8().constData());
|
||||
qCDebug(vUndo, "Can't find tag %s.", VAbstractPattern::TagModeling.toUtf8().constData());
|
||||
return;
|
||||
}
|
||||
emit NeedFullParsing();
|
||||
|
@ -78,13 +77,13 @@ void AddUnionDetails::redo()
|
|||
qCDebug(vUndo, "Redo.");
|
||||
|
||||
QDomElement modelingElement;
|
||||
if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement))
|
||||
if (doc->GetActivNodeElement(VAbstractPattern::TagModeling, modelingElement))
|
||||
{
|
||||
modelingElement.appendChild(xml);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't find tag %s.", VPattern::TagModeling.toUtf8().constData());
|
||||
qCDebug(vUndo, "Can't find tag %s.", VAbstractPattern::TagModeling.toUtf8().constData());
|
||||
return;
|
||||
}
|
||||
RedoFullParsing();
|
||||
|
|
|
@ -35,7 +35,7 @@ class AddUnionDetails : public VUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AddUnionDetails(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0);
|
||||
AddUnionDetails(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = 0);
|
||||
virtual ~AddUnionDetails();
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
|
|
|
@ -27,11 +27,10 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "deletedetail.h"
|
||||
#include "../xml/vpattern.h"
|
||||
#include "../tools/vtooldetail.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DeleteDetail::DeleteDetail(VPattern *doc, quint32 id, QUndoCommand *parent)
|
||||
DeleteDetail::DeleteDetail(VAbstractPattern *doc, quint32 id, QUndoCommand *parent)
|
||||
: VUndoCommand(QDomElement(), doc, parent), parentNode(QDomNode()), siblingId(NULL_ID)
|
||||
{
|
||||
setText(tr("Delete tool"));
|
||||
|
|
|
@ -36,7 +36,7 @@ class DeleteDetail : public VUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DeleteDetail(VPattern *doc, quint32 id, QUndoCommand *parent = 0);
|
||||
DeleteDetail(VAbstractPattern *doc, quint32 id, QUndoCommand *parent = 0);
|
||||
virtual ~DeleteDetail();
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
|
|
|
@ -27,11 +27,10 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "deletepatternpiece.h"
|
||||
#include "../xml/vpattern.h"
|
||||
#include "addpatternpiece.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DeletePatternPiece::DeletePatternPiece(VPattern *doc, const QString &namePP, QUndoCommand *parent)
|
||||
DeletePatternPiece::DeletePatternPiece(VAbstractPattern *doc, const QString &namePP, QUndoCommand *parent)
|
||||
: VUndoCommand(QDomElement(), doc, parent), namePP(namePP), patternPiece(QDomElement()), mPath(QString()),
|
||||
previousPPName(QString())
|
||||
{
|
||||
|
@ -41,7 +40,7 @@ DeletePatternPiece::DeletePatternPiece(VPattern *doc, const QString &namePP, QUn
|
|||
patternPiece = patternP.cloneNode().toElement();
|
||||
mPath = doc->MPath();
|
||||
QDomNode previousPP = patternP.previousSibling();//find previous pattern piece
|
||||
previousPPName = doc->GetParametrString(previousPP.toElement(), VPattern::AttrName, "");
|
||||
previousPPName = doc->GetParametrString(previousPP.toElement(), VAbstractPattern::AttrName, "");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -35,7 +35,7 @@ class DeletePatternPiece : public VUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DeletePatternPiece(VPattern *doc, const QString &namePP, QUndoCommand *parent = 0);
|
||||
DeletePatternPiece(VAbstractPattern *doc, const QString &namePP, QUndoCommand *parent = 0);
|
||||
virtual ~DeletePatternPiece();
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
|
|
|
@ -27,12 +27,11 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "deltool.h"
|
||||
#include "../xml/vpattern.h"
|
||||
#include <QGraphicsItem>
|
||||
#include "../tools/vtooldetail.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DelTool::DelTool(VPattern *doc, quint32 id, QUndoCommand *parent)
|
||||
DelTool::DelTool(VAbstractPattern *doc, quint32 id, QUndoCommand *parent)
|
||||
: VUndoCommand(QDomElement(), doc, parent), parentNode(QDomNode()), siblingId(NULL_ID),
|
||||
nameActivDraw(doc->GetNameActivPP())
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ class DelTool : public VUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DelTool(VPattern *doc, quint32 id, QUndoCommand *parent = 0);
|
||||
DelTool(VAbstractPattern *doc, quint32 id, QUndoCommand *parent = 0);
|
||||
virtual ~DelTool();
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
|
|
|
@ -29,13 +29,12 @@
|
|||
#include "movedetail.h"
|
||||
#include <QGraphicsScene>
|
||||
#include <QDomElement>
|
||||
#include "../xml/vpattern.h"
|
||||
#include "../tools/vabstracttool.h"
|
||||
#include "../core/vapplication.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MoveDetail::MoveDetail(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene,
|
||||
QUndoCommand *parent)
|
||||
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)
|
||||
{
|
||||
setText(QObject::tr("Move detail"));
|
||||
|
|
|
@ -37,7 +37,7 @@ class MoveDetail : public VUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MoveDetail(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene,
|
||||
MoveDetail(VAbstractPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene,
|
||||
QUndoCommand *parent = 0);
|
||||
virtual ~MoveDetail();
|
||||
virtual void undo();
|
||||
|
|
|
@ -29,12 +29,11 @@
|
|||
#include "movelabel.h"
|
||||
#include <QGraphicsScene>
|
||||
#include <QDomElement>
|
||||
#include "../xml/vpattern.h"
|
||||
#include "../tools/vabstracttool.h"
|
||||
#include "../core/vapplication.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MoveLabel::MoveLabel(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene,
|
||||
MoveLabel::MoveLabel(VAbstractPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene,
|
||||
QUndoCommand *parent)
|
||||
: VUndoCommand(QDomElement(), doc, parent), oldMx(0.0), oldMy(0.0), newMx(x), newMy(y), scene(scene)
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ class MoveLabel : public VUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MoveLabel(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene,
|
||||
MoveLabel(VAbstractPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene,
|
||||
QUndoCommand *parent = 0);
|
||||
virtual ~MoveLabel();
|
||||
virtual void undo();
|
||||
|
|
|
@ -30,10 +30,9 @@
|
|||
#include "../tools/vabstracttool.h"
|
||||
#include <QDomElement>
|
||||
#include <QGraphicsView>
|
||||
#include "../xml/vpattern.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MoveSpline::MoveSpline(VPattern *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)
|
||||
: VUndoCommand(QDomElement(), doc, parent), oldSpline(*oldSpl), newSpline(newSpl), scene(scene)
|
||||
{
|
||||
|
|
|
@ -38,8 +38,8 @@ class MoveSpline : public VUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MoveSpline(VPattern *doc, const VSpline *oldSpl, const VSpline &spl, const quint32 &id, QGraphicsScene *scene,
|
||||
QUndoCommand *parent = 0);
|
||||
MoveSpline(VAbstractPattern *doc, const VSpline *oldSpl, const VSpline &spl, const quint32 &id,
|
||||
QGraphicsScene *scene, QUndoCommand *parent = 0);
|
||||
virtual ~MoveSpline();
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "../tools/drawTools/vtoolsplinepath.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MoveSplinePath::MoveSplinePath(VPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath,
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -38,8 +38,8 @@ class MoveSplinePath : public VUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MoveSplinePath(VPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath, const quint32 &id,
|
||||
QGraphicsScene *scene, QUndoCommand *parent = 0);
|
||||
MoveSplinePath(VAbstractPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath,
|
||||
const quint32 &id, QGraphicsScene *scene, QUndoCommand *parent = 0);
|
||||
virtual ~MoveSplinePath();
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
|
|
|
@ -29,13 +29,12 @@
|
|||
#include "movespoint.h"
|
||||
#include <QGraphicsScene>
|
||||
#include <QDomElement>
|
||||
#include "../xml/vpattern.h"
|
||||
#include "../tools/vabstracttool.h"
|
||||
#include "../core/vapplication.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MoveSPoint::MoveSPoint(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene,
|
||||
QUndoCommand *parent)
|
||||
MoveSPoint::MoveSPoint(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)
|
||||
{
|
||||
setText(tr("Move single point"));
|
||||
|
|
|
@ -37,7 +37,7 @@ class MoveSPoint : public VUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MoveSPoint(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene,
|
||||
MoveSPoint(VAbstractPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene,
|
||||
QUndoCommand *parent = 0);
|
||||
virtual ~MoveSPoint();
|
||||
virtual void undo();
|
||||
|
|
|
@ -30,10 +30,9 @@
|
|||
|
||||
#include <QComboBox>
|
||||
#include "../options.h"
|
||||
#include "../xml/vpattern.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
RenamePP::RenamePP(VPattern *doc, const QString &newPPname, QComboBox *combo, QUndoCommand *parent)
|
||||
RenamePP::RenamePP(VAbstractPattern *doc, const QString &newPPname, QComboBox *combo, QUndoCommand *parent)
|
||||
:VUndoCommand(QDomElement(), doc, parent), combo(combo), newPPname(newPPname), oldPPname(QString())
|
||||
{
|
||||
setText(tr("Rename pattern piece"));
|
||||
|
|
|
@ -36,7 +36,7 @@ class RenamePP :public VUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RenamePP(VPattern *doc, const QString &newPPname, QComboBox *combo, QUndoCommand *parent = 0);
|
||||
RenamePP(VAbstractPattern *doc, const QString &newPPname, QComboBox *combo, QUndoCommand *parent = 0);
|
||||
virtual ~RenamePP();
|
||||
|
||||
virtual void undo();
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
#include <QGraphicsView>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
SaveDetailOptions::SaveDetailOptions(const VDetail &oldDet, const VDetail &newDet, VPattern *doc, const quint32 &id,
|
||||
QGraphicsScene *scene, QUndoCommand *parent)
|
||||
SaveDetailOptions::SaveDetailOptions(const VDetail &oldDet, const VDetail &newDet, VAbstractPattern *doc,
|
||||
const quint32 &id, QGraphicsScene *scene, QUndoCommand *parent)
|
||||
: VUndoCommand(QDomElement(), doc, parent), oldDet(oldDet), newDet(newDet), scene(scene)
|
||||
{
|
||||
setText(tr("Save detail option"));
|
||||
|
|
|
@ -38,7 +38,7 @@ class SaveDetailOptions : public VUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SaveDetailOptions(const VDetail &oldDet, const VDetail &newDet, VPattern *doc, const quint32 &id,
|
||||
SaveDetailOptions(const VDetail &oldDet, const VDetail &newDet, VAbstractPattern *doc, const quint32 &id,
|
||||
QGraphicsScene *scene, QUndoCommand *parent = 0);
|
||||
virtual ~SaveDetailOptions();
|
||||
virtual void undo();
|
||||
|
|
|
@ -28,11 +28,10 @@
|
|||
|
||||
#include "savetooloptions.h"
|
||||
#include "../options.h"
|
||||
#include "../xml/vpattern.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
SaveToolOptions::SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, VPattern *doc, const quint32 &id,
|
||||
QUndoCommand *parent)
|
||||
SaveToolOptions::SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, VAbstractPattern *doc,
|
||||
const quint32 &id, QUndoCommand *parent)
|
||||
: VUndoCommand(QDomElement(), doc, parent), oldXml(oldXml), newXml(newXml)
|
||||
{
|
||||
setText(tr("Save tool option"));
|
||||
|
|
|
@ -35,7 +35,7 @@ class SaveToolOptions : public VUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, VPattern *doc, const quint32 &id,
|
||||
SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, VAbstractPattern *doc, const quint32 &id,
|
||||
QUndoCommand *parent = 0);
|
||||
virtual ~SaveToolOptions();
|
||||
virtual void undo();
|
||||
|
|
|
@ -27,12 +27,12 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vundocommand.h"
|
||||
#include "../xml/vpattern.h"
|
||||
#include "../../libs/vmisc/def.h"
|
||||
|
||||
Q_LOGGING_CATEGORY(vUndo, "v.undo")
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VUndoCommand::VUndoCommand(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
||||
VUndoCommand::VUndoCommand(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent)
|
||||
:QObject(), QUndoCommand(parent), xml(xml), doc(doc), nodeId(NULL_ID), redoFlag(false)
|
||||
{
|
||||
SCASSERT(doc != nullptr);
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <QDomElement>
|
||||
|
||||
#include "../vmisc/logging.h"
|
||||
#include "../xml/vpattern.h"
|
||||
#include "../libs/ifc/xml/vabstractpattern.h"
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(vUndo)
|
||||
|
||||
|
@ -57,7 +57,7 @@ class VUndoCommand : public QObject, public QUndoCommand
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VUndoCommand(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0);
|
||||
VUndoCommand(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = 0);
|
||||
virtual ~VUndoCommand();
|
||||
signals:
|
||||
void ClearScene();
|
||||
|
@ -65,7 +65,7 @@ signals:
|
|||
void NeedLiteParsing(const Document &parse);
|
||||
protected:
|
||||
QDomElement xml;
|
||||
VPattern *doc;
|
||||
VAbstractPattern *doc;
|
||||
quint32 nodeId;
|
||||
bool redoFlag;
|
||||
virtual void RedoFullParsing();
|
||||
|
|
|
@ -49,81 +49,10 @@
|
|||
#include <QUndoStack>
|
||||
#include <QtCore/qmath.h>
|
||||
|
||||
const QString VPattern::TagPattern = QStringLiteral("pattern");
|
||||
const QString VPattern::TagCalculation = QStringLiteral("calculation");
|
||||
const QString VPattern::TagModeling = QStringLiteral("modeling");
|
||||
const QString VPattern::TagDetails = QStringLiteral("details");
|
||||
const QString VPattern::TagAuthor = QStringLiteral("author");
|
||||
const QString VPattern::TagDescription = QStringLiteral("description");
|
||||
const QString VPattern::TagNotes = QStringLiteral("notes");
|
||||
const QString VPattern::TagMeasurements = QStringLiteral("measurements");
|
||||
const QString VPattern::TagIncrements = QStringLiteral("increments");
|
||||
const QString VPattern::TagIncrement = QStringLiteral("increment");
|
||||
const QString VPattern::TagDraw = QStringLiteral("draw");
|
||||
const QString VPattern::TagPoint = QStringLiteral("point");
|
||||
const QString VPattern::TagLine = QStringLiteral("line");
|
||||
const QString VPattern::TagSpline = QStringLiteral("spline");
|
||||
const QString VPattern::TagArc = QStringLiteral("arc");
|
||||
const QString VPattern::TagTools = QStringLiteral("tools");
|
||||
const QString VPattern::TagGradation = QStringLiteral("gradation");
|
||||
const QString VPattern::TagHeights = QStringLiteral("heights");
|
||||
const QString VPattern::TagSizes = QStringLiteral("sizes");
|
||||
|
||||
const QString VPattern::AttrName = QStringLiteral("name");
|
||||
const QString VPattern::AttrType = QStringLiteral("type");
|
||||
const QString VPattern::AttrPath = QStringLiteral("path");
|
||||
|
||||
const QString VPattern::AttrAll = QStringLiteral("all");
|
||||
|
||||
const QString VPattern::AttrH92 = QStringLiteral("h92");
|
||||
const QString VPattern::AttrH98 = QStringLiteral("h98");
|
||||
const QString VPattern::AttrH104 = QStringLiteral("h104");
|
||||
const QString VPattern::AttrH110 = QStringLiteral("h110");
|
||||
const QString VPattern::AttrH116 = QStringLiteral("h116");
|
||||
const QString VPattern::AttrH122 = QStringLiteral("h122");
|
||||
const QString VPattern::AttrH128 = QStringLiteral("h128");
|
||||
const QString VPattern::AttrH134 = QStringLiteral("h134");
|
||||
const QString VPattern::AttrH140 = QStringLiteral("h140");
|
||||
const QString VPattern::AttrH146 = QStringLiteral("h146");
|
||||
const QString VPattern::AttrH152 = QStringLiteral("h152");
|
||||
const QString VPattern::AttrH158 = QStringLiteral("h158");
|
||||
const QString VPattern::AttrH164 = QStringLiteral("h164");
|
||||
const QString VPattern::AttrH170 = QStringLiteral("h170");
|
||||
const QString VPattern::AttrH176 = QStringLiteral("h176");
|
||||
const QString VPattern::AttrH182 = QStringLiteral("h182");
|
||||
const QString VPattern::AttrH188 = QStringLiteral("h188");
|
||||
const QString VPattern::AttrH194 = QStringLiteral("h194");
|
||||
|
||||
const QString VPattern::AttrS22 = QStringLiteral("s22");
|
||||
const QString VPattern::AttrS24 = QStringLiteral("s24");
|
||||
const QString VPattern::AttrS26 = QStringLiteral("s26");
|
||||
const QString VPattern::AttrS28 = QStringLiteral("s28");
|
||||
const QString VPattern::AttrS30 = QStringLiteral("s30");
|
||||
const QString VPattern::AttrS32 = QStringLiteral("s32");
|
||||
const QString VPattern::AttrS34 = QStringLiteral("s34");
|
||||
const QString VPattern::AttrS36 = QStringLiteral("s36");
|
||||
const QString VPattern::AttrS38 = QStringLiteral("s38");
|
||||
const QString VPattern::AttrS40 = QStringLiteral("s40");
|
||||
const QString VPattern::AttrS42 = QStringLiteral("s42");
|
||||
const QString VPattern::AttrS44 = QStringLiteral("s44");
|
||||
const QString VPattern::AttrS46 = QStringLiteral("s46");
|
||||
const QString VPattern::AttrS48 = QStringLiteral("s48");
|
||||
const QString VPattern::AttrS50 = QStringLiteral("s50");
|
||||
const QString VPattern::AttrS52 = QStringLiteral("s52");
|
||||
const QString VPattern::AttrS54 = QStringLiteral("s54");
|
||||
const QString VPattern::AttrS56 = QStringLiteral("s56");
|
||||
|
||||
const QString VPattern::IncrementName = QStringLiteral("name");
|
||||
const QString VPattern::IncrementBase = QStringLiteral("base");
|
||||
const QString VPattern::IncrementKsize = QStringLiteral("ksize");
|
||||
const QString VPattern::IncrementKgrowth = QStringLiteral("kgrowth");
|
||||
const QString VPattern::IncrementDescription = QStringLiteral("description");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPattern::VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *sceneDraw,
|
||||
VMainGraphicsScene *sceneDetail, QObject *parent)
|
||||
: QObject(parent), VDomDocument(), data(data), nameActivPP(QString()), tools(QHash<quint32, VDataTool*>()),
|
||||
history(QVector<VToolRecord>()), cursor(0), patternPieces(QStringList()), mode(mode), sceneDraw(sceneDraw),
|
||||
: VAbstractPattern(parent), data(data), patternPieces(QStringList()), mode(mode), sceneDraw(sceneDraw),
|
||||
sceneDetail(sceneDetail)
|
||||
{
|
||||
SCASSERT(sceneDraw != nullptr);
|
||||
|
@ -167,132 +96,6 @@ void VPattern::CreateEmptyFile(const QString &tablePath)
|
|||
insertBefore(createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""), this->firstChild());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ChangeActivPP set new active pattern piece name.
|
||||
* @param name new name.
|
||||
* @param parse parser file mode.
|
||||
*/
|
||||
void VPattern::ChangeActivPP(const QString &name, const Document &parse)
|
||||
{
|
||||
Q_ASSERT_X(name.isEmpty() == false, "ChangeActivPP", "name pattern piece is empty");
|
||||
if (CheckExistNamePP(name) && this->nameActivPP != name)
|
||||
{
|
||||
this->nameActivPP = name;
|
||||
if (parse == Document::FullParse)
|
||||
{
|
||||
emit ChangedActivPP(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetActivDrawElement return draw tag for current pattern peace.
|
||||
* @param element draw tag.
|
||||
* @return true if found.
|
||||
*/
|
||||
bool VPattern::GetActivDrawElement(QDomElement &element) const
|
||||
{
|
||||
if (nameActivPP.isEmpty() == false)
|
||||
{
|
||||
const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw );
|
||||
if (elements.size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for ( qint32 i = 0; i < elements.count(); i++ )
|
||||
{
|
||||
element = elements.at( i ).toElement();
|
||||
if (element.isNull() == false)
|
||||
{
|
||||
const QString fieldName = element.attribute( AttrName );
|
||||
if ( fieldName == nameActivPP )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
element = QDomElement();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief appendPP add new pattern piece.
|
||||
*
|
||||
* Method check if not exist pattern piece with the same name and change name active pattern piece name, send signal
|
||||
* about change pattern piece. Doen't add pattern piece to file structure. This task make SPoint tool.
|
||||
* @param name pattern peace name.
|
||||
* @return true if success.
|
||||
*/
|
||||
bool VPattern::appendPP(const QString &name)
|
||||
{
|
||||
Q_ASSERT_X(name.isEmpty() == false, "appendPP", "name pattern piece is empty");
|
||||
if (name.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (CheckExistNamePP(name) == false)
|
||||
{
|
||||
if (nameActivPP.isEmpty())
|
||||
{
|
||||
SetActivPP(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->nameActivPP = name;
|
||||
emit ChangedActivPP(name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ChangeNamePP change pattern piece name.
|
||||
* @param oldName old pattern piece name.
|
||||
* @param newName new pattern piece name.
|
||||
* @return true if success.
|
||||
*/
|
||||
bool VPattern::ChangeNamePP(const QString& oldName, const QString &newName)
|
||||
{
|
||||
Q_ASSERT_X(newName.isEmpty() == false, "SetNamePP", "new name pattern piece is empty");
|
||||
Q_ASSERT_X(oldName.isEmpty() == false, "SetNamePP", "old name pattern piece is empty");
|
||||
|
||||
if (CheckExistNamePP(oldName) == false)
|
||||
{
|
||||
qDebug()<<"Do not exist pattern piece with name"<<oldName;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (CheckExistNamePP(newName))
|
||||
{
|
||||
qDebug()<<"Already exist pattern piece with name"<<newName;
|
||||
return false;
|
||||
}
|
||||
|
||||
QDomElement ppElement = GetPPElement(oldName);
|
||||
if (ppElement.isElement())
|
||||
{
|
||||
if (nameActivPP == oldName)
|
||||
{
|
||||
nameActivPP = newName;
|
||||
}
|
||||
ppElement.setAttribute(AttrName, newName);
|
||||
emit patternChanged(false);//For situation when we change name directly, without undocommands.
|
||||
emit ChangedNameDraw(oldName, newName);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()<<"Can't find pattern piece node with name"<<oldName<<Q_FUNC_INFO;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Parse parse file.
|
||||
|
@ -384,41 +187,6 @@ void VPattern::Parse(const Document &parse)
|
|||
emit CheckLayout();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief getTool return tool from tool list.
|
||||
* @param id tool id.
|
||||
* @return tool.
|
||||
*/
|
||||
VDataTool *VPattern::getTool(const quint32 &id)
|
||||
{
|
||||
ToolExists(id);
|
||||
return tools.value(id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::ToolExists(const quint32 &id) const
|
||||
{
|
||||
if (tools.contains(id) == false)
|
||||
{
|
||||
throw VExceptionBadId(tr("Can't find tool in table."), id);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief setCursor set cursor.
|
||||
* @param value cursor.
|
||||
*/
|
||||
void VPattern::setCursor(const quint32 &value)
|
||||
{
|
||||
if (cursor != value)
|
||||
{
|
||||
cursor = value;
|
||||
emit ChangedCursor(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief setCurrentData set current data set.
|
||||
|
@ -491,19 +259,6 @@ void VPattern::setCurrentData()
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief AddTool add tool to list tools.
|
||||
* @param id tool id.
|
||||
* @param tool tool.
|
||||
*/
|
||||
void VPattern::AddTool(const quint32 &id, VDataTool *tool)
|
||||
{
|
||||
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
||||
SCASSERT(tool != nullptr);
|
||||
tools.insert(id, tool);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief UpdateToolData update tool in list tools.
|
||||
|
@ -520,34 +275,6 @@ void VPattern::UpdateToolData(const quint32 &id, VContainer *data)
|
|||
tool->VDataTool::setData(data);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief IncrementReferens increment reference parent objects.
|
||||
* @param id parent object id.
|
||||
*/
|
||||
void VPattern::IncrementReferens(quint32 id) const
|
||||
{
|
||||
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
||||
ToolExists(id);
|
||||
VDataTool *tool = tools.value(id);
|
||||
SCASSERT(tool != nullptr);
|
||||
tool->incrementReferens();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief DecrementReferens decrement reference parent objects.
|
||||
* @param id parent object id.
|
||||
*/
|
||||
void VPattern::DecrementReferens(quint32 id) const
|
||||
{
|
||||
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
||||
ToolExists(id);
|
||||
VDataTool *tool = tools.value(id);
|
||||
SCASSERT(tool != nullptr);
|
||||
tool->decrementReferens();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief SPointActiveDraw return id base point current pattern peace.
|
||||
|
@ -576,171 +303,6 @@ quint32 VPattern::SPointActiveDraw()
|
|||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief CheckNameDraw check if exist pattern peace with this name.
|
||||
* @param name pattern peace name.
|
||||
* @return true if exist.
|
||||
*/
|
||||
bool VPattern::CheckExistNamePP(const QString &name) const
|
||||
{
|
||||
Q_ASSERT_X(name.isEmpty() == false, "CheckNameDraw", "name draw is empty");
|
||||
const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw );
|
||||
if (elements.size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for ( qint32 i = 0; i < elements.count(); i++ )
|
||||
{
|
||||
const QDomElement elem = elements.at( i ).toElement();
|
||||
if (elem.isNull() == false)
|
||||
{
|
||||
if ( GetParametrString(elem, AttrName) == name )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief SetActivPP set current pattern piece.
|
||||
* @param name pattern peace name.
|
||||
*/
|
||||
void VPattern::SetActivPP(const QString &name)
|
||||
{
|
||||
Q_ASSERT_X(name.isEmpty() == false, "SetActivPP", "name pattern piece is empty");
|
||||
this->nameActivPP = name;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetActivNodeElement find element in current pattern piece by name.
|
||||
* @param name name tag.
|
||||
* @param element element.
|
||||
* @return true if found.
|
||||
*/
|
||||
bool VPattern::GetActivNodeElement(const QString &name, QDomElement &element) const
|
||||
{
|
||||
Q_ASSERT_X(name.isEmpty() == false, "GetActivNodeElement", "name draw is empty");
|
||||
QDomElement drawElement;
|
||||
if (GetActivDrawElement(drawElement))
|
||||
{
|
||||
const QDomNodeList listElement = drawElement.elementsByTagName(name);
|
||||
if (listElement.size() != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
element = listElement.at( 0 ).toElement();
|
||||
if (element.isNull() == false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VPattern::MPath() const
|
||||
{
|
||||
QDomNodeList list = elementsByTagName(TagMeasurements);
|
||||
QDomElement element = list.at(0).toElement();
|
||||
if (element.isElement())
|
||||
{
|
||||
return GetParametrString(element, AttrPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::SetPath(const QString &path)
|
||||
{
|
||||
if (path.isEmpty())
|
||||
{
|
||||
qDebug()<<"Path to measurements is empty"<<Q_FUNC_INFO;
|
||||
return;
|
||||
}
|
||||
QDomNodeList list = elementsByTagName(TagMeasurements);
|
||||
QDomElement element = list.at(0).toElement();
|
||||
if (element.isElement())
|
||||
{
|
||||
SetAttribute(element, AttrPath, path);
|
||||
emit patternChanged(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()<<"Can't save path to measurements"<<Q_FUNC_INFO;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
Unit VPattern::MUnit() const
|
||||
{
|
||||
QDomNodeList list = elementsByTagName(VPattern::TagMeasurements);
|
||||
QDomElement element = list.at(0).toElement();
|
||||
if (element.isElement())
|
||||
{
|
||||
QStringList units = QStringList() <<"mm" << "cm" << "inch";
|
||||
QString unit = GetParametrString(element, AttrUnit);
|
||||
switch (units.indexOf(unit))
|
||||
{
|
||||
case 0:// mm
|
||||
return Unit::Mm;
|
||||
break;
|
||||
case 1:// cm
|
||||
return Unit::Cm;
|
||||
break;
|
||||
case 2:// in
|
||||
return Unit::Inch;
|
||||
break;
|
||||
default:
|
||||
return Unit::Cm;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Unit::Cm;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MeasurementsType VPattern::MType() const
|
||||
{
|
||||
QDomNodeList list = elementsByTagName(VPattern::TagMeasurements);
|
||||
QDomElement element = list.at(0).toElement();
|
||||
if (element.isElement())
|
||||
{
|
||||
QString type = GetParametrString(element, AttrType);
|
||||
QStringList types = QStringList() << "standard" << "individual";
|
||||
switch (types.indexOf(type))
|
||||
{
|
||||
case 0:// standard
|
||||
return MeasurementsType::Standard;
|
||||
break;
|
||||
case 1:// individual
|
||||
return MeasurementsType::Individual;
|
||||
break;
|
||||
default:
|
||||
return MeasurementsType::Individual;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return MeasurementsType::Individual;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VPattern::SaveDocument(const QString &fileName, QString &error) const
|
||||
{
|
||||
|
@ -2740,43 +2302,6 @@ void VPattern::ToolsCommonAttributes(const QDomElement &domElement, quint32 &id)
|
|||
id = GetParametrId(domElement);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDomElement VPattern::GetPPElement(const QString &name)
|
||||
{
|
||||
if (name.isEmpty() == false)
|
||||
{
|
||||
const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw );
|
||||
if (elements.size() == 0)
|
||||
{
|
||||
return QDomElement();
|
||||
}
|
||||
for ( qint32 i = 0; i < elements.count(); i++ )
|
||||
{
|
||||
QDomElement element = elements.at( i ).toElement();
|
||||
if (element.isNull() == false)
|
||||
{
|
||||
if ( element.attribute( AttrName ) == name )
|
||||
{
|
||||
return element;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return QDomElement();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VPattern::CountPP() const
|
||||
{
|
||||
const QDomElement rootElement = this->documentElement();
|
||||
if (rootElement.isNull())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return rootElement.elementsByTagName( TagDraw ).count();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QRectF VPattern::ActiveDrawBoundingRect() const
|
||||
{
|
||||
|
@ -2893,61 +2418,30 @@ QRectF VPattern::ToolBoundingRect(const QRectF &rec, const quint32 &id) const
|
|||
return recTool;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<VToolRecord> VPattern::getLocalHistory() const
|
||||
/**
|
||||
* @brief IncrementReferens increment reference parent objects.
|
||||
* @param id parent object id.
|
||||
*/
|
||||
void VPattern::IncrementReferens(quint32 id) const
|
||||
{
|
||||
QVector<VToolRecord> historyPP;
|
||||
for (qint32 i = 0; i< history.size(); ++i)
|
||||
{
|
||||
const VToolRecord tool = history.at(i);
|
||||
if (tool.getNameDraw() != GetNameActivPP())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
historyPP.append(tool);
|
||||
}
|
||||
return historyPP;
|
||||
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
||||
ToolExists(id);
|
||||
VDataTool *tool = tools.value(id);
|
||||
SCASSERT(tool != nullptr);
|
||||
tool->incrementReferens();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VPattern::SiblingNodeId(const quint32 &nodeId) const
|
||||
/**
|
||||
* @brief DecrementReferens decrement reference parent objects.
|
||||
* @param id parent object id.
|
||||
*/
|
||||
void VPattern::DecrementReferens(quint32 id) const
|
||||
{
|
||||
quint32 siblingId = NULL_ID;
|
||||
|
||||
const QVector<VToolRecord> history = getLocalHistory();
|
||||
for (qint32 i = 0; i < history.size(); ++i)
|
||||
{
|
||||
const VToolRecord tool = history.at(i);
|
||||
if (nodeId == tool.getId())
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
siblingId = NULL_ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (qint32 j = i; j > 0; --j)
|
||||
{
|
||||
const VToolRecord tool = history.at(j-1);
|
||||
switch ( tool.getTypeTool() )
|
||||
{
|
||||
case Tool::Detail:
|
||||
case Tool::UnionDetails:
|
||||
case Tool::NodeArc:
|
||||
case Tool::NodePoint:
|
||||
case Tool::NodeSpline:
|
||||
case Tool::NodeSplinePath:
|
||||
continue;
|
||||
break;
|
||||
default:
|
||||
siblingId = tool.getId();
|
||||
j = 0;// break loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return siblingId;
|
||||
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
||||
ToolExists(id);
|
||||
VDataTool *tool = tools.value(id);
|
||||
SCASSERT(tool != nullptr);
|
||||
tool->decrementReferens();
|
||||
}
|
||||
|
|
|
@ -29,126 +29,37 @@
|
|||
#ifndef VPATTERN_H
|
||||
#define VPATTERN_H
|
||||
|
||||
#include "../libs/ifc/xml/vdomdocument.h"
|
||||
#include "../libs/ifc/xml/vabstractpattern.h"
|
||||
#include "../libs/ifc/xml/vtoolrecord.h"
|
||||
#include "../libs/vpatterndb/vcontainer.h"
|
||||
|
||||
class VDataTool;
|
||||
class VMainGraphicsScene;
|
||||
|
||||
enum class Document : char { LiteParse, LitePPParse, FullParse };
|
||||
enum class LabelType : char {NewPatternPiece, NewLabel};
|
||||
enum class CrossCirclesPoint : char {FirstPoint = 1, SecondPoint = 2};
|
||||
|
||||
/**
|
||||
* @brief The VPattern class working with pattern file.
|
||||
*/
|
||||
class VPattern : public QObject, public VDomDocument
|
||||
class VPattern : public VAbstractPattern
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
void CreateEmptyFile(const QString &tablePath);
|
||||
void ChangeActivPP(const QString& name, const Document &parse = Document::FullParse);
|
||||
QString GetNameActivPP() const;
|
||||
bool GetActivDrawElement(QDomElement &element) const;
|
||||
bool appendPP(const QString& name);
|
||||
bool ChangeNamePP(const QString& oldName, const QString &newName);
|
||||
QDomElement GetPPElement(const QString &name);
|
||||
bool CheckExistNamePP(const QString& name) const;
|
||||
int CountPP() const;
|
||||
virtual void CreateEmptyFile(const QString &tablePath);
|
||||
|
||||
void Parse(const Document &parse);
|
||||
QHash<quint32, VDataTool*>* getTools();
|
||||
VDataTool* getTool(const quint32 &id);
|
||||
QVector<VToolRecord> *getHistory();
|
||||
QVector<VToolRecord> getLocalHistory() const;
|
||||
quint32 getCursor() const;
|
||||
void setCursor(const quint32 &value);
|
||||
|
||||
void setCurrentData();
|
||||
void AddTool(const quint32 &id, VDataTool *tool);
|
||||
void UpdateToolData(const quint32 &id, VContainer *data);
|
||||
void IncrementReferens(quint32 id) const;
|
||||
void DecrementReferens(quint32 id) const;
|
||||
|
||||
virtual void IncrementReferens(quint32 id) const;
|
||||
virtual void DecrementReferens(quint32 id) const;
|
||||
|
||||
quint32 SPointActiveDraw();
|
||||
bool isPatternModified() const;
|
||||
void setPatternModified(bool value);
|
||||
bool GetActivNodeElement(const QString& name, QDomElement& element) const;
|
||||
QString MPath() const;
|
||||
void SetPath(const QString &path);
|
||||
Unit MUnit() const;
|
||||
MeasurementsType MType() const;
|
||||
static const QString TagPattern;
|
||||
static const QString TagCalculation;
|
||||
static const QString TagModeling;
|
||||
static const QString TagDetails;
|
||||
static const QString TagAuthor;
|
||||
static const QString TagDescription;
|
||||
static const QString TagNotes;
|
||||
static const QString TagMeasurements;
|
||||
static const QString TagIncrements;
|
||||
static const QString TagIncrement;
|
||||
static const QString TagDraw;
|
||||
static const QString TagPoint;
|
||||
static const QString TagLine;
|
||||
static const QString TagSpline;
|
||||
static const QString TagArc;
|
||||
static const QString TagTools;
|
||||
static const QString TagGradation;
|
||||
static const QString TagHeights;
|
||||
static const QString TagSizes;
|
||||
|
||||
static const QString AttrName;
|
||||
static const QString AttrType;
|
||||
static const QString AttrPath;
|
||||
|
||||
static const QString AttrAll;
|
||||
|
||||
static const QString AttrH92;
|
||||
static const QString AttrH98;
|
||||
static const QString AttrH104;
|
||||
static const QString AttrH110;
|
||||
static const QString AttrH116;
|
||||
static const QString AttrH122;
|
||||
static const QString AttrH128;
|
||||
static const QString AttrH134;
|
||||
static const QString AttrH140;
|
||||
static const QString AttrH146;
|
||||
static const QString AttrH152;
|
||||
static const QString AttrH158;
|
||||
static const QString AttrH164;
|
||||
static const QString AttrH170;
|
||||
static const QString AttrH176;
|
||||
static const QString AttrH182;
|
||||
static const QString AttrH188;
|
||||
static const QString AttrH194;
|
||||
|
||||
static const QString AttrS22;
|
||||
static const QString AttrS24;
|
||||
static const QString AttrS26;
|
||||
static const QString AttrS28;
|
||||
static const QString AttrS30;
|
||||
static const QString AttrS32;
|
||||
static const QString AttrS34;
|
||||
static const QString AttrS36;
|
||||
static const QString AttrS38;
|
||||
static const QString AttrS40;
|
||||
static const QString AttrS42;
|
||||
static const QString AttrS44;
|
||||
static const QString AttrS46;
|
||||
static const QString AttrS48;
|
||||
static const QString AttrS50;
|
||||
static const QString AttrS52;
|
||||
static const QString AttrS54;
|
||||
static const QString AttrS56;
|
||||
|
||||
static const QString IncrementName;
|
||||
static const QString IncrementBase;
|
||||
static const QString IncrementKsize;
|
||||
static const QString IncrementKgrowth;
|
||||
static const QString IncrementDescription;
|
||||
|
||||
virtual bool SaveDocument(const QString &fileName, QString &error) const;
|
||||
QStringList getPatternPieces() const;
|
||||
|
@ -174,43 +85,6 @@ public:
|
|||
|
||||
QString GenerateLabel(const LabelType &type)const;
|
||||
|
||||
quint32 SiblingNodeId(const quint32 &nodeId) const;
|
||||
signals:
|
||||
/**
|
||||
* @brief ChangedActivDraw change active pattern peace.
|
||||
* @param newName new pattern peace name.
|
||||
*/
|
||||
void ChangedActivPP(const QString &newName);
|
||||
/**
|
||||
* @brief ChangedNameDraw save new name pattern peace.
|
||||
* @param oldName old name.
|
||||
* @param newName new name.
|
||||
*/
|
||||
void ChangedNameDraw(const QString &oldName, const QString &newName);
|
||||
/**
|
||||
* @brief FullUpdateFromFile update tool data form file.
|
||||
*/
|
||||
void FullUpdateFromFile();
|
||||
/**
|
||||
* @brief patternChanged emit if we have unsaved change.
|
||||
*/
|
||||
void patternChanged(bool saved);
|
||||
/**
|
||||
* @brief ShowTool highlight tool.
|
||||
* @param id tool id.
|
||||
* @param enable enable or disable highlight.
|
||||
*/
|
||||
void ShowTool(quint32 id, bool enable);
|
||||
/**
|
||||
* @brief ChangedCursor change cursor position.
|
||||
* @param id tool id.
|
||||
*/
|
||||
void ChangedCursor(quint32 id);
|
||||
void ClearMainWindow();
|
||||
void UndoCommand();
|
||||
void SetEnabledGUI(bool enabled);
|
||||
void CheckLayout();
|
||||
void SetCurrentPP(const QString &patterPiece);
|
||||
public slots:
|
||||
void LiteParseTree(const Document &parse);
|
||||
void haveLiteChange();
|
||||
|
@ -225,18 +99,6 @@ private:
|
|||
/** @brief data container with data. */
|
||||
VContainer *data;
|
||||
|
||||
/** @brief nameActivDraw name current pattern peace. */
|
||||
QString nameActivPP;
|
||||
|
||||
/** @brief tools list with pointer on tools. */
|
||||
QHash<quint32, VDataTool*> tools;
|
||||
|
||||
/** @brief history history records. */
|
||||
QVector<VToolRecord> history;
|
||||
|
||||
/** @brief cursor cursor keep id tool after which we will add new tool in file. */
|
||||
quint32 cursor;
|
||||
|
||||
/** @brief patternPieces list of patern pieces names for combobox*/
|
||||
QStringList patternPieces;
|
||||
|
||||
|
@ -246,7 +108,6 @@ private:
|
|||
VMainGraphicsScene *sceneDraw;
|
||||
VMainGraphicsScene *sceneDetail;
|
||||
|
||||
void SetActivPP(const QString& name);
|
||||
void ParseDrawElement(const QDomNode& node, const Document &parse);
|
||||
void ParseDrawMode(const QDomNode& node, const Document &parse, const Draw &mode);
|
||||
void ParseDetailElement(const QDomElement &domElement,
|
||||
|
@ -278,49 +139,8 @@ private:
|
|||
void ParseCurrentPP();
|
||||
void CheckTagExists(const QString &tag);
|
||||
QString GetLabelBase(unsigned int index)const;
|
||||
void ToolExists(const quint32 &id) const;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetNameActivPP return current pattern piece name.
|
||||
* @return pattern piece name.
|
||||
*/
|
||||
inline QString VPattern::GetNameActivPP() const
|
||||
{
|
||||
return nameActivPP;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief getTools return list of tools pointers.
|
||||
* @return list.
|
||||
*/
|
||||
inline QHash<quint32, VDataTool *> *VPattern::getTools()
|
||||
{
|
||||
return &tools;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief getHistory return list with list of history records.
|
||||
* @return list of history records.
|
||||
*/
|
||||
inline QVector<VToolRecord> *VPattern::getHistory()
|
||||
{
|
||||
return &history;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief getCursor return cursor.
|
||||
* @return cursor.
|
||||
*/
|
||||
inline quint32 VPattern::getCursor() const
|
||||
{
|
||||
return cursor;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline QStringList VPattern::getPatternPieces() const
|
||||
{
|
||||
|
|
560
src/libs/ifc/xml/vabstractpattern.cpp
Normal file
560
src/libs/ifc/xml/vabstractpattern.cpp
Normal file
|
@ -0,0 +1,560 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vabstractpattern.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 15 6, 2015
|
||||
**
|
||||
** @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) 2015 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 "vabstractpattern.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "exception/vexceptionbadid.h"
|
||||
|
||||
const QString VAbstractPattern::TagPattern = QStringLiteral("pattern");
|
||||
const QString VAbstractPattern::TagCalculation = QStringLiteral("calculation");
|
||||
const QString VAbstractPattern::TagModeling = QStringLiteral("modeling");
|
||||
const QString VAbstractPattern::TagDetails = QStringLiteral("details");
|
||||
const QString VAbstractPattern::TagAuthor = QStringLiteral("author");
|
||||
const QString VAbstractPattern::TagDescription = QStringLiteral("description");
|
||||
const QString VAbstractPattern::TagNotes = QStringLiteral("notes");
|
||||
const QString VAbstractPattern::TagMeasurements = QStringLiteral("measurements");
|
||||
const QString VAbstractPattern::TagIncrements = QStringLiteral("increments");
|
||||
const QString VAbstractPattern::TagIncrement = QStringLiteral("increment");
|
||||
const QString VAbstractPattern::TagDraw = QStringLiteral("draw");
|
||||
const QString VAbstractPattern::TagPoint = QStringLiteral("point");
|
||||
const QString VAbstractPattern::TagLine = QStringLiteral("line");
|
||||
const QString VAbstractPattern::TagSpline = QStringLiteral("spline");
|
||||
const QString VAbstractPattern::TagArc = QStringLiteral("arc");
|
||||
const QString VAbstractPattern::TagTools = QStringLiteral("tools");
|
||||
const QString VAbstractPattern::TagGradation = QStringLiteral("gradation");
|
||||
const QString VAbstractPattern::TagHeights = QStringLiteral("heights");
|
||||
const QString VAbstractPattern::TagSizes = QStringLiteral("sizes");
|
||||
|
||||
const QString VAbstractPattern::AttrName = QStringLiteral("name");
|
||||
const QString VAbstractPattern::AttrType = QStringLiteral("type");
|
||||
const QString VAbstractPattern::AttrPath = QStringLiteral("path");
|
||||
|
||||
const QString VAbstractPattern::AttrAll = QStringLiteral("all");
|
||||
|
||||
const QString VAbstractPattern::AttrH92 = QStringLiteral("h92");
|
||||
const QString VAbstractPattern::AttrH98 = QStringLiteral("h98");
|
||||
const QString VAbstractPattern::AttrH104 = QStringLiteral("h104");
|
||||
const QString VAbstractPattern::AttrH110 = QStringLiteral("h110");
|
||||
const QString VAbstractPattern::AttrH116 = QStringLiteral("h116");
|
||||
const QString VAbstractPattern::AttrH122 = QStringLiteral("h122");
|
||||
const QString VAbstractPattern::AttrH128 = QStringLiteral("h128");
|
||||
const QString VAbstractPattern::AttrH134 = QStringLiteral("h134");
|
||||
const QString VAbstractPattern::AttrH140 = QStringLiteral("h140");
|
||||
const QString VAbstractPattern::AttrH146 = QStringLiteral("h146");
|
||||
const QString VAbstractPattern::AttrH152 = QStringLiteral("h152");
|
||||
const QString VAbstractPattern::AttrH158 = QStringLiteral("h158");
|
||||
const QString VAbstractPattern::AttrH164 = QStringLiteral("h164");
|
||||
const QString VAbstractPattern::AttrH170 = QStringLiteral("h170");
|
||||
const QString VAbstractPattern::AttrH176 = QStringLiteral("h176");
|
||||
const QString VAbstractPattern::AttrH182 = QStringLiteral("h182");
|
||||
const QString VAbstractPattern::AttrH188 = QStringLiteral("h188");
|
||||
const QString VAbstractPattern::AttrH194 = QStringLiteral("h194");
|
||||
|
||||
const QString VAbstractPattern::AttrS22 = QStringLiteral("s22");
|
||||
const QString VAbstractPattern::AttrS24 = QStringLiteral("s24");
|
||||
const QString VAbstractPattern::AttrS26 = QStringLiteral("s26");
|
||||
const QString VAbstractPattern::AttrS28 = QStringLiteral("s28");
|
||||
const QString VAbstractPattern::AttrS30 = QStringLiteral("s30");
|
||||
const QString VAbstractPattern::AttrS32 = QStringLiteral("s32");
|
||||
const QString VAbstractPattern::AttrS34 = QStringLiteral("s34");
|
||||
const QString VAbstractPattern::AttrS36 = QStringLiteral("s36");
|
||||
const QString VAbstractPattern::AttrS38 = QStringLiteral("s38");
|
||||
const QString VAbstractPattern::AttrS40 = QStringLiteral("s40");
|
||||
const QString VAbstractPattern::AttrS42 = QStringLiteral("s42");
|
||||
const QString VAbstractPattern::AttrS44 = QStringLiteral("s44");
|
||||
const QString VAbstractPattern::AttrS46 = QStringLiteral("s46");
|
||||
const QString VAbstractPattern::AttrS48 = QStringLiteral("s48");
|
||||
const QString VAbstractPattern::AttrS50 = QStringLiteral("s50");
|
||||
const QString VAbstractPattern::AttrS52 = QStringLiteral("s52");
|
||||
const QString VAbstractPattern::AttrS54 = QStringLiteral("s54");
|
||||
const QString VAbstractPattern::AttrS56 = QStringLiteral("s56");
|
||||
|
||||
const QString VAbstractPattern::IncrementName = QStringLiteral("name");
|
||||
const QString VAbstractPattern::IncrementBase = QStringLiteral("base");
|
||||
const QString VAbstractPattern::IncrementKsize = QStringLiteral("ksize");
|
||||
const QString VAbstractPattern::IncrementKgrowth = QStringLiteral("kgrowth");
|
||||
const QString VAbstractPattern::IncrementDescription = QStringLiteral("description");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractPattern::VAbstractPattern(QObject *parent)
|
||||
: QObject(parent), VDomDocument(), nameActivPP(QString()), cursor(0), tools(QHash<quint32, VDataTool*>()),
|
||||
history(QVector<VToolRecord>())
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractPattern::~VAbstractPattern()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ChangeActivPP set new active pattern piece name.
|
||||
* @param name new name.
|
||||
* @param parse parser file mode.
|
||||
*/
|
||||
void VAbstractPattern::ChangeActivPP(const QString &name, const Document &parse)
|
||||
{
|
||||
Q_ASSERT_X(name.isEmpty() == false, "ChangeActivPP", "name pattern piece is empty");
|
||||
if (CheckExistNamePP(name) && this->nameActivPP != name)
|
||||
{
|
||||
this->nameActivPP = name;
|
||||
if (parse == Document::FullParse)
|
||||
{
|
||||
emit ChangedActivPP(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetNameActivPP return current pattern piece name.
|
||||
* @return pattern piece name.
|
||||
*/
|
||||
QString VAbstractPattern::GetNameActivPP() const
|
||||
{
|
||||
return nameActivPP;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetActivDrawElement return draw tag for current pattern peace.
|
||||
* @param element draw tag.
|
||||
* @return true if found.
|
||||
*/
|
||||
bool VAbstractPattern::GetActivDrawElement(QDomElement &element) const
|
||||
{
|
||||
if (nameActivPP.isEmpty() == false)
|
||||
{
|
||||
const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw );
|
||||
if (elements.size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for ( qint32 i = 0; i < elements.count(); i++ )
|
||||
{
|
||||
element = elements.at( i ).toElement();
|
||||
if (element.isNull() == false)
|
||||
{
|
||||
const QString fieldName = element.attribute( AttrName );
|
||||
if ( fieldName == nameActivPP )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
element = QDomElement();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief CheckNameDraw check if exist pattern peace with this name.
|
||||
* @param name pattern peace name.
|
||||
* @return true if exist.
|
||||
*/
|
||||
bool VAbstractPattern::CheckExistNamePP(const QString &name) const
|
||||
{
|
||||
Q_ASSERT_X(name.isEmpty() == false, "CheckNameDraw", "name draw is empty");
|
||||
const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw );
|
||||
if (elements.size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for ( qint32 i = 0; i < elements.count(); i++ )
|
||||
{
|
||||
const QDomElement elem = elements.at( i ).toElement();
|
||||
if (elem.isNull() == false)
|
||||
{
|
||||
if ( GetParametrString(elem, AttrName) == name )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetActivNodeElement find element in current pattern piece by name.
|
||||
* @param name name tag.
|
||||
* @param element element.
|
||||
* @return true if found.
|
||||
*/
|
||||
bool VAbstractPattern::GetActivNodeElement(const QString &name, QDomElement &element) const
|
||||
{
|
||||
Q_ASSERT_X(name.isEmpty() == false, "GetActivNodeElement", "name draw is empty");
|
||||
QDomElement drawElement;
|
||||
if (GetActivDrawElement(drawElement))
|
||||
{
|
||||
const QDomNodeList listElement = drawElement.elementsByTagName(name);
|
||||
if (listElement.size() != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
element = listElement.at( 0 ).toElement();
|
||||
if (element.isNull() == false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VAbstractPattern::CountPP() const
|
||||
{
|
||||
const QDomElement rootElement = this->documentElement();
|
||||
if (rootElement.isNull())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return rootElement.elementsByTagName( TagDraw ).count();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDomElement VAbstractPattern::GetPPElement(const QString &name)
|
||||
{
|
||||
if (name.isEmpty() == false)
|
||||
{
|
||||
const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw );
|
||||
if (elements.size() == 0)
|
||||
{
|
||||
return QDomElement();
|
||||
}
|
||||
for ( qint32 i = 0; i < elements.count(); i++ )
|
||||
{
|
||||
QDomElement element = elements.at( i ).toElement();
|
||||
if (element.isNull() == false)
|
||||
{
|
||||
if ( element.attribute( AttrName ) == name )
|
||||
{
|
||||
return element;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return QDomElement();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ChangeNamePP change pattern piece name.
|
||||
* @param oldName old pattern piece name.
|
||||
* @param newName new pattern piece name.
|
||||
* @return true if success.
|
||||
*/
|
||||
bool VAbstractPattern::ChangeNamePP(const QString &oldName, const QString &newName)
|
||||
{
|
||||
Q_ASSERT_X(newName.isEmpty() == false, "SetNamePP", "new name pattern piece is empty");
|
||||
Q_ASSERT_X(oldName.isEmpty() == false, "SetNamePP", "old name pattern piece is empty");
|
||||
|
||||
if (CheckExistNamePP(oldName) == false)
|
||||
{
|
||||
qDebug()<<"Do not exist pattern piece with name"<<oldName;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (CheckExistNamePP(newName))
|
||||
{
|
||||
qDebug()<<"Already exist pattern piece with name"<<newName;
|
||||
return false;
|
||||
}
|
||||
|
||||
QDomElement ppElement = GetPPElement(oldName);
|
||||
if (ppElement.isElement())
|
||||
{
|
||||
if (nameActivPP == oldName)
|
||||
{
|
||||
nameActivPP = newName;
|
||||
}
|
||||
ppElement.setAttribute(AttrName, newName);
|
||||
emit patternChanged(false);//For situation when we change name directly, without undocommands.
|
||||
emit ChangedNameDraw(oldName, newName);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()<<"Can't find pattern piece node with name"<<oldName<<Q_FUNC_INFO;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief appendPP add new pattern piece.
|
||||
*
|
||||
* Method check if not exist pattern piece with the same name and change name active pattern piece name, send signal
|
||||
* about change pattern piece. Doen't add pattern piece to file structure. This task make SPoint tool.
|
||||
* @param name pattern peace name.
|
||||
* @return true if success.
|
||||
*/
|
||||
bool VAbstractPattern::appendPP(const QString &name)
|
||||
{
|
||||
Q_ASSERT_X(name.isEmpty() == false, "appendPP", "name pattern piece is empty");
|
||||
if (name.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (CheckExistNamePP(name) == false)
|
||||
{
|
||||
SetActivPP(name);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VAbstractPattern::getCursor() const
|
||||
{
|
||||
return cursor;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractPattern::setCursor(const quint32 &value)
|
||||
{
|
||||
if (cursor != value)
|
||||
{
|
||||
cursor = value;
|
||||
emit ChangedCursor(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief getTool return tool from tool list.
|
||||
* @param id tool id.
|
||||
* @return tool.
|
||||
*/
|
||||
VDataTool *VAbstractPattern::getTool(const quint32 &id)
|
||||
{
|
||||
ToolExists(id);
|
||||
return tools.value(id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief AddTool add tool to list tools.
|
||||
* @param id tool id.
|
||||
* @param tool tool.
|
||||
*/
|
||||
void VAbstractPattern::AddTool(const quint32 &id, VDataTool *tool)
|
||||
{
|
||||
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
||||
SCASSERT(tool != nullptr);
|
||||
tools.insert(id, tool);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief getHistory return list with list of history records.
|
||||
* @return list of history records.
|
||||
*/
|
||||
QVector<VToolRecord> *VAbstractPattern::getHistory()
|
||||
{
|
||||
return &history;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<VToolRecord> VAbstractPattern::getLocalHistory() const
|
||||
{
|
||||
QVector<VToolRecord> historyPP;
|
||||
for (qint32 i = 0; i< history.size(); ++i)
|
||||
{
|
||||
const VToolRecord tool = history.at(i);
|
||||
if (tool.getNameDraw() != GetNameActivPP())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
historyPP.append(tool);
|
||||
}
|
||||
return historyPP;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VAbstractPattern::MPath() const
|
||||
{
|
||||
QDomNodeList list = elementsByTagName(TagMeasurements);
|
||||
QDomElement element = list.at(0).toElement();
|
||||
if (element.isElement())
|
||||
{
|
||||
return GetParametrString(element, AttrPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractPattern::SetPath(const QString &path)
|
||||
{
|
||||
if (path.isEmpty())
|
||||
{
|
||||
qDebug()<<"Path to measurements is empty"<<Q_FUNC_INFO;
|
||||
return;
|
||||
}
|
||||
QDomNodeList list = elementsByTagName(TagMeasurements);
|
||||
QDomElement element = list.at(0).toElement();
|
||||
if (element.isElement())
|
||||
{
|
||||
SetAttribute(element, AttrPath, path);
|
||||
emit patternChanged(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()<<"Can't save path to measurements"<<Q_FUNC_INFO;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
Unit VAbstractPattern::MUnit() const
|
||||
{
|
||||
QDomNodeList list = elementsByTagName(VAbstractPattern::TagMeasurements);
|
||||
QDomElement element = list.at(0).toElement();
|
||||
if (element.isElement())
|
||||
{
|
||||
QStringList units = QStringList() <<"mm" << "cm" << "inch";
|
||||
QString unit = GetParametrString(element, AttrUnit);
|
||||
switch (units.indexOf(unit))
|
||||
{
|
||||
case 0:// mm
|
||||
return Unit::Mm;
|
||||
break;
|
||||
case 1:// cm
|
||||
return Unit::Cm;
|
||||
break;
|
||||
case 2:// in
|
||||
return Unit::Inch;
|
||||
break;
|
||||
default:
|
||||
return Unit::Cm;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Unit::Cm;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MeasurementsType VAbstractPattern::MType() const
|
||||
{
|
||||
QDomNodeList list = elementsByTagName(VAbstractPattern::TagMeasurements);
|
||||
QDomElement element = list.at(0).toElement();
|
||||
if (element.isElement())
|
||||
{
|
||||
QString type = GetParametrString(element, AttrType);
|
||||
QStringList types = QStringList() << "standard" << "individual";
|
||||
switch (types.indexOf(type))
|
||||
{
|
||||
case 0:// standard
|
||||
return MeasurementsType::Standard;
|
||||
break;
|
||||
case 1:// individual
|
||||
return MeasurementsType::Individual;
|
||||
break;
|
||||
default:
|
||||
return MeasurementsType::Individual;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return MeasurementsType::Individual;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VAbstractPattern::SiblingNodeId(const quint32 &nodeId) const
|
||||
{
|
||||
quint32 siblingId = NULL_ID;
|
||||
|
||||
const QVector<VToolRecord> history = getLocalHistory();
|
||||
for (qint32 i = 0; i < history.size(); ++i)
|
||||
{
|
||||
const VToolRecord tool = history.at(i);
|
||||
if (nodeId == tool.getId())
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
siblingId = NULL_ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (qint32 j = i; j > 0; --j)
|
||||
{
|
||||
const VToolRecord tool = history.at(j-1);
|
||||
switch ( tool.getTypeTool() )
|
||||
{
|
||||
case Tool::Detail:
|
||||
case Tool::UnionDetails:
|
||||
case Tool::NodeArc:
|
||||
case Tool::NodePoint:
|
||||
case Tool::NodeSpline:
|
||||
case Tool::NodeSplinePath:
|
||||
continue;
|
||||
break;
|
||||
default:
|
||||
siblingId = tool.getId();
|
||||
j = 0;// break loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return siblingId;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractPattern::ToolExists(const quint32 &id) const
|
||||
{
|
||||
if (tools.contains(id) == false)
|
||||
{
|
||||
throw VExceptionBadId(tr("Can't find tool in table."), id);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief SetActivPP set current pattern piece.
|
||||
* @param name pattern peace name.
|
||||
*/
|
||||
void VAbstractPattern::SetActivPP(const QString &name)
|
||||
{
|
||||
Q_ASSERT_X(name.isEmpty() == false, "SetActivPP", "name pattern piece is empty");
|
||||
this->nameActivPP = name;
|
||||
emit ChangedActivPP(name);
|
||||
}
|
221
src/libs/ifc/xml/vabstractpattern.h
Normal file
221
src/libs/ifc/xml/vabstractpattern.h
Normal file
|
@ -0,0 +1,221 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vabstractpattern.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 15 6, 2015
|
||||
**
|
||||
** @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) 2015 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/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef VABSTRACTPATTERN_H
|
||||
#define VABSTRACTPATTERN_H
|
||||
|
||||
#include "vdomdocument.h"
|
||||
#include "vtoolrecord.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
enum class Document : char { LiteParse, LitePPParse, FullParse };
|
||||
|
||||
class VDataTool;
|
||||
|
||||
class VAbstractPattern : public QObject, public VDomDocument
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VAbstractPattern(QObject *parent = nullptr);
|
||||
virtual ~VAbstractPattern();
|
||||
|
||||
virtual void CreateEmptyFile(const QString &tablePath)=0;
|
||||
|
||||
void ChangeActivPP(const QString& name, const Document &parse = Document::FullParse);
|
||||
QString GetNameActivPP() const;
|
||||
bool CheckExistNamePP(const QString& name) const;
|
||||
int CountPP() const;
|
||||
QDomElement GetPPElement(const QString &name);
|
||||
bool ChangeNamePP(const QString& oldName, const QString &newName);
|
||||
bool appendPP(const QString& name);
|
||||
|
||||
bool GetActivDrawElement(QDomElement &element) const;
|
||||
bool GetActivNodeElement(const QString& name, QDomElement& element) const;
|
||||
|
||||
quint32 getCursor() const;
|
||||
void setCursor(const quint32 &value);
|
||||
|
||||
virtual void IncrementReferens(quint32 id) const=0;
|
||||
virtual void DecrementReferens(quint32 id) const=0;
|
||||
|
||||
QHash<quint32, VDataTool *> *getTools();
|
||||
VDataTool *getTool(const quint32 &id);
|
||||
void AddTool(const quint32 &id, VDataTool *tool);
|
||||
|
||||
QVector<VToolRecord> *getHistory();
|
||||
QVector<VToolRecord> getLocalHistory() const;
|
||||
|
||||
QString MPath() const;
|
||||
void SetPath(const QString &path);
|
||||
Unit MUnit() const;
|
||||
MeasurementsType MType() const;
|
||||
|
||||
quint32 SiblingNodeId(const quint32 &nodeId) const;
|
||||
|
||||
static const QString TagPattern;
|
||||
static const QString TagCalculation;
|
||||
static const QString TagModeling;
|
||||
static const QString TagDetails;
|
||||
static const QString TagAuthor;
|
||||
static const QString TagDescription;
|
||||
static const QString TagNotes;
|
||||
static const QString TagMeasurements;
|
||||
static const QString TagIncrements;
|
||||
static const QString TagIncrement;
|
||||
static const QString TagDraw;
|
||||
static const QString TagPoint;
|
||||
static const QString TagLine;
|
||||
static const QString TagSpline;
|
||||
static const QString TagArc;
|
||||
static const QString TagTools;
|
||||
static const QString TagGradation;
|
||||
static const QString TagHeights;
|
||||
static const QString TagSizes;
|
||||
|
||||
static const QString AttrName;
|
||||
static const QString AttrType;
|
||||
static const QString AttrPath;
|
||||
|
||||
static const QString AttrAll;
|
||||
|
||||
static const QString AttrH92;
|
||||
static const QString AttrH98;
|
||||
static const QString AttrH104;
|
||||
static const QString AttrH110;
|
||||
static const QString AttrH116;
|
||||
static const QString AttrH122;
|
||||
static const QString AttrH128;
|
||||
static const QString AttrH134;
|
||||
static const QString AttrH140;
|
||||
static const QString AttrH146;
|
||||
static const QString AttrH152;
|
||||
static const QString AttrH158;
|
||||
static const QString AttrH164;
|
||||
static const QString AttrH170;
|
||||
static const QString AttrH176;
|
||||
static const QString AttrH182;
|
||||
static const QString AttrH188;
|
||||
static const QString AttrH194;
|
||||
|
||||
static const QString AttrS22;
|
||||
static const QString AttrS24;
|
||||
static const QString AttrS26;
|
||||
static const QString AttrS28;
|
||||
static const QString AttrS30;
|
||||
static const QString AttrS32;
|
||||
static const QString AttrS34;
|
||||
static const QString AttrS36;
|
||||
static const QString AttrS38;
|
||||
static const QString AttrS40;
|
||||
static const QString AttrS42;
|
||||
static const QString AttrS44;
|
||||
static const QString AttrS46;
|
||||
static const QString AttrS48;
|
||||
static const QString AttrS50;
|
||||
static const QString AttrS52;
|
||||
static const QString AttrS54;
|
||||
static const QString AttrS56;
|
||||
|
||||
static const QString IncrementName;
|
||||
static const QString IncrementBase;
|
||||
static const QString IncrementKsize;
|
||||
static const QString IncrementKgrowth;
|
||||
static const QString IncrementDescription;
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief ChangedActivDraw change active pattern peace.
|
||||
* @param newName new pattern peace name.
|
||||
*/
|
||||
void ChangedActivPP(const QString &newName);
|
||||
|
||||
/**
|
||||
* @brief ChangedCursor change cursor position.
|
||||
* @param id tool id.
|
||||
*/
|
||||
void ChangedCursor(quint32 id);
|
||||
|
||||
/**
|
||||
* @brief ChangedNameDraw save new name pattern peace.
|
||||
* @param oldName old name.
|
||||
* @param newName new name.
|
||||
*/
|
||||
void ChangedNameDraw(const QString &oldName, const QString &newName);
|
||||
/**
|
||||
* @brief FullUpdateFromFile update tool data form file.
|
||||
*/
|
||||
void FullUpdateFromFile();
|
||||
/**
|
||||
* @brief patternChanged emit if we have unsaved change.
|
||||
*/
|
||||
void patternChanged(bool saved);
|
||||
/**
|
||||
* @brief ShowTool highlight tool.
|
||||
* @param id tool id.
|
||||
* @param enable enable or disable highlight.
|
||||
*/
|
||||
void ShowTool(quint32 id, bool enable);
|
||||
void ClearMainWindow();
|
||||
void UndoCommand();
|
||||
void SetEnabledGUI(bool enabled);
|
||||
void CheckLayout();
|
||||
void SetCurrentPP(const QString &patterPiece);
|
||||
|
||||
protected:
|
||||
/** @brief nameActivDraw name current pattern peace. */
|
||||
QString nameActivPP;
|
||||
|
||||
/** @brief cursor cursor keep id tool after which we will add new tool in file. */
|
||||
quint32 cursor;
|
||||
|
||||
/** @brief tools list with pointer on tools. */
|
||||
QHash<quint32, VDataTool*> tools;
|
||||
|
||||
/** @brief history history records. */
|
||||
QVector<VToolRecord> history;
|
||||
|
||||
void ToolExists(const quint32 &id) const;
|
||||
|
||||
void SetActivPP(const QString& name);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VAbstractPattern)
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief getTools return list of tools pointers.
|
||||
* @return list.
|
||||
*/
|
||||
inline QHash<quint32, VDataTool *> *VAbstractPattern::getTools()
|
||||
{
|
||||
return &tools;
|
||||
}
|
||||
|
||||
#endif // VABSTRACTPATTERN_H
|
|
@ -5,10 +5,12 @@ HEADERS += \
|
|||
$$PWD/vabstractconverter.h \
|
||||
$$PWD/vdomdocument.h \
|
||||
$$PWD/vpatternconverter.h \
|
||||
$$PWD/vtoolrecord.h
|
||||
$$PWD/vtoolrecord.h \
|
||||
xml/vabstractpattern.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/vabstractconverter.cpp \
|
||||
$$PWD/vdomdocument.cpp \
|
||||
$$PWD/vpatternconverter.cpp \
|
||||
$$PWD/vtoolrecord.cpp
|
||||
$$PWD/vtoolrecord.cpp \
|
||||
xml/vabstractpattern.cpp
|
||||
|
|
Loading…
Reference in New Issue
Block a user