Added class VPiecePath.
--HG-- branch : feature
This commit is contained in:
parent
6b89f43e87
commit
5d5e677e2c
|
@ -54,6 +54,7 @@
|
||||||
#include "../vpatterndb/vpatternpiecedata.h"
|
#include "../vpatterndb/vpatternpiecedata.h"
|
||||||
#include "../vpatterndb/vpatterninfogeometry.h"
|
#include "../vpatterndb/vpatterninfogeometry.h"
|
||||||
#include "../vpatterndb/vgrainlinegeometry.h"
|
#include "../vpatterndb/vgrainlinegeometry.h"
|
||||||
|
#include "../vpatterndb/vpiecepath.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
|
@ -778,7 +779,7 @@ void VPattern::ParseDetailNodes(const QDomElement &domElement, VPiece &detail) c
|
||||||
node.SetSABefore(saBefore);
|
node.SetSABefore(saBefore);
|
||||||
node.SetSAAfter(saAfter);
|
node.SetSAAfter(saAfter);
|
||||||
node.SetAngleType(angle);
|
node.SetAngleType(angle);
|
||||||
detail.Append(node);
|
detail.GetPath().Append(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,8 @@ SOURCES += \
|
||||||
$$PWD/vgrainlinegeometry.cpp \
|
$$PWD/vgrainlinegeometry.cpp \
|
||||||
$$PWD/variables/vcurveclength.cpp \
|
$$PWD/variables/vcurveclength.cpp \
|
||||||
$$PWD/vpiece.cpp \
|
$$PWD/vpiece.cpp \
|
||||||
$$PWD/vpiecenode.cpp
|
$$PWD/vpiecenode.cpp \
|
||||||
|
$$PWD/vpiecepath.cpp
|
||||||
|
|
||||||
win32-msvc*:SOURCES += $$PWD/stable.cpp
|
win32-msvc*:SOURCES += $$PWD/stable.cpp
|
||||||
|
|
||||||
|
@ -63,4 +64,6 @@ HEADERS += \
|
||||||
$$PWD/vpiece.h \
|
$$PWD/vpiece.h \
|
||||||
$$PWD/vpiece_p.h \
|
$$PWD/vpiece_p.h \
|
||||||
$$PWD/vpiecenode.h \
|
$$PWD/vpiecenode.h \
|
||||||
$$PWD/vpiecenode_p.h
|
$$PWD/vpiecenode_p.h \
|
||||||
|
$$PWD/vpiecepath.h \
|
||||||
|
$$PWD/vpiecepath_p.h
|
||||||
|
|
|
@ -63,114 +63,27 @@ VPiece::~VPiece()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
VPiecePath VPiece::GetPath() const
|
||||||
* @brief append append in the end of list node.
|
|
||||||
* @param node new node.
|
|
||||||
*/
|
|
||||||
void VPiece::Append(const VPieceNode &node)
|
|
||||||
{
|
{
|
||||||
d->m_nodes.append(node);
|
return d->m_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/** @brief Clear detail full clear. */
|
VPiecePath &VPiece::GetPath()
|
||||||
void VPiece::Clear()
|
|
||||||
{
|
{
|
||||||
ClearNodes();
|
return d->m_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/** @brief ClearNodes clear list of nodes. */
|
void VPiece::SetPath(const VPiecePath &path)
|
||||||
void VPiece::ClearNodes()
|
|
||||||
{
|
{
|
||||||
d->m_nodes.clear();
|
d->m_path = path;
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief CountNode return count nodes.
|
|
||||||
* @return count.
|
|
||||||
*/
|
|
||||||
qint32 VPiece::CountNodes() const
|
|
||||||
{
|
|
||||||
return d->m_nodes.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief operator [] find node by index in list.
|
|
||||||
* @param indx index node in list.
|
|
||||||
* @return node
|
|
||||||
*/
|
|
||||||
VPieceNode &VPiece::operator [](int indx)
|
|
||||||
{
|
|
||||||
return d->m_nodes[indx];
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief at find node by index in list.
|
|
||||||
* @param indx index node in list.
|
|
||||||
* @return const node.
|
|
||||||
*/
|
|
||||||
const VPieceNode &VPiece::at(int indx) const
|
|
||||||
{
|
|
||||||
return d->m_nodes.at(indx);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief getNodes return list of nodes.
|
|
||||||
* @return list of nodes.
|
|
||||||
*/
|
|
||||||
QVector<VPieceNode> VPiece::GetNodes() const
|
|
||||||
{
|
|
||||||
return d->m_nodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief setNodes set list of nodes
|
|
||||||
* @param value list of nodes
|
|
||||||
*/
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void VPiece::SetNodes(const QVector<VPieceNode> &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 = GetPath().PathPoints(data);
|
||||||
for (int i = 0; i < CountNodes(); ++i)
|
|
||||||
{
|
|
||||||
switch (at(i).GetTypeTool())
|
|
||||||
{
|
|
||||||
case (Tool::NodePoint):
|
|
||||||
{
|
|
||||||
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(at(i).GetId());
|
|
||||||
points.append(*point);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case (Tool::NodeArc):
|
|
||||||
case (Tool::NodeSpline):
|
|
||||||
case (Tool::NodeSplinePath):
|
|
||||||
{
|
|
||||||
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(at(i).GetId());
|
|
||||||
|
|
||||||
const QPointF begin = StartSegment(data, i, at(i).GetReverse());
|
|
||||||
const QPointF end = EndSegment(data, i, at(i).GetReverse());
|
|
||||||
|
|
||||||
points << curve->GetSegmentPoints(begin, end, at(i).GetReverse());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
qDebug()<<"Get wrong tool type. Ignore."<< static_cast<char>(at(i).GetTypeTool());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
points = CheckLoops(CorrectEquidistantPoints(points));//A path can contains loops
|
points = CheckLoops(CorrectEquidistantPoints(points));//A path can contains loops
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
@ -178,26 +91,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;
|
return GetPath().PathNodePoints(data);
|
||||||
for (int i = 0; i < CountNodes(); ++i)
|
|
||||||
{
|
|
||||||
switch (at(i).GetTypeTool())
|
|
||||||
{
|
|
||||||
case Tool::NodePoint:
|
|
||||||
{
|
|
||||||
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(at(i).GetId());
|
|
||||||
points.append(*point);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Tool::NodeArc:
|
|
||||||
case Tool::NodeSpline:
|
|
||||||
case Tool::NodeSplinePath:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return points;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -212,9 +106,9 @@ QVector<QPointF> VPiece::SeamAllowancePoints(const VContainer *data) const
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<VSAPoint> pointsEkv;
|
QVector<VSAPoint> pointsEkv;
|
||||||
for (int i = 0; i< CountNodes(); ++i)
|
for (int i = 0; i< d->m_path.CountNodes(); ++i)
|
||||||
{
|
{
|
||||||
const VPieceNode &node = at(i);
|
const VPieceNode &node = d->m_path.at(i);
|
||||||
switch (node.GetTypeTool())
|
switch (node.GetTypeTool())
|
||||||
{
|
{
|
||||||
case (Tool::NodePoint):
|
case (Tool::NodePoint):
|
||||||
|
@ -334,31 +228,32 @@ void VPiece::SetInLayout(bool inLayout)
|
||||||
*/
|
*/
|
||||||
QVector<VPieceNode> VPiece::Missing(const VPiece &det) const
|
QVector<VPieceNode> VPiece::Missing(const VPiece &det) const
|
||||||
{
|
{
|
||||||
if (d->m_nodes.size() == det.CountNodes()) //-V807
|
const QVector<VPieceNode> pNodes = d->m_path.GetNodes();
|
||||||
|
if (pNodes.size() == det.GetPath().CountNodes()) //-V807
|
||||||
{
|
{
|
||||||
return QVector<VPieceNode>();
|
return QVector<VPieceNode>();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<quint32> set1;
|
QSet<quint32> set1;
|
||||||
for (qint32 i = 0; i < d->m_nodes.size(); ++i)
|
for (qint32 i = 0; i < pNodes.size(); ++i)
|
||||||
{
|
{
|
||||||
set1.insert(d->m_nodes.at(i).GetId());
|
set1.insert(pNodes.at(i).GetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<quint32> set2;
|
QSet<quint32> set2;
|
||||||
for (qint32 j = 0; j < det.CountNodes(); ++j)
|
for (qint32 j = 0; j < det.GetPath().CountNodes(); ++j)
|
||||||
{
|
{
|
||||||
set2.insert(det.at(j).GetId());
|
set2.insert(det.GetPath().at(j).GetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<quint32> set3 = set1.subtract(set2).toList();
|
const QList<quint32> set3 = set1.subtract(set2).toList();
|
||||||
QVector<VPieceNode> nodes;
|
QVector<VPieceNode> nodes;
|
||||||
for (qint32 i = 0; i < set3.size(); ++i)
|
for (qint32 i = 0; i < set3.size(); ++i)
|
||||||
{
|
{
|
||||||
const int index = indexOfNode(d->m_nodes, set3.at(i));
|
const int index = indexOfNode(pNodes, set3.at(i));
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
nodes.append(d->m_nodes.at(index));
|
nodes.append(pNodes.at(index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,15 +268,15 @@ QVector<VPieceNode> VPiece::Missing(const VPiece &det) const
|
||||||
*/
|
*/
|
||||||
int VPiece::indexOfNode(const quint32 &id) const
|
int VPiece::indexOfNode(const quint32 &id) const
|
||||||
{
|
{
|
||||||
return indexOfNode(d->m_nodes, id);
|
return indexOfNode(d->m_path.GetNodes(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPiece::CurveSeamAllowanceSegment(QVector<VSAPoint> &pointsEkv, const VContainer *data,
|
void VPiece::CurveSeamAllowanceSegment(QVector<VSAPoint> &pointsEkv, const VContainer *data,
|
||||||
const QSharedPointer<VAbstractCurve> &curve, int i, bool reverse) const
|
const QSharedPointer<VAbstractCurve> &curve, int i, bool reverse) const
|
||||||
{
|
{
|
||||||
const VSAPoint begin = StartSegment(data, i, reverse);
|
const VSAPoint begin = d->m_path.StartSegment(data, i, reverse);
|
||||||
const VSAPoint end = EndSegment(data, i, reverse);
|
const VSAPoint end = d->m_path.EndSegment(data, i, reverse);
|
||||||
|
|
||||||
const QVector<QPointF> points = curve->GetSegmentPoints(begin, end, reverse);
|
const QVector<QPointF> points = curve->GetSegmentPoints(begin, end, reverse);
|
||||||
if (points.isEmpty())
|
if (points.isEmpty())
|
||||||
|
@ -461,112 +356,6 @@ void VPiece::CurveSeamAllowanceSegment(QVector<VSAPoint> &pointsEkv, const VCont
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
VSAPoint VPiece::StartSegment(const VContainer *data, int i, bool reverse) const
|
|
||||||
{
|
|
||||||
if (i < 0 && i > CountNodes()-1)
|
|
||||||
{
|
|
||||||
return VSAPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(at(i).GetId());
|
|
||||||
|
|
||||||
QVector<QPointF> points = curve->GetPoints();
|
|
||||||
if (reverse)
|
|
||||||
{
|
|
||||||
points = VGObject::GetReversePoints(points);
|
|
||||||
}
|
|
||||||
|
|
||||||
VSAPoint begin = VSAPoint(points.first());
|
|
||||||
if (CountNodes() > 1)
|
|
||||||
{
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
if (at(CountNodes()-1).GetTypeTool() == Tool::NodePoint)
|
|
||||||
{
|
|
||||||
const VPieceNode &node = at(CountNodes()-1);
|
|
||||||
const QPointF p = *data->GeometricObject<VPointF>(node.GetId());
|
|
||||||
if (curve->IsPointOnCurve(p))
|
|
||||||
{
|
|
||||||
begin = VSAPoint(p);
|
|
||||||
begin.SetSAAfter(node.GetSAAfter(*data->GetPatternUnit()));
|
|
||||||
begin.SetSABefore(node.GetSABefore(*data->GetPatternUnit()));
|
|
||||||
begin.SetAngleType(node.GetAngleType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (at(i-1).GetTypeTool() == Tool::NodePoint)
|
|
||||||
{
|
|
||||||
const VPieceNode &node = at(i-1);
|
|
||||||
const QPointF p = *data->GeometricObject<VPointF>(node.GetId());
|
|
||||||
if (curve->IsPointOnCurve(p))
|
|
||||||
{
|
|
||||||
begin = VSAPoint(p);
|
|
||||||
begin.SetSAAfter(node.GetSAAfter(*data->GetPatternUnit()));
|
|
||||||
begin.SetSABefore(node.GetSABefore(*data->GetPatternUnit()));
|
|
||||||
begin.SetAngleType(node.GetAngleType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return begin;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
VSAPoint VPiece::EndSegment(const VContainer *data, int i, bool reverse) const
|
|
||||||
{
|
|
||||||
if (i < 0 && i > CountNodes()-1)
|
|
||||||
{
|
|
||||||
return VSAPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(at(i).GetId());
|
|
||||||
|
|
||||||
QVector<QPointF> points = curve->GetPoints();
|
|
||||||
if (reverse)
|
|
||||||
{
|
|
||||||
points = VGObject::GetReversePoints(points);
|
|
||||||
}
|
|
||||||
|
|
||||||
VSAPoint end = VSAPoint(points.last());
|
|
||||||
if (CountNodes() > 2)
|
|
||||||
{
|
|
||||||
if (i == CountNodes() - 1)
|
|
||||||
{
|
|
||||||
if (at(0).GetTypeTool() == Tool::NodePoint)
|
|
||||||
{
|
|
||||||
const VPieceNode &node = at(0);
|
|
||||||
const QPointF p = *data->GeometricObject<VPointF>(node.GetId());
|
|
||||||
if (curve->IsPointOnCurve(p))
|
|
||||||
{
|
|
||||||
end = VSAPoint(p);
|
|
||||||
end.SetSAAfter(node.GetSAAfter(*data->GetPatternUnit()));
|
|
||||||
end.SetSABefore(node.GetSABefore(*data->GetPatternUnit()));
|
|
||||||
end.SetAngleType(node.GetAngleType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (at(i+1).GetTypeTool() == Tool::NodePoint)
|
|
||||||
{
|
|
||||||
const VPieceNode &node = at(i+1);
|
|
||||||
const QPointF p = *data->GeometricObject<VPointF>(node.GetId());
|
|
||||||
if (curve->IsPointOnCurve(p))
|
|
||||||
{
|
|
||||||
end = VSAPoint(p);
|
|
||||||
end.SetSAAfter(node.GetSAAfter(*data->GetPatternUnit()));
|
|
||||||
end.SetSABefore(node.GetSABefore(*data->GetPatternUnit()));
|
|
||||||
end.SetAngleType(node.GetAngleType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief indexOfNode return index in list node using id object.
|
* @brief indexOfNode return index in list node using id object.
|
||||||
|
|
|
@ -42,6 +42,7 @@ class VContainer;
|
||||||
template <class T> class QVector;
|
template <class T> class QVector;
|
||||||
template <class T>class QSharedPointer;
|
template <class T>class QSharedPointer;
|
||||||
class VAbstractCurve;
|
class VAbstractCurve;
|
||||||
|
class VPiecePath;
|
||||||
|
|
||||||
class VPiece : public VAbstractPiece
|
class VPiece : public VAbstractPiece
|
||||||
{
|
{
|
||||||
|
@ -51,16 +52,9 @@ public:
|
||||||
VPiece &operator=(const VPiece &piece);
|
VPiece &operator=(const VPiece &piece);
|
||||||
virtual ~VPiece();
|
virtual ~VPiece();
|
||||||
|
|
||||||
void Append(const VPieceNode &node);
|
VPiecePath GetPath() const;
|
||||||
void Clear();
|
VPiecePath &GetPath();
|
||||||
void ClearNodes();
|
void SetPath(const VPiecePath &path);
|
||||||
qint32 CountNodes() const;
|
|
||||||
|
|
||||||
VPieceNode & operator[](int indx);
|
|
||||||
const VPieceNode & at ( int indx ) const;
|
|
||||||
|
|
||||||
QVector<VPieceNode> GetNodes() const;
|
|
||||||
void SetNodes(const QVector<VPieceNode> &nodes);
|
|
||||||
|
|
||||||
QVector<QPointF> MainPathPoints(const VContainer *data) const;
|
QVector<QPointF> MainPathPoints(const VContainer *data) const;
|
||||||
QVector<QPointF> MainPathNodePoints(const VContainer *data) const;
|
QVector<QPointF> MainPathNodePoints(const VContainer *data) const;
|
||||||
|
@ -87,8 +81,6 @@ private:
|
||||||
|
|
||||||
void CurveSeamAllowanceSegment(QVector<VSAPoint> &pointsEkv, const VContainer *data,
|
void CurveSeamAllowanceSegment(QVector<VSAPoint> &pointsEkv, const VContainer *data,
|
||||||
const QSharedPointer<VAbstractCurve> &curve, int i, bool reverse) const;
|
const QSharedPointer<VAbstractCurve> &curve, int i, bool reverse) const;
|
||||||
VSAPoint StartSegment(const VContainer *data, int i, bool reverse) const;
|
|
||||||
VSAPoint EndSegment(const VContainer *data, int i, bool reverse) const;
|
|
||||||
|
|
||||||
static int indexOfNode(const QVector<VPieceNode> &list, quint32 id);
|
static int indexOfNode(const QVector<VPieceNode> &list, quint32 id);
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
#include "../vmisc/diagnostic.h"
|
#include "../vmisc/diagnostic.h"
|
||||||
#include "vpiecenode.h"
|
#include "vpiecenode.h"
|
||||||
|
#include "vpiecepath.h"
|
||||||
|
|
||||||
QT_WARNING_PUSH
|
QT_WARNING_PUSH
|
||||||
QT_WARNING_DISABLE_GCC("-Weffc++")
|
QT_WARNING_DISABLE_GCC("-Weffc++")
|
||||||
|
@ -42,7 +43,7 @@ class VPieceData : public QSharedData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VPieceData()
|
VPieceData()
|
||||||
: m_nodes(),
|
: m_path(),
|
||||||
m_mx(0),
|
m_mx(0),
|
||||||
m_my(0),
|
m_my(0),
|
||||||
m_inLayout(true)
|
m_inLayout(true)
|
||||||
|
@ -50,7 +51,7 @@ public:
|
||||||
|
|
||||||
VPieceData(const VPieceData &detail)
|
VPieceData(const VPieceData &detail)
|
||||||
: QSharedData(detail),
|
: QSharedData(detail),
|
||||||
m_nodes(detail.m_nodes),
|
m_path(detail.m_path),
|
||||||
m_mx(detail.m_mx),
|
m_mx(detail.m_mx),
|
||||||
m_my(detail.m_my),
|
m_my(detail.m_my),
|
||||||
m_inLayout(detail.m_inLayout)
|
m_inLayout(detail.m_inLayout)
|
||||||
|
@ -59,7 +60,7 @@ public:
|
||||||
~VPieceData();
|
~VPieceData();
|
||||||
|
|
||||||
/** @brief nodes list detail nodes. */
|
/** @brief nodes list detail nodes. */
|
||||||
QVector<VPieceNode> m_nodes;
|
VPiecePath m_path;
|
||||||
|
|
||||||
qreal m_mx;
|
qreal m_mx;
|
||||||
qreal m_my;
|
qreal m_my;
|
||||||
|
|
287
src/libs/vpatterndb/vpiecepath.cpp
Normal file
287
src/libs/vpatterndb/vpiecepath.cpp
Normal file
|
@ -0,0 +1,287 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 22 11, 2016
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2016 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "vpiecepath.h"
|
||||||
|
#include "vpiecepath_p.h"
|
||||||
|
#include "vcontainer.h"
|
||||||
|
#include "../vgeometry/vpointf.h"
|
||||||
|
#include "../vlayout/vabstractpiece.h"
|
||||||
|
|
||||||
|
#include <QPainterPath>
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VPiecePath::VPiecePath()
|
||||||
|
: d(new VPiecePathData)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VPiecePath::VPiecePath(const VPiecePath &path)
|
||||||
|
: d (path.d)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VPiecePath &VPiecePath::operator=(const VPiecePath &path)
|
||||||
|
{
|
||||||
|
if ( &path == this )
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
d = path.d;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VPiecePath::~VPiecePath()
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPiecePath::Append(const VPieceNode &node)
|
||||||
|
{
|
||||||
|
d->m_nodes.append(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPiecePath::Clear()
|
||||||
|
{
|
||||||
|
d->m_nodes.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
qint32 VPiecePath::CountNodes() const
|
||||||
|
{
|
||||||
|
return d->m_nodes.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VPieceNode &VPiecePath::operator[](int indx)
|
||||||
|
{
|
||||||
|
return d->m_nodes[indx];
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
const VPieceNode &VPiecePath::at(int indx) const
|
||||||
|
{
|
||||||
|
return d->m_nodes.at(indx);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QVector<VPieceNode> VPiecePath::GetNodes() const
|
||||||
|
{
|
||||||
|
return d->m_nodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPiecePath::SetNodes(const QVector<VPieceNode> &nodes)
|
||||||
|
{
|
||||||
|
d->m_nodes = nodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QVector<QPointF> VPiecePath::PathPoints(const VContainer *data) const
|
||||||
|
{
|
||||||
|
QVector<QPointF> points;
|
||||||
|
for (int i = 0; i < CountNodes(); ++i)
|
||||||
|
{
|
||||||
|
switch (at(i).GetTypeTool())
|
||||||
|
{
|
||||||
|
case (Tool::NodePoint):
|
||||||
|
{
|
||||||
|
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(at(i).GetId());
|
||||||
|
points.append(*point);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case (Tool::NodeArc):
|
||||||
|
case (Tool::NodeSpline):
|
||||||
|
case (Tool::NodeSplinePath):
|
||||||
|
{
|
||||||
|
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(at(i).GetId());
|
||||||
|
|
||||||
|
const QPointF begin = StartSegment(data, i, at(i).GetReverse());
|
||||||
|
const QPointF end = EndSegment(data, i, at(i).GetReverse());
|
||||||
|
|
||||||
|
points << curve->GetSegmentPoints(begin, end, at(i).GetReverse());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qDebug()<<"Get wrong tool type. Ignore."<< static_cast<char>(at(i).GetTypeTool());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QVector<QPointF> VPiecePath::PathNodePoints(const VContainer *data) const
|
||||||
|
{
|
||||||
|
QVector<QPointF> points;
|
||||||
|
for (int i = 0; i < CountNodes(); ++i)
|
||||||
|
{
|
||||||
|
switch (at(i).GetTypeTool())
|
||||||
|
{
|
||||||
|
case Tool::NodePoint:
|
||||||
|
{
|
||||||
|
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(at(i).GetId());
|
||||||
|
points.append(*point);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Tool::NodeArc:
|
||||||
|
case Tool::NodeSpline:
|
||||||
|
case Tool::NodeSplinePath:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QPainterPath VPiecePath::PainterPath(const VContainer *data) const
|
||||||
|
{
|
||||||
|
const QVector<QPointF> points = PathPoints(data);
|
||||||
|
QPainterPath path;
|
||||||
|
|
||||||
|
if (not points.isEmpty())
|
||||||
|
{
|
||||||
|
path.moveTo(points[0]);
|
||||||
|
for (qint32 i = 1; i < points.count(); ++i)
|
||||||
|
{
|
||||||
|
path.lineTo(points.at(i));
|
||||||
|
}
|
||||||
|
path.setFillRule(Qt::WindingFill);
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VSAPoint VPiecePath::StartSegment(const VContainer *data, int i, bool reverse) const
|
||||||
|
{
|
||||||
|
if (i < 0 && i > CountNodes()-1)
|
||||||
|
{
|
||||||
|
return VSAPoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(at(i).GetId());
|
||||||
|
|
||||||
|
QVector<QPointF> points = curve->GetPoints();
|
||||||
|
if (reverse)
|
||||||
|
{
|
||||||
|
points = VGObject::GetReversePoints(points);
|
||||||
|
}
|
||||||
|
|
||||||
|
VSAPoint begin = VSAPoint(points.first());
|
||||||
|
if (CountNodes() > 1)
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
if (at(CountNodes()-1).GetTypeTool() == Tool::NodePoint)
|
||||||
|
{
|
||||||
|
const VPieceNode &node = at(CountNodes()-1);
|
||||||
|
const QPointF p = *data->GeometricObject<VPointF>(node.GetId());
|
||||||
|
if (curve->IsPointOnCurve(p))
|
||||||
|
{
|
||||||
|
begin = VSAPoint(p);
|
||||||
|
begin.SetSAAfter(node.GetSAAfter(*data->GetPatternUnit()));
|
||||||
|
begin.SetSABefore(node.GetSABefore(*data->GetPatternUnit()));
|
||||||
|
begin.SetAngleType(node.GetAngleType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (at(i-1).GetTypeTool() == Tool::NodePoint)
|
||||||
|
{
|
||||||
|
const VPieceNode &node = at(i-1);
|
||||||
|
const QPointF p = *data->GeometricObject<VPointF>(node.GetId());
|
||||||
|
if (curve->IsPointOnCurve(p))
|
||||||
|
{
|
||||||
|
begin = VSAPoint(p);
|
||||||
|
begin.SetSAAfter(node.GetSAAfter(*data->GetPatternUnit()));
|
||||||
|
begin.SetSABefore(node.GetSABefore(*data->GetPatternUnit()));
|
||||||
|
begin.SetAngleType(node.GetAngleType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return begin;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VSAPoint VPiecePath::EndSegment(const VContainer *data, int i, bool reverse) const
|
||||||
|
{
|
||||||
|
if (i < 0 && i > CountNodes()-1)
|
||||||
|
{
|
||||||
|
return VSAPoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(at(i).GetId());
|
||||||
|
|
||||||
|
QVector<QPointF> points = curve->GetPoints();
|
||||||
|
if (reverse)
|
||||||
|
{
|
||||||
|
points = VGObject::GetReversePoints(points);
|
||||||
|
}
|
||||||
|
|
||||||
|
VSAPoint end = VSAPoint(points.last());
|
||||||
|
if (CountNodes() > 2)
|
||||||
|
{
|
||||||
|
if (i == CountNodes() - 1)
|
||||||
|
{
|
||||||
|
if (at(0).GetTypeTool() == Tool::NodePoint)
|
||||||
|
{
|
||||||
|
const VPieceNode &node = at(0);
|
||||||
|
const QPointF p = *data->GeometricObject<VPointF>(node.GetId());
|
||||||
|
if (curve->IsPointOnCurve(p))
|
||||||
|
{
|
||||||
|
end = VSAPoint(p);
|
||||||
|
end.SetSAAfter(node.GetSAAfter(*data->GetPatternUnit()));
|
||||||
|
end.SetSABefore(node.GetSABefore(*data->GetPatternUnit()));
|
||||||
|
end.SetAngleType(node.GetAngleType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (at(i+1).GetTypeTool() == Tool::NodePoint)
|
||||||
|
{
|
||||||
|
const VPieceNode &node = at(i+1);
|
||||||
|
const QPointF p = *data->GeometricObject<VPointF>(node.GetId());
|
||||||
|
if (curve->IsPointOnCurve(p))
|
||||||
|
{
|
||||||
|
end = VSAPoint(p);
|
||||||
|
end.SetSAAfter(node.GetSAAfter(*data->GetPatternUnit()));
|
||||||
|
end.SetSABefore(node.GetSABefore(*data->GetPatternUnit()));
|
||||||
|
end.SetAngleType(node.GetAngleType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return end;
|
||||||
|
}
|
74
src/libs/vpatterndb/vpiecepath.h
Normal file
74
src/libs/vpatterndb/vpiecepath.h
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 22 11, 2016
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2016 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef VPIECEPATH_H
|
||||||
|
#define VPIECEPATH_H
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
#include <QSharedDataPointer>
|
||||||
|
|
||||||
|
class VPiecePathData;
|
||||||
|
class VPieceNode;
|
||||||
|
class QPointF;
|
||||||
|
class VContainer;
|
||||||
|
class VSAPoint;
|
||||||
|
class QPainterPath;
|
||||||
|
|
||||||
|
class VPiecePath
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VPiecePath();
|
||||||
|
VPiecePath(const VPiecePath &path);
|
||||||
|
VPiecePath &operator=(const VPiecePath &path);
|
||||||
|
~VPiecePath();
|
||||||
|
|
||||||
|
void Append(const VPieceNode &node);
|
||||||
|
void Clear();
|
||||||
|
qint32 CountNodes() const;
|
||||||
|
|
||||||
|
VPieceNode & operator[](int indx);
|
||||||
|
const VPieceNode & at ( int indx ) const;
|
||||||
|
|
||||||
|
QVector<VPieceNode> GetNodes() const;
|
||||||
|
void SetNodes(const QVector<VPieceNode> &nodes);
|
||||||
|
|
||||||
|
QVector<QPointF> PathPoints(const VContainer *data) const;
|
||||||
|
QVector<QPointF> PathNodePoints(const VContainer *data) const;
|
||||||
|
|
||||||
|
QPainterPath PainterPath(const VContainer *data) const;
|
||||||
|
|
||||||
|
VSAPoint StartSegment(const VContainer *data, int i, bool reverse) const;
|
||||||
|
VSAPoint EndSegment(const VContainer *data, int i, bool reverse) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSharedDataPointer<VPiecePathData> d;
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_TYPEINFO(VPiecePath, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
|
#endif // VPIECEPATH_H
|
67
src/libs/vpatterndb/vpiecepath_p.h
Normal file
67
src/libs/vpatterndb/vpiecepath_p.h
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 22 11, 2016
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2016 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef VPIECEPATH_P_H
|
||||||
|
#define VPIECEPATH_P_H
|
||||||
|
|
||||||
|
#include <QSharedData>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
#include "../vmisc/diagnostic.h"
|
||||||
|
#include "vpiecenode.h"
|
||||||
|
|
||||||
|
QT_WARNING_PUSH
|
||||||
|
QT_WARNING_DISABLE_GCC("-Weffc++")
|
||||||
|
|
||||||
|
class VPiecePathData : public QSharedData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VPiecePathData()
|
||||||
|
: m_nodes()
|
||||||
|
{}
|
||||||
|
|
||||||
|
VPiecePathData(const VPiecePathData &path)
|
||||||
|
: QSharedData(path),
|
||||||
|
m_nodes(path.m_nodes)
|
||||||
|
{}
|
||||||
|
|
||||||
|
~VPiecePathData();
|
||||||
|
|
||||||
|
QVector<VPieceNode> m_nodes;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VPiecePathData &operator=(const VPiecePathData &) Q_DECL_EQ_DELETE;
|
||||||
|
};
|
||||||
|
|
||||||
|
VPiecePathData::~VPiecePathData()
|
||||||
|
{}
|
||||||
|
|
||||||
|
QT_WARNING_POP
|
||||||
|
|
||||||
|
#endif // VPIECEPATH_P_H
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "dialogseamallowance.h"
|
#include "dialogseamallowance.h"
|
||||||
#include "ui_dialogseamallowance.h"
|
#include "ui_dialogseamallowance.h"
|
||||||
#include "../vpatterndb/vpiecenode.h"
|
#include "../vpatterndb/vpiecenode.h"
|
||||||
|
#include "../vpatterndb/vpiecepath.h"
|
||||||
#include "visualization/path/vistoolpiece.h"
|
#include "visualization/path/vistoolpiece.h"
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
@ -123,9 +124,9 @@ VPiece DialogSeamAllowance::GetPiece() const
|
||||||
void DialogSeamAllowance::SetPiece(const VPiece &piece)
|
void DialogSeamAllowance::SetPiece(const VPiece &piece)
|
||||||
{
|
{
|
||||||
ui->listWidget->clear();
|
ui->listWidget->clear();
|
||||||
for (int i = 0; i < piece.CountNodes(); ++i)
|
for (int i = 0; i < piece.GetPath().CountNodes(); ++i)
|
||||||
{
|
{
|
||||||
NewItem(piece.at(i));
|
NewItem(piece.GetPath().at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->checkBoxForbidFlipping->setChecked(piece.IsForbidFlipping());
|
ui->checkBoxForbidFlipping->setChecked(piece.IsForbidFlipping());
|
||||||
|
@ -186,7 +187,7 @@ void DialogSeamAllowance::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
const VPiece p = CreatePiece();
|
const VPiece p = CreatePiece();
|
||||||
visPath->SetPiece(p);
|
visPath->SetPiece(p);
|
||||||
|
|
||||||
if (p.CountNodes() == 1)
|
if (p.GetPath().CountNodes() == 1)
|
||||||
{
|
{
|
||||||
emit ToolTip(tr("Select main path objects clockwise, <b>Shift</b> - reverse direction curve, "
|
emit ToolTip(tr("Select main path objects clockwise, <b>Shift</b> - reverse direction curve, "
|
||||||
"<b>Enter</b> - finish creation"));
|
"<b>Enter</b> - finish creation"));
|
||||||
|
@ -329,7 +330,7 @@ void DialogSeamAllowance::NodeChanged(int index)
|
||||||
const int nodeIndex = piece.indexOfNode(id);
|
const int nodeIndex = piece.indexOfNode(id);
|
||||||
if (nodeIndex != -1)
|
if (nodeIndex != -1)
|
||||||
{
|
{
|
||||||
const VPieceNode &node = piece.at(nodeIndex);
|
const VPieceNode &node = piece.GetPath().at(nodeIndex);
|
||||||
|
|
||||||
ui->doubleSpinBoxSABefore->setEnabled(true);
|
ui->doubleSpinBoxSABefore->setEnabled(true);
|
||||||
ui->doubleSpinBoxSAAfter->setEnabled(true);
|
ui->doubleSpinBoxSAAfter->setEnabled(true);
|
||||||
|
@ -437,7 +438,7 @@ VPiece DialogSeamAllowance::CreatePiece() const
|
||||||
for (qint32 i = 0; i < ui->listWidget->count(); ++i)
|
for (qint32 i = 0; i < ui->listWidget->count(); ++i)
|
||||||
{
|
{
|
||||||
QListWidgetItem *item = ui->listWidget->item(i);
|
QListWidgetItem *item = ui->listWidget->item(i);
|
||||||
piece.Append(qvariant_cast<VPieceNode>(item->data(Qt::UserRole)));
|
piece.GetPath().Append(qvariant_cast<VPieceNode>(item->data(Qt::UserRole)));
|
||||||
}
|
}
|
||||||
|
|
||||||
piece.SetForbidFlipping(ui->checkBoxForbidFlipping->isChecked());
|
piece.SetForbidFlipping(ui->checkBoxForbidFlipping->isChecked());
|
||||||
|
@ -530,9 +531,9 @@ void DialogSeamAllowance::InitNodesList()
|
||||||
|
|
||||||
const VPiece piece = CreatePiece();
|
const VPiece piece = CreatePiece();
|
||||||
|
|
||||||
for (int i = 0; i < piece.CountNodes(); ++i)
|
for (int i = 0; i < piece.GetPath().CountNodes(); ++i)
|
||||||
{
|
{
|
||||||
const VPieceNode node = piece.at(i);
|
const VPieceNode node = piece.GetPath().at(i);
|
||||||
if (node.GetTypeTool() == Tool::NodePoint)
|
if (node.GetTypeTool() == Tool::NodePoint)
|
||||||
{
|
{
|
||||||
const QString name = GetNodeName(node);
|
const QString name = GetNodeName(node);
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "vtoolseamallowance.h"
|
#include "vtoolseamallowance.h"
|
||||||
#include "../dialogs/tools/dialogseamallowance.h"
|
#include "../dialogs/tools/dialogseamallowance.h"
|
||||||
#include "../vpatterndb/vpiecenode.h"
|
#include "../vpatterndb/vpiecenode.h"
|
||||||
|
#include "../vpatterndb/vpiecepath.h"
|
||||||
#include "nodeDetails/vnodearc.h"
|
#include "nodeDetails/vnodearc.h"
|
||||||
#include "nodeDetails/vnodepoint.h"
|
#include "nodeDetails/vnodepoint.h"
|
||||||
#include "nodeDetails/vnodespline.h"
|
#include "nodeDetails/vnodespline.h"
|
||||||
|
@ -88,10 +89,10 @@ VToolSeamAllowance *VToolSeamAllowance::Create(DialogTool *dialog, VMainGraphics
|
||||||
VPiece detail = dialogTool->GetPiece();
|
VPiece detail = dialogTool->GetPiece();
|
||||||
QVector<VPieceNode> nodes;
|
QVector<VPieceNode> nodes;
|
||||||
qApp->getUndoStack()->beginMacro("add detail");
|
qApp->getUndoStack()->beginMacro("add detail");
|
||||||
for (int i = 0; i< detail.CountNodes(); ++i)
|
for (int i = 0; i< detail.GetPath().CountNodes(); ++i)
|
||||||
{
|
{
|
||||||
quint32 id = 0;
|
quint32 id = 0;
|
||||||
VPieceNode nodeD = detail.at(i);
|
VPieceNode nodeD = detail.GetPath().at(i);
|
||||||
switch (nodeD.GetTypeTool())
|
switch (nodeD.GetTypeTool())
|
||||||
{
|
{
|
||||||
case (Tool::NodePoint):
|
case (Tool::NodePoint):
|
||||||
|
@ -142,7 +143,7 @@ VToolSeamAllowance *VToolSeamAllowance::Create(DialogTool *dialog, VMainGraphics
|
||||||
nodes.append(nodeD);
|
nodes.append(nodeD);
|
||||||
}
|
}
|
||||||
|
|
||||||
detail.SetNodes(nodes);
|
detail.GetPath().SetNodes(nodes);
|
||||||
VToolSeamAllowance *piece = Create(0, detail, scene, doc, data, Document::FullParse, Source::FromGui);
|
VToolSeamAllowance *piece = Create(0, detail, scene, doc, data, Document::FullParse, Source::FromGui);
|
||||||
|
|
||||||
if (piece != nullptr)
|
if (piece != nullptr)
|
||||||
|
@ -252,12 +253,12 @@ void VToolSeamAllowance::AddNode(VAbstractPattern *doc, QDomElement &domElement,
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolSeamAllowance::AddNodes(VAbstractPattern *doc, QDomElement &domElement, const VPiece &piece)
|
void VToolSeamAllowance::AddNodes(VAbstractPattern *doc, QDomElement &domElement, const VPiece &piece)
|
||||||
{
|
{
|
||||||
if (piece.CountNodes() > 0)
|
if (piece.GetPath().CountNodes() > 0)
|
||||||
{
|
{
|
||||||
QDomElement nodesElement = doc->createElement(TagNodes);
|
QDomElement nodesElement = doc->createElement(TagNodes);
|
||||||
for (int i = 0; i < piece.CountNodes(); ++i)
|
for (int i = 0; i < piece.GetPath().CountNodes(); ++i)
|
||||||
{
|
{
|
||||||
AddNode(doc, nodesElement, piece.at(i));
|
AddNode(doc, nodesElement, piece.GetPath().at(i));
|
||||||
}
|
}
|
||||||
domElement.appendChild(nodesElement);
|
domElement.appendChild(nodesElement);
|
||||||
}
|
}
|
||||||
|
@ -635,24 +636,24 @@ VToolSeamAllowance::VToolSeamAllowance(VAbstractPattern *doc, VContainer *data,
|
||||||
m_seamAllowance(new VNoBrushScalePathItem(this))
|
m_seamAllowance(new VNoBrushScalePathItem(this))
|
||||||
{
|
{
|
||||||
VPiece detail = data->GetPiece(id);
|
VPiece detail = data->GetPiece(id);
|
||||||
for (int i = 0; i< detail.CountNodes(); ++i)
|
for (int i = 0; i< detail.GetPath().CountNodes(); ++i)
|
||||||
{
|
{
|
||||||
switch (detail.at(i).GetTypeTool())
|
switch (detail.GetPath().at(i).GetTypeTool())
|
||||||
{
|
{
|
||||||
case (Tool::NodePoint):
|
case (Tool::NodePoint):
|
||||||
{
|
{
|
||||||
VNodePoint *tool = InitTool<VNodePoint>(scene, detail.at(i));
|
VNodePoint *tool = InitTool<VNodePoint>(scene, detail.GetPath().at(i));
|
||||||
connect(tool, &VNodePoint::ShowContextMenu, this, &VToolSeamAllowance::contextMenuEvent);
|
connect(tool, &VNodePoint::ShowContextMenu, this, &VToolSeamAllowance::contextMenuEvent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (Tool::NodeArc):
|
case (Tool::NodeArc):
|
||||||
doc->IncrementReferens(detail.at(i).GetId());
|
doc->IncrementReferens(detail.GetPath().at(i).GetId());
|
||||||
break;
|
break;
|
||||||
case (Tool::NodeSpline):
|
case (Tool::NodeSpline):
|
||||||
doc->IncrementReferens(detail.at(i).GetId());
|
doc->IncrementReferens(detail.GetPath().at(i).GetId());
|
||||||
break;
|
break;
|
||||||
case (Tool::NodeSplinePath):
|
case (Tool::NodeSplinePath):
|
||||||
doc->IncrementReferens(detail.at(i).GetId());
|
doc->IncrementReferens(detail.GetPath().at(i).GetId());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug()<<"Get wrong tool type. Ignore.";
|
qDebug()<<"Get wrong tool type. Ignore.";
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "addpiece.h"
|
#include "addpiece.h"
|
||||||
#include "../vpatterndb/vpiecenode.h"
|
#include "../vpatterndb/vpiecenode.h"
|
||||||
|
#include "../vpatterndb/vpiecepath.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
AddPiece::AddPiece(const QDomElement &xml, VAbstractPattern *doc, const VPiece &detail, const QString &drawName,
|
AddPiece::AddPiece(const QDomElement &xml, VAbstractPattern *doc, const VPiece &detail, const QString &drawName,
|
||||||
|
@ -61,7 +62,7 @@ void AddPiece::undo()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DecrementReferences(m_detail.GetNodes());
|
DecrementReferences(m_detail.GetPath().GetNodes());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "../tools/vdatatool.h"
|
#include "../tools/vdatatool.h"
|
||||||
#include "vundocommand.h"
|
#include "vundocommand.h"
|
||||||
#include "../vpatterndb/vpiecenode.h"
|
#include "../vpatterndb/vpiecenode.h"
|
||||||
|
#include "../vpatterndb/vpiecepath.h"
|
||||||
|
|
||||||
class QUndoCommand;
|
class QUndoCommand;
|
||||||
|
|
||||||
|
@ -105,7 +106,7 @@ void DeletePiece::redo()
|
||||||
SCASSERT(toolDet != nullptr);
|
SCASSERT(toolDet != nullptr);
|
||||||
toolDet->hide();
|
toolDet->hide();
|
||||||
|
|
||||||
DecrementReferences(m_detail.GetNodes());
|
DecrementReferences(m_detail.GetPath().GetNodes());
|
||||||
emit NeedFullParsing(); // Doesn't work when UnionDetail delete detail.
|
emit NeedFullParsing(); // Doesn't work when UnionDetail delete detail.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vistoolpiece.h"
|
#include "vistoolpiece.h"
|
||||||
|
#include "../vpatterndb/vpiecepath.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent)
|
VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent)
|
||||||
|
@ -49,7 +50,7 @@ void VisToolPiece::RefreshGeometry()
|
||||||
{
|
{
|
||||||
HideAllItems();
|
HideAllItems();
|
||||||
|
|
||||||
if (m_piece.CountNodes() > 0)
|
if (m_piece.GetPath().CountNodes() > 0)
|
||||||
{
|
{
|
||||||
DrawPath(this, m_piece.MainPathPath(Visualization::data), mainColor, Qt::SolidLine, Qt::RoundCap);
|
DrawPath(this, m_piece.MainPathPath(Visualization::data), mainColor, Qt::SolidLine, Qt::RoundCap);
|
||||||
|
|
||||||
|
@ -99,7 +100,6 @@ void VisToolPiece::HideAllItems()
|
||||||
m_line2->setVisible(false);
|
m_line2->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<QGraphicsEllipseItem *> m_points;
|
|
||||||
for (int i=0; i < m_points.size(); ++i)
|
for (int i=0; i < m_points.size(); ++i)
|
||||||
{
|
{
|
||||||
if (QGraphicsEllipseItem *item = m_points.at(i))
|
if (QGraphicsEllipseItem *item = m_points.at(i))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user