Moved unsetEdit() to ViewProvider to avoid code duplication in all feature ViewProviders
This commit is contained in:
committed by
Stefan Tröger
parent
d082f16bbf
commit
5ebdc82b5d
@@ -31,6 +31,7 @@
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
#include <Mod/Part/App/PropertyTopoShape.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Base/Exception.h>
|
||||
|
||||
@@ -60,6 +61,27 @@ bool ViewProvider::doubleClicked(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewProvider::unsetEdit(int ModNum)
|
||||
{
|
||||
// return to the WB we were in before editing the PartDesign feature
|
||||
Gui::Command::assureWorkbench(oldWb.c_str());
|
||||
|
||||
if (ModNum == ViewProvider::Default) {
|
||||
// when pressing ESC make sure to close the dialog
|
||||
Gui::Control().closeDialog();
|
||||
if ((PartDesignGui::ActivePartObject != NULL) && (oldTip != NULL)) {
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelection(oldTip->getDocument()->getName(), oldTip->getNameInDocument());
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"FreeCADGui.runCommand('PartDesign_MoveTip')");
|
||||
}
|
||||
oldTip = NULL;
|
||||
}
|
||||
else {
|
||||
PartGui::ViewProviderPart::unsetEdit(ModNum);
|
||||
oldTip = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProvider::updateData(const App::Property* prop)
|
||||
{
|
||||
if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId() &&
|
||||
|
||||
@@ -43,6 +43,8 @@ public:
|
||||
void updateData(const App::Property*);
|
||||
|
||||
protected:
|
||||
virtual void unsetEdit(int ModNum);
|
||||
|
||||
std::string oldWb;
|
||||
};
|
||||
|
||||
|
||||
@@ -102,20 +102,6 @@ bool ViewProviderChamfer::setEdit(int ModNum)
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderChamfer::unsetEdit(int ModNum)
|
||||
{
|
||||
// return to the WB we were in before editing the PartDesign feature
|
||||
Gui::Command::assureWorkbench(oldWb.c_str());
|
||||
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
// when pressing ESC make sure to close the dialog
|
||||
Gui::Control().closeDialog();
|
||||
}
|
||||
else {
|
||||
PartGui::ViewProviderPart::unsetEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderChamfer::onDelete(const std::vector<std::string> &s)
|
||||
{
|
||||
return ViewProvider::onDelete(s);
|
||||
|
||||
@@ -46,7 +46,6 @@ public:
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -102,20 +102,6 @@ bool ViewProviderDraft::setEdit(int ModNum)
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderDraft::unsetEdit(int ModNum)
|
||||
{
|
||||
// return to the WB we were in before editing the PartDesign feature
|
||||
Gui::Command::assureWorkbench(oldWb.c_str());
|
||||
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
// when pressing ESC make sure to close the dialog
|
||||
Gui::Control().closeDialog();
|
||||
}
|
||||
else {
|
||||
PartGui::ViewProviderPart::unsetEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderDraft::onDelete(const std::vector<std::string> &s)
|
||||
{
|
||||
return ViewProvider::onDelete(s);
|
||||
|
||||
@@ -46,7 +46,6 @@ public:
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -102,20 +102,6 @@ bool ViewProviderFillet::setEdit(int ModNum)
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderFillet::unsetEdit(int ModNum)
|
||||
{
|
||||
// return to the WB we were in before editing the PartDesign feature
|
||||
Gui::Command::assureWorkbench(oldWb.c_str());
|
||||
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
// when pressing ESC make sure to close the dialog
|
||||
Gui::Control().closeDialog();
|
||||
}
|
||||
else {
|
||||
PartGui::ViewProviderPart::unsetEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderFillet::onDelete(const std::vector<std::string> &s)
|
||||
{
|
||||
return ViewProvider::onDelete(s);
|
||||
|
||||
@@ -46,7 +46,6 @@ public:
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -119,20 +119,6 @@ bool ViewProviderGroove::setEdit(int ModNum)
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderGroove::unsetEdit(int ModNum)
|
||||
{
|
||||
// return to the WB we were in before editing the PartDesign feature
|
||||
Gui::Command::assureWorkbench(oldWb.c_str());
|
||||
|
||||
if (ModNum == ViewProvider::Default) {
|
||||
// when pressing ESC make sure to close the dialog
|
||||
Gui::Control().closeDialog();
|
||||
}
|
||||
else {
|
||||
PartGui::ViewProviderPart::unsetEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderGroove::onDelete(const std::vector<std::string> &s)
|
||||
{
|
||||
// get the Sketch
|
||||
|
||||
@@ -47,8 +47,7 @@ public:
|
||||
virtual bool onDelete(const std::vector<std::string> &);
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
virtual bool setEdit(int ModNum);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -116,20 +116,6 @@ bool ViewProviderPad::setEdit(int ModNum)
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderPad::unsetEdit(int ModNum)
|
||||
{
|
||||
// return to the WB we were in before editing the PartDesign feature
|
||||
Gui::Command::assureWorkbench(oldWb.c_str());
|
||||
|
||||
if (ModNum == ViewProvider::Default) {
|
||||
// when pressing ESC make sure to close the dialog
|
||||
Gui::Control().closeDialog();
|
||||
}
|
||||
else {
|
||||
PartGui::ViewProviderPart::unsetEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderPad::onDelete(const std::vector<std::string> &s)
|
||||
{
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(getObject());
|
||||
|
||||
@@ -47,7 +47,6 @@ public:
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -109,20 +109,6 @@ bool ViewProviderPocket::setEdit(int ModNum)
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderPocket::unsetEdit(int ModNum)
|
||||
{
|
||||
// return to the WB we were in before editing the PartDesign feature
|
||||
Gui::Command::assureWorkbench(oldWb.c_str());
|
||||
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
// when pressing ESC make sure to close the dialog
|
||||
Gui::Control().closeDialog();
|
||||
}
|
||||
else {
|
||||
PartGui::ViewProviderPart::unsetEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderPocket::onDelete(const std::vector<std::string> &s)
|
||||
{
|
||||
// get the Sketch
|
||||
|
||||
@@ -47,7 +47,6 @@ public:
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -119,20 +119,6 @@ bool ViewProviderRevolution::setEdit(int ModNum)
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderRevolution::unsetEdit(int ModNum)
|
||||
{
|
||||
// return to the WB we were in before editing the PartDesign feature
|
||||
Gui::Command::assureWorkbench(oldWb.c_str());
|
||||
|
||||
if (ModNum == ViewProvider::Default) {
|
||||
// when pressing ESC make sure to close the dialog
|
||||
Gui::Control().closeDialog();
|
||||
}
|
||||
else {
|
||||
PartGui::ViewProviderPart::unsetEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderRevolution::onDelete(const std::vector<std::string> &s)
|
||||
{
|
||||
// get the Sketch
|
||||
|
||||
@@ -48,7 +48,6 @@ public:
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user