PartDesign/Body: move deletion of subobjects to view provider
This commit is contained in:
committed by
Stefan Tröger
parent
57a913f796
commit
9db890015c
@@ -462,18 +462,14 @@ void Body::onSettingDocument() {
|
||||
if(connection.connected())
|
||||
connection.disconnect();
|
||||
|
||||
getDocument()->signalDeletedObject.connect(boost::bind(&Body::onDelete, this, _1));
|
||||
|
||||
Part::BodyBase::onSettingDocument();
|
||||
}
|
||||
|
||||
void Body::onDelete(const App::DocumentObject& obj) {
|
||||
// TODO Handle this in view provider rather here (2015-08-06, Fat-Zer)
|
||||
if(&obj == this) {
|
||||
//delete all child objects if needed
|
||||
std::vector<DocumentObject*> grp = Model.getValues();
|
||||
for (auto obj : grp)
|
||||
this->getDocument()->remObject(obj->getNameInDocument(), true);
|
||||
void Body::removeModelFromDocument() {
|
||||
//delete all child objects if needed
|
||||
std::set<DocumentObject*> grp ( Model.getValues().begin (), Model.getValues().end() );
|
||||
for (auto obj : grp) {
|
||||
this->getDocument()->remObject(obj->getNameInDocument(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,6 +112,9 @@ public:
|
||||
*/
|
||||
static Body *findBodyOf(const App::DocumentObject* feature);
|
||||
|
||||
/// Delets all the objects linked to the model.
|
||||
void removeModelFromDocument();
|
||||
|
||||
/// Return the bounding box of the Tip Shape, taking into account datum features
|
||||
Base::BoundBox3d getBoundBox();
|
||||
|
||||
@@ -138,7 +141,6 @@ protected:
|
||||
private:
|
||||
App::DocumentObject* rememberTip;
|
||||
boost::signals::scoped_connection connection;
|
||||
void onDelete(const App::DocumentObject& obj);
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="BodyBasePy"
|
||||
<PythonExport
|
||||
Father="BodyBasePy"
|
||||
Name="BodyPy"
|
||||
Twin="Body"
|
||||
TwinPointer="Body"
|
||||
Include="Mod/PartDesign/App/Body.h"
|
||||
Namespace="PartDesign"
|
||||
FatherInclude="Mod/Part/App/BodyBasePy.h"
|
||||
Twin="Body"
|
||||
TwinPointer="Body"
|
||||
Include="Mod/PartDesign/App/Body.h"
|
||||
Namespace="PartDesign"
|
||||
FatherInclude="Mod/Part/App/BodyBasePy.h"
|
||||
FatherNamespace="Part">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Juergen Riegel" EMail="FreeCAD@juergen-riegel.net" />
|
||||
@@ -18,11 +18,6 @@
|
||||
<UserDocu>addFeature(feat) - Add the given feature after the current Tip feature</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeFeature">
|
||||
<Documentation>
|
||||
<UserDocu>removeFeature(feat) - Remove the given feature from the Body</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="insertFeature">
|
||||
<Documentation>
|
||||
<UserDocu>insertFeatureAfter(feature, target, after=False)
|
||||
@@ -38,5 +33,15 @@
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeFeature">
|
||||
<Documentation>
|
||||
<UserDocu>removeFeature(feat) - Remove the given feature from the Body</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeModelFromDocument">
|
||||
<Documentation>
|
||||
<UserDocu>Delets all the objects linked to the model.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -113,4 +113,12 @@ PyObject* BodyPy::removeFeature(PyObject *args)
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* BodyPy::removeModelFromDocument(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return 0;
|
||||
|
||||
getBodyPtr()->removeModelFromDocument();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user