VPiece class. Added members for storing a piece position.
--HG-- branch : feature
This commit is contained in:
parent
977b52b787
commit
37173fb0e4
|
@ -69,7 +69,7 @@ VPiece::~VPiece()
|
||||||
*/
|
*/
|
||||||
void VPiece::Append(const VPieceNode &node)
|
void VPiece::Append(const VPieceNode &node)
|
||||||
{
|
{
|
||||||
d->nodes.append(node);
|
d->m_nodes.append(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -83,7 +83,7 @@ void VPiece::Clear()
|
||||||
/** @brief ClearNodes clear list of nodes. */
|
/** @brief ClearNodes clear list of nodes. */
|
||||||
void VPiece::ClearNodes()
|
void VPiece::ClearNodes()
|
||||||
{
|
{
|
||||||
d->nodes.clear();
|
d->m_nodes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -91,9 +91,9 @@ void VPiece::ClearNodes()
|
||||||
* @brief CountNode return count nodes.
|
* @brief CountNode return count nodes.
|
||||||
* @return count.
|
* @return count.
|
||||||
*/
|
*/
|
||||||
qint32 VPiece::CountNode() const
|
qint32 VPiece::CountNodes() const
|
||||||
{
|
{
|
||||||
return d->nodes.size();
|
return d->m_nodes.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -104,7 +104,7 @@ qint32 VPiece::CountNode() const
|
||||||
*/
|
*/
|
||||||
VPieceNode &VPiece::operator [](int indx)
|
VPieceNode &VPiece::operator [](int indx)
|
||||||
{
|
{
|
||||||
return d->nodes[indx];
|
return d->m_nodes[indx];
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -115,7 +115,7 @@ VPieceNode &VPiece::operator [](int indx)
|
||||||
*/
|
*/
|
||||||
const VPieceNode &VPiece::at(int indx) const
|
const VPieceNode &VPiece::at(int indx) const
|
||||||
{
|
{
|
||||||
return d->nodes.at(indx);
|
return d->m_nodes.at(indx);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -125,7 +125,7 @@ const VPieceNode &VPiece::at(int indx) const
|
||||||
*/
|
*/
|
||||||
QVector<VPieceNode> VPiece::GetNodes() const
|
QVector<VPieceNode> VPiece::GetNodes() const
|
||||||
{
|
{
|
||||||
return d->nodes;
|
return d->m_nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -136,14 +136,14 @@ QVector<VPieceNode> VPiece::GetNodes() const
|
||||||
// cppcheck-suppress unusedFunction
|
// cppcheck-suppress unusedFunction
|
||||||
void VPiece::SetNodes(const QVector<VPieceNode> &nodes)
|
void VPiece::SetNodes(const QVector<VPieceNode> &nodes)
|
||||||
{
|
{
|
||||||
d->nodes = nodes;
|
d->m_nodes = nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QVector<QPointF> VPiece::MainPathPoints(const VContainer *data) const
|
QVector<QPointF> VPiece::MainPathPoints(const VContainer *data) const
|
||||||
{
|
{
|
||||||
QVector<QPointF> points;
|
QVector<QPointF> points;
|
||||||
for (int i = 0; i < CountNode(); ++i)
|
for (int i = 0; i < CountNodes(); ++i)
|
||||||
{
|
{
|
||||||
switch (at(i).GetTypeTool())
|
switch (at(i).GetTypeTool())
|
||||||
{
|
{
|
||||||
|
@ -179,7 +179,7 @@ QVector<QPointF> VPiece::MainPathPoints(const VContainer *data) const
|
||||||
QVector<QPointF> VPiece::MainPathNodePoints(const VContainer *data) const
|
QVector<QPointF> VPiece::MainPathNodePoints(const VContainer *data) const
|
||||||
{
|
{
|
||||||
QVector<QPointF> points;
|
QVector<QPointF> points;
|
||||||
for (int i = 0; i < CountNode(); ++i)
|
for (int i = 0; i < CountNodes(); ++i)
|
||||||
{
|
{
|
||||||
switch (at(i).GetTypeTool())
|
switch (at(i).GetTypeTool())
|
||||||
{
|
{
|
||||||
|
@ -220,10 +220,34 @@ QPainterPath VPiece::MainPathPath(const VContainer *data) const
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
qreal VPiece::GetMx() const
|
||||||
|
{
|
||||||
|
return d->m_mx;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPiece::SetMx(qreal value)
|
||||||
|
{
|
||||||
|
d->m_mx = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
qreal VPiece::GetMy() const
|
||||||
|
{
|
||||||
|
return d->m_my;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPiece::SetMy(qreal value)
|
||||||
|
{
|
||||||
|
d->m_my = value;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QPointF VPiece::StartSegment(const VContainer *data, const int &i, bool reverse) const
|
QPointF VPiece::StartSegment(const VContainer *data, const int &i, bool reverse) const
|
||||||
{
|
{
|
||||||
if (i < 0 && i > CountNode()-1)
|
if (i < 0 && i > CountNodes()-1)
|
||||||
{
|
{
|
||||||
return QPointF();
|
return QPointF();
|
||||||
}
|
}
|
||||||
|
@ -237,13 +261,13 @@ QPointF VPiece::StartSegment(const VContainer *data, const int &i, bool reverse)
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF begin = points.first();
|
QPointF begin = points.first();
|
||||||
if (CountNode() > 1)
|
if (CountNodes() > 1)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
if (at(CountNode()-1).GetTypeTool() == Tool::NodePoint)
|
if (at(CountNodes()-1).GetTypeTool() == Tool::NodePoint)
|
||||||
{
|
{
|
||||||
begin = *data->GeometricObject<VPointF>(at(CountNode()-1).GetId());
|
begin = *data->GeometricObject<VPointF>(at(CountNodes()-1).GetId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -260,7 +284,7 @@ QPointF VPiece::StartSegment(const VContainer *data, const int &i, bool reverse)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QPointF VPiece::EndSegment(const VContainer *data, const int &i, bool reverse) const
|
QPointF VPiece::EndSegment(const VContainer *data, const int &i, bool reverse) const
|
||||||
{
|
{
|
||||||
if (i < 0 && i > CountNode()-1)
|
if (i < 0 && i > CountNodes()-1)
|
||||||
{
|
{
|
||||||
return QPointF();
|
return QPointF();
|
||||||
}
|
}
|
||||||
|
@ -274,9 +298,9 @@ QPointF VPiece::EndSegment(const VContainer *data, const int &i, bool reverse) c
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF end = points.last();
|
QPointF end = points.last();
|
||||||
if (CountNode() > 2)
|
if (CountNodes() > 2)
|
||||||
{
|
{
|
||||||
if (i == CountNode() - 1)
|
if (i == CountNodes() - 1)
|
||||||
{
|
{
|
||||||
if (at(0).GetTypeTool() == Tool::NodePoint)
|
if (at(0).GetTypeTool() == Tool::NodePoint)
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
void Append(const VPieceNode &node);
|
void Append(const VPieceNode &node);
|
||||||
void Clear();
|
void Clear();
|
||||||
void ClearNodes();
|
void ClearNodes();
|
||||||
qint32 CountNode() const;
|
qint32 CountNodes() const;
|
||||||
|
|
||||||
VPieceNode & operator[](int indx);
|
VPieceNode & operator[](int indx);
|
||||||
const VPieceNode & at ( int indx ) const;
|
const VPieceNode & at ( int indx ) const;
|
||||||
|
@ -65,6 +65,12 @@ public:
|
||||||
|
|
||||||
QPainterPath MainPathPath(const VContainer *data) const;
|
QPainterPath MainPathPath(const VContainer *data) const;
|
||||||
|
|
||||||
|
qreal GetMx() const;
|
||||||
|
void SetMx(qreal value);
|
||||||
|
|
||||||
|
qreal GetMy() const;
|
||||||
|
void SetMy(qreal value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedDataPointer<VPieceData> d;
|
QSharedDataPointer<VPieceData> d;
|
||||||
|
|
||||||
|
|
|
@ -42,18 +42,25 @@ class VPieceData : public QSharedData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VPieceData()
|
VPieceData()
|
||||||
: nodes()
|
: m_nodes(),
|
||||||
|
m_mx(0),
|
||||||
|
m_my(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
VPieceData(const VPieceData &detail)
|
VPieceData(const VPieceData &detail)
|
||||||
: QSharedData(detail),
|
: QSharedData(detail),
|
||||||
nodes(detail.nodes)
|
m_nodes(detail.m_nodes),
|
||||||
|
m_mx(detail.m_mx),
|
||||||
|
m_my(detail.m_my)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~VPieceData();
|
~VPieceData();
|
||||||
|
|
||||||
/** @brief nodes list detail nodes. */
|
/** @brief nodes list detail nodes. */
|
||||||
QVector<VPieceNode> nodes;
|
QVector<VPieceNode> m_nodes;
|
||||||
|
|
||||||
|
qreal m_mx;
|
||||||
|
qreal m_my;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VPieceData &operator=(const VPieceData &) Q_DECL_EQ_DELETE;
|
VPieceData &operator=(const VPieceData &) Q_DECL_EQ_DELETE;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user