PartDesign: Unify deletion behavior

This unifies deletion behavior for all PartDesign features ensuring that
sketches that were used to create these features show after deletion and
that the tip is properly transfered.
This commit is contained in:
Kacper Donat
2025-08-14 16:14:02 +02:00
committed by Chris Hennes
parent be3b9edd33
commit cf951bae6b
12 changed files with 12 additions and 92 deletions

View File

@@ -249,6 +249,15 @@ void ViewProvider::updatePreview()
}
}
void ViewProvider::makeChildrenVisible()
{
for (const auto child : claimChildren()) {
if (auto vp = Gui::Application::Instance->getViewProvider(child)) {
vp->show();
}
}
}
void ViewProvider::onChanged(const App::Property* prop) {
//if the object is inside of a body we make sure it is the only visible one on activation
@@ -340,6 +349,8 @@ bool ViewProvider::onDelete(const std::vector<std::string>&)
FCMD_OBJ_CMD(body, "removeObject(" << Gui::Command::getObjectCmd(feature) << ')');
}
makeChildrenVisible();
return true;
}

View File

@@ -98,6 +98,7 @@ protected:
void attachPreview() override;
void updatePreview() override;
virtual void makeChildrenVisible();
bool onDelete(const std::vector<std::string> &) override;
/**

View File

@@ -78,18 +78,3 @@ std::vector<App::DocumentObject*> ViewProviderHelix::claimChildren() const {
return temp;
}
bool ViewProviderHelix::onDelete(const std::vector<std::string> &s) {
PartDesign::ProfileBased* feature = getObject<PartDesign::ProfileBased>();
// get the Sketch
Sketcher::SketchObject *pcSketch = nullptr;
if (feature->Profile.getValue())
pcSketch = static_cast<Sketcher::SketchObject*>(feature->Profile.getValue());
// if abort command deleted the object the sketch is visible again
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
Gui::Application::Instance->getViewProvider(pcSketch)->show();
return ViewProvider::onDelete(s);
}

View File

@@ -44,8 +44,6 @@ public:
/// grouping handling
std::vector<App::DocumentObject*> claimChildren() const override;
bool onDelete(const std::vector<std::string> &) override;
protected:
QIcon getIcon() const override;

View File

@@ -63,23 +63,6 @@ void ViewProviderHole::setupContextMenu(QMenu* menu, QObject* receiver, const ch
PartDesignGui::ViewProvider::setupContextMenu(menu, receiver, member);
}
bool ViewProviderHole::onDelete(const std::vector<std::string>& s)
{
// get the Sketch
PartDesign::Hole* pcHole = getObject<PartDesign::Hole>();
Sketcher::SketchObject* pcSketch = nullptr;
if (pcHole->Profile.getValue()) {
pcSketch = static_cast<Sketcher::SketchObject*>(pcHole->Profile.getValue());
}
// if abort command deleted the object the sketch is visible again
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch)) {
Gui::Application::Instance->getViewProvider(pcSketch)->show();
}
return ViewProvider::onDelete(s);
}
TaskDlgFeatureParameters* ViewProviderHole::getEditDialog()
{
return new TaskDlgHoleParameters(this);

View File

@@ -42,7 +42,6 @@ public:
/// grouping handling
std::vector<App::DocumentObject*> claimChildren()const override;
void setupContextMenu(QMenu *menu, QObject *receiver, const char *member) override;
bool onDelete(const std::vector<std::string> &s) override;
protected:
TaskDlgFeatureParameters* getEditDialog() override;

View File

@@ -71,23 +71,6 @@ TaskDlgFeatureParameters* ViewProviderLoft::getEditDialog() {
return new TaskDlgLoftParameters(this);
}
bool ViewProviderLoft::onDelete(const std::vector<std::string> & /*s*/)
{/*
PartDesign::Loft* pcLoft = getObject<PartDesign::Loft>();
// get the Sketch
Sketcher::SketchObject *pcSketch = 0;
if (pcLoft->Sketch.getValue())
pcSketch = static_cast<Sketcher::SketchObject*>(pcLoft->Sketch.getValue());
// if abort command deleted the object the sketch is visible again
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
Gui::Application::Instance->getViewProvider(pcSketch)->show();
return ViewProvider::onDelete(s);*/
return true;
}
void ViewProviderLoft::highlightProfile(bool on)
{
PartDesign::Loft* pcLoft = getObject<PartDesign::Loft>();

View File

@@ -48,7 +48,6 @@ public:
std::vector<App::DocumentObject*> claimChildren() const override;
void setupContextMenu(QMenu*, QObject*, const char*) override;
bool onDelete(const std::vector<std::string> &) override;
void highlightProfile(bool on);
void highlightSection(bool on);
void highlightReferences(Reference mode, bool on);

View File

@@ -79,24 +79,6 @@ TaskDlgFeatureParameters* ViewProviderPipe::getEditDialog() {
return new TaskDlgPipeParameters(this, false);
}
bool ViewProviderPipe::onDelete(const std::vector<std::string> &s)
{/*
PartDesign::Pipe* pcPipe = getObject<PartDesign::Pipe>();
// get the Sketch
Sketcher::SketchObject *pcSketch = 0;
if (pcPipe->Sketch.getValue())
pcSketch = static_cast<Sketcher::SketchObject*>(pcPipe->Sketch.getValue());
// if abort command deleted the object the sketch is visible again
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
Gui::Application::Instance->getViewProvider(pcSketch)->show();
*/
return ViewProvider::onDelete(s);
}
void ViewProviderPipe::highlightReferences(ViewProviderPipe::Reference mode, bool on)
{
PartDesign::Pipe* pcPipe = getObject<PartDesign::Pipe>();

View File

@@ -49,7 +49,6 @@ public:
std::vector<App::DocumentObject*> claimChildren()const override;
void setupContextMenu(QMenu*, QObject*, const char*) override;
bool onDelete(const std::vector<std::string> &) override;
void highlightReferences(Reference mode, bool on);
protected:

View File

@@ -36,7 +36,6 @@ PROPERTY_SOURCE(PartDesignGui::ViewProviderSketchBased, PartDesignGui::ViewProvi
ViewProviderSketchBased::ViewProviderSketchBased() = default;
ViewProviderSketchBased::~ViewProviderSketchBased() = default;
@@ -48,20 +47,3 @@ std::vector<App::DocumentObject*> ViewProviderSketchBased::claimChildren() const
return temp;
}
bool ViewProviderSketchBased::onDelete(const std::vector<std::string> &s) {
PartDesign::ProfileBased* feature = getObject<PartDesign::ProfileBased>();
// get the Sketch
Sketcher::SketchObject *pcSketch = nullptr;
if (feature->Profile.getValue())
pcSketch = static_cast<Sketcher::SketchObject*>(feature->Profile.getValue());
// if abort command deleted the object the sketch is visible again
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
Gui::Application::Instance->getViewProvider(pcSketch)->show();
return ViewProvider::onDelete(s);
}

View File

@@ -43,8 +43,6 @@ public:
/// grouping handling
std::vector<App::DocumentObject*> claimChildren() const override;
bool onDelete(const std::vector<std::string> &) override;
};
} /* PartDesignGui */