From 3b95517a70ad16f0d192c6da803b1761668aecbb Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Fri, 10 May 2013 15:33:26 +0430 Subject: [PATCH] Drop into insert mode when user double-clicks on a PartDesign feature in the Tree --- src/Mod/PartDesign/Gui/Command.cpp | 3 ++ src/Mod/PartDesign/Gui/ViewProvider.cpp | 11 +++++++ src/Mod/PartDesign/Gui/ViewProvider.h | 1 + src/Mod/PartDesign/Gui/ViewProviderDatum.cpp | 30 +++++++++++++++++++ src/Mod/PartDesign/Gui/ViewProviderDatum.h | 2 ++ .../Gui/ViewProviderTransformed.cpp | 11 ++++++- 6 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index e074842a9..fe0aa261a 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -199,6 +199,9 @@ void CmdPartDesignMoveTip::activated(int iMsg) prevSolidFeature = pcActiveBody->getPrevSolidFeature(); if ((prevSolidFeature != NULL) && !PartDesign::Body::isSolidFeature(selFeature)) doCommand(Gui,"Gui.activeDocument().show(\"%s\")", prevSolidFeature->getNameInDocument()); + + // TOOD: Hide all datum features after the Tip feature? But the user might have already hidden some and wants to see + // others, so we would have to remember their state somehow } bool CmdPartDesignMoveTip::isActive(void) diff --git a/src/Mod/PartDesign/Gui/ViewProvider.cpp b/src/Mod/PartDesign/Gui/ViewProvider.cpp index dfe39e3eb..a0b9de8a8 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.cpp +++ b/src/Mod/PartDesign/Gui/ViewProvider.cpp @@ -41,6 +41,8 @@ PROPERTY_SOURCE(PartDesignGui::ViewProvider,PartGui::ViewProviderPart) ViewProvider::ViewProvider() { + oldWb = ""; + oldTip = NULL; } ViewProvider::~ViewProvider() @@ -52,6 +54,15 @@ bool ViewProvider::doubleClicked(void) std::string Msg("Edit "); Msg += this->pcObject->Label.getValue(); Gui::Command::openCommand(Msg.c_str()); + if (PartDesignGui::ActivePartObject != 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 + oldTip = ActivePartObject->Tip.getValue(); + Gui::Command::doCommand(Gui::Command::Gui,"FreeCADGui.runCommand('PartDesign_MoveTip')"); + } else { + oldTip = NULL; + } + try { Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s',0)",this->pcObject->getNameInDocument()); } diff --git a/src/Mod/PartDesign/Gui/ViewProvider.h b/src/Mod/PartDesign/Gui/ViewProvider.h index 7dff03edb..32926f154 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.h +++ b/src/Mod/PartDesign/Gui/ViewProvider.h @@ -46,6 +46,7 @@ protected: virtual void unsetEdit(int ModNum); std::string oldWb; + App::DocumentObject* oldTip; }; diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp index c5aafe547..cbefe3883 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp @@ -68,6 +68,9 @@ ViewProviderDatum::ViewProviderDatum() { pShapeSep = new SoSeparator(); pShapeSep->ref(); + + oldWb = ""; + oldTip = NULL; } ViewProviderDatum::~ViewProviderDatum() @@ -253,6 +256,24 @@ bool ViewProviderDatum::setEdit(int ModNum) } } +bool ViewProviderDatum::doubleClicked(void) +{ + std::string Msg("Edit "); + Msg += this->pcObject->Label.getValue(); + Gui::Command::openCommand(Msg.c_str()); + if (PartDesignGui::ActivePartObject != 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 + oldTip = ActivePartObject->Tip.getValue(); + Gui::Command::doCommand(Gui::Command::Gui,"FreeCADGui.runCommand('PartDesign_MoveTip')"); + } else { + oldTip = NULL; + } + + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s',0)",this->pcObject->getNameInDocument()); + return true; +} + void ViewProviderDatum::unsetEdit(int ModNum) { // return to the WB we were in before editing the PartDesign feature @@ -261,6 +282,15 @@ void ViewProviderDatum::unsetEdit(int ModNum) 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 { + oldTip = NULL; + } } else { Gui::ViewProviderGeometryObject::unsetEdit(ModNum); diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatum.h b/src/Mod/PartDesign/Gui/ViewProviderDatum.h index c73c2183a..db4c48c9c 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatum.h +++ b/src/Mod/PartDesign/Gui/ViewProviderDatum.h @@ -44,6 +44,7 @@ public: virtual void attach(App::DocumentObject *); virtual bool onDelete(const std::vector &); virtual void updateData(const App::Property* prop) { Gui::ViewProviderGeometryObject::updateData(prop); } + virtual bool doubleClicked(void); std::vector getDisplayModes(void) const; void setDisplayMode(const char* ModeName); @@ -66,6 +67,7 @@ protected: protected: SoSeparator* pShapeSep; std::string oldWb; + App::DocumentObject* oldTip; }; diff --git a/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp b/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp index 60f2cfd6a..249b22972 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp @@ -47,6 +47,7 @@ # include #endif +#include "Workbench.h" #include "ViewProviderTransformed.h" #include "TaskTransformedParameters.h" #include @@ -136,7 +137,15 @@ void ViewProviderTransformed::unsetEdit(int ModNum) if (ModNum == ViewProvider::Default) { // when pressing ESC make sure to close the dialog - Gui::Control().closeDialog(); + 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 { + oldTip = NULL; + } } else { PartGui::ViewProviderPart::unsetEdit(ModNum);