From 8ada7af302c9d6579ac7642669de4dc9a6394bc3 Mon Sep 17 00:00:00 2001 From: Paddle Date: Tue, 21 Mar 2023 16:28:18 +0100 Subject: [PATCH 1/6] PartDesign: Fillet/chamfer/draft/thickness: Merge Add & Remove buttons. --- .../PartDesign/Gui/TaskChamferParameters.cpp | 52 +++++++----------- .../PartDesign/Gui/TaskChamferParameters.ui | 40 ++++---------- .../PartDesign/Gui/TaskDraftParameters.cpp | 47 +++++++--------- src/Mod/PartDesign/Gui/TaskDraftParameters.ui | 41 +++++--------- .../PartDesign/Gui/TaskDressUpParameters.cpp | 54 +++++-------------- .../PartDesign/Gui/TaskDressUpParameters.h | 9 ++-- .../PartDesign/Gui/TaskFilletParameters.cpp | 52 +++++++----------- .../PartDesign/Gui/TaskFilletParameters.ui | 40 ++++---------- .../Gui/TaskThicknessParameters.cpp | 45 +++++++--------- .../PartDesign/Gui/TaskThicknessParameters.ui | 40 ++++---------- 10 files changed, 141 insertions(+), 279 deletions(-) diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp index a1255ab0c0..0cf07fb19d 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp @@ -62,8 +62,7 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView, Q bool useAllEdges = pcChamfer->UseAllEdges.getValue(); ui->checkBoxUseAllEdges->setChecked(useAllEdges); - ui->buttonRefAdd->setEnabled(!useAllEdges); - ui->buttonRefRemove->setEnabled(!useAllEdges); + ui->buttonRefSel->setEnabled(!useAllEdges); ui->listWidgetReferences->setEnabled(!useAllEdges); QMetaObject::invokeMethod(ui->chamferSize, "setFocus", Qt::QueuedConnection); @@ -85,15 +84,13 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView, Q this, &TaskChamferParameters::onAngleChanged); connect(ui->flipDirection, &QCheckBox::toggled, this, &TaskChamferParameters::onFlipDirection); - connect(ui->buttonRefAdd, &QToolButton::toggled, - this, &TaskChamferParameters::onButtonRefAdd); - connect(ui->buttonRefRemove, &QToolButton::toggled, - this, &TaskChamferParameters::onButtonRefRemove); + connect(ui->buttonRefSel, &QToolButton::toggled, + this, &TaskChamferParameters::onButtonRefSel); connect(ui->checkBoxUseAllEdges, &QCheckBox::toggled, this, &TaskChamferParameters::onCheckBoxUseAllEdgesToggled); // Create context menu - createDeleteAction(ui->listWidgetReferences, ui->buttonRefRemove); + createDeleteAction(ui->listWidgetReferences); connect(deleteAction, &QAction::triggered, this, &TaskChamferParameters::onRefDeleted); createAddAllEdgesAction(ui->listWidgetReferences); @@ -160,29 +157,25 @@ void TaskChamferParameters::onSelectionChanged(const Gui::SelectionChanges& msg) if (msg.Type == Gui::SelectionChanges::AddSelection) { if (referenceSelected(msg)) { - if (selectionMode == refAdd) { + // Clear selection. + Gui::Selection().clearSelection(); + + if (removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName)) { + // if there is only one item left, it cannot be deleted + if (ui->listWidgetReferences->count() == 1) { + deleteAction->setEnabled(false); + deleteAction->setStatusTip(tr("There must be at least one item")); + // we must also end the selection mode + exitSelectionMode(); + clearButtons(none); + } + } + else { ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName)); // it might be the second one so we can enable the context menu if (ui->listWidgetReferences->count() > 1) { deleteAction->setEnabled(true); deleteAction->setStatusTip(QString()); - ui->buttonRefRemove->setEnabled(true); - ui->buttonRefRemove->setToolTip(tr("Click button to enter selection mode,\nclick again to end selection")); - } - } - else { - removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName); - // remove its selection too - Gui::Selection().clearSelection(); - // if there is only one item left, it cannot be deleted - if (ui->listWidgetReferences->count() == 1) { - deleteAction->setEnabled(false); - deleteAction->setStatusTip(tr("There must be at least one item")); - ui->buttonRefRemove->setEnabled(false); - ui->buttonRefRemove->setToolTip(tr("There must be at least one item")); - // we must also end the selection mode - exitSelectionMode(); - clearButtons(none); } } // highlight existing references for possible further selections @@ -194,8 +187,7 @@ void TaskChamferParameters::onSelectionChanged(const Gui::SelectionChanges& msg) void TaskChamferParameters::onCheckBoxUseAllEdgesToggled(bool checked) { PartDesign::Chamfer* pcChamfer = static_cast(DressUpView->getObject()); - ui->buttonRefRemove->setEnabled(!checked); - ui->buttonRefAdd->setEnabled(!checked); + ui->buttonRefSel->setEnabled(!checked); ui->listWidgetReferences->setEnabled(!checked); pcChamfer->UseAllEdges.setValue(checked); pcChamfer->getDocument()->recomputeFeature(pcChamfer); @@ -203,8 +195,7 @@ void TaskChamferParameters::onCheckBoxUseAllEdgesToggled(bool checked) void TaskChamferParameters::clearButtons(const selectionModes notThis) { - if (notThis != refAdd) ui->buttonRefAdd->setChecked(false); - if (notThis != refRemove) ui->buttonRefRemove->setChecked(false); + if (notThis != refSel) ui->buttonRefSel->setChecked(false); DressUpView->highlightReferences(false); } @@ -255,15 +246,12 @@ void TaskChamferParameters::onRefDeleted() if (ui->listWidgetReferences->count() == 1) { deleteAction->setEnabled(false); deleteAction->setStatusTip(tr("There must be at least one item")); - ui->buttonRefRemove->setEnabled(false); - ui->buttonRefRemove->setToolTip(tr("There must be at least one item")); } } void TaskChamferParameters::onAddAllEdges() { TaskDressUpParameters::addAllEdges(ui->listWidgetReferences); - ui->buttonRefRemove->setEnabled(true); } void TaskChamferParameters::onTypeChanged(int index) diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.ui b/src/Mod/PartDesign/Gui/TaskChamferParameters.ui index 52b2295fe5..aff84ea890 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.ui @@ -15,36 +15,18 @@ - - - - - Click button to enter selection mode, + + + Click button to enter selection mode, click again to end selection - - - Add - - - true - - - - - - - Click button to enter selection mode, -click again to end selection - - - Remove - - - true - - - - + + + Select + + + true + + diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp index aebcaabe45..209c0df4af 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp @@ -85,17 +85,15 @@ TaskDraftParameters::TaskDraftParameters(ViewProviderDressUp *DressUpView, QWidg this, &TaskDraftParameters::onAngleChanged); connect(ui->checkReverse, &QCheckBox::toggled, this, &TaskDraftParameters::onReversedChanged); - connect(ui->buttonRefAdd, &QToolButton::toggled, - this, &TaskDraftParameters::onButtonRefAdd); - connect(ui->buttonRefRemove, &QToolButton::toggled, - this, &TaskDraftParameters::onButtonRefRemove); + connect(ui->buttonRefSel, &QToolButton::toggled, + this, &TaskDraftParameters::onButtonRefSel); connect(ui->buttonPlane, &QToolButton::toggled, this, &TaskDraftParameters::onButtonPlane); connect(ui->buttonLine, &QToolButton::toggled, this, &TaskDraftParameters::onButtonLine); // Create context menu - createDeleteAction(ui->listWidgetReferences, ui->buttonRefRemove); + createDeleteAction(ui->listWidgetReferences); connect(deleteAction, &QAction::triggered, this, &TaskDraftParameters::onRefDeleted); connect(ui->listWidgetReferences, &QListWidget::currentItemChanged, @@ -127,34 +125,31 @@ void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg) if (msg.Type == Gui::SelectionChanges::AddSelection) { if (referenceSelected(msg)) { - if (selectionMode == refAdd) { - ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName)); - // it might be the second one so we can enable the context menu - if (ui->listWidgetReferences->count() > 1) { - deleteAction->setEnabled(true); - deleteAction->setStatusTip(QString()); - ui->buttonRefRemove->setEnabled(true); - ui->buttonRefRemove->setToolTip(tr("Click button to enter selection mode,\nclick again to end selection")); - } - } - else { - removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName); - // remove its selection too - Gui::Selection().clearSelection(); + // Clear selection. + Gui::Selection().clearSelection(); + + if (removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName)) { // if there is only one item left, it cannot be deleted if (ui->listWidgetReferences->count() == 1) { deleteAction->setEnabled(false); deleteAction->setStatusTip(tr("There must be at least one item")); - ui->buttonRefRemove->setEnabled(false); - ui->buttonRefRemove->setToolTip(tr("There must be at least one item")); // we must also end the selection mode exitSelectionMode(); clearButtons(none); } } + else { + ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName)); + // it might be the second one so we can enable the context menu + if (ui->listWidgetReferences->count() > 1) { + deleteAction->setEnabled(true); + deleteAction->setStatusTip(QString()); + } + } // highlight existing references for possible further selections DressUpView->highlightReferences(true); - } else if (selectionMode == plane) { + } + else if (selectionMode == plane) { PartDesign::Draft* pcDraft = static_cast(DressUpView->getObject()); std::vector planes; App::DocumentObject* selObj; @@ -170,7 +165,8 @@ void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg) DressUpView->highlightReferences(true); // hide the draft if there was a computation error hideOnError(); - } else if (selectionMode == line) { + } + else if (selectionMode == line) { PartDesign::Draft* pcDraft = static_cast(DressUpView->getObject()); std::vector edges; App::DocumentObject* selObj; @@ -192,8 +188,7 @@ void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg) void TaskDraftParameters::clearButtons(const selectionModes notThis) { - if (notThis != refAdd) ui->buttonRefAdd->setChecked(false); - if (notThis != refRemove) ui->buttonRefRemove->setChecked(false); + if (notThis != refSel) ui->buttonRefSel->setChecked(false); if (notThis != line) ui->buttonLine->setChecked(false); if (notThis != plane) ui->buttonPlane->setChecked(false); DressUpView->highlightReferences(false); @@ -271,8 +266,6 @@ void TaskDraftParameters::onRefDeleted(void) if (ui->listWidgetReferences->count() == 1) { deleteAction->setEnabled(false); deleteAction->setStatusTip(tr("There must be at least one item")); - ui->buttonRefRemove->setEnabled(false); - ui->buttonRefRemove->setToolTip(tr("There must be at least one item")); } } diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.ui b/src/Mod/PartDesign/Gui/TaskDraftParameters.ui index c3f11b0f52..ca30e850ae 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.ui @@ -15,36 +15,19 @@ - - - - - Click button to enter selection mode, + + + + Click button to enter selection mode, click again to end selection - - - Add face - - - true - - - - - - - Click button to enter selection mode, -click again to end selection - - - Remove face - - - true - - - - + + + Select face + + + true + + diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp index 55286e000d..ef5cbc36fb 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp @@ -97,8 +97,7 @@ void TaskDressUpParameters::setupTransaction() bool TaskDressUpParameters::referenceSelected(const Gui::SelectionChanges& msg) { - if ((msg.Type == Gui::SelectionChanges::AddSelection) && ( - (selectionMode == refAdd) || (selectionMode == refRemove))) { + if ((msg.Type == Gui::SelectionChanges::AddSelection) && (selectionMode == refSel)) { if (strcmp(msg.pDocName, DressUpView->getObject()->getDocument()->getName()) != 0) return false; @@ -115,17 +114,11 @@ bool TaskDressUpParameters::referenceSelected(const Gui::SelectionChanges& msg) std::vector refs = pcDressUp->Base.getSubValues(); std::vector::iterator f = std::find(refs.begin(), refs.end(), subName); - if (selectionMode == refAdd) { - if (f == refs.end()) - refs.push_back(subName); - else - return false; // duplicate selection - } else { - if (f != refs.end()) - refs.erase(f); - else - return false; - } + if (f != refs.end()) + refs.erase(f); + else + refs.push_back(subName); + DressUpView->highlightReferences(false); setupTransaction(); pcDressUp->Base.setValue(base, refs); @@ -162,7 +155,7 @@ void TaskDressUpParameters::addAllEdges(QListWidget* widget) pcDressUp->getDocument()->recomputeFeature(pcDressUp); hideObject(); DressUpView->highlightReferences(true); - onButtonRefAdd(true); + onButtonRefSel(true); if (deleteAction) { deleteAction->setEnabled(widget->count() > 1); @@ -171,12 +164,12 @@ void TaskDressUpParameters::addAllEdges(QListWidget* widget) } } -void TaskDressUpParameters::onButtonRefAdd(bool checked) +void TaskDressUpParameters::onButtonRefSel(bool checked) { if (checked) { - clearButtons(refAdd); + clearButtons(refSel); hideObject(); - selectionMode = refAdd; + selectionMode = refSel; if (addAllEdgesAction) addAllEdgesAction->setEnabled(true); AllowSelectionFlags allow; @@ -194,25 +187,6 @@ void TaskDressUpParameters::onButtonRefAdd(bool checked) } } -void TaskDressUpParameters::onButtonRefRemove(const bool checked) -{ - if (checked) { - clearButtons(refRemove); - hideObject(); - selectionMode = refRemove; - AllowSelectionFlags allow; - allow.setFlag(AllowSelection::EDGE, allowEdges); - allow.setFlag(AllowSelection::FACE, allowFaces); - Gui::Selection().clearSelection(); - Gui::Selection().addSelectionGate(new ReferenceSelection(this->getBase(), allow)); - DressUpView->highlightReferences(true); - } - else { - exitSelectionMode(); - DressUpView->highlightReferences(false); - } -} - void TaskDressUpParameters::doubleClicked(QListWidgetItem* item) { // executed when the user double-clicks on any item in the list // shows the fillets as they are -> useful to switch out of selection mode @@ -286,7 +260,7 @@ void TaskDressUpParameters::createAddAllEdgesAction(QListWidget* parentList) } -void TaskDressUpParameters::createDeleteAction(QListWidget* parentList, QWidget* parentButton) +void TaskDressUpParameters::createDeleteAction(QListWidget* parentList) { // creates a context menu, a shortcut for it and connects it to a slot function @@ -301,8 +275,6 @@ void TaskDressUpParameters::createDeleteAction(QListWidget* parentList, QWidget* if (parentList->count() == 1) { deleteAction->setEnabled(false); deleteAction->setStatusTip(tr("There must be at least one item")); - parentButton->setEnabled(false); - parentButton->setToolTip(tr("There must be at least one item")); } parentList->setContextMenuPolicy(Qt::ActionsContextMenu); } @@ -347,7 +319,7 @@ const std::vector TaskDressUpParameters::getReferences() const } // TODO: This code is identical with TaskTransformedParameters::removeItemFromListWidget() -void TaskDressUpParameters::removeItemFromListWidget(QListWidget* widget, const char* itemstr) +bool TaskDressUpParameters::removeItemFromListWidget(QListWidget* widget, const char* itemstr) { QList items = widget->findItems(QString::fromLatin1(itemstr), Qt::MatchExactly); if (!items.empty()) { @@ -355,7 +327,9 @@ void TaskDressUpParameters::removeItemFromListWidget(QListWidget* widget, const QListWidgetItem* it = widget->takeItem(widget->row(*i)); delete it; } + return true; } + return false; } void TaskDressUpParameters::hideOnError() diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.h b/src/Mod/PartDesign/Gui/TaskDressUpParameters.h index f3a011cc73..a6a9181978 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.h +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.h @@ -63,13 +63,12 @@ public: } protected Q_SLOTS: - void onButtonRefAdd(const bool checked); - void onButtonRefRemove(const bool checked); + void onButtonRefSel(const bool checked); void doubleClicked(QListWidgetItem* item); void setSelection(QListWidgetItem* current); void itemClickedTimeout(); virtual void onRefDeleted(void) = 0; - void createDeleteAction(QListWidget* parentList, QWidget* parentButton); + void createDeleteAction(QListWidget* parentList); void createAddAllEdgesAction(QListWidget* parentList); protected: @@ -81,9 +80,9 @@ protected: void addAllEdges(QListWidget* listWidget); protected: - enum selectionModes { none, refAdd, refRemove, plane, line }; + enum selectionModes { none, refSel, plane, line }; virtual void clearButtons(const selectionModes notThis) = 0; - static void removeItemFromListWidget(QListWidget* widget, const char* itemstr); + static bool removeItemFromListWidget(QListWidget* widget, const char* itemstr); ViewProviderDressUp* getDressUpView() const { return DressUpView; } diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp index 3f9959d474..97feb14290 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp @@ -58,8 +58,7 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView, QWi PartDesign::Fillet* pcFillet = static_cast(DressUpView->getObject()); bool useAllEdges = pcFillet->UseAllEdges.getValue(); ui->checkBoxUseAllEdges->setChecked(useAllEdges); - ui->buttonRefAdd->setEnabled(!useAllEdges); - ui->buttonRefRemove->setEnabled(!useAllEdges); + ui->buttonRefSel->setEnabled(!useAllEdges); ui->listWidgetReferences->setEnabled(!useAllEdges); double r = pcFillet->Radius.getValue(); @@ -79,15 +78,13 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView, QWi connect(ui->filletRadius, qOverload(&Gui::QuantitySpinBox::valueChanged), this, &TaskFilletParameters::onLengthChanged); - connect(ui->buttonRefAdd, &QToolButton::toggled, - this, &TaskFilletParameters::onButtonRefAdd); - connect(ui->buttonRefRemove, &QToolButton::toggled, - this, &TaskFilletParameters::onButtonRefRemove); + connect(ui->buttonRefSel, &QToolButton::toggled, + this, &TaskFilletParameters::onButtonRefSel); connect(ui->checkBoxUseAllEdges, &QToolButton::toggled, this, &TaskFilletParameters::onCheckBoxUseAllEdgesToggled); // Create context menu - createDeleteAction(ui->listWidgetReferences, ui->buttonRefRemove); + createDeleteAction(ui->listWidgetReferences); connect(deleteAction, &QAction::triggered, this, &TaskFilletParameters::onRefDeleted); createAddAllEdgesAction(ui->listWidgetReferences); @@ -114,29 +111,25 @@ void TaskFilletParameters::onSelectionChanged(const Gui::SelectionChanges& msg) if (msg.Type == Gui::SelectionChanges::AddSelection) { if (referenceSelected(msg)) { - if (selectionMode == refAdd) { + // Clear selection. + Gui::Selection().clearSelection(); + + if (removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName)) { + // if there is only one item left, it cannot be deleted + if (ui->listWidgetReferences->count() == 1) { + deleteAction->setEnabled(false); + deleteAction->setStatusTip(tr("There must be at least one item")); + // we must also end the selection mode + exitSelectionMode(); + clearButtons(none); + } + } + else { ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName)); // it might be the second one so we can enable the context menu if (ui->listWidgetReferences->count() > 1) { deleteAction->setEnabled(true); deleteAction->setStatusTip(QString()); - ui->buttonRefRemove->setEnabled(true); - ui->buttonRefRemove->setToolTip(tr("Click button to enter selection mode,\nclick again to end selection")); - } - } - else { - removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName); - // remove its selection too - Gui::Selection().clearSelection(); - // if there is only one item left, it cannot be deleted - if (ui->listWidgetReferences->count() == 1) { - deleteAction->setEnabled(false); - deleteAction->setStatusTip(tr("There must be at least one item")); - ui->buttonRefRemove->setEnabled(false); - ui->buttonRefRemove->setToolTip(tr("There must be at least one item")); - // we must also end the selection mode - exitSelectionMode(); - clearButtons(none); } } // highlight existing references for possible further selections @@ -148,8 +141,7 @@ void TaskFilletParameters::onSelectionChanged(const Gui::SelectionChanges& msg) void TaskFilletParameters::onCheckBoxUseAllEdgesToggled(bool checked) { PartDesign::Fillet* pcFillet = static_cast(DressUpView->getObject()); - ui->buttonRefRemove->setEnabled(!checked); - ui->buttonRefAdd->setEnabled(!checked); + ui->buttonRefSel->setEnabled(!checked); ui->listWidgetReferences->setEnabled(!checked); pcFillet->UseAllEdges.setValue(checked); pcFillet->getDocument()->recomputeFeature(pcFillet); @@ -157,8 +149,7 @@ void TaskFilletParameters::onCheckBoxUseAllEdgesToggled(bool checked) void TaskFilletParameters::clearButtons(const selectionModes notThis) { - if (notThis != refAdd) ui->buttonRefAdd->setChecked(false); - if (notThis != refRemove) ui->buttonRefRemove->setChecked(false); + if (notThis != refSel) ui->buttonRefSel->setChecked(false); DressUpView->highlightReferences(false); } @@ -209,15 +200,12 @@ void TaskFilletParameters::onRefDeleted() if (ui->listWidgetReferences->count() == 1) { deleteAction->setEnabled(false); deleteAction->setStatusTip(tr("There must be at least one item")); - ui->buttonRefRemove->setEnabled(false); - ui->buttonRefRemove->setToolTip(tr("There must be at least one item")); } } void TaskFilletParameters::onAddAllEdges() { TaskDressUpParameters::addAllEdges(ui->listWidgetReferences); - ui->buttonRefRemove->setEnabled(true); } void TaskFilletParameters::onLengthChanged(double len) diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.ui b/src/Mod/PartDesign/Gui/TaskFilletParameters.ui index 2718be1f63..8b6fb663ff 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.ui @@ -15,36 +15,18 @@ - - - - - Click button to enter selection mode, + + + Click button to enter selection mode, click again to end selection - - - Add - - - true - - - - - - - Click button to enter selection mode, -click again to end selection - - - Remove - - - true - - - - + + + Select + + + true + + diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp index cefa05518f..5508fa2bf1 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp @@ -86,17 +86,15 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie this, &TaskThicknessParameters::onReversedChanged); connect(ui->checkIntersection, &QCheckBox::toggled, this, &TaskThicknessParameters::onIntersectionChanged); - connect(ui->buttonRefAdd, &QToolButton::toggled, - this, &TaskThicknessParameters::onButtonRefAdd); - connect(ui->buttonRefRemove, &QToolButton::toggled, - this, &TaskThicknessParameters::onButtonRefRemove); + connect(ui->buttonRefSel, &QToolButton::toggled, + this, &TaskThicknessParameters::onButtonRefSel); connect(ui->modeComboBox, qOverload(&QComboBox::currentIndexChanged), this, &TaskThicknessParameters::onModeChanged); connect(ui->joinComboBox, qOverload(&QComboBox::currentIndexChanged), this, &TaskThicknessParameters::onJoinTypeChanged); // Create context menu - createDeleteAction(ui->listWidgetReferences, ui->buttonRefRemove); + createDeleteAction(ui->listWidgetReferences); connect(deleteAction, &QAction::triggered, this, &TaskThicknessParameters::onRefDeleted); connect(ui->listWidgetReferences, &QListWidget::currentItemChanged, @@ -126,29 +124,25 @@ void TaskThicknessParameters::onSelectionChanged(const Gui::SelectionChanges& ms if (msg.Type == Gui::SelectionChanges::AddSelection) { if (referenceSelected(msg)) { - if (selectionMode == refAdd) { + // Clear selection. + Gui::Selection().clearSelection(); + + if (removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName)) { + // if there is only one item left, it cannot be deleted + if (ui->listWidgetReferences->count() == 1) { + deleteAction->setEnabled(false); + deleteAction->setStatusTip(tr("There must be at least one item")); + // we must also end the selection mode + exitSelectionMode(); + clearButtons(none); + } + } + else { ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName)); // it might be the second one so we can enable the context menu if (ui->listWidgetReferences->count() > 1) { deleteAction->setEnabled(true); deleteAction->setStatusTip(QString()); - ui->buttonRefRemove->setEnabled(true); - ui->buttonRefRemove->setToolTip(tr("Click button to enter selection mode,\nclick again to end selection")); - } - } - else { - removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName); - // remove its selection too - Gui::Selection().clearSelection(); - // if there is only one item left, it cannot be deleted - if (ui->listWidgetReferences->count() == 1) { - deleteAction->setEnabled(false); - deleteAction->setStatusTip(tr("There must be at least one item")); - ui->buttonRefRemove->setEnabled(false); - ui->buttonRefRemove->setToolTip(tr("There must be at least one item")); - // we must also end the selection mode - exitSelectionMode(); - clearButtons(none); } } // highlight existing references for possible further selections @@ -159,8 +153,7 @@ void TaskThicknessParameters::onSelectionChanged(const Gui::SelectionChanges& ms void TaskThicknessParameters::clearButtons(const selectionModes notThis) { - if (notThis != refAdd) ui->buttonRefAdd->setChecked(false); - if (notThis != refRemove) ui->buttonRefRemove->setChecked(false); + if (notThis != refSel) ui->buttonRefSel->setChecked(false); DressUpView->highlightReferences(false); } @@ -211,8 +204,6 @@ void TaskThicknessParameters::onRefDeleted(void) if (ui->listWidgetReferences->count() == 1) { deleteAction->setEnabled(false); deleteAction->setStatusTip(tr("There must be at least one item")); - ui->buttonRefRemove->setEnabled(false); - ui->buttonRefRemove->setToolTip(tr("There must be at least one item")); } } diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.ui b/src/Mod/PartDesign/Gui/TaskThicknessParameters.ui index 006076e68b..d7f332916b 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.ui @@ -15,36 +15,18 @@ - - - - - Click button to enter selection mode, + + + Click button to enter selection mode, click again to end selection - - - Add face - - - true - - - - - - - Click button to enter selection mode, -click again to end selection - - - Remove face - - - true - - - - + + + Select face + + + true + + From 47cc265b4f9353357fa5ac246acb841bfb6783a5 Mon Sep 17 00:00:00 2001 From: Paddle Date: Wed, 22 Mar 2023 15:25:31 +0100 Subject: [PATCH 2/6] PartDesign: Fillet, Chamfer, Draft, Thickness : Enable tool to start with no selection. --- src/Mod/PartDesign/App/FeatureChamfer.cpp | 13 +- src/Mod/PartDesign/App/FeatureDraft.cpp | 12 +- src/Mod/PartDesign/App/FeatureFillet.cpp | 12 +- src/Mod/PartDesign/App/FeatureThickness.cpp | 10 +- src/Mod/PartDesign/Gui/Command.cpp | 114 ++++++---- .../PartDesign/Gui/TaskChamferParameters.cpp | 95 ++------ .../PartDesign/Gui/TaskChamferParameters.h | 2 +- .../PartDesign/Gui/TaskChamferParameters.ui | 2 +- .../PartDesign/Gui/TaskDraftParameters.cpp | 100 ++------- src/Mod/PartDesign/Gui/TaskDraftParameters.h | 2 +- src/Mod/PartDesign/Gui/TaskDraftParameters.ui | 2 +- .../PartDesign/Gui/TaskDressUpParameters.cpp | 211 +++++++++--------- .../PartDesign/Gui/TaskDressUpParameters.h | 11 +- .../PartDesign/Gui/TaskFilletParameters.cpp | 93 ++------ src/Mod/PartDesign/Gui/TaskFilletParameters.h | 2 +- .../PartDesign/Gui/TaskFilletParameters.ui | 2 +- .../Gui/TaskThicknessParameters.cpp | 98 ++------ .../PartDesign/Gui/TaskThicknessParameters.h | 2 +- .../PartDesign/Gui/TaskThicknessParameters.ui | 2 +- 19 files changed, 288 insertions(+), 497 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureChamfer.cpp b/src/Mod/PartDesign/App/FeatureChamfer.cpp index 70a45c0fb9..9ca9025f6c 100644 --- a/src/Mod/PartDesign/App/FeatureChamfer.cpp +++ b/src/Mod/PartDesign/App/FeatureChamfer.cpp @@ -109,7 +109,8 @@ App::DocumentObjectExecReturn *Chamfer::execute() Part::TopoShape TopShape; try { TopShape = getBaseShape(); - } catch (Base::Exception& e) { + } + catch (Base::Exception& e) { return new App::DocumentObjectExecReturn(e.what()); } @@ -130,9 +131,6 @@ App::DocumentObjectExecReturn *Chamfer::execute() getContinuousEdges(TopShape, SubNames, FaceNames); - if (SubNames.empty()) - return new App::DocumentObjectExecReturn("No edges specified"); - const int chamferType = ChamferType.getValue(); const double size = Size.getValue(); const double size2 = Size2.getValue(); @@ -145,6 +143,13 @@ App::DocumentObjectExecReturn *Chamfer::execute() } this->positionByBaseFeature(); + + //If no element is selected, then we use a copy of previous feature. + if (SubNames.empty()) { + this->Shape.setValue(TopShape); + return App::DocumentObject::StdReturn; + } + // create an untransformed copy of the basefeature shape Part::TopoShape baseShape(TopShape); baseShape.setTransform(Base::Matrix4D()); diff --git a/src/Mod/PartDesign/App/FeatureDraft.cpp b/src/Mod/PartDesign/App/FeatureDraft.cpp index 4312309de8..ec33e96b98 100644 --- a/src/Mod/PartDesign/App/FeatureDraft.cpp +++ b/src/Mod/PartDesign/App/FeatureDraft.cpp @@ -102,15 +102,21 @@ App::DocumentObjectExecReturn *Draft::execute() Part::TopoShape TopShape; try { TopShape = getBaseShape(); - } catch (Base::Exception& e) { + } + catch (Base::Exception& e) { return new App::DocumentObjectExecReturn(e.what()); } // Faces where draft should be applied // Note: Cannot be const reference currently because of BRepOffsetAPI_DraftAngle::Remove() bug, see below std::vector SubVals = Base.getSubValuesStartsWith("Face"); - if (SubVals.empty()) - return new App::DocumentObjectExecReturn("No faces specified"); + + //If no element is selected, then we use a copy of previous feature. + if (SubVals.empty()) { + this->positionByBaseFeature(); + this->Shape.setValue(TopShape); + return App::DocumentObject::StdReturn; + } // Draft angle double angle = Base::toRadians(Angle.getValue()); diff --git a/src/Mod/PartDesign/App/FeatureFillet.cpp b/src/Mod/PartDesign/App/FeatureFillet.cpp index 70d5b6894f..9fa33963be 100644 --- a/src/Mod/PartDesign/App/FeatureFillet.cpp +++ b/src/Mod/PartDesign/App/FeatureFillet.cpp @@ -68,7 +68,8 @@ App::DocumentObjectExecReturn *Fillet::execute() Part::TopoShape TopShape; try { TopShape = getBaseShape(); - } catch (Base::Exception& e) { + } + catch (Base::Exception& e) { return new App::DocumentObjectExecReturn(e.what()); } std::vector SubNames = std::vector(Base.getSubValues()); @@ -86,9 +87,6 @@ App::DocumentObjectExecReturn *Fillet::execute() getContinuousEdges(TopShape, SubNames); - if (SubNames.empty()) - return new App::DocumentObjectExecReturn("Fillet not possible on selected shapes"); - double radius = Radius.getValue(); if(radius <= 0) @@ -96,6 +94,12 @@ App::DocumentObjectExecReturn *Fillet::execute() this->positionByBaseFeature(); + //If no element is selected, then we use a copy of previous feature. + if (SubNames.empty()) { + this->Shape.setValue(TopShape); + return App::DocumentObject::StdReturn; + } + // create an untransformed copy of the base shape Part::TopoShape baseShape(TopShape); baseShape.setTransform(Base::Matrix4D()); diff --git a/src/Mod/PartDesign/App/FeatureThickness.cpp b/src/Mod/PartDesign/App/FeatureThickness.cpp index c7cc2c51d0..2dbe7d76ef 100644 --- a/src/Mod/PartDesign/App/FeatureThickness.cpp +++ b/src/Mod/PartDesign/App/FeatureThickness.cpp @@ -72,8 +72,16 @@ App::DocumentObjectExecReturn *Thickness::execute() return new App::DocumentObjectExecReturn(e.what()); } - TopTools_ListOfShape closingFaces; const std::vector& subStrings = Base.getSubValues(); + + //If no element is selected, then we use a copy of previous feature. + if (subStrings.empty()) { + this->Shape.setValue(TopShape); + return App::DocumentObject::StdReturn; + } + + TopTools_ListOfShape closingFaces; + for (std::vector::const_iterator it = subStrings.begin(); it != subStrings.end(); ++it) { TopoDS_Face face = TopoDS::Face(TopShape.getSubShape(it->c_str())); closingFaces.Append(face); diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 1c9371cacf..9d05bf6633 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -1541,7 +1541,7 @@ bool CmdPartDesignSubtractiveHelix::isActive() //=========================================================================== bool dressupGetSelected(Gui::Command* cmd, const std::string& which, - Gui::SelectionObject &selected, bool &useAllEdges) + Gui::SelectionObject &selected, bool &useAllEdges, bool& noSelection) { // No PartDesign feature without Body past FreeCAD 0.16 App::Document *doc = cmd->getDocument(); @@ -1556,10 +1556,10 @@ bool dressupGetSelected(Gui::Command* cmd, const std::string& which, std::vector selection = cmd->getSelection().getSelectionEx(); if (selection.empty()) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Select an edge, face, or body.")); - return false; - } else if (selection.size() != 1) { + noSelection = true; + return true; + } + else if (selection.size() != 1) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select an edge, face, or body from a single body.")); return false; @@ -1615,12 +1615,6 @@ bool dressupGetSelected(Gui::Command* cmd, const std::string& which, void finishDressupFeature(const Gui::Command* cmd, const std::string& which, Part::Feature *base, const std::vector & SubNames, const bool useAllEdges) { - if (SubNames.empty()) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QString::fromStdString(which) + QObject::tr(" not possible on selected faces/edges.")); - return; - } - std::ostringstream str; str << '(' << Gui::Command::getObjectCmd(base) << ",["; for (std::vector::const_iterator it = SubNames.begin();it!=SubNames.end();++it){ @@ -1656,13 +1650,20 @@ void finishDressupFeature(const Gui::Command* cmd, const std::string& which, void makeChamferOrFillet(Gui::Command* cmd, const std::string& which) { bool useAllEdges = false; + bool noSelection = false; Gui::SelectionObject selected; - if (!dressupGetSelected ( cmd, which, selected, useAllEdges)) + if (!dressupGetSelected ( cmd, which, selected, useAllEdges, noSelection)) return; - Part::Feature *base = static_cast(selected.getObject()); - - std::vector SubNames = std::vector(selected.getSubNames()); + Part::Feature *base; + std::vector SubNames; + if (noSelection) { + base = static_cast(PartDesignGui::getBody(true)->Tip.getValue()); + } + else { + base = static_cast(selected.getObject()); + SubNames = std::vector(selected.getSubNames()); + } finishDressupFeature (cmd, which, base, SubNames, useAllEdges); } @@ -1746,31 +1747,41 @@ void CmdPartDesignDraft::activated(int iMsg) Q_UNUSED(iMsg); Gui::SelectionObject selected; bool useAllEdges = false; - if (!dressupGetSelected ( this, "Draft", selected, useAllEdges)) + bool noSelection = false; + if (!dressupGetSelected ( this, "Draft", selected, useAllEdges, noSelection)) return; - Part::Feature *base = static_cast(selected.getObject()); - std::vector SubNames = std::vector(selected.getSubNames()); - const Part::TopoShape& TopShape = base->Shape.getShape(); - size_t i = 0; + Part::Feature* base; + std::vector SubNames; + if (noSelection) { + base = static_cast(PartDesignGui::getBody(true)->Tip.getValue()); + } + else { + base = static_cast(selected.getObject()); + SubNames = std::vector(selected.getSubNames()); - // filter out the edges - while(i < SubNames.size()) - { - std::string aSubName = static_cast(SubNames.at(i)); + const Part::TopoShape& TopShape = base->Shape.getShape(); - if (aSubName.compare(0, 4, "Face") == 0) { - // Check for valid face types - TopoDS_Face face = TopoDS::Face(TopShape.getSubShape(aSubName.c_str())); - BRepAdaptor_Surface sf(face); - if ((sf.GetType() != GeomAbs_Plane) && (sf.GetType() != GeomAbs_Cylinder) && (sf.GetType() != GeomAbs_Cone)) - SubNames.erase(SubNames.begin()+i); - } else { - // empty name or any other sub-element - SubNames.erase(SubNames.begin()+i); + // filter out the edges + size_t i = 0; + while (i < SubNames.size()) + { + std::string aSubName = static_cast(SubNames.at(i)); + + if (aSubName.compare(0, 4, "Face") == 0) { + // Check for valid face types + TopoDS_Face face = TopoDS::Face(TopShape.getSubShape(aSubName.c_str())); + BRepAdaptor_Surface sf(face); + if ((sf.GetType() != GeomAbs_Plane) && (sf.GetType() != GeomAbs_Cylinder) && (sf.GetType() != GeomAbs_Cone)) + SubNames.erase(SubNames.begin() + i); + } + else { + // empty name or any other sub-element + SubNames.erase(SubNames.begin() + i); + } + + i++; } - - i++; } finishDressupFeature (this, "Draft", base, SubNames, useAllEdges); @@ -1804,23 +1815,32 @@ void CmdPartDesignThickness::activated(int iMsg) Q_UNUSED(iMsg); Gui::SelectionObject selected; bool useAllEdges = false; - if (!dressupGetSelected ( this, "Thickness", selected, useAllEdges)) + bool noSelection = false; + if (!dressupGetSelected ( this, "Thickness", selected, useAllEdges, noSelection)) return; - Part::Feature *base = static_cast(selected.getObject()); - std::vector SubNames = std::vector(selected.getSubNames()); - size_t i = 0; - // filter out the edges - while(i < SubNames.size()) - { - std::string aSubName = static_cast(SubNames.at(i)); + Part::Feature* base; + std::vector SubNames; + if (noSelection) { + base = static_cast(PartDesignGui::getBody(true)->Tip.getValue()); + } + else { + base = static_cast(selected.getObject()); + SubNames = std::vector(selected.getSubNames()); - if (aSubName.compare(0, 4, "Face") != 0) { - // empty name or any other sub-element - SubNames.erase(SubNames.begin()+i); + // filter out the edges + size_t i = 0; + while (i < SubNames.size()) + { + std::string aSubName = static_cast(SubNames.at(i)); + + if (aSubName.compare(0, 4, "Face") != 0) { + // empty name or any other sub-element + SubNames.erase(SubNames.begin() + i); + } + i++; } - i++; } finishDressupFeature (this, "Thickness", base, SubNames, useAllEdges); diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp index 0cf07fb19d..ed085a6c72 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp @@ -103,8 +103,10 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView, Q connect(ui->listWidgetReferences, &QListWidget::itemDoubleClicked, this, &TaskChamferParameters::doubleClicked); - // the dialog can be called on a broken chamfer, then hide the chamfer - hideOnError(); + if (strings.size() == 0) + setSelectionMode(refSel); + else + hideOnError(); } void TaskChamferParameters::setUpUI(PartDesign::Chamfer* pcChamfer) @@ -152,40 +154,17 @@ void TaskChamferParameters::onSelectionChanged(const Gui::SelectionChanges& msg) // executed when the user selected something in the CAD object // adds/deletes the selection accordingly - if (selectionMode == none) - return; - if (msg.Type == Gui::SelectionChanges::AddSelection) { - if (referenceSelected(msg)) { - // Clear selection. - Gui::Selection().clearSelection(); - - if (removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName)) { - // if there is only one item left, it cannot be deleted - if (ui->listWidgetReferences->count() == 1) { - deleteAction->setEnabled(false); - deleteAction->setStatusTip(tr("There must be at least one item")); - // we must also end the selection mode - exitSelectionMode(); - clearButtons(none); - } - } - else { - ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName)); - // it might be the second one so we can enable the context menu - if (ui->listWidgetReferences->count() > 1) { - deleteAction->setEnabled(true); - deleteAction->setStatusTip(QString()); - } - } - // highlight existing references for possible further selections - DressUpView->highlightReferences(true); + if (selectionMode == refSel) { + referenceSelected(msg, ui->listWidgetReferences); } } } void TaskChamferParameters::onCheckBoxUseAllEdgesToggled(bool checked) { + if(checked) + setSelectionMode(none); PartDesign::Chamfer* pcChamfer = static_cast(DressUpView->getObject()); ui->buttonRefSel->setEnabled(!checked); ui->listWidgetReferences->setEnabled(!checked); @@ -193,60 +172,15 @@ void TaskChamferParameters::onCheckBoxUseAllEdgesToggled(bool checked) pcChamfer->getDocument()->recomputeFeature(pcChamfer); } -void TaskChamferParameters::clearButtons(const selectionModes notThis) +void TaskChamferParameters::setButtons(const selectionModes mode) { - if (notThis != refSel) ui->buttonRefSel->setChecked(false); - DressUpView->highlightReferences(false); + ui->buttonRefSel->setChecked(mode == refSel); + ui->buttonRefSel->setText(mode == refSel ? tr("End selection") : tr("Start selection")); } void TaskChamferParameters::onRefDeleted() { - // assure we we are not in selection mode - exitSelectionMode(); - clearButtons(none); - // delete any selections since the reference(s) might be highlighted - Gui::Selection().clearSelection(); - DressUpView->highlightReferences(false); - - // get the list of items to be deleted - QList selectedList = ui->listWidgetReferences->selectedItems(); - - // if all items are selected, we must stop because one must be kept to avoid that the feature gets broken - if (selectedList.count() == ui->listWidgetReferences->model()->rowCount()) { - QMessageBox::warning(this, tr("Selection error"), tr("At least one item must be kept.")); - return; - } - - // get the chamfer object - PartDesign::Chamfer* pcChamfer = static_cast(DressUpView->getObject()); - App::DocumentObject* base = pcChamfer->Base.getValue(); - // get all chamfer references - std::vector refs = pcChamfer->Base.getSubValues(); - setupTransaction(); - - // delete the selection backwards to assure the list index keeps valid for the deletion - for (int i = selectedList.count() - 1; i > -1; i--) { - // the ref index is the same as the listWidgetReferences index - // so we can erase using the row number of the element to be deleted - int rowNumber = ui->listWidgetReferences->row(selectedList.at(i)); - // erase the reference - refs.erase(refs.begin() + rowNumber); - // remove from the list - ui->listWidgetReferences->model()->removeRow(rowNumber); - } - - // update the object - 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) { - deleteAction->setEnabled(false); - deleteAction->setStatusTip(tr("There must be at least one item")); - } + TaskDressUpParameters::deleteRef(ui->listWidgetReferences); } void TaskChamferParameters::onAddAllEdges() @@ -256,6 +190,7 @@ void TaskChamferParameters::onAddAllEdges() void TaskChamferParameters::onTypeChanged(int index) { + setSelectionMode(none); PartDesign::Chamfer* pcChamfer = static_cast(DressUpView->getObject()); pcChamfer->ChamferType.setValue(index); ui->stackedWidget->setCurrentIndex(index); @@ -267,6 +202,7 @@ void TaskChamferParameters::onTypeChanged(int index) void TaskChamferParameters::onSizeChanged(double len) { + setSelectionMode(none); PartDesign::Chamfer* pcChamfer = static_cast(DressUpView->getObject()); setupTransaction(); pcChamfer->Size.setValue(len); @@ -277,6 +213,7 @@ void TaskChamferParameters::onSizeChanged(double len) void TaskChamferParameters::onSize2Changed(double len) { + setSelectionMode(none); PartDesign::Chamfer* pcChamfer = static_cast(DressUpView->getObject()); setupTransaction(); pcChamfer->Size2.setValue(len); @@ -287,6 +224,7 @@ void TaskChamferParameters::onSize2Changed(double len) void TaskChamferParameters::onAngleChanged(double angle) { + setSelectionMode(none); PartDesign::Chamfer* pcChamfer = static_cast(DressUpView->getObject()); setupTransaction(); pcChamfer->Angle.setValue(angle); @@ -297,6 +235,7 @@ void TaskChamferParameters::onAngleChanged(double angle) void TaskChamferParameters::onFlipDirection(bool flip) { + setSelectionMode(none); PartDesign::Chamfer* pcChamfer = static_cast(DressUpView->getObject()); setupTransaction(); pcChamfer->FlipDirection.setValue(flip); diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.h b/src/Mod/PartDesign/Gui/TaskChamferParameters.h index 442401da80..41b8b10e76 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.h +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.h @@ -55,7 +55,7 @@ private Q_SLOTS: void onCheckBoxUseAllEdgesToggled(bool checked); protected: - void clearButtons(const selectionModes notThis) override; + void setButtons(const selectionModes mode) override; bool event(QEvent *e) override; void changeEvent(QEvent *e) override; void onSelectionChanged(const Gui::SelectionChanges& msg) override; diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.ui b/src/Mod/PartDesign/Gui/TaskChamferParameters.ui index aff84ea890..2d613143cd 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.ui @@ -21,7 +21,7 @@ click again to end selection - Select + Enter selection true diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp index 209c0df4af..0dde2ca0fb 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp @@ -111,8 +111,10 @@ TaskDraftParameters::TaskDraftParameters(ViewProviderDressUp *DressUpView, QWidg strings = pcDraft->PullDirection.getSubValues(); ui->lineLine->setText(getRefStr(ref, strings)); - // the dialog can be called on a broken draft, then hide the draft - hideOnError(); + if (strings.size() == 0) + setSelectionMode(refSel); + else + hideOnError(); } void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg) @@ -120,34 +122,9 @@ void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg) // executed when the user selected something in the CAD object // adds/deletes the selection accordingly - if (selectionMode == none) - return; - if (msg.Type == Gui::SelectionChanges::AddSelection) { - if (referenceSelected(msg)) { - // Clear selection. - Gui::Selection().clearSelection(); - - if (removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName)) { - // if there is only one item left, it cannot be deleted - if (ui->listWidgetReferences->count() == 1) { - deleteAction->setEnabled(false); - deleteAction->setStatusTip(tr("There must be at least one item")); - // we must also end the selection mode - exitSelectionMode(); - clearButtons(none); - } - } - else { - ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName)); - // it might be the second one so we can enable the context menu - if (ui->listWidgetReferences->count() > 1) { - deleteAction->setEnabled(true); - deleteAction->setStatusTip(QString()); - } - } - // highlight existing references for possible further selections - DressUpView->highlightReferences(true); + if (selectionMode == refSel) { + referenceSelected(msg, ui->listWidgetReferences); } else if (selectionMode == plane) { PartDesign::Draft* pcDraft = static_cast(DressUpView->getObject()); @@ -186,18 +163,18 @@ void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg) } } -void TaskDraftParameters::clearButtons(const selectionModes notThis) +void TaskDraftParameters::setButtons(const selectionModes mode) { - if (notThis != refSel) ui->buttonRefSel->setChecked(false); - if (notThis != line) ui->buttonLine->setChecked(false); - if (notThis != plane) ui->buttonPlane->setChecked(false); - DressUpView->highlightReferences(false); + ui->buttonRefSel->setText(mode == refSel ? tr("End selection") : tr("Start selection")); + ui->buttonRefSel->setChecked(mode == refSel); + ui->buttonLine->setChecked(mode == line); + ui->buttonPlane->setChecked(mode == plane); } void TaskDraftParameters::onButtonPlane(bool checked) { if (checked) { - clearButtons(plane); + setButtons(plane); hideObject(); selectionMode = plane; Gui::Selection().clearSelection(); @@ -210,7 +187,7 @@ void TaskDraftParameters::onButtonPlane(bool checked) void TaskDraftParameters::onButtonLine(bool checked) { if (checked) { - clearButtons(line); + setButtons(line); hideObject(); selectionMode = line; Gui::Selection().clearSelection(); @@ -221,52 +198,7 @@ void TaskDraftParameters::onButtonLine(bool checked) void TaskDraftParameters::onRefDeleted(void) { - // assure we we are not in selection mode - exitSelectionMode(); - clearButtons(none); - // delete any selections since the reference(s) might be highlighted - Gui::Selection().clearSelection(); - DressUpView->highlightReferences(false); - - // get the list of items to be deleted - QList selectedList = ui->listWidgetReferences->selectedItems(); - - // if all items are selected, we must stop because one must be kept to avoid that the feature gets broken - if (selectedList.count() == ui->listWidgetReferences->model()->rowCount()) { - QMessageBox::warning(this, tr("Selection error"), tr("At least one item must be kept.")); - return; - } - - // get the draft object - PartDesign::Draft* pcDraft = static_cast(DressUpView->getObject()); - App::DocumentObject* base = pcDraft->Base.getValue(); - // get all draft references - std::vector refs = pcDraft->Base.getSubValues(); - setupTransaction(); - - // delete the selection backwards to assure the list index keeps valid for the deletion - for (int i = selectedList.count() - 1; i > -1; i--) { - // the ref index is the same as the listWidgetReferences index - // so we can erase using the row number of the element to be deleted - int rowNumber = ui->listWidgetReferences->row(selectedList.at(i)); - // erase the reference - refs.erase(refs.begin() + rowNumber); - // remove from the list - ui->listWidgetReferences->model()->removeRow(rowNumber); - } - - // update the object - 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) { - deleteAction->setEnabled(false); - deleteAction->setStatusTip(tr("There must be at least one item")); - } + TaskDressUpParameters::deleteRef(ui->listWidgetReferences); } void TaskDraftParameters::getPlane(App::DocumentObject*& obj, std::vector& sub) const @@ -289,7 +221,7 @@ void TaskDraftParameters::getLine(App::DocumentObject*& obj, std::vector(DressUpView->getObject()); setupTransaction(); pcDraft->Angle.setValue(angle); @@ -304,7 +236,7 @@ double TaskDraftParameters::getAngle(void) const } void TaskDraftParameters::onReversedChanged(const bool on) { - clearButtons(none); + setButtons(none); PartDesign::Draft* pcDraft = static_cast(DressUpView->getObject()); setupTransaction(); pcDraft->Reversed.setValue(on); diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.h b/src/Mod/PartDesign/Gui/TaskDraftParameters.h index b2024e9376..cdd9270a86 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.h +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.h @@ -54,7 +54,7 @@ private Q_SLOTS: void onRefDeleted() override; protected: - void clearButtons(const selectionModes notThis) override; + void setButtons(const selectionModes mode) override; bool event(QEvent *e) override; void changeEvent(QEvent *e) override; void onSelectionChanged(const Gui::SelectionChanges& msg) override; diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.ui b/src/Mod/PartDesign/Gui/TaskDraftParameters.ui index ca30e850ae..4e3de180e6 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.ui @@ -22,7 +22,7 @@ click again to end selection - Select face + Enter selection true diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp index ef5cbc36fb..6406fe75dc 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp @@ -41,7 +41,6 @@ #include #include #include -#include #include #include "TaskDressUpParameters.h" @@ -95,96 +94,102 @@ void TaskDressUpParameters::setupTransaction() transactionID = App::GetApplication().setActiveTransaction(n.c_str()); } -bool TaskDressUpParameters::referenceSelected(const Gui::SelectionChanges& msg) +void TaskDressUpParameters::referenceSelected(const Gui::SelectionChanges& msg, QListWidget* widget) { - if ((msg.Type == Gui::SelectionChanges::AddSelection) && (selectionMode == refSel)) { + if (strcmp(msg.pDocName, DressUpView->getObject()->getDocument()->getName()) != 0) + return; - if (strcmp(msg.pDocName, DressUpView->getObject()->getDocument()->getName()) != 0) - return false; + Gui::Selection().clearSelection(); - PartDesign::DressUp* pcDressUp = static_cast(DressUpView->getObject()); - App::DocumentObject* base = this->getBase(); + PartDesign::DressUp* pcDressUp = static_cast(DressUpView->getObject()); + App::DocumentObject* base = this->getBase(); - // TODO: Must we make a copy here instead of assigning to const char* ? - const char* fname = base->getNameInDocument(); - if (strcmp(msg.pObjectName, fname) != 0) - return false; + // TODO: Must we make a copy here instead of assigning to const char* ? + const char* fname = base->getNameInDocument(); + if (strcmp(msg.pObjectName, fname) != 0) + return; - std::string subName(msg.pSubName); - std::vector refs = pcDressUp->Base.getSubValues(); - std::vector::iterator f = std::find(refs.begin(), refs.end(), subName); + std::string subName(msg.pSubName); + std::vector refs = pcDressUp->Base.getSubValues(); + std::vector::iterator f = std::find(refs.begin(), refs.end(), subName); - if (f != refs.end()) - refs.erase(f); - else - refs.push_back(subName); - - DressUpView->highlightReferences(false); - setupTransaction(); - pcDressUp->Base.setValue(base, refs); - pcDressUp->getDocument()->recomputeFeature(pcDressUp); - - return true; + if (f != refs.end()) { //If it's found then it's in the list so we remove it. + refs.erase(f); + removeItemFromListWidget(widget, msg.pSubName); + } + else { //if it's not found then it's not yet in the list so we add it. + refs.push_back(subName); + widget->addItem(QString::fromStdString(msg.pSubName)); } - return false; + updateFeature(pcDressUp, refs); } void TaskDressUpParameters::addAllEdges(QListWidget* widget) { PartDesign::DressUp* pcDressUp = static_cast(DressUpView->getObject()); - if (pcDressUp) { - App::DocumentObject* base = pcDressUp->Base.getValue(); - if (base) { - Gui::WaitCursor wait; - int count = pcDressUp->getBaseTopoShape().countSubElements("Edge"); - std::vector edgeNames; - for (int ii = 0; ii < count; ii++){ - std::ostringstream edgeName; - edgeName << "Edge" << ii+1; - edgeNames.push_back(edgeName.str()); - } - for (std::vector::const_iterator it = edgeNames.begin(); it != edgeNames.end(); ++it){ - if (widget->findItems(QLatin1String(it->c_str()), Qt::MatchExactly).isEmpty()){ - widget->addItem(QLatin1String(it->c_str())); - } - } - - pcDressUp->Base.setValue(base, edgeNames); - pcDressUp->getDocument()->recomputeFeature(pcDressUp); - hideObject(); - DressUpView->highlightReferences(true); - onButtonRefSel(true); - - if (deleteAction) { - deleteAction->setEnabled(widget->count() > 1); - } - } + Gui::WaitCursor wait; + int count = pcDressUp->getBaseTopoShape().countSubElements("Edge"); + std::vector edgeNames; + for (int ii = 0; ii < count; ii++){ + std::ostringstream edgeName; + edgeName << "Edge" << ii+1; + edgeNames.push_back(edgeName.str()); } + + //First we need to clear the widget in case the user had faces selected. Else the faces will still be in widget but not in the feature refs! + QSignalBlocker block(widget); + widget->clear(); + + for (std::vector::const_iterator it = edgeNames.begin(); it != edgeNames.end(); ++it){ + widget->addItem(QLatin1String(it->c_str())); + } + + updateFeature(pcDressUp, edgeNames); +} + +void TaskDressUpParameters::deleteRef(QListWidget* widget) +{ + // delete any selections since the reference(s) being deleted might be highlighted + Gui::Selection().clearSelection(); + + // get the list of items to be deleted + QList selectedList = widget->selectedItems(); + + PartDesign::DressUp* pcDressUp = static_cast(DressUpView->getObject()); + std::vector refs = pcDressUp->Base.getSubValues(); + + // delete the selection backwards to assure the list index keeps valid for the deletion + QSignalBlocker block(widget); + for (int i = selectedList.count() - 1; i > -1; i--) { + // the ref index is the same as the listWidgetReferences index + // so we can erase using the row number of the element to be deleted + int rowNumber = widget->row(selectedList.at(i)); + refs.erase(refs.begin() + rowNumber); + widget->model()->removeRow(rowNumber); + } + + updateFeature(pcDressUp, refs); +} + +void TaskDressUpParameters::updateFeature(PartDesign::DressUp* pcDressUp, const std::vector& refs) +{ + if (selectionMode == refSel) + DressUpView->highlightReferences(false); + + setupTransaction(); + pcDressUp->Base.setValue(pcDressUp->Base.getValue(), refs); + pcDressUp->recomputeFeature(); + if (selectionMode == refSel) + DressUpView->highlightReferences(true); + else + hideOnError(); } void TaskDressUpParameters::onButtonRefSel(bool checked) { - if (checked) { - clearButtons(refSel); - hideObject(); - selectionMode = refSel; - if (addAllEdgesAction) - addAllEdgesAction->setEnabled(true); - AllowSelectionFlags allow; - allow.setFlag(AllowSelection::EDGE, allowEdges); - allow.setFlag(AllowSelection::FACE, allowFaces); - Gui::Selection().clearSelection(); - Gui::Selection().addSelectionGate(new ReferenceSelection(this->getBase(), allow)); - DressUpView->highlightReferences(true); - } - else { - if (addAllEdgesAction) - addAllEdgesAction->setEnabled(false); - exitSelectionMode(); - DressUpView->highlightReferences(false); - } + setSelectionMode(checked ? refSel : none); } void TaskDressUpParameters::doubleClicked(QListWidgetItem* item) { @@ -195,14 +200,7 @@ void TaskDressUpParameters::doubleClicked(QListWidgetItem* item) { wasDoubleClicked = true; // assure we are not in selection mode - exitSelectionMode(); - clearButtons(none); - - // assure the fillets are shown - showObject(); - // remove any highlights and selections - DressUpView->highlightReferences(false); - Gui::Selection().clearSelection(); + setSelectionMode(none); // enable next possible single-click event after double-click time passed QTimer::singleShot(QApplication::doubleClickInterval(), this, &TaskDressUpParameters::itemClickedTimeout); @@ -225,15 +223,16 @@ void TaskDressUpParameters::setSelection(QListWidgetItem* current) { if (body) { std::string objName = body->getNameInDocument(); - // hide fillet to see the original edge - // (a fillet creates new edges so that the original one is not available) - hideObject(); - // highlight all objects in the list - DressUpView->highlightReferences(true); - // clear existing selection because only the current item is highlighted, not all selected ones to keep the overview - Gui::Selection().clearSelection(); + // Enter selection mode + if (selectionMode == none) + setSelectionMode(refSel); + else + Gui::Selection().clearSelection(); + // highlight the selected item + bool block = this->blockSelection(true); Gui::Selection().addSelection(docName.c_str(), objName.c_str(), subName.c_str(), 0, 0, 0); + this->blockSelection(block); } } } @@ -254,12 +253,10 @@ void TaskDressUpParameters::createAddAllEdgesAction(QListWidget* parentList) addAllEdgesAction->setShortcutVisibleInContextMenu(true); #endif parentList->addAction(addAllEdgesAction); - addAllEdgesAction->setEnabled(false); addAllEdgesAction->setStatusTip(tr("Adds all edges to the list box (active only when in add selection mode).")); parentList->setContextMenuPolicy(Qt::ActionsContextMenu); } - void TaskDressUpParameters::createDeleteAction(QListWidget* parentList) { // creates a context menu, a shortcut for it and connects it to a slot function @@ -271,11 +268,6 @@ void TaskDressUpParameters::createDeleteAction(QListWidget* parentList) deleteAction->setShortcutVisibleInContextMenu(true); #endif parentList->addAction(deleteAction); - // if there is only one item, it cannot be deleted - if (parentList->count() == 1) { - deleteAction->setEnabled(false); - deleteAction->setStatusTip(tr("There must be at least one item")); - } parentList->setContextMenuPolicy(Qt::ActionsContextMenu); } @@ -319,7 +311,7 @@ const std::vector TaskDressUpParameters::getReferences() const } // TODO: This code is identical with TaskTransformedParameters::removeItemFromListWidget() -bool TaskDressUpParameters::removeItemFromListWidget(QListWidget* widget, const char* itemstr) +void TaskDressUpParameters::removeItemFromListWidget(QListWidget* widget, const char* itemstr) { QList items = widget->findItems(QString::fromLatin1(itemstr), Qt::MatchExactly); if (!items.empty()) { @@ -327,9 +319,7 @@ bool TaskDressUpParameters::removeItemFromListWidget(QListWidget* widget, const QListWidgetItem* it = widget->takeItem(widget->row(*i)); delete it; } - return true; } - return false; } void TaskDressUpParameters::hideOnError() @@ -369,12 +359,31 @@ Part::Feature* TaskDressUpParameters::getBase(void) const return pcDressUp->getBaseObject(); } -void TaskDressUpParameters::exitSelectionMode() +void TaskDressUpParameters::setSelectionMode(selectionModes mode) { - selectionMode = none; - Gui::Selection().rmvSelectionGate(); + selectionMode = mode; + setButtons(mode); + + if (mode == none) { + showObject(); + + Gui::Selection().rmvSelectionGate(); + + // remove any highlights and selections + DressUpView->highlightReferences(false); + } + else { + hideObject(); + + AllowSelectionFlags allow; + allow.setFlag(AllowSelection::EDGE, allowEdges); + allow.setFlag(AllowSelection::FACE, allowFaces); + Gui::Selection().addSelectionGate(new ReferenceSelection(this->getBase(), allow)); + + DressUpView->highlightReferences(true); + } + Gui::Selection().clearSelection(); - showObject(); } //************************************************************************** diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.h b/src/Mod/PartDesign/Gui/TaskDressUpParameters.h index a6a9181978..4a8524b0c9 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.h +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.h @@ -25,6 +25,7 @@ #define GUI_TASKVIEW_TaskDressUpParameters_H #include +#include #include "TaskFeatureParameters.h" #include "ViewProviderDressUp.h" @@ -72,17 +73,19 @@ protected Q_SLOTS: void createAddAllEdgesAction(QListWidget* parentList); protected: - void exitSelectionMode(); - bool referenceSelected(const Gui::SelectionChanges& msg); + void referenceSelected(const Gui::SelectionChanges& msg, QListWidget* widget); bool wasDoubleClicked = false; bool KeyEvent(QEvent *e); void hideOnError(); void addAllEdges(QListWidget* listWidget); + void deleteRef(QListWidget* listWidget); + void updateFeature(PartDesign::DressUp* pcDressUp, const std::vector& refs); protected: enum selectionModes { none, refSel, plane, line }; - virtual void clearButtons(const selectionModes notThis) = 0; - static bool removeItemFromListWidget(QListWidget* widget, const char* itemstr); + void setSelectionMode(selectionModes mode); + virtual void setButtons(const selectionModes mode) = 0; + static void removeItemFromListWidget(QListWidget* widget, const char* itemstr); ViewProviderDressUp* getDressUpView() const { return DressUpView; } diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp index 97feb14290..6130a0619b 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp @@ -52,7 +52,6 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView, QWi // we need a separate container widget to add all controls to proxy = new QWidget(this); ui->setupUi(proxy); - this->groupLayout()->addWidget(proxy); PartDesign::Fillet* pcFillet = static_cast(DressUpView->getObject()); @@ -97,8 +96,10 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView, QWi connect(ui->listWidgetReferences, &QListWidget::itemDoubleClicked, this, &TaskFilletParameters::doubleClicked); - // the dialog can be called on a broken fillet, then hide the fillet - hideOnError(); + if (strings.size() == 0) + setSelectionMode(refSel); + else + hideOnError(); } void TaskFilletParameters::onSelectionChanged(const Gui::SelectionChanges& msg) @@ -106,40 +107,17 @@ void TaskFilletParameters::onSelectionChanged(const Gui::SelectionChanges& msg) // executed when the user selected something in the CAD object // adds/deletes the selection accordingly - if (selectionMode == none) - return; - if (msg.Type == Gui::SelectionChanges::AddSelection) { - if (referenceSelected(msg)) { - // Clear selection. - Gui::Selection().clearSelection(); - - if (removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName)) { - // if there is only one item left, it cannot be deleted - if (ui->listWidgetReferences->count() == 1) { - deleteAction->setEnabled(false); - deleteAction->setStatusTip(tr("There must be at least one item")); - // we must also end the selection mode - exitSelectionMode(); - clearButtons(none); - } - } - else { - ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName)); - // it might be the second one so we can enable the context menu - if (ui->listWidgetReferences->count() > 1) { - deleteAction->setEnabled(true); - deleteAction->setStatusTip(QString()); - } - } - // highlight existing references for possible further selections - DressUpView->highlightReferences(true); + if (selectionMode == refSel) { + referenceSelected(msg, ui->listWidgetReferences); } } } void TaskFilletParameters::onCheckBoxUseAllEdgesToggled(bool checked) { + if (checked) + setSelectionMode(none); PartDesign::Fillet* pcFillet = static_cast(DressUpView->getObject()); ui->buttonRefSel->setEnabled(!checked); ui->listWidgetReferences->setEnabled(!checked); @@ -147,60 +125,15 @@ void TaskFilletParameters::onCheckBoxUseAllEdgesToggled(bool checked) pcFillet->getDocument()->recomputeFeature(pcFillet); } -void TaskFilletParameters::clearButtons(const selectionModes notThis) +void TaskFilletParameters::setButtons(const selectionModes mode) { - if (notThis != refSel) ui->buttonRefSel->setChecked(false); - DressUpView->highlightReferences(false); + ui->buttonRefSel->setChecked(mode == refSel); + ui->buttonRefSel->setText(mode == refSel ? tr("End selection") : tr("Start selection")); } void TaskFilletParameters::onRefDeleted() { - // assure we we are not in selection mode - exitSelectionMode(); - clearButtons(none); - // delete any selections since the reference(s) might be highlighted - Gui::Selection().clearSelection(); - DressUpView->highlightReferences(false); - - // get the list of items to be deleted - QList selectedList = ui->listWidgetReferences->selectedItems(); - - // if all items are selected, we must stop because one must be kept to avoid that the feature gets broken - if (selectedList.count() == ui->listWidgetReferences->model()->rowCount()){ - QMessageBox::warning(this, tr("Selection error"), tr("At least one item must be kept.")); - return; - } - - // get the fillet object - PartDesign::Fillet* pcFillet = static_cast(DressUpView->getObject()); - App::DocumentObject* base = pcFillet->Base.getValue(); - // get all fillet references - std::vector refs = pcFillet->Base.getSubValues(); - setupTransaction(); - - // delete the selection backwards to assure the list index keeps valid for the deletion - for (int i = selectedList.count()-1; i > -1; i--) { - // the ref index is the same as the listWidgetReferences index - // so we can erase using the row number of the element to be deleted - int rowNumber = ui->listWidgetReferences->row(selectedList.at(i)); - // erase the reference - refs.erase(refs.begin() + rowNumber); - // remove from the list - ui->listWidgetReferences->model()->removeRow(rowNumber); - } - - // update the object - 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) { - deleteAction->setEnabled(false); - deleteAction->setStatusTip(tr("There must be at least one item")); - } + TaskDressUpParameters::deleteRef(ui->listWidgetReferences); } void TaskFilletParameters::onAddAllEdges() @@ -210,7 +143,7 @@ void TaskFilletParameters::onAddAllEdges() void TaskFilletParameters::onLengthChanged(double len) { - clearButtons(none); + setSelectionMode(none); PartDesign::Fillet* pcFillet = static_cast(DressUpView->getObject()); setupTransaction(); pcFillet->Radius.setValue(len); diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.h b/src/Mod/PartDesign/Gui/TaskFilletParameters.h index 37a1ffb977..d5142d3f8a 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.h +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.h @@ -49,7 +49,7 @@ private Q_SLOTS: protected: double getLength() const; - void clearButtons(const selectionModes notThis) override; + void setButtons(const selectionModes mode) override; bool event(QEvent *e) override; void changeEvent(QEvent *e) override; void onSelectionChanged(const Gui::SelectionChanges& msg) override; diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.ui b/src/Mod/PartDesign/Gui/TaskFilletParameters.ui index 8b6fb663ff..06c250615d 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.ui @@ -21,7 +21,7 @@ click again to end selection - Select + Enter selection true diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp index 5508fa2bf1..6ec5e319fd 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp @@ -110,8 +110,10 @@ 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(); + if (strings.size() == 0) + setSelectionMode(refSel); + else + hideOnError(); } void TaskThicknessParameters::onSelectionChanged(const Gui::SelectionChanges& msg) @@ -119,97 +121,27 @@ void TaskThicknessParameters::onSelectionChanged(const Gui::SelectionChanges& ms // executed when the user selected something in the CAD object // adds/deletes the selection accordingly - if (selectionMode == none) - return; - if (msg.Type == Gui::SelectionChanges::AddSelection) { - if (referenceSelected(msg)) { - // Clear selection. - Gui::Selection().clearSelection(); - - if (removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName)) { - // if there is only one item left, it cannot be deleted - if (ui->listWidgetReferences->count() == 1) { - deleteAction->setEnabled(false); - deleteAction->setStatusTip(tr("There must be at least one item")); - // we must also end the selection mode - exitSelectionMode(); - clearButtons(none); - } - } - else { - ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName)); - // it might be the second one so we can enable the context menu - if (ui->listWidgetReferences->count() > 1) { - deleteAction->setEnabled(true); - deleteAction->setStatusTip(QString()); - } - } - // highlight existing references for possible further selections - DressUpView->highlightReferences(true); + if (selectionMode == refSel) { + referenceSelected(msg, ui->listWidgetReferences); } } } -void TaskThicknessParameters::clearButtons(const selectionModes notThis) +void TaskThicknessParameters::setButtons(const selectionModes mode) { - if (notThis != refSel) ui->buttonRefSel->setChecked(false); - DressUpView->highlightReferences(false); + ui->buttonRefSel->setChecked(mode == refSel); + ui->buttonRefSel->setText(mode == refSel ? tr("End selection") : tr("Start selection")); } void TaskThicknessParameters::onRefDeleted(void) { - // assure we we are not in selection mode - exitSelectionMode(); - clearButtons(none); - // delete any selections since the reference(s) might be highlighted - Gui::Selection().clearSelection(); - DressUpView->highlightReferences(false); - - // get the list of items to be deleted - QList selectedList = ui->listWidgetReferences->selectedItems(); - - // if all items are selected, we must stop because one must be kept to avoid that the feature gets broken - if (selectedList.count() == ui->listWidgetReferences->model()->rowCount()) { - QMessageBox::warning(this, tr("Selection error"), tr("At least one item must be kept.")); - return; - } - - // get the thickness object - PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); - App::DocumentObject* base = pcThickness->Base.getValue(); - // get all thickness references - std::vector refs = pcThickness->Base.getSubValues(); - setupTransaction(); - - // delete the selection backwards to assure the list index keeps valid for the deletion - for (int i = selectedList.count() - 1; i > -1; i--) { - // the ref index is the same as the listWidgetReferences index - // so we can erase using the row number of the element to be deleted - int rowNumber = ui->listWidgetReferences->row(selectedList.at(i)); - // erase the reference - refs.erase(refs.begin() + rowNumber); - // remove from the list - ui->listWidgetReferences->model()->removeRow(rowNumber); - } - - // update the object - 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) { - deleteAction->setEnabled(false); - deleteAction->setStatusTip(tr("There must be at least one item")); - } + TaskDressUpParameters::deleteRef(ui->listWidgetReferences); } void TaskThicknessParameters::onValueChanged(double angle) { - clearButtons(none); + setButtons(none); PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); setupTransaction(); pcThickness->Value.setValue(angle); @@ -220,7 +152,7 @@ void TaskThicknessParameters::onValueChanged(double angle) void TaskThicknessParameters::onJoinTypeChanged(int join) { - clearButtons(none); + setButtons(none); PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); setupTransaction(); pcThickness->Join.setValue(join); @@ -231,7 +163,7 @@ void TaskThicknessParameters::onJoinTypeChanged(int join) { void TaskThicknessParameters::onModeChanged(int mode) { - clearButtons(none); + setButtons(none); PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); setupTransaction(); pcThickness->Mode.setValue(mode); @@ -246,7 +178,7 @@ double TaskThicknessParameters::getValue(void) const } void TaskThicknessParameters::onReversedChanged(const bool on) { - clearButtons(none); + setButtons(none); PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); setupTransaction(); pcThickness->Reversed.setValue(on); @@ -261,7 +193,7 @@ bool TaskThicknessParameters::getReversed(void) const } void TaskThicknessParameters::onIntersectionChanged(const bool on) { - clearButtons(none); + setButtons(none); PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); pcThickness->Intersection.setValue(on); pcThickness->getDocument()->recomputeFeature(pcThickness); diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.h b/src/Mod/PartDesign/Gui/TaskThicknessParameters.h index 5513b2f47d..00eb26e072 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.h +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.h @@ -54,7 +54,7 @@ private Q_SLOTS: void onRefDeleted(void) override; protected: - void clearButtons(const selectionModes notThis) override; + void setButtons(const selectionModes mode) override; bool event(QEvent *e) override; void changeEvent(QEvent *e) override; void onSelectionChanged(const Gui::SelectionChanges& msg) override; diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.ui b/src/Mod/PartDesign/Gui/TaskThicknessParameters.ui index d7f332916b..5497707f8b 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.ui @@ -21,7 +21,7 @@ click again to end selection - Select face + Start selection true From d896d00d48827fbdafadd8a7b3a79b6a161a01fc Mon Sep 17 00:00:00 2001 From: Paddle Date: Fri, 24 Mar 2023 14:42:16 +0100 Subject: [PATCH 3/6] PartDesign: Fillet Draft Chamfer Thickness : Add warning message on empty feature creation --- src/Mod/PartDesign/Gui/TaskChamferParameters.cpp | 4 ++++ src/Mod/PartDesign/Gui/TaskDraftParameters.cpp | 10 ++++++++++ src/Mod/PartDesign/Gui/TaskDraftParameters.h | 2 ++ src/Mod/PartDesign/Gui/TaskFilletParameters.cpp | 4 ++++ src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp | 8 ++++++++ src/Mod/PartDesign/Gui/TaskThicknessParameters.h | 2 ++ 6 files changed, 30 insertions(+) diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp index ed085a6c72..22bd9a7d2e 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp @@ -318,6 +318,10 @@ void TaskChamferParameters::apply() ui->chamferAngle->apply(); break; } + + //Alert user if he created an empty feature + if (ui->listWidgetReferences->count() == 0) + Base::Console().Warning(tr("Empty chamfer created !\n").toStdString().c_str()); } //************************************************************************** diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp index 0dde2ca0fb..457c8ecbc2 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp @@ -275,6 +275,14 @@ void TaskDraftParameters::changeEvent(QEvent *e) } } +void TaskDraftParameters::apply() +{ + //Alert user if he created an empty feature + if (ui->listWidgetReferences->count() == 0) + Base::Console().Warning(tr("Empty draft created !\n").toStdString().c_str()); + + TaskDressUpParameters::apply(); +} //************************************************************************** //************************************************************************** @@ -312,6 +320,8 @@ bool TaskDlgDraftParameters::accept() if (!tobj->isError()) parameter->showObject(); + parameter->apply(); + std::vector strings; App::DocumentObject* obj; TaskDraftParameters* draftparameter = static_cast(parameter); diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.h b/src/Mod/PartDesign/Gui/TaskDraftParameters.h index cdd9270a86..bb170a1b79 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.h +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.h @@ -40,6 +40,8 @@ public: explicit TaskDraftParameters(ViewProviderDressUp *DressUpView, QWidget *parent=nullptr); ~TaskDraftParameters() override; + void apply() override; + double getAngle() const; bool getReversed() const; const std::vector getFaces() const; diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp index 6130a0619b..58160e4910 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp @@ -188,6 +188,10 @@ void TaskFilletParameters::apply() //Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Fillet changed")); ui->filletRadius->apply(); + + //Alert user if he created an empty feature + if(ui->listWidgetReferences->count() == 0) + Base::Console().Warning(tr("Empty fillet created !\n").toStdString().c_str()); } //************************************************************************** diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp index 6ec5e319fd..b08b6b8e9e 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp @@ -241,6 +241,12 @@ void TaskThicknessParameters::changeEvent(QEvent *e) } } +void TaskThicknessParameters::apply() +{ + //Alert user if he created an empty feature + if (ui->listWidgetReferences->count() == 0) + Base::Console().Warning(tr("Empty thickness created !\n").toStdString().c_str()); +} //************************************************************************** //************************************************************************** @@ -283,6 +289,8 @@ bool TaskDlgThicknessParameters::accept() if (!obj->isError()) parameter->showObject(); + parameter->apply(); + TaskThicknessParameters* draftparameter = static_cast(parameter); FCMD_OBJ_CMD(obj,"Value = " << draftparameter->getValue()); diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.h b/src/Mod/PartDesign/Gui/TaskThicknessParameters.h index 00eb26e072..a94a09bcf5 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.h +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.h @@ -39,6 +39,8 @@ public: explicit TaskThicknessParameters(ViewProviderDressUp *DressUpView, QWidget *parent=nullptr); ~TaskThicknessParameters() override; + void apply() override; + double getValue(void) const; bool getReversed(void) const; bool getIntersection(void) const; From de6038ff9bccbe3d4c8d8b03fb03c6e4ced1b4e1 Mon Sep 17 00:00:00 2001 From: Paddle Date: Fri, 24 Mar 2023 15:16:09 +0100 Subject: [PATCH 4/6] PartDesign: Fix placement issue with thickness tool when the feature was empty. --- src/Mod/PartDesign/App/FeatureThickness.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Mod/PartDesign/App/FeatureThickness.cpp b/src/Mod/PartDesign/App/FeatureThickness.cpp index 2dbe7d76ef..59d52e13fa 100644 --- a/src/Mod/PartDesign/App/FeatureThickness.cpp +++ b/src/Mod/PartDesign/App/FeatureThickness.cpp @@ -76,10 +76,16 @@ App::DocumentObjectExecReturn *Thickness::execute() //If no element is selected, then we use a copy of previous feature. if (subStrings.empty()) { + //We must set the placement of the feature in case it's empty. + this->positionByBaseFeature(); this->Shape.setValue(TopShape); return App::DocumentObject::StdReturn; } + /* If the feature was empty at some point, then Placement was set by positionByBaseFeature. + * However makeThickSolid apparantly requires the placement to be empty, so we have to clear it*/ + this->Placement.setValue(Base::Placement()); + TopTools_ListOfShape closingFaces; for (std::vector::const_iterator it = subStrings.begin(); it != subStrings.end(); ++it) { From 18a9c164d6f9a8dccedf7f9670715f15be76f109 Mon Sep 17 00:00:00 2001 From: Paddle Date: Sat, 25 Mar 2023 06:36:56 +0100 Subject: [PATCH 5/6] PartDesign: Fillet/chamger/draft/thickness: change the button strings to 'Preview' and 'Select' --- src/Mod/PartDesign/Gui/TaskChamferParameters.cpp | 2 +- src/Mod/PartDesign/Gui/TaskDraftParameters.cpp | 2 +- src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp | 3 +++ src/Mod/PartDesign/Gui/TaskDressUpParameters.h | 3 +++ src/Mod/PartDesign/Gui/TaskFilletParameters.cpp | 2 +- src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp | 2 +- 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp index 22bd9a7d2e..3990b2449a 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp @@ -175,7 +175,7 @@ void TaskChamferParameters::onCheckBoxUseAllEdgesToggled(bool checked) void TaskChamferParameters::setButtons(const selectionModes mode) { ui->buttonRefSel->setChecked(mode == refSel); - ui->buttonRefSel->setText(mode == refSel ? tr("End selection") : tr("Start selection")); + ui->buttonRefSel->setText(mode == refSel ? btnPreviewStr : btnSelectStr); } void TaskChamferParameters::onRefDeleted() diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp index 457c8ecbc2..91d14e3d68 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp @@ -165,7 +165,7 @@ void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg) void TaskDraftParameters::setButtons(const selectionModes mode) { - ui->buttonRefSel->setText(mode == refSel ? tr("End selection") : tr("Start selection")); + ui->buttonRefSel->setText(mode == refSel ? btnPreviewStr : btnSelectStr); ui->buttonRefSel->setChecked(mode == refSel); ui->buttonLine->setChecked(mode == line); ui->buttonPlane->setChecked(mode == plane); diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp index 6406fe75dc..4add27e77b 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp @@ -51,6 +51,9 @@ FC_LOG_LEVEL_INIT("PartDesign",true,true) using namespace PartDesignGui; using namespace Gui; +const QString TaskDressUpParameters::btnPreviewStr = tr("Preview"); +const QString TaskDressUpParameters::btnSelectStr = tr("Select"); + /* TRANSLATOR PartDesignGui::TaskDressUpParameters */ TaskDressUpParameters::TaskDressUpParameters(ViewProviderDressUp *DressUpView, bool selectEdges, bool selectFaces, QWidget *parent) diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.h b/src/Mod/PartDesign/Gui/TaskDressUpParameters.h index 4a8524b0c9..50c35ee22d 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.h +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.h @@ -99,6 +99,9 @@ protected: bool allowFaces, allowEdges; selectionModes selectionMode; int transactionID; + + static const QString btnPreviewStr; + static const QString btnSelectStr; }; /// simulation dialog for the TaskView diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp index 58160e4910..b0421e4c4a 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp @@ -128,7 +128,7 @@ void TaskFilletParameters::onCheckBoxUseAllEdgesToggled(bool checked) void TaskFilletParameters::setButtons(const selectionModes mode) { ui->buttonRefSel->setChecked(mode == refSel); - ui->buttonRefSel->setText(mode == refSel ? tr("End selection") : tr("Start selection")); + ui->buttonRefSel->setText(mode == refSel ? btnPreviewStr : btnSelectStr); } void TaskFilletParameters::onRefDeleted() diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp index b08b6b8e9e..f35f892741 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp @@ -131,7 +131,7 @@ void TaskThicknessParameters::onSelectionChanged(const Gui::SelectionChanges& ms void TaskThicknessParameters::setButtons(const selectionModes mode) { ui->buttonRefSel->setChecked(mode == refSel); - ui->buttonRefSel->setText(mode == refSel ? tr("End selection") : tr("Start selection")); + ui->buttonRefSel->setText(mode == refSel ? btnPreviewStr : btnSelectStr); } void TaskThicknessParameters::onRefDeleted(void) From 12588150c1117e8bfcdeb3cb5076ac99e48e31f0 Mon Sep 17 00:00:00 2001 From: Paddle Date: Tue, 28 Mar 2023 13:30:13 +0200 Subject: [PATCH 6/6] PartDesign: Chamfer/fillet/draft/thickness small fixes. --- src/Mod/PartDesign/App/FeatureThickness.cpp | 2 +- src/Mod/PartDesign/Gui/Command.cpp | 4 ++-- src/Mod/PartDesign/Gui/TaskChamferParameters.ui | 2 +- src/Mod/PartDesign/Gui/TaskDraftParameters.ui | 2 +- src/Mod/PartDesign/Gui/TaskFilletParameters.ui | 2 +- src/Mod/PartDesign/Gui/TaskThicknessParameters.ui | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureThickness.cpp b/src/Mod/PartDesign/App/FeatureThickness.cpp index 59d52e13fa..41705b62dc 100644 --- a/src/Mod/PartDesign/App/FeatureThickness.cpp +++ b/src/Mod/PartDesign/App/FeatureThickness.cpp @@ -83,7 +83,7 @@ App::DocumentObjectExecReturn *Thickness::execute() } /* If the feature was empty at some point, then Placement was set by positionByBaseFeature. - * However makeThickSolid apparantly requires the placement to be empty, so we have to clear it*/ + * However makeThickSolid apparently requires the placement to be empty, so we have to clear it*/ this->Placement.setValue(Base::Placement()); TopTools_ListOfShape closingFaces; diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 9d05bf6633..8da099f8f8 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -1766,7 +1766,7 @@ void CmdPartDesignDraft::activated(int iMsg) size_t i = 0; while (i < SubNames.size()) { - std::string aSubName = static_cast(SubNames.at(i)); + std::string aSubName = SubNames.at(i); if (aSubName.compare(0, 4, "Face") == 0) { // Check for valid face types @@ -1833,7 +1833,7 @@ void CmdPartDesignThickness::activated(int iMsg) size_t i = 0; while (i < SubNames.size()) { - std::string aSubName = static_cast(SubNames.at(i)); + std::string aSubName = SubNames.at(i); if (aSubName.compare(0, 4, "Face") != 0) { // empty name or any other sub-element diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.ui b/src/Mod/PartDesign/Gui/TaskChamferParameters.ui index 2d613143cd..aff84ea890 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.ui @@ -21,7 +21,7 @@ click again to end selection - Enter selection + Select true diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.ui b/src/Mod/PartDesign/Gui/TaskDraftParameters.ui index 4e3de180e6..e306168d67 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.ui @@ -22,7 +22,7 @@ click again to end selection - Enter selection + Select true diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.ui b/src/Mod/PartDesign/Gui/TaskFilletParameters.ui index 06c250615d..8b6fb663ff 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.ui @@ -21,7 +21,7 @@ click again to end selection - Enter selection + Select true diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.ui b/src/Mod/PartDesign/Gui/TaskThicknessParameters.ui index 5497707f8b..197f0bc2cf 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.ui @@ -21,7 +21,7 @@ click again to end selection - Start selection + Select true