Increment custom seam allowance in tool seam allowance.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-11-25 16:37:32 +02:00
parent 82d9fcba3f
commit 20f8da230d
2 changed files with 44 additions and 24 deletions

View file

@ -665,30 +665,8 @@ VToolSeamAllowance::VToolSeamAllowance(VAbstractPattern *doc, VContainer *data,
m_seamAllowance(new VNoBrushScalePathItem(this))
{
VPiece detail = data->GetPiece(id);
for (int i = 0; i< detail.GetPath().CountNodes(); ++i)
{
switch (detail.GetPath().at(i).GetTypeTool())
{
case (Tool::NodePoint):
{
VNodePoint *tool = InitTool<VNodePoint>(scene, detail.GetPath().at(i));
connect(tool, &VNodePoint::ShowContextMenu, this, &VToolSeamAllowance::contextMenuEvent);
break;
}
case (Tool::NodeArc):
doc->IncrementReferens(detail.GetPath().at(i).GetId());
break;
case (Tool::NodeSpline):
doc->IncrementReferens(detail.GetPath().at(i).GetId());
break;
case (Tool::NodeSplinePath):
doc->IncrementReferens(detail.GetPath().at(i).GetId());
break;
default:
qDebug()<<"Get wrong tool type. Ignore.";
break;
}
}
InitNodes(detail, scene);
InitCSAPaths(detail);
this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
RefreshGeometry();
@ -754,6 +732,45 @@ void VToolSeamAllowance::SaveDialogChange()
qApp->getUndoStack()->push(saveCommand);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::InitNodes(const VPiece &detail, VMainGraphicsScene *scene)
{
for (int i = 0; i< detail.GetPath().CountNodes(); ++i)
{
switch (detail.GetPath().at(i).GetTypeTool())
{
case (Tool::NodePoint):
{
VNodePoint *tool = InitTool<VNodePoint>(scene, detail.GetPath().at(i));
connect(tool, &VNodePoint::ShowContextMenu, this, &VToolSeamAllowance::contextMenuEvent);
break;
}
case (Tool::NodeArc):
doc->IncrementReferens(detail.GetPath().at(i).GetId());
break;
case (Tool::NodeSpline):
doc->IncrementReferens(detail.GetPath().at(i).GetId());
break;
case (Tool::NodeSplinePath):
doc->IncrementReferens(detail.GetPath().at(i).GetId());
break;
default:
qDebug()<<"Get wrong tool type. Ignore.";
break;
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::InitCSAPaths(const VPiece &detail)
{
QVector<CustomSARecord> records = detail.GetCustomSARecords();
for (int i = 0; i < records.size(); ++i)
{
doc->IncrementReferens(records.at(i).path);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::DeleteTool(bool ask)
{

View file

@ -130,6 +130,9 @@ private:
void RefreshGeometry();
void SaveDialogChange();
void InitNodes(const VPiece &detail, VMainGraphicsScene *scene);
void InitCSAPaths(const VPiece &detail);
template <typename Tool>
Tool* InitTool(VMainGraphicsScene *scene, const VPieceNode &node);
};