diff --git a/src/app/core/vtooloptionspropertybrowser.cpp b/src/app/core/vtooloptionspropertybrowser.cpp index 0ef4f58e9..7e47f60cf 100644 --- a/src/app/core/vtooloptionspropertybrowser.cpp +++ b/src/app/core/vtooloptionspropertybrowser.cpp @@ -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" diff --git a/src/app/tools/drawTools/vabstractspline.h b/src/app/tools/drawTools/vabstractspline.h index 6dfe08709..48f90295c 100644 --- a/src/app/tools/drawTools/vabstractspline.h +++ b/src/app/tools/drawTools/vabstractspline.h @@ -31,7 +31,7 @@ #include "vdrawtool.h" #include -#include "../../visualization/vcontrolpointspline.h" +#include "../libs/vwidgets/vcontrolpointspline.h" class VAbstractSpline:public VDrawTool, public QGraphicsPathItem { diff --git a/src/app/tools/drawTools/vtoolpoint.cpp b/src/app/tools/drawTools/vtoolpoint.cpp index 5e8c522c2..91d2ddf01 100644 --- a/src/app/tools/drawTools/vtoolpoint.cpp +++ b/src/app/tools/drawTools/vtoolpoint.cpp @@ -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 diff --git a/src/app/tools/drawTools/vtoolsinglepoint.cpp b/src/app/tools/drawTools/vtoolsinglepoint.cpp index c763fa9dd..f8b8c521c 100644 --- a/src/app/tools/drawTools/vtoolsinglepoint.cpp +++ b/src/app/tools/drawTools/vtoolsinglepoint.cpp @@ -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" diff --git a/src/app/tools/drawTools/vtoolsplinepath.cpp b/src/app/tools/drawTools/vtoolsplinepath.cpp index 6d0498938..0b176cfa1 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolsplinepath.cpp @@ -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); diff --git a/src/app/tools/drawTools/vtoolsplinepath.h b/src/app/tools/drawTools/vtoolsplinepath.h index 0cddec8f3..feb1bbf82 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.h +++ b/src/app/tools/drawTools/vtoolsplinepath.h @@ -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(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); }; diff --git a/src/app/tools/nodeDetails/vnodepoint.cpp b/src/app/tools/nodeDetails/vnodepoint.cpp index 93a521acf..b019f370d 100644 --- a/src/app/tools/nodeDetails/vnodepoint.cpp +++ b/src/app/tools/nodeDetails/vnodepoint.cpp @@ -30,7 +30,7 @@ #include "../../core/vapplication.h" #include "../../libs/vgeometry/vpointf.h" -#include "../../visualization/vgraphicssimpletextitem.h" +#include "../../libs/vwidgets/vgraphicssimpletextitem.h" #include #include #include diff --git a/src/app/tools/vtooldetail.cpp b/src/app/tools/vtooldetail.cpp index 2412bac8c..6303b5284 100644 --- a/src/app/tools/vtooldetail.cpp +++ b/src/app/tools/vtooldetail.cpp @@ -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); diff --git a/src/app/tools/vtooldetail.h b/src/app/tools/vtooldetail.h index 17ee686f8..4105efd4f 100644 --- a/src/app/tools/vtooldetail.h +++ b/src/app/tools/vtooldetail.h @@ -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(Tool::Detail)}; virtual QString getTagName() const; diff --git a/src/app/undocommands/adddet.cpp b/src/app/undocommands/adddet.cpp index d522598f8..197404b5a 100644 --- a/src/app/undocommands/adddet.cpp +++ b/src/app/undocommands/adddet.cpp @@ -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(); diff --git a/src/app/undocommands/adddet.h b/src/app/undocommands/adddet.h index 230c216e7..53e05fb39 100644 --- a/src/app/undocommands/adddet.h +++ b/src/app/undocommands/adddet.h @@ -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(); diff --git a/src/app/undocommands/adddetnode.cpp b/src/app/undocommands/adddetnode.cpp index c46c0d86d..de1b5b64b 100644 --- a/src/app/undocommands/adddetnode.cpp +++ b/src/app/undocommands/adddetnode.cpp @@ -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; } } diff --git a/src/app/undocommands/adddetnode.h b/src/app/undocommands/adddetnode.h index d58b255dc..8db44930d 100644 --- a/src/app/undocommands/adddetnode.h +++ b/src/app/undocommands/adddetnode.h @@ -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(); diff --git a/src/app/undocommands/addpatternpiece.cpp b/src/app/undocommands/addpatternpiece.cpp index 04c88df46..253f89e77 100644 --- a/src/app/undocommands/addpatternpiece.cpp +++ b/src/app/undocommands/addpatternpiece.cpp @@ -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); diff --git a/src/app/undocommands/addpatternpiece.h b/src/app/undocommands/addpatternpiece.h index 52416ac01..2e900267a 100644 --- a/src/app/undocommands/addpatternpiece.h +++ b/src/app/undocommands/addpatternpiece.h @@ -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(); diff --git a/src/app/undocommands/addtocalc.cpp b/src/app/undocommands/addtocalc.cpp index bab94b40a..0ef79f65b 100644 --- a/src/app/undocommands/addtocalc.cpp +++ b/src/app/undocommands/addtocalc.cpp @@ -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")); diff --git a/src/app/undocommands/addtocalc.h b/src/app/undocommands/addtocalc.h index 261be91df..388caf91e 100644 --- a/src/app/undocommands/addtocalc.h +++ b/src/app/undocommands/addtocalc.h @@ -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(); diff --git a/src/app/undocommands/adduniondetails.cpp b/src/app/undocommands/adduniondetails.cpp index f04f1cce8..a10c47340 100644 --- a/src/app/undocommands/adduniondetails.cpp +++ b/src/app/undocommands/adduniondetails.cpp @@ -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(); diff --git a/src/app/undocommands/adduniondetails.h b/src/app/undocommands/adduniondetails.h index 29ab151d4..e14e8a5f9 100644 --- a/src/app/undocommands/adduniondetails.h +++ b/src/app/undocommands/adduniondetails.h @@ -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(); diff --git a/src/app/undocommands/deletedetail.cpp b/src/app/undocommands/deletedetail.cpp index eeff845de..3cfc70ff0 100644 --- a/src/app/undocommands/deletedetail.cpp +++ b/src/app/undocommands/deletedetail.cpp @@ -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")); diff --git a/src/app/undocommands/deletedetail.h b/src/app/undocommands/deletedetail.h index 8923d5244..46a991f35 100644 --- a/src/app/undocommands/deletedetail.h +++ b/src/app/undocommands/deletedetail.h @@ -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(); diff --git a/src/app/undocommands/deletepatternpiece.cpp b/src/app/undocommands/deletepatternpiece.cpp index eb14c56b1..d8649f13c 100644 --- a/src/app/undocommands/deletepatternpiece.cpp +++ b/src/app/undocommands/deletepatternpiece.cpp @@ -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, ""); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/undocommands/deletepatternpiece.h b/src/app/undocommands/deletepatternpiece.h index 1d29fab5d..64ff5027c 100644 --- a/src/app/undocommands/deletepatternpiece.h +++ b/src/app/undocommands/deletepatternpiece.h @@ -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(); diff --git a/src/app/undocommands/deltool.cpp b/src/app/undocommands/deltool.cpp index 3d9455b9b..8114c434e 100644 --- a/src/app/undocommands/deltool.cpp +++ b/src/app/undocommands/deltool.cpp @@ -27,12 +27,11 @@ *************************************************************************/ #include "deltool.h" -#include "../xml/vpattern.h" #include #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()) { diff --git a/src/app/undocommands/deltool.h b/src/app/undocommands/deltool.h index f92f9463f..dce673687 100644 --- a/src/app/undocommands/deltool.h +++ b/src/app/undocommands/deltool.h @@ -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(); diff --git a/src/app/undocommands/movedetail.cpp b/src/app/undocommands/movedetail.cpp index a05dc8817..6fb508f91 100644 --- a/src/app/undocommands/movedetail.cpp +++ b/src/app/undocommands/movedetail.cpp @@ -29,13 +29,12 @@ #include "movedetail.h" #include #include -#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")); diff --git a/src/app/undocommands/movedetail.h b/src/app/undocommands/movedetail.h index 2c42a396a..3886d6252 100644 --- a/src/app/undocommands/movedetail.h +++ b/src/app/undocommands/movedetail.h @@ -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(); diff --git a/src/app/undocommands/movelabel.cpp b/src/app/undocommands/movelabel.cpp index 4443975a2..edb284a22 100644 --- a/src/app/undocommands/movelabel.cpp +++ b/src/app/undocommands/movelabel.cpp @@ -29,12 +29,11 @@ #include "movelabel.h" #include #include -#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) { diff --git a/src/app/undocommands/movelabel.h b/src/app/undocommands/movelabel.h index f3d277560..fcbfc6d2f 100644 --- a/src/app/undocommands/movelabel.h +++ b/src/app/undocommands/movelabel.h @@ -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(); diff --git a/src/app/undocommands/movespline.cpp b/src/app/undocommands/movespline.cpp index ca50e7226..a09f0ed55 100644 --- a/src/app/undocommands/movespline.cpp +++ b/src/app/undocommands/movespline.cpp @@ -30,10 +30,9 @@ #include "../tools/vabstracttool.h" #include #include -#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) { diff --git a/src/app/undocommands/movespline.h b/src/app/undocommands/movespline.h index b9f369be4..afdbd6a00 100644 --- a/src/app/undocommands/movespline.h +++ b/src/app/undocommands/movespline.h @@ -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(); diff --git a/src/app/undocommands/movesplinepath.cpp b/src/app/undocommands/movesplinepath.cpp index 2520c3530..dff694b2f 100644 --- a/src/app/undocommands/movesplinepath.cpp +++ b/src/app/undocommands/movesplinepath.cpp @@ -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) { diff --git a/src/app/undocommands/movesplinepath.h b/src/app/undocommands/movesplinepath.h index 3f05c84e7..60571fc3d 100644 --- a/src/app/undocommands/movesplinepath.h +++ b/src/app/undocommands/movesplinepath.h @@ -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(); diff --git a/src/app/undocommands/movespoint.cpp b/src/app/undocommands/movespoint.cpp index 9a21d871f..53fbc93c6 100644 --- a/src/app/undocommands/movespoint.cpp +++ b/src/app/undocommands/movespoint.cpp @@ -29,13 +29,12 @@ #include "movespoint.h" #include #include -#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")); diff --git a/src/app/undocommands/movespoint.h b/src/app/undocommands/movespoint.h index 49e1d4ad2..62dd6d0b8 100644 --- a/src/app/undocommands/movespoint.h +++ b/src/app/undocommands/movespoint.h @@ -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(); diff --git a/src/app/undocommands/renamepp.cpp b/src/app/undocommands/renamepp.cpp index f80c39d0e..3aee58ca4 100644 --- a/src/app/undocommands/renamepp.cpp +++ b/src/app/undocommands/renamepp.cpp @@ -30,10 +30,9 @@ #include #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")); diff --git a/src/app/undocommands/renamepp.h b/src/app/undocommands/renamepp.h index 84e790ac3..c52c7a01c 100644 --- a/src/app/undocommands/renamepp.h +++ b/src/app/undocommands/renamepp.h @@ -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(); diff --git a/src/app/undocommands/savedetailoptions.cpp b/src/app/undocommands/savedetailoptions.cpp index 179bdc9f2..2a9c7cf67 100644 --- a/src/app/undocommands/savedetailoptions.cpp +++ b/src/app/undocommands/savedetailoptions.cpp @@ -31,8 +31,8 @@ #include //--------------------------------------------------------------------------------------------------------------------- -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")); diff --git a/src/app/undocommands/savedetailoptions.h b/src/app/undocommands/savedetailoptions.h index 9fb4394e8..a32b4fd91 100644 --- a/src/app/undocommands/savedetailoptions.h +++ b/src/app/undocommands/savedetailoptions.h @@ -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(); diff --git a/src/app/undocommands/savetooloptions.cpp b/src/app/undocommands/savetooloptions.cpp index 9db984d78..99299c95d 100644 --- a/src/app/undocommands/savetooloptions.cpp +++ b/src/app/undocommands/savetooloptions.cpp @@ -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")); diff --git a/src/app/undocommands/savetooloptions.h b/src/app/undocommands/savetooloptions.h index 21cd29d9e..2051b7e53 100644 --- a/src/app/undocommands/savetooloptions.h +++ b/src/app/undocommands/savetooloptions.h @@ -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(); diff --git a/src/app/undocommands/vundocommand.cpp b/src/app/undocommands/vundocommand.cpp index 873f66081..8ec73d30b 100644 --- a/src/app/undocommands/vundocommand.cpp +++ b/src/app/undocommands/vundocommand.cpp @@ -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); diff --git a/src/app/undocommands/vundocommand.h b/src/app/undocommands/vundocommand.h index dc86281f8..608f91dfe 100644 --- a/src/app/undocommands/vundocommand.h +++ b/src/app/undocommands/vundocommand.h @@ -33,7 +33,7 @@ #include #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(); diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index 1ec85ab58..c518d4fe3 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -49,81 +49,10 @@ #include #include -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()), - history(QVector()), 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"< 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"<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 VPattern::getLocalHistory() const +/** + * @brief IncrementReferens increment reference parent objects. + * @param id parent object id. + */ +void VPattern::IncrementReferens(quint32 id) const { - QVector 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 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(); } diff --git a/src/app/xml/vpattern.h b/src/app/xml/vpattern.h index 9dc53bdff..3d5b99a4d 100644 --- a/src/app/xml/vpattern.h +++ b/src/app/xml/vpattern.h @@ -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* getTools(); - VDataTool* getTool(const quint32 &id); - QVector *getHistory(); - QVector 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 tools; - - /** @brief history history records. */ - QVector 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 *VPattern::getTools() -{ - return &tools; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getHistory return list with list of history records. - * @return list of history records. - */ -inline QVector *VPattern::getHistory() -{ - return &history; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getCursor return cursor. - * @return cursor. - */ -inline quint32 VPattern::getCursor() const -{ - return cursor; -} - //--------------------------------------------------------------------------------------------------------------------- inline QStringList VPattern::getPatternPieces() const { diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp new file mode 100644 index 000000000..878fdef35 --- /dev/null +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -0,0 +1,560 @@ +/************************************************************************ + ** + ** @file vabstractpattern.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 . + ** + *************************************************************************/ + +#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()), + history(QVector()) +{} + +//--------------------------------------------------------------------------------------------------------------------- +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"< 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 *VAbstractPattern::getHistory() +{ + return &history; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VAbstractPattern::getLocalHistory() const +{ + QVector 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"< 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); +} diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h new file mode 100644 index 000000000..4c3b16bbe --- /dev/null +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -0,0 +1,221 @@ +/************************************************************************ + ** + ** @file vabstractpattern.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 . + ** + *************************************************************************/ + +#ifndef VABSTRACTPATTERN_H +#define VABSTRACTPATTERN_H + +#include "vdomdocument.h" +#include "vtoolrecord.h" + +#include + +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 *getTools(); + VDataTool *getTool(const quint32 &id); + void AddTool(const quint32 &id, VDataTool *tool); + + QVector *getHistory(); + QVector 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 tools; + + /** @brief history history records. */ + QVector 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 *VAbstractPattern::getTools() +{ + return &tools; +} + +#endif // VABSTRACTPATTERN_H diff --git a/src/libs/ifc/xml/xml.pri b/src/libs/ifc/xml/xml.pri index 81fd98886..65b44e814 100644 --- a/src/libs/ifc/xml/xml.pri +++ b/src/libs/ifc/xml/xml.pri @@ -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