do not auto activate single body in document when opening context-menu
This commit is contained in:
@@ -59,7 +59,15 @@ using namespace Attacher;
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
PartDesign::Body *getBody(bool messageIfNot)
|
||||
/*!
|
||||
* \brief Return active body or show a warning message.
|
||||
* If \a autoActivate is true (the default) then if there is
|
||||
* only single body in the document it will be activated.
|
||||
* \param messageIfNot
|
||||
* \param autoActivate
|
||||
* \return Body
|
||||
*/
|
||||
PartDesign::Body *getBody(bool messageIfNot, bool autoActivate)
|
||||
{
|
||||
PartDesign::Body * activeBody = nullptr;
|
||||
Gui::MDIView *activeView = Gui::Application::Instance->activeView();
|
||||
@@ -70,7 +78,7 @@ PartDesign::Body *getBody(bool messageIfNot)
|
||||
if ( PartDesignGui::assureModernWorkflow ( activeView->getAppDocument() ) ) {
|
||||
activeBody = activeView->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
|
||||
if (!activeBody && singleBodyDocument) {
|
||||
if (!activeBody && singleBodyDocument && autoActivate) {
|
||||
Gui::Command::doCommand( Gui::Command::Gui,
|
||||
"Gui.activeView().setActiveObject('pdbody',App.ActiveDocument.findObjects('PartDesign::Body')[0])");
|
||||
activeBody = activeView->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
@@ -114,13 +122,13 @@ PartDesign::Body * makeBody(App::Document *doc)
|
||||
return activeView->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
}
|
||||
|
||||
PartDesign::Body *getBodyFor(const App::DocumentObject* obj, bool messageIfNot)
|
||||
PartDesign::Body *getBodyFor(const App::DocumentObject* obj, bool messageIfNot, bool autoActivate)
|
||||
{
|
||||
if(!obj)
|
||||
return nullptr;
|
||||
|
||||
PartDesign::Body * rv = getBody( /*messageIfNot =*/ false);
|
||||
if(rv && rv->hasObject(obj))
|
||||
PartDesign::Body * rv = getBody(/*messageIfNot =*/false, autoActivate);
|
||||
if (rv && rv->hasObject(obj))
|
||||
return rv;
|
||||
|
||||
rv = PartDesign::Body::findBodyOf(obj);
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Sketcher {
|
||||
namespace PartDesignGui {
|
||||
|
||||
/// Return active body or show a warning message
|
||||
PartDesign::Body *getBody(bool messageIfNot);
|
||||
PartDesign::Body *getBody(bool messageIfNot, bool autoActivate=true);
|
||||
|
||||
/// Display error when there are existing Body objects, but none are active
|
||||
void needActiveBodyError(void);
|
||||
@@ -56,7 +56,7 @@ PartDesign::Body * makeBody(App::Document *doc);
|
||||
* Finds a body for the given feature. And shows a message if not found
|
||||
* Also unlike Body::findBodyFor it checks if the active body has the feature first.
|
||||
*/
|
||||
PartDesign::Body *getBodyFor(const App::DocumentObject*, bool messageIfNot);
|
||||
PartDesign::Body *getBodyFor(const App::DocumentObject*, bool messageIfNot, bool autoActivate=true);
|
||||
App::Part *getPartFor(const App::DocumentObject*, bool messageIfNot);
|
||||
App::Part *getActivePart();
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ void Workbench::setupContextMenu(const char* recipient, Gui::MenuItem* item) con
|
||||
// Add move Tip Command
|
||||
if ( selection.size () >= 1 ) {
|
||||
App::DocumentObject *feature = selection.front().pObject;
|
||||
PartDesign::Body *body = PartDesignGui::getBodyFor ( feature, false );
|
||||
PartDesign::Body *body = PartDesignGui::getBodyFor (feature, false, false);
|
||||
// lote of assertion so feature should be marked as a tip
|
||||
if ( selection.size () == 1 && feature && (
|
||||
feature->isDerivedFrom ( PartDesign::Body::getClassTypeId () ) ||
|
||||
|
||||
Reference in New Issue
Block a user