From de0200ca2a154ba6e96f14924bc55f53eceedb3b Mon Sep 17 00:00:00 2001 From: dismine Date: Tue, 25 Feb 2014 16:02:09 +0200 Subject: [PATCH] Refactoring VDomDocument, creation VPattern class. --HG-- branch : feature --- src/container/vcontainer.cpp | 1 + src/dialogs/app/dialoghistory.cpp | 14 +- src/dialogs/app/dialoghistory.h | 6 +- src/dialogs/app/dialogincrements.cpp | 8 +- src/dialogs/app/dialogincrements.h | 6 +- src/dialogs/app/dialogpatternproperties.cpp | 4 +- src/dialogs/app/dialogpatternproperties.h | 6 +- src/mainwindow.cpp | 8 +- src/mainwindow.h | 2 +- src/tools/drawTools/vdrawtool.cpp | 10 +- src/tools/drawTools/vdrawtool.h | 4 +- src/tools/drawTools/vtoolalongline.cpp | 48 +- src/tools/drawTools/vtoolalongline.h | 6 +- src/tools/drawTools/vtoolarc.cpp | 34 +- src/tools/drawTools/vtoolarc.h | 6 +- src/tools/drawTools/vtoolbisector.cpp | 54 +- src/tools/drawTools/vtoolbisector.h | 6 +- src/tools/drawTools/vtoolcutarc.cpp | 36 +- src/tools/drawTools/vtoolcutarc.h | 6 +- src/tools/drawTools/vtoolcutspline.cpp | 36 +- src/tools/drawTools/vtoolcutspline.h | 6 +- src/tools/drawTools/vtoolcutsplinepath.cpp | 36 +- src/tools/drawTools/vtoolcutsplinepath.h | 6 +- src/tools/drawTools/vtoolendline.cpp | 48 +- src/tools/drawTools/vtoolendline.h | 6 +- src/tools/drawTools/vtoolheight.cpp | 50 +- src/tools/drawTools/vtoolheight.h | 6 +- src/tools/drawTools/vtoolline.cpp | 26 +- src/tools/drawTools/vtoolline.h | 6 +- src/tools/drawTools/vtoollineintersect.cpp | 48 +- src/tools/drawTools/vtoollineintersect.h | 6 +- src/tools/drawTools/vtoollinepoint.cpp | 2 +- src/tools/drawTools/vtoollinepoint.h | 2 +- src/tools/drawTools/vtoolnormal.cpp | 54 +- src/tools/drawTools/vtoolnormal.h | 6 +- src/tools/drawTools/vtoolpoint.cpp | 6 +- src/tools/drawTools/vtoolpoint.h | 2 +- src/tools/drawTools/vtoolpointofcontact.cpp | 48 +- src/tools/drawTools/vtoolpointofcontact.h | 6 +- .../drawTools/vtoolpointofintersection.cpp | 36 +- .../drawTools/vtoolpointofintersection.h | 6 +- src/tools/drawTools/vtoolshoulderpoint.cpp | 54 +- src/tools/drawTools/vtoolshoulderpoint.h | 6 +- src/tools/drawTools/vtoolsinglepoint.cpp | 36 +- src/tools/drawTools/vtoolsinglepoint.h | 2 +- src/tools/drawTools/vtoolspline.cpp | 62 +- src/tools/drawTools/vtoolspline.h | 6 +- src/tools/drawTools/vtoolsplinepath.cpp | 34 +- src/tools/drawTools/vtoolsplinepath.h | 6 +- src/tools/drawTools/vtooltriangle.cpp | 48 +- src/tools/drawTools/vtooltriangle.h | 6 +- src/tools/nodeDetails/vabstractnode.cpp | 4 +- src/tools/nodeDetails/vabstractnode.h | 2 +- src/tools/nodeDetails/vnodearc.cpp | 16 +- src/tools/nodeDetails/vnodearc.h | 4 +- src/tools/nodeDetails/vnodepoint.cpp | 28 +- src/tools/nodeDetails/vnodepoint.h | 4 +- src/tools/nodeDetails/vnodespline.cpp | 16 +- src/tools/nodeDetails/vnodespline.h | 4 +- src/tools/nodeDetails/vnodesplinepath.cpp | 16 +- src/tools/nodeDetails/vnodesplinepath.h | 4 +- src/tools/vabstracttool.cpp | 10 +- src/tools/vabstracttool.h | 27 +- src/tools/vtooldetail.cpp | 60 +- src/tools/vtooldetail.h | 6 +- src/tools/vtooluniondetails.cpp | 42 +- src/tools/vtooluniondetails.h | 10 +- src/widgets/vsimplesplinepath.cpp | 2 +- src/widgets/vsimplesplinepath.h | 2 +- src/xml/vdomdocument.cpp | 1342 +---------------- src/xml/vdomdocument.h | 395 +---- src/xml/vpattern.cpp | 1265 ++++++++++++++++ src/xml/vpattern.h | 367 +++++ src/xml/xml.pri | 6 +- 74 files changed, 2291 insertions(+), 2314 deletions(-) create mode 100644 src/xml/vpattern.cpp create mode 100644 src/xml/vpattern.h diff --git a/src/container/vcontainer.cpp b/src/container/vcontainer.cpp index ddac8b87a..bcda3190d 100644 --- a/src/container/vcontainer.cpp +++ b/src/container/vcontainer.cpp @@ -275,6 +275,7 @@ void VContainer::Clear() lengthArcs.clear(); lineAngles.clear(); details.clear(); + lengthSplines.clear(); ClearGObjects(); } diff --git a/src/dialogs/app/dialoghistory.cpp b/src/dialogs/app/dialoghistory.cpp index ac3e83325..fa920848c 100644 --- a/src/dialogs/app/dialoghistory.cpp +++ b/src/dialogs/app/dialoghistory.cpp @@ -38,7 +38,7 @@ #include #include -DialogHistory::DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent) +DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent) :DialogTool(data, parent), ui(new Ui::DialogHistory), doc(doc), cursorRow(0), cursorToolRecordRow(0) { @@ -48,10 +48,10 @@ DialogHistory::DialogHistory(VContainer *data, VDomDocument *doc, QWidget *paren FillTable(); InitialTable(); connect(ui->tableWidget, &QTableWidget::cellClicked, this, &DialogHistory::cellClicked); - connect(this, &DialogHistory::ShowHistoryTool, doc, &VDomDocument::ShowHistoryTool); - connect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor); - connect(doc, &VDomDocument::patternChanged, this, &DialogHistory::UpdateHistory); - connect(doc, &VDomDocument::ChangedActivDraw, this, &DialogHistory::UpdateHistory); + connect(this, &DialogHistory::ShowHistoryTool, doc, &VPattern::ShowHistoryTool); + connect(doc, &VPattern::ChangedCursor, this, &DialogHistory::ChangedCursor); + connect(doc, &VPattern::patternChanged, this, &DialogHistory::UpdateHistory); + connect(doc, &VPattern::ChangedActivDraw, this, &DialogHistory::UpdateHistory); ShowPoint(); } @@ -79,9 +79,9 @@ void DialogHistory::cellClicked(int row, int column) cursorRow = row; item->setIcon(QIcon("://icon/32x32/put_after.png")); qint64 id = qvariant_cast(item->data(Qt::UserRole)); - disconnect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor); + disconnect(doc, &VPattern::ChangedCursor, this, &DialogHistory::ChangedCursor); doc->setCursor(id); - connect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor); + connect(doc, &VPattern::ChangedCursor, this, &DialogHistory::ChangedCursor); } else { diff --git a/src/dialogs/app/dialoghistory.h b/src/dialogs/app/dialoghistory.h index 5670c498c..526f6f46f 100644 --- a/src/dialogs/app/dialoghistory.h +++ b/src/dialogs/app/dialoghistory.h @@ -30,7 +30,7 @@ #define DIALOGHISTORY_H #include "../tools/dialogtool.h" -#include "../../xml/vdomdocument.h" +#include "../../xml/vpattern.h" namespace Ui { @@ -50,7 +50,7 @@ public: * @param doc dom document container * @param parent parent widget */ - DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent = 0); + DialogHistory(VContainer *data, VPattern *doc, QWidget *parent = 0); virtual ~DialogHistory(); public slots: /** @@ -95,7 +95,7 @@ private: /** * @brief doc dom document container */ - VDomDocument *doc; + VPattern *doc; /** * @brief cursorRow save number of row where is cursor */ diff --git a/src/dialogs/app/dialogincrements.cpp b/src/dialogs/app/dialogincrements.cpp index daf940cc1..7bd2c87df 100644 --- a/src/dialogs/app/dialogincrements.cpp +++ b/src/dialogs/app/dialogincrements.cpp @@ -34,7 +34,7 @@ #include -DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent) +DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent) :DialogTool(data, parent), ui(new Ui::DialogIncrements), data(data), doc(doc), row(0), column(0) { ui->setupUi(this); @@ -57,9 +57,9 @@ DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget connect(ui->toolButtonAdd, &QPushButton::clicked, this, &DialogIncrements::clickedToolButtonAdd); connect(ui->toolButtonRemove, &QPushButton::clicked, this, &DialogIncrements::clickedToolButtonRemove); - connect(this, &DialogIncrements::FullUpdateTree, this->doc, &VDomDocument::FullUpdateTree); - connect(this, &DialogIncrements::haveLiteChange, this->doc, &VDomDocument::haveLiteChange); - connect(this->doc, &VDomDocument::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile); + connect(this, &DialogIncrements::FullUpdateTree, this->doc, &VPattern::FullUpdateTree); + connect(this, &DialogIncrements::haveLiteChange, this->doc, &VPattern::haveLiteChange); + connect(this->doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile); ui->tabWidget->setCurrentIndex(0); } diff --git a/src/dialogs/app/dialogincrements.h b/src/dialogs/app/dialogincrements.h index 5f42b9b08..85e13eba7 100644 --- a/src/dialogs/app/dialogincrements.h +++ b/src/dialogs/app/dialogincrements.h @@ -30,7 +30,7 @@ #define DIALOGINCREMENTS_H #include "../tools/dialogtool.h" -#include "../../xml/vdomdocument.h" +#include "../../xml/vpattern.h" namespace Ui { @@ -50,7 +50,7 @@ public: * @param doc dom document container * @param parent parent widget */ - DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent = 0); + DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent = 0); ~DialogIncrements(); public slots: /** @@ -95,7 +95,7 @@ private: /** * @brief doc dom document container */ - VDomDocument *doc; + VPattern *doc; /** * @brief row save number of row current selected cell */ diff --git a/src/dialogs/app/dialogpatternproperties.cpp b/src/dialogs/app/dialogpatternproperties.cpp index 45deeecd4..6d7f922aa 100644 --- a/src/dialogs/app/dialogpatternproperties.cpp +++ b/src/dialogs/app/dialogpatternproperties.cpp @@ -30,7 +30,7 @@ #include "ui_dialogpatternproperties.h" #include -DialogPatternProperties::DialogPatternProperties(VDomDocument *doc, QWidget *parent) : +DialogPatternProperties::DialogPatternProperties(VPattern *doc, QWidget *parent) : QDialog(parent), ui(new Ui::DialogPatternProperties), doc(doc) { ui->setupUi(this); @@ -57,7 +57,7 @@ DialogPatternProperties::DialogPatternProperties(VDomDocument *doc, QWidget *par Q_CHECK_PTR(bCansel); connect(bCansel, &QPushButton::clicked, this, &DialogPatternProperties::close); - connect(this, &DialogPatternProperties::haveChange, this->doc, &VDomDocument::haveLiteChange); + connect(this, &DialogPatternProperties::haveChange, this->doc, &VPattern::haveLiteChange); } DialogPatternProperties::~DialogPatternProperties() diff --git a/src/dialogs/app/dialogpatternproperties.h b/src/dialogs/app/dialogpatternproperties.h index 10f47fe07..5efd8a28a 100644 --- a/src/dialogs/app/dialogpatternproperties.h +++ b/src/dialogs/app/dialogpatternproperties.h @@ -30,7 +30,7 @@ #define DIALOGPATTERNPROPERTIES_H #include -#include "../../xml/vdomdocument.h" +#include "../../xml/vpattern.h" namespace Ui { class DialogPatternProperties; @@ -40,7 +40,7 @@ class DialogPatternProperties : public QDialog { Q_OBJECT public: - DialogPatternProperties(VDomDocument *doc, QWidget *parent = 0); + DialogPatternProperties(VPattern *doc, QWidget *parent = 0); virtual ~DialogPatternProperties(); signals: void haveChange(); @@ -49,7 +49,7 @@ public slots: private: Q_DISABLE_COPY(DialogPatternProperties) Ui::DialogPatternProperties *ui; - VDomDocument *doc; + VPattern *doc; void Write(const QString &tagName, const QString &text) const; }; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4bdadaddb..6761c6873 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -128,9 +128,9 @@ MainWindow::MainWindow(QWidget *parent) pattern = new VContainer(); - doc = new VDomDocument(pattern, comboBoxDraws, &mode); + doc = new VPattern(pattern, comboBoxDraws, &mode); doc->CreateEmptyFile(); - connect(doc, &VDomDocument::patternChanged, this, &MainWindow::PatternWasModified); + connect(doc, &VPattern::patternChanged, this, &MainWindow::PatternWasModified); InitAutoSave(); @@ -268,7 +268,7 @@ void MainWindow::SetToolButton(bool checked, Tool::Tools t, const QString &curso connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChoosedObject); connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot); connect(dialogTool, &DialogTool::ToolTip, this, &MainWindow::ShowToolTip); - connect(doc, &VDomDocument::FullUpdateFromFile, dialogTool, &DialogTool::UpdateList); + connect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogTool::UpdateList); } else { @@ -488,7 +488,7 @@ void MainWindow::ToolUnionDetails(bool checked) SetToolButton(checked, Tool::UnionDetails, ":/cursor/union_cursor.png", tr("Select detail"), &MainWindow::ClosedDialogUnionDetails); //Must disconnect this signal here. - disconnect(doc, &VDomDocument::FullUpdateFromFile, dialogTool, &DialogTool::UpdateList); + disconnect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogTool::UpdateList); } void MainWindow::ClosedDialogUnionDetails(int result) diff --git a/src/mainwindow.h b/src/mainwindow.h index 75c4f7f81..04c6625b4 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -403,7 +403,7 @@ private: /** * @brief doc dom document container */ - VDomDocument *doc; + VPattern *doc; /** * @brief tool current tool */ diff --git a/src/tools/drawTools/vdrawtool.cpp b/src/tools/drawTools/vdrawtool.cpp index e4ad8d170..a588da3da 100644 --- a/src/tools/drawTools/vdrawtool.cpp +++ b/src/tools/drawTools/vdrawtool.cpp @@ -30,13 +30,13 @@ qreal VDrawTool::factor = 1; -VDrawTool::VDrawTool(VDomDocument *doc, VContainer *data, qint64 id) +VDrawTool::VDrawTool(VPattern *doc, VContainer *data, qint64 id) :VAbstractTool(doc, data, id), ignoreContextMenuEvent(false), ignoreFullUpdate(false), nameActivDraw(doc->GetNameActivDraw()), dialog(0) { - connect(this->doc, &VDomDocument::ChangedActivDraw, this, &VDrawTool::ChangedActivDraw); - connect(this->doc, &VDomDocument::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw); - connect(this->doc, &VDomDocument::ShowTool, this, &VDrawTool::ShowTool); + connect(this->doc, &VPattern::ChangedActivDraw, this, &VDrawTool::ChangedActivDraw); + connect(this->doc, &VPattern::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw); + connect(this->doc, &VPattern::ShowTool, this, &VDrawTool::ShowTool); } VDrawTool::~VDrawTool() @@ -99,7 +99,7 @@ void VDrawTool::SetFactor(qreal factor) void VDrawTool::AddToCalculation(const QDomElement &domElement) { QDomElement calcElement; - bool ok = doc->GetActivCalculationElement(calcElement); + bool ok = doc->GetActivNodeElement(VPattern::TagCalculation, calcElement); if (ok) { qint64 id = doc->getCursor(); diff --git a/src/tools/drawTools/vdrawtool.h b/src/tools/drawTools/vdrawtool.h index 4b5ec40e4..e44cbc54f 100644 --- a/src/tools/drawTools/vdrawtool.h +++ b/src/tools/drawTools/vdrawtool.h @@ -49,7 +49,7 @@ public: * @param id object id in container. * @param parent parent object. */ - VDrawTool(VDomDocument *doc, VContainer *data, qint64 id); + VDrawTool(VPattern *doc, VContainer *data, qint64 id); virtual ~VDrawTool(); /** * @brief setDialog set dialog when user want change tool option. @@ -159,7 +159,7 @@ protected: connect(dialog, &DialogTool::DialogClosed, tool, &Tool::FullUpdateFromGui); if (ignoreFullUpdate == false) { - connect(doc, &VDomDocument::FullUpdateFromFile, dialog, &DialogTool::UpdateList); + connect(doc, &VPattern::FullUpdateFromFile, dialog, &DialogTool::UpdateList); } tool->setDialog(); diff --git a/src/tools/drawTools/vtoolalongline.cpp b/src/tools/drawTools/vtoolalongline.cpp index dbdc36561..88b8d1149 100644 --- a/src/tools/drawTools/vtoolalongline.cpp +++ b/src/tools/drawTools/vtoolalongline.cpp @@ -32,7 +32,7 @@ const QString VToolAlongLine::ToolType = QStringLiteral("alongLine"); -VToolAlongLine::VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula, +VToolAlongLine::VToolAlongLine(VPattern *doc, VContainer *data, qint64 id, const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId, const QString &typeLine, const Tool::Sources &typeCreation, QGraphicsItem *parent) @@ -84,16 +84,16 @@ void VToolAlongLine::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrTypeLine, typeLine); - SetAttribute(domElement, AttrLength, formula); - SetAttribute(domElement, AttrFirstPoint, basePointId); - SetAttribute(domElement, AttrSecondPoint, secondPointId); + doc->SetAttribute(domElement, AttrTypeLine, typeLine); + doc->SetAttribute(domElement, AttrLength, formula); + doc->SetAttribute(domElement, AttrFirstPoint, basePointId); + doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); AddToCalculation(domElement); } @@ -104,13 +104,13 @@ void VToolAlongLine::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrTypeLine, typeLine); - SetAttribute(domElement, AttrLength, formula); - SetAttribute(domElement, AttrFirstPoint, basePointId); - SetAttribute(domElement, AttrSecondPoint, secondPointId); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrTypeLine, typeLine); + doc->SetAttribute(domElement, AttrLength, formula); + doc->SetAttribute(domElement, AttrFirstPoint, basePointId); + doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); } } @@ -125,11 +125,11 @@ void VToolAlongLine::SaveDialog(QDomElement &domElement) Q_CHECK_PTR(dialog); DialogAlongLine *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - SetAttribute(domElement, AttrName, dialogTool->getPointName()); - SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); - SetAttribute(domElement, AttrLength, dialogTool->getFormula()); - SetAttribute(domElement, AttrFirstPoint, dialogTool->getFirstPointId()); - SetAttribute(domElement, AttrSecondPoint, dialogTool->getSecondPointId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); + doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrFirstPoint, dialogTool->getFirstPointId()); + doc->SetAttribute(domElement, AttrSecondPoint, dialogTool->getSecondPointId()); } void VToolAlongLine::setDialog() @@ -145,7 +145,7 @@ void VToolAlongLine::setDialog() dialogTool->setPointName(p->name()); } -void VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data) +void VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); DialogAlongLine *dialogTool = qobject_cast(dialog); @@ -161,7 +161,7 @@ void VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomD void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine, const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { const VPointF *firstPoint = data->GeometricObject(firstPointId); diff --git a/src/tools/drawTools/vtoolalongline.h b/src/tools/drawTools/vtoolalongline.h index 21c9f7bbd..d1a325dec 100644 --- a/src/tools/drawTools/vtoolalongline.h +++ b/src/tools/drawTools/vtoolalongline.h @@ -50,7 +50,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula, + VToolAlongLine(VPattern *doc, VContainer *data, qint64 id, const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId, const QString &typeLine, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); /** @@ -64,7 +64,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool. * @param _id tool id, 0 if tool doesn't exist yet. @@ -83,7 +83,7 @@ public: */ static void Create(const qint64 _id, const QString &pointName, const QString &typeLine, const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); static const QString ToolType; public slots: diff --git a/src/tools/drawTools/vtoolarc.cpp b/src/tools/drawTools/vtoolarc.cpp index c5c6b0aa1..8eed179f8 100644 --- a/src/tools/drawTools/vtoolarc.cpp +++ b/src/tools/drawTools/vtoolarc.cpp @@ -33,7 +33,7 @@ const QString VToolArc::TagName = QStringLiteral("arc"); const QString VToolArc::ToolType = QStringLiteral("simple"); -VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, +VToolArc::VToolArc(VPattern *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, QGraphicsItem *parent) :VDrawTool(doc, data, id), QGraphicsPathItem(parent) { @@ -69,7 +69,7 @@ void VToolArc::setDialog() dialogTool->SetRadius(arc->GetFormulaRadius()); } -void VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, +void VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); @@ -83,7 +83,7 @@ void VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocumen } void VToolArc::Create(const qint64 _id, const qint64 ¢er, const QString &radius, const QString &f1, - const QString &f2, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + const QString &f2, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { qreal calcRadius = 0, calcF1 = 0, calcF2 = 0; @@ -183,12 +183,12 @@ void VToolArc::AddToFile() const VArc *arc = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrCenter, arc->GetCenter().id()); - SetAttribute(domElement, AttrRadius, arc->GetFormulaRadius()); - SetAttribute(domElement, AttrAngle1, arc->GetFormulaF1()); - SetAttribute(domElement, AttrAngle2, arc->GetFormulaF2()); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrCenter, arc->GetCenter().id()); + doc->SetAttribute(domElement, AttrRadius, arc->GetFormulaRadius()); + doc->SetAttribute(domElement, AttrAngle1, arc->GetFormulaF1()); + doc->SetAttribute(domElement, AttrAngle2, arc->GetFormulaF2()); AddToCalculation(domElement); } @@ -199,10 +199,10 @@ void VToolArc::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrCenter, arc->GetCenter().id()); - SetAttribute(domElement, AttrRadius, arc->GetFormulaRadius()); - SetAttribute(domElement, AttrAngle1, arc->GetFormulaF1()); - SetAttribute(domElement, AttrAngle2, arc->GetFormulaF2()); + doc->SetAttribute(domElement, AttrCenter, arc->GetCenter().id()); + doc->SetAttribute(domElement, AttrRadius, arc->GetFormulaRadius()); + doc->SetAttribute(domElement, AttrAngle1, arc->GetFormulaF1()); + doc->SetAttribute(domElement, AttrAngle2, arc->GetFormulaF2()); } } @@ -271,10 +271,10 @@ void VToolArc::SaveDialog(QDomElement &domElement) Q_CHECK_PTR(dialog); DialogArc *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetCenter())); - SetAttribute(domElement, AttrRadius, dialogTool->GetRadius()); - SetAttribute(domElement, AttrAngle1, dialogTool->GetF1()); - SetAttribute(domElement, AttrAngle2, dialogTool->GetF2()); + doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetCenter())); + doc->SetAttribute(domElement, AttrRadius, dialogTool->GetRadius()); + doc->SetAttribute(domElement, AttrAngle1, dialogTool->GetF1()); + doc->SetAttribute(domElement, AttrAngle2, dialogTool->GetF2()); } void VToolArc::RefreshGeometry() diff --git a/src/tools/drawTools/vtoolarc.h b/src/tools/drawTools/vtoolarc.h index 1455db910..b81a4cfad 100644 --- a/src/tools/drawTools/vtoolarc.h +++ b/src/tools/drawTools/vtoolarc.h @@ -48,7 +48,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object */ - VToolArc(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, + VToolArc(VPattern *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); /** * @brief setDialog set dialog when user want change tool option. @@ -61,7 +61,7 @@ public: * @param doc dom document container * @param data container with variables */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool form GUI. * @param _id tool id, 0 if tool doesn't exist yet. @@ -76,7 +76,7 @@ public: * @param typeCreation way we create this tool. */ static void Create(const qint64 _id, const qint64 ¢er, const QString &radius, const QString &f1, - const QString &f2, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + const QString &f2, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); static const QString TagName; static const QString ToolType; diff --git a/src/tools/drawTools/vtoolbisector.cpp b/src/tools/drawTools/vtoolbisector.cpp index ad169ae5b..63a0a63e5 100644 --- a/src/tools/drawTools/vtoolbisector.cpp +++ b/src/tools/drawTools/vtoolbisector.cpp @@ -32,7 +32,7 @@ const QString VToolBisector::ToolType = QStringLiteral("bisector"); -VToolBisector::VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id, +VToolBisector::VToolBisector(VPattern *doc, VContainer *data, const qint64 &id, const QString &typeLine, const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId, const qint64 &thirdPointId, const Tool::Sources &typeCreation, QGraphicsItem *parent) @@ -84,7 +84,7 @@ void VToolBisector::setDialog() dialogTool->setPointName(p->name()); } -void VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, +void VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); @@ -103,7 +103,7 @@ void VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDo void VToolBisector::Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine, const QString &pointName, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { const VPointF *firstPoint = data->GeometricObject(firstPointId); @@ -183,17 +183,17 @@ void VToolBisector::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrTypeLine, typeLine); - SetAttribute(domElement, AttrLength, formula); - SetAttribute(domElement, AttrFirstPoint, firstPointId); - SetAttribute(domElement, AttrSecondPoint, basePointId); - SetAttribute(domElement, AttrThirdPoint, thirdPointId); + doc->SetAttribute(domElement, AttrTypeLine, typeLine); + doc->SetAttribute(domElement, AttrLength, formula); + doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); + doc->SetAttribute(domElement, AttrSecondPoint, basePointId); + doc->SetAttribute(domElement, AttrThirdPoint, thirdPointId); AddToCalculation(domElement); } @@ -204,14 +204,14 @@ void VToolBisector::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrTypeLine, typeLine); - SetAttribute(domElement, AttrLength, formula); - SetAttribute(domElement, AttrFirstPoint, firstPointId); - SetAttribute(domElement, AttrSecondPoint, basePointId); - SetAttribute(domElement, AttrThirdPoint, thirdPointId); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrTypeLine, typeLine); + doc->SetAttribute(domElement, AttrLength, formula); + doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); + doc->SetAttribute(domElement, AttrSecondPoint, basePointId); + doc->SetAttribute(domElement, AttrThirdPoint, thirdPointId); } } @@ -227,10 +227,10 @@ void VToolBisector::SaveDialog(QDomElement &domElement) Q_CHECK_PTR(dialog); DialogBisector *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - SetAttribute(domElement, AttrName, dialogTool->getPointName()); - SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); - SetAttribute(domElement, AttrLength, dialogTool->getFormula()); - SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); - SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); - SetAttribute(domElement, AttrThirdPoint, QString().setNum(dialogTool->getThirdPointId())); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); + doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); + doc->SetAttribute(domElement, AttrThirdPoint, QString().setNum(dialogTool->getThirdPointId())); } diff --git a/src/tools/drawTools/vtoolbisector.h b/src/tools/drawTools/vtoolbisector.h index f019bd35e..b88e284c1 100644 --- a/src/tools/drawTools/vtoolbisector.h +++ b/src/tools/drawTools/vtoolbisector.h @@ -50,7 +50,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, + VToolBisector(VPattern *doc, VContainer *data, const qint64 &id, const QString &typeLine, const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId, const qint64 &thirdPointId, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); @@ -75,7 +75,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool. * @param _id tool id, 0 if tool doesn't exist yet. @@ -96,7 +96,7 @@ public: static void Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine, const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, + VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); static const QString ToolType; public slots: diff --git a/src/tools/drawTools/vtoolcutarc.cpp b/src/tools/drawTools/vtoolcutarc.cpp index 52772a577..426ff7094 100644 --- a/src/tools/drawTools/vtoolcutarc.cpp +++ b/src/tools/drawTools/vtoolcutarc.cpp @@ -33,7 +33,7 @@ const QString VToolCutArc::ToolType = QStringLiteral("cutArc"); const QString VToolCutArc::AttrArc = QStringLiteral("arc"); -VToolCutArc::VToolCutArc(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &formula, +VToolCutArc::VToolCutArc(VPattern *doc, VContainer *data, const qint64 &id, const QString &formula, const qint64 &arcId, const qint64 &arc1id, const qint64 &arc2id, const Tool::Sources &typeCreation, QGraphicsItem * parent) :VToolPoint(doc, data, id, parent), formula(formula), arcId(arcId), firstArc(), secondArc(), arc1id(arc1id), @@ -76,7 +76,7 @@ void VToolCutArc::setDialog() dialogTool->setPointName(point->name()); } -void VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, +void VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); @@ -89,7 +89,7 @@ void VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocu } void VToolCutArc::Create(const qint64 _id, const QString &pointName, const QString &formula, const qint64 &arcId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { const VArc *arc = data->GeometricObject(arcId); @@ -213,14 +213,14 @@ void VToolCutArc::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrLength, formula); - SetAttribute(domElement, AttrArc, arcId); + doc->SetAttribute(domElement, AttrLength, formula); + doc->SetAttribute(domElement, AttrArc, arcId); AddToCalculation(domElement); } @@ -231,11 +231,11 @@ void VToolCutArc::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrLength, formula); - SetAttribute(domElement, AttrArc, arcId); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrLength, formula); + doc->SetAttribute(domElement, AttrArc, arcId); } } @@ -251,9 +251,9 @@ void VToolCutArc::SaveDialog(QDomElement &domElement) Q_CHECK_PTR(dialog); DialogCutArc *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - SetAttribute(domElement, AttrName, dialogTool->getPointName()); - SetAttribute(domElement, AttrLength, dialogTool->getFormula()); - SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->getArcId())); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->getArcId())); } void VToolCutArc::RefreshArc(VSimpleArc *sArc, qint64 arcid, SimpleArc::Translation tr) diff --git a/src/tools/drawTools/vtoolcutarc.h b/src/tools/drawTools/vtoolcutarc.h index 9d10bcf0a..1cf876fa1 100644 --- a/src/tools/drawTools/vtoolcutarc.h +++ b/src/tools/drawTools/vtoolcutarc.h @@ -51,7 +51,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolCutArc(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &formula, + VToolCutArc(VPattern *doc, VContainer *data, const qint64 &id, const QString &formula, const qint64 &arcId, const qint64 &arc1id, const qint64 &arc2id, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); /** @@ -65,7 +65,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool. * @param _id tool id, 0 if tool doesn't exist yet. @@ -81,7 +81,7 @@ public: * @param typeCreation way we create this tool. */ static void Create(const qint64 _id, const QString &pointName, const QString &formula, const qint64 &arcId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); static const QString ToolType; static const QString AttrArc; diff --git a/src/tools/drawTools/vtoolcutspline.cpp b/src/tools/drawTools/vtoolcutspline.cpp index 1783a4e19..0c2c01ca7 100644 --- a/src/tools/drawTools/vtoolcutspline.cpp +++ b/src/tools/drawTools/vtoolcutspline.cpp @@ -33,7 +33,7 @@ const QString VToolCutSpline::ToolType = QStringLiteral("cutSpline"); const QString VToolCutSpline::AttrSpline = QStringLiteral("spline"); -VToolCutSpline::VToolCutSpline(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &formula, +VToolCutSpline::VToolCutSpline(VPattern *doc, VContainer *data, const qint64 &id, const QString &formula, const qint64 &splineId, const qint64 &spl1id, const qint64 &spl2id, const Tool::Sources &typeCreation, QGraphicsItem *parent) :VToolPoint(doc, data, id, parent), formula(formula), splineId(splineId), firstSpline(), secondSpline(), @@ -77,7 +77,7 @@ void VToolCutSpline::setDialog() } void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data) + VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); DialogCutSpline *dialogTool = qobject_cast(dialog); @@ -90,7 +90,7 @@ void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, void VToolCutSpline::Create(const qint64 _id, const QString &pointName, const QString &formula, const qint64 &splineId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { const VSpline *spl = data->GeometricObject(splineId); @@ -214,14 +214,14 @@ void VToolCutSpline::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrLength, formula); - SetAttribute(domElement, AttrSpline, splineId); + doc->SetAttribute(domElement, AttrLength, formula); + doc->SetAttribute(domElement, AttrSpline, splineId); AddToCalculation(domElement); } @@ -232,11 +232,11 @@ void VToolCutSpline::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrLength, formula); - SetAttribute(domElement, AttrSpline, splineId); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrLength, formula); + doc->SetAttribute(domElement, AttrSpline, splineId); } } @@ -257,9 +257,9 @@ void VToolCutSpline::SaveDialog(QDomElement &domElement) Q_CHECK_PTR(dialog); DialogCutSpline *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - SetAttribute(domElement, AttrName, dialogTool->getPointName()); - SetAttribute(domElement, AttrLength, dialogTool->getFormula()); - SetAttribute(domElement, AttrSpline, QString().setNum(dialogTool->getSplineId())); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrSpline, QString().setNum(dialogTool->getSplineId())); } void VToolCutSpline::RefreshSpline(VSimpleSpline *spline, qint64 splid, SimpleSpline::Translation tr) diff --git a/src/tools/drawTools/vtoolcutspline.h b/src/tools/drawTools/vtoolcutspline.h index bdf971598..d9b0e7634 100644 --- a/src/tools/drawTools/vtoolcutspline.h +++ b/src/tools/drawTools/vtoolcutspline.h @@ -49,7 +49,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolCutSpline(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &formula, + VToolCutSpline(VPattern *doc, VContainer *data, const qint64 &id, const QString &formula, const qint64 &splineId, const qint64 &spl1id, const qint64 &spl2id, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); /** @@ -63,7 +63,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool. * @param _id tool id, 0 if tool doesn't exist yet. @@ -80,7 +80,7 @@ public: */ static void Create(const qint64 _id, const QString &pointName, const QString &formula, const qint64 &splineId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); static const QString ToolType; static const QString AttrSpline; diff --git a/src/tools/drawTools/vtoolcutsplinepath.cpp b/src/tools/drawTools/vtoolcutsplinepath.cpp index 0f401b42f..495d4897d 100644 --- a/src/tools/drawTools/vtoolcutsplinepath.cpp +++ b/src/tools/drawTools/vtoolcutsplinepath.cpp @@ -33,7 +33,7 @@ const QString VToolCutSplinePath::ToolType = QStringLiteral("cutSplinePath"); const QString VToolCutSplinePath::AttrSplinePath = QStringLiteral("splinePath"); -VToolCutSplinePath::VToolCutSplinePath(VDomDocument *doc, VContainer *data, const qint64 &id, +VToolCutSplinePath::VToolCutSplinePath(VPattern *doc, VContainer *data, const qint64 &id, const QString &formula, const qint64 &splinePathId, const qint64 &splPath1id, const qint64 &splPath2id, const Tool::Sources &typeCreation, QGraphicsItem *parent) @@ -77,7 +77,7 @@ void VToolCutSplinePath::setDialog() dialogTool->setPointName(point->name()); } -void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data) +void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); DialogCutSplinePath *dialogTool = qobject_cast(dialog); @@ -90,7 +90,7 @@ void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, V void VToolCutSplinePath::Create(const qint64 _id, const QString &pointName, const QString &formula, const qint64 &splinePathId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { const VSplinePath *splPath = data->GeometricObject(splinePathId); @@ -295,14 +295,14 @@ void VToolCutSplinePath::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrLength, formula); - SetAttribute(domElement, AttrSplinePath, splinePathId); + doc->SetAttribute(domElement, AttrLength, formula); + doc->SetAttribute(domElement, AttrSplinePath, splinePathId); AddToCalculation(domElement); } @@ -313,11 +313,11 @@ void VToolCutSplinePath::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrLength, formula); - SetAttribute(domElement, AttrSplinePath, splinePathId); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrLength, formula); + doc->SetAttribute(domElement, AttrSplinePath, splinePathId); } } @@ -338,9 +338,9 @@ void VToolCutSplinePath::SaveDialog(QDomElement &domElement) Q_CHECK_PTR(dialog); DialogCutSplinePath *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - SetAttribute(domElement, AttrName, dialogTool->getPointName()); - SetAttribute(domElement, AttrLength, dialogTool->getFormula()); - SetAttribute(domElement, AttrSplinePath, QString().setNum(dialogTool->getSplinePathId())); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrSplinePath, QString().setNum(dialogTool->getSplinePathId())); } void VToolCutSplinePath::RefreshSpline(VSimpleSpline *spline, qint64 splPathid, SimpleSpline::Translation tr) diff --git a/src/tools/drawTools/vtoolcutsplinepath.h b/src/tools/drawTools/vtoolcutsplinepath.h index 7a13d2e5e..f29d8a999 100644 --- a/src/tools/drawTools/vtoolcutsplinepath.h +++ b/src/tools/drawTools/vtoolcutsplinepath.h @@ -52,7 +52,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolCutSplinePath(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &formula, + VToolCutSplinePath(VPattern *doc, VContainer *data, const qint64 &id, const QString &formula, const qint64 &splinePathId, const qint64 &splPath1id, const qint64 &splPath2id, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); /** @@ -66,7 +66,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool. * @param _id tool id, 0 if tool doesn't exist yet. @@ -83,7 +83,7 @@ public: */ static void Create(const qint64 _id, const QString &pointName, const QString &formula, const qint64 &splinePathId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, + VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); static const QString ToolType; static const QString AttrSplinePath; diff --git a/src/tools/drawTools/vtoolendline.cpp b/src/tools/drawTools/vtoolendline.cpp index 1f3d4d97c..4178689fe 100644 --- a/src/tools/drawTools/vtoolendline.cpp +++ b/src/tools/drawTools/vtoolendline.cpp @@ -33,7 +33,7 @@ const QString VToolEndLine::ToolType = QStringLiteral("endLine"); -VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, +VToolEndLine::VToolEndLine(VPattern *doc, VContainer *data, const qint64 &id, const QString &typeLine, const QString &formula, const qreal &angle, const qint64 &basePointId, const Tool::Sources &typeCreation, QGraphicsItem *parent) :VToolLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent) @@ -62,7 +62,7 @@ void VToolEndLine::setDialog() dialogTool->setPointName(p->name()); } -void VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, +void VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); @@ -79,7 +79,7 @@ void VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDoc void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine, const QString &formula, const qreal &angle, const qint64 &basePointId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { const VPointF *basePoint = data->GeometricObject(basePointId); @@ -148,16 +148,16 @@ void VToolEndLine::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrTypeLine, typeLine); - SetAttribute(domElement, AttrLength, formula); - SetAttribute(domElement, AttrAngle, angle); - SetAttribute(domElement, AttrBasePoint, basePointId); + doc->SetAttribute(domElement, AttrTypeLine, typeLine); + doc->SetAttribute(domElement, AttrLength, formula); + doc->SetAttribute(domElement, AttrAngle, angle); + doc->SetAttribute(domElement, AttrBasePoint, basePointId); AddToCalculation(domElement); } @@ -168,13 +168,13 @@ void VToolEndLine::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrTypeLine, typeLine); - SetAttribute(domElement, AttrLength, formula); - SetAttribute(domElement, AttrAngle, angle); - SetAttribute(domElement, AttrBasePoint, basePointId); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrTypeLine, typeLine); + doc->SetAttribute(domElement, AttrLength, formula); + doc->SetAttribute(domElement, AttrAngle, angle); + doc->SetAttribute(domElement, AttrBasePoint, basePointId); } } @@ -183,9 +183,9 @@ void VToolEndLine::SaveDialog(QDomElement &domElement) Q_CHECK_PTR(dialog); DialogEndLine *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - SetAttribute(domElement, AttrName, dialogTool->getPointName()); - SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); - SetAttribute(domElement, AttrLength, dialogTool->getFormula()); - SetAttribute(domElement, AttrAngle, QString().setNum(dialogTool->getAngle())); - SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId())); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); + doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrAngle, QString().setNum(dialogTool->getAngle())); + doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId())); } diff --git a/src/tools/drawTools/vtoolendline.h b/src/tools/drawTools/vtoolendline.h index a8b3c4992..938beb98e 100644 --- a/src/tools/drawTools/vtoolendline.h +++ b/src/tools/drawTools/vtoolendline.h @@ -50,7 +50,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, + VToolEndLine(VPattern *doc, VContainer *data, const qint64 &id, const QString &typeLine, const QString &formula, const qreal &angle, const qint64 &basePointId, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); /** @@ -64,7 +64,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool. * @param _id tool id, 0 if tool doesn't exist yet. @@ -83,7 +83,7 @@ public: */ static void Create(const qint64 _id, const QString &pointName, const QString &typeLine, const QString &formula, const qreal &angle, const qint64 &basePointId, const qreal &mx, - const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); static const QString ToolType; public slots: diff --git a/src/tools/drawTools/vtoolheight.cpp b/src/tools/drawTools/vtoolheight.cpp index d81505585..893e99459 100644 --- a/src/tools/drawTools/vtoolheight.cpp +++ b/src/tools/drawTools/vtoolheight.cpp @@ -31,7 +31,7 @@ const QString VToolHeight::ToolType = QStringLiteral("height"); -VToolHeight::VToolHeight(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, +VToolHeight::VToolHeight(VPattern *doc, VContainer *data, const qint64 &id, const QString &typeLine, const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId, const Tool::Sources &typeCreation, QGraphicsItem * parent) :VToolLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent), p1LineId(p1LineId), p2LineId(p2LineId) @@ -60,13 +60,13 @@ void VToolHeight::setDialog() dialogTool->setPointName(p->name()); } -void VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, +void VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); DialogHeight *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - disconnect(doc, &VDomDocument::FullUpdateFromFile, dialogTool, &DialogHeight::UpdateList); + disconnect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogHeight::UpdateList); QString pointName = dialogTool->getPointName(); QString typeLine = dialogTool->getTypeLine(); qint64 basePointId = dialogTool->getBasePointId(); @@ -78,7 +78,7 @@ void VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocu void VToolHeight::Create(const qint64 _id, const QString &pointName, const QString &typeLine, const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { const VPointF *basePoint = data->GeometricObject(basePointId); @@ -154,16 +154,16 @@ void VToolHeight::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrTypeLine, typeLine); - SetAttribute(domElement, AttrBasePoint, basePointId); - SetAttribute(domElement, AttrP1Line, p1LineId); - SetAttribute(domElement, AttrP2Line, p2LineId); + doc->SetAttribute(domElement, AttrTypeLine, typeLine); + doc->SetAttribute(domElement, AttrBasePoint, basePointId); + doc->SetAttribute(domElement, AttrP1Line, p1LineId); + doc->SetAttribute(domElement, AttrP2Line, p2LineId); AddToCalculation(domElement); @@ -175,13 +175,13 @@ void VToolHeight::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrTypeLine, typeLine); - SetAttribute(domElement, AttrBasePoint, basePointId); - SetAttribute(domElement, AttrP1Line, p1LineId); - SetAttribute(domElement, AttrP2Line, p2LineId); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrTypeLine, typeLine); + doc->SetAttribute(domElement, AttrBasePoint, basePointId); + doc->SetAttribute(domElement, AttrP1Line, p1LineId); + doc->SetAttribute(domElement, AttrP2Line, p2LineId); } } @@ -190,9 +190,9 @@ void VToolHeight::SaveDialog(QDomElement &domElement) Q_CHECK_PTR(dialog); DialogHeight *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - SetAttribute(domElement, AttrName, dialogTool->getPointName()); - SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); - SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId())); - SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->getP1LineId())); - SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getP2LineId())); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); + doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId())); + doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->getP1LineId())); + doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getP2LineId())); } diff --git a/src/tools/drawTools/vtoolheight.h b/src/tools/drawTools/vtoolheight.h index 085407efb..f1117041a 100644 --- a/src/tools/drawTools/vtoolheight.h +++ b/src/tools/drawTools/vtoolheight.h @@ -50,7 +50,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolHeight(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, + VToolHeight(VPattern *doc, VContainer *data, const qint64 &id, const QString &typeLine, const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); /** @@ -64,7 +64,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool * @param _id tool id, 0 if tool doesn't exist yet. @@ -83,7 +83,7 @@ public: */ static void Create(const qint64 _id, const QString &pointName, const QString &typeLine, const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); /** * @brief FindPoint find projection base point onto line. diff --git a/src/tools/drawTools/vtoolline.cpp b/src/tools/drawTools/vtoolline.cpp index 47cb56a2a..36aa631ce 100644 --- a/src/tools/drawTools/vtoolline.cpp +++ b/src/tools/drawTools/vtoolline.cpp @@ -31,7 +31,7 @@ const QString VToolLine::TagName = QStringLiteral("line"); -VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint, +VToolLine::VToolLine(VPattern *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint, const QString &typeLine, const Tool::Sources &typeCreation, QGraphicsItem *parent) :VDrawTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint) { @@ -67,7 +67,7 @@ void VToolLine::setDialog() dialogTool->setTypeLine(typeLine); } -void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data) +void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); DialogLine *dialogTool = qobject_cast(dialog); @@ -79,7 +79,7 @@ void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocume } void VToolLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint, const QString &typeLine, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { Q_CHECK_PTR(scene); @@ -156,10 +156,10 @@ void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void VToolLine::AddToFile() { QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrFirstPoint, firstPoint); - SetAttribute(domElement, AttrSecondPoint, secondPoint); - SetAttribute(domElement, AttrTypeLine, typeLine); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrFirstPoint, firstPoint); + doc->SetAttribute(domElement, AttrSecondPoint, secondPoint); + doc->SetAttribute(domElement, AttrTypeLine, typeLine); AddToCalculation(domElement); } @@ -169,9 +169,9 @@ void VToolLine::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrFirstPoint, firstPoint); - SetAttribute(domElement, AttrSecondPoint, secondPoint); - SetAttribute(domElement, AttrTypeLine, typeLine); + doc->SetAttribute(domElement, AttrFirstPoint, firstPoint); + doc->SetAttribute(domElement, AttrSecondPoint, secondPoint); + doc->SetAttribute(domElement, AttrTypeLine, typeLine); } } @@ -229,9 +229,9 @@ void VToolLine::SaveDialog(QDomElement &domElement) Q_CHECK_PTR(dialog); DialogLine *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPoint())); - SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPoint())); - SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPoint())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPoint())); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); } void VToolLine::RefreshGeometry() diff --git a/src/tools/drawTools/vtoolline.h b/src/tools/drawTools/vtoolline.h index 1b8534c5c..4ca4ffcf9 100644 --- a/src/tools/drawTools/vtoolline.h +++ b/src/tools/drawTools/vtoolline.h @@ -51,7 +51,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, + VToolLine(VPattern *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint, const QString &typeLine, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); /** @@ -65,7 +65,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool. * @param _id tool id, 0 if tool doesn't exist yet. @@ -79,7 +79,7 @@ public: * @param typeCreation way we create this tool. */ static void Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint, const QString &typeLine, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); static const QString TagName; public slots: diff --git a/src/tools/drawTools/vtoollineintersect.cpp b/src/tools/drawTools/vtoollineintersect.cpp index 716b19386..132d6fff2 100644 --- a/src/tools/drawTools/vtoollineintersect.cpp +++ b/src/tools/drawTools/vtoollineintersect.cpp @@ -31,7 +31,7 @@ const QString VToolLineIntersect::ToolType = QStringLiteral("lineIntersect"); -VToolLineIntersect::VToolLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id, +VToolLineIntersect::VToolLineIntersect(VPattern *doc, VContainer *data, const qint64 &id, const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2, const qint64 &p2Line2, const Tool::Sources &typeCreation, QGraphicsItem *parent) @@ -62,7 +62,7 @@ void VToolLineIntersect::setDialog() dialogTool->setPointName(p->name()); } -void VToolLineIntersect::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data) +void VToolLineIntersect::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); DialogLineIntersect *dialogTool = qobject_cast(dialog); @@ -79,7 +79,7 @@ void VToolLineIntersect::Create(DialogTool *dialog, VMainGraphicsScene *scene, V void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id, const qint64 &p1Line2Id, const qint64 &p2Line2Id, const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, + VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { const VPointF *p1Line1 = data->GeometricObject(p1Line1Id); @@ -165,16 +165,16 @@ void VToolLineIntersect::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrP1Line1, p1Line1); - SetAttribute(domElement, AttrP2Line1, p2Line1); - SetAttribute(domElement, AttrP1Line2, p1Line2); - SetAttribute(domElement, AttrP2Line2, p2Line2); + doc->SetAttribute(domElement, AttrP1Line1, p1Line1); + doc->SetAttribute(domElement, AttrP2Line1, p2Line1); + doc->SetAttribute(domElement, AttrP1Line2, p1Line2); + doc->SetAttribute(domElement, AttrP2Line2, p2Line2); AddToCalculation(domElement); } @@ -185,13 +185,13 @@ void VToolLineIntersect::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrP1Line1, p1Line1); - SetAttribute(domElement, AttrP2Line1, p2Line1); - SetAttribute(domElement, AttrP1Line2, p1Line2); - SetAttribute(domElement, AttrP2Line2, p2Line2); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrP1Line1, p1Line1); + doc->SetAttribute(domElement, AttrP2Line1, p2Line1); + doc->SetAttribute(domElement, AttrP1Line2, p1Line2); + doc->SetAttribute(domElement, AttrP2Line2, p2Line2); } } @@ -208,9 +208,9 @@ void VToolLineIntersect::SaveDialog(QDomElement &domElement) Q_CHECK_PTR(dialog); DialogLineIntersect *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - SetAttribute(domElement, AttrName, dialogTool->getPointName()); - SetAttribute(domElement, AttrP1Line1, QString().setNum(dialogTool->getP1Line1())); - SetAttribute(domElement, AttrP2Line1, QString().setNum(dialogTool->getP2Line1())); - SetAttribute(domElement, AttrP1Line2, QString().setNum(dialogTool->getP1Line2())); - SetAttribute(domElement, AttrP2Line2, QString().setNum(dialogTool->getP2Line2())); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrP1Line1, QString().setNum(dialogTool->getP1Line1())); + doc->SetAttribute(domElement, AttrP2Line1, QString().setNum(dialogTool->getP2Line1())); + doc->SetAttribute(domElement, AttrP1Line2, QString().setNum(dialogTool->getP1Line2())); + doc->SetAttribute(domElement, AttrP2Line2, QString().setNum(dialogTool->getP2Line2())); } diff --git a/src/tools/drawTools/vtoollineintersect.h b/src/tools/drawTools/vtoollineintersect.h index f39dc0b6e..14125de25 100644 --- a/src/tools/drawTools/vtoollineintersect.h +++ b/src/tools/drawTools/vtoollineintersect.h @@ -50,7 +50,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id, const qint64 &p1Line1, + VToolLineIntersect(VPattern *doc, VContainer *data, const qint64 &id, const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2, const qint64 &p2Line2, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); /** @@ -64,7 +64,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool. * @param _id tool id, 0 if tool doesn't exist yet. @@ -83,7 +83,7 @@ public: */ static void Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id, const qint64 &p1Line2Id, const qint64 &p2Line2Id, const QString &pointName, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); static const QString ToolType; public slots: diff --git a/src/tools/drawTools/vtoollinepoint.cpp b/src/tools/drawTools/vtoollinepoint.cpp index ff7d53dc4..e3dfab958 100644 --- a/src/tools/drawTools/vtoollinepoint.cpp +++ b/src/tools/drawTools/vtoollinepoint.cpp @@ -28,7 +28,7 @@ #include "vtoollinepoint.h" -VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, +VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const qint64 &id, const QString &typeLine, const QString &formula, const qint64 &basePointId, const qreal &angle, QGraphicsItem *parent) :VToolPoint(doc, data, id, parent), formula(formula), angle(angle), basePointId(basePointId), diff --git a/src/tools/drawTools/vtoollinepoint.h b/src/tools/drawTools/vtoollinepoint.h index 2ba9bd9ab..c15dd18b9 100644 --- a/src/tools/drawTools/vtoollinepoint.h +++ b/src/tools/drawTools/vtoollinepoint.h @@ -49,7 +49,7 @@ public: * @param angle line angle. * @param parent parent object. */ - VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, + VToolLinePoint(VPattern *doc, VContainer *data, const qint64 &id, const QString &typeLine, const QString &formula, const qint64 &basePointId, const qreal &angle, QGraphicsItem * parent = 0); public slots: diff --git a/src/tools/drawTools/vtoolnormal.cpp b/src/tools/drawTools/vtoolnormal.cpp index af31122f0..b34e84c12 100644 --- a/src/tools/drawTools/vtoolnormal.cpp +++ b/src/tools/drawTools/vtoolnormal.cpp @@ -32,7 +32,7 @@ const QString VToolNormal::ToolType = QStringLiteral("normal"); -VToolNormal::VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, +VToolNormal::VToolNormal(VPattern *doc, VContainer *data, const qint64 &id, const QString &typeLine, const QString &formula, const qreal &angle, const qint64 &firstPointId, const qint64 &secondPointId, const Tool::Sources &typeCreation, QGraphicsItem *parent) :VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent), @@ -63,7 +63,7 @@ void VToolNormal::setDialog() dialogTool->setPointName(p->name()); } -void VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data) +void VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); DialogNormal *dialogTool = qobject_cast(dialog); @@ -81,7 +81,7 @@ void VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocu void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId, const QString &typeLine, const QString &pointName, const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, + VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { const VPointF *firstPoint = data->GeometricObject(firstPointId); @@ -168,17 +168,17 @@ void VToolNormal::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrTypeLine, typeLine); - SetAttribute(domElement, AttrLength, formula); - SetAttribute(domElement, AttrAngle, angle); - SetAttribute(domElement, AttrFirstPoint, basePointId); - SetAttribute(domElement, AttrSecondPoint, secondPointId); + doc->SetAttribute(domElement, AttrTypeLine, typeLine); + doc->SetAttribute(domElement, AttrLength, formula); + doc->SetAttribute(domElement, AttrAngle, angle); + doc->SetAttribute(domElement, AttrFirstPoint, basePointId); + doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); AddToCalculation(domElement); } @@ -189,14 +189,14 @@ void VToolNormal::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrTypeLine, typeLine); - SetAttribute(domElement, AttrLength, formula); - SetAttribute(domElement, AttrAngle, angle); - SetAttribute(domElement, AttrFirstPoint, basePointId); - SetAttribute(domElement, AttrSecondPoint, secondPointId); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrTypeLine, typeLine); + doc->SetAttribute(domElement, AttrLength, formula); + doc->SetAttribute(domElement, AttrAngle, angle); + doc->SetAttribute(domElement, AttrFirstPoint, basePointId); + doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); } } @@ -211,10 +211,10 @@ void VToolNormal::SaveDialog(QDomElement &domElement) Q_CHECK_PTR(dialog); DialogNormal *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - SetAttribute(domElement, AttrName, dialogTool->getPointName()); - SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); - SetAttribute(domElement, AttrLength, dialogTool->getFormula()); - SetAttribute(domElement, AttrAngle, QString().setNum(dialogTool->getAngle())); - SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); - SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); + doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrAngle, QString().setNum(dialogTool->getAngle())); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); } diff --git a/src/tools/drawTools/vtoolnormal.h b/src/tools/drawTools/vtoolnormal.h index 018374b8d..ae79635c9 100644 --- a/src/tools/drawTools/vtoolnormal.h +++ b/src/tools/drawTools/vtoolnormal.h @@ -51,7 +51,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, + VToolNormal(VPattern *doc, VContainer *data, const qint64 &id, const QString &typeLine, const QString &formula, const qreal &angle, const qint64 &firstPointId, const qint64 &secondPointId, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); @@ -66,7 +66,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool. * @param _id tool id, 0 if tool doesn't exist yet. @@ -87,7 +87,7 @@ public: static void Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId, const QString &typeLine, const QString &pointName, const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, + VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); /** * @brief FindPoint return normal point. diff --git a/src/tools/drawTools/vtoolpoint.cpp b/src/tools/drawTools/vtoolpoint.cpp index 4baf9a1d6..c906561b1 100644 --- a/src/tools/drawTools/vtoolpoint.cpp +++ b/src/tools/drawTools/vtoolpoint.cpp @@ -30,7 +30,7 @@ const QString VToolPoint::TagName = QStringLiteral("point"); -VToolPoint::VToolPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphicsItem *parent):VDrawTool(doc, data, id), +VToolPoint::VToolPoint(VPattern *doc, VContainer *data, qint64 id, QGraphicsItem *parent):VDrawTool(doc, data, id), QGraphicsEllipseItem(parent), radius(toPixel(2)), namePoint(0), lineName(0) { namePoint = new VGraphicsSimpleTextItem(this); @@ -65,8 +65,8 @@ void VToolPoint::UpdateNamePosition(qreal mx, qreal my) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrMx, toMM(mx)); - SetAttribute(domElement, AttrMy, toMM(my)); + doc->SetAttribute(domElement, AttrMx, toMM(mx)); + doc->SetAttribute(domElement, AttrMy, toMM(my)); emit toolhaveChange(); } } diff --git a/src/tools/drawTools/vtoolpoint.h b/src/tools/drawTools/vtoolpoint.h index 23c4ae4f2..22a48c9be 100644 --- a/src/tools/drawTools/vtoolpoint.h +++ b/src/tools/drawTools/vtoolpoint.h @@ -46,7 +46,7 @@ public: * @param id object id in container. * @param parent parent object. */ - VToolPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphicsItem * parent = 0); + VToolPoint(VPattern *doc, VContainer *data, qint64 id, QGraphicsItem * parent = 0); virtual ~VToolPoint(){} static const QString TagName; public slots: diff --git a/src/tools/drawTools/vtoolpointofcontact.cpp b/src/tools/drawTools/vtoolpointofcontact.cpp index 5fe5dba03..261716c9a 100644 --- a/src/tools/drawTools/vtoolpointofcontact.cpp +++ b/src/tools/drawTools/vtoolpointofcontact.cpp @@ -32,7 +32,7 @@ const QString VToolPointOfContact::ToolType = QStringLiteral("pointOfContact"); -VToolPointOfContact::VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id, +VToolPointOfContact::VToolPointOfContact(VPattern *doc, VContainer *data, const qint64 &id, const QString &radius, const qint64 ¢er, const qint64 &firstPointId, const qint64 &secondPointId, const Tool::Sources &typeCreation, QGraphicsItem *parent) @@ -88,7 +88,7 @@ QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF ¢e return pArc; } -void VToolPointOfContact::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data) +void VToolPointOfContact::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); DialogPointOfContact *dialogTool = qobject_cast(dialog); @@ -105,7 +105,7 @@ void VToolPointOfContact::Create(DialogTool *dialog, VMainGraphicsScene *scene, void VToolPointOfContact::Create(const qint64 _id, const QString &radius, const qint64 ¢er, const qint64 &firstPointId, const qint64 &secondPointId, const QString &pointName, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { const VPointF *centerP = data->GeometricObject(center); @@ -188,16 +188,16 @@ void VToolPointOfContact::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrRadius, arcRadius); - SetAttribute(domElement, AttrCenter, center); - SetAttribute(domElement, AttrFirstPoint, firstPointId); - SetAttribute(domElement, AttrSecondPoint, secondPointId); + doc->SetAttribute(domElement, AttrRadius, arcRadius); + doc->SetAttribute(domElement, AttrCenter, center); + doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); + doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); AddToCalculation(domElement); } @@ -208,13 +208,13 @@ void VToolPointOfContact::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrRadius, arcRadius); - SetAttribute(domElement, AttrCenter, center); - SetAttribute(domElement, AttrFirstPoint, firstPointId); - SetAttribute(domElement, AttrSecondPoint, secondPointId); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrRadius, arcRadius); + doc->SetAttribute(domElement, AttrCenter, center); + doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); + doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); } } @@ -230,9 +230,9 @@ void VToolPointOfContact::SaveDialog(QDomElement &domElement) Q_CHECK_PTR(dialog); DialogPointOfContact *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - SetAttribute(domElement, AttrName, dialogTool->getPointName()); - SetAttribute(domElement, AttrRadius, dialogTool->getRadius()); - SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->getCenter())); - SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPoint())); - SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPoint())); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrRadius, dialogTool->getRadius()); + doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->getCenter())); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPoint())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPoint())); } diff --git a/src/tools/drawTools/vtoolpointofcontact.h b/src/tools/drawTools/vtoolpointofcontact.h index 0855537c8..6dd7b5482 100644 --- a/src/tools/drawTools/vtoolpointofcontact.h +++ b/src/tools/drawTools/vtoolpointofcontact.h @@ -49,7 +49,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id, + VToolPointOfContact(VPattern *doc, VContainer *data, const qint64 &id, const QString &arcRadius, const qint64 ¢er, const qint64 &firstPointId, const qint64 &secondPointId, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); @@ -74,7 +74,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool. * @param _id tool id, 0 if tool doesn't exist yet. @@ -93,7 +93,7 @@ public: */ static void Create(const qint64 _id, const QString &arcRadius, const qint64 ¢er, const qint64 &firstPointId, const qint64 &secondPointId, const QString &pointName, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); static const QString ToolType; public slots: diff --git a/src/tools/drawTools/vtoolpointofintersection.cpp b/src/tools/drawTools/vtoolpointofintersection.cpp index 7f374a654..5775196dc 100644 --- a/src/tools/drawTools/vtoolpointofintersection.cpp +++ b/src/tools/drawTools/vtoolpointofintersection.cpp @@ -31,7 +31,7 @@ const QString VToolPointOfIntersection::ToolType = QStringLiteral("pointOfIntersection"); -VToolPointOfIntersection::VToolPointOfIntersection(VDomDocument *doc, VContainer *data, const qint64 &id, +VToolPointOfIntersection::VToolPointOfIntersection(VPattern *doc, VContainer *data, const qint64 &id, const qint64 &firstPointId, const qint64 &secondPointId, const Tool::Sources &typeCreation, QGraphicsItem *parent) :VToolPoint(doc, data, id, parent), firstPointId(firstPointId), secondPointId(secondPointId) @@ -58,7 +58,7 @@ void VToolPointOfIntersection::setDialog() dialogTool->setPointName(p->name()); } -void VToolPointOfIntersection::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, +void VToolPointOfIntersection::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); @@ -72,7 +72,7 @@ void VToolPointOfIntersection::Create(DialogTool *dialog, VMainGraphicsScene *sc void VToolPointOfIntersection::Create(const qint64 _id, const QString &pointName, const qint64 &firstPointId, const qint64 &secondPointId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { const VPointF *firstPoint = data->GeometricObject(firstPointId); @@ -138,14 +138,14 @@ void VToolPointOfIntersection::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrFirstPoint, firstPointId); - SetAttribute(domElement, AttrSecondPoint, secondPointId); + doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); + doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); AddToCalculation(domElement); } @@ -156,11 +156,11 @@ void VToolPointOfIntersection::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrFirstPoint, firstPointId); - SetAttribute(domElement, AttrSecondPoint, secondPointId); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); + doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); } } @@ -169,7 +169,7 @@ void VToolPointOfIntersection::SaveDialog(QDomElement &domElement) Q_CHECK_PTR(dialog); DialogPointOfIntersection *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - SetAttribute(domElement, AttrName, dialogTool->getPointName()); - SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); - SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); } diff --git a/src/tools/drawTools/vtoolpointofintersection.h b/src/tools/drawTools/vtoolpointofintersection.h index 33e2905c6..1692c75e4 100644 --- a/src/tools/drawTools/vtoolpointofintersection.h +++ b/src/tools/drawTools/vtoolpointofintersection.h @@ -48,7 +48,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolPointOfIntersection(VDomDocument *doc, VContainer *data, const qint64 &id, + VToolPointOfIntersection(VPattern *doc, VContainer *data, const qint64 &id, const qint64 &firstPointId, const qint64 &secondPointId, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); /** @@ -62,7 +62,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool. * @param _id tool id, 0 if tool doesn't exist yet. @@ -79,7 +79,7 @@ public: */ static void Create(const qint64 _id, const QString &pointName, const qint64 &firstPointId, const qint64 &secondPointId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, + VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); static const QString ToolType; public slots: diff --git a/src/tools/drawTools/vtoolshoulderpoint.cpp b/src/tools/drawTools/vtoolshoulderpoint.cpp index 98ca0ce68..04ab02cd3 100644 --- a/src/tools/drawTools/vtoolshoulderpoint.cpp +++ b/src/tools/drawTools/vtoolshoulderpoint.cpp @@ -32,7 +32,7 @@ const QString VToolShoulderPoint::ToolType = QStringLiteral("shoulder"); -VToolShoulderPoint::VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id, +VToolShoulderPoint::VToolShoulderPoint(VPattern *doc, VContainer *data, const qint64 &id, const QString &typeLine, const QString &formula, const qint64 &p1Line, const qint64 &p2Line, const qint64 &pShoulder, const Tool::Sources &typeCreation, QGraphicsItem * parent) @@ -89,7 +89,7 @@ QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Li } } -void VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data) +void VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); DialogShoulderPoint *dialogTool = qobject_cast(dialog); @@ -107,7 +107,7 @@ void VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphicsScene *scene, V void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const qint64 &p1Line, const qint64 &p2Line, const qint64 &pShoulder, const QString &typeLine, const QString &pointName, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { const VPointF *firstPoint = data->GeometricObject(p1Line); @@ -190,17 +190,17 @@ void VToolShoulderPoint::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrTypeLine, typeLine); - SetAttribute(domElement, AttrLength, formula); - SetAttribute(domElement, AttrP1Line, basePointId); - SetAttribute(domElement, AttrP2Line, p2Line); - SetAttribute(domElement, AttrPShoulder, pShoulder); + doc->SetAttribute(domElement, AttrTypeLine, typeLine); + doc->SetAttribute(domElement, AttrLength, formula); + doc->SetAttribute(domElement, AttrP1Line, basePointId); + doc->SetAttribute(domElement, AttrP2Line, p2Line); + doc->SetAttribute(domElement, AttrPShoulder, pShoulder); AddToCalculation(domElement); } @@ -211,14 +211,14 @@ void VToolShoulderPoint::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrName, toMM(point->mx())); - SetAttribute(domElement, AttrName, toMM(point->my())); - SetAttribute(domElement, AttrTypeLine, typeLine); - SetAttribute(domElement, AttrLength, formula); - SetAttribute(domElement, AttrP1Line, basePointId); - SetAttribute(domElement, AttrP2Line, p2Line); - SetAttribute(domElement, AttrPShoulder, pShoulder); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrName, toMM(point->mx())); + doc->SetAttribute(domElement, AttrName, toMM(point->my())); + doc->SetAttribute(domElement, AttrTypeLine, typeLine); + doc->SetAttribute(domElement, AttrLength, formula); + doc->SetAttribute(domElement, AttrP1Line, basePointId); + doc->SetAttribute(domElement, AttrP2Line, p2Line); + doc->SetAttribute(domElement, AttrPShoulder, pShoulder); } } @@ -234,10 +234,10 @@ void VToolShoulderPoint::SaveDialog(QDomElement &domElement) Q_CHECK_PTR(dialog); DialogShoulderPoint *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - SetAttribute(domElement, AttrName, dialogTool->getPointName()); - SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); - SetAttribute(domElement, AttrLength, dialogTool->getFormula()); - SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->getP1Line())); - SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getP2Line())); - SetAttribute(domElement, AttrPShoulder, QString().setNum(dialogTool->getPShoulder())); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); + doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->getP1Line())); + doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getP2Line())); + doc->SetAttribute(domElement, AttrPShoulder, QString().setNum(dialogTool->getPShoulder())); } diff --git a/src/tools/drawTools/vtoolshoulderpoint.h b/src/tools/drawTools/vtoolshoulderpoint.h index fec464fc2..0566a994e 100644 --- a/src/tools/drawTools/vtoolshoulderpoint.h +++ b/src/tools/drawTools/vtoolshoulderpoint.h @@ -51,7 +51,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, + VToolShoulderPoint(VPattern *doc, VContainer *data, const qint64 &id, const QString &typeLine, const QString &formula, const qint64 &p1Line, const qint64 &p2Line, const qint64 &pShoulder, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); @@ -76,7 +76,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool. * @param _id tool id, 0 if tool doesn't exist yet. @@ -96,7 +96,7 @@ public: */ static void Create(const qint64 _id, const QString &formula, const qint64 &p1Line, const qint64 &p2Line, const qint64 &pShoulder, const QString &typeLine, const QString &pointName, const qreal &mx, - const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); static const QString ToolType; public slots: diff --git a/src/tools/drawTools/vtoolsinglepoint.cpp b/src/tools/drawTools/vtoolsinglepoint.cpp index 38922455b..f470b4d1f 100644 --- a/src/tools/drawTools/vtoolsinglepoint.cpp +++ b/src/tools/drawTools/vtoolsinglepoint.cpp @@ -31,7 +31,7 @@ const QString VToolSinglePoint::ToolType = QStringLiteral("single"); -VToolSinglePoint::VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, +VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, QGraphicsItem * parent ) :VToolPoint(doc, data, id, parent) { @@ -66,13 +66,13 @@ void VToolSinglePoint::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrX, toMM(point->x())); - SetAttribute(domElement, AttrY, toMM(point->y())); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrX, toMM(point->x())); + doc->SetAttribute(domElement, AttrY, toMM(point->y())); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); AddToCalculation(domElement); } @@ -83,11 +83,11 @@ void VToolSinglePoint::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrX, QString().setNum(toMM(point->x()))); - SetAttribute(domElement, AttrY, QString().setNum(toMM(point->y()))); - SetAttribute(domElement, AttrMx, QString().setNum(toMM(point->mx()))); - SetAttribute(domElement, AttrMy, QString().setNum(toMM(point->my()))); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrX, QString().setNum(toMM(point->x()))); + doc->SetAttribute(domElement, AttrY, QString().setNum(toMM(point->y()))); + doc->SetAttribute(domElement, AttrMx, QString().setNum(toMM(point->mx()))); + doc->SetAttribute(domElement, AttrMy, QString().setNum(toMM(point->my()))); } } @@ -113,8 +113,8 @@ QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrX, QString().setNum(toMM(newPos.x()))); - SetAttribute(domElement, AttrY, QString().setNum(toMM(newPos.y()))); + doc->SetAttribute(domElement, AttrX, QString().setNum(toMM(newPos.x()))); + doc->SetAttribute(domElement, AttrY, QString().setNum(toMM(newPos.y()))); QList list = this->scene()->views(); VAbstractTool::NewSceneRect(this->scene(), list[0]); @@ -142,9 +142,9 @@ void VToolSinglePoint::SaveDialog(QDomElement &domElement) Q_CHECK_PTR(dialogTool); QPointF p = dialogTool->getPoint(); QString name = dialogTool->getName(); - SetAttribute(domElement, AttrName, name); - SetAttribute(domElement, AttrX, QString().setNum(toMM(p.x()))); - SetAttribute(domElement, AttrY, QString().setNum(toMM(p.y()))); + doc->SetAttribute(domElement, AttrName, name); + doc->SetAttribute(domElement, AttrX, QString().setNum(toMM(p.x()))); + doc->SetAttribute(domElement, AttrY, QString().setNum(toMM(p.y()))); } void VToolSinglePoint::setColorLabel(const Qt::GlobalColor &color) diff --git a/src/tools/drawTools/vtoolsinglepoint.h b/src/tools/drawTools/vtoolsinglepoint.h index 625a2b231..2e09e0353 100644 --- a/src/tools/drawTools/vtoolsinglepoint.h +++ b/src/tools/drawTools/vtoolsinglepoint.h @@ -47,7 +47,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, + VToolSinglePoint (VPattern *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0 ); /** * @brief setDialog set dialog when user want change tool option. diff --git a/src/tools/drawTools/vtoolspline.cpp b/src/tools/drawTools/vtoolspline.cpp index 02760da64..cada66ebe 100644 --- a/src/tools/drawTools/vtoolspline.cpp +++ b/src/tools/drawTools/vtoolspline.cpp @@ -33,7 +33,7 @@ const QString VToolSpline::TagName = QStringLiteral("spline"); const QString VToolSpline::ToolType = QStringLiteral("simple"); -VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, +VToolSpline::VToolSpline(VPattern *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, QGraphicsItem *parent) :VDrawTool(doc, data, id), QGraphicsPathItem(parent), controlPoints(QVector()) { @@ -90,7 +90,7 @@ void VToolSpline::setDialog() dialogTool->setKCurve(spl->GetKcurve()); } -void VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, +void VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); @@ -109,7 +109,7 @@ void VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocu void VToolSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4, const qreal &kAsm1, const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { VPointF point1 = *data->GeometricObject(p1); @@ -166,11 +166,11 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrAngle1, QString().setNum(spl.GetAngle1())); - SetAttribute(domElement, AttrAngle2, QString().setNum(spl.GetAngle2())); - SetAttribute(domElement, AttrKAsm1, QString().setNum(spl.GetKasm1())); - SetAttribute(domElement, AttrKAsm2, QString().setNum(spl.GetKasm2())); - SetAttribute(domElement, AttrKCurve, QString().setNum(spl.GetKcurve())); + doc->SetAttribute(domElement, AttrAngle1, QString().setNum(spl.GetAngle1())); + doc->SetAttribute(domElement, AttrAngle2, QString().setNum(spl.GetAngle2())); + doc->SetAttribute(domElement, AttrKAsm1, QString().setNum(spl.GetKasm1())); + doc->SetAttribute(domElement, AttrKAsm2, QString().setNum(spl.GetKasm2())); + doc->SetAttribute(domElement, AttrKCurve, QString().setNum(spl.GetKcurve())); emit FullUpdateTree(); emit toolhaveChange(); } @@ -186,15 +186,15 @@ void VToolSpline::AddToFile() const VSpline *spl = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrPoint1, spl->GetP1().id()); - SetAttribute(domElement, AttrPoint4, spl->GetP4().id()); - SetAttribute(domElement, AttrAngle1, spl->GetAngle1()); - SetAttribute(domElement, AttrAngle2, spl->GetAngle2()); - SetAttribute(domElement, AttrKAsm1, spl->GetKasm1()); - SetAttribute(domElement, AttrKAsm2, spl->GetKasm2()); - SetAttribute(domElement, AttrKCurve, spl->GetKcurve()); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrPoint1, spl->GetP1().id()); + doc->SetAttribute(domElement, AttrPoint4, spl->GetP4().id()); + doc->SetAttribute(domElement, AttrAngle1, spl->GetAngle1()); + doc->SetAttribute(domElement, AttrAngle2, spl->GetAngle2()); + doc->SetAttribute(domElement, AttrKAsm1, spl->GetKasm1()); + doc->SetAttribute(domElement, AttrKAsm2, spl->GetKasm2()); + doc->SetAttribute(domElement, AttrKCurve, spl->GetKcurve()); AddToCalculation(domElement); } @@ -205,13 +205,13 @@ void VToolSpline::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrPoint1, spl->GetP1().id()); - SetAttribute(domElement, AttrPoint4, spl->GetP4().id()); - SetAttribute(domElement, AttrAngle1, spl->GetAngle1()); - SetAttribute(domElement, AttrAngle2, spl->GetAngle2()); - SetAttribute(domElement, AttrKAsm1, spl->GetKasm1()); - SetAttribute(domElement, AttrKAsm2, spl->GetKasm2()); - SetAttribute(domElement, AttrKCurve, spl->GetKcurve()); + doc->SetAttribute(domElement, AttrPoint1, spl->GetP1().id()); + doc->SetAttribute(domElement, AttrPoint4, spl->GetP4().id()); + doc->SetAttribute(domElement, AttrAngle1, spl->GetAngle1()); + doc->SetAttribute(domElement, AttrAngle2, spl->GetAngle2()); + doc->SetAttribute(domElement, AttrKAsm1, spl->GetKasm1()); + doc->SetAttribute(domElement, AttrKAsm2, spl->GetKasm2()); + doc->SetAttribute(domElement, AttrKCurve, spl->GetKcurve()); } } @@ -298,13 +298,13 @@ void VToolSpline::SaveDialog(QDomElement &domElement) spl = VSpline (point1, controlPoints[0]->pos(), controlPoints[1]->pos(), point4, dialogTool->getKCurve()); - SetAttribute(domElement, AttrPoint1, spl.GetP1().id()); - SetAttribute(domElement, AttrPoint4, spl.GetP4().id()); - SetAttribute(domElement, AttrAngle1, spl.GetAngle1()); - SetAttribute(domElement, AttrAngle2, spl.GetAngle2()); - SetAttribute(domElement, AttrKAsm1, spl.GetKasm1()); - SetAttribute(domElement, AttrKAsm2, spl.GetKasm2()); - SetAttribute(domElement, AttrKCurve, spl.GetKcurve()); + doc->SetAttribute(domElement, AttrPoint1, spl.GetP1().id()); + doc->SetAttribute(domElement, AttrPoint4, spl.GetP4().id()); + doc->SetAttribute(domElement, AttrAngle1, spl.GetAngle1()); + doc->SetAttribute(domElement, AttrAngle2, spl.GetAngle2()); + doc->SetAttribute(domElement, AttrKAsm1, spl.GetKasm1()); + doc->SetAttribute(domElement, AttrKAsm2, spl.GetKasm2()); + doc->SetAttribute(domElement, AttrKCurve, spl.GetKcurve()); } void VToolSpline::RefreshGeometry() diff --git a/src/tools/drawTools/vtoolspline.h b/src/tools/drawTools/vtoolspline.h index fc8350083..ce15a1500 100644 --- a/src/tools/drawTools/vtoolspline.h +++ b/src/tools/drawTools/vtoolspline.h @@ -49,7 +49,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolSpline (VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, + VToolSpline (VPattern *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0 ); /** * @brief setDialog set dialog when user want change tool option. @@ -62,7 +62,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool. * @param _id tool id, 0 if tool doesn't exist yet. @@ -81,7 +81,7 @@ public: */ static void Create(const qint64 _id, const qint64 &p1, const qint64 &p4, const qreal &kAsm1, const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); static const QString TagName; static const QString ToolType; diff --git a/src/tools/drawTools/vtoolsplinepath.cpp b/src/tools/drawTools/vtoolsplinepath.cpp index 4316905f5..587854374 100644 --- a/src/tools/drawTools/vtoolsplinepath.cpp +++ b/src/tools/drawTools/vtoolsplinepath.cpp @@ -32,7 +32,7 @@ const QString VToolSplinePath::TagName = QStringLiteral("spline"); const QString VToolSplinePath::ToolType = QStringLiteral("path"); -VToolSplinePath::VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, +VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, QGraphicsItem *parent) :VDrawTool(doc, data, id), QGraphicsPathItem(parent), controlPoints(QVector()) { @@ -84,7 +84,7 @@ void VToolSplinePath::setDialog() dialogTool->SetPath(*splPath); } -void VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data) +void VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); DialogSplinePath *dialogTool = qobject_cast(dialog); @@ -99,7 +99,7 @@ void VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDom } void VToolSplinePath::Create(const qint64 _id, VSplinePath *path, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, + VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { qint64 id = _id; @@ -151,7 +151,7 @@ void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, cons QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.getKCurve())); + doc->SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.getKCurve())); UpdatePathPoint(domElement, splPath); emit FullUpdateTree(); emit toolhaveChange(); @@ -181,10 +181,10 @@ void VToolSplinePath::UpdatePathPoint(QDomNode& node, VSplinePath &path) if (domElement.isNull() == false) { VSplinePoint p = path[i]; - SetAttribute(domElement, AttrPSpline, p.P().id()); - SetAttribute(domElement, AttrKAsm1, p.KAsm1()); - SetAttribute(domElement, AttrKAsm2, p.KAsm2()); - SetAttribute(domElement, AttrAngle, p.Angle2()); + doc->SetAttribute(domElement, AttrPSpline, p.P().id()); + doc->SetAttribute(domElement, AttrKAsm1, p.KAsm1()); + doc->SetAttribute(domElement, AttrKAsm2, p.KAsm2()); + doc->SetAttribute(domElement, AttrAngle, p.Angle2()); } } } @@ -230,9 +230,9 @@ void VToolSplinePath::AddToFile() VSplinePath splPath = *VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrKCurve, splPath.getKCurve()); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrKCurve, splPath.getKCurve()); for (qint32 i = 0; i < splPath.CountPoint(); ++i) { @@ -268,7 +268,7 @@ void VToolSplinePath::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.getKCurve())); + doc->SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.getKCurve())); UpdatePathPoint(domElement, splPath); } @@ -279,10 +279,10 @@ void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint & { QDomElement pathPoint = doc->createElement(AttrPathPoint); - SetAttribute(pathPoint, AttrPSpline, splPoint.P().id()); - SetAttribute(pathPoint, AttrKAsm1, splPoint.KAsm1()); - SetAttribute(pathPoint, AttrKAsm2, splPoint.KAsm2()); - SetAttribute(pathPoint, AttrAngle, splPoint.Angle2()); + doc->SetAttribute(pathPoint, AttrPSpline, splPoint.P().id()); + doc->SetAttribute(pathPoint, AttrKAsm1, splPoint.KAsm1()); + doc->SetAttribute(pathPoint, AttrKAsm2, splPoint.KAsm2()); + doc->SetAttribute(pathPoint, AttrAngle, splPoint.Angle2()); domElement.appendChild(pathPoint); } @@ -376,7 +376,7 @@ void VToolSplinePath::SaveDialog(QDomElement &domElement) CorectControlPoints(spl, splPath, i); } - SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.getKCurve())); + doc->SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.getKCurve())); UpdatePathPoint(domElement, splPath); } diff --git a/src/tools/drawTools/vtoolsplinepath.h b/src/tools/drawTools/vtoolsplinepath.h index a905f4cf8..77398eba1 100644 --- a/src/tools/drawTools/vtoolsplinepath.h +++ b/src/tools/drawTools/vtoolsplinepath.h @@ -48,7 +48,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, + VToolSplinePath(VPattern *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); /** * @brief setDialog set dialog when user want change tool option. @@ -61,7 +61,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool. * @param _id tool id, 0 if tool doesn't exist yet. @@ -73,7 +73,7 @@ public: * @param typeCreation way we create this tool. */ static void Create(const qint64 _id, VSplinePath *path, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, + VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); static const QString TagName; static const QString ToolType; diff --git a/src/tools/drawTools/vtooltriangle.cpp b/src/tools/drawTools/vtooltriangle.cpp index c0be5dd83..4dd50e717 100644 --- a/src/tools/drawTools/vtooltriangle.cpp +++ b/src/tools/drawTools/vtooltriangle.cpp @@ -31,7 +31,7 @@ const QString VToolTriangle::ToolType = QStringLiteral("triangle"); -VToolTriangle::VToolTriangle(VDomDocument *doc, VContainer *data, const qint64 &id, +VToolTriangle::VToolTriangle(VPattern *doc, VContainer *data, const qint64 &id, const qint64 &axisP1Id, const qint64 &axisP2Id, const qint64 &firstPointId, const qint64 &secondPointId, const Tool::Sources &typeCreation, QGraphicsItem *parent) :VToolPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId), @@ -62,7 +62,7 @@ void VToolTriangle::setDialog() } void VToolTriangle::Create(DialogTool *dialog, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data) + VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); DialogTriangle *dialogTool = qobject_cast(dialog); @@ -78,7 +78,7 @@ void VToolTriangle::Create(DialogTool *dialog, VMainGraphicsScene *scene, void VToolTriangle::Create(const qint64 _id, const QString &pointName, const qint64 &axisP1Id, const qint64 &axisP2Id, const qint64 &firstPointId, const qint64 &secondPointId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { const VPointF *axisP1 = data->GeometricObject(axisP1Id); @@ -194,16 +194,16 @@ void VToolTriangle::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrAxisP1, axisP1Id); - SetAttribute(domElement, AttrAxisP2, axisP2Id); - SetAttribute(domElement, AttrFirstPoint, firstPointId); - SetAttribute(domElement, AttrSecondPoint, secondPointId); + doc->SetAttribute(domElement, AttrAxisP1, axisP1Id); + doc->SetAttribute(domElement, AttrAxisP2, axisP2Id); + doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); + doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); AddToCalculation(domElement); } @@ -214,13 +214,13 @@ void VToolTriangle::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrName, point->name()); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); - SetAttribute(domElement, AttrAxisP1, axisP1Id); - SetAttribute(domElement, AttrAxisP2, axisP2Id); - SetAttribute(domElement, AttrFirstPoint, firstPointId); - SetAttribute(domElement, AttrSecondPoint, secondPointId); + doc->SetAttribute(domElement, AttrName, point->name()); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrAxisP1, axisP1Id); + doc->SetAttribute(domElement, AttrAxisP2, axisP2Id); + doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); + doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); } } @@ -229,9 +229,9 @@ void VToolTriangle::SaveDialog(QDomElement &domElement) Q_CHECK_PTR(dialog); DialogTriangle *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - SetAttribute(domElement, AttrName, dialogTool->getPointName()); - SetAttribute(domElement, AttrAxisP1, QString().setNum(dialogTool->getAxisP1Id())); - SetAttribute(domElement, AttrAxisP2, QString().setNum(dialogTool->getAxisP2Id())); - SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); - SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrAxisP1, QString().setNum(dialogTool->getAxisP1Id())); + doc->SetAttribute(domElement, AttrAxisP2, QString().setNum(dialogTool->getAxisP2Id())); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); } diff --git a/src/tools/drawTools/vtooltriangle.h b/src/tools/drawTools/vtooltriangle.h index ba2f76bf4..9d6c4fc2d 100644 --- a/src/tools/drawTools/vtooltriangle.h +++ b/src/tools/drawTools/vtooltriangle.h @@ -50,7 +50,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolTriangle(VDomDocument *doc, VContainer *data, const qint64 &id, const qint64 &axisP1Id, + VToolTriangle(VPattern *doc, VContainer *data, const qint64 &id, const qint64 &axisP1Id, const qint64 &axisP2Id, const qint64 &firstPointId, const qint64 &secondPointId, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); /** @@ -64,7 +64,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool. * @param _id tool id, 0 if tool doesn't exist yet. @@ -83,7 +83,7 @@ public: */ static void Create(const qint64 _id, const QString &pointName, const qint64 &axisP1Id, const qint64 &axisP2Id, const qint64 &firstPointId, const qint64 &secondPointId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); /** * @brief FindPoint find point intersection two foots right triangle. diff --git a/src/tools/nodeDetails/vabstractnode.cpp b/src/tools/nodeDetails/vabstractnode.cpp index 4a9464eb2..43f39520c 100644 --- a/src/tools/nodeDetails/vabstractnode.cpp +++ b/src/tools/nodeDetails/vabstractnode.cpp @@ -32,7 +32,7 @@ const QString VAbstractNode::AttrIdObject = QStringLiteral("idObject"); const QString VAbstractNode::AttrIdTool = QStringLiteral("idTool"); -VAbstractNode::VAbstractNode(VDomDocument *doc, VContainer *data, const qint64 &id, const qint64 &idNode, +VAbstractNode::VAbstractNode(VPattern *doc, VContainer *data, const qint64 &id, const qint64 &idNode, const qint64 &idTool, QObject *parent) : VAbstractTool(doc, data, id, parent), idNode(idNode), idTool(idTool) { @@ -76,7 +76,7 @@ void VAbstractNode::DeleteNode() void VAbstractNode::AddToModeling(const QDomElement &domElement) { QDomElement modelingElement; - bool ok = doc->GetActivModelingElement(modelingElement); + bool ok = doc->GetActivNodeElement(VPattern::TagModeling, modelingElement); if (ok) { modelingElement.appendChild(domElement); diff --git a/src/tools/nodeDetails/vabstractnode.h b/src/tools/nodeDetails/vabstractnode.h index fc3519cb8..181cfd165 100644 --- a/src/tools/nodeDetails/vabstractnode.h +++ b/src/tools/nodeDetails/vabstractnode.h @@ -46,7 +46,7 @@ public: * @param id object id in containerNode. * @param parent parent object. */ - VAbstractNode(VDomDocument *doc, VContainer *data, const qint64 &id, const qint64 &idNode, + VAbstractNode(VPattern *doc, VContainer *data, const qint64 &id, const qint64 &idNode, const qint64 &idTool, QObject *parent = 0); virtual ~VAbstractNode() {} static const QString AttrIdObject; diff --git a/src/tools/nodeDetails/vnodearc.cpp b/src/tools/nodeDetails/vnodearc.cpp index ebda652c1..fe2516375 100644 --- a/src/tools/nodeDetails/vnodearc.cpp +++ b/src/tools/nodeDetails/vnodearc.cpp @@ -33,7 +33,7 @@ const QString VNodeArc::TagName = QStringLiteral("arc"); const QString VNodeArc::ToolType = QStringLiteral("modeling"); -VNodeArc::VNodeArc(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, const Tool::Sources &typeCreation, +VNodeArc::VNodeArc(VPattern *doc, VContainer *data, qint64 id, qint64 idArc, const Tool::Sources &typeCreation, const qint64 &idTool, QObject *qoParent, QGraphicsItem *parent) :VAbstractNode(doc, data, id, idArc, idTool, qoParent), QGraphicsPathItem(parent) { @@ -50,7 +50,7 @@ VNodeArc::VNodeArc(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, } } -void VNodeArc::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, const Document::Documents &parse, +void VNodeArc::Create(VPattern *doc, VContainer *data, qint64 id, qint64 idArc, const Document::Documents &parse, const Tool::Sources &typeCreation, const qint64 &idTool, QObject *parent) { VAbstractTool::AddRecord(id, Tool::NodeArc, doc); @@ -93,12 +93,12 @@ void VNodeArc::AddToFile() { QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrIdObject, idNode); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrIdObject, idNode); if (idTool != 0) { - SetAttribute(domElement, AttrIdTool, idTool); + doc->SetAttribute(domElement, AttrIdTool, idTool); } AddToModeling(domElement); @@ -109,10 +109,10 @@ void VNodeArc::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrIdObject, idNode); + doc->SetAttribute(domElement, AttrIdObject, idNode); if (idTool != 0) { - SetAttribute(domElement, AttrIdTool, idTool); + doc->SetAttribute(domElement, AttrIdTool, idTool); } } } diff --git a/src/tools/nodeDetails/vnodearc.h b/src/tools/nodeDetails/vnodearc.h index 2a5093f69..6ab04e358 100644 --- a/src/tools/nodeDetails/vnodearc.h +++ b/src/tools/nodeDetails/vnodearc.h @@ -48,7 +48,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VNodeArc(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, + VNodeArc(VPattern *doc, VContainer *data, qint64 id, qint64 idArc, const Tool::Sources &typeCreation, const qint64 &idTool = 0, QObject *qoParent = 0, QGraphicsItem * parent = 0); /** @@ -60,7 +60,7 @@ public: * @param parse parser file mode. * @param typeCreation way we create this tool. */ - static void Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, const Document::Documents &parse, + static void Create(VPattern *doc, VContainer *data, qint64 id, qint64 idArc, const Document::Documents &parse, const Tool::Sources &typeCreation, const qint64 &idTool = 0, QObject *parent = 0); static const QString TagName; static const QString ToolType; diff --git a/src/tools/nodeDetails/vnodepoint.cpp b/src/tools/nodeDetails/vnodepoint.cpp index d86fbccd8..a3d7ffd14 100644 --- a/src/tools/nodeDetails/vnodepoint.cpp +++ b/src/tools/nodeDetails/vnodepoint.cpp @@ -33,7 +33,7 @@ const QString VNodePoint::TagName = QStringLiteral("point"); const QString VNodePoint::ToolType = QStringLiteral("modeling"); -VNodePoint::VNodePoint(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint, +VNodePoint::VNodePoint(VPattern *doc, VContainer *data, qint64 id, qint64 idPoint, const Tool::Sources &typeCreation, const qint64 &idTool, QObject *qoParent, QGraphicsItem *parent) :VAbstractNode(doc, data, id, idPoint, idTool, qoParent), QGraphicsEllipseItem(parent), radius(toPixel(1.5)), @@ -58,7 +58,7 @@ VNodePoint::VNodePoint(VDomDocument *doc, VContainer *data, qint64 id, qint64 id } } -void VNodePoint::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint, +void VNodePoint::Create(VPattern *doc, VContainer *data, qint64 id, qint64 idPoint, const Document::Documents &parse, const Tool::Sources &typeCreation, const qint64 &idTool, QObject *parent) { @@ -105,14 +105,14 @@ void VNodePoint::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrIdObject, idNode); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrIdObject, idNode); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); if (idTool != 0) { - SetAttribute(domElement, AttrIdTool, idTool); + doc->SetAttribute(domElement, AttrIdTool, idTool); } AddToModeling(domElement); @@ -124,12 +124,12 @@ void VNodePoint::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrIdObject, idNode); - SetAttribute(domElement, AttrMx, toMM(point->mx())); - SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrIdObject, idNode); + doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); + doc->SetAttribute(domElement, AttrMy, toMM(point->my())); if (idTool != 0) { - SetAttribute(domElement, AttrIdTool, idTool); + doc->SetAttribute(domElement, AttrIdTool, idTool); } } } @@ -172,8 +172,8 @@ void VNodePoint::UpdateNamePosition(qreal mx, qreal my) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrMx, QString().setNum(toMM(mx))); - SetAttribute(domElement, AttrMy, QString().setNum(toMM(my))); + doc->SetAttribute(domElement, AttrMx, QString().setNum(toMM(mx))); + doc->SetAttribute(domElement, AttrMy, QString().setNum(toMM(my))); emit toolhaveChange(); } } diff --git a/src/tools/nodeDetails/vnodepoint.h b/src/tools/nodeDetails/vnodepoint.h index 9e366c5af..ea66884c7 100644 --- a/src/tools/nodeDetails/vnodepoint.h +++ b/src/tools/nodeDetails/vnodepoint.h @@ -48,7 +48,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VNodePoint(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint, + VNodePoint(VPattern *doc, VContainer *data, qint64 id, qint64 idPoint, const Tool::Sources &typeCreation, const qint64 &idTool = 0, QObject *qoParent = 0, QGraphicsItem * parent = 0 ); /** @@ -60,7 +60,7 @@ public: * @param parse parser file mode. * @param typeCreation way we create this tool. */ - static void Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint, + static void Create(VPattern *doc, VContainer *data, qint64 id, qint64 idPoint, const Document::Documents &parse, const Tool::Sources &typeCreation, const qint64 &idTool = 0, QObject *parent = 0); static const QString TagName; diff --git a/src/tools/nodeDetails/vnodespline.cpp b/src/tools/nodeDetails/vnodespline.cpp index 7ec99d27b..778cf3c62 100644 --- a/src/tools/nodeDetails/vnodespline.cpp +++ b/src/tools/nodeDetails/vnodespline.cpp @@ -33,7 +33,7 @@ const QString VNodeSpline::TagName = QStringLiteral("spline"); const QString VNodeSpline::ToolType = QStringLiteral("modelingSpline"); -VNodeSpline::VNodeSpline(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, +VNodeSpline::VNodeSpline(VPattern *doc, VContainer *data, qint64 id, qint64 idSpline, const Tool::Sources &typeCreation, const qint64 &idTool, QObject *qoParent, QGraphicsItem * parent) :VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent) @@ -51,7 +51,7 @@ VNodeSpline::VNodeSpline(VDomDocument *doc, VContainer *data, qint64 id, qint64 } } -VNodeSpline *VNodeSpline::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, +VNodeSpline *VNodeSpline::Create(VPattern *doc, VContainer *data, qint64 id, qint64 idSpline, const Document::Documents &parse, const Tool::Sources &typeCreation, const qint64 &idTool, QObject *parent) { @@ -96,12 +96,12 @@ void VNodeSpline::AddToFile() { QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrIdObject, idNode); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrIdObject, idNode); if (idTool != 0) { - SetAttribute(domElement, AttrIdTool, idTool); + doc->SetAttribute(domElement, AttrIdTool, idTool); } AddToModeling(domElement); @@ -112,10 +112,10 @@ void VNodeSpline::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrIdObject, QString().setNum(idNode)); + doc->SetAttribute(domElement, AttrIdObject, QString().setNum(idNode)); if (idTool != 0) { - SetAttribute(domElement, AttrIdTool, idTool); + doc->SetAttribute(domElement, AttrIdTool, idTool); } } } diff --git a/src/tools/nodeDetails/vnodespline.h b/src/tools/nodeDetails/vnodespline.h index 20559a3c5..aebc2b3c4 100644 --- a/src/tools/nodeDetails/vnodespline.h +++ b/src/tools/nodeDetails/vnodespline.h @@ -48,7 +48,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VNodeSpline(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, + VNodeSpline(VPattern *doc, VContainer *data, qint64 id, qint64 idSpline, const Tool::Sources &typeCreation, const qint64 &idTool = 0, QObject *qoParent = 0, QGraphicsItem * parent = 0); /** @@ -61,7 +61,7 @@ public: * @param typeCreation way we create this tool. * @return */ - static VNodeSpline *Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, + static VNodeSpline *Create(VPattern *doc, VContainer *data, qint64 id, qint64 idSpline, const Document::Documents &parse, const Tool::Sources &typeCreation, const qint64 &idTool = 0, QObject *parent = 0); static const QString TagName; diff --git a/src/tools/nodeDetails/vnodesplinepath.cpp b/src/tools/nodeDetails/vnodesplinepath.cpp index 54dc91ea5..db5effcfd 100644 --- a/src/tools/nodeDetails/vnodesplinepath.cpp +++ b/src/tools/nodeDetails/vnodesplinepath.cpp @@ -33,7 +33,7 @@ const QString VNodeSplinePath::TagName = QStringLiteral("spline"); const QString VNodeSplinePath::ToolType = QStringLiteral("modelingPath"); -VNodeSplinePath::VNodeSplinePath(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, +VNodeSplinePath::VNodeSplinePath(VPattern *doc, VContainer *data, qint64 id, qint64 idSpline, const Tool::Sources &typeCreation, const qint64 &idTool, QObject *qoParent, QGraphicsItem * parent) :VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent) @@ -51,7 +51,7 @@ VNodeSplinePath::VNodeSplinePath(VDomDocument *doc, VContainer *data, qint64 id, } } -void VNodeSplinePath::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, +void VNodeSplinePath::Create(VPattern *doc, VContainer *data, qint64 id, qint64 idSpline, const Document::Documents &parse, const Tool::Sources &typeCreation, const qint64 &idTool, QObject *parent) { @@ -100,12 +100,12 @@ void VNodeSplinePath::AddToFile() { QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrIdObject, idNode); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrIdObject, idNode); if (idTool != 0) { - SetAttribute(domElement, AttrIdTool, idTool); + doc->SetAttribute(domElement, AttrIdTool, idTool); } AddToModeling(domElement); @@ -116,10 +116,10 @@ void VNodeSplinePath::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrIdObject, QString().setNum(idNode)); + doc->SetAttribute(domElement, AttrIdObject, QString().setNum(idNode)); if (idTool != 0) { - SetAttribute(domElement, AttrIdTool, idTool); + doc->SetAttribute(domElement, AttrIdTool, idTool); } } } diff --git a/src/tools/nodeDetails/vnodesplinepath.h b/src/tools/nodeDetails/vnodesplinepath.h index 5429fee8c..5f35b8607 100644 --- a/src/tools/nodeDetails/vnodesplinepath.h +++ b/src/tools/nodeDetails/vnodesplinepath.h @@ -48,7 +48,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VNodeSplinePath(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, + VNodeSplinePath(VPattern *doc, VContainer *data, qint64 id, qint64 idSpline, const Tool::Sources &typeCreation, const qint64 &idTool = 0, QObject *qoParent = 0, QGraphicsItem * parent = 0); /** @@ -60,7 +60,7 @@ public: * @param parse parser file mode. * @param typeCreation way we create this tool. */ - static void Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, + static void Create(VPattern *doc, VContainer *data, qint64 id, qint64 idSpline, const Document::Documents &parse, const Tool::Sources &typeCreation, const qint64 &idTool = 0, QObject *parent = 0); static const QString TagName; diff --git a/src/tools/vabstracttool.cpp b/src/tools/vabstracttool.cpp index 8bb711086..b1cc2a69c 100644 --- a/src/tools/vabstracttool.cpp +++ b/src/tools/vabstracttool.cpp @@ -69,13 +69,13 @@ const QString VAbstractTool::TypeLineDotLine = QStringLiteral("dotLine"); const QString VAbstractTool::TypeLineDashDotLine = QStringLiteral("dashDotLine"); const QString VAbstractTool::TypeLineDashDotDotLine = QStringLiteral("dashDotDotLine"); -VAbstractTool::VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent) +VAbstractTool::VAbstractTool(VPattern *doc, VContainer *data, qint64 id, QObject *parent) :VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), currentColor(Qt::black), typeLine(TypeLineLine) { Q_CHECK_PTR(doc); - connect(this, &VAbstractTool::toolhaveChange, this->doc, &VDomDocument::haveLiteChange); - connect(this->doc, &VDomDocument::FullUpdateFromFile, this, &VAbstractTool::FullUpdateFromFile); - connect(this, &VAbstractTool::FullUpdateTree, this->doc, &VDomDocument::FullUpdateTree); + connect(this, &VAbstractTool::toolhaveChange, this->doc, &VPattern::haveLiteChange); + connect(this->doc, &VPattern::FullUpdateFromFile, this, &VAbstractTool::FullUpdateFromFile); + connect(this, &VAbstractTool::FullUpdateTree, this->doc, &VPattern::FullUpdateTree); emit toolhaveChange(); } @@ -303,7 +303,7 @@ const QStringList VAbstractTool::Styles() return styles; } -void VAbstractTool::AddRecord(const qint64 id, const Tool::Tools &toolType, VDomDocument *doc) +void VAbstractTool::AddRecord(const qint64 id, const Tool::Tools &toolType, VPattern *doc) { qint64 cursor = doc->getCursor(); QVector *history = doc->getHistory(); diff --git a/src/tools/vabstracttool.h b/src/tools/vabstracttool.h index c18f77f92..b866e14c0 100644 --- a/src/tools/vabstracttool.h +++ b/src/tools/vabstracttool.h @@ -30,7 +30,7 @@ #define VABSTRACTTOOL_H #include "vdatatool.h" -#include "../xml/vdomdocument.h" +#include "../xml/vpattern.h" #include /** @@ -47,7 +47,7 @@ public: * @param id object id in container. * @param parent parent object. */ - VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent = 0); + VAbstractTool(VPattern *doc, VContainer *data, qint64 id, QObject *parent = 0); virtual ~VAbstractTool(){} /** * @brief NewSceneRect calculate scene rect what contains all items and doesn't less that size of scene view. @@ -153,7 +153,7 @@ public: * @param toolType tool type * @param doc dom document container */ - static void AddRecord(const qint64 id, const Tool::Tools &toolType, VDomDocument *doc); + static void AddRecord(const qint64 id, const Tool::Tools &toolType, VPattern *doc); public slots: /** * @brief FullUpdateFromFile update tool data form file. @@ -178,7 +178,7 @@ protected: /** * @brief doc dom document container */ - VDomDocument *doc; + VPattern *doc; /** * @brief id object id. */ @@ -227,26 +227,7 @@ protected: * @return pen style. */ Qt::PenStyle LineStyle(); - template - /** - * @brief SetAttribute set attribute in pattern file. Replace "," by ".". - * @param domElement element in xml tree. - * @param name name of attribute. - * @param value value of attribute. - */ - void SetAttribute(QDomElement &domElement, const QString &name, const T &value) - { - QString val = QString().setNum(value); - val = val.replace(",", "."); - domElement.setAttribute(name, val); - } private: Q_DISABLE_COPY(VAbstractTool) }; - -template <> -inline void VAbstractTool::SetAttribute(QDomElement &domElement, const QString &name, const QString &value) -{ - domElement.setAttribute(name, value); -} #endif // VABSTRACTTOOL_H diff --git a/src/tools/vtooldetail.cpp b/src/tools/vtooldetail.cpp index 6a0e26e1d..278e2713a 100644 --- a/src/tools/vtooldetail.cpp +++ b/src/tools/vtooldetail.cpp @@ -40,7 +40,7 @@ const QString VToolDetail::AttrNodeType = QStringLiteral("nodeType"); const QString VToolDetail::NodeTypeContour = QStringLiteral("Contour"); const QString VToolDetail::NodeTypeModeling = QStringLiteral("Modeling"); -VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id, const Tool::Sources &typeCreation, +VToolDetail::VToolDetail(VPattern *doc, VContainer *data, const qint64 &id, const Tool::Sources &typeCreation, VMainGraphicsScene *scene, QGraphicsItem *parent) :VAbstractTool(doc, data, id), QGraphicsPathItem(parent), dialog(0), sceneDetails(scene) { @@ -93,7 +93,7 @@ void VToolDetail::setDialog() dialogTool->setDetails(detail); } -void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data) +void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); DialogDetail *dialogTool = qobject_cast(dialog); @@ -140,7 +140,7 @@ void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocu Create(0, det, scene, doc, data, Document::FullParse, Tool::FromGui); } -void VToolDetail::Create(const qint64 &_id, const VDetail &newDetail, VMainGraphicsScene *scene, VDomDocument *doc, +void VToolDetail::Create(const qint64 &_id, const VDetail &newDetail, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { qint64 id = _id; @@ -188,10 +188,10 @@ void VToolDetail::FullUpdateFromGui(int result) DialogDetail *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); VDetail det = dialogTool->getDetails(); - SetAttribute(domElement, AttrName, det.getName()); - SetAttribute(domElement, AttrSupplement, QString().setNum(det.getSeamAllowance())); - SetAttribute(domElement, AttrClosed, QString().setNum(det.getClosed())); - SetAttribute(domElement, AttrWidth, QString().setNum(det.getWidth())); + doc->SetAttribute(domElement, AttrName, det.getName()); + doc->SetAttribute(domElement, AttrSupplement, QString().setNum(det.getSeamAllowance())); + doc->SetAttribute(domElement, AttrClosed, QString().setNum(det.getClosed())); + doc->SetAttribute(domElement, AttrWidth, QString().setNum(det.getWidth())); RemoveAllChild(domElement); for (ptrdiff_t i = 0; i < det.CountNode(); ++i) { @@ -221,13 +221,13 @@ void VToolDetail::AddToFile() VDetail detail = VAbstractTool::data.GetDetail(id); QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrName, detail.getName()); - SetAttribute(domElement, AttrMx, toMM(detail.getMx())); - SetAttribute(domElement, AttrMy, toMM(detail.getMy())); - SetAttribute(domElement, AttrSupplement, detail.getSeamAllowance()); - SetAttribute(domElement, AttrClosed, detail.getClosed()); - SetAttribute(domElement, AttrWidth, detail.getWidth()); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrName, detail.getName()); + doc->SetAttribute(domElement, AttrMx, toMM(detail.getMx())); + doc->SetAttribute(domElement, AttrMy, toMM(detail.getMy())); + doc->SetAttribute(domElement, AttrSupplement, detail.getSeamAllowance()); + doc->SetAttribute(domElement, AttrClosed, detail.getClosed()); + doc->SetAttribute(domElement, AttrWidth, detail.getWidth()); for (ptrdiff_t i = 0; i < detail.CountNode(); ++i) { @@ -235,7 +235,7 @@ void VToolDetail::AddToFile() } QDomElement element; - bool ok = doc->GetActivDetailsElement(element); + bool ok = doc->GetActivNodeElement(VPattern::TagDetails, element); if (ok) { element.appendChild(domElement); @@ -248,10 +248,10 @@ void VToolDetail::RefreshDataInFile() if (domElement.isElement()) { VDetail det = VAbstractTool::data.GetDetail(id); - SetAttribute(domElement, AttrName, det.getName()); - SetAttribute(domElement, AttrSupplement, QString().setNum(det.getSeamAllowance())); - SetAttribute(domElement, AttrClosed, QString().setNum(det.getClosed())); - SetAttribute(domElement, AttrWidth, QString().setNum(det.getWidth())); + doc->SetAttribute(domElement, AttrName, det.getName()); + doc->SetAttribute(domElement, AttrSupplement, QString().setNum(det.getSeamAllowance())); + doc->SetAttribute(domElement, AttrClosed, QString().setNum(det.getClosed())); + doc->SetAttribute(domElement, AttrWidth, QString().setNum(det.getWidth())); RemoveAllChild(domElement); for (ptrdiff_t i = 0; i < det.CountNode(); ++i) { @@ -270,8 +270,8 @@ QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrMx, QString().setNum(toMM(newPos.x()))); - SetAttribute(domElement, AttrMy, QString().setNum(toMM(newPos.y()))); + doc->SetAttribute(domElement, AttrMx, QString().setNum(toMM(newPos.x()))); + doc->SetAttribute(domElement, AttrMy, QString().setNum(toMM(newPos.y()))); QList list = this->scene()->views(); VAbstractTool::NewSceneRect(this->scene(), list[0]); @@ -362,30 +362,30 @@ void VToolDetail::AddNode(QDomElement &domElement, const VNodeDetail &node) { QDomElement nod = doc->createElement(TagNode); - SetAttribute(nod, AttrIdObject, node.getId()); - SetAttribute(nod, AttrMx, toMM(node.getMx())); - SetAttribute(nod, AttrMy, toMM(node.getMy())); + doc->SetAttribute(nod, AttrIdObject, node.getId()); + doc->SetAttribute(nod, AttrMx, toMM(node.getMx())); + doc->SetAttribute(nod, AttrMy, toMM(node.getMy())); if (node.getTypeNode() == NodeDetail::Contour) { - SetAttribute(nod, AttrNodeType, NodeTypeContour); + doc->SetAttribute(nod, AttrNodeType, NodeTypeContour); } else { - SetAttribute(nod, AttrNodeType, NodeTypeModeling); + doc->SetAttribute(nod, AttrNodeType, NodeTypeModeling); } switch (node.getTypeTool()) { case (Tool::NodeArc): - SetAttribute(nod, AttrType, QStringLiteral("NodeArc")); + doc->SetAttribute(nod, AttrType, QStringLiteral("NodeArc")); break; case (Tool::NodePoint): - SetAttribute(nod, AttrType, QStringLiteral("NodePoint")); + doc->SetAttribute(nod, AttrType, QStringLiteral("NodePoint")); break; case (Tool::NodeSpline): - SetAttribute(nod, AttrType, QStringLiteral("NodeSpline")); + doc->SetAttribute(nod, AttrType, QStringLiteral("NodeSpline")); break; case (Tool::NodeSplinePath): - SetAttribute(nod, AttrType, QStringLiteral("NodeSplinePath")); + doc->SetAttribute(nod, AttrType, QStringLiteral("NodeSplinePath")); break; default: qWarning()<<"May be wrong tool type!!! Ignoring."<setY(line.p2().y()); } -void VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data) +void VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); DialogUnionDetails *dialogTool = qobject_cast(dialog); @@ -417,7 +417,7 @@ void VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VD void VToolUnionDetails::Create(const qint64 _id, const VDetail &d1, const VDetail &d2, const qint64 &d1id, const qint64 &d2id, const ptrdiff_t &indexD1, const ptrdiff_t &indexD2, - VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { VToolUnionDetails *unionDetails = 0; @@ -613,7 +613,7 @@ void VToolUnionDetails::Create(const qint64 _id, const VDetail &d1, const VDetai } } -QVector VToolUnionDetails::GetDetailFromFile(VDomDocument *doc, const QDomElement &domElement) +QVector VToolUnionDetails::GetDetailFromFile(VPattern *doc, const QDomElement &domElement) { QVector vector; QDomNodeList detailList = domElement.childNodes(); @@ -672,10 +672,10 @@ void VToolUnionDetails::AddToFile() { QDomElement domElement = doc->createElement(TagName); - SetAttribute(domElement, AttrId, id); - SetAttribute(domElement, AttrType, ToolType); - SetAttribute(domElement, AttrIndexD1, indexD1); - SetAttribute(domElement, AttrIndexD2, indexD2); + doc->SetAttribute(domElement, AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrIndexD1, indexD1); + doc->SetAttribute(domElement, AttrIndexD2, indexD2); AddDetail(domElement, d1); AddDetail(domElement, d2); @@ -688,8 +688,8 @@ void VToolUnionDetails::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - SetAttribute(domElement, AttrIndexD1, indexD1); - SetAttribute(domElement, AttrIndexD2, indexD2); + doc->SetAttribute(domElement, AttrIndexD1, indexD1); + doc->SetAttribute(domElement, AttrIndexD2, indexD2); QDomNode domNode = domElement.firstChild(); domNode = UpdateDetail(domNode, d1); @@ -713,30 +713,30 @@ void VToolUnionDetails::AddNode(QDomElement &domElement, const VNodeDetail &node { QDomElement nod = doc->createElement(TagNode); - SetAttribute(nod, AttrIdObject, node.getId()); - SetAttribute(nod, AttrMx, toMM(node.getMx())); - SetAttribute(nod, AttrMy, toMM(node.getMy())); + doc->SetAttribute(nod, AttrIdObject, node.getId()); + doc->SetAttribute(nod, AttrMx, toMM(node.getMx())); + doc->SetAttribute(nod, AttrMy, toMM(node.getMy())); if (node.getTypeNode() == NodeDetail::Contour) { - SetAttribute(nod, AttrNodeType, NodeTypeContour); + doc->SetAttribute(nod, AttrNodeType, NodeTypeContour); } else { - SetAttribute(nod, AttrNodeType, NodeTypeModeling); + doc->SetAttribute(nod, AttrNodeType, NodeTypeModeling); } switch (node.getTypeTool()) { case (Tool::NodeArc): - SetAttribute(nod, AttrType, QStringLiteral("NodeArc")); + doc->SetAttribute(nod, AttrType, QStringLiteral("NodeArc")); break; case (Tool::NodePoint): - SetAttribute(nod, AttrType, QStringLiteral("NodePoint")); + doc->SetAttribute(nod, AttrType, QStringLiteral("NodePoint")); break; case (Tool::NodeSpline): - SetAttribute(nod, AttrType, QStringLiteral("NodeSpline")); + doc->SetAttribute(nod, AttrType, QStringLiteral("NodeSpline")); break; case (Tool::NodeSplinePath): - SetAttribute(nod, AttrType, QStringLiteral("NodeSplinePath")); + doc->SetAttribute(nod, AttrType, QStringLiteral("NodeSplinePath")); break; default: qWarning()<<"May be wrong tool type!!! Ignoring."<GetActivModelingElement(modelingElement); + bool ok = doc->GetActivNodeElement(VPattern::TagModeling, modelingElement); if (ok) { modelingElement.appendChild(domElement); diff --git a/src/tools/vtooluniondetails.h b/src/tools/vtooluniondetails.h index 5a7c68f8b..d8d507b01 100644 --- a/src/tools/vtooluniondetails.h +++ b/src/tools/vtooluniondetails.h @@ -51,7 +51,7 @@ public: * @param typeCreation way we create this tool. * @param parent parent object. */ - VToolUnionDetails(VDomDocument *doc, VContainer *data, const qint64 &id, const VDetail &d1, const VDetail &d2, + VToolUnionDetails(VPattern *doc, VContainer *data, const qint64 &id, const VDetail &d1, const VDetail &d2, const ptrdiff_t &indexD1, const ptrdiff_t &indexD2, const Tool::Sources &typeCreation, QObject *parent = 0); /** @@ -64,7 +64,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); + static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool. * @param _id tool id, 0 if tool doesn't exist yet. @@ -82,7 +82,7 @@ public: */ static void Create(const qint64 _id, const VDetail &d1, const VDetail &d2, const qint64 &d1id, const qint64 &d2id, const ptrdiff_t &indexD1, const ptrdiff_t &indexD2, VMainGraphicsScene *scene, - VDomDocument *doc, VContainer *data, const Document::Documents &parse, + VPattern *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation); /** * @brief GetDetailFromFile parse detail from file. @@ -90,7 +90,7 @@ public: * @param domElement tag in xml tree. * @return detail stored in file. */ - static QVector GetDetailFromFile(VDomDocument *doc, const QDomElement &domElement); + static QVector GetDetailFromFile(VPattern *doc, const QDomElement &domElement); static const QString TagName; static const QString ToolType; static const QString TagDetail; @@ -115,7 +115,7 @@ public: * @param pRotate point rotation. * @param angle angle rotation. */ - static void AddToNewDetail(QObject *tool, VDomDocument *doc, VContainer *data, VDetail &newDetail, + static void AddToNewDetail(QObject *tool, VPattern *doc, VContainer *data, VDetail &newDetail, const VDetail &det, const ptrdiff_t &i, const qint64 &idTool, const qreal &dx = 0, const qreal &dy = 0, const qint64 &pRotate = 0, const qreal &angle = 0); /** diff --git a/src/widgets/vsimplesplinepath.cpp b/src/widgets/vsimplesplinepath.cpp index fb63883b4..1488fb1d8 100644 --- a/src/widgets/vsimplesplinepath.cpp +++ b/src/widgets/vsimplesplinepath.cpp @@ -28,7 +28,7 @@ #include "vsimplesplinepath.h" -VSimpleSplinePath::VSimpleSplinePath(VDomDocument *doc, VContainer *data, qint64 id, qreal *factor) +VSimpleSplinePath::VSimpleSplinePath(VPattern *doc, VContainer *data, qint64 id, qreal *factor) :VAbstractTool(doc, data, id), factor(factor) { } diff --git a/src/widgets/vsimplesplinepath.h b/src/widgets/vsimplesplinepath.h index 457f32bf5..ae7af4fa7 100644 --- a/src/widgets/vsimplesplinepath.h +++ b/src/widgets/vsimplesplinepath.h @@ -47,7 +47,7 @@ public: * @param id spline path id. * @param factor scale factor. */ - VSimpleSplinePath(VDomDocument *doc, VContainer *data, qint64 id, qreal *factor); + VSimpleSplinePath(VPattern *doc, VContainer *data, qint64 id, qreal *factor); protected: /** * @brief mouseReleaseEvent handle mouse release events. diff --git a/src/xml/vdomdocument.cpp b/src/xml/vdomdocument.cpp index 2af908437..97155f9a5 100644 --- a/src/xml/vdomdocument.cpp +++ b/src/xml/vdomdocument.cpp @@ -27,35 +27,15 @@ *************************************************************************/ #include "vdomdocument.h" -#include "../exception/vexceptionwrongparameterid.h" #include "../exception/vexceptionconversionerror.h" #include "../exception/vexceptionemptyparameter.h" -#include "../exception/vexceptionuniqueid.h" -#include "../exception/vexceptionobjecterror.h" #include "../exception/vexceptionbadid.h" -#include "../tools/vtooldetail.h" -#include "../tools/vtooluniondetails.h" -#include "../tools/drawTools/drawtools.h" -#include "../tools/nodeDetails/nodedetails.h" -#include +VDomDocument::VDomDocument(VContainer *data) + : QDomDocument(), data(data), map(QHash()) +{ -VDomDocument::VDomDocument(VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode, QObject *parent) - : QObject(parent), QDomDocument(), map(QHash()), nameActivDraw(QString()), data(data), - tools(QHash()), history(QVector()), cursor(0), - comboBoxDraws(comboBoxDraws), mode(mode), patternModified(false){} - -VDomDocument::VDomDocument(const QString& name, VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode, - QObject *parent) - :QObject(parent), QDomDocument(name), map(QHash()), nameActivDraw(QString()), data(data), - tools(QHash()), history(QVector()), cursor(0), - comboBoxDraws(comboBoxDraws), mode(mode), patternModified(false){} - -VDomDocument::VDomDocument(const QDomDocumentType& doctype, VContainer *data, QComboBox *comboBoxDraws, - Draw::Draws *mode, QObject *parent) - :QObject(parent), QDomDocument(doctype), map(QHash()), nameActivDraw(QString()), data(data), - tools(QHash()), history(QVector()), cursor(0), - comboBoxDraws(comboBoxDraws), mode(mode), patternModified(false){} +} QDomElement VDomDocument::elementById(const QString& id) { @@ -69,8 +49,7 @@ QDomElement VDomDocument::elementById(const QString& id) map.remove(id); } - bool res = this->find(this->documentElement(), id); - if (res) + if (this->find(this->documentElement(), id)) { return map[id]; } @@ -99,7 +78,7 @@ bool VDomDocument::find(const QDomElement &node, const QString& id) { if (node.hasAttribute("id")) { - QString value = node.attribute("id"); + const QString value = node.attribute("id"); this->map[value] = node; if (value == id) { @@ -112,55 +91,7 @@ bool VDomDocument::find(const QDomElement &node, const QString& id) QDomNode n = node.childNodes().at(i); if (n.isElement()) { - bool res = this->find(n.toElement(), id); - if (res) - { - return true; - } - } - } - - return false; -} - -void VDomDocument::CreateEmptyFile() -{ - QDomElement patternElement = this->createElement("pattern"); - this->appendChild(patternElement); - - QDomComment info = this->createComment("Valentina pattern format."); - patternElement.appendChild(info); - QDomNode xmlNode = this->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""); - this->insertBefore(xmlNode, this->firstChild()); - - QDomElement authorElement = this->createElement("author"); - patternElement.appendChild(authorElement); - - QDomElement descElement = this->createElement("description"); - patternElement.appendChild(descElement); - - QDomElement notesElement = this->createElement("notes"); - patternElement.appendChild(notesElement); - - QDomElement incrElement = this->createElement("increments"); - patternElement.appendChild(incrElement); -} - -bool VDomDocument::CheckNameDraw(const QString& name) const -{ - Q_ASSERT_X(name.isEmpty() == false, "CheckNameDraw", "name draw is empty"); - QDomNodeList elements = this->documentElement().elementsByTagName( "draw" ); - if (elements.size() == 0) - { - return false; - } - for ( qint32 i = 0; i < elements.count(); i++ ) - { - QDomElement elem = elements.at( i ).toElement(); - if (elem.isNull() == false) - { - QString fieldName = elem.attribute( "name" ); - if ( fieldName == name ) + if (this->find(n.toElement(), id)) { return true; } @@ -169,301 +100,14 @@ bool VDomDocument::CheckNameDraw(const QString& name) const return false; } -bool VDomDocument::appendDraw(const QString& name) -{ - Q_ASSERT_X(name.isEmpty() == false, "appendDraw", "name draw is empty"); - if (name.isEmpty()) - { - return false; - } - if (CheckNameDraw(name)== false) - { - QDomElement rootElement = this->documentElement(); - - QDomElement drawElement = this->createElement("draw"); - QDomAttr drawAttr = this->createAttribute("name"); - drawAttr.setValue(name); - drawElement.setAttributeNode(drawAttr); - - QDomElement calculationElement = this->createElement("calculation"); - QDomElement modelingElement = this->createElement("modeling"); - QDomElement pathsElement = this->createElement("details"); - drawElement.appendChild(calculationElement); - drawElement.appendChild(modelingElement); - drawElement.appendChild(pathsElement); - - rootElement.appendChild(drawElement); - - if (nameActivDraw.isEmpty()) - { - SetActivDraw(name); - } - else - { - ChangeActivDraw(name); - } - return true; - } - else - { - return false; - } - return false; -} - -void VDomDocument::ChangeActivDraw(const QString& name, const Document::Documents &parse) -{ - Q_ASSERT_X(name.isEmpty() == false, "ChangeActivDraw", "name draw is empty"); - if (CheckNameDraw(name) == true) - { - this->nameActivDraw = name; - if (parse == Document::FullParse) - { - emit ChangedActivDraw(name); - } - } -} - -bool VDomDocument::SetNameDraw(const QString& name) -{ - Q_ASSERT_X(name.isEmpty() == false, "SetNameDraw", "name draw is empty"); - QString oldName = nameActivDraw; - QDomElement element; - if (GetActivDrawElement(element)) - { - nameActivDraw = name; - element.setAttribute("name", nameActivDraw); - emit patternChanged(); - emit ChangedNameDraw(oldName, nameActivDraw); - return true; - } - else - { - qWarning()<<"Can't find activ draw"<nameActivDraw = name; -} - -bool VDomDocument::GetActivDrawElement(QDomElement &element) -{ - if (nameActivDraw.isEmpty() == false) - { - QDomNodeList elements = this->documentElement().elementsByTagName( "draw" ); - if (elements.size() == 0) - { - return false; - } - for ( qint32 i = 0; i < elements.count(); i++ ) - { - element = elements.at( i ).toElement(); - if (element.isNull() == false) - { - QString fieldName = element.attribute( "name" ); - if ( fieldName == nameActivDraw ) - { - return true; - } - } - } - } - return false; -} - -bool VDomDocument::GetActivCalculationElement(QDomElement &element) -{ - bool ok = GetActivNodeElement("calculation", element); - if (ok) - { - return true; - } - else - { - return false; - } -} - -bool VDomDocument::GetActivModelingElement(QDomElement &element) -{ - bool ok = GetActivNodeElement("modeling", element); - if (ok) - { - return true; - } - else - { - return false; - } -} - -bool VDomDocument::GetActivDetailsElement(QDomElement &element) -{ - bool ok = GetActivNodeElement("details", element); - if (ok) - { - return true; - } - else - { - return false; - } -} - -bool VDomDocument::GetActivNodeElement(const QString& name, QDomElement &element) -{ - Q_ASSERT_X(name.isEmpty() == false, "GetActivNodeElement", "name draw is empty"); - QDomElement drawElement; - bool drawOk = this->GetActivDrawElement(drawElement); - if (drawOk == true) - { - QDomNodeList listElement = drawElement.elementsByTagName(name); - if (listElement.size() == 0 || listElement.size() > 1) - { - return false; - } - element = listElement.at( 0 ).toElement(); - if (element.isNull() == false) - { - return true; - } - else - { - return false; - } - } - else - { - return false; - } -} - -void VDomDocument::Parse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw, - VMainGraphicsScene *sceneDetail) -{ - Q_CHECK_PTR(sceneDraw); - Q_CHECK_PTR(sceneDetail); - if (parse == Document::FullParse) - { - TestUniqueId(); - data->Clear(); - data->CreateManTableIGroup(); - nameActivDraw.clear(); - sceneDraw->clear(); - sceneDetail->clear(); - comboBoxDraws->clear(); - tools.clear(); - cursor = 0; - } - data->ClearLengthLines(); - data->ClearLengthArcs(); - data->ClearLengthSplines(); - data->ClearLineAngles(); - data->ClearDetails(); - history.clear(); - QDomElement rootElement = this->documentElement(); - QDomNode domNode = rootElement.firstChild(); - while (domNode.isNull() == false) - { - if (domNode.isElement()) - { - QDomElement domElement = domNode.toElement(); - if (domElement.isNull() == false) - { - if (domElement.tagName()=="draw") - { - if (parse == Document::FullParse) - { - if (nameActivDraw.isEmpty()) - { - SetActivDraw(domElement.attribute("name")); - } - else - { - ChangeActivDraw(domElement.attribute("name")); - } - comboBoxDraws->addItem(domElement.attribute("name")); - } - else - { - ChangeActivDraw(domElement.attribute("name"), Document::LiteParse); - } - ParseDrawElement(sceneDraw, sceneDetail, domElement, parse); - } - if (domElement.tagName()=="increments") - { - ParseIncrementsElement(domElement); - } - } - } - domNode = domNode.nextSibling(); - } -} - -VDataTool *VDomDocument::getTool(const qint64 &id) -{ - if (tools.contains(id)) - { - return tools.value(id); - } - else - { - QString error = QString(tr("Can't find tool id = %1 in table.")).arg(id); - throw VException(error); - } - return 0; -} - -void VDomDocument::ParseIncrementsElement(const QDomNode &node) -{ - QDomNode domNode = node.firstChild(); - while (domNode.isNull() == false) - { - if (domNode.isElement()) - { - QDomElement domElement = domNode.toElement(); - if (domElement.isNull() == false) - { - if (domElement.tagName() == "increment") - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, "name", ""); - qreal base = GetParametrDouble(domElement, "base", "0"); - qreal ksize = GetParametrDouble(domElement, "ksize", "0"); - qreal kgrowth = GetParametrDouble(domElement, "kgrowth", "0"); - QString desc = GetParametrString(domElement, "description", "Description"); - data->UpdateId(id); - data->AddIncrementTableRow(name, VIncrementTableRow(id, base, ksize, kgrowth, desc)); - } - } - } - domNode = domNode.nextSibling(); - } -} - -qint64 VDomDocument::GetParametrId(const QDomElement &domElement) const -{ - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - qint64 id = GetParametrLongLong(domElement, "id", "0"); - if (id <= 0) - { - throw VExceptionWrongParameterId(tr("Got wrong parameter id. Need only id > 0."), domElement); - } - return id; -} - qint64 VDomDocument::GetParametrLongLong(const QDomElement &domElement, const QString &name, const QString &defValue) const { Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty"); Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); bool ok = false; - QString parametr = GetParametrString(domElement, name, defValue); - qint64 id = parametr.toLongLong(&ok); + const QString parametr = GetParametrString(domElement, name, defValue); + const qint64 id = parametr.toLongLong(&ok); if (ok == false) { throw VExceptionConversionError(tr("Can't convert toLongLong parameter"), name); @@ -476,7 +120,7 @@ QString VDomDocument::GetParametrString(const QDomElement &domElement, const QSt { Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty"); Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - QString parameter = domElement.attribute(name, defValue); + const QString parameter = domElement.attribute(name, defValue); if (parameter.isEmpty()) { throw VExceptionEmptyParameter(tr("Got empty parameter"), name, domElement); @@ -490,903 +134,27 @@ qreal VDomDocument::GetParametrDouble(const QDomElement &domElement, const QStri Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); bool ok = false; QString parametr = GetParametrString(domElement, name, defValue); - qreal param = parametr.replace(",", ".").toDouble(&ok); + const qreal param = parametr.replace(",", ".").toDouble(&ok); if (ok == false) { - qDebug()<<"defValue"< vector; - CollectId(this->documentElement(), vector); -} - -void VDomDocument::CollectId(const QDomElement &node, QVector &vector) const -{ - if (node.hasAttribute("id")) - { - qint64 id = GetParametrId(node); - if (vector.contains(id)) - { - throw VExceptionUniqueId(tr("This id is not unique."), node); - } - vector.append(id); - } - - for (qint32 i=0; iClearCalculationGObjects(); - ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Draw::Calculation); - } - if (domElement.tagName() == "modeling") - { - ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Draw::Modeling); - } - if (domElement.tagName() == "details") - { - ParseDetails(sceneDetail, domElement, parse); - } - } - } - domNode = domNode.nextSibling(); - } -} - -void VDomDocument::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, - const QDomNode& node, const Document::Documents &parse, const Draw::Draws &mode) -{ - Q_CHECK_PTR(sceneDraw); - Q_CHECK_PTR(sceneDetail); - VMainGraphicsScene *scene = 0; - if (mode == Draw::Calculation) - { - scene = sceneDraw; - } - else - { - scene = sceneDetail; - } - QDomNodeList nodeList = node.childNodes(); - qint32 num = nodeList.size(); - for (qint32 i = 0; i < num; ++i) - { - QDomElement domElement = nodeList.at(i).toElement(); - if (domElement.isNull() == false) - { - if (domElement.tagName() == "point") - { - ParsePointElement(scene, domElement, parse, domElement.attribute("type", "")); - continue; - } - if (domElement.tagName() == "line") - { - ParseLineElement(scene, domElement, parse); - continue; - } - if (domElement.tagName() == "spline") - { - ParseSplineElement(scene, domElement, parse, domElement.attribute("type", "")); - continue; - } - if (domElement.tagName() == "arc") - { - ParseArcElement(scene, domElement, parse, domElement.attribute("type", "")); - continue; - } - if (domElement.tagName() == "tools") - { - ParseToolsElement(scene, domElement, parse, domElement.attribute("type", "")); - continue; - } - } - } -} - -void VDomDocument::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement, - const Document::Documents &parse) -{ - Q_CHECK_PTR(sceneDetail); - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - try - { - VDetail detail; - VDetail oldDetail; - qint64 id = GetParametrId(domElement); - detail.setName(GetParametrString(domElement, VAbstractTool::AttrName, "")); - detail.setMx(toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0"))); - detail.setMy(toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "0.0"))); - detail.setSeamAllowance(GetParametrLongLong(domElement, VToolDetail::AttrSupplement, "1")); - detail.setWidth(GetParametrDouble(domElement, VToolDetail::AttrWidth, "10.0")); - detail.setClosed(GetParametrLongLong(domElement, VToolDetail::AttrClosed, "1")); - - QDomNodeList nodeList = domElement.childNodes(); - qint32 num = nodeList.size(); - for (qint32 i = 0; i < num; ++i) - { - QDomElement element = nodeList.at(i).toElement(); - if (element.isNull() == false) - { - if (element.tagName() == VToolDetail::TagNode) - { - qint64 id = GetParametrLongLong(element, VToolDetail::AttrIdObject, "0"); - qreal mx = toPixel(GetParametrDouble(element, VAbstractTool::AttrMx, "0.0")); - qreal my = toPixel(GetParametrDouble(element, VAbstractTool::AttrMy, "0.0")); - Tool::Tools tool; - NodeDetail::NodeDetails nodeType = NodeDetail::Contour; - QString t = GetParametrString(element, "type", "NodePoint"); - if (t == "NodePoint") - { - tool = Tool::NodePoint; -// const VPointF *point = data->GeometricObject(id); -// oldDetail.append(VNodeDetail(point.getIdObject(), tool, NodeDetail::Contour)); - } - else if (t == "NodeArc") - { - tool = Tool::NodeArc; -// VArc arc = data->GetArc(id); -// oldDetail.append(VNodeDetail(arc.getIdObject(), tool, NodeDetail::Contour)); - } - else if (t == "NodeSpline") - { - tool = Tool::NodeSpline; -// VSpline spl = data->GetSpline(id); -// oldDetail.append(VNodeDetail(spl.getIdObject(), tool, NodeDetail::Contour)); - } - else if (t == "NodeSplinePath") - { - tool = Tool::NodeSplinePath; -// VSplinePath splPath = data->GetSplinePath(id); -// oldDetail.append(VNodeDetail(splPath.getIdObject(), tool, NodeDetail::Contour)); - } - detail.append(VNodeDetail(id, tool, nodeType, mx, my)); - } - } - } - VToolDetail::Create(id, detail, sceneDetail, this, data, parse, Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating detail"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } -} - -void VDomDocument::ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement, - const Document::Documents &parse) -{ - Q_CHECK_PTR(sceneDetail); - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - QDomNode domNode = domElement.firstChild(); - while (domNode.isNull() == false) - { - if (domNode.isElement()) - { - QDomElement domElement = domNode.toElement(); - if (domElement.isNull() == false) - { - if (domElement.tagName() == VToolDetail::TagName) - { - ParseDetailElement(sceneDetail, domElement, parse); - } - } - } - domNode = domNode.nextSibling(); - } -} - -void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement, - const Document::Documents &parse, const QString& type) -{ - Q_CHECK_PTR(scene); - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of point is empty"); - - - QStringList points; - points << VToolSinglePoint::ToolType << VToolEndLine::ToolType << VToolAlongLine::ToolType - << VToolShoulderPoint::ToolType << VToolNormal::ToolType << VToolBisector::ToolType - << VToolLineIntersect::ToolType << VToolPointOfContact::ToolType << VNodePoint::ToolType - << VToolHeight::ToolType << VToolTriangle::ToolType << VToolPointOfIntersection::ToolType - << VToolCutSpline::ToolType << VToolCutSplinePath::ToolType << VToolCutArc::ToolType; - switch(points.indexOf(type)) { - case 0: //VToolSinglePoint::ToolType - { - VToolSinglePoint *spoint = 0; - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, VAbstractTool::AttrName, "A"); - qreal x = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrX, "10.0")); - qreal y = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrY, "10.0")); - qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - - data->UpdateGObject(id, new VPointF(x, y, name, mx, my)); - VDrawTool::AddRecord(id, Tool::SinglePointTool, this); - if (parse != Document::FullParse) - { - UpdateToolData(id, data); - } - if (parse == Document::FullParse) - { - spoint = new VToolSinglePoint(this, data, id, Tool::FromFile); - Q_CHECK_PTR(spoint); - scene->addItem(spoint); - connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor); - tools[id] = spoint; - } - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating single point"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - scene->removeItem(spoint); - delete spoint; - throw excep; - } - break; - } - case 1: //VToolEndLine::ToolType - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); - QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); - qint64 basePointId = GetParametrLongLong(domElement, VAbstractTool::AttrBasePoint, "0"); - qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0"); - - VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId, - mx, my, scene, this, data, parse, Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating point of end line"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - case 2: //VToolAlongLine::ToolType - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); - QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); - qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0"); - qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0"); - - VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my, scene, this, data, - parse, Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating point along line"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - case 3: //VToolShoulderPoint::ToolType - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); - QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); - qint64 p1Line = GetParametrLongLong(domElement, VAbstractTool::AttrP1Line, "0"); - qint64 p2Line = GetParametrLongLong(domElement, VAbstractTool::AttrP2Line, "0"); - qint64 pShoulder = GetParametrLongLong(domElement, VAbstractTool::AttrPShoulder, "0"); - - VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my, scene, this, - data, parse, Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating point of shoulder"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - case 4: //VToolNormal::ToolType - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); - QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); - qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0"); - qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0"); - qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0"); - - VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, - angle, mx, my, scene, this,data, parse, Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating point of normal"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - case 5: //VToolBisector::ToolType - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); - QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); - qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0"); - qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0"); - qint64 thirdPointId = GetParametrLongLong(domElement, VAbstractTool::AttrThirdPoint, "0"); - - VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, - typeLine, name, mx, my, scene, this, data, parse, Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating point of bisector"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - case 6: //VToolLineIntersect::ToolType - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - qint64 p1Line1Id = GetParametrLongLong(domElement, VAbstractTool::AttrP1Line1, "0"); - qint64 p2Line1Id = GetParametrLongLong(domElement, VAbstractTool::AttrP2Line1, "0"); - qint64 p1Line2Id = GetParametrLongLong(domElement, VAbstractTool::AttrP1Line2, "0"); - qint64 p2Line2Id = GetParametrLongLong(domElement, VAbstractTool::AttrP2Line2, "0"); - - VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, - mx, my, scene, this, data, parse, Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating point of lineintersection"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - case 7: //VToolPointOfContact::ToolType - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "0"); - qint64 center = GetParametrLongLong(domElement, VAbstractTool::AttrCenter, "0"); - qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0"); - qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0"); - - VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, - mx, my, scene, this,data, parse, Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating point of contact"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - case 8: //VNodePoint::ToolType - try - { - qint64 id = GetParametrId(domElement); - qint64 idObject = GetParametrLongLong(domElement, VAbstractNode::AttrIdObject, "0"); - qint64 idTool = GetParametrLongLong(domElement, VAbstractNode::AttrIdTool, "0"); - const VPointF *point = data->GeometricObject(idObject ); - qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - data->UpdateGObject(id, new VPointF(point->x(), point->y(), point->name(), - mx, my, idObject,Draw::Modeling)); - VNodePoint::Create(this, data, id, idObject, parse, Tool::FromFile, idTool); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating modeling point"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - case 9: //VToolHeight::ToolType - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); - qint64 basePointId = GetParametrLongLong(domElement, VAbstractTool::AttrBasePoint, "0"); - qint64 p1LineId = GetParametrLongLong(domElement, VAbstractTool::AttrP1Line, "0"); - qint64 p2LineId = GetParametrLongLong(domElement, VAbstractTool::AttrP2Line, "0"); - - VToolHeight::Create(id, name, typeLine, basePointId, p1LineId, p2LineId, - mx, my, scene, this, data, parse, Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating height"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - case 10: //VToolTriangle::ToolType - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - qint64 axisP1Id = GetParametrLongLong(domElement, VAbstractTool::AttrAxisP1, "0"); - qint64 axisP2Id = GetParametrLongLong(domElement, VAbstractTool::AttrAxisP2, "0"); - qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0"); - qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0"); - - VToolTriangle::Create(id, name, axisP1Id, axisP2Id, firstPointId, secondPointId, mx, my, scene, this, data, - parse, Tool::FromFile); - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating triangle"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - case 11: //VToolPointOfIntersection::ToolType - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0"); - qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0"); - - VToolPointOfIntersection::Create(id, name, firstPointId, secondPointId, - mx, my, scene, this, data, parse,Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating point of intersection"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - case 12: //VToolCutSpline::ToolType - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); - qint64 splineId = GetParametrLongLong(domElement, VToolCutSpline::AttrSpline, "0"); - - VToolCutSpline::Create(id, name, formula, splineId, mx, my, scene, this, data, parse, Tool::FromFile); - return; - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating cut spline point"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - case 13: //VToolCutSplinePath::ToolType - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); - qint64 splinePathId = GetParametrLongLong(domElement, VToolCutSplinePath::AttrSplinePath, "0"); - - VToolCutSplinePath::Create(id, name, formula, splinePathId, mx, my, - scene, this, data, parse, Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating cut spline path point"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - case 14: //VToolCutArc::ToolType - try - { - qint64 id = GetParametrId(domElement); - QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); - qint64 arcId = GetParametrLongLong(domElement, VToolCutArc::AttrArc, "0"); - - VToolCutArc::Create(id, name, formula, arcId, mx, my, scene, this, data, parse, Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating cut arc point"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - default: - qWarning() << "Illegal point type in VDomDocument::ParsePointElement()."; - break; - } -} - -void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement, - const Document::Documents &parse) -{ - Q_CHECK_PTR(scene); - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - try - { - qint64 id = GetParametrId(domElement); - qint64 firstPoint = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0"); - qint64 secondPoint = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0"); - QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); - - VToolLine::Create(id, firstPoint, secondPoint, typeLine, scene, this, data, parse, Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating line"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } -} - -void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &domElement, - const Document::Documents &parse, const QString &type) -{ - Q_CHECK_PTR(scene); - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); - - QStringList splines; - splines << VToolSpline::ToolType << VToolSplinePath::ToolType << VNodeSpline::ToolType << VNodeSplinePath::ToolType; - switch(splines.indexOf(type)) { - case 0: //VToolSpline::ToolType - try - { - qint64 id = GetParametrId(domElement); - qint64 point1 = GetParametrLongLong(domElement, VAbstractTool::AttrPoint1, "0"); - qint64 point4 = GetParametrLongLong(domElement, VAbstractTool::AttrPoint4, "0"); - qreal angle1 = GetParametrDouble(domElement, VAbstractTool::AttrAngle1, "270.0"); - qreal angle2 = GetParametrDouble(domElement, VAbstractTool::AttrAngle2, "90.0"); - qreal kAsm1 = GetParametrDouble(domElement, VAbstractTool::AttrKAsm1, "1.0"); - qreal kAsm2 = GetParametrDouble(domElement, VAbstractTool::AttrKAsm2, "1.0"); - qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0"); - - VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this, data, parse,Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating simple curve"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - case 1: //VToolSplinePath::ToolType - try - { - qint64 id = GetParametrId(domElement); - qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0"); - VSplinePath *path = new VSplinePath(kCurve); - Q_CHECK_PTR(path); - - QDomNodeList nodeList = domElement.childNodes(); - qint32 num = nodeList.size(); - for (qint32 i = 0; i < num; ++i) - { - QDomElement element = nodeList.at(i).toElement(); - if (element.isNull() == false) - { - if (element.tagName() == VAbstractTool::AttrPathPoint) - { - qreal kAsm1 = GetParametrDouble(element, VAbstractTool::AttrKAsm1, "1.0"); - qreal angle = GetParametrDouble(element, VAbstractTool::AttrAngle, "0"); - qreal kAsm2 = GetParametrDouble(element, VAbstractTool::AttrKAsm2, "1.0"); - qint64 pSpline = GetParametrLongLong(element, VAbstractTool::AttrPSpline, "0"); - VPointF p = *data->GeometricObject(pSpline); - - QLineF line(0, 0, 100, 0); - line.setAngle(angle+180); - - VSplinePoint splPoint(p, kAsm1, line.angle(), kAsm2, angle); - path->append(splPoint); - if (parse == Document::FullParse) - { - IncrementReferens(pSpline); - } - } - } - } - - VToolSplinePath::Create(id, path, scene, this, data, parse, Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating curve path"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - case 2: //VNodeSpline::ToolType - try - { - qint64 id = GetParametrId(domElement); - qint64 idObject = GetParametrLongLong(domElement, VAbstractNode::AttrIdObject, "0"); - qint64 idTool = GetParametrLongLong(domElement, VAbstractNode::AttrIdTool, "0"); - VSpline *spl = new VSpline(*data->GeometricObject(idObject)); - Q_CHECK_PTR(spl); - spl->setIdObject(idObject); - spl->setMode(Draw::Modeling); - data->UpdateGObject(id, spl); - VNodeSpline::Create(this, data, id, idObject, parse, Tool::FromFile, idTool); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating modeling simple curve"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - case 3: //VNodeSplinePath::ToolType - try - { - qint64 id = GetParametrId(domElement); - qint64 idObject = GetParametrLongLong(domElement, VAbstractNode::AttrIdObject, "0"); - qint64 idTool = GetParametrLongLong(domElement, VAbstractNode::AttrIdTool, "0"); - VSplinePath *path = new VSplinePath(*data->GeometricObject(idObject)); - Q_CHECK_PTR(path); - path->setIdObject(idObject); - path->setMode(Draw::Modeling); - data->UpdateGObject(id, path); - VNodeSplinePath::Create(this, data, id, idObject, parse, Tool::FromFile, idTool); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating modeling curve path"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - default: - qWarning() << "Illegal spline type in VDomDocument::ParseSplineElement()."; - break; - } -} - -void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &domElement, - const Document::Documents &parse, const QString &type) -{ - Q_CHECK_PTR(scene); - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); - - QStringList arcs; - arcs << VToolArc::ToolType << VNodeArc::ToolType; - - switch(arcs.indexOf(type)) { - case 0: //VToolArc::ToolType - try - { - qint64 id = GetParametrId(domElement); - qint64 center = GetParametrLongLong(domElement, VAbstractTool::AttrCenter, "0"); - QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "10"); - QString f1 = GetParametrString(domElement, VAbstractTool::AttrAngle1, "180"); - QString f2 = GetParametrString(domElement, VAbstractTool::AttrAngle2, "270"); - - VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - case 1: //VNodeArc::ToolType - try - { - qint64 id = GetParametrId(domElement); - qint64 idObject = GetParametrLongLong(domElement, VAbstractNode::AttrIdObject, "0"); - qint64 idTool = GetParametrLongLong(domElement, VAbstractNode::AttrIdTool, "0"); - VArc *arc = new VArc(*data->GeometricObject(idObject)); - Q_CHECK_PTR(arc); - arc->setIdObject(idObject); - arc->setMode(Draw::Modeling); - data->UpdateGObject(id, arc); - VNodeArc::Create(this, data, id, idObject, parse, Tool::FromFile, idTool); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating modeling arc"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - default: - qWarning() << "Illegal arc type in VDomDocument::ParseArcElement()."; - break; - } -} - -void VDomDocument::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &domElement, - const Document::Documents &parse, const QString &type) -{ - Q_CHECK_PTR(scene); - Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); - Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); - - QStringList tools; - tools << VToolUnionDetails::ToolType; - - switch(tools.indexOf(type)) { - case 0: //VToolUnionDetails::ToolType - try - { - qint64 id = GetParametrId(domElement); - qint64 indexD1 = GetParametrLongLong(domElement, VToolUnionDetails::AttrIndexD1, "-1"); - qint64 indexD2 = GetParametrLongLong(domElement, VToolUnionDetails::AttrIndexD2, "-1"); - - QVector vector = VToolUnionDetails::GetDetailFromFile(this, domElement); - - VToolUnionDetails::Create(id, vector[0], vector[1], 0, 0, indexD1, indexD2, scene, this, data, parse, - Tool::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating union details"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } - break; - default: - qWarning() << "Illegal tools type in VDomDocument::ParseToolsElement()."; - break; - } -} - -void VDomDocument::FullUpdateTree() -{ - VMainGraphicsScene *scene = new VMainGraphicsScene(); - Q_CHECK_PTR(scene); - try - { - Parse(Document::LiteParse, scene, scene); - } - catch (const std::bad_alloc &) - { - delete scene; - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error parsing file.")); - msgBox.setInformativeText("std::bad_alloc"); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); - return; - } - catch (...) - { - delete scene; - throw; - } - - delete scene; - setCurrentData(); - emit FullUpdateFromFile(); -} - -void VDomDocument::haveLiteChange() -{ - patternModified = true; - emit patternChanged(); -} - -void VDomDocument::ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable) -{ - emit ShowTool(id, color, enable); -} -bool VDomDocument::isPatternModified() const -{ - return patternModified; -} - -void VDomDocument::setPatternModified(bool value) -{ - patternModified = value; -} - -QString VDomDocument::UniqueTagText(const QString &tagName, const QString &defVal) -{ - QDomNodeList nodeList = this->elementsByTagName(tagName); + const QDomNodeList nodeList = this->elementsByTagName(tagName); if (nodeList.isEmpty()) { return defVal; } else { - QDomNode domNode = nodeList.at(0); + const QDomNode domNode = nodeList.at(0); if (domNode.isNull() == false && domNode.isElement()) { - QDomElement domElement = domNode.toElement(); + const QDomElement domElement = domNode.toElement(); if (domElement.isNull() == false) { return domElement.text(); @@ -1395,83 +163,3 @@ QString VDomDocument::UniqueTagText(const QString &tagName, const QString &defVa } return defVal; } - - -void VDomDocument::setCursor(const qint64 &value) -{ - cursor = value; - emit ChangedCursor(cursor); -} - -void VDomDocument::setCurrentData() -{ - if (*mode == Draw::Calculation) - { - QString nameDraw = comboBoxDraws->itemText(comboBoxDraws->currentIndex()); - if (nameActivDraw != nameDraw) - { - nameActivDraw = nameDraw; - qint64 id = 0; - if (history.size() == 0) - { - return; - } - for (qint32 i = 0; i < history.size(); ++i) - { - VToolRecord tool = history.at(i); - if (tool.getNameDraw() == nameDraw) - { - id = tool.getId(); - } - } - if (id == 0) - { - VToolRecord tool = history.at(history.size()-1); - id = tool.getId(); - if (id == 0) - { - return; - } - } - if (tools.size() > 0) - { - VDataTool *vTool = tools.value(id); - data->setData(vTool->getData()); - } - } - } -} - -void VDomDocument::AddTool(const qint64 &id, VDataTool *tool) -{ - Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); - Q_CHECK_PTR(tool); - tools.insert(id, tool); -} - -void VDomDocument::UpdateToolData(const qint64 &id, VContainer *data) -{ - Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); - Q_CHECK_PTR(data); - VDataTool *tool = tools.value(id); - Q_CHECK_PTR(tool); - tool->VDataTool::setData(data); -} - -void VDomDocument::IncrementReferens(qint64 id) const -{ - Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); - VDataTool *tool = tools.value(id); - Q_CHECK_PTR(tool); - tool->incrementReferens(); -} - -void VDomDocument::DecrementReferens(qint64 id) const -{ - Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); - VDataTool *tool = tools.value(id); - if (tool != 0) - { - tool->decrementReferens(); - } -} diff --git a/src/xml/vdomdocument.h b/src/xml/vdomdocument.h index e808e614e..de30543de 100644 --- a/src/xml/vdomdocument.h +++ b/src/xml/vdomdocument.h @@ -30,62 +30,29 @@ #define VDOMDOCUMENT_H #include "../container/vcontainer.h" -#include "../widgets/vmaingraphicsscene.h" -#include "../tools/vdatatool.h" -#include "vtoolrecord.h" -#include #include #include -namespace Document -{ - /** - * @brief The Document enum types parse. - */ - enum Document { LiteParse, FullParse}; - Q_DECLARE_FLAGS(Documents, Document) -} -Q_DECLARE_OPERATORS_FOR_FLAGS(Document::Documents) - #ifdef Q_CC_GNU #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #endif /** - * @brief The VDomDocument class working with pattern file. + * @brief The VDomDocument class extend QDomDocument class. */ -class VDomDocument : public QObject, public QDomDocument +class VDomDocument : public QDomDocument { - Q_OBJECT + Q_DECLARE_TR_FUNCTIONS(VDomDocument) public: - /** - * @brief VDomDocument constructor. - * @param data container with variables. - * @param comboBoxDraws combobox for pattern peaces names. - * @param mode draw mode. - */ - VDomDocument(VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode, QObject *parent = 0); - /** - * @brief VDomDocument constructor. - * @param name pattern peace name. - * @param data container with variables. - * @param comboBoxDraws combobox for pattern peaces names. - * @param mode draw mode. - */ - VDomDocument(const QString& name, VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode, - QObject *parent = 0); - /** - * @brief VDomDocument constructor. - * @param doc dom document container type. - * @param data container with variables. - * @param comboBoxDraws combobox for pattern peaces names. - * @param mode draw mode. - */ - VDomDocument(const QDomDocumentType& doctype, VContainer *data, QComboBox *comboBoxDraws, - Draw::Draws *mode, QObject *parent = 0); - ~VDomDocument(){} + /** + * @brief VDomDocument constructor. + * @param data container with variables. + * @param parent parent object + */ + VDomDocument(VContainer *data); + virtual ~VDomDocument(){} /** * @brief elementById find element by id. * @param id value id attribute. @@ -97,121 +64,19 @@ public: * @param element tag. */ void removeAllChilds(QDomElement &element); + template /** - * @brief CreateEmptyFile create minimal empty file. + * @brief SetAttribute set attribute in pattern file. Replace "," by ".". + * @param domElement element in xml tree. + * @param name name of attribute. + * @param value value of attribute. */ - void CreateEmptyFile(); - /** - * @brief ChangeActivDraw set new pattern peace name. - * @param name new name. - * @param parse parser file mode. - */ - void ChangeActivDraw(const QString& name, const Document::Documents &parse = Document::FullParse); - /** - * @brief GetNameActivDraw return current pattern peace name. - * @return pattern peace name. - */ - inline QString GetNameActivDraw() const {return nameActivDraw;} - /** - * @brief GetActivDrawElement return draw tag for current pattern peace. - * @param element draw tag. - * @return true if found. - */ - bool GetActivDrawElement(QDomElement &element); - /** - * @brief GetActivCalculationElement return calculation tag for current pattern peace. - * @param element calculation tag. - * @return true if found. - */ - bool GetActivCalculationElement(QDomElement &element); - /** - * @brief GetActivModelingElement return modeling tag for current pattern peace. - * @param element modeling tag - * @return true if found. - */ - bool GetActivModelingElement(QDomElement &element); - /** - * @brief GetActivDetailsElement return details tag for current pattern peace. - * @param element details tag. - * @return true if found. - */ - bool GetActivDetailsElement(QDomElement &element); - /** - * @brief appendDraw add new pattern peace structure to the file. - * @param name pattern peace name. - * @return true if success. - */ - bool appendDraw(const QString& name); - /** - * @brief SetNameDraw change current pattern peace. - * @param name pattern peace name. - * @return true if success. - */ - bool SetNameDraw(const QString& name); - /** - * @brief Parse parse file. - * @param parse parser file mode. - * @param sceneDraw pointer to draw scene. - * @param sceneDetail pointer to details scene. - */ - void Parse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw, - VMainGraphicsScene *sceneDetail); - /** - * @brief getTools return list of tools pointers. - * @return list. - */ - inline QHash* getTools() {return &tools;} - /** - * @brief getTool return tool from tool list. - * @param id tool id. - * @return tool. - */ - VDataTool* getTool(const qint64 &id); - /** - * @brief getHistory return list with list of history records. - * @return list of history records. - */ - inline QVector *getHistory() {return &history;} - /** - * @brief getCursor return cursor. - * @return cursor. - */ - inline qint64 getCursor() const {return cursor;} - /** - * @brief setCursor set cursor. - * @param value cursor. - */ - void setCursor(const qint64 &value); - /** - * @brief setCurrentData set current data set. - */ - void setCurrentData(); - /** - * @brief AddTool add tool to list tools. - * @param id tool id. - * @param tool tool. - */ - void AddTool(const qint64 &id, VDataTool *tool); - /** - * @brief UpdateToolData update tool in list tools. - * @param id tool id. - * @param data container with variables. - */ - void UpdateToolData(const qint64 &id, VContainer *data); - /** - * @brief IncrementReferens increment reference parent objects. - * @param id parent object id. - */ - void IncrementReferens(qint64 id) const; - /** - * @brief DecrementReferens decrement reference parent objects. - * @param id parent object id. - */ - void DecrementReferens(qint64 id) const; - /** - * @brief TestUniqueId test exist unique id in pattern file. Each id must be unique. - */ - void TestUniqueId() const; + void SetAttribute(QDomElement &domElement, const QString &name, const T &value) + { + QString val = QString().setNum(value); + val = val.replace(",", "."); + domElement.setAttribute(name, val); + } /** * @brief GetParametrLongLong return long long value of attribute. * @param domElement tag in xml tree. @@ -226,7 +91,8 @@ public: * @param name attribute name. * @return attribute value. */ - QString GetParametrString(const QDomElement& domElement, const QString &name, const QString &defValue) const; + QString GetParametrString(const QDomElement& domElement, const QString &name, + const QString &defValue = QString()) const; /** * @brief GetParametrDouble return double value of attribute. * @param domElement tag in xml tree. @@ -234,100 +100,19 @@ public: * @return double value. */ qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue) const; + QString UniqueTagText(const QString &tagName, const QString &defVal = QString()) const; +protected: /** - * @brief SPointActiveDraw return id base point current pattern peace. - * @return id base point. + * @brief data container with data. */ - qint64 SPointActiveDraw(); - bool isPatternModified() const; - void setPatternModified(bool value); - QString UniqueTagText(const QString &tagName, const QString &defVal = QString()); -signals: - /** - * @brief ChangedActivDraw change active pattern peace. - * @param newName new pattern peace name. - */ - void ChangedActivDraw(const QString &newName); - /** - * @brief ChangedNameDraw save new name active 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(); - /** - * @brief ShowTool highlight tool. - * @param id tool id. - * @param color highlight color. - * @param enable enable or disable highlight. - */ - void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); - /** - * @brief ChangedCursor change cursor position. - * @param id tool id. - */ - void ChangedCursor(qint64 id); -public slots: - /** - * @brief FullUpdateTree lite parse file. - */ - void FullUpdateTree(); - /** - * @brief haveLiteChange we have unsaved change. - */ - void haveLiteChange(); - /** - * @brief ShowHistoryTool hightlight tool. - * @param id tool id. - * @param color hightlight color. - * @param enable enable or diasable hightlight. - */ - void ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable); + VContainer *data; private: Q_DISABLE_COPY(VDomDocument) /** * @brief map use for finding element by id. */ QHash map; - /** - * @brief nameActivDraw name current pattern peace. - */ - QString nameActivDraw; - /** - * @brief data container with data. - */ - VContainer *data; - /** - * @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. - */ - qint64 cursor; - /** - * @brief comboBoxDraws combobox with pattern peace names. - */ - QComboBox *comboBoxDraws; - /** - * @brief mode current draw mode. - */ - Draw::Draws *mode; - /** - * @brief fileModified true if exist change in file. - */ - bool patternModified; + /** * @brief find find element by id. * @param node node. @@ -335,126 +120,14 @@ private: * @return true if found. */ bool find(const QDomElement &node, const QString& id); - /** - * @brief CheckNameDraw check if exist pattern peace with this name. - * @param name pattern peace name. - * @return true if exist. - */ - bool CheckNameDraw(const QString& name) const; - /** - * @brief SetActivDraw set current pattern peace. - * @param name pattern peace name. - */ - void SetActivDraw(const QString& name); - /** - * @brief GetActivNodeElement find element in current pattern peace by name. - * @param name name tag. - * @param element element. - * @return true if found. - */ - bool GetActivNodeElement(const QString& name, QDomElement& element); - /** - * @brief ParseDrawElement parse draw tag. - * @param sceneDraw draw scene. - * @param sceneDetail details scene. - * @param node node. - * @param parse parser file mode. - */ - void ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, - const QDomNode& node, const Document::Documents &parse); - /** - * @brief ParseDrawMode parse draw tag with draw mode. - * @param sceneDraw draw scene. - * @param sceneDetail details scene. - * @param node node. - * @param parse parser file mode. - * @param mode draw mode. - */ - void ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, - const QDomNode& node, const Document::Documents &parse, const Draw::Draws &mode); - /** - * @brief ParseDetailElement parse detail tag. - * @param sceneDetail detail scene. - * @param domElement tag in xml tree. - * @param parse parser file mode. - */ - void ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement, - const Document::Documents &parse); - /** - * @brief ParseDetails parse details tag. - * @param sceneDetail detail scene. - * @param domElement tag in xml tree. - * @param parse parser file mode. - */ - void ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement, - const Document::Documents &parse); - /** - * @brief ParsePointElement parse point tag. - * @param scene scene. - * @param domElement tag in xml tree. - * @param parse parser file mode. - * @param type type of point. - * @param mode draw mode. - */ - void ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement, - const Document::Documents &parse, const QString &type); - /** - * @brief ParseLineElement parse line tag. - * @param scene scene. - * @param domElement tag in xml tree. - * @param parse parser file mode. - * @param mode draw mode. - */ - void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement, - const Document::Documents &parse); - /** - * @brief ParseSplineElement parse spline tag. - * @param scene scene. - * @param domElement tag in xml tree. - * @param parse parser file mode. - * @param type type of spline. - * @param mode draw mode. - */ - void ParseSplineElement(VMainGraphicsScene *scene, const QDomElement& domElement, - const Document::Documents &parse, const QString& type); - /** - * @brief ParseArcElement parse arc tag. - * @param scene scene. - * @param domElement tag in xml tree. - * @param parse parser file mode. - * @param type type of spline. - * @param mode draw mode. - */ - void ParseArcElement(VMainGraphicsScene *scene, const QDomElement& domElement, - const Document::Documents &parse, const QString& type); - /** - * @brief ParseToolsElement parse tools tag. - * @param scene scene. - * @param domElement tag in xml tree. - * @param parse parser file mode. - * @param type type of spline. - */ - void ParseToolsElement(VMainGraphicsScene *scene, const QDomElement& domElement, - const Document::Documents &parse, const QString& type); - /** - * @brief ParseIncrementsElement parse increments tag. - * @param node tag in xml tree. - */ - void ParseIncrementsElement(const QDomNode& node); - /** - * @brief GetParametrId return value id attribute. - * @param domElement tag in xml tree. - * @return id value. - */ - qint64 GetParametrId(const QDomElement& domElement) const; - /** - * @brief CollectId recursive function, try find id attribute in file. Throw exclusion if find not unique. - * @param node tag in xml tree. - * @param vector list with ids. - */ - void CollectId(const QDomElement &node, QVector &vector)const; }; +template <> +inline void VDomDocument::SetAttribute(QDomElement &domElement, const QString &name, const QString &value) +{ + domElement.setAttribute(name, value); +} + #ifdef Q_CC_GNU #pragma GCC diagnostic pop #endif diff --git a/src/xml/vpattern.cpp b/src/xml/vpattern.cpp new file mode 100644 index 000000000..9b152c98b --- /dev/null +++ b/src/xml/vpattern.cpp @@ -0,0 +1,1265 @@ +/************************************************************************ + ** + ** @file vpattern.cpp + ** @author Roman Telezhinsky + ** @date 24 2, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2013 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 "vpattern.h" + +#include "../tools/vtooldetail.h" +#include "../tools/vtooluniondetails.h" +#include "../tools/drawTools/drawtools.h" +#include "../tools/nodeDetails/nodedetails.h" +#include "../exception/vexceptionobjecterror.h" +#include "../exception/vexceptionwrongparameterid.h" +#include "../exception/vexceptionuniqueid.h" + +#include + +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::TagIncrements = QStringLiteral("increments"); +const QString VPattern::TagDraw = QStringLiteral("draw"); +const QString VPattern::AttrName = QStringLiteral("name"); + +VPattern::VPattern(VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode, QObject *parent) + : QObject(parent), VDomDocument(data), nameActivDraw(QString()), tools(QHash()), + history(QVector()), cursor(0), comboBoxDraws(comboBoxDraws), mode(mode), patternModified(false) +{ +} + +void VPattern::CreateEmptyFile() +{ + QDomElement patternElement = this->createElement("pattern"); + + patternElement.appendChild(createComment("Valentina pattern format.")); + patternElement.appendChild(createElement(TagAuthor)); + patternElement.appendChild(createElement(TagDescription)); + patternElement.appendChild(createElement(TagNotes)); + patternElement.appendChild(createElement(TagIncrements)); + + this->appendChild(patternElement); + insertBefore(createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""), this->firstChild()); +} + +void VPattern::ChangeActivDraw(const QString &name, const Document::Documents &parse) +{ + Q_ASSERT_X(name.isEmpty() == false, "ChangeActivDraw", "name draw is empty"); + if (CheckNameDraw(name)) + { + this->nameActivDraw = name; + if (parse == Document::FullParse) + { + emit ChangedActivDraw(name); + } + } +} + +bool VPattern::GetActivDrawElement(QDomElement &element) +{ + if (nameActivDraw.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 == nameActivDraw ) + { + return true; + } + } + } + } + return false; +} + +bool VPattern::appendDraw(const QString &name) +{ + Q_ASSERT_X(name.isEmpty() == false, "appendDraw", "name draw is empty"); + if (name.isEmpty()) + { + return false; + } + if (CheckNameDraw(name) == false) + { + QDomElement rootElement = this->documentElement(); + + QDomElement drawElement = this->createElement(TagDraw); + SetAttribute(drawElement, AttrName, name); + + drawElement.appendChild(createElement(TagCalculation)); + drawElement.appendChild(createElement(TagModeling)); + drawElement.appendChild(createElement(TagDetails)); + + rootElement.appendChild(drawElement); + + if (nameActivDraw.isEmpty()) + { + SetActivDraw(name); + } + else + { + ChangeActivDraw(name); + } + return true; + } + return false; +} + +bool VPattern::SetNameDraw(const QString &name) +{ + Q_ASSERT_X(name.isEmpty() == false, "SetNameDraw", "name draw is empty"); + const QString oldName = nameActivDraw; + QDomElement element; + if (GetActivDrawElement(element)) + { + nameActivDraw = name; + element.setAttribute(AttrName, nameActivDraw); + emit patternChanged(); + emit ChangedNameDraw(oldName, nameActivDraw); + return true; + } + else + { + qWarning()<<"Can't find activ draw"<addItem(GetParametrString(domElement, AttrName)); + } + else + { + ChangeActivDraw(GetParametrString(domElement, AttrName), Document::LiteParse); + } + ParseDrawElement(sceneDraw, sceneDetail, domElement, parse); + } + if (domElement.tagName()=="increments") + { + ParseIncrementsElement(domElement); + } + } + } + domNode = domNode.nextSibling(); + } +} + +VDataTool *VPattern::getTool(const qint64 &id) +{ + if (tools.contains(id)) + { + return tools.value(id); + } + else + { + const QString error = QString(tr("Can't find tool id = %1 in table.")).arg(id); + throw VException(error); + } + return 0; +} + +void VPattern::setCursor(const qint64 &value) +{ + cursor = value; + emit ChangedCursor(cursor); +} + +void VPattern::setCurrentData() +{ + if (*mode == Draw::Calculation) + { + const QString nameDraw = comboBoxDraws->itemText(comboBoxDraws->currentIndex()); + if (nameActivDraw != nameDraw) + { + nameActivDraw = nameDraw; + qint64 id = 0; + if (history.size() == 0) + { + return; + } + for (qint32 i = 0; i < history.size(); ++i) + { + const VToolRecord tool = history.at(i); + if (tool.getNameDraw() == nameDraw) + { + id = tool.getId(); + } + } + if (id == 0) + { + const VToolRecord tool = history.at(history.size()-1); + id = tool.getId(); + if (id == 0) + { + return; + } + } + if (tools.size() > 0) + { + const VDataTool *vTool = tools.value(id); + data->setData(vTool->getData()); + } + } + } +} + +void VPattern::AddTool(const qint64 &id, VDataTool *tool) +{ + Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); + Q_CHECK_PTR(tool); + tools.insert(id, tool); +} + +void VPattern::UpdateToolData(const qint64 &id, VContainer *data) +{ + Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); + Q_CHECK_PTR(data); + VDataTool *tool = tools.value(id); + Q_CHECK_PTR(tool); + tool->VDataTool::setData(data); +} + +void VPattern::IncrementReferens(qint64 id) const +{ + Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); + VDataTool *tool = tools.value(id); + Q_CHECK_PTR(tool); + tool->incrementReferens(); +} + +void VPattern::DecrementReferens(qint64 id) const +{ + Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); + VDataTool *tool = tools.value(id); + Q_CHECK_PTR(tool); + tool->decrementReferens(); +} + +void VPattern::TestUniqueId() const +{ + QVector vector; + CollectId(documentElement(), vector); +} + +qint64 VPattern::SPointActiveDraw() +{ + QDomElement calcElement; + if (GetActivNodeElement(TagCalculation, calcElement)) + { + const QDomNode domNode = calcElement.firstChild(); + if (domNode.isNull() == false && domNode.isElement()) + { + const QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + if (domElement.tagName() == VToolPoint::TagName && + domElement.attribute("type", "") == VToolSinglePoint::ToolType) + { + return GetParametrId(domElement); + } + } + } + } + return 0; +} + +bool VPattern::CheckNameDraw(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; +} + +void VPattern::SetActivDraw(const QString &name) +{ + Q_ASSERT_X(name.isEmpty() == false, "SetActivDraw", "name draw is empty"); + this->nameActivDraw = name; +} + +bool VPattern::GetActivNodeElement(const QString &name, QDomElement &element) +{ + 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; +} + +void VPattern::FullUpdateTree() +{ + VMainGraphicsScene *scene = new VMainGraphicsScene(); + Q_CHECK_PTR(scene); + try + { + Parse(Document::LiteParse, scene, scene); + } + catch (const std::bad_alloc &) + { + delete scene; + QMessageBox msgBox; + msgBox.setWindowTitle(tr("Error!")); + msgBox.setText(tr("Error parsing file.")); + msgBox.setInformativeText("std::bad_alloc"); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.setIcon(QMessageBox::Warning); + msgBox.exec(); + return; + } + catch (...) + { + delete scene; + throw; + } + + delete scene; + setCurrentData(); + emit FullUpdateFromFile(); +} + +void VPattern::haveLiteChange() +{ + patternModified = true; + emit patternChanged(); +} + +void VPattern::ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable) +{ + emit ShowTool(id, color, enable); +} + +void VPattern::ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, const QDomNode &node, + const Document::Documents &parse) +{ + QDomNode domNode = node.firstChild(); + while (domNode.isNull() == false) + { + if (domNode.isElement()) + { + const QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + if (domElement.tagName() == "calculation") + { + data->ClearCalculationGObjects(); + ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Draw::Calculation); + } + if (domElement.tagName() == "modeling") + { + ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Draw::Modeling); + } + if (domElement.tagName() == "details") + { + ParseDetails(sceneDetail, domElement, parse); + } + } + } + domNode = domNode.nextSibling(); + } +} + +void VPattern::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, const QDomNode &node, + const Document::Documents &parse, const Draw::Draws &mode) +{ + Q_CHECK_PTR(sceneDraw); + Q_CHECK_PTR(sceneDetail); + VMainGraphicsScene *scene = 0; + if (mode == Draw::Calculation) + { + scene = sceneDraw; + } + else + { + scene = sceneDetail; + } + const QDomNodeList nodeList = node.childNodes(); + const qint32 num = nodeList.size(); + for (qint32 i = 0; i < num; ++i) + { + const QDomElement domElement = nodeList.at(i).toElement(); + if (domElement.isNull() == false) + { + if (domElement.tagName() == "point") + { + ParsePointElement(scene, domElement, parse, domElement.attribute("type", "")); + continue; + } + if (domElement.tagName() == "line") + { + ParseLineElement(scene, domElement, parse); + continue; + } + if (domElement.tagName() == "spline") + { + ParseSplineElement(scene, domElement, parse, domElement.attribute("type", "")); + continue; + } + if (domElement.tagName() == "arc") + { + ParseArcElement(scene, domElement, parse, domElement.attribute("type", "")); + continue; + } + if (domElement.tagName() == "tools") + { + ParseToolsElement(scene, domElement, parse, domElement.attribute("type", "")); + continue; + } + } + } +} + +void VPattern::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement, + const Document::Documents &parse) +{ + Q_CHECK_PTR(sceneDetail); + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + try + { + VDetail detail; + const qint64 id = GetParametrId(domElement); + detail.setName(GetParametrString(domElement, VAbstractTool::AttrName, "")); + detail.setMx(toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0"))); + detail.setMy(toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "0.0"))); + detail.setSeamAllowance(GetParametrLongLong(domElement, VToolDetail::AttrSupplement, "1")); + detail.setWidth(GetParametrDouble(domElement, VToolDetail::AttrWidth, "10.0")); + detail.setClosed(GetParametrLongLong(domElement, VToolDetail::AttrClosed, "1")); + + const QDomNodeList nodeList = domElement.childNodes(); + const qint32 num = nodeList.size(); + for (qint32 i = 0; i < num; ++i) + { + const QDomElement element = nodeList.at(i).toElement(); + if (element.isNull() == false) + { + if (element.tagName() == VToolDetail::TagNode) + { + const qint64 id = GetParametrLongLong(element, VToolDetail::AttrIdObject, "0"); + const qreal mx = toPixel(GetParametrDouble(element, VAbstractTool::AttrMx, "0.0")); + const qreal my = toPixel(GetParametrDouble(element, VAbstractTool::AttrMy, "0.0")); + const NodeDetail::NodeDetails nodeType = NodeDetail::Contour; + const QString t = GetParametrString(element, "type", "NodePoint"); + Tool::Tools tool; + if (t == "NodePoint") + { + tool = Tool::NodePoint; + } + else if (t == "NodeArc") + { + tool = Tool::NodeArc; + } + else if (t == "NodeSpline") + { + tool = Tool::NodeSpline; + } + else if (t == "NodeSplinePath") + { + tool = Tool::NodeSplinePath; + } + detail.append(VNodeDetail(id, tool, nodeType, mx, my)); + } + } + } + VToolDetail::Create(id, detail, sceneDetail, this, data, parse, Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating detail"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } +} + +void VPattern::ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement, + const Document::Documents &parse) +{ + Q_CHECK_PTR(sceneDetail); + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + QDomNode domNode = domElement.firstChild(); + while (domNode.isNull() == false) + { + if (domNode.isElement()) + { + const QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + if (domElement.tagName() == VToolDetail::TagName) + { + ParseDetailElement(sceneDetail, domElement, parse); + } + } + } + domNode = domNode.nextSibling(); + } +} + +void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &domElement, + const Document::Documents &parse, const QString &type) +{ + Q_CHECK_PTR(scene); + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of point is empty"); + + + QStringList points; + points << VToolSinglePoint::ToolType << VToolEndLine::ToolType << VToolAlongLine::ToolType + << VToolShoulderPoint::ToolType << VToolNormal::ToolType << VToolBisector::ToolType + << VToolLineIntersect::ToolType << VToolPointOfContact::ToolType << VNodePoint::ToolType + << VToolHeight::ToolType << VToolTriangle::ToolType << VToolPointOfIntersection::ToolType + << VToolCutSpline::ToolType << VToolCutSplinePath::ToolType << VToolCutArc::ToolType; + switch(points.indexOf(type)) { + case 0: //VToolSinglePoint::ToolType + { + VToolSinglePoint *spoint = 0; + try + { + const qint64 id = GetParametrId(domElement); + const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "A"); + const qreal x = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrX, "10.0")); + const qreal y = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrY, "10.0")); + const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); + const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + + data->UpdateGObject(id, new VPointF(x, y, name, mx, my)); + VDrawTool::AddRecord(id, Tool::SinglePointTool, this); + if (parse != Document::FullParse) + { + UpdateToolData(id, data); + } + if (parse == Document::FullParse) + { + spoint = new VToolSinglePoint(this, data, id, Tool::FromFile); + Q_CHECK_PTR(spoint); + scene->addItem(spoint); + connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor); + tools[id] = spoint; + } + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating single point"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + scene->removeItem(spoint); + delete spoint; + throw excep; + } + break; + } + case 1: //VToolEndLine::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); + const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); + const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, + VAbstractTool::TypeLineLine); + const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); + const qint64 basePointId = GetParametrLongLong(domElement, VAbstractTool::AttrBasePoint, "0"); + const qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0"); + + VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId, + mx, my, scene, this, data, parse, Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of end line"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 2: //VToolAlongLine::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); + const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); + const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, + VAbstractTool::TypeLineLine); + const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); + const qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0"); + const qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0"); + + VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my, scene, this, + data, parse, Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point along line"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 3: //VToolShoulderPoint::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); + const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); + const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, + VAbstractTool::TypeLineLine); + const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); + const qint64 p1Line = GetParametrLongLong(domElement, VAbstractTool::AttrP1Line, "0"); + const qint64 p2Line = GetParametrLongLong(domElement, VAbstractTool::AttrP2Line, "0"); + const qint64 pShoulder = GetParametrLongLong(domElement, VAbstractTool::AttrPShoulder, "0"); + + VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my, scene, this, + data, parse, Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of shoulder"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 4: //VToolNormal::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); + const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); + const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, + VAbstractTool::TypeLineLine); + const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); + const qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0"); + const qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0"); + const qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0"); + + VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, + angle, mx, my, scene, this,data, parse, Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of normal"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 5: //VToolBisector::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); + const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); + const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, + VAbstractTool::TypeLineLine); + const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); + const qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0"); + const qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0"); + const qint64 thirdPointId = GetParametrLongLong(domElement, VAbstractTool::AttrThirdPoint, "0"); + + VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, + typeLine, name, mx, my, scene, this, data, parse, Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of bisector"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 6: //VToolLineIntersect::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); + const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); + const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + const qint64 p1Line1Id = GetParametrLongLong(domElement, VAbstractTool::AttrP1Line1, "0"); + const qint64 p2Line1Id = GetParametrLongLong(domElement, VAbstractTool::AttrP2Line1, "0"); + const qint64 p1Line2Id = GetParametrLongLong(domElement, VAbstractTool::AttrP1Line2, "0"); + const qint64 p2Line2Id = GetParametrLongLong(domElement, VAbstractTool::AttrP2Line2, "0"); + + VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, + mx, my, scene, this, data, parse, Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of lineintersection"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 7: //VToolPointOfContact::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); + const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); + const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "0"); + const qint64 center = GetParametrLongLong(domElement, VAbstractTool::AttrCenter, "0"); + const qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0"); + const qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0"); + + VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, + mx, my, scene, this,data, parse, Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of contact"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 8: //VNodePoint::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const qint64 idObject = GetParametrLongLong(domElement, VAbstractNode::AttrIdObject, "0"); + const qint64 idTool = GetParametrLongLong(domElement, VAbstractNode::AttrIdTool, "0"); + const VPointF *point = data->GeometricObject(idObject ); + const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); + const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + data->UpdateGObject(id, new VPointF(point->x(), point->y(), point->name(), + mx, my, idObject,Draw::Modeling)); + VNodePoint::Create(this, data, id, idObject, parse, Tool::FromFile, idTool); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating modeling point"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 9: //VToolHeight::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); + const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); + const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, + VAbstractTool::TypeLineLine); + const qint64 basePointId = GetParametrLongLong(domElement, VAbstractTool::AttrBasePoint, "0"); + const qint64 p1LineId = GetParametrLongLong(domElement, VAbstractTool::AttrP1Line, "0"); + const qint64 p2LineId = GetParametrLongLong(domElement, VAbstractTool::AttrP2Line, "0"); + + VToolHeight::Create(id, name, typeLine, basePointId, p1LineId, p2LineId, + mx, my, scene, this, data, parse, Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating height"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 10: //VToolTriangle::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); + const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); + const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + const qint64 axisP1Id = GetParametrLongLong(domElement, VAbstractTool::AttrAxisP1, "0"); + const qint64 axisP2Id = GetParametrLongLong(domElement, VAbstractTool::AttrAxisP2, "0"); + const qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0"); + const qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0"); + + VToolTriangle::Create(id, name, axisP1Id, axisP2Id, firstPointId, secondPointId, mx, my, scene, this, + data, parse, Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating triangle"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 11: //VToolPointOfIntersection::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); + const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); + const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + const qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0"); + const qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0"); + + VToolPointOfIntersection::Create(id, name, firstPointId, secondPointId, + mx, my, scene, this, data, parse,Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of intersection"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 12: //VToolCutSpline::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); + const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); + const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); + const qint64 splineId = GetParametrLongLong(domElement, VToolCutSpline::AttrSpline, "0"); + + VToolCutSpline::Create(id, name, formula, splineId, mx, my, scene, this, data, parse, Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating cut spline point"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 13: //VToolCutSplinePath::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); + const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); + const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); + const qint64 splinePathId = GetParametrLongLong(domElement, VToolCutSplinePath::AttrSplinePath, "0"); + + VToolCutSplinePath::Create(id, name, formula, splinePathId, mx, my, + scene, this, data, parse, Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating cut spline path point"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 14: //VToolCutArc::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); + const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); + const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); + const qint64 arcId = GetParametrLongLong(domElement, VToolCutArc::AttrArc, "0"); + + VToolCutArc::Create(id, name, formula, arcId, mx, my, scene, this, data, parse, Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating cut arc point"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + default: + qWarning() << "Illegal point type in VDomDocument::ParsePointElement()."; + break; + } +} + +void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement, const Document::Documents &parse) +{ + Q_CHECK_PTR(scene); + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + try + { + const qint64 id = GetParametrId(domElement); + const qint64 firstPoint = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0"); + const qint64 secondPoint = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0"); + const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); + + VToolLine::Create(id, firstPoint, secondPoint, typeLine, scene, this, data, parse, Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating line"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } +} + +void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &domElement, + const Document::Documents &parse, const QString &type) +{ + Q_CHECK_PTR(scene); + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); + + QStringList splines; + splines << VToolSpline::ToolType << VToolSplinePath::ToolType << VNodeSpline::ToolType << VNodeSplinePath::ToolType; + switch(splines.indexOf(type)) { + case 0: //VToolSpline::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const qint64 point1 = GetParametrLongLong(domElement, VAbstractTool::AttrPoint1, "0"); + const qint64 point4 = GetParametrLongLong(domElement, VAbstractTool::AttrPoint4, "0"); + const qreal angle1 = GetParametrDouble(domElement, VAbstractTool::AttrAngle1, "270.0"); + const qreal angle2 = GetParametrDouble(domElement, VAbstractTool::AttrAngle2, "90.0"); + const qreal kAsm1 = GetParametrDouble(domElement, VAbstractTool::AttrKAsm1, "1.0"); + const qreal kAsm2 = GetParametrDouble(domElement, VAbstractTool::AttrKAsm2, "1.0"); + const qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0"); + + VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this, data, parse, + Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating simple curve"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 1: //VToolSplinePath::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0"); + VSplinePath *path = new VSplinePath(kCurve); + Q_CHECK_PTR(path); + + const QDomNodeList nodeList = domElement.childNodes(); + const qint32 num = nodeList.size(); + for (qint32 i = 0; i < num; ++i) + { + const QDomElement element = nodeList.at(i).toElement(); + if (element.isNull() == false) + { + if (element.tagName() == VAbstractTool::AttrPathPoint) + { + const qreal kAsm1 = GetParametrDouble(element, VAbstractTool::AttrKAsm1, "1.0"); + const qreal angle = GetParametrDouble(element, VAbstractTool::AttrAngle, "0"); + const qreal kAsm2 = GetParametrDouble(element, VAbstractTool::AttrKAsm2, "1.0"); + const qint64 pSpline = GetParametrLongLong(element, VAbstractTool::AttrPSpline, "0"); + const VPointF p = *data->GeometricObject(pSpline); + + QLineF line(0, 0, 100, 0); + line.setAngle(angle+180); + + VSplinePoint splPoint(p, kAsm1, line.angle(), kAsm2, angle); + path->append(splPoint); + if (parse == Document::FullParse) + { + IncrementReferens(pSpline); + } + } + } + } + + VToolSplinePath::Create(id, path, scene, this, data, parse, Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating curve path"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 2: //VNodeSpline::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const qint64 idObject = GetParametrLongLong(domElement, VAbstractNode::AttrIdObject, "0"); + const qint64 idTool = GetParametrLongLong(domElement, VAbstractNode::AttrIdTool, "0"); + VSpline *spl = new VSpline(*data->GeometricObject(idObject)); + Q_CHECK_PTR(spl); + spl->setIdObject(idObject); + spl->setMode(Draw::Modeling); + data->UpdateGObject(id, spl); + VNodeSpline::Create(this, data, id, idObject, parse, Tool::FromFile, idTool); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating modeling simple curve"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 3: //VNodeSplinePath::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const qint64 idObject = GetParametrLongLong(domElement, VAbstractNode::AttrIdObject, "0"); + const qint64 idTool = GetParametrLongLong(domElement, VAbstractNode::AttrIdTool, "0"); + VSplinePath *path = new VSplinePath(*data->GeometricObject(idObject)); + Q_CHECK_PTR(path); + path->setIdObject(idObject); + path->setMode(Draw::Modeling); + data->UpdateGObject(id, path); + VNodeSplinePath::Create(this, data, id, idObject, parse, Tool::FromFile, idTool); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating modeling curve path"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + default: + qWarning() << "Illegal spline type in VDomDocument::ParseSplineElement()."; + break; + } +} + +void VPattern::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &domElement, + const Document::Documents &parse, const QString &type) +{ + Q_CHECK_PTR(scene); + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); + + QStringList arcs; + arcs << VToolArc::ToolType << VNodeArc::ToolType; + + switch(arcs.indexOf(type)) { + case 0: //VToolArc::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const qint64 center = GetParametrLongLong(domElement, VAbstractTool::AttrCenter, "0"); + const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "10"); + const QString f1 = GetParametrString(domElement, VAbstractTool::AttrAngle1, "180"); + const QString f2 = GetParametrString(domElement, VAbstractTool::AttrAngle2, "270"); + + VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + case 1: //VNodeArc::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const qint64 idObject = GetParametrLongLong(domElement, VAbstractNode::AttrIdObject, "0"); + const qint64 idTool = GetParametrLongLong(domElement, VAbstractNode::AttrIdTool, "0"); + VArc *arc = new VArc(*data->GeometricObject(idObject)); + Q_CHECK_PTR(arc); + arc->setIdObject(idObject); + arc->setMode(Draw::Modeling); + data->UpdateGObject(id, arc); + VNodeArc::Create(this, data, id, idObject, parse, Tool::FromFile, idTool); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating modeling arc"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + default: + qWarning() << "Illegal arc type in VDomDocument::ParseArcElement()."; + break; + } +} + +void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &domElement, + const Document::Documents &parse, const QString &type) +{ + Q_CHECK_PTR(scene); + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); + + QStringList tools; + tools << VToolUnionDetails::ToolType; + + switch(tools.indexOf(type)) { + case 0: //VToolUnionDetails::ToolType + try + { + const qint64 id = GetParametrId(domElement); + const qint64 indexD1 = GetParametrLongLong(domElement, VToolUnionDetails::AttrIndexD1, "-1"); + const qint64 indexD2 = GetParametrLongLong(domElement, VToolUnionDetails::AttrIndexD2, "-1"); + + const QVector vector = VToolUnionDetails::GetDetailFromFile(this, domElement); + + VToolUnionDetails::Create(id, vector[0], vector[1], 0, 0, indexD1, indexD2, scene, this, data, parse, + Tool::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating union details"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; + default: + qWarning() << "Illegal tools type in VDomDocument::ParseToolsElement()."; + break; + } +} + +void VPattern::ParseIncrementsElement(const QDomNode &node) +{ + QDomNode domNode = node.firstChild(); + while (domNode.isNull() == false) + { + if (domNode.isElement()) + { + const QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + if (domElement.tagName() == "increment") + { + qint64 id = GetParametrId(domElement); + QString name = GetParametrString(domElement, "name", ""); + qreal base = GetParametrDouble(domElement, "base", "0"); + qreal ksize = GetParametrDouble(domElement, "ksize", "0"); + qreal kgrowth = GetParametrDouble(domElement, "kgrowth", "0"); + QString desc = GetParametrString(domElement, "description", "Description"); + data->UpdateId(id); + data->AddIncrementTableRow(name, VIncrementTableRow(id, base, ksize, kgrowth, desc)); + } + } + } + domNode = domNode.nextSibling(); + } +} + +qint64 VPattern::GetParametrId(const QDomElement &domElement) const +{ + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + const qint64 id = GetParametrLongLong(domElement, "id", "0"); + if (id <= 0) + { + throw VExceptionWrongParameterId(tr("Got wrong parameter id. Need only id > 0."), domElement); + } + return id; +} + +void VPattern::CollectId(const QDomElement &node, QVector &vector) const +{ + if (node.hasAttribute("id")) + { + const qint64 id = GetParametrId(node); + if (vector.contains(id)) + { + throw VExceptionUniqueId(tr("This id is not unique."), node); + } + vector.append(id); + } + + for (qint32 i=0; iClear(); + data->CreateManTableIGroup(); + nameActivDraw.clear(); + sceneDraw->clear(); + sceneDetail->clear(); + comboBoxDraws->clear(); + tools.clear(); + cursor = 0; + } + data->ClearLengthLines(); + data->ClearLengthArcs(); + data->ClearLengthSplines(); + data->ClearLineAngles(); + data->ClearDetails(); + history.clear(); +} diff --git a/src/xml/vpattern.h b/src/xml/vpattern.h new file mode 100644 index 000000000..3ce440177 --- /dev/null +++ b/src/xml/vpattern.h @@ -0,0 +1,367 @@ +/************************************************************************ + ** + ** @file vpattern.h + ** @author Roman Telezhinsky + ** @date 24 2, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2013 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 VPATTERN_H +#define VPATTERN_H + +#include "vdomdocument.h" +#include "../widgets/vmaingraphicsscene.h" +#include "../tools/vdatatool.h" +#include "vtoolrecord.h" +#include + +namespace Document +{ + /** + * @brief The Document enum parse types. + */ + enum Document { LiteParse, FullParse}; + Q_DECLARE_FLAGS(Documents, Document) +} +Q_DECLARE_OPERATORS_FOR_FLAGS(Document::Documents) + +/** + * @brief The VPattern class working with pattern file. + */ +class VPattern : public QObject, public VDomDocument +{ + Q_OBJECT +public: + VPattern(VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode, QObject *parent = 0); + /** + * @brief CreateEmptyFile create minimal empty file. + */ + void CreateEmptyFile(); + /** + * @brief ChangeActivDraw set new pattern peace name. + * @param name new name. + * @param parse parser file mode. + */ + void ChangeActivDraw(const QString& name, const Document::Documents &parse = Document::FullParse); + /** + * @brief GetNameActivDraw return current pattern peace name. + * @return pattern peace name. + */ + inline QString GetNameActivDraw() const {return nameActivDraw;} + /** + * @brief GetActivDrawElement return draw tag for current pattern peace. + * @param element draw tag. + * @return true if found. + */ + bool GetActivDrawElement(QDomElement &element); + /** + * @brief appendDraw add new pattern peace structure to the file. + * @param name pattern peace name. + * @return true if success. + */ + bool appendDraw(const QString& name); + /** + * @brief SetNameDraw change current pattern peace. + * @param name pattern peace name. + * @return true if success. + */ + bool SetNameDraw(const QString& name); + /** + * @brief Parse parse file. + * @param parse parser file mode. + * @param sceneDraw pointer to draw scene. + * @param sceneDetail pointer to details scene. + */ + void Parse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw, + VMainGraphicsScene *sceneDetail); + /** + * @brief getTools return list of tools pointers. + * @return list. + */ + inline QHash* getTools() {return &tools;} + /** + * @brief getTool return tool from tool list. + * @param id tool id. + * @return tool. + */ + VDataTool* getTool(const qint64 &id); + /** + * @brief getHistory return list with list of history records. + * @return list of history records. + */ + inline QVector *getHistory() {return &history;} + /** + * @brief getCursor return cursor. + * @return cursor. + */ + inline qint64 getCursor() const {return cursor;} + /** + * @brief setCursor set cursor. + * @param value cursor. + */ + void setCursor(const qint64 &value); + /** + * @brief setCurrentData set current data set. + */ + void setCurrentData(); + /** + * @brief AddTool add tool to list tools. + * @param id tool id. + * @param tool tool. + */ + void AddTool(const qint64 &id, VDataTool *tool); + /** + * @brief UpdateToolData update tool in list tools. + * @param id tool id. + * @param data container with variables. + */ + void UpdateToolData(const qint64 &id, VContainer *data); + /** + * @brief IncrementReferens increment reference parent objects. + * @param id parent object id. + */ + void IncrementReferens(qint64 id) const; + /** + * @brief DecrementReferens decrement reference parent objects. + * @param id parent object id. + */ + void DecrementReferens(qint64 id) const; + /** + * @brief TestUniqueId test exist unique id in pattern file. Each id must be unique. + */ + void TestUniqueId() const; + /** + * @brief SPointActiveDraw return id base point current pattern peace. + * @return id base point. + */ + qint64 SPointActiveDraw(); + inline bool isPatternModified() const {return patternModified;} + inline void setPatternModified(bool value) {patternModified = value;} + /** + * @brief GetActivNodeElement find element in current pattern piece by name. + * @param name name tag. + * @param element element. + * @return true if found. + */ + bool GetActivNodeElement(const QString& name, QDomElement& element); + 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 TagIncrements; + static const QString TagDraw; + static const QString AttrName; +signals: + /** + * @brief ChangedActivDraw change active pattern peace. + * @param newName new pattern peace name. + */ + void ChangedActivDraw(const QString &newName); + /** + * @brief ChangedNameDraw save new name active 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(); + /** + * @brief ShowTool highlight tool. + * @param id tool id. + * @param color highlight color. + * @param enable enable or disable highlight. + */ + void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); + /** + * @brief ChangedCursor change cursor position. + * @param id tool id. + */ + void ChangedCursor(qint64 id); +public slots: + /** + * @brief FullUpdateTree lite parse file. + */ + void FullUpdateTree(); + /** + * @brief haveLiteChange we have unsaved change. + */ + void haveLiteChange(); + /** + * @brief ShowHistoryTool hightlight tool. + * @param id tool id. + * @param color hightlight color. + * @param enable enable or diasable hightlight. + */ + void ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable); +private: + Q_DISABLE_COPY(VPattern) + /** + * @brief nameActivDraw name current pattern peace. + */ + QString nameActivDraw; + /** + * @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. + */ + qint64 cursor; + QComboBox *comboBoxDraws; + /** + * @brief mode current draw mode. + */ + Draw::Draws *mode; + /** + * @brief fileModified true if exist change in file. + */ + bool patternModified; + /** + * @brief CheckNameDraw check if exist pattern peace with this name. + * @param name pattern peace name. + * @return true if exist. + */ + bool CheckNameDraw(const QString& name) const; + /** + * @brief SetActivDraw set current pattern peace. + * @param name pattern peace name. + */ + void SetActivDraw(const QString& name); + + /** + * @brief ParseDrawElement parse draw tag. + * @param sceneDraw draw scene. + * @param sceneDetail details scene. + * @param node node. + * @param parse parser file mode. + */ + void ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, + const QDomNode& node, const Document::Documents &parse); + /** + * @brief ParseDrawMode parse draw tag with draw mode. + * @param sceneDraw draw scene. + * @param sceneDetail details scene. + * @param node node. + * @param parse parser file mode. + * @param mode draw mode. + */ + void ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, + const QDomNode& node, const Document::Documents &parse, const Draw::Draws &mode); + /** + * @brief ParseDetailElement parse detail tag. + * @param sceneDetail detail scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + */ + void ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement, + const Document::Documents &parse); + /** + * @brief ParseDetails parse details tag. + * @param sceneDetail detail scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + */ + void ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement, + const Document::Documents &parse); + /** + * @brief ParsePointElement parse point tag. + * @param scene scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + * @param type type of point. + * @param mode draw mode. + */ + void ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement, + const Document::Documents &parse, const QString &type); + /** + * @brief ParseLineElement parse line tag. + * @param scene scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + * @param mode draw mode. + */ + void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement, + const Document::Documents &parse); + /** + * @brief ParseSplineElement parse spline tag. + * @param scene scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + * @param type type of spline. + * @param mode draw mode. + */ + void ParseSplineElement(VMainGraphicsScene *scene, const QDomElement& domElement, + const Document::Documents &parse, const QString& type); + /** + * @brief ParseArcElement parse arc tag. + * @param scene scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + * @param type type of spline. + * @param mode draw mode. + */ + void ParseArcElement(VMainGraphicsScene *scene, const QDomElement& domElement, + const Document::Documents &parse, const QString& type); + /** + * @brief ParseToolsElement parse tools tag. + * @param scene scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + * @param type type of spline. + */ + void ParseToolsElement(VMainGraphicsScene *scene, const QDomElement& domElement, + const Document::Documents &parse, const QString& type); + /** + * @brief ParseIncrementsElement parse increments tag. + * @param node tag in xml tree. + */ + void ParseIncrementsElement(const QDomNode& node); + /** + * @brief GetParametrId return value id attribute. + * @param domElement tag in xml tree. + * @return id value. + */ + qint64 GetParametrId(const QDomElement& domElement) const; + /** + * @brief CollectId recursive function, try find id attribute in file. Throw exclusion if find not unique. + * @param node tag in xml tree. + * @param vector list with ids. + */ + void CollectId(const QDomElement &node, QVector &vector)const; + void PrepareForParse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw, + VMainGraphicsScene *sceneDetail); +}; + +#endif // VPATTERN_H diff --git a/src/xml/xml.pri b/src/xml/xml.pri index 0214e42b5..08b77844d 100644 --- a/src/xml/xml.pri +++ b/src/xml/xml.pri @@ -1,7 +1,9 @@ HEADERS += \ src/xml/vtoolrecord.h \ - src/xml/vdomdocument.h + src/xml/vdomdocument.h \ + src/xml/vpattern.h SOURCES += \ src/xml/vtoolrecord.cpp \ - src/xml/vdomdocument.cpp + src/xml/vdomdocument.cpp \ + src/xml/vpattern.cpp