Fixed issue with deleting detail (after union details) and blocked objects.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-12-26 19:10:02 +02:00
parent 1aa2263686
commit 37e799ce71
17 changed files with 83 additions and 100 deletions

View File

@ -1279,11 +1279,10 @@ void VPattern::ParseNodePoint(const QDomElement &domElement, const Document &par
PointsCommonAttributes(domElement, id, mx, my); PointsCommonAttributes(domElement, id, mx, my);
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR); const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR);
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR); const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
const NodeUsage inUse = GetParametrUsage(domElement, VAbstractNode::AttrInUse);
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idObject ); const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idObject );
data->UpdateGObject(id, new VPointF(point->toQPointF(), point->name(), mx, my, idObject, data->UpdateGObject(id, new VPointF(point->toQPointF(), point->name(), mx, my, idObject,
Draw::Modeling)); Draw::Modeling));
VNodePoint::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, inUse, idTool); VNodePoint::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, idTool);
} }
catch (const VExceptionBadId &e) catch (const VExceptionBadId &e)
{ {
@ -1900,12 +1899,11 @@ void VPattern::ParseNodeSpline(const QDomElement &domElement, const Document &pa
quint32 idTool = 0; quint32 idTool = 0;
SplinesCommonAttributes(domElement, id, idObject, idTool); SplinesCommonAttributes(domElement, id, idObject, idTool);
const NodeUsage inUse = GetParametrUsage(domElement, VAbstractNode::AttrInUse);
VSpline *spl = new VSpline(*data->GeometricObject<VSpline>(idObject)); VSpline *spl = new VSpline(*data->GeometricObject<VSpline>(idObject));
spl->setIdObject(idObject); spl->setIdObject(idObject);
spl->setMode(Draw::Modeling); spl->setMode(Draw::Modeling);
data->UpdateGObject(id, spl); data->UpdateGObject(id, spl);
VNodeSpline::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, inUse, idTool); VNodeSpline::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, idTool);
} }
catch (const VExceptionBadId &e) catch (const VExceptionBadId &e)
{ {
@ -1927,12 +1925,11 @@ void VPattern::ParseNodeSplinePath(const QDomElement &domElement, const Document
quint32 idTool = 0; quint32 idTool = 0;
SplinesCommonAttributes(domElement, id, idObject, idTool); SplinesCommonAttributes(domElement, id, idObject, idTool);
const NodeUsage inUse = GetParametrUsage(domElement, VAbstractNode::AttrInUse);
VSplinePath *path = new VSplinePath(*data->GeometricObject<VSplinePath>(idObject)); VSplinePath *path = new VSplinePath(*data->GeometricObject<VSplinePath>(idObject));
path->setIdObject(idObject); path->setIdObject(idObject);
path->setMode(Draw::Modeling); path->setMode(Draw::Modeling);
data->UpdateGObject(id, path); data->UpdateGObject(id, path);
VNodeSplinePath::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, inUse, idTool); VNodeSplinePath::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, idTool);
} }
catch (const VExceptionBadId &e) catch (const VExceptionBadId &e)
{ {
@ -1999,12 +1996,11 @@ void VPattern::ParseNodeArc(const QDomElement &domElement, const Document &parse
ToolsCommonAttributes(domElement, id); ToolsCommonAttributes(domElement, id);
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR); const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR);
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR); const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
const NodeUsage inUse = GetParametrUsage(domElement, VAbstractNode::AttrInUse);
VArc *arc = new VArc(*data->GeometricObject<VArc>(idObject)); VArc *arc = new VArc(*data->GeometricObject<VArc>(idObject));
arc->setIdObject(idObject); arc->setIdObject(idObject);
arc->setMode(Draw::Modeling); arc->setMode(Draw::Modeling);
data->UpdateGObject(id, arc); data->UpdateGObject(id, arc);
VNodeArc::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, inUse, idTool); VNodeArc::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, idTool);
} }
catch (const VExceptionBadId &e) catch (const VExceptionBadId &e)
{ {

View File

@ -256,6 +256,7 @@
<xs:attribute name="type" type="xs:string"></xs:attribute> <xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="indexD1" type="xs:unsignedInt"></xs:attribute> <xs:attribute name="indexD1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="indexD2" type="xs:unsignedInt"></xs:attribute> <xs:attribute name="indexD2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
</xs:choice> </xs:choice>

View File

@ -33,7 +33,6 @@
const QString VAbstractNode::AttrIdObject = QStringLiteral("idObject"); const QString VAbstractNode::AttrIdObject = QStringLiteral("idObject");
const QString VAbstractNode::AttrIdTool = QStringLiteral("idTool"); const QString VAbstractNode::AttrIdTool = QStringLiteral("idTool");
const QString VAbstractNode::AttrInUse = QStringLiteral("inUse");
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -61,11 +60,8 @@ void VAbstractNode::ShowVisualization(bool show)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractNode::incrementReferens() void VAbstractNode::incrementReferens()
{ {
if (_referens <= 0) ++_referens;
{ if (_referens == 1)
++_referens;
}
if (_referens > 0)
{ {
idTool != NULL_ID ? doc->IncrementReferens(idTool) : doc->IncrementReferens(idNode); idTool != NULL_ID ? doc->IncrementReferens(idTool) : doc->IncrementReferens(idNode);
ShowNode(); ShowNode();
@ -87,7 +83,7 @@ void VAbstractNode::decrementReferens()
{ {
--_referens; --_referens;
} }
if (_referens <= 0) if (_referens == 0)
{ {
idTool != NULL_ID ? doc->DecrementReferens(idTool) : doc->DecrementReferens(idNode); idTool != NULL_ID ? doc->DecrementReferens(idTool) : doc->DecrementReferens(idNode);
HideNode(); HideNode();

View File

@ -45,7 +45,6 @@ public:
virtual ~VAbstractNode() Q_DECL_OVERRIDE {} virtual ~VAbstractNode() Q_DECL_OVERRIDE {}
static const QString AttrIdObject; static const QString AttrIdObject;
static const QString AttrIdTool; static const QString AttrIdTool;
static const QString AttrInUse;
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
virtual void incrementReferens() Q_DECL_OVERRIDE; virtual void incrementReferens() Q_DECL_OVERRIDE;
virtual void decrementReferens() Q_DECL_OVERRIDE; virtual void decrementReferens() Q_DECL_OVERRIDE;

View File

@ -69,8 +69,7 @@ VNodeArc::VNodeArc(VAbstractPattern *doc, VContainer *data, quint32 id, quint32
* @param parent QObject parent * @param parent QObject parent
*/ */
void VNodeArc::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id, quint32 idArc, void VNodeArc::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id, quint32 idArc,
const Document &parse, const Document &parse, const Source &typeCreation, const quint32 &idTool, QObject *parent)
const Source &typeCreation, const NodeUsage &inUse, const quint32 &idTool, QObject *parent)
{ {
VAbstractTool::AddRecord(id, Tool::NodeArc, doc); VAbstractTool::AddRecord(id, Tool::NodeArc, doc);
if (parse == Document::FullParse) if (parse == Document::FullParse)
@ -84,22 +83,11 @@ void VNodeArc::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScen
doc->AddTool(id, arc); doc->AddTool(id, arc);
if (idTool != NULL_ID) if (idTool != NULL_ID)
{ {
if (inUse == NodeUsage::InUse)
{
doc->IncrementReferens(idTool);
}
//Some nodes we don't show on scene. Tool that create this nodes must free memory. //Some nodes we don't show on scene. Tool that create this nodes must free memory.
VDataTool *tool = doc->getTool(idTool); VDataTool *tool = doc->getTool(idTool);
SCASSERT(tool != nullptr); SCASSERT(tool != nullptr);
arc->setParent(tool);// Adopted by a tool arc->setParent(tool);// Adopted by a tool
} }
else
{
if (inUse == NodeUsage::InUse)
{
doc->IncrementReferens(idArc);
}
}
} }
else else
{ {

View File

@ -44,8 +44,7 @@ public:
static void Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id, static void Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id,
quint32 idArc, const Document &parse, quint32 idArc, const Document &parse,
const Source &typeCreation, const NodeUsage &inUse, const quint32 &idTool = 0, const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr);
QObject *parent = nullptr);
static const QString TagName; static const QString TagName;
static const QString ToolType; static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;} virtual int type() const Q_DECL_OVERRIDE {return Type;}

View File

@ -81,7 +81,7 @@ VNodePoint::VNodePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quin
*/ */
void VNodePoint::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, void VNodePoint::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene,
quint32 id, quint32 idPoint, const Document &parse, quint32 id, quint32 idPoint, const Document &parse,
const Source &typeCreation, const NodeUsage &inUse, const quint32 &idTool, QObject *parent) const Source &typeCreation, const quint32 &idTool, QObject *parent)
{ {
VAbstractTool::AddRecord(id, Tool::NodePoint, doc); VAbstractTool::AddRecord(id, Tool::NodePoint, doc);
if (parse == Document::FullParse) if (parse == Document::FullParse)
@ -98,22 +98,11 @@ void VNodePoint::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsSc
doc->AddTool(id, point); doc->AddTool(id, point);
if (idTool != NULL_ID) if (idTool != NULL_ID)
{ {
if (inUse == NodeUsage::InUse)
{
doc->IncrementReferens(idTool);
}
//Some nodes we don't show on scene. Tool that create this nodes must free memory. //Some nodes we don't show on scene. Tool that create this nodes must free memory.
VDataTool *tool = doc->getTool(idTool); VDataTool *tool = doc->getTool(idTool);
SCASSERT(tool != nullptr); SCASSERT(tool != nullptr);
point->setParent(tool);// Adopted by a tool point->setParent(tool);// Adopted by a tool
} }
else
{
if (inUse == NodeUsage::InUse)
{
doc->IncrementReferens(idPoint);
}
}
} }
else else
{ {

View File

@ -50,8 +50,7 @@ public:
static void Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, static void Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene,
quint32 id, quint32 idPoint, const Document &parse, quint32 id, quint32 idPoint, const Document &parse,
const Source &typeCreation, const NodeUsage &inUse, const quint32 &idTool = 0, const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr);
QObject *parent = nullptr);
static const QString TagName; static const QString TagName;
static const QString ToolType; static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;} virtual int type() const Q_DECL_OVERRIDE {return Type;}

View File

@ -71,8 +71,7 @@ VNodeSpline::VNodeSpline(VAbstractPattern *doc, VContainer *data, quint32 id, qu
*/ */
VNodeSpline *VNodeSpline::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id, VNodeSpline *VNodeSpline::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id,
quint32 idSpline, const Document &parse, quint32 idSpline, const Document &parse,
const Source &typeCreation, const NodeUsage &inUse, const quint32 &idTool, const Source &typeCreation, const quint32 &idTool, QObject *parent)
QObject *parent)
{ {
VAbstractTool::AddRecord(id, Tool::NodeSpline, doc); VAbstractTool::AddRecord(id, Tool::NodeSpline, doc);
VNodeSpline *spl = nullptr; VNodeSpline *spl = nullptr;
@ -87,22 +86,11 @@ VNodeSpline *VNodeSpline::Create(VAbstractPattern *doc, VContainer *data, VMainG
doc->AddTool(id, spl); doc->AddTool(id, spl);
if (idTool != NULL_ID) if (idTool != NULL_ID)
{ {
if (inUse == NodeUsage::InUse)
{
doc->IncrementReferens(idTool);
}
//Some nodes we don't show on scene. Tool that create this nodes must free memory. //Some nodes we don't show on scene. Tool that create this nodes must free memory.
VDataTool *tool = doc->getTool(idTool); VDataTool *tool = doc->getTool(idTool);
SCASSERT(tool != nullptr); SCASSERT(tool != nullptr);
spl->setParent(tool);// Adopted by a tool spl->setParent(tool);// Adopted by a tool
} }
else
{
if (inUse == NodeUsage::InUse)
{
doc->IncrementReferens(idSpline);
}
}
} }
else else
{ {

View File

@ -44,8 +44,7 @@ public:
static VNodeSpline *Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id, static VNodeSpline *Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id,
quint32 idSpline, const Document &parse, quint32 idSpline, const Document &parse,
const Source &typeCreation, const NodeUsage &inUse, const quint32 &idTool = 0, const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr);
QObject *parent = nullptr);
static const QString TagName; static const QString TagName;
static const QString ToolType; static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;} virtual int type() const Q_DECL_OVERRIDE {return Type;}

View File

@ -72,7 +72,7 @@ VNodeSplinePath::VNodeSplinePath(VAbstractPattern *doc, VContainer *data, quint3
*/ */
void VNodeSplinePath::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id, void VNodeSplinePath::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id,
quint32 idSpline, const Document &parse, quint32 idSpline, const Document &parse,
const Source &typeCreation, const NodeUsage &inUse, const quint32 &idTool, QObject *parent) const Source &typeCreation, const quint32 &idTool, QObject *parent)
{ {
VAbstractTool::AddRecord(id, Tool::NodeSplinePath, doc); VAbstractTool::AddRecord(id, Tool::NodeSplinePath, doc);
if (parse == Document::FullParse) if (parse == Document::FullParse)
@ -90,22 +90,11 @@ void VNodeSplinePath::Create(VAbstractPattern *doc, VContainer *data, VMainGraph
{ {
if (idTool != NULL_ID) if (idTool != NULL_ID)
{ {
if (inUse == NodeUsage::InUse)
{
doc->IncrementReferens(idTool);
}
//Some nodes we don't show on scene. Tool that create this nodes must free memory. //Some nodes we don't show on scene. Tool that create this nodes must free memory.
VDataTool *tool = doc->getTool(idTool); VDataTool *tool = doc->getTool(idTool);
SCASSERT(tool != nullptr); SCASSERT(tool != nullptr);
splPath->setParent(tool);// Adopted by a tool splPath->setParent(tool);// Adopted by a tool
} }
else
{
if (inUse == NodeUsage::InUse)
{
doc->IncrementReferens(points->at(i).P().id());
}
}
} }
} }
else else

View File

@ -43,8 +43,7 @@ public:
const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr); const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr);
static void Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id, static void Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id,
quint32 idSpline, const Document &parse, quint32 idSpline, const Document &parse,
const Source &typeCreation, const NodeUsage &inUse, const quint32 &idTool = 0, const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = 0);
QObject *parent = 0);
static const QString TagName; static const QString TagName;
static const QString ToolType; static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;} virtual int type() const Q_DECL_OVERRIDE {return Type;}

