add option to getBodyFor to suppress dialog to set workflow style to modern
This commit is contained in:
@@ -67,7 +67,7 @@ namespace PartDesignGui {
|
||||
* \param autoActivate
|
||||
* \return Body
|
||||
*/
|
||||
PartDesign::Body *getBody(bool messageIfNot, bool autoActivate)
|
||||
PartDesign::Body *getBody(bool messageIfNot, bool autoActivate, bool assertModern)
|
||||
{
|
||||
PartDesign::Body * activeBody = nullptr;
|
||||
Gui::MDIView *activeView = Gui::Application::Instance->activeView();
|
||||
@@ -75,7 +75,7 @@ PartDesign::Body *getBody(bool messageIfNot, bool autoActivate)
|
||||
if (activeView) {
|
||||
bool singleBodyDocument = activeView->getAppDocument()->
|
||||
countObjectsOfType(PartDesign::Body::getClassTypeId()) == 1;
|
||||
if ( PartDesignGui::assureModernWorkflow ( activeView->getAppDocument() ) ) {
|
||||
if (assertModern && PartDesignGui::assureModernWorkflow ( activeView->getAppDocument() ) ) {
|
||||
activeBody = activeView->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
|
||||
if (!activeBody && singleBodyDocument && autoActivate) {
|
||||
@@ -122,12 +122,13 @@ PartDesign::Body * makeBody(App::Document *doc)
|
||||
return activeView->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
}
|
||||
|
||||
PartDesign::Body *getBodyFor(const App::DocumentObject* obj, bool messageIfNot, bool autoActivate)
|
||||
PartDesign::Body *getBodyFor(const App::DocumentObject* obj, bool messageIfNot,
|
||||
bool autoActivate, bool assertModern)
|
||||
{
|
||||
if(!obj)
|
||||
return nullptr;
|
||||
|
||||
PartDesign::Body * rv = getBody(/*messageIfNot =*/false, autoActivate);
|
||||
PartDesign::Body * rv = getBody(/*messageIfNot =*/false, autoActivate, assertModern);
|
||||
if (rv && rv->hasObject(obj))
|
||||
return rv;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Sketcher {
|
||||
namespace PartDesignGui {
|
||||
|
||||
/// Return active body or show a warning message
|
||||
PartDesign::Body *getBody(bool messageIfNot, bool autoActivate=true);
|
||||
PartDesign::Body *getBody(bool messageIfNot, bool autoActivate=true, bool assertModern=true);
|
||||
|
||||
/// Display error when there are existing Body objects, but none are active
|
||||
void needActiveBodyError(void);
|
||||
@@ -56,7 +56,8 @@ 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, bool autoActivate=true);
|
||||
PartDesign::Body *getBodyFor(const App::DocumentObject*, bool messageIfNot,
|
||||
bool autoActivate=true, bool assertModern=true);
|
||||
App::Part *getPartFor(const App::DocumentObject*, bool messageIfNot);
|
||||
App::Part *getActivePart();
|
||||
|
||||
|
||||
@@ -163,7 +163,16 @@ 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, false);
|
||||
PartDesign::Body *body = nullptr;
|
||||
|
||||
// if PD workflow is not new-style then add a command to the context-menu
|
||||
bool assertModern = true;
|
||||
if (feature && !isModernWorkflow(feature->getDocument())) {
|
||||
assertModern = false;
|
||||
*item << "PartDesign_Migrate";
|
||||
}
|
||||
|
||||
body = PartDesignGui::getBodyFor (feature, false, false, assertModern);
|
||||
// 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