From da1fb99dc58dde9a624657891d259c2cd1bd7d63 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Sun, 26 Jul 2015 13:22:32 +0300 Subject: [PATCH] PartDesign/ViewProvider: minor enhancements --- src/Mod/PartDesign/Gui/ViewProvider.cpp | 19 +++++++++++-------- src/Mod/PartDesign/Gui/ViewProvider.h | 8 +++++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/Mod/PartDesign/Gui/ViewProvider.cpp b/src/Mod/PartDesign/Gui/ViewProvider.cpp index b9d39079e..ba26242bf 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.cpp +++ b/src/Mod/PartDesign/Gui/ViewProvider.cpp @@ -55,7 +55,7 @@ ViewProvider::~ViewProvider() bool ViewProvider::doubleClicked(void) { PartDesign::Body* body = PartDesign::Body::findBodyOf(getObject()); - + // TODO May be move to setEdit()? (2015-07-26, Fat-Zer) if (body != NULL) { // Drop into insert mode so that the user doesn't see all the geometry that comes later in the tree // Also, this way the user won't be tempted to use future geometry as external references for the sketch @@ -113,24 +113,27 @@ bool ViewProvider::setEdit(int ModNum) // always change to PartDesign WB, remember where we come from oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); - // start the edit dialog - if (featureDlg) { - Gui::Control().showDialog(featureDlg); - } else { - Gui::Control().showDialog(this->getEditDialog()); + // start the edit dialog if + if (!featureDlg) { + featureDlg = this->getEditDialog(); + if (!featureDlg) { // Shouldn't generally happen + throw Base::Exception ("Failed to create new edit dialog."); + } } + Gui::Control().showDialog(featureDlg); return true; } else { return PartGui::ViewProviderPart::setEdit(ModNum); } } -TaskDlgFeatureParameters *ViewProvider::getEditDialog() -{ + +TaskDlgFeatureParameters *ViewProvider::getEditDialog() { throw Base::Exception("getEditDialog() not implemented"); } + void ViewProvider::unsetEdit(int ModNum) { // return to the WB we were in before editing the PartDesign feature diff --git a/src/Mod/PartDesign/Gui/ViewProvider.h b/src/Mod/PartDesign/Gui/ViewProvider.h index cd9a42cc1..77c2fa332 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.h +++ b/src/Mod/PartDesign/Gui/ViewProvider.h @@ -53,9 +53,11 @@ protected: virtual bool onDelete(const std::vector &); - /// Returns a newly create dialog for the part to be placed in the task view - // TODO make it pure virtual when finish implementation for all view providers (2015-07-24, Fat-Zer) - virtual TaskDlgFeatureParameters *getEditDialog()/* =0 */; + /** + * Returns a newly create dialog for the part to be placed in the task view + * Must be reimplemented in subclasses. + */ + virtual TaskDlgFeatureParameters *getEditDialog(); std::string oldWb; App::DocumentObject* oldTip;