View File

@ -41,6 +41,8 @@
#include <QMessageBox> #include <QMessageBox>
#include <QtCore/qmath.h> #include <QtCore/qmath.h>
const QString VAbstractTool::AttrInUse = QStringLiteral("inUse");
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief VAbstractTool container. * @brief VAbstractTool container.

View File

@ -56,6 +56,8 @@ public:
virtual ~VAbstractTool() Q_DECL_OVERRIDE; virtual ~VAbstractTool() Q_DECL_OVERRIDE;
quint32 getId() const; quint32 getId() const;
static const QString AttrInUse;
static const QStringList StylesList(); static const QStringList StylesList();
static Qt::PenStyle LineStyleToPenStyle(const QString &typeLine); static Qt::PenStyle LineStyleToPenStyle(const QString &typeLine);
static QMap<QString, QIcon> LineStylesPics(); static QMap<QString, QIcon> LineStylesPics();

View File

@ -98,7 +98,6 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32
qDebug()<<"Get wrong tool type. Ignore."; qDebug()<<"Get wrong tool type. Ignore.";
break; break;
} }
doc->IncrementReferens(detail.at(i).getId());
} }
this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -162,29 +161,25 @@ void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstrac
case (Tool::NodePoint): case (Tool::NodePoint):
{ {
id = CreateNode<VPointF>(data, nodeD.getId()); id = CreateNode<VPointF>(data, nodeD.getId());
VNodePoint::Create(doc, data, scene, id, nodeD.getId(), Document::FullParse, Source::FromGui, VNodePoint::Create(doc, data, scene, id, nodeD.getId(), Document::FullParse, Source::FromGui);
NodeUsage::InUse);
} }
break; break;
case (Tool::NodeArc): case (Tool::NodeArc):
{ {
id = CreateNode<VArc>(data, nodeD.getId()); id = CreateNode<VArc>(data, nodeD.getId());
VNodeArc::Create(doc, data, scene, id, nodeD.getId(), Document::FullParse, Source::FromGui, VNodeArc::Create(doc, data, scene, id, nodeD.getId(), Document::FullParse, Source::FromGui);
NodeUsage::InUse);
} }
break; break;
case (Tool::NodeSpline): case (Tool::NodeSpline):
{ {
id = CreateNode<VSpline>(data, nodeD.getId()); id = CreateNode<VSpline>(data, nodeD.getId());
VNodeSpline::Create(doc, data, scene, id, nodeD.getId(), Document::FullParse, Source::FromGui, VNodeSpline::Create(doc, data, scene, id, nodeD.getId(), Document::FullParse, Source::FromGui);
NodeUsage::InUse);
} }
break; break;
case (Tool::NodeSplinePath): case (Tool::NodeSplinePath):
{ {
id = CreateNode<VSplinePath>(data, nodeD.getId()); id = CreateNode<VSplinePath>(data, nodeD.getId());
VNodeSplinePath::Create(doc, data, scene, id, nodeD.getId(), Document::FullParse, Source::FromGui, VNodeSplinePath::Create(doc, data, scene, id, nodeD.getId(), Document::FullParse, Source::FromGui);
NodeUsage::InUse);
} }
break; break;
default: default:

