Added new contructor for VPointF.

--HG--
branch : develop
This commit is contained in:
dismine 2014-07-25 14:53:39 +03:00
parent ccbdff7fb5
commit 933e63d103
20 changed files with 85 additions and 66 deletions

View File

@ -46,30 +46,30 @@ public:
VGObject(const VGObject &obj); VGObject(const VGObject &obj);
VGObject& operator= (const VGObject &obj); VGObject& operator= (const VGObject &obj);
virtual ~VGObject(){} virtual ~VGObject(){}
quint32 getIdObject() const; quint32 getIdObject() const;
void setIdObject(const quint32 &value); void setIdObject(const quint32 &value);
virtual QString name() const; virtual QString name() const;
void setName(const QString &name); void setName(const QString &name);
Draw getMode() const; Draw getMode() const;
void setMode(const Draw &value); void setMode(const Draw &value);
GOType getType() const; GOType getType() const;
quint32 id() const; quint32 id() const;
virtual void setId(const quint32 &id); virtual void setId(const quint32 &id);
protected: protected:
/** @brief _id id in container. Ned for arcs, spline and spline paths. */ /** @brief _id id in container. Ned for arcs, spline and spline paths. */
quint32 _id; quint32 _id;
/** @brief type type of graphical object */ /** @brief type type of graphical object */
GOType type; GOType type;
/** @brief idObject id of parent object. Only for modeling. All another return 0. */ /** @brief idObject id of parent object. Only for modeling. All another return 0. */
quint32 idObject; quint32 idObject;
/** @brief _name object name */ /** @brief _name object name */
QString _name; QString _name;
/** @brief mode object created in calculation or drawing mode */ /** @brief mode object created in calculation or drawing mode */
Draw mode; Draw mode;
}; };
#endif // VGOBJECT_H #endif // VGOBJECT_H

View File

@ -35,15 +35,30 @@
* @brief VPointF create new point * @brief VPointF create new point
* @param x x coordinate * @param x x coordinate
* @param y y coordinate * @param y y coordinate
* @param name point label
* @param mx offset name respect to x * @param mx offset name respect to x
* @param my offset name respect to y * @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) :VGObject(GOType::Point, idObject, mode), _mx(mx), _my(my), _x(x), _y(y)
{ {
this->_name = name; 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 * @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()) VPointF::VPointF(const QPointF &point) :VGObject(VPointF()), _mx(0), _my(0), _x(point.x()), _y(point.y())
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief operator = assignment operator * @brief operator = assignment operator
@ -75,12 +92,6 @@ VPointF &VPointF::operator =(const VPointF &point)
return *this; return *this;
} }
//---------------------------------------------------------------------------------------------------------------------
QString VPointF::name() const
{
return _name;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief toQPointF convert to QPointF * @brief toQPointF convert to QPointF

View File

@ -43,32 +43,33 @@ public:
VPointF (); VPointF ();
VPointF (const VPointF &point ); VPointF (const VPointF &point );
VPointF (const QPointF &point ); VPointF (const QPointF &point );
VPointF ( qreal x, qreal y, QString name, qreal mx, qreal my, quint32 idObject = 0, VPointF (qreal x, qreal y, const QString &name, qreal mx, qreal my, quint32 idObject = 0,
Draw mode = Draw::Calculation); 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(){} virtual ~VPointF(){}
VPointF &operator=(const VPointF &point); VPointF &operator=(const VPointF &point);
qreal mx() const; qreal mx() const;
qreal my() const; qreal my() const;
void setMx(qreal mx); void setMx(qreal mx);
void setMy(qreal my); void setMy(qreal my);
QPointF toQPointF()const; QPointF toQPointF()const;
qreal x() const; qreal x() const;
void setX(const qreal &value); void setX(const qreal &value);
qreal y() const; qreal y() const;
void setY(const qreal &value); void setY(const qreal &value);
virtual QString name() const;
private: private:
/** @brief _mx offset name respect to x */ /** @brief _mx offset name respect to x */
qreal _mx; qreal _mx;
/** @brief _my offset name respect to y */ /** @brief _my offset name respect to y */
qreal _my; qreal _my;
/** @brief _x x coordinate */ /** @brief _x x coordinate */
qreal _x; qreal _x;
/** @brief _y y coordinate */ /** @brief _y y coordinate */
qreal _y; qreal _y;
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -31,7 +31,8 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSplinePath::VSplinePath(qreal kCurve, quint32 idObject, Draw mode) VSplinePath::VSplinePath(qreal kCurve, quint32 idObject, Draw mode)
: VAbstractCurve(GOType::SplinePath, idObject, mode), path(QVector<VSplinePoint>()), kCurve(kCurve), maxCountPoints(0) : VAbstractCurve(GOType::SplinePath, idObject, mode), path(QVector<VSplinePoint>()), kCurve(kCurve),
maxCountPoints(0)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -199,31 +199,37 @@ protected:
qint32 maxCountPoints; qint32 maxCountPoints;
}; };
//---------------------------------------------------------------------------------------------------------------------
inline qint32 VSplinePath::CountPoint() const inline qint32 VSplinePath::CountPoint() const
{ {
return path.size(); return path.size();
} }
//---------------------------------------------------------------------------------------------------------------------
inline QVector<VSplinePoint> VSplinePath::GetSplinePath() const inline QVector<VSplinePoint> VSplinePath::GetSplinePath() const
{ {
return path; return path;
} }
//---------------------------------------------------------------------------------------------------------------------
inline void VSplinePath::Clear() inline void VSplinePath::Clear()
{ {
path.clear(); path.clear();
} }
//---------------------------------------------------------------------------------------------------------------------
inline qreal VSplinePath::getKCurve() const inline qreal VSplinePath::getKCurve() const
{ {
return kCurve; return kCurve;
} }
//---------------------------------------------------------------------------------------------------------------------
inline void VSplinePath::setKCurve(const qreal &value) inline void VSplinePath::setKCurve(const qreal &value)
{ {
kCurve = value; kCurve = value;
} }
//---------------------------------------------------------------------------------------------------------------------
inline const QVector<VSplinePoint> *VSplinePath::GetPoint() const inline const QVector<VSplinePoint> *VSplinePath::GetPoint() const
{ {
return &path; return &path;

View File

@ -258,13 +258,13 @@ VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointNa
quint32 id = _id; quint32 id = _id;
if (typeCreation == Source::FromGui) 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(firstPointId, id);
data->AddLine(id, secondPointId); data->AddLine(id, secondPointId);
} }
else 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(firstPointId, id);
data->AddLine(id, secondPointId); data->AddLine(id, secondPointId);
if (parse != Document::FullParse) if (parse != Document::FullParse)

