From 162794c70b1d4d627cfef23dafae6bdc17a09ec2 Mon Sep 17 00:00:00 2001 From: dismine Date: Mon, 1 Sep 2014 17:47:44 +0300 Subject: [PATCH] Setter and getter for options VToolBisector. --HG-- branch : feature --- src/app/options.h | 4 ++- src/app/tools/drawTools/vtoolalongline.cpp | 9 ++++-- src/app/tools/drawTools/vtoolarc.cpp | 13 +++++--- src/app/tools/drawTools/vtoolbisector.cpp | 37 ++++++++++++++++++++++ src/app/tools/drawTools/vtoolbisector.h | 7 ++++ 5 files changed, 61 insertions(+), 9 deletions(-) diff --git a/src/app/options.h b/src/app/options.h index e2a2a7d4d..364068ddf 100644 --- a/src/app/options.h +++ b/src/app/options.h @@ -37,9 +37,11 @@ class QString; +static const quint32 null_id = 0; + #define SceneSize 50000 #define DefPointRadius 2.0//mm -#define NULL_ID 0//use this value for initialization variables that keeps id values. 0 mean uknown id value. +#define NULL_ID null_id//use this value for initialization variables that keeps id values. 0 mean uknown id value. enum class SceneObject : char { Point, Line, Spline, Arc, SplinePath, Detail, Unknown }; enum class Tool : unsigned char diff --git a/src/app/tools/drawTools/vtoolalongline.cpp b/src/app/tools/drawTools/vtoolalongline.cpp index 0fe0eb783..a8785b98a 100644 --- a/src/app/tools/drawTools/vtoolalongline.cpp +++ b/src/app/tools/drawTools/vtoolalongline.cpp @@ -166,10 +166,13 @@ quint32 VToolAlongLine::getSecondPointId() const //--------------------------------------------------------------------------------------------------------------------- void VToolAlongLine::setSecondPointId(const quint32 &value) { - secondPointId = value; + if (value != NULL_ID) + { + secondPointId = value; - QSharedPointer obj = VAbstractTool::data.GetGObject(id); - SaveOption(obj); + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolarc.cpp b/src/app/tools/drawTools/vtoolarc.cpp index 6a5b1f625..5b22e6a92 100644 --- a/src/app/tools/drawTools/vtoolarc.cpp +++ b/src/app/tools/drawTools/vtoolarc.cpp @@ -184,12 +184,15 @@ quint32 VToolArc::getCenter() const //--------------------------------------------------------------------------------------------------------------------- void VToolArc::setCenter(const quint32 &value) { - QSharedPointer obj = VAbstractTool::data.GetGObject(id); - QSharedPointer arc = qSharedPointerDynamicCast(obj); + if (value != NULL_ID) + { + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + QSharedPointer arc = qSharedPointerDynamicCast(obj); - QSharedPointer point = VAbstractTool::data.GeometricObject(value); - arc->SetCenter(*point.data()); - SaveOption(obj); + QSharedPointer point = VAbstractTool::data.GeometricObject(value); + arc->SetCenter(*point.data()); + SaveOption(obj); + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolbisector.cpp b/src/app/tools/drawTools/vtoolbisector.cpp index 7f25bde4d..cd4f9eee6 100644 --- a/src/app/tools/drawTools/vtoolbisector.cpp +++ b/src/app/tools/drawTools/vtoolbisector.cpp @@ -309,3 +309,40 @@ void VToolBisector::SaveOptions(QDomElement &tag, QSharedPointer &obj) doc->SetAttribute(tag, AttrSecondPoint, basePointId); doc->SetAttribute(tag, AttrThirdPoint, thirdPointId); } + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolBisector::getThirdPointId() const +{ + return thirdPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolBisector::setThirdPointId(const quint32 &value) +{ + if (value != NULL_ID) + { + thirdPointId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolBisector::getFirstPointId() const +{ + return firstPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolBisector::setFirstPointId(const quint32 &value) +{ + if (value != NULL_ID) + { + firstPointId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + diff --git a/src/app/tools/drawTools/vtoolbisector.h b/src/app/tools/drawTools/vtoolbisector.h index 8bc7bd0e5..c0cee1b78 100644 --- a/src/app/tools/drawTools/vtoolbisector.h +++ b/src/app/tools/drawTools/vtoolbisector.h @@ -55,6 +55,13 @@ public: static const QString ToolType; virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::Bisector)}; + + quint32 getFirstPointId() const; + void setFirstPointId(const quint32 &value); + + quint32 getThirdPointId() const; + void setThirdPointId(const quint32 &value); + public slots: virtual void FullUpdateFromFile(); virtual void SetFactor(qreal factor);