diff --git a/src/app/tools/drawTools/vtoolalongline.cpp b/src/app/tools/drawTools/vtoolalongline.cpp index 347745d38..499a08041 100644 --- a/src/app/tools/drawTools/vtoolalongline.cpp +++ b/src/app/tools/drawTools/vtoolalongline.cpp @@ -54,15 +54,7 @@ VToolAlongLine::VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, cons QGraphicsItem *parent) :VToolLinePoint(doc, data, id, typeLine, lineColor, formula, firstPointId, 0, parent), secondPointId(secondPointId) { - - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolarc.cpp b/src/app/tools/drawTools/vtoolarc.cpp index 4a7a48c5c..a405bc0d6 100644 --- a/src/app/tools/drawTools/vtoolarc.cpp +++ b/src/app/tools/drawTools/vtoolarc.cpp @@ -60,14 +60,7 @@ VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const QString &c this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolbisector.cpp b/src/app/tools/drawTools/vtoolbisector.cpp index e3db54b55..9739bad34 100644 --- a/src/app/tools/drawTools/vtoolbisector.cpp +++ b/src/app/tools/drawTools/vtoolbisector.cpp @@ -58,14 +58,7 @@ VToolBisector::VToolBisector(VPattern *doc, VContainer *data, const quint32 &id, this->firstPointId = firstPointId; this->thirdPointId = thirdPointId; - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp b/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp index c0d771cf7..11ffeaafd 100644 --- a/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp +++ b/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp @@ -45,14 +45,7 @@ VToolCurveIntersectAxis::VToolCurveIntersectAxis(VPattern *doc, VContainer *data :VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), formulaAngle(formulaAngle), curveId(curveId) { - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolcutarc.cpp b/src/app/tools/drawTools/vtoolcutarc.cpp index 2cabd8d88..3d9e64184 100644 --- a/src/app/tools/drawTools/vtoolcutarc.cpp +++ b/src/app/tools/drawTools/vtoolcutarc.cpp @@ -57,14 +57,7 @@ VToolCutArc::VToolCutArc(VPattern *doc, VContainer *data, const quint32 &id, con RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint); RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint); - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolcutspline.cpp b/src/app/tools/drawTools/vtoolcutspline.cpp index e2f51df25..184d00cfc 100644 --- a/src/app/tools/drawTools/vtoolcutspline.cpp +++ b/src/app/tools/drawTools/vtoolcutspline.cpp @@ -55,14 +55,7 @@ VToolCutSpline::VToolCutSpline(VPattern *doc, VContainer *data, const quint32 &i RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint); RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint); - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.cpp b/src/app/tools/drawTools/vtoolcutsplinepath.cpp index e2ed31a38..f33ace8bd 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolcutsplinepath.cpp @@ -58,14 +58,7 @@ VToolCutSplinePath::VToolCutSplinePath(VPattern *doc, VContainer *data, const qu RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint); RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint); - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolendline.cpp b/src/app/tools/drawTools/vtoolendline.cpp index eb6ef2a8c..17096ba89 100644 --- a/src/app/tools/drawTools/vtoolendline.cpp +++ b/src/app/tools/drawTools/vtoolendline.cpp @@ -55,14 +55,7 @@ VToolEndLine::VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, :VToolLinePoint(doc, data, id, typeLine, lineColor, formulaLength, basePointId, 0, parent), formulaAngle(formulaAngle) { - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolheight.cpp b/src/app/tools/drawTools/vtoolheight.cpp index 58178eb85..a1efbcdba 100644 --- a/src/app/tools/drawTools/vtoolheight.cpp +++ b/src/app/tools/drawTools/vtoolheight.cpp @@ -52,14 +52,7 @@ VToolHeight::VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, con :VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), p1LineId(p1LineId), p2LineId(p2LineId) { - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolline.cpp b/src/app/tools/drawTools/vtoolline.cpp index cdc174e31..1f0ba0334 100644 --- a/src/app/tools/drawTools/vtoolline.cpp +++ b/src/app/tools/drawTools/vtoolline.cpp @@ -64,14 +64,7 @@ VToolLine::VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstP this->setAcceptHoverEvents(true); this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine))); - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoollineintersect.cpp b/src/app/tools/drawTools/vtoollineintersect.cpp index ae064c7e8..59ba14ccd 100644 --- a/src/app/tools/drawTools/vtoollineintersect.cpp +++ b/src/app/tools/drawTools/vtoollineintersect.cpp @@ -53,14 +53,7 @@ VToolLineIntersect::VToolLineIntersect(VPattern *doc, VContainer *data, const qu :VToolPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2), p2Line2(p2Line2) { - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoollineintersectaxis.cpp b/src/app/tools/drawTools/vtoollineintersectaxis.cpp index 4e0052943..f0904b29a 100644 --- a/src/app/tools/drawTools/vtoollineintersectaxis.cpp +++ b/src/app/tools/drawTools/vtoollineintersectaxis.cpp @@ -45,14 +45,7 @@ VToolLineIntersectAxis::VToolLineIntersectAxis(VPattern *doc, VContainer *data, :VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), formulaAngle(formulaAngle), firstPointId(firstPointId), secondPointId(secondPointId) { - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolnormal.cpp b/src/app/tools/drawTools/vtoolnormal.cpp index 2646ec444..255358430 100644 --- a/src/app/tools/drawTools/vtoolnormal.cpp +++ b/src/app/tools/drawTools/vtoolnormal.cpp @@ -56,14 +56,7 @@ VToolNormal::VToolNormal(VPattern *doc, VContainer *data, const quint32 &id, con secondPointId(secondPointId) { - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolpointofcontact.cpp b/src/app/tools/drawTools/vtoolpointofcontact.cpp index c0606cdb1..47317add0 100644 --- a/src/app/tools/drawTools/vtoolpointofcontact.cpp +++ b/src/app/tools/drawTools/vtoolpointofcontact.cpp @@ -56,14 +56,7 @@ VToolPointOfContact::VToolPointOfContact(VPattern *doc, VContainer *data, const : VToolPoint(doc, data, id, parent), arcRadius(radius), center(center), firstPointId(firstPointId), secondPointId(secondPointId) { - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolpointofintersection.cpp b/src/app/tools/drawTools/vtoolpointofintersection.cpp index 0ce44d59e..36d2dd584 100644 --- a/src/app/tools/drawTools/vtoolpointofintersection.cpp +++ b/src/app/tools/drawTools/vtoolpointofintersection.cpp @@ -49,14 +49,7 @@ VToolPointOfIntersection::VToolPointOfIntersection(VPattern *doc, VContainer *da const Source &typeCreation, QGraphicsItem *parent) :VToolPoint(doc, data, id, parent), firstPointId(firstPointId), secondPointId(secondPointId) { - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolpointofintersectionarcs.cpp b/src/app/tools/drawTools/vtoolpointofintersectionarcs.cpp index d20d33509..56fb30dc5 100644 --- a/src/app/tools/drawTools/vtoolpointofintersectionarcs.cpp +++ b/src/app/tools/drawTools/vtoolpointofintersectionarcs.cpp @@ -41,14 +41,7 @@ VToolPointOfIntersectionArcs::VToolPointOfIntersectionArcs(VPattern *doc, VConta QGraphicsItem *parent) :VToolPoint(doc, data, id, parent), firstArcId(firstArcId), secondArcId(secondArcId), crossPoint(pType) { - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.cpp b/src/app/tools/drawTools/vtoolshoulderpoint.cpp index 12ccaee99..548beecb0 100644 --- a/src/app/tools/drawTools/vtoolshoulderpoint.cpp +++ b/src/app/tools/drawTools/vtoolshoulderpoint.cpp @@ -55,14 +55,7 @@ VToolShoulderPoint::VToolShoulderPoint(VPattern *doc, VContainer *data, const qu :VToolLinePoint(doc, data, id, typeLine, lineColor, formula, p1Line, 0, parent), p2Line(p2Line), pShoulder(pShoulder) { - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolsinglepoint.cpp b/src/app/tools/drawTools/vtoolsinglepoint.cpp index 5a716cdaf..dca90f60c 100644 --- a/src/app/tools/drawTools/vtoolsinglepoint.cpp +++ b/src/app/tools/drawTools/vtoolsinglepoint.cpp @@ -58,14 +58,7 @@ VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id, this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setFlag(QGraphicsItem::ItemIsFocusable, false); SetColorLabel(Qt::black); - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolspline.cpp b/src/app/tools/drawTools/vtoolspline.cpp index 15a319149..4b7c59c25 100644 --- a/src/app/tools/drawTools/vtoolspline.cpp +++ b/src/app/tools/drawTools/vtoolspline.cpp @@ -85,14 +85,7 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const QStr ShowHandles(false); - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolsplinepath.cpp b/src/app/tools/drawTools/vtoolsplinepath.cpp index 54c4f061c..c41a6b35d 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolsplinepath.cpp @@ -87,14 +87,7 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co ShowHandles(false); - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtooltriangle.cpp b/src/app/tools/drawTools/vtooltriangle.cpp index 16f6a98a2..7c58cfd39 100644 --- a/src/app/tools/drawTools/vtooltriangle.cpp +++ b/src/app/tools/drawTools/vtooltriangle.cpp @@ -53,14 +53,7 @@ VToolTriangle::VToolTriangle(VPattern *doc, VContainer *data, const quint32 &id, :VToolPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId), secondPointId(secondPointId) { - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/nodeDetails/vnodearc.cpp b/src/app/tools/nodeDetails/vnodearc.cpp index 1cd77c329..23158b6da 100644 --- a/src/app/tools/nodeDetails/vnodearc.cpp +++ b/src/app/tools/nodeDetails/vnodearc.cpp @@ -55,14 +55,7 @@ VNodeArc::VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, c RefreshGeometry(); this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine()))); - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/nodeDetails/vnodepoint.cpp b/src/app/tools/nodeDetails/vnodepoint.cpp index 84e5dd07d..c080edf5c 100644 --- a/src/app/tools/nodeDetails/vnodepoint.cpp +++ b/src/app/tools/nodeDetails/vnodepoint.cpp @@ -65,14 +65,7 @@ VNodePoint::VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPo this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setAcceptHoverEvents(true); RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/nodeDetails/vnodespline.cpp b/src/app/tools/nodeDetails/vnodespline.cpp index 69f0de630..ce231ed51 100644 --- a/src/app/tools/nodeDetails/vnodespline.cpp +++ b/src/app/tools/nodeDetails/vnodespline.cpp @@ -56,14 +56,7 @@ VNodeSpline::VNodeSpline(VPattern *doc, VContainer *data, quint32 id, quint32 id RefreshGeometry(); this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine()))); - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/nodeDetails/vnodesplinepath.cpp b/src/app/tools/nodeDetails/vnodesplinepath.cpp index 87c9c91e8..c3aac3c0c 100644 --- a/src/app/tools/nodeDetails/vnodesplinepath.cpp +++ b/src/app/tools/nodeDetails/vnodesplinepath.cpp @@ -56,14 +56,7 @@ VNodeSplinePath::VNodeSplinePath(VPattern *doc, VContainer *data, quint32 id, qu RefreshGeometry(); this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine()))); - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/vabstracttool.cpp b/src/app/tools/vabstracttool.cpp index e62120f5d..d9ae938dc 100644 --- a/src/app/tools/vabstracttool.cpp +++ b/src/app/tools/vabstracttool.cpp @@ -351,6 +351,19 @@ void VAbstractTool::SaveOption(QSharedPointer &obj) } } +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractTool::ToolCreation(const Source &typeCreation) +{ + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief Styles return list of all line styles. diff --git a/src/app/tools/vabstracttool.h b/src/app/tools/vabstracttool.h index 0b9dc83ed..8f7241465 100644 --- a/src/app/tools/vabstracttool.h +++ b/src/app/tools/vabstracttool.h @@ -186,6 +186,7 @@ protected: } virtual void SetVisualization()=0; + void ToolCreation(const Source &typeCreation); private: Q_DISABLE_COPY(VAbstractTool) }; diff --git a/src/app/tools/vtooluniondetails.cpp b/src/app/tools/vtooluniondetails.cpp index e1f6796ad..11a8dd615 100644 --- a/src/app/tools/vtooluniondetails.cpp +++ b/src/app/tools/vtooluniondetails.cpp @@ -64,14 +64,7 @@ VToolUnionDetails::VToolUnionDetails(VPattern *doc, VContainer *data, const quin const Source &typeCreation, QObject *parent) :VAbstractTool(doc, data, id, parent), d1(d1), d2(d2), indexD1(indexD1), indexD2(indexD2) { - if (typeCreation == Source::FromGui) - { - AddToFile(); - } - else - { - RefreshDataInFile(); - } + ToolCreation(typeCreation); } //---------------------------------------------------------------------------------------------------------------------