First successful build. The redesign is not finished.
--HG-- branch : feature
This commit is contained in:
parent
60810c4d04
commit
6faa0bc318
|
@ -3164,13 +3164,17 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d
|
||||||
{
|
{
|
||||||
quint32 id = 0;
|
quint32 id = 0;
|
||||||
ToolsCommonAttributes(domElement, id);
|
ToolsCommonAttributes(domElement, id);
|
||||||
const quint32 indexD1 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD1, "-1");
|
|
||||||
const quint32 indexD2 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD2, "-1");
|
|
||||||
|
|
||||||
const QVector<VDetail> vector = VToolUnionDetails::GetDetailFromFile(this, domElement);
|
VToolUnionDetailsInitData initData;
|
||||||
|
initData.indexD1 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD1, "-1");
|
||||||
|
initData.indexD2 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD2, "-1");
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = this;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = parse;
|
||||||
|
initData.typeCreation = Source::FromFile;
|
||||||
|
|
||||||
VToolUnionDetails::Create(id, vector[0], vector[1], 0, 0, indexD1, indexD2, scene, this, data, parse,
|
VToolUnionDetails::Create(id, initData);
|
||||||
Source::FromFile);
|
|
||||||
}
|
}
|
||||||
catch (const VExceptionBadId &e)
|
catch (const VExceptionBadId &e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -361,6 +361,92 @@ int VPiecePath::indexOfNode(quint32 id) const
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief NodeOnEdge return nodes located on edge with index.
|
||||||
|
* @param index index of edge.
|
||||||
|
* @param p1 first node.
|
||||||
|
* @param p2 second node.
|
||||||
|
*/
|
||||||
|
void VPiecePath::NodeOnEdge(quint32 index, VPieceNode &p1, VPieceNode &p2) const
|
||||||
|
{
|
||||||
|
const QVector<VPieceNode> list = ListNodePoint();
|
||||||
|
if (index > static_cast<quint32>(list.size()))
|
||||||
|
{
|
||||||
|
qDebug()<<"Wrong edge index index ="<<index;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
p1 = list.at(static_cast<int>(index));
|
||||||
|
if (index + 1 > static_cast<quint32>(list.size()) - 1)
|
||||||
|
{
|
||||||
|
p2 = list.at(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p2 = list.at(static_cast<int>(index+1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief listNodePoint return list nodes only with points.
|
||||||
|
* @return list points node.
|
||||||
|
*/
|
||||||
|
QVector<VPieceNode> VPiecePath::ListNodePoint() const
|
||||||
|
{
|
||||||
|
QVector<VPieceNode> list;
|
||||||
|
for (int i = 0; i < d->m_nodes.size(); ++i) //-V807
|
||||||
|
{
|
||||||
|
if (d->m_nodes.at(i).GetTypeTool() == Tool::NodePoint)
|
||||||
|
{
|
||||||
|
list.append(d->m_nodes.at(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief RemoveEdge return path without edge with index.
|
||||||
|
* @param index idex of edge.
|
||||||
|
* @return path without edge with index.
|
||||||
|
*/
|
||||||
|
VPiecePath VPiecePath::RemoveEdge(quint32 index) const
|
||||||
|
{
|
||||||
|
VPiecePath path(*this);
|
||||||
|
path.Clear();
|
||||||
|
|
||||||
|
// Edge can be only segment. We ignore all curves inside segments.
|
||||||
|
const quint32 edges = static_cast<quint32>(ListNodePoint().size());
|
||||||
|
quint32 k = 0;
|
||||||
|
for (quint32 i=0; i<edges; ++i)
|
||||||
|
{
|
||||||
|
if (i == index)
|
||||||
|
{
|
||||||
|
path.Append(this->at(static_cast<int>(k)));
|
||||||
|
++k;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VPieceNode p1;
|
||||||
|
VPieceNode p2;
|
||||||
|
this->NodeOnEdge(i, p1, p2);
|
||||||
|
const int j1 = this->indexOfNode(p1.GetId());
|
||||||
|
int j2 = this->indexOfNode(p2.GetId());
|
||||||
|
if (j2 == 0)
|
||||||
|
{
|
||||||
|
j2 = this->CountNodes();
|
||||||
|
}
|
||||||
|
for (int j=j1; j<j2; ++j)
|
||||||
|
{// Add "segment" except last point. Inside can be curves too.
|
||||||
|
path.Append(this->at(j));
|
||||||
|
++k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VSAPoint VPiecePath::StartSegment(const VContainer *data, int i, bool reverse) const
|
VSAPoint VPiecePath::StartSegment(const VContainer *data, int i, bool reverse) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -80,6 +80,11 @@ public:
|
||||||
QVector<quint32> MissingNodes(const VPiecePath &path) const;
|
QVector<quint32> MissingNodes(const VPiecePath &path) const;
|
||||||
|
|
||||||
int indexOfNode(quint32 id) const;
|
int indexOfNode(quint32 id) const;
|
||||||
|
void NodeOnEdge(quint32 index, VPieceNode &p1, VPieceNode &p2) const;
|
||||||
|
|
||||||
|
QVector<VPieceNode> ListNodePoint() const;
|
||||||
|
|
||||||
|
VPiecePath RemoveEdge(quint32 index) const;
|
||||||
|
|
||||||
VSAPoint StartSegment(const VContainer *data, 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;
|
VSAPoint EndSegment(const VContainer *data, int i, bool reverse) const;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -43,7 +43,7 @@
|
||||||
#include "../ifc/xml/vabstractpattern.h"
|
#include "../ifc/xml/vabstractpattern.h"
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "vabstracttool.h"
|
#include "vabstracttool.h"
|
||||||
#include "vdetail.h"
|
#include "../vpatterndb/vpiece.h"
|
||||||
|
|
||||||
class DialogTool;
|
class DialogTool;
|
||||||
class QDomElement;
|
class QDomElement;
|
||||||
|
@ -54,6 +54,33 @@ class VMainGraphicsScene;
|
||||||
class VNodeDetail;
|
class VNodeDetail;
|
||||||
class VPointF;
|
class VPointF;
|
||||||
|
|
||||||
|
struct VToolUnionDetailsInitData
|
||||||
|
{
|
||||||
|
VToolUnionDetailsInitData()
|
||||||
|
: d1id(NULL_ID),
|
||||||
|
d2id(NULL_ID),
|
||||||
|
indexD1(NULL_ID),
|
||||||
|
indexD2(NULL_ID),
|
||||||
|
scene(nullptr),
|
||||||
|
doc(nullptr),
|
||||||
|
data(nullptr),
|
||||||
|
parse(Document::FullParse),
|
||||||
|
typeCreation(Source::FromFile),
|
||||||
|
retainPieces(false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 d1id;
|
||||||
|
quint32 d2id;
|
||||||
|
quint32 indexD1;
|
||||||
|
quint32 indexD2;
|
||||||
|
VMainGraphicsScene *scene;
|
||||||
|
VAbstractPattern *doc;
|
||||||
|
VContainer *data;
|
||||||
|
Document parse;
|
||||||
|
Source typeCreation;
|
||||||
|
bool retainPieces;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolUnionDetails class tool union details.
|
* @brief The VToolUnionDetails class tool union details.
|
||||||
*/
|
*/
|
||||||
|
@ -67,13 +94,7 @@ public:
|
||||||
virtual void setDialog() {}
|
virtual void setDialog() {}
|
||||||
static VToolUnionDetails *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
static VToolUnionDetails *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
VContainer *data);
|
VContainer *data);
|
||||||
static VToolUnionDetails *Create(const quint32 _id, const VDetail &d1, const VDetail &d2, const quint32 &d1id,
|
static VToolUnionDetails *Create(const quint32 _id, const VToolUnionDetailsInitData &initData);
|
||||||
const quint32 &d2id, const quint32 &indexD1, const quint32 &indexD2,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse,
|
|
||||||
const Source &typeCreation,
|
|
||||||
bool retainPieces = false);
|
|
||||||
static QVector<VDetail> GetDetailFromFile(VAbstractPattern *doc, const QDomElement &domElement);
|
|
||||||
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
static const QString TagDetail;
|
static const QString TagDetail;
|
||||||
|
@ -105,11 +126,11 @@ protected:
|
||||||
virtual void SetVisualization() Q_DECL_OVERRIDE {}
|
virtual void SetVisualization() Q_DECL_OVERRIDE {}
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VToolUnionDetails)
|
Q_DISABLE_COPY(VToolUnionDetails)
|
||||||
/** @brief d1 first detail. */
|
/** @brief d1 first detail id. */
|
||||||
VDetail d1;
|
quint32 d1id;
|
||||||
|
|
||||||
/** @brief d2 second detail. */
|
/** @brief d2 second detail id. */
|
||||||
VDetail d2;
|
quint32 d2id;
|
||||||
|
|
||||||
/** @brief indexD1 index edge in first detail. */
|
/** @brief indexD1 index edge in first detail. */
|
||||||
quint32 indexD1;
|
quint32 indexD1;
|
||||||
|
@ -117,36 +138,12 @@ private:
|
||||||
/** @brief indexD2 index edge in second detail. */
|
/** @brief indexD2 index edge in second detail. */
|
||||||
quint32 indexD2;
|
quint32 indexD2;
|
||||||
|
|
||||||
QString drawName;
|
VToolUnionDetails(quint32 id, const VToolUnionDetailsInitData &initData, QObject *parent = nullptr);
|
||||||
|
|
||||||
VToolUnionDetails(VAbstractPattern *doc, VContainer *data, const quint32 &id, const VDetail &d1, const VDetail &d2,
|
void AddDetail(QDomElement &domElement, const VPiece &d) const;
|
||||||
const quint32 &indexD1, const quint32 &indexD2, const Source &typeCreation,
|
|
||||||
const QString &drawName, QObject *parent = nullptr);
|
|
||||||
|
|
||||||
void AddDetail(QDomElement &domElement, VDetail &d);
|
|
||||||
void AddNode(QDomElement &domElement, const VNodeDetail &node);
|
|
||||||
QDomNode UpdateDetail(const QDomNode &domNode, const VDetail &d);
|
|
||||||
void AddToModeling(const QDomElement &domElement);
|
void AddToModeling(const QDomElement &domElement);
|
||||||
void IncrementReferences(const VDetail &d) const;
|
QVector<quint32> GetReferenceObjects() const;
|
||||||
void DecrementReferences(const VDetail &d) const;
|
QVector<quint32> NodesReferenceObjects(const QDomElement &nodes) const;
|
||||||
|
|
||||||
static void SaveChildren(VAbstractPattern *doc, quint32 id, const QVector<quint32> &children);
|
|
||||||
static QVector<quint32> AllChildren(VAbstractPattern *doc, quint32 id);
|
|
||||||
static quint32 TakeNextId(QVector<quint32> &children);
|
|
||||||
static QString DrawName(VAbstractPattern *doc, quint32 d1id, quint32 d2id);
|
|
||||||
static void PointsOnEdge(const VDetail &d, const quint32 &index, VPointF &p1, VPointF &p2,
|
|
||||||
VContainer *data);
|
|
||||||
static void FindIndexJ(const qint32 &pointsD2, const VDetail &d2, const quint32 &indexD2, qint32 &j);
|
|
||||||
static void AddToNewDetail(VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
VDetail &newDetail, const VDetail &det, const int &i, const quint32 &idTool,
|
|
||||||
QVector<quint32> &children, const QString &drawName, const qreal &dx = 0,
|
|
||||||
const qreal &dy = 0, const quint32 &pRotate = NULL_ID,
|
|
||||||
const qreal &angle = 0);
|
|
||||||
static void UpdatePoints(VContainer *data, const VDetail &det, const int &i, QVector<quint32> &children,
|
|
||||||
const qreal &dx = 0, const qreal &dy = 0, const quint32 &pRotate = NULL_ID,
|
|
||||||
const qreal &angle = 0);
|
|
||||||
static void BiasRotatePoint(VPointF *point, const qreal &dx, const qreal &dy, const QPointF &pRotate,
|
|
||||||
const qreal &angle);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLUNIONDETAILS_H
|
#endif // VTOOLUNIONDETAILS_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user