Fixed bug in DeleteTool method.
--HG-- branch : develop
This commit is contained in:
parent
7d51c4cf4f
commit
24140d6e3d
|
@ -193,7 +193,6 @@ void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QS
|
||||||
secondPointId, typeLine, typeCreation);
|
secondPointId, typeLine, typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(point, &VToolAlongLine::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolAlongLine::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolAlongLine::SetFactor);
|
||||||
doc->AddTool(id, point);
|
doc->AddTool(id, point);
|
||||||
doc->IncrementReferens(firstPointId);
|
doc->IncrementReferens(firstPointId);
|
||||||
|
|
|
@ -128,7 +128,6 @@ void VToolArc::Create(const qint64 _id, const qint64 ¢er, const QString &rad
|
||||||
VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation);
|
VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation);
|
||||||
scene->addItem(toolArc);
|
scene->addItem(toolArc);
|
||||||
connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(toolArc, &VToolArc::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
doc->AddTool(id, toolArc);
|
doc->AddTool(id, toolArc);
|
||||||
doc->IncrementReferens(center);
|
doc->IncrementReferens(center);
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,6 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
|
||||||
thirdPointId, typeCreation);
|
thirdPointId, typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
connect(point, &VToolBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(point, &VToolBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(point, &VToolBisector::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolBisector::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolBisector::SetFactor);
|
||||||
doc->AddTool(id, point);
|
doc->AddTool(id, point);
|
||||||
doc->IncrementReferens(firstPointId);
|
doc->IncrementReferens(firstPointId);
|
||||||
|
|
|
@ -145,7 +145,6 @@ void VToolCutSpline::Create(const qint64 _id, const QString &pointName,
|
||||||
VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, typeCreation);
|
VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(point, &VToolPoint::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
|
||||||
doc->AddTool(id, point);
|
doc->AddTool(id, point);
|
||||||
doc->AddTool(spl1id, point);
|
doc->AddTool(spl1id, point);
|
||||||
|
|
|
@ -216,7 +216,6 @@ void VToolCutSplinePath::Create(const qint64 _id, const QString &pointName, cons
|
||||||
splPath2id, typeCreation);
|
splPath2id, typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(point, &VToolPoint::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
|
||||||
doc->AddTool(id, point);
|
doc->AddTool(id, point);
|
||||||
doc->AddTool(splPath1id, point);
|
doc->AddTool(splPath1id, point);
|
||||||
|
|
|
@ -108,7 +108,6 @@ void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QStr
|
||||||
basePointId, typeCreation);
|
basePointId, typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(point, &VToolPoint::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
|
||||||
doc->AddTool(id, point);
|
doc->AddTool(id, point);
|
||||||
doc->IncrementReferens(basePointId);
|
doc->IncrementReferens(basePointId);
|
||||||
|
|
|
@ -107,7 +107,6 @@ void VToolHeight::Create(const qint64 _id, const QString &pointName, const QStri
|
||||||
typeCreation);
|
typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(point, &VToolPoint::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
|
||||||
doc->AddTool(id, point);
|
doc->AddTool(id, point);
|
||||||
doc->IncrementReferens(basePointId);
|
doc->IncrementReferens(basePointId);
|
||||||
|
|
|
@ -99,7 +99,6 @@ void VToolLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64
|
||||||
Q_ASSERT(line != 0);
|
Q_ASSERT(line != 0);
|
||||||
scene->addItem(line);
|
scene->addItem(line);
|
||||||
connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(line, &VToolLine::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, line, &VToolLine::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, line, &VToolLine::SetFactor);
|
||||||
doc->AddTool(id, line);
|
doc->AddTool(id, line);
|
||||||
doc->IncrementReferens(firstPoint);
|
doc->IncrementReferens(firstPoint);
|
||||||
|
|
|
@ -116,7 +116,6 @@ void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const
|
||||||
p2Line2Id, typeCreation);
|
p2Line2Id, typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(point, &VToolLineIntersect::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolLineIntersect::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolLineIntersect::SetFactor);
|
||||||
doc->AddTool(id, point);
|
doc->AddTool(id, point);
|
||||||
doc->IncrementReferens(p1Line1Id);
|
doc->IncrementReferens(p1Line1Id);
|
||||||
|
|
|
@ -110,7 +110,6 @@ void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64
|
||||||
firstPointId, secondPointId, typeCreation);
|
firstPointId, secondPointId, typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(point, &VToolNormal::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolNormal::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolNormal::SetFactor);
|
||||||
doc->AddTool(id, point);
|
doc->AddTool(id, point);
|
||||||
doc->IncrementReferens(firstPointId);
|
doc->IncrementReferens(firstPointId);
|
||||||
|
|
|
@ -140,7 +140,6 @@ void VToolPointOfContact::Create(const qint64 _id, const QString &radius, const
|
||||||
firstPointId, secondPointId, typeCreation);
|
firstPointId, secondPointId, typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(point, &VToolPointOfContact::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfContact::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfContact::SetFactor);
|
||||||
doc->AddTool(id, point);
|
doc->AddTool(id, point);
|
||||||
doc->IncrementReferens(center);
|
doc->IncrementReferens(center);
|
||||||
|
|
|
@ -94,7 +94,6 @@ void VToolPointOfIntersection::Create(const qint64 _id, const QString &pointName
|
||||||
secondPointId, typeCreation);
|
secondPointId, typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
connect(point, &VToolPointOfIntersection::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(point, &VToolPointOfIntersection::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(point, &VToolPointOfIntersection::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersection::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersection::SetFactor);
|
||||||
doc->AddTool(id, point);
|
doc->AddTool(id, point);
|
||||||
doc->IncrementReferens(firstPointId);
|
doc->IncrementReferens(firstPointId);
|
||||||
|
|
|
@ -142,7 +142,6 @@ void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const
|
||||||
typeCreation);
|
typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
connect(point, &VToolShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(point, &VToolShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(point, &VToolShoulderPoint::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolShoulderPoint::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolShoulderPoint::SetFactor);
|
||||||
doc->AddTool(id, point);
|
doc->AddTool(id, point);
|
||||||
doc->IncrementReferens(p1Line);
|
doc->IncrementReferens(p1Line);
|
||||||
|
|
|
@ -132,7 +132,6 @@ void VToolSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4, c
|
||||||
VToolSpline *spl = new VToolSpline(doc, data, id, typeCreation);
|
VToolSpline *spl = new VToolSpline(doc, data, id, typeCreation);
|
||||||
scene->addItem(spl);
|
scene->addItem(spl);
|
||||||
connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(spl, &VToolSpline::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSpline::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSpline::SetFactor);
|
||||||
doc->AddTool(id, spl);
|
doc->AddTool(id, spl);
|
||||||
doc->IncrementReferens(p1);
|
doc->IncrementReferens(p1);
|
||||||
|
|
|
@ -119,7 +119,6 @@ void VToolSplinePath::Create(const qint64 _id, VSplinePath *path, VMainGraphicsS
|
||||||
VToolSplinePath *spl = new VToolSplinePath(doc, data, id, typeCreation);
|
VToolSplinePath *spl = new VToolSplinePath(doc, data, id, typeCreation);
|
||||||
scene->addItem(spl);
|
scene->addItem(spl);
|
||||||
connect(spl, &VToolSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(spl, &VToolSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(spl, &VToolSplinePath::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSplinePath::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSplinePath::SetFactor);
|
||||||
doc->AddTool(id, spl);
|
doc->AddTool(id, spl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,6 @@ void VToolTriangle::Create(const qint64 _id, const QString &pointName, const qin
|
||||||
secondPointId, typeCreation);
|
secondPointId, typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
connect(point, &VToolTriangle::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(point, &VToolTriangle::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(point, &VToolTriangle::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolTriangle::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolTriangle::SetFactor);
|
||||||
doc->AddTool(id, point);
|
doc->AddTool(id, point);
|
||||||
doc->IncrementReferens(axisP1Id);
|
doc->IncrementReferens(axisP1Id);
|
||||||
|
|
|
@ -188,10 +188,22 @@ void VAbstractTool::DeleteTool(QGraphicsItem *tool)
|
||||||
{
|
{
|
||||||
QDomNode element = domElement.parentNode();
|
QDomNode element = domElement.parentNode();
|
||||||
if (element.isNull() == false)
|
if (element.isNull() == false)
|
||||||
|
{
|
||||||
|
if (element.isElement())
|
||||||
{
|
{
|
||||||
RemoveReferens();//deincrement referens
|
RemoveReferens();//deincrement referens
|
||||||
element.removeChild(domElement);//remove form file
|
element.removeChild(domElement);//remove form file
|
||||||
emit SceneRemoveTool(tool);//remove form scene
|
QGraphicsScene *scene = tool->scene();
|
||||||
|
if(scene != 0)//some tools haven't scene
|
||||||
|
{
|
||||||
|
scene->removeItem(tool);//remove form scene
|
||||||
|
}
|
||||||
|
emit toolhaveChange();//set enabled save button
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning()<<"parent isn't element"<<Q_FUNC_INFO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -266,11 +266,6 @@ signals:
|
||||||
* @brief FullUpdateTree
|
* @brief FullUpdateTree
|
||||||
*/
|
*/
|
||||||
void FullUpdateTree();
|
void FullUpdateTree();
|
||||||
/**
|
|
||||||
* @brief RemoveTool
|
|
||||||
* @param tool
|
|
||||||
*/
|
|
||||||
void SceneRemoveTool(QGraphicsItem *tool);
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief doc dom document container
|
* @brief doc dom document container
|
||||||
|
|
|
@ -153,7 +153,6 @@ void VToolDetail::Create(const qint64 &_id, const VDetail &newDetail, VMainGraph
|
||||||
VToolDetail *detail = new VToolDetail(doc, data, id, typeCreation, scene);
|
VToolDetail *detail = new VToolDetail(doc, data, id, typeCreation, scene);
|
||||||
scene->addItem(detail);
|
scene->addItem(detail);
|
||||||
connect(detail, &VToolDetail::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(detail, &VToolDetail::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(detail, &VToolDetail::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
QHash<qint64, VDataTool*>* tools = doc->getTools();
|
QHash<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
tools->insert(id, detail);
|
tools->insert(id, detail);
|
||||||
}
|
}
|
||||||
|
@ -161,7 +160,7 @@ void VToolDetail::Create(const qint64 &_id, const VDetail &newDetail, VMainGraph
|
||||||
|
|
||||||
void VToolDetail::Remove()
|
void VToolDetail::Remove()
|
||||||
{
|
{
|
||||||
|
DeleteTool(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolDetail::FullUpdateFromFile()
|
void VToolDetail::FullUpdateFromFile()
|
||||||
|
@ -379,6 +378,5 @@ void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node)
|
||||||
Tool *tool = qobject_cast<Tool*>(tools->value(node.getId()));
|
Tool *tool = qobject_cast<Tool*>(tools->value(node.getId()));
|
||||||
Q_ASSERT(tool != 0);
|
Q_ASSERT(tool != 0);
|
||||||
connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(tool, &Tool::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
tool->setParentItem(this);
|
tool->setParentItem(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,12 +155,6 @@ public slots:
|
||||||
* @param result
|
* @param result
|
||||||
*/
|
*/
|
||||||
virtual void FullUpdateFromGui(int result);
|
virtual void FullUpdateFromGui(int result);
|
||||||
signals:
|
|
||||||
/**
|
|
||||||
* @brief RemoveTool
|
|
||||||
* @param tool
|
|
||||||
*/
|
|
||||||
void SceneRemoveTool(QGraphicsItem *tool);
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief AddToFile
|
* @brief AddToFile
|
||||||
|
|
|
@ -76,11 +76,6 @@ public slots:
|
||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
void ChoosedItem(qint64 id, const Scene::Scenes &type);
|
void ChoosedItem(qint64 id, const Scene::Scenes &type);
|
||||||
/**
|
|
||||||
* @brief RemoveTool
|
|
||||||
* @param tool
|
|
||||||
*/
|
|
||||||
inline void RemoveTool(QGraphicsItem *tool) {this->removeItem(tool);}
|
|
||||||
/**
|
/**
|
||||||
* @brief SetFactor
|
* @brief SetFactor
|
||||||
* @param factor
|
* @param factor
|
||||||
|
|
|
@ -726,7 +726,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
|
||||||
{
|
{
|
||||||
VExceptionObjectError excep(tr("Error creating or updating single point"), domElement);
|
VExceptionObjectError excep(tr("Error creating or updating single point"), domElement);
|
||||||
excep.AddMoreInformation(e.ErrorMessage());
|
excep.AddMoreInformation(e.ErrorMessage());
|
||||||
scene->RemoveTool(spoint);
|
scene->removeItem(spoint);
|
||||||
delete spoint;
|
delete spoint;
|
||||||
throw excep;
|
throw excep;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user