auto WB switching for editing Sketches and new TaskWatcher

This commit is contained in:
jriegel 2012-05-18 14:43:35 +02:00 committed by Stefan Tröger
parent f5cfa8d72a
commit db460cff8a
5 changed files with 28 additions and 10 deletions

View File

@ -169,4 +169,5 @@ bool TaskWatcherCommandsEmptySelection::shouldShow()
return (App::GetApplication().getActiveDocument() && Gui::Selection().size() == 0); return (App::GetApplication().getActiveDocument() && Gui::Selection().size() == 0);
} }
#include "moc_TaskWatcher.cpp" #include "moc_TaskWatcher.cpp"

View File

@ -35,6 +35,8 @@
#include <Gui/ToolBarManager.h> #include <Gui/ToolBarManager.h>
#include <Gui/Control.h> #include <Gui/Control.h>
#include <Mod/PartDesign/App/Body.h>
using namespace PartDesignGui; using namespace PartDesignGui;
#if 0 // needed for Qt's lupdate utility #if 0 // needed for Qt's lupdate utility
@ -44,6 +46,9 @@ using namespace PartDesignGui;
qApp->translate("Gui::TaskView::TaskWatcherCommands", "Create Geometry"); qApp->translate("Gui::TaskView::TaskWatcherCommands", "Create Geometry");
#endif #endif
extern PartDesign::Body *ActivePartObject;
/// @namespace PartDesignGui @class Workbench /// @namespace PartDesignGui @class Workbench
TYPESYSTEM_SOURCE(PartDesignGui::Workbench, Gui::StdWorkbench) TYPESYSTEM_SOURCE(PartDesignGui::Workbench, Gui::StdWorkbench)
@ -62,15 +67,6 @@ void Workbench::activated()
std::vector<Gui::TaskView::TaskWatcher*> Watcher; std::vector<Gui::TaskView::TaskWatcher*> Watcher;
//Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
// "FROM Robot SELECT TrajectoryObject COUNT 1"
// "FROM Robot SELECT RobotObject COUNT 1",
// RobotAndTrac,
// "Trajectory tools",
// "Robot_InsertWaypoint"
//));
//Watcher.push_back(new TaskWatcherRobot);
const char* Edge[] = { const char* Edge[] = {
"PartDesign_Fillet", "PartDesign_Fillet",
@ -149,15 +145,27 @@ void Workbench::activated()
addTaskWatcher(Watcher); addTaskWatcher(Watcher);
Gui::Control().showTaskView(); Gui::Control().showTaskView();
// set the previous used active Body
if(oldActive != "")
Gui::Command::doCommand(Gui::Command::Doc,"PartDesignGui.setActivePart(App.activeDocument().%s)",oldActive.c_str());
} }
void Workbench::deactivated() void Workbench::deactivated()
{ {
// remember the body for later activation
if(ActivePartObject)
oldActive = ActivePartObject->getNameInDocument();
else
oldActive = "";
// reset the active Body
Gui::Command::doCommand(Gui::Command::Doc,"PartDesignGui.setActivePart(None)"); Gui::Command::doCommand(Gui::Command::Doc,"PartDesignGui.setActivePart(None)");
Gui::Workbench::deactivated(); Gui::Workbench::deactivated();
removeTaskWatcher(); removeTaskWatcher();
} }
Gui::MenuItem* Workbench::setupMenuBar() const Gui::MenuItem* Workbench::setupMenuBar() const

View File

@ -48,6 +48,8 @@ protected:
Gui::MenuItem* setupMenuBar() const; Gui::MenuItem* setupMenuBar() const;
Gui::ToolBarItem* setupToolBars() const; Gui::ToolBarItem* setupToolBars() const;
Gui::ToolBarItem* setupCommandBars() const; Gui::ToolBarItem* setupCommandBars() const;
std::string oldActive;
}; };
} // namespace PartDesignGui } // namespace PartDesignGui

View File

@ -4156,6 +4156,9 @@ void ViewProviderSketch::setupContextMenu(QMenu *menu, QObject *receiver, const
bool ViewProviderSketch::setEdit(int ModNum) bool ViewProviderSketch::setEdit(int ModNum)
{ {
// always change to sketcher WB, remember where we come from
oldWb = Gui::Command::assureWorkbench("SketcherWorkbench");
// When double-clicking on the item for this sketch the // When double-clicking on the item for this sketch the
// object unsets and sets its edit mode without closing // object unsets and sets its edit mode without closing
// the task panel // the task panel
@ -4580,6 +4583,9 @@ void ViewProviderSketch::unsetEdit(int ModNum)
// when pressing ESC make sure to close the dialog // when pressing ESC make sure to close the dialog
Gui::Control().closeDialog(); Gui::Control().closeDialog();
// return to the WB before edeting the sketch
Gui::Command::assureWorkbench(oldWb.c_str());
} }
void ViewProviderSketch::setEditViewer(Gui::View3DInventorViewer* viewer, int ModNum) void ViewProviderSketch::setEditViewer(Gui::View3DInventorViewer* viewer, int ModNum)

View File

@ -382,6 +382,7 @@ protected:
bool relative; bool relative;
Gui::Rubberband* rubberband; Gui::Rubberband* rubberband;
std::string oldWb;
}; };
} // namespace PartGui } // namespace PartGui