View File

@ -183,12 +183,12 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const
quint32 id = _id; quint32 id = _id;
if (typeCreation == Source::FromGui) 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(firstPointId, id);
} }
else 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(firstPointId, id);
if (parse != Document::FullParse) if (parse != Document::FullParse)
{ {

View File

@ -138,7 +138,7 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS
quint32 arc2id = 0; quint32 arc2id = 0;
if (typeCreation == Source::FromGui) 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); id = data->AddGObject(p);
VArc * ar1 = new VArc(arc1); VArc * ar1 = new VArc(arc1);
@ -149,7 +149,7 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS
} }
else else
{ {
VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my); VPointF *p = new VPointF(point, pointName, mx, my);
data->UpdateGObject(id, p); data->UpdateGObject(id, p);
arc1id = id + 1; arc1id = id + 1;

View File

@ -131,7 +131,7 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString
quint32 spl2id = 0; quint32 spl2id = 0;
if (typeCreation == Source::FromGui) 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); id = data->AddGObject(p);
VSpline *spline1 = new VSpline(spl->GetP1(), spl1p2, spl1p3, *p, spl->GetKcurve()); 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 else
{ {
VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my); VPointF *p = new VPointF(point, pointName, mx, my);
data->UpdateGObject(id, p); data->UpdateGObject(id, p);
spl1id = id + 1; spl1id = id + 1;

View File

@ -132,7 +132,7 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt
qint32 p1 = 0, p2 = 0; qint32 p1 = 0, p2 = 0;
const QPointF point = splPath->CutSplinePath(qApp->toPixel(result), p1, p2, spl1p2, spl1p3, spl2p2, spl2p3); 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) if (typeCreation == Source::FromGui)
{ {
id = data->AddGObject(p); id = data->AddGObject(p);

View File

@ -143,12 +143,12 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName,
quint32 id = _id; quint32 id = _id;
if (typeCreation == Source::FromGui) 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); data->AddLine(basePointId, id);
} }
else 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); data->AddLine(basePointId, id);
if (parse != Document::FullParse) if (parse != Document::FullParse)
{ {

View File

@ -132,14 +132,14 @@ void VToolHeight::Create(const quint32 _id, const QString &pointName, const QStr
quint32 id = _id; quint32 id = _id;
if (typeCreation == Source::FromGui) 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(basePointId, id);
data->AddLine(p1LineId, id); data->AddLine(p1LineId, id);
data->AddLine(p2LineId, id); data->AddLine(p2LineId, id);
} }
else 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(basePointId, id);
data->AddLine(p1LineId, id); data->AddLine(p1LineId, id);
data->AddLine(p2LineId, id); data->AddLine(p2LineId, id);

View File

@ -139,7 +139,7 @@ void VToolLineIntersect::Create(const quint32 _id, const quint32 &p1Line1Id, con
quint32 id = _id; quint32 id = _id;
if (typeCreation == Source::FromGui) 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(p1Line1Id, id);
data->AddLine(id, p2Line1Id); data->AddLine(id, p2Line1Id);
data->AddLine(p1Line2Id, id); data->AddLine(p1Line2Id, id);
@ -147,7 +147,7 @@ void VToolLineIntersect::Create(const quint32 _id, const quint32 &p1Line1Id, con
} }
else 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(p1Line1Id, id);
data->AddLine(id, p2Line1Id); data->AddLine(id, p2Line1Id);
data->AddLine(p1Line2Id, id); data->AddLine(p1Line2Id, id);

View File

@ -145,12 +145,12 @@ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quin
quint32 id = _id; quint32 id = _id;
if (typeCreation == Source::FromGui) 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(firstPointId, id);
} }
else 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(firstPointId, id);
if (parse != Document::FullParse) if (parse != Document::FullParse)
{ {

View File

@ -178,14 +178,14 @@ VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &rad
quint32 id = _id; quint32 id = _id;
if (typeCreation == Source::FromGui) 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(firstPointId, id);
data->AddLine(secondPointId, id); data->AddLine(secondPointId, id);
data->AddLine(center, id); data->AddLine(center, id);
} }
else 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(firstPointId, id);
data->AddLine(secondPointId, id); data->AddLine(secondPointId, id);
data->AddLine(center, id); data->AddLine(center, id);

