Moved some methods from PartDesign::Body to Part::BodyBase so the SketchObjects will be removed cleanly from the Body when deleted

This commit is contained in:
jrheinlaender
2013-05-04 10:52:54 +04:30
committed by Stefan Tröger
parent 5b3d5e6bd8
commit 02dfb8551d
13 changed files with 77 additions and 62 deletions

View File

@@ -83,6 +83,7 @@
#include <App/Application.h>
#include <App/Document.h>
#include <Gui/Command.h>
#include <Gui/Application.h>
#include <Gui/Selection.h>
#include <Gui/View3DInventorViewer.h>
@@ -90,6 +91,7 @@
#include "ViewProvider.h"
#include "SoFCShapeObject.h"
#include <Mod/Part/App/BodyBase.h>
#include <Mod/Part/App/PartFeature.h>
#include <Mod/Part/App/PrimitiveFeature.h>
@@ -123,6 +125,29 @@ bool ViewProviderPart::doubleClicked(void)
}
}
bool ViewProviderPart::onDelete(const std::vector<std::string> &)
{
// Body feature housekeeping
Part::BodyBase* body = Part::BodyBase::findBodyOf(getObject());
if (body != NULL) {
body->removeFeature(getObject());
// Make the new Tip and the previous solid feature visible again
App::DocumentObject* tip = body->Tip.getValue();
App::DocumentObject* prev = body->getPrevSolidFeature();
if (tip != NULL) {
Gui::Application::Instance->getViewProvider(tip)->show();
if ((tip != prev) && (prev != NULL))
Gui::Application::Instance->getViewProvider(prev)->show();
}
}
// TODO: Ask user what to do about dependent objects, e.g. Sketches that have this feature as their support
// 1. Delete
// 2. Suppress
// 3. Re-route
return true;
}
void ViewProviderPart::applyColor(const Part::ShapeHistory& hist,
const std::vector<App::Color>& colBase,
std::vector<App::Color>& colBool)