PartDesign: Add new need active body dialog with option to choose body (#4949)

* [PD] Add new need active body dialog

Intended for use wherever an active body is needed but none exists. The dialog
contains a list with the bodies present in the document, with an extra option to
make a new body. Custom text can be provided if needed.

This commit also replaces the warnings used by "new sketch" and "primitive"
command with this new dialog.

Addresses issue #4288.
This commit is contained in:
Ajinkya Dahale
2021-09-16 13:27:46 -04:00
committed by GitHub
parent 820e88f95b
commit e305dbd49c
8 changed files with 324 additions and 42 deletions

View File

@@ -41,6 +41,7 @@
#include "Utils.h"
#include "WorkflowManager.h"
#include "DlgActiveBody.h"
using namespace std;
@@ -85,12 +86,15 @@ void CmdPrimtiveCompAdditive::activated(int iMsg)
PartDesign::Body *pcActiveBody = PartDesignGui::getBody( /* messageIfNot = */ false );
auto shouldMakeBody( false );
if (pcActiveBody == nullptr) {
if (!pcActiveBody) {
if ( doc->getObjectsOfType(PartDesign::Body::getClassTypeId()).empty() ) {
shouldMakeBody = true;
} else {
PartDesignGui::needActiveBodyError();
return;
PartDesignGui::DlgActiveBody dia(Gui::getMainWindow(), doc);
if (dia.exec() == QDialog::DialogCode::Accepted)
pcActiveBody = dia.getActiveBody();
if (!pcActiveBody)
return;
}
}
@@ -104,7 +108,7 @@ void CmdPrimtiveCompAdditive::activated(int iMsg)
pcActiveBody = PartDesignGui::makeBody(doc);
}
if (pcActiveBody == nullptr) {
if (!pcActiveBody) {
return;
}