diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index e7c27222d1df..4b7450a5ea01 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -61,6 +61,7 @@ #include #include #include +#include #include #include "TaskFeaturePick.h" @@ -1889,6 +1890,15 @@ void finishDressupFeature(const Gui::Command* cmd, const std::string& which, FCMD_OBJ_CMD(Feat,"Base = " << str.str()); cmd->doCommand(cmd->Gui,"Gui.Selection.clearSelection()"); finishFeature(cmd, Feat, base); + + App::DocumentObject* baseFeature = static_cast(Feat)->Base.getValue(); + if (baseFeature) { + PartDesignGui::ViewProvider* view = dynamic_cast(Gui::Application::Instance->getViewProvider(baseFeature)); + // in case there is an error, for example when a fillet is larger than the available space + // display the base feature to avoid that the user sees nothing + if (view && Feat->isError()) + view->Visibility.setValue(true); + } } void makeChamferOrFillet(Gui::Command* cmd, const std::string& which) diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp index 83671682d5db..b979122ec383 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp @@ -102,6 +102,9 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView, Q this, SLOT(setSelection(QListWidgetItem*))); connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(doubleClicked(QListWidgetItem*))); + + // the dialog can be called on a broken chamfer, then hide the chamfer + hideOnError(); } void TaskChamferParameters::setUpUI(PartDesign::Chamfer* pcChamfer) @@ -231,6 +234,8 @@ void TaskChamferParameters::onRefDeleted(void) pcChamfer->Base.setValue(base, refs); // recompute the feature pcChamfer->recomputeFeature(); + // hide the chamfer if there was a computation error + hideOnError(); // if there is only one item left, it cannot be deleted if (ui->listWidgetReferences->count() == 1) { @@ -248,6 +253,8 @@ void TaskChamferParameters::onTypeChanged(int index) ui->stackedWidget->setCurrentIndex(index); ui->flipDirection->setEnabled(index != 0); // Enable if type is not "Equal distance" pcChamfer->getDocument()->recomputeFeature(pcChamfer); + // hide the chamfer if there was a computation error + hideOnError(); } void TaskChamferParameters::onSizeChanged(double len) @@ -256,6 +263,8 @@ void TaskChamferParameters::onSizeChanged(double len) setupTransaction(); pcChamfer->Size.setValue(len); pcChamfer->getDocument()->recomputeFeature(pcChamfer); + // hide the chamfer if there was a computation error + hideOnError(); } void TaskChamferParameters::onSize2Changed(double len) @@ -264,6 +273,8 @@ void TaskChamferParameters::onSize2Changed(double len) setupTransaction(); pcChamfer->Size2.setValue(len); pcChamfer->getDocument()->recomputeFeature(pcChamfer); + // hide the chamfer if there was a computation error + hideOnError(); } void TaskChamferParameters::onAngleChanged(double angle) @@ -272,6 +283,8 @@ void TaskChamferParameters::onAngleChanged(double angle) setupTransaction(); pcChamfer->Angle.setValue(angle); pcChamfer->getDocument()->recomputeFeature(pcChamfer); + // hide the chamfer if there was a computation error + hideOnError(); } void TaskChamferParameters::onFlipDirection(bool flip) @@ -280,6 +293,8 @@ void TaskChamferParameters::onFlipDirection(bool flip) setupTransaction(); pcChamfer->FlipDirection.setValue(flip); pcChamfer->getDocument()->recomputeFeature(pcChamfer); + // hide the chamfer if there was a computation error + hideOnError(); } int TaskChamferParameters::getType(void) const @@ -389,7 +404,6 @@ TaskDlgChamferParameters::~TaskDlgChamferParameters() //} bool TaskDlgChamferParameters::accept() { - parameter->showObject(); parameter->apply(); return TaskDlgDressUpParameters::accept(); diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp index 55e83b8e0b1b..75aef0926636 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp @@ -118,6 +118,9 @@ TaskDraftParameters::TaskDraftParameters(ViewProviderDressUp *DressUpView, QWidg ref = pcDraft->PullDirection.getValue(); strings = pcDraft->PullDirection.getSubValues(); ui->lineLine->setText(getRefStr(ref, strings)); + + // the dialog can be called on a broken draft, then hide the draft + hideOnError(); } void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg) @@ -171,6 +174,8 @@ void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg) pcDraft->getDocument()->recomputeFeature(pcDraft); // highlight existing references for possible further selections DressUpView->highlightReferences(true); + // hide the draft if there was a computation error + hideOnError(); } else if (selectionMode == line) { PartDesign::Draft* pcDraft = static_cast(DressUpView->getObject()); std::vector edges; @@ -185,6 +190,8 @@ void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg) pcDraft->getDocument()->recomputeFeature(pcDraft); // highlight existing references for possible further selections DressUpView->highlightReferences(true); + // hide the draft if there was a computation error + hideOnError(); } } } @@ -260,6 +267,8 @@ void TaskDraftParameters::onRefDeleted(void) pcDraft->Base.setValue(base, refs); // recompute the feature pcDraft->recomputeFeature(); + // hide the draft if there was a computation error + hideOnError(); // if there is only one item left, it cannot be deleted if (ui->listWidgetReferences->count() == 1) { @@ -295,6 +304,8 @@ void TaskDraftParameters::onAngleChanged(double angle) setupTransaction(); pcDraft->Angle.setValue(angle); pcDraft->getDocument()->recomputeFeature(pcDraft); + // hide the draft if there was a computation error + hideOnError(); } double TaskDraftParameters::getAngle(void) const @@ -308,6 +319,8 @@ void TaskDraftParameters::onReversedChanged(const bool on) { setupTransaction(); pcDraft->Reversed.setValue(on); pcDraft->getDocument()->recomputeFeature(pcDraft); + // hide the draft if there was a computation error + hideOnError(); } bool TaskDraftParameters::getReversed(void) const @@ -373,8 +386,6 @@ TaskDlgDraftParameters::~TaskDlgDraftParameters() bool TaskDlgDraftParameters::accept() { - parameter->showObject(); - std::vector strings; App::DocumentObject* obj; TaskDraftParameters* draftparameter = static_cast(parameter); diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp index 75f3663b3433..79f63a2b95db 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp @@ -291,6 +291,15 @@ void TaskDressUpParameters::removeItemFromListWidget(QListWidget* widget, const } } +void TaskDressUpParameters::hideOnError() +{ + App::DocumentObject* dressup = DressUpView->getObject(); + if (dressup->isError()) + hideObject(); + else + showObject(); +} + void TaskDressUpParameters::hideObject() { App::DocumentObject* base = getBase(); diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.h b/src/Mod/PartDesign/Gui/TaskDressUpParameters.h index 72ce57840432..e90883f52569 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.h +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.h @@ -77,6 +77,7 @@ protected Q_SLOTS: bool referenceSelected(const Gui::SelectionChanges& msg); bool wasDoubleClicked = false; bool KeyEvent(QEvent *e); + void hideOnError(); protected: enum selectionModes { none, refAdd, refRemove, plane, line }; diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp index 037d9c0ef1a3..bd83f737c626 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp @@ -96,6 +96,9 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView, QWi this, SLOT(setSelection(QListWidgetItem*))); connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(doubleClicked(QListWidgetItem*))); + + // the dialog can be called on a broken fillet, then hide the fillet + hideOnError(); } void TaskFilletParameters::onSelectionChanged(const Gui::SelectionChanges& msg) @@ -186,6 +189,8 @@ void TaskFilletParameters::onRefDeleted(void) pcFillet->Base.setValue(base, refs); // recompute the feature pcFillet->recomputeFeature(); + // hide the fillet if there was a computation error + hideOnError(); // if there is only one item left, it cannot be deleted if (ui->listWidgetReferences->count() == 1) { @@ -203,6 +208,8 @@ void TaskFilletParameters::onLengthChanged(double len) setupTransaction(); pcFillet->Radius.setValue(len); pcFillet->getDocument()->recomputeFeature(pcFillet); + // hide the fillet if there was a computation error + hideOnError(); } double TaskFilletParameters::getLength(void) const @@ -274,7 +281,6 @@ TaskDlgFilletParameters::~TaskDlgFilletParameters() //} bool TaskDlgFilletParameters::accept() { - parameter->showObject(); parameter->apply(); return TaskDlgDressUpParameters::accept(); diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp index 22c2fa3025f1..51cfa6f47dd3 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp @@ -118,6 +118,9 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie int join = pcThickness->Join.getValue(); ui->joinComboBox->setCurrentIndex(join); + + // the dialog can be called on a broken thickness, then hide the thickness + hideOnError(); } void TaskThicknessParameters::onSelectionChanged(const Gui::SelectionChanges& msg) @@ -208,6 +211,8 @@ void TaskThicknessParameters::onRefDeleted(void) pcThickness->Base.setValue(base, refs); // recompute the feature pcThickness->recomputeFeature(); + // hide the thickness if there was a computation error + hideOnError(); // if there is only one item left, it cannot be deleted if (ui->listWidgetReferences->count() == 1) { @@ -225,6 +230,8 @@ void TaskThicknessParameters::onValueChanged(double angle) setupTransaction(); pcThickness->Value.setValue(angle); pcThickness->getDocument()->recomputeFeature(pcThickness); + // hide the thickness if there was a computation error + hideOnError(); } void TaskThicknessParameters::onJoinTypeChanged(int join) { @@ -234,6 +241,8 @@ void TaskThicknessParameters::onJoinTypeChanged(int join) { setupTransaction(); pcThickness->Join.setValue(join); pcThickness->getDocument()->recomputeFeature(pcThickness); + // hide the thickness if there was a computation error + hideOnError(); } void TaskThicknessParameters::onModeChanged(int mode) { @@ -243,6 +252,8 @@ void TaskThicknessParameters::onModeChanged(int mode) { setupTransaction(); pcThickness->Mode.setValue(mode); pcThickness->getDocument()->recomputeFeature(pcThickness); + // hide the thickness if there was a computation error + hideOnError(); } double TaskThicknessParameters::getValue(void) const @@ -256,6 +267,8 @@ void TaskThicknessParameters::onReversedChanged(const bool on) { setupTransaction(); pcThickness->Reversed.setValue(on); pcThickness->getDocument()->recomputeFeature(pcThickness); + // hide the thickness if there was a computation error + hideOnError(); } bool TaskThicknessParameters::getReversed(void) const @@ -268,6 +281,8 @@ void TaskThicknessParameters::onIntersectionChanged(const bool on) { PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); pcThickness->Intersection.setValue(on); pcThickness->getDocument()->recomputeFeature(pcThickness); + // hide the thickness if there was a computation error + hideOnError(); } bool TaskThicknessParameters::getIntersection(void) const @@ -285,7 +300,6 @@ int TaskThicknessParameters::getMode(void) const { return ui->modeComboBox->currentIndex(); } - TaskThicknessParameters::~TaskThicknessParameters() { try { @@ -349,8 +363,6 @@ TaskDlgThicknessParameters::~TaskDlgThicknessParameters() bool TaskDlgThicknessParameters::accept() { - parameter->showObject(); - TaskThicknessParameters* draftparameter = static_cast(parameter); auto obj = vp->getObject();