Added custom increment and decrement methods for tool VToolPiecePath.
--HG-- branch : feature
This commit is contained in:
parent
14962270f6
commit
b3f3f03cc3
|
@ -98,6 +98,55 @@ QString VToolPiecePath::getTagName() const
|
||||||
return VAbstractPattern::TagPath;
|
return VAbstractPattern::TagPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolPiecePath::incrementReferens()
|
||||||
|
{
|
||||||
|
++_referens;
|
||||||
|
if (_referens == 1)
|
||||||
|
{
|
||||||
|
if (idTool != NULL_ID)
|
||||||
|
{
|
||||||
|
doc->IncrementReferens(idTool);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IncrementNodes(VAbstractTool::data.GetPiecePath(id));
|
||||||
|
}
|
||||||
|
ShowNode();
|
||||||
|
QDomElement domElement = doc->elementById(id);
|
||||||
|
if (domElement.isElement())
|
||||||
|
{
|
||||||
|
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::InUse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolPiecePath::decrementReferens()
|
||||||
|
{
|
||||||
|
if (_referens > 0)
|
||||||
|
{
|
||||||
|
--_referens;
|
||||||
|
}
|
||||||
|
if (_referens == 0)
|
||||||
|
{
|
||||||
|
if (idTool != NULL_ID)
|
||||||
|
{
|
||||||
|
doc->DecrementReferens(idTool);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DecrementNodes(VAbstractTool::data.GetPiecePath(id));
|
||||||
|
}
|
||||||
|
HideNode();
|
||||||
|
QDomElement domElement = doc->elementById(id);
|
||||||
|
if (domElement.isElement())
|
||||||
|
{
|
||||||
|
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::NotInUse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolPiecePath::AddNode(VAbstractPattern *doc, QDomElement &domElement, const VPieceNode &node)
|
void VToolPiecePath::AddNode(VAbstractPattern *doc, QDomElement &domElement, const VPieceNode &node)
|
||||||
{
|
{
|
||||||
|
@ -241,3 +290,23 @@ void VToolPiecePath::RefreshGeometry()
|
||||||
this->setPath(p);
|
this->setPath(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolPiecePath::IncrementNodes(const VPiecePath &path) const
|
||||||
|
{
|
||||||
|
for (int i = 0; i < path.CountNodes(); ++i)
|
||||||
|
{
|
||||||
|
const QSharedPointer<VGObject> node = VAbstractTool::data.GetGObject(path.at(i).GetId());
|
||||||
|
doc->IncrementReferens(node->getIdTool());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolPiecePath::DecrementNodes(const VPiecePath &path) const
|
||||||
|
{
|
||||||
|
for (int i = 0; i < path.CountNodes(); ++i)
|
||||||
|
{
|
||||||
|
const QSharedPointer<VGObject> node = VAbstractTool::data.GetGObject(path.at(i).GetId());
|
||||||
|
doc->DecrementReferens(node->getIdTool());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -50,6 +50,9 @@ public:
|
||||||
enum { Type = UserType + static_cast<int>(Tool::PiecePath)};
|
enum { Type = UserType + static_cast<int>(Tool::PiecePath)};
|
||||||
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
virtual void incrementReferens() Q_DECL_OVERRIDE;
|
||||||
|
virtual void decrementReferens() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
static void AddNode(VAbstractPattern *doc, QDomElement &domElement, const VPieceNode &node);
|
static void AddNode(VAbstractPattern *doc, QDomElement &domElement, const VPieceNode &node);
|
||||||
static void AddNodes(VAbstractPattern *doc, QDomElement &domElement, const VPiecePath &path);
|
static void AddNodes(VAbstractPattern *doc, QDomElement &domElement, const VPiecePath &path);
|
||||||
static void AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, const VPiecePath &path);
|
static void AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, const VPiecePath &path);
|
||||||
|
@ -72,6 +75,9 @@ private:
|
||||||
QGraphicsItem * parent = nullptr );
|
QGraphicsItem * parent = nullptr );
|
||||||
|
|
||||||
void RefreshGeometry();
|
void RefreshGeometry();
|
||||||
|
|
||||||
|
void IncrementNodes(const VPiecePath &path) const;
|
||||||
|
void DecrementNodes(const VPiecePath &path) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLPIECEPATH_H
|
#endif // VTOOLPIECEPATH_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user