View File

@ -64,6 +64,7 @@ VToolUnionDetails::VToolUnionDetails(VAbstractPattern *doc, VContainer *data, co
const Source &typeCreation, QObject *parent) const Source &typeCreation, QObject *parent)
:VAbstractTool(doc, data, id, parent), d1(d1), d2(d2), indexD1(indexD1), indexD2(indexD2) :VAbstractTool(doc, data, id, parent), d1(d1), d2(d2), indexD1(indexD1), indexD2(indexD2)
{ {
_referens = 0;
ToolCreation(typeCreation); ToolCreation(typeCreation);
} }
@ -105,8 +106,7 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VMainGraphicsScene *scene,
VPointF *point1 = new VPointF(*point); VPointF *point1 = new VPointF(*point);
point1->setMode(Draw::Modeling); point1->setMode(Draw::Modeling);
id = data->AddGObject(point1); id = data->AddGObject(point1);
VNodePoint::Create(doc, data, scene, id, idObject, Document::FullParse, Source::FromGui, VNodePoint::Create(doc, data, scene, id, idObject, Document::FullParse, Source::FromGui, idTool, tool);
NodeUsage::InUse, idTool, tool);
} }
} }
break; break;
@ -142,8 +142,7 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VMainGraphicsScene *scene,
arc2->setMode(Draw::Modeling); arc2->setMode(Draw::Modeling);
id = data->AddGObject(arc2); id = data->AddGObject(arc2);
VNodeArc::Create(doc, data, scene, id, idObject, Document::FullParse, Source::FromGui, NodeUsage::InUse, VNodeArc::Create(doc, data, scene, id, idObject, Document::FullParse, Source::FromGui, idTool, tool);
idTool, tool);
} }
} }
break; break;
@ -177,8 +176,7 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VMainGraphicsScene *scene,
VSpline *spl1 = new VSpline(*spl); VSpline *spl1 = new VSpline(*spl);
spl1->setMode(Draw::Modeling); spl1->setMode(Draw::Modeling);
id = data->AddGObject(spl1); id = data->AddGObject(spl1);
VNodeSpline::Create(doc, data, scene, id, idObject, Document::FullParse, Source::FromGui, VNodeSpline::Create(doc, data, scene, id, idObject, Document::FullParse, Source::FromGui, idTool, tool);
NodeUsage::InUse, idTool, tool);
delete p4; delete p4;
delete p1; delete p1;
@ -233,8 +231,8 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VMainGraphicsScene *scene,
VSplinePath *path1 = new VSplinePath(*path); VSplinePath *path1 = new VSplinePath(*path);
path1->setMode(Draw::Modeling); path1->setMode(Draw::Modeling);
id = data->AddGObject(path1); id = data->AddGObject(path1);
VNodeSplinePath::Create(doc, data, scene, id, idObject, Document::FullParse, Source::FromGui, VNodeSplinePath::Create(doc, data, scene, id, idObject, Document::FullParse, Source::FromGui, idTool,
NodeUsage::InUse, idTool, tool); tool);
} }
} }
break; break;
@ -424,6 +422,57 @@ void VToolUnionDetails::ShowVisualization(bool show)
Q_UNUSED(show) Q_UNUSED(show)
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolUnionDetails::incrementReferens()
{
++_referens;
if (_referens == 1)
{
for (int i = 0; i < d1.CountNode(); ++i)
{
doc->IncrementReferens(d1.at(i).getId());
}
for (int i = 0; i < d2.CountNode(); ++i)
{
doc->IncrementReferens(d2.at(i).getId());
}
QDomElement domElement = doc->elementById(id);
if (domElement.isElement())
{
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::InUse);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolUnionDetails::decrementReferens()
{
if (_referens > 0)
{
--_referens;
}
if (_referens == 0)
{
for (int i = 0; i < d1.CountNode(); ++i)
{
doc->DecrementReferens(d1.at(i).getId());
}
for (int i = 0; i < d2.CountNode(); ++i)
{
doc->DecrementReferens(d2.at(i).getId());
}
QDomElement domElement = doc->elementById(id);
if (domElement.isElement())
{
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::NotInUse);
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Create help create tool from GUI. * @brief Create help create tool from GUI.
@ -490,15 +539,6 @@ VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d
unionDetails = new VToolUnionDetails(doc, data, id, d1, d2, indexD1, indexD2, typeCreation, doc); unionDetails = new VToolUnionDetails(doc, data, id, d1, d2, indexD1, indexD2, typeCreation, doc);
QHash<quint32, VDataTool*>* tools = doc->getTools(); QHash<quint32, VDataTool*>* tools = doc->getTools();
tools->insert(id, unionDetails); tools->insert(id, unionDetails);
for (int i = 0; i < d1.CountNode(); ++i)
{
doc->IncrementReferens(d1.at(i).getId());
}
for (int i = 0; i < d2.CountNode(); ++i)
{
doc->IncrementReferens(d2.at(i).getId());
}
} }
//Then create new details //Then create new details
VNodeDetail det1p1; VNodeDetail det1p1;

View File

@ -79,6 +79,8 @@ public:
const qreal &angle); const qreal &angle);
virtual QString getTagName() const Q_DECL_OVERRIDE; virtual QString getTagName() const Q_DECL_OVERRIDE;
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
virtual void incrementReferens() Q_DECL_OVERRIDE;
virtual void decrementReferens() Q_DECL_OVERRIDE;
public slots: public slots:
/** /**
* @brief FullUpdateFromFile update tool data form file. * @brief FullUpdateFromFile update tool data form file.