Union Details tool now supports pin points.
--HG-- branch : feature
This commit is contained in:
parent
3f8dc54acb
commit
8549e55fec
|
@ -67,6 +67,7 @@
|
|||
#include "nodeDetails/vnodespline.h"
|
||||
#include "nodeDetails/vnodesplinepath.h"
|
||||
#include "nodeDetails/vtoolpiecepath.h"
|
||||
#include "nodeDetails/vtoolpin.h"
|
||||
#include "vdatatool.h"
|
||||
#include "vnodedetail.h"
|
||||
#include "vtoolseamallowance.h"
|
||||
|
@ -202,6 +203,37 @@ QVector<quint32> GetPiece2InternalPaths(VAbstractPattern *doc, quint32 id)
|
|||
return QVector<quint32>();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<quint32> GetPiece2Pins(VAbstractPattern *doc, quint32 id)
|
||||
{
|
||||
const QDomElement tool = doc->elementById(id);
|
||||
if (tool.isNull())
|
||||
{
|
||||
VException e(QString("Can't get tool by id='%1'.").arg(id));
|
||||
throw e;
|
||||
}
|
||||
|
||||
const QDomNodeList nodesList = tool.childNodes();
|
||||
for (qint32 i = 0; i < nodesList.size(); ++i)
|
||||
{
|
||||
const QDomElement element = nodesList.at(i).toElement();
|
||||
if (not element.isNull() && element.tagName() == VToolUnionDetails::TagDetail && i+1 == 2)
|
||||
{
|
||||
const QDomNodeList detList = element.childNodes();
|
||||
for (qint32 j = 0; j < detList.size(); ++j)
|
||||
{
|
||||
const QDomElement element = detList.at(j).toElement();
|
||||
if (not element.isNull() && element.tagName() == VToolSeamAllowance::TagPins)
|
||||
{
|
||||
return VAbstractPattern::ParsePiecePins(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QVector<quint32>();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DrawName(VAbstractPattern *doc, quint32 d1id, quint32 d2id)
|
||||
{
|
||||
|
@ -354,6 +386,29 @@ quint32 AddNodePoint(const VPieceNode &node, const VToolUnionDetailsInitData &in
|
|||
return id;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 AddPin(quint32 id, const VToolUnionDetailsInitData &initData, quint32 idTool, QVector<quint32> &children,
|
||||
const QString &drawName, qreal dx, qreal dy, quint32 pRotate, qreal angle)
|
||||
{
|
||||
QScopedPointer<VPointF> point(new VPointF(*initData.data->GeometricObject<VPointF>(id)));
|
||||
point->setMode(Draw::Modeling);
|
||||
|
||||
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID)
|
||||
{
|
||||
BiasRotatePoint(point.data(), dx, dy, *initData.data->GeometricObject<VPointF>(pRotate), angle);
|
||||
}
|
||||
|
||||
QScopedPointer<VPointF> point1(new VPointF(*point));
|
||||
|
||||
const quint32 idObject = initData.data->AddGObject(point.take());
|
||||
children.append(idObject);
|
||||
point1->setMode(Draw::Modeling);
|
||||
const quint32 idPin = initData.data->AddGObject(point1.take());
|
||||
VToolPin::Create(idPin, idObject, 0, initData.doc, initData.data, Document::FullParse, Source::FromTool, drawName,
|
||||
idTool);
|
||||
return idPin;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 AddNodeArc(const VPieceNode &node, const VToolUnionDetailsInitData &initData, quint32 idTool,
|
||||
QVector<quint32> &children, const QString &drawName, qreal dx, qreal dy,
|
||||
|
@ -653,6 +708,12 @@ void SaveInternalPathsChildren(VAbstractPattern *doc, quint32 id, const QVector<
|
|||
SaveChildren(doc, id, doc->createElement(VToolSeamAllowance::TagIPaths), children);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void SavePinsChildren(VAbstractPattern *doc, quint32 id, const QVector<quint32> &children)
|
||||
{
|
||||
SaveChildren(doc, id, doc->createElement(VToolSeamAllowance::TagPins), children);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<quint32> GetChildren(VAbstractPattern *doc, quint32 id, const QString &tagName)
|
||||
{
|
||||
|
@ -705,6 +766,12 @@ QVector<quint32> GetInternalPathsChildren(VAbstractPattern *doc, quint32 id)
|
|||
return GetChildren(doc, id, VToolSeamAllowance::TagIPaths);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<quint32> GetPinChildren(VAbstractPattern *doc, quint32 id)
|
||||
{
|
||||
return GetChildren(doc, id, VToolSeamAllowance::TagPins);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 TakeNextId(QVector<quint32> &children)
|
||||
{
|
||||
|
@ -1038,6 +1105,35 @@ void CreateUnitedInternalPaths(VPiece &newDetail, const VPiece &d1, const VPiece
|
|||
SaveInternalPathsChildren(initData.doc, id, children);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void CreateUnitedDetailPins(VPiece &newDetail, const VPiece &d, QVector<quint32> &children, quint32 idTool,
|
||||
const QString &drawName, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy,
|
||||
quint32 pRotate, qreal angle)
|
||||
{
|
||||
QVector<quint32> nodeChildren;
|
||||
for(int i=0; i < d.GetPins().size(); ++i)
|
||||
{
|
||||
const quint32 id = AddPin(d.GetPins().at(i), initData, idTool, children, drawName, dx, dy, pRotate, angle);
|
||||
newDetail.GetPins().append(id);
|
||||
nodeChildren.prepend(id);
|
||||
}
|
||||
children += nodeChildren;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void CreateUnitedPins(VPiece &newDetail, const VPiece &d1, const VPiece &d2, quint32 id, const QString &drawName,
|
||||
const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle)
|
||||
{
|
||||
for (int i = 0; i < d1.GetPins().size(); ++i)
|
||||
{
|
||||
newDetail.GetPins().append(d1.GetPins().at(i));
|
||||
}
|
||||
|
||||
QVector<quint32> children;
|
||||
CreateUnitedDetailPins(newDetail, d2, children, id, drawName, initData, dx, dy, pRotate, angle);
|
||||
SavePinsChildren(initData.doc, id, children);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void UpdateUnitedNodes(quint32 id, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate,
|
||||
qreal angle)
|
||||
|
@ -1157,6 +1253,24 @@ void UpdateUnitedDetailInternalPaths(quint32 id, const VToolUnionDetailsInitData
|
|||
UpdateUnitedDetailPaths(initData, dx, dy, pRotate, angle, records, GetInternalPathsChildren(initData.doc, id));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void UpdateUnitedDetailPins(quint32 id, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy,
|
||||
quint32 pRotate, qreal angle, const QVector<quint32> &records)
|
||||
{
|
||||
QVector<quint32> children = GetPinChildren(initData.doc, id);
|
||||
|
||||
for (int i = 0; i < records.size(); ++i)
|
||||
{
|
||||
QScopedPointer<VPointF> point(new VPointF(*initData.data->GeometricObject<VPointF>(records.at(i))));
|
||||
point->setMode(Draw::Modeling);
|
||||
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID)
|
||||
{
|
||||
BiasRotatePoint(point.data(), dx, dy, *initData.data->GeometricObject<VPointF>(pRotate), angle);
|
||||
}
|
||||
initData.data->UpdateGObject(TakeNextId(children), point.take());
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void CreateUnitedDetail(quint32 id, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate,
|
||||
qreal angle)
|
||||
|
@ -1172,6 +1286,7 @@ void CreateUnitedDetail(quint32 id, const VToolUnionDetailsInitData &initData, q
|
|||
CreateUnitedNodes(newDetail, d1, d2, id, drawName, initData, dx, dy, pRotate, angle);
|
||||
CreateUnitedCSA(newDetail, d1, d2, id, drawName, initData, dx, dy, pRotate, angle);
|
||||
CreateUnitedInternalPaths(newDetail, d1, d2, id, drawName, initData, dx, dy, pRotate, angle);
|
||||
CreateUnitedPins(newDetail, d1, d2, id, drawName, initData, dx, dy, pRotate, angle);
|
||||
|
||||
newDetail.SetName(QObject::tr("United detail"));
|
||||
QString formulaSAWidth = d1.GetFormulaSAWidth();
|
||||
|
@ -1207,6 +1322,7 @@ void UpdateUnitedDetail(quint32 id, const VToolUnionDetailsInitData &initData, q
|
|||
UpdateUnitedNodes(id, initData, dx, dy, pRotate, angle);
|
||||
UpdateUnitedDetailCSA(id, initData, dx, dy, pRotate, angle, GetPiece2CSAPaths(initData.doc, id));
|
||||
UpdateUnitedDetailInternalPaths(id, initData, dx, dy, pRotate, angle, GetPiece2InternalPaths(initData.doc, id));
|
||||
UpdateUnitedDetailPins(id, initData, dx, dy, pRotate, angle, GetPiece2Pins(initData.doc, id));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user