diff --git a/src/Mod/PartDesign/Gui/ViewProvider.h b/src/Mod/PartDesign/Gui/ViewProvider.h index 955910b2a..fd023e0c2 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.h +++ b/src/Mod/PartDesign/Gui/ViewProvider.h @@ -43,6 +43,9 @@ public: void updateData(const App::Property*); virtual bool onDelete(const std::vector &); + +protected: + std::string oldWb; }; diff --git a/src/Mod/PartDesign/Gui/ViewProviderChamfer.cpp b/src/Mod/PartDesign/Gui/ViewProviderChamfer.cpp index a86ccd9fc..490c01b69 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderChamfer.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderChamfer.cpp @@ -85,8 +85,9 @@ bool ViewProviderChamfer::setEdit(int ModNum) // clear the selection (convenience) Gui::Selection().clearSelection(); - //if(ModNum == 1) - // Gui::Command::openCommand("Change chamfer parameters"); + + // always change to PartDesign WB, remember where we come from + oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); // start the edit dialog if (padDlg) @@ -103,10 +104,10 @@ bool ViewProviderChamfer::setEdit(int ModNum) void ViewProviderChamfer::unsetEdit(int ModNum) { - if (ModNum == ViewProvider::Default ) { - // and update the pad - //getSketchObject()->getDocument()->recompute(); + // 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(); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderDraft.cpp b/src/Mod/PartDesign/Gui/ViewProviderDraft.cpp index e7f4545f8..7d8b60f07 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDraft.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDraft.cpp @@ -85,8 +85,9 @@ bool ViewProviderDraft::setEdit(int ModNum) // clear the selection (convenience) Gui::Selection().clearSelection(); - //if(ModNum == 1) - // Gui::Command::openCommand("Change draft parameters"); + + // always change to PartDesign WB, remember where we come from + oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); // start the edit dialog if (draftDlg) @@ -103,10 +104,10 @@ bool ViewProviderDraft::setEdit(int ModNum) void ViewProviderDraft::unsetEdit(int ModNum) { - if (ModNum == ViewProvider::Default ) { - // and update the draft - //getSketchObject()->getDocument()->recompute(); + // 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(); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderFillet.cpp b/src/Mod/PartDesign/Gui/ViewProviderFillet.cpp index 28fda0583..0882ce576 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderFillet.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderFillet.cpp @@ -85,8 +85,9 @@ bool ViewProviderFillet::setEdit(int ModNum) // clear the selection (convenience) Gui::Selection().clearSelection(); - //if(ModNum == 1) - // Gui::Command::openCommand("Change fillet parameters"); + + // always change to PartDesign WB, remember where we come from + oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); // start the edit dialog if (padDlg) @@ -103,10 +104,10 @@ bool ViewProviderFillet::setEdit(int ModNum) void ViewProviderFillet::unsetEdit(int ModNum) { - if (ModNum == ViewProvider::Default ) { - // and update the pad - //getSketchObject()->getDocument()->recompute(); + // 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(); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderGroove.cpp b/src/Mod/PartDesign/Gui/ViewProviderGroove.cpp index fbe733e5c..cbfa9b3d3 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderGroove.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderGroove.cpp @@ -102,8 +102,9 @@ bool ViewProviderGroove::setEdit(int ModNum) // clear the selection (convenience) Gui::Selection().clearSelection(); - //if (ModNum == 1) - // Gui::Command::openCommand("Change Groove parameters"); + + // always change to PartDesign WB, remember where we come from + oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); // start the edit dialog if (padDlg) @@ -120,10 +121,10 @@ bool ViewProviderGroove::setEdit(int ModNum) void ViewProviderGroove::unsetEdit(int ModNum) { - if (ModNum == ViewProvider::Default) { - // and update the pad - //getSketchObject()->getDocument()->recompute(); + // 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(); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderLinearPattern.cpp b/src/Mod/PartDesign/Gui/ViewProviderLinearPattern.cpp index cb0e256a9..f23c64b89 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderLinearPattern.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderLinearPattern.cpp @@ -46,6 +46,9 @@ bool ViewProviderLinearPattern::setEdit(int ModNum) TaskDlgLinearPatternParameters *linearpatternDlg = NULL; if (checkDlgOpen(linearpatternDlg)) { + // always change to PartDesign WB, remember where we come from + oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); + // start the edit dialog if (linearpatternDlg) Gui::Control().showDialog(linearpatternDlg); diff --git a/src/Mod/PartDesign/Gui/ViewProviderMirrored.cpp b/src/Mod/PartDesign/Gui/ViewProviderMirrored.cpp index dece48ea2..cd7c14c56 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderMirrored.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderMirrored.cpp @@ -46,6 +46,9 @@ bool ViewProviderMirrored::setEdit(int ModNum) TaskDlgMirroredParameters *mirroredDlg = NULL; if (checkDlgOpen(mirroredDlg)) { + // always change to PartDesign WB, remember where we come from + oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); + // start the edit dialog if (mirroredDlg) Gui::Control().showDialog(mirroredDlg); diff --git a/src/Mod/PartDesign/Gui/ViewProviderMultiTransform.cpp b/src/Mod/PartDesign/Gui/ViewProviderMultiTransform.cpp index 839e28ff0..86105a19b 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderMultiTransform.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderMultiTransform.cpp @@ -46,6 +46,9 @@ bool ViewProviderMultiTransform::setEdit(int ModNum) TaskDlgMultiTransformParameters *multitransformDlg = NULL; if (checkDlgOpen(multitransformDlg)) { + // always change to PartDesign WB, remember where we come from + oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); + // start the edit dialog if (multitransformDlg) Gui::Control().showDialog(multitransformDlg); diff --git a/src/Mod/PartDesign/Gui/ViewProviderPad.cpp b/src/Mod/PartDesign/Gui/ViewProviderPad.cpp index 0ff00ad05..131e8b145 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderPad.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderPad.cpp @@ -100,6 +100,9 @@ bool ViewProviderPad::setEdit(int ModNum) // clear the selection (convenience) Gui::Selection().clearSelection(); + // always change to PartDesign WB, remember where we come from + oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); + // start the edit dialog if (padDlg) Gui::Control().showDialog(padDlg); @@ -115,10 +118,10 @@ bool ViewProviderPad::setEdit(int ModNum) void ViewProviderPad::unsetEdit(int ModNum) { - if (ModNum == ViewProvider::Default) { - // and update the pad - //getSketchObject()->getDocument()->recompute(); + // 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(); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderPocket.cpp b/src/Mod/PartDesign/Gui/ViewProviderPocket.cpp index e21cf00bd..4df05c235 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderPocket.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderPocket.cpp @@ -92,8 +92,9 @@ bool ViewProviderPocket::setEdit(int ModNum) // clear the selection (convenience) Gui::Selection().clearSelection(); - //if(ModNum == ViewProvider::Default) - // Gui::Command::openCommand("Change pocket parameters"); + + // always change to PartDesign WB, remember where we come from + oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); // start the edit dialog if (padDlg) @@ -110,10 +111,10 @@ bool ViewProviderPocket::setEdit(int ModNum) void ViewProviderPocket::unsetEdit(int ModNum) { - if (ModNum == ViewProvider::Default ) { - // and update the pad - //getSketchObject()->getDocument()->recompute(); + // 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(); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderPolarPattern.cpp b/src/Mod/PartDesign/Gui/ViewProviderPolarPattern.cpp index cafefd54d..7ec126da5 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderPolarPattern.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderPolarPattern.cpp @@ -46,6 +46,9 @@ bool ViewProviderPolarPattern::setEdit(int ModNum) TaskDlgPolarPatternParameters *polarpatternDlg = NULL; if (checkDlgOpen(polarpatternDlg)) { + // always change to PartDesign WB, remember where we come from + oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); + // start the edit dialog if (polarpatternDlg) Gui::Control().showDialog(polarpatternDlg); diff --git a/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp b/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp index 398f8aeae..caa00dd8f 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp @@ -102,8 +102,9 @@ bool ViewProviderRevolution::setEdit(int ModNum) // clear the selection (convenience) Gui::Selection().clearSelection(); - //if (ModNum == 1) - // Gui::Command::openCommand("Change revolution parameters"); + + // always change to PartDesign WB, remember where we come from + oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); // start the edit dialog if (padDlg) @@ -120,10 +121,10 @@ bool ViewProviderRevolution::setEdit(int ModNum) void ViewProviderRevolution::unsetEdit(int ModNum) { - if (ModNum == ViewProvider::Default) { - // and update the pad - //getSketchObject()->getDocument()->recompute(); + // 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(); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderScaled.cpp b/src/Mod/PartDesign/Gui/ViewProviderScaled.cpp index 61df00ca4..9a4e8f455 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderScaled.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderScaled.cpp @@ -46,6 +46,9 @@ bool ViewProviderScaled::setEdit(int ModNum) TaskDlgScaledParameters *scaledDlg = NULL; if (checkDlgOpen(scaledDlg)) { + // always change to PartDesign WB, remember where we come from + oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); + // start the edit dialog if (scaledDlg) Gui::Control().showDialog(scaledDlg); diff --git a/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp b/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp index 55bf53d04..7be6c4c47 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp @@ -51,6 +51,7 @@ #include "TaskTransformedParameters.h" #include #include +#include #include #include #include @@ -129,6 +130,9 @@ bool ViewProviderTransformed::setEdit(int ModNum) void ViewProviderTransformed::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(); diff --git a/src/Mod/Start/Gui/Workbench.cpp b/src/Mod/Start/Gui/Workbench.cpp index 52b3aa857..619214464 100644 --- a/src/Mod/Start/Gui/Workbench.cpp +++ b/src/Mod/Start/Gui/Workbench.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -58,6 +59,12 @@ StartGui::Workbench::~Workbench() void StartGui::Workbench::activated() { + // Ensure that we don't open the Start page multiple times + QList ch = Gui::getMainWindow()->windows(); + for (QList::const_iterator c = ch.begin(); c != ch.end(); c++) + if ((*c)->windowTitle() == QObject::tr("Start page")) + return; + try { Gui::Command::doCommand(Gui::Command::Gui,"import WebGui"); Gui::Command::doCommand(Gui::Command::Gui,"from StartPage import StartPage");