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& 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

View File

@ -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

View File

@ -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;
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -31,7 +31,8 @@
//---------------------------------------------------------------------------------------------------------------------
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;
};
//---------------------------------------------------------------------------------------------------------------------
inline qint32 VSplinePath::CountPoint() const
{
return path.size();
}
//---------------------------------------------------------------------------------------------------------------------
inline QVector<VSplinePoint> 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<VSplinePoint> *VSplinePath::GetPoint() const
{
return &path;

View File

@ -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)

View File

@ -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)
{

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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)
{

View File

@ -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);

View File

@ -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);

View File

@ -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)
{

View File

@ -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);

View File

@ -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);

View File

@ -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)

View File

@ -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);

View File

@ -125,9 +125,9 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer
else
{
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);
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);
VPointF *center = new VPointF(arc->GetCenter());
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 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0");
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));
VNodePoint::Create(this, data, id, idObject, parse, Source::FromFile, idTool);
}