From 933e63d1032b00010e9b70ad95fcc9865c7895bb Mon Sep 17 00:00:00 2001 From: dismine Date: Fri, 25 Jul 2014 14:53:39 +0300 Subject: [PATCH] Added new contructor for VPointF. --HG-- branch : develop --- src/app/geometry/vgobject.h | 28 ++++++++-------- src/app/geometry/vpointf.cpp | 25 ++++++++++---- src/app/geometry/vpointf.h | 33 ++++++++++--------- src/app/geometry/vsplinepath.cpp | 3 +- src/app/geometry/vsplinepath.h | 6 ++++ src/app/tools/drawTools/vtoolalongline.cpp | 4 +-- src/app/tools/drawTools/vtoolbisector.cpp | 4 +-- src/app/tools/drawTools/vtoolcutarc.cpp | 4 +-- src/app/tools/drawTools/vtoolcutspline.cpp | 4 +-- .../tools/drawTools/vtoolcutsplinepath.cpp | 2 +- src/app/tools/drawTools/vtoolendline.cpp | 4 +-- src/app/tools/drawTools/vtoolheight.cpp | 4 +-- .../tools/drawTools/vtoollineintersect.cpp | 4 +-- src/app/tools/drawTools/vtoolnormal.cpp | 4 +-- .../tools/drawTools/vtoolpointofcontact.cpp | 4 +-- .../drawTools/vtoolpointofintersection.cpp | 4 +-- .../tools/drawTools/vtoolshoulderpoint.cpp | 4 +-- src/app/tools/drawTools/vtooltriangle.cpp | 4 +-- src/app/tools/vtooluniondetails.cpp | 4 +-- src/app/xml/vpattern.cpp | 2 +- 20 files changed, 85 insertions(+), 66 deletions(-) diff --git a/src/app/geometry/vgobject.h b/src/app/geometry/vgobject.h index 83c48aafa..d7993931c 100644 --- a/src/app/geometry/vgobject.h +++ b/src/app/geometry/vgobject.h @@ -46,30 +46,30 @@ public: VGObject(const VGObject &obj); VGObject& operator= (const VGObject &obj); virtual ~VGObject(){} - quint32 getIdObject() const; - void setIdObject(const quint32 &value); - virtual QString name() const; - void setName(const QString &name); - Draw getMode() const; - void setMode(const Draw &value); - GOType getType() const; - quint32 id() const; - virtual void setId(const quint32 &id); + quint32 getIdObject() const; + void setIdObject(const quint32 &value); + virtual QString name() const; + void setName(const QString &name); + Draw getMode() const; + void setMode(const Draw &value); + GOType getType() const; + quint32 id() const; + virtual void setId(const quint32 &id); protected: /** @brief _id id in container. Ned for arcs, spline and spline paths. */ - quint32 _id; + quint32 _id; /** @brief type type of graphical object */ - GOType type; + GOType type; /** @brief idObject id of parent object. Only for modeling. All another return 0. */ - quint32 idObject; + quint32 idObject; /** @brief _name object name */ - QString _name; + QString _name; /** @brief mode object created in calculation or drawing mode */ - Draw mode; + Draw mode; }; #endif // VGOBJECT_H diff --git a/src/app/geometry/vpointf.cpp b/src/app/geometry/vpointf.cpp index dfc80a326..61be19c7e 100644 --- a/src/app/geometry/vpointf.cpp +++ b/src/app/geometry/vpointf.cpp @@ -35,15 +35,30 @@ * @brief VPointF create new point * @param x x coordinate * @param y y coordinate + * @param name point label * @param mx offset name respect to x * @param my offset name respect to y */ -VPointF::VPointF(qreal x, qreal y, QString name, qreal mx, qreal my, quint32 idObject, Draw mode) +VPointF::VPointF(qreal x, qreal y, const QString &name, qreal mx, qreal my, quint32 idObject, const Draw &mode) :VGObject(GOType::Point, idObject, mode), _mx(mx), _my(my), _x(x), _y(y) { this->_name = name; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VPointF create new point + * @param point point + * @param name point label + * @param mx offset name respect to x + * @param my offset name respect to y + */ +VPointF::VPointF(const QPointF &point, const QString &name, qreal mx, qreal my, quint32 idObject, const Draw &mode) + :VGObject(GOType::Point, idObject, mode), _mx(mx), _my(my), _x(point.x()), _y(point.y()) +{ + this->_name = name; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VPointF creat empty point @@ -59,6 +74,8 @@ VPointF::VPointF(const VPointF &point) :VGObject(point), _mx(point.mx()), _my(po VPointF::VPointF(const QPointF &point) :VGObject(VPointF()), _mx(0), _my(0), _x(point.x()), _y(point.y()) {} + + //--------------------------------------------------------------------------------------------------------------------- /** * @brief operator = assignment operator @@ -75,12 +92,6 @@ VPointF &VPointF::operator =(const VPointF &point) return *this; } -//--------------------------------------------------------------------------------------------------------------------- -QString VPointF::name() const -{ - return _name; -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief toQPointF convert to QPointF diff --git a/src/app/geometry/vpointf.h b/src/app/geometry/vpointf.h index 942525ae9..56d92f7ec 100644 --- a/src/app/geometry/vpointf.h +++ b/src/app/geometry/vpointf.h @@ -43,32 +43,33 @@ public: VPointF (); VPointF (const VPointF &point ); VPointF (const QPointF &point ); - VPointF ( qreal x, qreal y, QString name, qreal mx, qreal my, quint32 idObject = 0, - Draw mode = Draw::Calculation); + VPointF (qreal x, qreal y, const QString &name, qreal mx, qreal my, quint32 idObject = 0, + const Draw &mode = Draw::Calculation); + VPointF (const QPointF &point, const QString &name, qreal mx, qreal my, quint32 idObject = 0, + const Draw &mode = Draw::Calculation); virtual ~VPointF(){} VPointF &operator=(const VPointF &point); - qreal mx() const; - qreal my() const; - void setMx(qreal mx); - void setMy(qreal my); - QPointF toQPointF()const; - qreal x() const; - void setX(const qreal &value); - qreal y() const; - void setY(const qreal &value); - virtual QString name() const; + qreal mx() const; + qreal my() const; + void setMx(qreal mx); + void setMy(qreal my); + QPointF toQPointF()const; + qreal x() const; + void setX(const qreal &value); + qreal y() const; + void setY(const qreal &value); private: /** @brief _mx offset name respect to x */ - qreal _mx; + qreal _mx; /** @brief _my offset name respect to y */ - qreal _my; + qreal _my; /** @brief _x x coordinate */ - qreal _x; + qreal _x; /** @brief _y y coordinate */ - qreal _y; + qreal _y; }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/geometry/vsplinepath.cpp b/src/app/geometry/vsplinepath.cpp index 34235d7dc..aa8d00ab1 100644 --- a/src/app/geometry/vsplinepath.cpp +++ b/src/app/geometry/vsplinepath.cpp @@ -31,7 +31,8 @@ //--------------------------------------------------------------------------------------------------------------------- VSplinePath::VSplinePath(qreal kCurve, quint32 idObject, Draw mode) - : VAbstractCurve(GOType::SplinePath, idObject, mode), path(QVector()), kCurve(kCurve), maxCountPoints(0) + : VAbstractCurve(GOType::SplinePath, idObject, mode), path(QVector()), kCurve(kCurve), + maxCountPoints(0) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/geometry/vsplinepath.h b/src/app/geometry/vsplinepath.h index 3d22c88bd..6ac82058d 100644 --- a/src/app/geometry/vsplinepath.h +++ b/src/app/geometry/vsplinepath.h @@ -199,31 +199,37 @@ protected: qint32 maxCountPoints; }; +//--------------------------------------------------------------------------------------------------------------------- inline qint32 VSplinePath::CountPoint() const { return path.size(); } +//--------------------------------------------------------------------------------------------------------------------- inline QVector VSplinePath::GetSplinePath() const { return path; } +//--------------------------------------------------------------------------------------------------------------------- inline void VSplinePath::Clear() { path.clear(); } +//--------------------------------------------------------------------------------------------------------------------- inline qreal VSplinePath::getKCurve() const { return kCurve; } +//--------------------------------------------------------------------------------------------------------------------- inline void VSplinePath::setKCurve(const qreal &value) { kCurve = value; } +//--------------------------------------------------------------------------------------------------------------------- inline const QVector *VSplinePath::GetPoint() const { return &path; diff --git a/src/app/tools/drawTools/vtoolalongline.cpp b/src/app/tools/drawTools/vtoolalongline.cpp index 871d1a433..74f0c37b0 100644 --- a/src/app/tools/drawTools/vtoolalongline.cpp +++ b/src/app/tools/drawTools/vtoolalongline.cpp @@ -258,13 +258,13 @@ VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointNa quint32 id = _id; if (typeCreation == Source::FromGui) { - id = data->AddGObject( new VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); + id = data->AddGObject( new VPointF(line.p2(), pointName, mx, my)); data->AddLine(firstPointId, id); data->AddLine(id, secondPointId); } else { - data->UpdateGObject(id, new VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); + data->UpdateGObject(id, new VPointF(line.p2(), pointName, mx, my)); data->AddLine(firstPointId, id); data->AddLine(id, secondPointId); if (parse != Document::FullParse) diff --git a/src/app/tools/drawTools/vtoolbisector.cpp b/src/app/tools/drawTools/vtoolbisector.cpp index 31edd4178..b11231fea 100644 --- a/src/app/tools/drawTools/vtoolbisector.cpp +++ b/src/app/tools/drawTools/vtoolbisector.cpp @@ -183,12 +183,12 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const quint32 id = _id; if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); + id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); data->AddLine(firstPointId, id); } else { - data->UpdateGObject(id, new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); + data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); data->AddLine(firstPointId, id); if (parse != Document::FullParse) { diff --git a/src/app/tools/drawTools/vtoolcutarc.cpp b/src/app/tools/drawTools/vtoolcutarc.cpp index 07f635a0c..591d65395 100644 --- a/src/app/tools/drawTools/vtoolcutarc.cpp +++ b/src/app/tools/drawTools/vtoolcutarc.cpp @@ -138,7 +138,7 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS quint32 arc2id = 0; if (typeCreation == Source::FromGui) { - VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my); + VPointF *p = new VPointF(point, pointName, mx, my); id = data->AddGObject(p); VArc * ar1 = new VArc(arc1); @@ -149,7 +149,7 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS } else { - VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my); + VPointF *p = new VPointF(point, pointName, mx, my); data->UpdateGObject(id, p); arc1id = id + 1; diff --git a/src/app/tools/drawTools/vtoolcutspline.cpp b/src/app/tools/drawTools/vtoolcutspline.cpp index 2f8b29770..b29e4dd0a 100644 --- a/src/app/tools/drawTools/vtoolcutspline.cpp +++ b/src/app/tools/drawTools/vtoolcutspline.cpp @@ -131,7 +131,7 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString quint32 spl2id = 0; if (typeCreation == Source::FromGui) { - VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my); + VPointF *p = new VPointF(point, pointName, mx, my); id = data->AddGObject(p); VSpline *spline1 = new VSpline(spl->GetP1(), spl1p2, spl1p3, *p, spl->GetKcurve()); @@ -144,7 +144,7 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString } else { - VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my); + VPointF *p = new VPointF(point, pointName, mx, my); data->UpdateGObject(id, p); spl1id = id + 1; diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.cpp b/src/app/tools/drawTools/vtoolcutsplinepath.cpp index 82a988f91..57e79ba62 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolcutsplinepath.cpp @@ -132,7 +132,7 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt qint32 p1 = 0, p2 = 0; const QPointF point = splPath->CutSplinePath(qApp->toPixel(result), p1, p2, spl1p2, spl1p3, spl2p2, spl2p3); - VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my); + VPointF *p = new VPointF(point, pointName, mx, my); if (typeCreation == Source::FromGui) { id = data->AddGObject(p); diff --git a/src/app/tools/drawTools/vtoolendline.cpp b/src/app/tools/drawTools/vtoolendline.cpp index 0fe997ebd..878b81a05 100644 --- a/src/app/tools/drawTools/vtoolendline.cpp +++ b/src/app/tools/drawTools/vtoolendline.cpp @@ -143,12 +143,12 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, quint32 id = _id; if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); + id = data->AddGObject(new VPointF(line.p2(), pointName, mx, my)); data->AddLine(basePointId, id); } else { - data->UpdateGObject(id, new VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); + data->UpdateGObject(id, new VPointF(line.p2(), pointName, mx, my)); data->AddLine(basePointId, id); if (parse != Document::FullParse) { diff --git a/src/app/tools/drawTools/vtoolheight.cpp b/src/app/tools/drawTools/vtoolheight.cpp index 1a26c392e..0009826cf 100644 --- a/src/app/tools/drawTools/vtoolheight.cpp +++ b/src/app/tools/drawTools/vtoolheight.cpp @@ -132,14 +132,14 @@ void VToolHeight::Create(const quint32 _id, const QString &pointName, const QStr quint32 id = _id; if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(pHeight.x(), pHeight.y(), pointName, mx, my)); + id = data->AddGObject(new VPointF(pHeight, pointName, mx, my)); data->AddLine(basePointId, id); data->AddLine(p1LineId, id); data->AddLine(p2LineId, id); } else { - data->UpdateGObject(id, new VPointF(pHeight.x(), pHeight.y(), pointName, mx, my)); + data->UpdateGObject(id, new VPointF(pHeight, pointName, mx, my)); data->AddLine(basePointId, id); data->AddLine(p1LineId, id); data->AddLine(p2LineId, id); diff --git a/src/app/tools/drawTools/vtoollineintersect.cpp b/src/app/tools/drawTools/vtoollineintersect.cpp index 36a98e11f..65a75940a 100644 --- a/src/app/tools/drawTools/vtoollineintersect.cpp +++ b/src/app/tools/drawTools/vtoollineintersect.cpp @@ -139,7 +139,7 @@ void VToolLineIntersect::Create(const quint32 _id, const quint32 &p1Line1Id, con quint32 id = _id; if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); + id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); data->AddLine(p1Line1Id, id); data->AddLine(id, p2Line1Id); data->AddLine(p1Line2Id, id); @@ -147,7 +147,7 @@ void VToolLineIntersect::Create(const quint32 _id, const quint32 &p1Line1Id, con } else { - data->UpdateGObject(id, new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); + data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); data->AddLine(p1Line1Id, id); data->AddLine(id, p2Line1Id); data->AddLine(p1Line2Id, id); diff --git a/src/app/tools/drawTools/vtoolnormal.cpp b/src/app/tools/drawTools/vtoolnormal.cpp index 1f9c14584..3fbdf754e 100644 --- a/src/app/tools/drawTools/vtoolnormal.cpp +++ b/src/app/tools/drawTools/vtoolnormal.cpp @@ -145,12 +145,12 @@ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quin quint32 id = _id; if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); + id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); data->AddLine(firstPointId, id); } else { - data->UpdateGObject(id, new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); + data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); data->AddLine(firstPointId, id); if (parse != Document::FullParse) { diff --git a/src/app/tools/drawTools/vtoolpointofcontact.cpp b/src/app/tools/drawTools/vtoolpointofcontact.cpp index 2cb9d1e31..a1b4dd096 100644 --- a/src/app/tools/drawTools/vtoolpointofcontact.cpp +++ b/src/app/tools/drawTools/vtoolpointofcontact.cpp @@ -178,14 +178,14 @@ VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &rad quint32 id = _id; if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); + id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); data->AddLine(firstPointId, id); data->AddLine(secondPointId, id); data->AddLine(center, id); } else { - data->UpdateGObject(id, new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); + data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); data->AddLine(firstPointId, id); data->AddLine(secondPointId, id); data->AddLine(center, id); diff --git a/src/app/tools/drawTools/vtoolpointofintersection.cpp b/src/app/tools/drawTools/vtoolpointofintersection.cpp index 2df07fe28..a9ec943ba 100644 --- a/src/app/tools/drawTools/vtoolpointofintersection.cpp +++ b/src/app/tools/drawTools/vtoolpointofintersection.cpp @@ -121,11 +121,11 @@ void VToolPointOfIntersection::Create(const quint32 _id, const QString &pointNam quint32 id = _id; if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(point.x(), point.y(), pointName, mx, my)); + id = data->AddGObject(new VPointF(point, pointName, mx, my)); } else { - data->UpdateGObject(id, new VPointF(point.x(), point.y(), pointName, mx, my)); + data->UpdateGObject(id, new VPointF(point, pointName, mx, my)); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.cpp b/src/app/tools/drawTools/vtoolshoulderpoint.cpp index de415aede..ee44b8d15 100644 --- a/src/app/tools/drawTools/vtoolshoulderpoint.cpp +++ b/src/app/tools/drawTools/vtoolshoulderpoint.cpp @@ -183,13 +183,13 @@ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formu quint32 id = _id; if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); + id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); data->AddLine(p1Line, id); data->AddLine(p2Line, id); } else { - data->UpdateGObject(id, new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); + data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); data->AddLine(p1Line, id); data->AddLine(p2Line, id); if (parse != Document::FullParse) diff --git a/src/app/tools/drawTools/vtooltriangle.cpp b/src/app/tools/drawTools/vtooltriangle.cpp index 42974d5b7..1d82f20a8 100644 --- a/src/app/tools/drawTools/vtooltriangle.cpp +++ b/src/app/tools/drawTools/vtooltriangle.cpp @@ -133,11 +133,11 @@ void VToolTriangle::Create(const quint32 _id, const QString &pointName, const qu quint32 id = _id; if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(point.x(), point.y(), pointName, mx, my)); + id = data->AddGObject(new VPointF(point, pointName, mx, my)); } else { - data->UpdateGObject(id, new VPointF(point.x(), point.y(), pointName, mx, my)); + data->UpdateGObject(id, new VPointF(point, pointName, mx, my)); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); diff --git a/src/app/tools/vtooluniondetails.cpp b/src/app/tools/vtooluniondetails.cpp index 1bb5e2f14..93a046b4b 100644 --- a/src/app/tools/vtooluniondetails.cpp +++ b/src/app/tools/vtooluniondetails.cpp @@ -125,9 +125,9 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer else { const VArc *arc = data->GeometricObject(det.at(i).getId()); - VPointF p1 = VPointF(arc->GetP1().x(), arc->GetP1().y(), "A", 0, 0); + VPointF p1 = VPointF(arc->GetP1(), "A", 0, 0); BiasRotatePoint(&p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); - VPointF p2 = VPointF(arc->GetP2().x(), arc->GetP2().y(), "A", 0, 0); + VPointF p2 = VPointF(arc->GetP2(), "A", 0, 0); BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); VPointF *center = new VPointF(arc->GetCenter()); BiasRotatePoint(center, dx, dy, data->GeometricObject(pRotate)->toQPointF(), diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index 0205c083f..82114b904 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -1277,7 +1277,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0"); const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0"); const VPointF *point = data->GeometricObject(idObject ); - data->UpdateGObject(id, new VPointF(point->x(), point->y(), point->name(), mx, my, idObject, + data->UpdateGObject(id, new VPointF(point->toQPointF(), point->name(), mx, my, idObject, Draw::Modeling)); VNodePoint::Create(this, data, id, idObject, parse, Source::FromFile, idTool); }