diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index a7fbc7192..3be346f08 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -255,6 +255,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons QCursor cur(pixmap, 2, 3); ui->view->setCursor(cur); helpLabel->setText(toolTip); + ui->view->setShowToolOptions(false); dialogTool = new Dialog(pattern, 0, this); connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject); connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot); @@ -292,6 +293,7 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur QPixmap pixmap(cursor); QCursor cur(pixmap, 2, 3); ui->view->setCursor(cur); + ui->view->setShowToolOptions(false); helpLabel->setText(toolTip); dialogTool = new Dialog(pattern, 0, this); connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject); @@ -321,7 +323,8 @@ void MainWindow::ClosedDialog(int result) SCASSERT(dialogTool != nullptr); if (result == QDialog::Accepted) { - DrawTool::Create(dialogTool, currentScene, doc, pattern); + QGraphicsItem *tool = dynamic_cast(DrawTool::Create(dialogTool, currentScene, doc, pattern)); + ui->view->itemClicked(tool); } ArrowTool(); } @@ -349,9 +352,11 @@ void MainWindow::ClosedDialogWithApply(int result) vtool->FullUpdateFromGuiApply(); } } + QGraphicsItem *tool = dynamic_cast(dialogTool->GetAssociatedTool()); + ui->view->itemClicked(tool); if (dialogTool->GetAssociatedTool() != nullptr) { - VDrawTool * vtool= static_cast(dialogTool->GetAssociatedTool()); + VDrawTool *vtool= static_cast(dialogTool->GetAssociatedTool()); vtool->DialogLinkDestroy(); } ArrowTool(); @@ -1067,6 +1072,7 @@ void MainWindow::ArrowTool() QCursor cur(Qt::ArrowCursor); ui->view->setCursor(cur); helpLabel->setText(""); + ui->view->setShowToolOptions(true); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vabstractspline.cpp b/src/app/tools/drawTools/vabstractspline.cpp index 78bbdfd57..108194901 100644 --- a/src/app/tools/drawTools/vabstractspline.cpp +++ b/src/app/tools/drawTools/vabstractspline.cpp @@ -52,6 +52,12 @@ void VAbstractSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *o QGraphicsPathItem::paint(painter, &myOption, widget); } +//--------------------------------------------------------------------------------------------------------------------- +QString VAbstractSpline::getTagName() const +{ + return VAbstractSpline::TagName; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief FullUpdateFromFile update tool data form file. diff --git a/src/app/tools/drawTools/vabstractspline.h b/src/app/tools/drawTools/vabstractspline.h index 1b5f10b0a..810dd1c2a 100644 --- a/src/app/tools/drawTools/vabstractspline.h +++ b/src/app/tools/drawTools/vabstractspline.h @@ -42,6 +42,7 @@ public: virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::AbstractSpline)}; + virtual QString getTagName() const; public slots: virtual void FullUpdateFromFile (); void Disable(bool disable); diff --git a/src/app/tools/drawTools/vdrawtool.cpp b/src/app/tools/drawTools/vdrawtool.cpp index 106025ada..408b07b97 100644 --- a/src/app/tools/drawTools/vdrawtool.cpp +++ b/src/app/tools/drawTools/vdrawtool.cpp @@ -148,6 +148,36 @@ void VDrawTool::SaveDialogChange() } } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ +void VDrawTool::AddToFile() +{ + QDomElement domElement = doc->createElement(getTagName()); + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOptions(domElement, obj); + AddToCalculation(domElement); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ +void VDrawTool::RefreshDataInFile() +{ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOptions(domElement, obj); + } + else + { + qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO; + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief DialogLinkDestroy removes dialog pointer diff --git a/src/app/tools/drawTools/vdrawtool.h b/src/app/tools/drawTools/vdrawtool.h index eeb750398..9d11576e8 100644 --- a/src/app/tools/drawTools/vdrawtool.h +++ b/src/app/tools/drawTools/vdrawtool.h @@ -81,6 +81,8 @@ protected: /** @brief SaveDialog save options into file after change in dialog. */ virtual void SaveDialog(QDomElement &domElement)=0; void SaveDialogChange(); + virtual void AddToFile(); + virtual void RefreshDataInFile(); template /** diff --git a/src/app/tools/drawTools/vtoolalongline.cpp b/src/app/tools/drawTools/vtoolalongline.cpp index 9fe4bcd0a..0fe0eb783 100644 --- a/src/app/tools/drawTools/vtoolalongline.cpp +++ b/src/app/tools/drawTools/vtoolalongline.cpp @@ -31,7 +31,6 @@ #include "../../dialogs/tools/dialogalongline.h" #include "../../geometry/vpointf.h" #include "exception/vexceptionobjecterror.h" -#include "../undocommands/savetooloptions.h" const QString VToolAlongLine::ToolType = QStringLiteral("alongLine"); @@ -114,38 +113,6 @@ void VToolAlongLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) ContextMenu(this, event); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddToFile add tag with informations about tool into file. - */ -void VToolAlongLine::AddToFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->createElement(TagName); - - SaveOptions(domElement, *point.data()); - - AddToCalculation(domElement); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ -void VToolAlongLine::RefreshDataInFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - SaveOptions(domElement, *point.data()); - } - else - { - qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO; - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief RemoveReferens decrement value of reference. @@ -173,13 +140,16 @@ void VToolAlongLine::SaveDialog(QDomElement &domElement) } //--------------------------------------------------------------------------------------------------------------------- -void VToolAlongLine::SaveOptions(QDomElement &tag, const VPointF &point) +void VToolAlongLine::SaveOptions(QDomElement &tag, QSharedPointer &obj) { + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + doc->SetAttribute(tag, VDomDocument::AttrId, id); doc->SetAttribute(tag, AttrType, ToolType); - doc->SetAttribute(tag, AttrName, point.name()); - doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point.mx())); - doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point.my())); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrTypeLine, typeLine); doc->SetAttribute(tag, AttrLength, formulaLength); @@ -187,26 +157,6 @@ void VToolAlongLine::SaveOptions(QDomElement &tag, const VPointF &point) doc->SetAttribute(tag, AttrSecondPoint, secondPointId); } -//--------------------------------------------------------------------------------------------------------------------- -void VToolAlongLine::SaveOption(const VPointF &point) -{ - QDomElement oldDomElement = doc->elementById(QString().setNum(id)); - if (oldDomElement.isElement()) - { - QDomElement newDomElement = oldDomElement.cloneNode().toElement(); - - SaveOptions(newDomElement, point); - - SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, id); - connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VPattern::LiteParseTree); - qApp->getUndoStack()->push(saveOptions); - } - else - { - qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO; - } -} - //--------------------------------------------------------------------------------------------------------------------- quint32 VToolAlongLine::getSecondPointId() const { @@ -218,46 +168,8 @@ void VToolAlongLine::setSecondPointId(const quint32 &value) { secondPointId = value; - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - SaveOption(*point.data()); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolAlongLine::setName(const QString &name) -{ - VPointF newPoint = VPointF(*VAbstractTool::data.GeometricObject(id).data()); - newPoint.setName(name); - SaveOption(newPoint); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolAlongLine::setTypeLine(const QString &value) -{ - typeLine = value; - - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - SaveOption(*point.data()); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolAlongLine::setFormulaLength(const VFormula &value) -{ - if (value.error() == false) - { - formulaLength = value.getFormula(FormulaType::FromUser); - - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - SaveOption(*point.data()); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolAlongLine::setFirstPointId(const quint32 &value) -{ - basePointId = value; - - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - SaveOption(*point.data()); + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolalongline.h b/src/app/tools/drawTools/vtoolalongline.h index 9d4d49e1a..a469b0d34 100644 --- a/src/app/tools/drawTools/vtoolalongline.h +++ b/src/app/tools/drawTools/vtoolalongline.h @@ -51,27 +51,22 @@ public: static const QString ToolType; virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::AlongLine)}; - void setFirstPointId(const quint32 &value); + quint32 getSecondPointId() const; void setSecondPointId(const quint32 &value); - void setName(const QString &name); - void setTypeLine(const QString &value); - void setFormulaLength(const VFormula &value); + public slots: virtual void FullUpdateFromFile(); virtual void SetFactor(qreal factor); virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - virtual void AddToFile(); - virtual void RefreshDataInFile(); virtual void RemoveReferens(); virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: /** @brief secondPointId id second point of line. */ quint32 secondPointId; - void SaveOptions(QDomElement &tag, const VPointF &point); - void SaveOption(const VPointF &point); }; #endif // VTOOLALONGLINE_H diff --git a/src/app/tools/drawTools/vtoolarc.cpp b/src/app/tools/drawTools/vtoolarc.cpp index c7f4a6b07..3fe7d4bae 100644 --- a/src/app/tools/drawTools/vtoolarc.cpp +++ b/src/app/tools/drawTools/vtoolarc.cpp @@ -164,6 +164,12 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 ¢er, QString &ra return nullptr; } +//--------------------------------------------------------------------------------------------------------------------- +QString VToolArc::getTagName() const +{ + return VToolArc::TagName; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief FullUpdateFromFile update tool data form file. @@ -183,42 +189,6 @@ void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) ContextMenu(this, event); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddToFile add tag with informations about tool into file. - */ -void VToolArc::AddToFile() -{ - const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->createElement(TagName); - - doc->SetAttribute(domElement, VDomDocument::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); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ -void VToolArc::RefreshDataInFile() -{ - const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - 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()); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief RemoveReferens decrement value of reference. @@ -244,6 +214,20 @@ void VToolArc::SaveDialog(QDomElement &domElement) doc->SetAttribute(domElement, AttrAngle2, dialogTool->GetF2()); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolArc::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer arc = qSharedPointerDynamicCast(obj); + SCASSERT(arc.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrCenter, arc->GetCenter().id()); + doc->SetAttribute(tag, AttrRadius, arc->GetFormulaRadius()); + doc->SetAttribute(tag, AttrAngle1, arc->GetFormulaF1()); + doc->SetAttribute(tag, AttrAngle2, arc->GetFormulaF2()); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief RefreshGeometry refresh item on scene. diff --git a/src/app/tools/drawTools/vtoolarc.h b/src/app/tools/drawTools/vtoolarc.h index 6417cf8c0..30a63acfb 100644 --- a/src/app/tools/drawTools/vtoolarc.h +++ b/src/app/tools/drawTools/vtoolarc.h @@ -48,14 +48,14 @@ public: static const QString ToolType; virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::Arc)}; + virtual QString getTagName() const; public slots: virtual void FullUpdateFromFile(); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - virtual void AddToFile(); - virtual void RefreshDataInFile(); virtual void RemoveReferens(); virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: void RefreshGeometry(); }; diff --git a/src/app/tools/drawTools/vtoolbisector.cpp b/src/app/tools/drawTools/vtoolbisector.cpp index 69116db27..7f25bde4d 100644 --- a/src/app/tools/drawTools/vtoolbisector.cpp +++ b/src/app/tools/drawTools/vtoolbisector.cpp @@ -263,51 +263,6 @@ void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) ContextMenu(this, event); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddToFile add tag with informations about tool into file. - */ -void VToolBisector::AddToFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->createElement(TagName); - - doc->SetAttribute(domElement, VDomDocument::AttrId, id); - doc->SetAttribute(domElement, AttrType, ToolType); - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - - doc->SetAttribute(domElement, AttrTypeLine, typeLine); - doc->SetAttribute(domElement, AttrLength, formulaLength); - doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); - doc->SetAttribute(domElement, AttrSecondPoint, basePointId); - doc->SetAttribute(domElement, AttrThirdPoint, thirdPointId); - - AddToCalculation(domElement); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ -void VToolBisector::RefreshDataInFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrTypeLine, typeLine); - doc->SetAttribute(domElement, AttrLength, formulaLength); - doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); - doc->SetAttribute(domElement, AttrSecondPoint, basePointId); - doc->SetAttribute(domElement, AttrThirdPoint, thirdPointId); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief RemoveReferens decrement value of reference. @@ -335,3 +290,22 @@ void VToolBisector::SaveDialog(QDomElement &domElement) doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); doc->SetAttribute(domElement, AttrThirdPoint, QString().setNum(dialogTool->getThirdPointId())); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolBisector::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrLength, formulaLength); + doc->SetAttribute(tag, AttrFirstPoint, firstPointId); + doc->SetAttribute(tag, AttrSecondPoint, basePointId); + doc->SetAttribute(tag, AttrThirdPoint, thirdPointId); +} diff --git a/src/app/tools/drawTools/vtoolbisector.h b/src/app/tools/drawTools/vtoolbisector.h index f824fd5bf..8bc7bd0e5 100644 --- a/src/app/tools/drawTools/vtoolbisector.h +++ b/src/app/tools/drawTools/vtoolbisector.h @@ -61,10 +61,9 @@ public slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - virtual void AddToFile(); - virtual void RefreshDataInFile(); virtual void RemoveReferens(); virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: /** @brief firstPointId id first point of angle. */ quint32 firstPointId; diff --git a/src/app/tools/drawTools/vtoolcutarc.cpp b/src/app/tools/drawTools/vtoolcutarc.cpp index 75f432d5a..e110c1d6b 100644 --- a/src/app/tools/drawTools/vtoolcutarc.cpp +++ b/src/app/tools/drawTools/vtoolcutarc.cpp @@ -219,45 +219,6 @@ void VToolCutArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) ContextMenu(this, event); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddToFile add tag with informations about tool into file. - */ -void VToolCutArc::AddToFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->createElement(TagName); - - doc->SetAttribute(domElement, VDomDocument::AttrId, id); - doc->SetAttribute(domElement, AttrType, ToolType); - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - - doc->SetAttribute(domElement, AttrLength, formula); - doc->SetAttribute(domElement, AttrArc, curveCutId); - - AddToCalculation(domElement); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ -void VToolCutArc::RefreshDataInFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - doc->SetAttribute(domElement, AttrLength, formula); - doc->SetAttribute(domElement, AttrArc, curveCutId); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief SaveDialog save options into file after change in dialog. @@ -296,3 +257,19 @@ void VToolCutArc::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurve } curve->setPath(path); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCutArc::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrLength, formula); + doc->SetAttribute(tag, AttrArc, curveCutId); +} diff --git a/src/app/tools/drawTools/vtoolcutarc.h b/src/app/tools/drawTools/vtoolcutarc.h index a64e4eff5..204871f43 100644 --- a/src/app/tools/drawTools/vtoolcutarc.h +++ b/src/app/tools/drawTools/vtoolcutarc.h @@ -56,11 +56,10 @@ public slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - virtual void AddToFile(); - virtual void RefreshDataInFile(); virtual void SaveDialog(QDomElement &domElement); virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, PathDirection direction = PathDirection::Hide); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: Q_DISABLE_COPY(VToolCutArc) }; diff --git a/src/app/tools/drawTools/vtoolcutspline.cpp b/src/app/tools/drawTools/vtoolcutspline.cpp index 95a5aaee2..4f6f6332e 100644 --- a/src/app/tools/drawTools/vtoolcutspline.cpp +++ b/src/app/tools/drawTools/vtoolcutspline.cpp @@ -88,7 +88,7 @@ void VToolCutSpline::setDialog() * @param doc dom document container. * @param data container with variables. */ -void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, +VToolCutSpline* VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); @@ -97,7 +97,13 @@ void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, const QString pointName = dialogTool->getPointName(); QString formula = dialogTool->getFormula(); const quint32 splineId = dialogTool->getSplineId(); - Create(0, pointName, formula, splineId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); + VToolCutSpline* point = nullptr; + point = Create(0, pointName, formula, splineId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; } //--------------------------------------------------------------------------------------------------------------------- @@ -115,9 +121,10 @@ void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, * @param parse parser file mode. * @param typeCreation way we create this tool. */ -void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splineId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document &parse, const Source &typeCreation) +VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString &formula, + const quint32 &splineId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) { const QSharedPointer spl = data->GeometricObject(splineId); @@ -175,7 +182,9 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString doc->AddTool(spl1id, point); doc->AddTool(spl2id, point); doc->IncrementReferens(splineId); + return point; } + return nullptr; } //--------------------------------------------------------------------------------------------------------------------- @@ -217,45 +226,6 @@ void VToolCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) ContextMenu(this, event); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddToFile add tag with informations about tool into file. - */ -void VToolCutSpline::AddToFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->createElement(TagName); - - doc->SetAttribute(domElement, VDomDocument::AttrId, id); - doc->SetAttribute(domElement, AttrType, ToolType); - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - - doc->SetAttribute(domElement, AttrLength, formula); - doc->SetAttribute(domElement, AttrSpline, curveCutId); - - AddToCalculation(domElement); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ -void VToolCutSpline::RefreshDataInFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - doc->SetAttribute(domElement, AttrLength, formula); - doc->SetAttribute(domElement, AttrSpline, curveCutId); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief SaveDialog save options into file after change in dialog. @@ -294,3 +264,19 @@ void VToolCutSpline::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCu } curve->setPath(path); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCutSpline::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrLength, formula); + doc->SetAttribute(tag, AttrSpline, curveCutId); +} diff --git a/src/app/tools/drawTools/vtoolcutspline.h b/src/app/tools/drawTools/vtoolcutspline.h index 221b0a278..ba4111e4d 100644 --- a/src/app/tools/drawTools/vtoolcutspline.h +++ b/src/app/tools/drawTools/vtoolcutspline.h @@ -43,10 +43,10 @@ public: const quint32 &splineId, const quint32 &spl1id, const quint32 &spl2id, const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splineId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document &parse, const Source &typeCreation); + static VToolCutSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolCutSpline *Create(const quint32 _id, const QString &pointName, QString &formula, + const quint32 &splineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static const QString ToolType; static const QString AttrSpline; virtual int type() const {return Type;} @@ -57,11 +57,10 @@ public slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - virtual void AddToFile(); - virtual void RefreshDataInFile(); virtual void SaveDialog(QDomElement &domElement); virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, PathDirection direction = PathDirection::Hide); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: Q_DISABLE_COPY(VToolCutSpline) }; diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.cpp b/src/app/tools/drawTools/vtoolcutsplinepath.cpp index c252f325a..b9a62baca 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolcutsplinepath.cpp @@ -91,7 +91,8 @@ void VToolCutSplinePath::setDialog() * @param doc dom document container. * @param data container with variables. */ -void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) +VToolCutSplinePath* VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data) { SCASSERT(dialog != nullptr); DialogCutSplinePath *dialogTool = qobject_cast(dialog); @@ -99,7 +100,13 @@ void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, V const QString pointName = dialogTool->getPointName(); QString formula = dialogTool->getFormula(); const quint32 splinePathId = dialogTool->getSplinePathId(); - Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); + VToolCutSplinePath* point = nullptr; + point = Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; } //--------------------------------------------------------------------------------------------------------------------- @@ -117,10 +124,10 @@ void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, V * @param parse parser file mode. * @param typeCreation way we create this tool. */ -void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula, - const quint32 &splinePathId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document &parse, const Source &typeCreation) +VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula, + const quint32 &splinePathId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) { const QSharedPointer splPath = data->GeometricObject(splinePathId); SCASSERT(splPath != nullptr); @@ -230,7 +237,9 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt doc->AddTool(splPath1id, point); doc->AddTool(splPath2id, point); doc->IncrementReferens(splinePathId); + return point; } + return nullptr; } //--------------------------------------------------------------------------------------------------------------------- @@ -272,45 +281,6 @@ void VToolCutSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) ContextMenu(this, event); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddToFile add tag with informations about tool into file. - */ -void VToolCutSplinePath::AddToFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->createElement(TagName); - - doc->SetAttribute(domElement, VDomDocument::AttrId, id); - doc->SetAttribute(domElement, AttrType, ToolType); - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - - doc->SetAttribute(domElement, AttrLength, formula); - doc->SetAttribute(domElement, AttrSplinePath, curveCutId); - - AddToCalculation(domElement); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ -void VToolCutSplinePath::RefreshDataInFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - doc->SetAttribute(domElement, AttrLength, formula); - doc->SetAttribute(domElement, AttrSplinePath, curveCutId); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief SaveDialog save options into file after change in dialog. @@ -351,3 +321,19 @@ void VToolCutSplinePath::RefreshCurve(VSimpleCurve *curve, quint32 curveId, Simp } curve->setPath(path); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCutSplinePath::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrLength, formula); + doc->SetAttribute(tag, AttrSplinePath, curveCutId); +} diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.h b/src/app/tools/drawTools/vtoolcutsplinepath.h index 7a0c0050c..a7de665f2 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.h +++ b/src/app/tools/drawTools/vtoolcutsplinepath.h @@ -44,10 +44,11 @@ public: const quint32 &splinePathId, const quint32 &splPath1id, const quint32 &splPath2id, const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splinePathId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document &parse, const Source &typeCreation); + static VToolCutSplinePath *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolCutSplinePath *Create(const quint32 _id, const QString &pointName, QString &formula, + const quint32 &splinePathId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation); static const QString ToolType; static const QString AttrSplinePath; virtual int type() const {return Type;} @@ -58,11 +59,10 @@ public slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - virtual void AddToFile(); - virtual void RefreshDataInFile(); virtual void SaveDialog(QDomElement &domElement); virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, PathDirection direction = PathDirection::Hide); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: Q_DISABLE_COPY(VToolCutSplinePath) }; diff --git a/src/app/tools/drawTools/vtoolendline.cpp b/src/app/tools/drawTools/vtoolendline.cpp index 83e9d7133..645df23c1 100644 --- a/src/app/tools/drawTools/vtoolendline.cpp +++ b/src/app/tools/drawTools/vtoolendline.cpp @@ -32,7 +32,6 @@ #include "../../dialogs/tools/dialogendline.h" #include "../../dialogs/tools/dialogeditwrongformula.h" #include "../../geometry/vpointf.h" -#include "../../undocommands/savetooloptions.h" const QString VToolEndLine::ToolType = QStringLiteral("endLine"); @@ -171,54 +170,6 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, return nullptr; } -void VToolEndLine::SaveOption(const VPointF &point) -{ - QDomElement oldDomElement = doc->elementById(QString().setNum(id)); - if (oldDomElement.isElement()) - { - QDomElement newDomElement = oldDomElement.cloneNode().toElement(); - - SaveOptions(newDomElement, point); - - SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, id); - connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VPattern::LiteParseTree); - qApp->getUndoStack()->push(saveOptions); - } - else - { - qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO; - } -} - -void VToolEndLine::setName(const QString &name) -{ - VPointF newPoint = VPointF(*VAbstractTool::data.GeometricObject(id).data()); - newPoint.setName(name); - SaveOption(newPoint); -} - -void VToolEndLine::setBasePointId(const quint32 &value) -{ - if (value != NULL_ID) - { - basePointId = value; - - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - SaveOption(*point.data()); - } -} - -void VToolEndLine::setFormulaLength(const VFormula &value) -{ - if (value.error() == false) - { - formulaLength = value.getFormula(FormulaType::FromUser); - - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - SaveOption(*point.data()); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief FullUpdateFromFile update tool data form file. @@ -256,38 +207,6 @@ void VToolEndLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) ContextMenu(this, event); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddToFile add tag with informations about tool into file. - */ -void VToolEndLine::AddToFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->createElement(TagName); - - SaveOptions(domElement, *point.data()); - - AddToCalculation(domElement); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ -void VToolEndLine::RefreshDataInFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - SaveOptions(domElement, *point.data()); - } - else - { - qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO; - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief SaveDialog save options into file after change in dialog. @@ -305,13 +224,16 @@ void VToolEndLine::SaveDialog(QDomElement &domElement) } //--------------------------------------------------------------------------------------------------------------------- -void VToolEndLine::SaveOptions(QDomElement &tag, const VPointF &point) +void VToolEndLine::SaveOptions(QDomElement &tag, QSharedPointer &obj) { + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + doc->SetAttribute(tag, VDomDocument::AttrId, id); doc->SetAttribute(tag, AttrType, ToolType); - doc->SetAttribute(tag, AttrName, point.name()); - doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point.mx())); - doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point.my())); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrTypeLine, typeLine); doc->SetAttribute(tag, AttrLength, formulaLength); @@ -336,16 +258,7 @@ void VToolEndLine::setFormulaAngle(const VFormula &value) { formulaAngle = value.getFormula(FormulaType::FromUser); - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - SaveOption(*point.data()); + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); } } - -//--------------------------------------------------------------------------------------------------------------------- -void VToolEndLine::setTypeLine(const QString &value) -{ - typeLine = value; - - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - SaveOption(*point.data()); -} diff --git a/src/app/tools/drawTools/vtoolendline.h b/src/app/tools/drawTools/vtoolendline.h index 89448b29b..16c58c7ea 100644 --- a/src/app/tools/drawTools/vtoolendline.h +++ b/src/app/tools/drawTools/vtoolendline.h @@ -51,24 +51,19 @@ public: static const QString ToolType; virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::EndLine)}; - void setName(const QString &name); + VFormula getFormulaAngle() const; void setFormulaAngle(const VFormula &value); - void setTypeLine(const QString &value); - void setFormulaLength(const VFormula &value); - void setBasePointId(const quint32 &value); + public slots: virtual void FullUpdateFromFile(); virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - virtual void AddToFile(); - virtual void RefreshDataInFile(); virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: QString formulaAngle; - void SaveOptions(QDomElement &tag, const VPointF &point); - void SaveOption(const VPointF &point); }; #endif // VTOOLENDLINE_H diff --git a/src/app/tools/drawTools/vtoolheight.cpp b/src/app/tools/drawTools/vtoolheight.cpp index 8425e50f7..067cab00c 100644 --- a/src/app/tools/drawTools/vtoolheight.cpp +++ b/src/app/tools/drawTools/vtoolheight.cpp @@ -224,50 +224,6 @@ void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) ContextMenu(this, event); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddToFile add tag with informations about tool into file. - */ -void VToolHeight::AddToFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->createElement(TagName); - - doc->SetAttribute(domElement, VDomDocument::AttrId, id); - doc->SetAttribute(domElement, AttrType, ToolType); - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - - doc->SetAttribute(domElement, AttrTypeLine, typeLine); - doc->SetAttribute(domElement, AttrBasePoint, basePointId); - doc->SetAttribute(domElement, AttrP1Line, p1LineId); - doc->SetAttribute(domElement, AttrP2Line, p2LineId); - - AddToCalculation(domElement); - -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ -void VToolHeight::RefreshDataInFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - doc->SetAttribute(domElement, AttrTypeLine, typeLine); - doc->SetAttribute(domElement, AttrBasePoint, basePointId); - doc->SetAttribute(domElement, AttrP1Line, p1LineId); - doc->SetAttribute(domElement, AttrP2Line, p2LineId); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief SaveDialog save options into file after change in dialog. @@ -283,3 +239,21 @@ void VToolHeight::SaveDialog(QDomElement &domElement) doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->getP1LineId())); doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getP2LineId())); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolHeight::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrBasePoint, basePointId); + doc->SetAttribute(tag, AttrP1Line, p1LineId); + doc->SetAttribute(tag, AttrP2Line, p2LineId); +} diff --git a/src/app/tools/drawTools/vtoolheight.h b/src/app/tools/drawTools/vtoolheight.h index c7fb5b146..bbbfabf3a 100644 --- a/src/app/tools/drawTools/vtoolheight.h +++ b/src/app/tools/drawTools/vtoolheight.h @@ -57,9 +57,8 @@ public slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - virtual void AddToFile(); - virtual void RefreshDataInFile(); virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: /** @brief p1LineId id first point of line. */ quint32 p1LineId; diff --git a/src/app/tools/drawTools/vtoolline.cpp b/src/app/tools/drawTools/vtoolline.cpp index d05b337e5..abe37eba0 100644 --- a/src/app/tools/drawTools/vtoolline.cpp +++ b/src/app/tools/drawTools/vtoolline.cpp @@ -176,6 +176,12 @@ void VToolLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QGraphicsLineItem::paint(painter, &myOption, widget); } +//--------------------------------------------------------------------------------------------------------------------- +QString VToolLine::getTagName() const +{ + return VToolLine::TagName; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief FullUpdateFromFile update tool data form file. @@ -254,11 +260,8 @@ void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void VToolLine::AddToFile() { QDomElement domElement = doc->createElement(TagName); - doc->SetAttribute(domElement, VDomDocument::AttrId, id); - doc->SetAttribute(domElement, AttrFirstPoint, firstPoint); - doc->SetAttribute(domElement, AttrSecondPoint, secondPoint); - doc->SetAttribute(domElement, AttrTypeLine, typeLine); - + QSharedPointer obj = QSharedPointer (); + SaveOptions(domElement, obj); AddToCalculation(domElement); } @@ -271,9 +274,12 @@ void VToolLine::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - doc->SetAttribute(domElement, AttrFirstPoint, firstPoint); - doc->SetAttribute(domElement, AttrSecondPoint, secondPoint); - doc->SetAttribute(domElement, AttrTypeLine, typeLine); + QSharedPointer obj = QSharedPointer (); + SaveOptions(domElement, obj); + } + else + { + qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO; } } @@ -366,6 +372,17 @@ void VToolLine::SaveDialog(QDomElement &domElement) doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolLine::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + Q_UNUSED(obj) + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrFirstPoint, firstPoint); + doc->SetAttribute(tag, AttrSecondPoint, secondPoint); + doc->SetAttribute(tag, AttrTypeLine, typeLine); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief RefreshGeometry refresh item on scene. diff --git a/src/app/tools/drawTools/vtoolline.h b/src/app/tools/drawTools/vtoolline.h index 8dfbd4c0e..722258cf4 100644 --- a/src/app/tools/drawTools/vtoolline.h +++ b/src/app/tools/drawTools/vtoolline.h @@ -50,6 +50,7 @@ public: virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::Line)}; + virtual QString getTagName() const; public slots: virtual void FullUpdateFromFile(); virtual void ChangedActivDraw(const QString &newName); @@ -66,6 +67,7 @@ protected: virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); virtual void keyReleaseEvent(QKeyEvent * event); virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: /** @brief firstPoint id first line point. */ quint32 firstPoint; diff --git a/src/app/tools/drawTools/vtoollineintersect.cpp b/src/app/tools/drawTools/vtoollineintersect.cpp index 1a83b0013..7ddc33983 100644 --- a/src/app/tools/drawTools/vtoollineintersect.cpp +++ b/src/app/tools/drawTools/vtoollineintersect.cpp @@ -234,49 +234,6 @@ void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) ContextMenu(this, event); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddToFile add tag with informations about tool into file. - */ -void VToolLineIntersect::AddToFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->createElement(TagName); - - doc->SetAttribute(domElement, VDomDocument::AttrId, id); - doc->SetAttribute(domElement, AttrType, ToolType); - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - - doc->SetAttribute(domElement, AttrP1Line1, p1Line1); - doc->SetAttribute(domElement, AttrP2Line1, p2Line1); - doc->SetAttribute(domElement, AttrP1Line2, p1Line2); - doc->SetAttribute(domElement, AttrP2Line2, p2Line2); - - AddToCalculation(domElement); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ -void VToolLineIntersect::RefreshDataInFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - doc->SetAttribute(domElement, AttrP1Line1, p1Line1); - doc->SetAttribute(domElement, AttrP2Line1, p2Line1); - doc->SetAttribute(domElement, AttrP1Line2, p1Line2); - doc->SetAttribute(domElement, AttrP2Line2, p2Line2); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief RemoveReferens decrement value of reference. @@ -304,3 +261,21 @@ void VToolLineIntersect::SaveDialog(QDomElement &domElement) doc->SetAttribute(domElement, AttrP1Line2, QString().setNum(dialogTool->getP1Line2())); doc->SetAttribute(domElement, AttrP2Line2, QString().setNum(dialogTool->getP2Line2())); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersect::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrP1Line1, p1Line1); + doc->SetAttribute(tag, AttrP2Line1, p2Line1); + doc->SetAttribute(tag, AttrP1Line2, p1Line2); + doc->SetAttribute(tag, AttrP2Line2, p2Line2); +} diff --git a/src/app/tools/drawTools/vtoollineintersect.h b/src/app/tools/drawTools/vtoollineintersect.h index fe1802353..8a415c01e 100644 --- a/src/app/tools/drawTools/vtoollineintersect.h +++ b/src/app/tools/drawTools/vtoollineintersect.h @@ -56,10 +56,9 @@ public slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - virtual void AddToFile(); - virtual void RefreshDataInFile(); virtual void RemoveReferens(); virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: /** @brief p1Line1 id first point first line. */ quint32 p1Line1; diff --git a/src/app/tools/drawTools/vtoollinepoint.cpp b/src/app/tools/drawTools/vtoollinepoint.cpp index fb02060e0..da3a06392 100644 --- a/src/app/tools/drawTools/vtoollinepoint.cpp +++ b/src/app/tools/drawTools/vtoollinepoint.cpp @@ -108,11 +108,25 @@ void VToolLinePoint::SetFactor(qreal factor) RefreshGeometry(); } +//--------------------------------------------------------------------------------------------------------------------- quint32 VToolLinePoint::getBasePointId() const { return basePointId; } +//--------------------------------------------------------------------------------------------------------------------- +void VToolLinePoint::setBasePointId(const quint32 &value) +{ + if (value != NULL_ID) + { + basePointId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- VFormula VToolLinePoint::getFormulaLength() const { VFormula fLength(formulaLength, this->getData()); @@ -122,3 +136,15 @@ VFormula VToolLinePoint::getFormulaLength() const return fLength; } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLinePoint::setFormulaLength(const VFormula &value) +{ + if (value.error() == false) + { + formulaLength = value.getFormula(FormulaType::FromUser); + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} diff --git a/src/app/tools/drawTools/vtoollinepoint.h b/src/app/tools/drawTools/vtoollinepoint.h index 4929381d1..9640e1316 100644 --- a/src/app/tools/drawTools/vtoollinepoint.h +++ b/src/app/tools/drawTools/vtoollinepoint.h @@ -44,10 +44,10 @@ public: virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::LinePoint)}; VFormula getFormulaLength() const; - //void setFormulaLength(const QString &value)=0; + void setFormulaLength(const VFormula &value); quint32 getBasePointId() const; - //void setBasePointId(const quint32 &value)=0; + void setBasePointId(const quint32 &value); public slots: virtual void ChangedActivDraw(const QString &newName); diff --git a/src/app/tools/drawTools/vtoolnormal.cpp b/src/app/tools/drawTools/vtoolnormal.cpp index 4359363ae..e46e6ae4d 100644 --- a/src/app/tools/drawTools/vtoolnormal.cpp +++ b/src/app/tools/drawTools/vtoolnormal.cpp @@ -242,51 +242,6 @@ void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) ContextMenu(this, event); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddToFile add tag with informations about tool into file. - */ -void VToolNormal::AddToFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->createElement(TagName); - - doc->SetAttribute(domElement, VDomDocument::AttrId, id); - doc->SetAttribute(domElement, AttrType, ToolType); - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - - doc->SetAttribute(domElement, AttrTypeLine, typeLine); - doc->SetAttribute(domElement, AttrLength, formulaLength); - doc->SetAttribute(domElement, AttrAngle, angle); - doc->SetAttribute(domElement, AttrFirstPoint, basePointId); - doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); - - AddToCalculation(domElement); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ -void VToolNormal::RefreshDataInFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - doc->SetAttribute(domElement, AttrTypeLine, typeLine); - doc->SetAttribute(domElement, AttrLength, formulaLength); - doc->SetAttribute(domElement, AttrAngle, angle); - doc->SetAttribute(domElement, AttrFirstPoint, basePointId); - doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief RemoveReferens decrement value of reference. @@ -313,3 +268,22 @@ void VToolNormal::SaveDialog(QDomElement &domElement) doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolNormal::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrLength, formulaLength); + doc->SetAttribute(tag, AttrAngle, angle); + doc->SetAttribute(tag, AttrFirstPoint, basePointId); + doc->SetAttribute(tag, AttrSecondPoint, secondPointId); +} diff --git a/src/app/tools/drawTools/vtoolnormal.h b/src/app/tools/drawTools/vtoolnormal.h index c5b1f8d0b..1f0458ade 100644 --- a/src/app/tools/drawTools/vtoolnormal.h +++ b/src/app/tools/drawTools/vtoolnormal.h @@ -58,10 +58,9 @@ public slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - virtual void AddToFile(); - virtual void RefreshDataInFile(); virtual void RemoveReferens(); virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: /** @brief secondPointId id second line point. */ quint32 secondPointId; diff --git a/src/app/tools/drawTools/vtoolpoint.cpp b/src/app/tools/drawTools/vtoolpoint.cpp index 13dd87e5c..8a40360a1 100644 --- a/src/app/tools/drawTools/vtoolpoint.cpp +++ b/src/app/tools/drawTools/vtoolpoint.cpp @@ -78,6 +78,20 @@ QString VToolPoint::name() const return VAbstractTool::data.GeometricObject(id)->name(); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolPoint::setName(const QString &name) +{ + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + obj->setName(name); + SaveOption(obj); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolPoint::getTagName() const +{ + return VToolPoint::TagName; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief NameChangePosition handle change posion point label. diff --git a/src/app/tools/drawTools/vtoolpoint.h b/src/app/tools/drawTools/vtoolpoint.h index d06188241..5c19d073a 100644 --- a/src/app/tools/drawTools/vtoolpoint.h +++ b/src/app/tools/drawTools/vtoolpoint.h @@ -44,10 +44,11 @@ class VToolPoint: public VDrawTool, public QGraphicsEllipseItem public: VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr); virtual ~VToolPoint(){} - static const QString TagName; virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); QString name() const; - //void setName(const QString &name)=0; + void setName(const QString &name); + virtual QString getTagName() const; + static const QString TagName; public slots: void NameChangePosition(const QPointF &pos); virtual void ChangedActivDraw(const QString &newName); diff --git a/src/app/tools/drawTools/vtoolpointofcontact.cpp b/src/app/tools/drawTools/vtoolpointofcontact.cpp index 0f7ae3e28..e81d5aaae 100644 --- a/src/app/tools/drawTools/vtoolpointofcontact.cpp +++ b/src/app/tools/drawTools/vtoolpointofcontact.cpp @@ -260,49 +260,6 @@ void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event ContextMenu(this, event); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddToFile add tag with informations about tool into file. - */ -void VToolPointOfContact::AddToFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->createElement(TagName); - - doc->SetAttribute(domElement, VDomDocument::AttrId, id); - doc->SetAttribute(domElement, AttrType, ToolType); - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - - doc->SetAttribute(domElement, AttrRadius, arcRadius); - doc->SetAttribute(domElement, AttrCenter, center); - doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); - doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); - - AddToCalculation(domElement); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ -void VToolPointOfContact::RefreshDataInFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - doc->SetAttribute(domElement, AttrRadius, arcRadius); - doc->SetAttribute(domElement, AttrCenter, center); - doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); - doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief RemoveReferens decrement value of reference. @@ -329,3 +286,21 @@ void VToolPointOfContact::SaveDialog(QDomElement &domElement) doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPoint())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPoint())); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfContact::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrRadius, arcRadius); + doc->SetAttribute(tag, AttrCenter, center); + doc->SetAttribute(tag, AttrFirstPoint, firstPointId); + doc->SetAttribute(tag, AttrSecondPoint, secondPointId); +} diff --git a/src/app/tools/drawTools/vtoolpointofcontact.h b/src/app/tools/drawTools/vtoolpointofcontact.h index 7bdb63e8b..cbbefba91 100644 --- a/src/app/tools/drawTools/vtoolpointofcontact.h +++ b/src/app/tools/drawTools/vtoolpointofcontact.h @@ -59,10 +59,9 @@ public slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - virtual void AddToFile(); - virtual void RefreshDataInFile(); virtual void RemoveReferens(); virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: /** @brief radius string with formula radius arc. */ QString arcRadius; diff --git a/src/app/tools/drawTools/vtoolpointofintersection.cpp b/src/app/tools/drawTools/vtoolpointofintersection.cpp index 10790a8b4..bd7d845cc 100644 --- a/src/app/tools/drawTools/vtoolpointofintersection.cpp +++ b/src/app/tools/drawTools/vtoolpointofintersection.cpp @@ -203,45 +203,6 @@ void VToolPointOfIntersection::contextMenuEvent(QGraphicsSceneContextMenuEvent * ContextMenu(this, event); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddToFile add tag with informations about tool into file. - */ -void VToolPointOfIntersection::AddToFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->createElement(TagName); - - doc->SetAttribute(domElement, VDomDocument::AttrId, id); - doc->SetAttribute(domElement, AttrType, ToolType); - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - - doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); - doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); - - AddToCalculation(domElement); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ -void VToolPointOfIntersection::RefreshDataInFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); - doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief SaveDialog save options into file after change in dialog. @@ -255,3 +216,19 @@ void VToolPointOfIntersection::SaveDialog(QDomElement &domElement) doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersection::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrFirstPoint, firstPointId); + doc->SetAttribute(tag, AttrSecondPoint, secondPointId); +} diff --git a/src/app/tools/drawTools/vtoolpointofintersection.h b/src/app/tools/drawTools/vtoolpointofintersection.h index 55dcd021f..9a82ad1f9 100644 --- a/src/app/tools/drawTools/vtoolpointofintersection.h +++ b/src/app/tools/drawTools/vtoolpointofintersection.h @@ -57,9 +57,8 @@ public slots: protected: virtual void RemoveReferens(); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - virtual void AddToFile(); - virtual void RefreshDataInFile(); virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: Q_DISABLE_COPY(VToolPointOfIntersection) /** @brief firstPointId id first line point. */ diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.cpp b/src/app/tools/drawTools/vtoolshoulderpoint.cpp index 5221a18de..0d6cb2a2c 100644 --- a/src/app/tools/drawTools/vtoolshoulderpoint.cpp +++ b/src/app/tools/drawTools/vtoolshoulderpoint.cpp @@ -267,51 +267,6 @@ void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) ContextMenu(this, event); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddToFile add tag with informations about tool into file. - */ -void VToolShoulderPoint::AddToFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->createElement(TagName); - - doc->SetAttribute(domElement, VDomDocument::AttrId, id); - doc->SetAttribute(domElement, AttrType, ToolType); - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - - doc->SetAttribute(domElement, AttrTypeLine, typeLine); - doc->SetAttribute(domElement, AttrLength, formulaLength); - doc->SetAttribute(domElement, AttrP1Line, basePointId); - doc->SetAttribute(domElement, AttrP2Line, p2Line); - doc->SetAttribute(domElement, AttrPShoulder, pShoulder); - - AddToCalculation(domElement); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ -void VToolShoulderPoint::RefreshDataInFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrName, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrName, qApp->fromPixel(point->my())); - doc->SetAttribute(domElement, AttrTypeLine, typeLine); - doc->SetAttribute(domElement, AttrLength, formulaLength); - doc->SetAttribute(domElement, AttrP1Line, basePointId); - doc->SetAttribute(domElement, AttrP2Line, p2Line); - doc->SetAttribute(domElement, AttrPShoulder, pShoulder); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief RemoveReferens decrement value of reference. @@ -339,3 +294,22 @@ void VToolShoulderPoint::SaveDialog(QDomElement &domElement) doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getP2Line())); doc->SetAttribute(domElement, AttrPShoulder, QString().setNum(dialogTool->getPShoulder())); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolShoulderPoint::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrLength, formulaLength); + doc->SetAttribute(tag, AttrP1Line, basePointId); + doc->SetAttribute(tag, AttrP2Line, p2Line); + doc->SetAttribute(tag, AttrPShoulder, pShoulder); +} diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.h b/src/app/tools/drawTools/vtoolshoulderpoint.h index f1592ed2a..8c8b30a1d 100644 --- a/src/app/tools/drawTools/vtoolshoulderpoint.h +++ b/src/app/tools/drawTools/vtoolshoulderpoint.h @@ -59,10 +59,9 @@ public slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - virtual void AddToFile(); - virtual void RefreshDataInFile(); virtual void RemoveReferens(); virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: /** @brief p2Line id second line point. */ quint32 p2Line; diff --git a/src/app/tools/drawTools/vtoolsinglepoint.cpp b/src/app/tools/drawTools/vtoolsinglepoint.cpp index 83e23ed44..c8a9461fb 100644 --- a/src/app/tools/drawTools/vtoolsinglepoint.cpp +++ b/src/app/tools/drawTools/vtoolsinglepoint.cpp @@ -33,7 +33,6 @@ #include "../../undocommands/addpatternpiece.h" #include "../../undocommands/deletepatternpiece.h" #include "../../geometry/vpointf.h" -#include "../../undocommands/savetooloptions.h" #include @@ -83,34 +82,6 @@ void VToolSinglePoint::setDialog() dialogTool->setData(p->name(), p->toQPointF()); } -//--------------------------------------------------------------------------------------------------------------------- -void VToolSinglePoint::setName(const QString &name) -{ - QDomElement oldDomElement = doc->elementById(QString().setNum(id)); - if (oldDomElement.isElement()) - { - QDomElement newDomElement = oldDomElement.cloneNode().toElement(); - - VPointF newPoint = VPointF(*VAbstractTool::data.GeometricObject(id).data()); - newPoint.setName(name); - SaveOptions(newDomElement, newPoint); - - SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, id); - connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VPattern::LiteParseTree); - qApp->getUndoStack()->push(saveOptions); - } - else - { - qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO; - } -} - -//--------------------------------------------------------------------------------------------------------------------- -int VToolSinglePoint::type() const -{ - return Type; -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief AddToFile add tag with informations about tool into file. @@ -119,11 +90,11 @@ void VToolSinglePoint::AddToFile() { Q_ASSERT_X(namePP.isEmpty() == false, "AddToFile", "name pattern piece is empty"); - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement sPoint = doc->createElement(TagName); // Create SPoint tag - SaveOptions(sPoint, *point.data()); + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOptions(sPoint, obj); //Create pattern piece structure QDomElement patternPiece = doc->createElement(VPattern::TagDraw); @@ -142,24 +113,6 @@ void VToolSinglePoint::AddToFile() qApp->getUndoStack()->push(addPP); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ -void VToolSinglePoint::RefreshDataInFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - SaveOptions(domElement, *point.data()); - } - else - { - qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO; - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief itemChange handle tool change. @@ -298,15 +251,18 @@ void VToolSinglePoint::setColorLabel(const Qt::GlobalColor &color) } //--------------------------------------------------------------------------------------------------------------------- -void VToolSinglePoint::SaveOptions(QDomElement &tag, const VPointF &point) +void VToolSinglePoint::SaveOptions(QDomElement &tag, QSharedPointer &obj) { + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + doc->SetAttribute(tag, VDomDocument::AttrId, id); doc->SetAttribute(tag, AttrType, ToolType); - doc->SetAttribute(tag, AttrName, point.name()); - doc->SetAttribute(tag, AttrX, qApp->fromPixel(point.x())); - doc->SetAttribute(tag, AttrY, qApp->fromPixel(point.y())); - doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point.mx())); - doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point.my())); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrX, qApp->fromPixel(point->x())); + doc->SetAttribute(tag, AttrY, qApp->fromPixel(point->y())); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolsinglepoint.h b/src/app/tools/drawTools/vtoolsinglepoint.h index 48c7494a0..98a60bcd5 100644 --- a/src/app/tools/drawTools/vtoolsinglepoint.h +++ b/src/app/tools/drawTools/vtoolsinglepoint.h @@ -43,8 +43,7 @@ public: const QString &namePP, const QString &mPath, QGraphicsItem * parent = nullptr ); virtual void setDialog(); static const QString ToolType; - void setName(const QString &name); - virtual int type()const; + virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::SinglePoint)}; public slots: virtual void FullUpdateFromFile(); @@ -59,7 +58,6 @@ signals: protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void AddToFile(); - virtual void RefreshDataInFile(); QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); virtual void decrementReferens(); virtual void DeleteTool(bool ask = true); @@ -68,11 +66,12 @@ protected: virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: QString namePP; QString mPath; void setColorLabel(const Qt::GlobalColor & color); - void SaveOptions(QDomElement &tag, const VPointF &point); + }; #endif // VTOOLSINGLEPOINT_H diff --git a/src/app/tools/drawTools/vtoolspline.cpp b/src/app/tools/drawTools/vtoolspline.cpp index 9ddabb672..be3d9c641 100644 --- a/src/app/tools/drawTools/vtoolspline.cpp +++ b/src/app/tools/drawTools/vtoolspline.cpp @@ -225,48 +225,6 @@ void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) ContextMenu(this, event); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddToFile add tag with informations about tool into file. - */ -void VToolSpline::AddToFile() -{ - const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->createElement(TagName); - - doc->SetAttribute(domElement, VDomDocument::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); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ -void VToolSpline::RefreshDataInFile() -{ - const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - 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()); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief RemoveReferens decrement value of reference. @@ -313,6 +271,23 @@ void VToolSpline::SaveDialog(QDomElement &domElement) doc->SetAttribute(domElement, AttrKCurve, spl.GetKcurve()); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSpline::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer spl = qSharedPointerDynamicCast(obj); + SCASSERT(spl.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrPoint1, spl->GetP1().id()); + doc->SetAttribute(tag, AttrPoint4, spl->GetP4().id()); + doc->SetAttribute(tag, AttrAngle1, spl->GetAngle1()); + doc->SetAttribute(tag, AttrAngle2, spl->GetAngle2()); + doc->SetAttribute(tag, AttrKAsm1, spl->GetKasm1()); + doc->SetAttribute(tag, AttrKAsm2, spl->GetKasm2()); + doc->SetAttribute(tag, AttrKCurve, spl->GetKcurve()); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief RefreshGeometry refresh item on scene. diff --git a/src/app/tools/drawTools/vtoolspline.h b/src/app/tools/drawTools/vtoolspline.h index f1607e17a..7d7cf2ca5 100644 --- a/src/app/tools/drawTools/vtoolspline.h +++ b/src/app/tools/drawTools/vtoolspline.h @@ -55,10 +55,9 @@ public slots: const QPointF &pos); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - virtual void AddToFile (); - virtual void RefreshDataInFile(); virtual void RemoveReferens(); virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: void RefreshGeometry (); }; diff --git a/src/app/tools/drawTools/vtoolsplinepath.cpp b/src/app/tools/drawTools/vtoolsplinepath.cpp index c3e25c609..e157340fe 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolsplinepath.cpp @@ -104,7 +104,7 @@ void VToolSplinePath::setDialog() * @param doc dom document container. * @param data container with variables. */ -void VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) +VToolSplinePath* VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); DialogSplinePath *dialogTool = qobject_cast(dialog); @@ -114,7 +114,13 @@ void VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPat { doc->IncrementReferens((*path)[i].P().id()); } - Create(0, path, scene, doc, data, Document::FullParse, Source::FromGui); + VToolSplinePath* spl = nullptr; + spl = Create(0, path, scene, doc, data, Document::FullParse, Source::FromGui); + if (spl != nullptr) + { + spl->dialog=dialogTool; + } + return spl; } //--------------------------------------------------------------------------------------------------------------------- @@ -128,7 +134,7 @@ void VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPat * @param parse parser file mode. * @param typeCreation way we create this tool. */ -void VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, VPattern *doc, +VToolSplinePath* VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { quint32 id = _id; @@ -155,7 +161,9 @@ void VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphics connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSplinePath::SetFactor); connect(scene, &VMainGraphicsScene::DisableItem, spl, &VToolSplinePath::Disable); doc->AddTool(id, spl); + return spl; } + return nullptr; } //--------------------------------------------------------------------------------------------------------------------- @@ -266,27 +274,6 @@ void VToolSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) ContextMenu(this, event); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddToFile add tag with informations about tool into file. - */ -void VToolSplinePath::AddToFile() -{ - VSplinePath splPath = *VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->createElement(TagName); - - doc->SetAttribute(domElement, VDomDocument::AttrId, id); - doc->SetAttribute(domElement, AttrType, ToolType); - doc->SetAttribute(domElement, AttrKCurve, splPath.getKCurve()); - - for (qint32 i = 0; i < splPath.CountPoint(); ++i) - { - AddPathPoint(domElement, splPath.at(i)); - } - - AddToCalculation(domElement); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. @@ -352,6 +339,22 @@ void VToolSplinePath::SaveDialog(QDomElement &domElement) UpdatePathPoint(doc, domElement, splPath); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSplinePath::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer splPath = qSharedPointerDynamicCast(obj); + SCASSERT(splPath.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrKCurve, splPath->getKCurve()); + + for (qint32 i = 0; i < splPath->CountPoint(); ++i) + { + AddPathPoint(tag, splPath->at(i)); + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief RefreshGeometry refresh item on scene. diff --git a/src/app/tools/drawTools/vtoolsplinepath.h b/src/app/tools/drawTools/vtoolsplinepath.h index b94ffc919..e854c6d4f 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.h +++ b/src/app/tools/drawTools/vtoolsplinepath.h @@ -41,9 +41,9 @@ public: VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - static void Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document &parse, const Source &typeCreation); + static VToolSplinePath *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolSplinePath *Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation); static const QString ToolType; static void UpdatePathPoint(VPattern *doc, QDomNode& node, const VSplinePath &path); virtual int type() const {return Type;} @@ -69,10 +69,10 @@ public slots: const QPointF &pos); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - virtual void AddToFile(); virtual void RefreshDataInFile(); virtual void RemoveReferens(); virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: void RefreshGeometry(); void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint); diff --git a/src/app/tools/drawTools/vtooltriangle.cpp b/src/app/tools/drawTools/vtooltriangle.cpp index 73021e3f2..e41d547ba 100644 --- a/src/app/tools/drawTools/vtooltriangle.cpp +++ b/src/app/tools/drawTools/vtooltriangle.cpp @@ -263,49 +263,6 @@ void VToolTriangle::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) ContextMenu(this, event); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddToFile add tag with informations about tool into file. - */ -void VToolTriangle::AddToFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->createElement(TagName); - - doc->SetAttribute(domElement, VDomDocument::AttrId, id); - doc->SetAttribute(domElement, AttrType, ToolType); - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - - doc->SetAttribute(domElement, AttrAxisP1, axisP1Id); - doc->SetAttribute(domElement, AttrAxisP2, axisP2Id); - doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); - doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); - - AddToCalculation(domElement); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ -void VToolTriangle::RefreshDataInFile() -{ - const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - doc->SetAttribute(domElement, AttrAxisP1, axisP1Id); - doc->SetAttribute(domElement, AttrAxisP2, axisP2Id); - doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); - doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief SaveDialog save options into file after change in dialog. @@ -321,3 +278,21 @@ void VToolTriangle::SaveDialog(QDomElement &domElement) doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolTriangle::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrAxisP1, axisP1Id); + doc->SetAttribute(tag, AttrAxisP2, axisP2Id); + doc->SetAttribute(tag, AttrFirstPoint, firstPointId); + doc->SetAttribute(tag, AttrSecondPoint, secondPointId); +} diff --git a/src/app/tools/drawTools/vtooltriangle.h b/src/app/tools/drawTools/vtooltriangle.h index d8cca4530..4e36d4835 100644 --- a/src/app/tools/drawTools/vtooltriangle.h +++ b/src/app/tools/drawTools/vtooltriangle.h @@ -59,9 +59,8 @@ public slots: protected: virtual void RemoveReferens(); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - virtual void AddToFile(); - virtual void RefreshDataInFile(); virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: Q_DISABLE_COPY(VToolTriangle) /** @brief axisP1Id id first axis point. */ diff --git a/src/app/tools/nodeDetails/vabstractnode.cpp b/src/app/tools/nodeDetails/vabstractnode.cpp index 09f6e1da8..e8268da8d 100644 --- a/src/app/tools/nodeDetails/vabstractnode.cpp +++ b/src/app/tools/nodeDetails/vabstractnode.cpp @@ -130,3 +130,9 @@ void VAbstractNode::RestoreReferens() doc->IncrementReferens(idNode); } } + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractNode::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + +} diff --git a/src/app/tools/nodeDetails/vabstractnode.h b/src/app/tools/nodeDetails/vabstractnode.h index 9cca668bf..3d167618b 100644 --- a/src/app/tools/nodeDetails/vabstractnode.h +++ b/src/app/tools/nodeDetails/vabstractnode.h @@ -56,6 +56,7 @@ protected: virtual void decrementReferens(); virtual void RemoveReferens(); virtual void RestoreReferens(); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); }; #endif // VABSTRACTNODE_H diff --git a/src/app/tools/nodeDetails/vnodearc.cpp b/src/app/tools/nodeDetails/vnodearc.cpp index 802265e19..829d86b22 100644 --- a/src/app/tools/nodeDetails/vnodearc.cpp +++ b/src/app/tools/nodeDetails/vnodearc.cpp @@ -124,6 +124,12 @@ void VNodeArc::RestoreNode() } } +//--------------------------------------------------------------------------------------------------------------------- +QString VNodeArc::getTagName() const +{ + return VNodeArc::TagName; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief FullUpdateFromFile update tool data form file. @@ -144,7 +150,7 @@ void VNodeArc::AddToFile() doc->SetAttribute(domElement, VDomDocument::AttrId, id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrIdObject, idNode); - if (idTool != 0) + if (idTool != NULL_ID) { doc->SetAttribute(domElement, AttrIdTool, idTool); } @@ -162,7 +168,7 @@ void VNodeArc::RefreshDataInFile() if (domElement.isElement()) { doc->SetAttribute(domElement, AttrIdObject, idNode); - if (idTool != 0) + if (idTool != NULL_ID) { doc->SetAttribute(domElement, AttrIdTool, idTool); } diff --git a/src/app/tools/nodeDetails/vnodearc.h b/src/app/tools/nodeDetails/vnodearc.h index b199855cb..5341a3f99 100644 --- a/src/app/tools/nodeDetails/vnodearc.h +++ b/src/app/tools/nodeDetails/vnodearc.h @@ -51,6 +51,7 @@ public: virtual void RestoreNode(); virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::NodeArc)}; + virtual QString getTagName() const; public slots: virtual void FullUpdateFromFile(); protected: diff --git a/src/app/tools/nodeDetails/vnodepoint.cpp b/src/app/tools/nodeDetails/vnodepoint.cpp index 5e02e2443..cce6c8629 100644 --- a/src/app/tools/nodeDetails/vnodepoint.cpp +++ b/src/app/tools/nodeDetails/vnodepoint.cpp @@ -136,6 +136,12 @@ void VNodePoint::RestoreNode() } } +//--------------------------------------------------------------------------------------------------------------------- +QString VNodePoint::getTagName() const +{ + return VNodePoint::TagName; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief FullUpdateFromFile update tool data form file. @@ -159,7 +165,7 @@ void VNodePoint::AddToFile() doc->SetAttribute(domElement, AttrIdObject, idNode); doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - if (idTool != 0) + if (idTool != NULL_ID) { doc->SetAttribute(domElement, AttrIdTool, idTool); } @@ -180,7 +186,7 @@ void VNodePoint::RefreshDataInFile() doc->SetAttribute(domElement, AttrIdObject, idNode); doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); - if (idTool != 0) + if (idTool != NULL_ID) { doc->SetAttribute(domElement, AttrIdTool, idTool); } diff --git a/src/app/tools/nodeDetails/vnodepoint.h b/src/app/tools/nodeDetails/vnodepoint.h index 0201af254..23e666aa8 100644 --- a/src/app/tools/nodeDetails/vnodepoint.h +++ b/src/app/tools/nodeDetails/vnodepoint.h @@ -57,6 +57,7 @@ public: virtual void RestoreNode(); virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::NodePoint)}; + virtual QString getTagName() const; public slots: virtual void FullUpdateFromFile(); void NameChangePosition(const QPointF &pos); diff --git a/src/app/tools/nodeDetails/vnodespline.cpp b/src/app/tools/nodeDetails/vnodespline.cpp index ffbe5327d..73227ca84 100644 --- a/src/app/tools/nodeDetails/vnodespline.cpp +++ b/src/app/tools/nodeDetails/vnodespline.cpp @@ -127,6 +127,12 @@ void VNodeSpline::RestoreNode() } } +//--------------------------------------------------------------------------------------------------------------------- +QString VNodeSpline::getTagName() const +{ + return VNodeSpline::TagName; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief FullUpdateFromFile update tool data form file. @@ -147,7 +153,7 @@ void VNodeSpline::AddToFile() doc->SetAttribute(domElement, VDomDocument::AttrId, id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrIdObject, idNode); - if (idTool != 0) + if (idTool != NULL_ID) { doc->SetAttribute(domElement, AttrIdTool, idTool); } @@ -165,7 +171,7 @@ void VNodeSpline::RefreshDataInFile() if (domElement.isElement()) { doc->SetAttribute(domElement, AttrIdObject, QString().setNum(idNode)); - if (idTool != 0) + if (idTool != NULL_ID) { doc->SetAttribute(domElement, AttrIdTool, idTool); } diff --git a/src/app/tools/nodeDetails/vnodespline.h b/src/app/tools/nodeDetails/vnodespline.h index ea29108a2..4ae2225f5 100644 --- a/src/app/tools/nodeDetails/vnodespline.h +++ b/src/app/tools/nodeDetails/vnodespline.h @@ -51,6 +51,7 @@ public: virtual void RestoreNode(); virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::NodeSpline)}; + virtual QString getTagName() const; public slots: virtual void FullUpdateFromFile (); protected: diff --git a/src/app/tools/nodeDetails/vnodesplinepath.cpp b/src/app/tools/nodeDetails/vnodesplinepath.cpp index 9451e3f11..5047aea9d 100644 --- a/src/app/tools/nodeDetails/vnodesplinepath.cpp +++ b/src/app/tools/nodeDetails/vnodesplinepath.cpp @@ -130,6 +130,12 @@ void VNodeSplinePath::RestoreNode() } } +//--------------------------------------------------------------------------------------------------------------------- +QString VNodeSplinePath::getTagName() const +{ + return VNodeSplinePath::TagName; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief FullUpdateFromFile update tool data form file. diff --git a/src/app/tools/nodeDetails/vnodesplinepath.h b/src/app/tools/nodeDetails/vnodesplinepath.h index 7be54d734..d92bed5a3 100644 --- a/src/app/tools/nodeDetails/vnodesplinepath.h +++ b/src/app/tools/nodeDetails/vnodesplinepath.h @@ -50,6 +50,7 @@ public: virtual void RestoreNode(); virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::SplinePath)}; + virtual QString getTagName() const; public slots: virtual void FullUpdateFromFile(); protected: diff --git a/src/app/tools/vabstracttool.cpp b/src/app/tools/vabstracttool.cpp index 3dea9ee93..adf2d4f5a 100644 --- a/src/app/tools/vabstracttool.cpp +++ b/src/app/tools/vabstracttool.cpp @@ -32,6 +32,7 @@ #include "../undocommands/deltool.h" #include "../widgets/vapplication.h" #include "../geometry/vpointf.h" +#include "../undocommands/savetooloptions.h" const QString VAbstractTool::AttrType = QStringLiteral("type"); const QString VAbstractTool::AttrMx = QStringLiteral("mx"); @@ -289,11 +290,23 @@ Qt::PenStyle VAbstractTool::LineStyle(const QString &typeLine) break; } } + +//--------------------------------------------------------------------------------------------------------------------- QString VAbstractTool::getLineType() const { return typeLine; } +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractTool::setTypeLine(const QString &value) +{ + typeLine = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); +} + +//--------------------------------------------------------------------------------------------------------------------- QMap VAbstractTool::PointsList() const { const QHash > *objs = data.DataGObjects(); @@ -314,7 +327,6 @@ QMap VAbstractTool::PointsList() const return list; } - //--------------------------------------------------------------------------------------------------------------------- int VAbstractTool::ConfirmDeletion() { @@ -327,6 +339,26 @@ int VAbstractTool::ConfirmDeletion() return msgBox.exec(); } +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractTool::SaveOption(QSharedPointer &obj) +{ + QDomElement oldDomElement = doc->elementById(QString().setNum(id)); + if (oldDomElement.isElement()) + { + QDomElement newDomElement = oldDomElement.cloneNode().toElement(); + + SaveOptions(newDomElement, obj); + + SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, id); + connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VPattern::LiteParseTree); + qApp->getUndoStack()->push(saveOptions); + } + else + { + qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO; + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief LineCoefficients coefficient for equation of segment. Segment equestion ax+by+c=0. diff --git a/src/app/tools/vabstracttool.h b/src/app/tools/vabstracttool.h index b945ec805..210b02480 100644 --- a/src/app/tools/vabstracttool.h +++ b/src/app/tools/vabstracttool.h @@ -102,8 +102,10 @@ public: const VContainer *getData() const; QString getLineType() const; - //void setTypeLine(const QString &value)=0; + void setTypeLine(const QString &value); QMap PointsList() const; + virtual QString getTagName() const =0; + public slots: /** * @brief FullUpdateFromFile update tool data form file. @@ -139,6 +141,7 @@ protected: /** @brief typeLine line type. */ QString typeLine; + /** * @brief AddToFile add tag with informations about tool into file. */ @@ -153,6 +156,8 @@ protected: virtual void RemoveReferens(){} virtual void DeleteTool(bool ask = true); static int ConfirmDeletion(); + void SaveOption(QSharedPointer &obj); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj)=0; private: Q_DISABLE_COPY(VAbstractTool) }; diff --git a/src/app/tools/vtooldetail.cpp b/src/app/tools/vtooldetail.cpp index d93488eaf..010e96b04 100644 --- a/src/app/tools/vtooldetail.cpp +++ b/src/app/tools/vtooldetail.cpp @@ -370,6 +370,12 @@ void VToolDetail::keyReleaseEvent(QKeyEvent *event) QGraphicsItem::keyReleaseEvent ( event ); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolDetail::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief mouseReleaseEvent handle mouse release events. @@ -475,6 +481,12 @@ void VToolDetail::AddNode(VPattern *doc, QDomElement &domElement, const VNodeDet domElement.appendChild(nod); } +//--------------------------------------------------------------------------------------------------------------------- +QString VToolDetail::getTagName() const +{ + return VToolDetail::TagName; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief RefreshGeometry refresh item on scene. diff --git a/src/app/tools/vtooldetail.h b/src/app/tools/vtooldetail.h index cd0c9bec8..3b33c0695 100644 --- a/src/app/tools/vtooldetail.h +++ b/src/app/tools/vtooldetail.h @@ -84,6 +84,7 @@ public: static void AddNode(VPattern *doc, QDomElement &domElement, const VNodeDetail &node); virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::Detail)}; + virtual QString getTagName() const; public slots: virtual void FullUpdateFromFile (); virtual void FullUpdateFromGuiOk(int result); @@ -95,6 +96,7 @@ protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void RemoveReferens(); virtual void keyReleaseEvent(QKeyEvent * event); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: Q_DISABLE_COPY(VToolDetail) /** @brief dialog dialog options. */ diff --git a/src/app/tools/vtooluniondetails.cpp b/src/app/tools/vtooluniondetails.cpp index 76b9dfc7c..a8cbcd6b3 100644 --- a/src/app/tools/vtooluniondetails.cpp +++ b/src/app/tools/vtooluniondetails.cpp @@ -435,6 +435,12 @@ void VToolUnionDetails::BiasRotatePoint(VPointF *point, const qreal &dx, const q point->setY(line.p2().y()); } +//--------------------------------------------------------------------------------------------------------------------- +QString VToolUnionDetails::getTagName() const +{ + return VToolUnionDetails::TagName; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief Create help create tool from GUI. @@ -442,7 +448,8 @@ void VToolUnionDetails::BiasRotatePoint(VPointF *point, const qreal &dx, const q * @param doc dom document container. * @param data container with variables. */ -void VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) +VToolUnionDetails* VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data) { SCASSERT(dialog != nullptr); DialogUnionDetails *dialogTool = qobject_cast(dialog); @@ -452,9 +459,11 @@ void VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VP quint32 indexD1 = static_cast(dialogTool->getIndexD1()); quint32 indexD2 = static_cast(dialogTool->getIndexD2()); qApp->getUndoStack()->beginMacro("union details"); - Create(0, d1, d2, dialogTool->getD1(), dialogTool->getD2(), indexD1, indexD2, scene, doc, data, Document::FullParse, - Source::FromGui); + VToolUnionDetails* tool = nullptr; + tool = Create(0, d1, d2, dialogTool->getD1(), dialogTool->getD2(), indexD1, indexD2, scene, doc, data, + Document::FullParse, Source::FromGui); qApp->getUndoStack()->endMacro(); + return tool; } //--------------------------------------------------------------------------------------------------------------------- @@ -473,10 +482,10 @@ void VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VP * @param parse parser file mode. * @param typeCreation way we create this tool. */ -void VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDetail &d2, const quint32 &d1id, - const quint32 &d2id, const quint32 &indexD1, const quint32 &indexD2, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document &parse, const Source &typeCreation) +VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDetail &d2, + const quint32 &d1id, const quint32 &d2id, const quint32 &indexD1, + const quint32 &indexD2, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation) { VToolUnionDetails *unionDetails = 0; quint32 id = _id; @@ -609,6 +618,7 @@ void VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDeta } } while (i &obj) +{ + +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief AddDetail add detail to xml file. diff --git a/src/app/tools/vtooluniondetails.h b/src/app/tools/vtooluniondetails.h index bc610a0c3..2d4168c55 100644 --- a/src/app/tools/vtooluniondetails.h +++ b/src/app/tools/vtooluniondetails.h @@ -50,11 +50,11 @@ public: * @brief setDialog set dialog when user want change tool option. */ virtual void setDialog() {} - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - static void Create(const quint32 _id, const VDetail &d1, const VDetail &d2, const quint32 &d1id, - const quint32 &d2id, const quint32 &indexD1, const quint32 &indexD2, VMainGraphicsScene *scene, - VPattern *doc, VContainer *data, const Document &parse, - const Source &typeCreation); + static VToolUnionDetails *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolUnionDetails *Create(const quint32 _id, const VDetail &d1, const VDetail &d2, const quint32 &d1id, + const quint32 &d2id, const quint32 &indexD1, const quint32 &indexD2, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); static void PointsOnEdge(const VDetail &d, const quint32 &index, VPointF &p1, VPointF &p2, VContainer *data); static void FindJ(const qint32 &pointsD2, const VDetail &d2, const quint32 &indexD2, qint32 &j); static QVector GetDetailFromFile(VPattern *doc, const QDomElement &domElement); @@ -76,6 +76,7 @@ public: const qreal &angle = 0); static void BiasRotatePoint(VPointF *point, const qreal &dx, const qreal &dy, const QPointF &pRotate, const qreal &angle); + virtual QString getTagName() const; public slots: /** * @brief FullUpdateFromFile update tool data form file. @@ -84,6 +85,7 @@ public slots: protected: virtual void AddToFile(); virtual void RefreshDataInFile(); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: Q_DISABLE_COPY(VToolUnionDetails) /** @brief d1 first detail. */ diff --git a/src/app/widgets/vmaingraphicsview.cpp b/src/app/widgets/vmaingraphicsview.cpp index a11e3b0d9..4a7ef658b 100644 --- a/src/app/widgets/vmaingraphicsview.cpp +++ b/src/app/widgets/vmaingraphicsview.cpp @@ -157,7 +157,7 @@ bool GraphicsViewZoom::eventFilter(QObject *object, QEvent *event) * @param parent parent object. */ VMainGraphicsView::VMainGraphicsView(QWidget *parent) - :QGraphicsView(parent), zoom(nullptr) + :QGraphicsView(parent), zoom(nullptr), showToolOptions(true) { zoom = new GraphicsViewZoom(this); this->setResizeAnchor(QGraphicsView::AnchorUnderMouse); @@ -221,7 +221,10 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress) QGraphicsView::setDragMode(QGraphicsView::ScrollHandDrag); break; case Qt::NoModifier: - emit itemClicked(itemAt(mousePress->pos())); + if (showToolOptions) + { + emit itemClicked(itemAt(mousePress->pos())); + } break; default: break; @@ -244,3 +247,10 @@ void VMainGraphicsView::mouseReleaseEvent(QMouseEvent *event) emit MouseRelease(); } } + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsView::setShowToolOptions(bool value) +{ + showToolOptions = value; +} + diff --git a/src/app/widgets/vmaingraphicsview.h b/src/app/widgets/vmaingraphicsview.h index 8df21f47c..abec4a09e 100644 --- a/src/app/widgets/vmaingraphicsview.h +++ b/src/app/widgets/vmaingraphicsview.h @@ -97,6 +97,8 @@ class VMainGraphicsView : public QGraphicsView public: explicit VMainGraphicsView(QWidget *parent = nullptr); + void setShowToolOptions(bool value); + signals: /** * @brief NewFactor send new scale factor. @@ -120,6 +122,7 @@ protected: void mouseReleaseEvent(QMouseEvent *event); private: GraphicsViewZoom* zoom; + bool showToolOptions; }; #endif // VMAINGRAPHICSVIEW_H diff --git a/src/app/widgets/vtooloptionspropertybrowser.cpp b/src/app/widgets/vtooloptionspropertybrowser.cpp index ac0c877b2..d2ecf97e3 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.cpp +++ b/src/app/widgets/vtooloptionspropertybrowser.cpp @@ -390,7 +390,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolAlongLine(VProperty *property) SetPointName(value.toString()); break; case 6: // VAbstractTool::AttrFirstPoint - i->setFirstPointId(value.toUInt()); + i->setBasePointId(value.toUInt()); break; case 7: // VAbstractTool::AttrSecondPoint i->setSecondPointId(value.toUInt());