View File

@ -121,11 +121,11 @@ void VToolPointOfIntersection::Create(const quint32 _id, const QString &pointNam
quint32 id = _id; quint32 id = _id;
if (typeCreation == Source::FromGui) 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 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) if (parse != Document::FullParse)
{ {
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);

View File

@ -183,13 +183,13 @@ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formu
quint32 id = _id; quint32 id = _id;
if (typeCreation == Source::FromGui) 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(p1Line, id);
data->AddLine(p2Line, id); data->AddLine(p2Line, id);
} }
else 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(p1Line, id);
data->AddLine(p2Line, id); data->AddLine(p2Line, id);
if (parse != Document::FullParse) if (parse != Document::FullParse)

View File

@ -133,11 +133,11 @@ void VToolTriangle::Create(const quint32 _id, const QString &pointName, const qu
quint32 id = _id; quint32 id = _id;
if (typeCreation == Source::FromGui) 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 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) if (parse != Document::FullParse)
{ {
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);

View File

@ -125,9 +125,9 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer
else else
{ {
const VArc *arc = data->GeometricObject<const VArc *>(det.at(i).getId()); const VArc *arc = data->GeometricObject<const VArc *>(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<const VPointF *>(pRotate)->toQPointF(), angle); BiasRotatePoint(&p1, dx, dy, data->GeometricObject<const VPointF *>(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<const VPointF *>(pRotate)->toQPointF(), angle); BiasRotatePoint(&p2, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
VPointF *center = new VPointF(arc->GetCenter()); VPointF *center = new VPointF(arc->GetCenter());
BiasRotatePoint(center, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), BiasRotatePoint(center, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(),

View File

@ -1277,7 +1277,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0"); const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0");
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0"); const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0");
const VPointF *point = data->GeometricObject<const VPointF *>(idObject ); const VPointF *point = data->GeometricObject<const VPointF *>(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)); Draw::Modeling));
VNodePoint::Create(this, data, id, idObject, parse, Source::FromFile, idTool); VNodePoint::Create(this, data, id, idObject, parse, Source::FromFile, idTool);
} }