diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp index 7b2ef24c73..4c8d046974 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp @@ -50,7 +50,7 @@ using namespace Gui; /* TRANSLATOR PartDesignGui::TaskChamferParameters */ -TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView,QWidget *parent) +TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView, QWidget *parent) : TaskDressUpParameters(DressUpView, true, true, parent) { // we need a separate container widget to add all controls to @@ -77,11 +77,11 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView,QW QMetaObject::connectSlotsByName(this); connect(ui->chamferDistance, SIGNAL(valueChanged(double)), - this, SLOT(onLengthChanged(double))); + this, SLOT(onLengthChanged(double))); connect(ui->buttonRefAdd, SIGNAL(toggled(bool)), - this, SLOT(onButtonRefAdd(bool))); + this, SLOT(onButtonRefAdd(bool))); connect(ui->buttonRefRemove, SIGNAL(toggled(bool)), - this, SLOT(onButtonRefRemove(bool))); + this, SLOT(onButtonRefRemove(bool))); // Create context menu QAction* action = new QAction(tr("Remove"), this); @@ -91,8 +91,20 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView,QW action->setShortcutVisibleInContextMenu(true); #endif ui->listWidgetReferences->addAction(action); + // if there is only one item, it cannot be deleted + if (ui->listWidgetReferences->count() == 1) { + action->setEnabled(false); + action->setStatusTip(tr("There must be at least one item")); + ui->buttonRefRemove->setEnabled(false); + ui->buttonRefRemove->setToolTip(tr("There must be at least one item")); + } connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted())); ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu); + + connect(ui->listWidgetReferences, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + this, SLOT(setSelection(QListWidgetItem*))); + connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)), + this, SLOT(doubleClicked(QListWidgetItem*))); } void TaskChamferParameters::onSelectionChanged(const Gui::SelectionChanges& msg) @@ -102,10 +114,32 @@ void TaskChamferParameters::onSelectionChanged(const Gui::SelectionChanges& msg) if (msg.Type == Gui::SelectionChanges::AddSelection) { if (referenceSelected(msg)) { - if (selectionMode == refAdd) + QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action + if (selectionMode == refAdd) { ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName)); - else + // it might be the second one so we can enable the context menu + if (ui->listWidgetReferences->count() > 1) { + action->setEnabled(true); + action->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) { + action->setEnabled(false); + action->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 DressUpView->highlightReferences(true); } @@ -121,6 +155,13 @@ void TaskChamferParameters::clearButtons(const selectionModes notThis) void TaskChamferParameters::onRefDeleted(void) { + // assure we we are not in selection mode + exitSelectionMode(); + clearButtons(none); + // delete any selections since the reference might be highlighted + Gui::Selection().clearSelection(); + DressUpView->highlightReferences(false); + PartDesign::Chamfer* pcChamfer = static_cast(DressUpView->getObject()); App::DocumentObject* base = pcChamfer->Base.getValue(); std::vector refs = pcChamfer->Base.getSubValues(); @@ -129,6 +170,15 @@ void TaskChamferParameters::onRefDeleted(void) pcChamfer->Base.setValue(base, refs); ui->listWidgetReferences->model()->removeRow(ui->listWidgetReferences->currentRow()); pcChamfer->getDocument()->recomputeFeature(pcChamfer); + + // if there is only one item left, it cannot be deleted + if (ui->listWidgetReferences->count() == 1) { + QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action + action->setEnabled(false); + action->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::onLengthChanged(double len) @@ -146,7 +196,13 @@ double TaskChamferParameters::getLength(void) const TaskChamferParameters::~TaskChamferParameters() { + // assure the fillets are shown + showObject(); + // remove any highlights and selections + DressUpView->highlightReferences(false); + Gui::Selection().clearSelection(); Gui::Selection().rmvSelectionGate(); + delete ui; } diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.ui b/src/Mod/PartDesign/Gui/TaskChamferParameters.ui index 29a603a8f2..cc62e031d1 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.ui @@ -1,65 +1,78 @@ - - - PartDesignGui::TaskChamferParameters - - - - 0 - 0 - 182 - 185 - - - - Form - - - - - - - - Add ref - - - true - - - - - - - Remove ref - - - true - - - - - - - - - - - - - - - Size: - - - - - - - - Gui::QuantitySpinBox - QWidget -
Gui/QuantitySpinBox.h
-
-
- - -
+ + + PartDesignGui::TaskChamferParameters + + + + 0 + 0 + 182 + 185 + + + + Form + + + + + + + + Click button to enter selection mode, +click again to end selection + + + Add ref + + + true + + + + + + + Click button to enter selection mode, +click again to end selection + + + Remove ref + + + true + + + + + + + + + - select an item to highlight it +- double-click on an item to see the chamfers + + + + + + + + + + Size: + + + + + + + + Gui::QuantitySpinBox + QWidget +
Gui/QuantitySpinBox.h
+
+
+ + +
diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp index 7d2b66cf49..4124a05cb4 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp @@ -51,7 +51,7 @@ using namespace Gui; /* TRANSLATOR PartDesignGui::TaskDraftParameters */ -TaskDraftParameters::TaskDraftParameters(ViewProviderDressUp *DressUpView,QWidget *parent) +TaskDraftParameters::TaskDraftParameters(ViewProviderDressUp *DressUpView, QWidget *parent) : TaskDressUpParameters(DressUpView, false, true, parent) { // we need a separate container widget to add all controls to @@ -85,17 +85,17 @@ TaskDraftParameters::TaskDraftParameters(ViewProviderDressUp *DressUpView,QWidge QMetaObject::connectSlotsByName(this); connect(ui->draftAngle, SIGNAL(valueChanged(double)), - this, SLOT(onAngleChanged(double))); + this, SLOT(onAngleChanged(double))); connect(ui->checkReverse, SIGNAL(toggled(bool)), - this, SLOT(onReversedChanged(bool))); + this, SLOT(onReversedChanged(bool))); connect(ui->buttonRefAdd, SIGNAL(toggled(bool)), - this, SLOT(onButtonRefAdd(bool))); + this, SLOT(onButtonRefAdd(bool))); connect(ui->buttonRefRemove, SIGNAL(toggled(bool)), - this, SLOT(onButtonRefRemove(bool))); + this, SLOT(onButtonRefRemove(bool))); connect(ui->buttonPlane, SIGNAL(toggled(bool)), - this, SLOT(onButtonPlane(bool))); + this, SLOT(onButtonPlane(bool))); connect(ui->buttonLine, SIGNAL(toggled(bool)), - this, SLOT(onButtonLine(bool))); + this, SLOT(onButtonLine(bool))); // Create context menu QAction* action = new QAction(tr("Remove"), this); @@ -105,9 +105,21 @@ TaskDraftParameters::TaskDraftParameters(ViewProviderDressUp *DressUpView,QWidge action->setShortcutVisibleInContextMenu(true); #endif ui->listWidgetReferences->addAction(action); + // if there is only one item, it cannot be deleted + if (ui->listWidgetReferences->count() == 1) { + action->setEnabled(false); + action->setStatusTip(tr("There must be at least one item")); + ui->buttonRefRemove->setEnabled(false); + ui->buttonRefRemove->setToolTip(tr("There must be at least one item")); + } connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted())); ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu); + connect(ui->listWidgetReferences, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + this, SLOT(setSelection(QListWidgetItem*))); + connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)), + this, SLOT(doubleClicked(QListWidgetItem*))); + App::DocumentObject* ref = pcDraft->NeutralPlane.getValue(); strings = pcDraft->NeutralPlane.getSubValues(); ui->linePlane->setText(getRefStr(ref, strings)); @@ -124,10 +136,32 @@ void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg) if (msg.Type == Gui::SelectionChanges::AddSelection) { if (referenceSelected(msg)) { - if (selectionMode == refAdd) + QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action + if (selectionMode == refAdd) { ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName)); - else + // it might be the second one so we can enable the context menu + if (ui->listWidgetReferences->count() > 1) { + action->setEnabled(true); + action->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) { + action->setEnabled(false); + action->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 DressUpView->highlightReferences(true); } else if (selectionMode == plane) { @@ -195,6 +229,13 @@ 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 might be highlighted + Gui::Selection().clearSelection(); + DressUpView->highlightReferences(false); + PartDesign::Draft* pcDraft = static_cast(DressUpView->getObject()); App::DocumentObject* base = pcDraft->Base.getValue(); std::vector faces = pcDraft->Base.getSubValues(); @@ -203,6 +244,15 @@ void TaskDraftParameters::onRefDeleted(void) pcDraft->Base.setValue(base, faces); ui->listWidgetReferences->model()->removeRow(ui->listWidgetReferences->currentRow()); pcDraft->getDocument()->recomputeFeature(pcDraft); + + // if there is only one item left, it cannot be deleted + if (ui->listWidgetReferences->count() == 1) { + QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action + action->setEnabled(false); + action->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 TaskDraftParameters::getPlane(App::DocumentObject*& obj, std::vector& sub) const @@ -252,7 +302,13 @@ bool TaskDraftParameters::getReversed(void) const TaskDraftParameters::~TaskDraftParameters() { + // assure the fillets are shown + showObject(); + // remove any highlights and selections + DressUpView->highlightReferences(false); + Gui::Selection().clearSelection(); Gui::Selection().rmvSelectionGate(); + delete ui; } diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.ui b/src/Mod/PartDesign/Gui/TaskDraftParameters.ui index 32b5fa4acc..6e91bc509a 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.ui @@ -1,128 +1,141 @@ - - - PartDesignGui::TaskDraftParameters - - - - 0 - 0 - 257 - 285 - - - - Form - - - - - - - - Add face - - - true - - - - - - - Remove face - - - true - - - - - - - - - - - - - - Draft angle - - - - - - - deg - - - 0.000000000000000 - - - 89.999999999999986 - - - 0.100000000000000 - - - 1.500000000000000 - - - - - - - - - - - Neutral plane - - - true - - - - - - - - - - - - - - Pull direction - - - true - - - - - - - - - - - - Reverse pull direction - - - - - checkReverse - listWidgetReferences - - - - Gui::QuantitySpinBox - QWidget -
Gui/QuantitySpinBox.h
-
-
- - -
+ + + PartDesignGui::TaskDraftParameters + + + + 0 + 0 + 257 + 285 + + + + Form + + + + + + + + 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 an item to highlight it +- double-click on an item to see the drafts + + + + + + + + + Draft angle + + + + + + + deg + + + 0.000000000000000 + + + 89.999999999999986 + + + 0.100000000000000 + + + 1.500000000000000 + + + + + + + + + + + Neutral plane + + + true + + + + + + + + + + + + + + Pull direction + + + true + + + + + + + + + + + + Reverse pull direction + + + + + checkReverse + listWidgetReferences + + + + Gui::QuantitySpinBox + QWidget +
Gui/QuantitySpinBox.h
+
+
+ + +
diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp index cf37c8bea7..17e5295cb2 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -153,6 +154,44 @@ void TaskDressUpParameters::onButtonRefRemove(const bool checked) } } +void TaskDressUpParameters::doubleClicked(QListWidgetItem* item) { + // executed when the user selected a new item in the list + // shows the fillets as they are -> useful to switch out of selection mode + + // assure we are not in selection mode + exitSelectionMode(); + clearButtons(none); + + // assure the fillets are shown + showObject(); + // remove any highlights andd selections + DressUpView->highlightReferences(false); + Gui::Selection().clearSelection(); +} + +void TaskDressUpParameters::setSelection(QListWidgetItem* current) { + // executed when the user selected a new item in the list + // highlights the currently selected item + + // name of the item + std::string subName = current->text().toStdString(); + // get the document name + std::string docName = DressUpView->getObject()->getDocument()->getName(); + // get the name of the body we are in + Part::BodyBase* body = PartDesign::Body::findBodyOf(DressUpView->getObject()); + 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 selections + Gui::Selection().clearSelection(); + // highligh the selected item + Gui::Selection().addSelection(docName.c_str(), objName.c_str(), subName.c_str(), 0, 0, 0); +} + const std::vector TaskDressUpParameters::getReferences() const { PartDesign::DressUp* pcDressUp = static_cast(DressUpView->getObject()); diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.h b/src/Mod/PartDesign/Gui/TaskDressUpParameters.h index 8ad4b67a1f..a7c6d5288b 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.h +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.h @@ -60,6 +60,8 @@ public: protected Q_SLOTS: void onButtonRefAdd(const bool checked); void onButtonRefRemove(const bool checked); + void doubleClicked(QListWidgetItem* item); + void setSelection(QListWidgetItem* current); virtual void onRefDeleted(void) = 0; protected: diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp index 1d51f9f3d8..0fee3d7886 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp @@ -49,7 +49,7 @@ using namespace Gui; /* TRANSLATOR PartDesignGui::TaskFilletParameters */ -TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView,QWidget *parent) +TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView, QWidget *parent) : TaskDressUpParameters(DressUpView, true, true, parent) { // we need a separate container widget to add all controls to @@ -77,11 +77,11 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView,QWid QMetaObject::connectSlotsByName(this); connect(ui->filletRadius, SIGNAL(valueChanged(double)), - this, SLOT(onLengthChanged(double))); + this, SLOT(onLengthChanged(double))); connect(ui->buttonRefAdd, SIGNAL(toggled(bool)), - this, SLOT(onButtonRefAdd(bool))); + this, SLOT(onButtonRefAdd(bool))); connect(ui->buttonRefRemove, SIGNAL(toggled(bool)), - this, SLOT(onButtonRefRemove(bool))); + this, SLOT(onButtonRefRemove(bool))); // Create context menu QAction* action = new QAction(tr("Remove"), this); @@ -91,8 +91,20 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView,QWid action->setShortcutVisibleInContextMenu(true); #endif ui->listWidgetReferences->addAction(action); + // if there is only one item, it cannot be deleted + if (ui->listWidgetReferences->count() == 1) { + action->setEnabled(false); + action->setStatusTip(tr("There must be at least one item")); + ui->buttonRefRemove->setEnabled(false); + ui->buttonRefRemove->setToolTip(tr("There must be at least one item")); + } connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted())); ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu); + + connect(ui->listWidgetReferences, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + this, SLOT(setSelection(QListWidgetItem*))); + connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)), + this, SLOT(doubleClicked(QListWidgetItem*))); } void TaskFilletParameters::onSelectionChanged(const Gui::SelectionChanges& msg) @@ -102,10 +114,32 @@ void TaskFilletParameters::onSelectionChanged(const Gui::SelectionChanges& msg) if (msg.Type == Gui::SelectionChanges::AddSelection) { if (referenceSelected(msg)) { - if (selectionMode == refAdd) + QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action + if (selectionMode == refAdd) { ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName)); - else + // it might be the second one so we can enable the context menu + if (ui->listWidgetReferences->count() > 1) { + action->setEnabled(true); + action->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) { + action->setEnabled(false); + action->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 DressUpView->highlightReferences(true); } @@ -121,6 +155,13 @@ void TaskFilletParameters::clearButtons(const selectionModes notThis) void TaskFilletParameters::onRefDeleted(void) { + // assure we we are not in selection mode + exitSelectionMode(); + clearButtons(none); + // delete any selections since the reference might be highlighted + Gui::Selection().clearSelection(); + DressUpView->highlightReferences(false); + PartDesign::Fillet* pcFillet = static_cast(DressUpView->getObject()); App::DocumentObject* base = pcFillet->Base.getValue(); std::vector refs = pcFillet->Base.getSubValues(); @@ -129,6 +170,15 @@ void TaskFilletParameters::onRefDeleted(void) pcFillet->Base.setValue(base, refs); ui->listWidgetReferences->model()->removeRow(ui->listWidgetReferences->currentRow()); pcFillet->getDocument()->recomputeFeature(pcFillet); + + // if there is only one item left, it cannot be deleted + if (ui->listWidgetReferences->count() == 1) { + QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action + action->setEnabled(false); + action->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::onLengthChanged(double len) @@ -147,7 +197,13 @@ double TaskFilletParameters::getLength(void) const TaskFilletParameters::~TaskFilletParameters() { + // assure the fillets are shown + showObject(); + // remove any highlights and selections + DressUpView->highlightReferences(false); + Gui::Selection().clearSelection(); Gui::Selection().rmvSelectionGate(); + delete ui; } diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.ui b/src/Mod/PartDesign/Gui/TaskFilletParameters.ui index b6803af459..c6cd718820 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.ui @@ -1,69 +1,82 @@ - - - PartDesignGui::TaskFilletParameters - - - - 0 - 0 - 208 - 164 - - - - Form - - - - - - - - Add ref - - - true - - - - - - - Remove ref - - - true - - - - - - - - - - - - - - Radius: - - - - - - - - - - - - - Gui::QuantitySpinBox - QWidget -
Gui/QuantitySpinBox.h
-
-
- - -
+ + + PartDesignGui::TaskFilletParameters + + + + 0 + 0 + 208 + 164 + + + + Form + + + + + + + + Click button to enter selection mode, +click again to end selection + + + Add ref + + + true + + + + + + + Click button to enter selection mode, +click again to end selection + + + Remove ref + + + true + + + + + + + + + - select an item to highlight it +- double-click on an item to see the fillets + + + + + + + + + Radius: + + + + + + + + + + + + + Gui::QuantitySpinBox + QWidget +
Gui/QuantitySpinBox.h
+
+
+ + +
diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp index 51299c3cd0..f5c3ec0881 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp @@ -49,7 +49,7 @@ using namespace Gui; /* TRANSLATOR PartDesignGui::TaskThicknessParameters */ -TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpView,QWidget *parent) +TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpView, QWidget *parent) : TaskDressUpParameters(DressUpView, false, true, parent) { // we need a separate container widget to add all controls to @@ -85,19 +85,19 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie QMetaObject::connectSlotsByName(this); connect(ui->Value, SIGNAL(valueChanged(double)), - this, SLOT(onValueChanged(double))); + this, SLOT(onValueChanged(double))); connect(ui->checkReverse, SIGNAL(toggled(bool)), - this, SLOT(onReversedChanged(bool))); + this, SLOT(onReversedChanged(bool))); connect(ui->checkIntersection, SIGNAL(toggled(bool)), - this, SLOT(onIntersectionChanged(bool))); + this, SLOT(onIntersectionChanged(bool))); connect(ui->buttonRefAdd, SIGNAL(toggled(bool)), - this, SLOT(onButtonRefAdd(bool))); + this, SLOT(onButtonRefAdd(bool))); connect(ui->buttonRefRemove, SIGNAL(toggled(bool)), - this, SLOT(onButtonRefRemove(bool))); + this, SLOT(onButtonRefRemove(bool))); connect(ui->modeComboBox, SIGNAL(currentIndexChanged(int)), - this, SLOT(onModeChanged(int))); + this, SLOT(onModeChanged(int))); connect(ui->joinComboBox, SIGNAL(currentIndexChanged(int)), - this, SLOT(onJoinTypeChanged(int))); + this, SLOT(onJoinTypeChanged(int))); // Create context menu QAction* action = new QAction(tr("Remove"), this); @@ -107,9 +107,21 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie action->setShortcutVisibleInContextMenu(true); #endif ui->listWidgetReferences->addAction(action); + // if there is only one item, it cannot be deleted + if (ui->listWidgetReferences->count() == 1) { + action->setEnabled(false); + action->setStatusTip(tr("There must be at least one item")); + ui->buttonRefRemove->setEnabled(false); + ui->buttonRefRemove->setToolTip(tr("There must be at least one item")); + } connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted())); ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu); + connect(ui->listWidgetReferences, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + this, SLOT(setSelection(QListWidgetItem*))); + connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)), + this, SLOT(doubleClicked(QListWidgetItem*))); + int mode = pcThickness->Mode.getValue(); ui->modeComboBox->setCurrentIndex(mode); @@ -124,10 +136,32 @@ void TaskThicknessParameters::onSelectionChanged(const Gui::SelectionChanges& ms if (msg.Type == Gui::SelectionChanges::AddSelection) { if (referenceSelected(msg)) { - if (selectionMode == refAdd) + QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action + if (selectionMode == refAdd) { ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName)); - else + // it might be the second one so we can enable the context menu + if (ui->listWidgetReferences->count() > 1) { + action->setEnabled(true); + action->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) { + action->setEnabled(false); + action->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 DressUpView->highlightReferences(true); } @@ -143,6 +177,13 @@ void TaskThicknessParameters::clearButtons(const selectionModes notThis) void TaskThicknessParameters::onRefDeleted(void) { + // assure we we are not in selection mode + exitSelectionMode(); + clearButtons(none); + // delete any selections since the reference might be highlighted + Gui::Selection().clearSelection(); + DressUpView->highlightReferences(false); + PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); App::DocumentObject* base = pcThickness->Base.getValue(); std::vector faces = pcThickness->Base.getSubValues(); @@ -153,6 +194,15 @@ void TaskThicknessParameters::onRefDeleted(void) pcThickness->getDocument()->recomputeFeature(pcThickness); clearButtons(none); exitSelectionMode(); + + // if there is only one item left, it cannot be deleted + if (ui->listWidgetReferences->count() == 1) { + QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action + action->setEnabled(false); + action->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 TaskThicknessParameters::onValueChanged(double angle) @@ -226,7 +276,13 @@ int TaskThicknessParameters::getMode(void) const { TaskThicknessParameters::~TaskThicknessParameters() { + // assure the fillets are shown + showObject(); + // remove any highlights and selections + DressUpView->highlightReferences(false); + Gui::Selection().clearSelection(); Gui::Selection().rmvSelectionGate(); + delete ui; } diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.ui b/src/Mod/PartDesign/Gui/TaskThicknessParameters.ui index e4812e09f8..faf42a3a00 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.ui @@ -1,159 +1,172 @@ - - - PartDesignGui::TaskThicknessParameters - - - - 0 - 0 - 321 - 509 - - - - Form - - - - - - - - Add face - - - true - - - - - - - Remove face - - - true - - - - - - - - - - - - - - Thickness - - - - - - - Qt::TabFocus - - - mm - - - 0.000000000000000 - - - 999999999.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Mode - - - - - - - Join Type - - - - - - - - Skin - - - - - Pipe - - - - - Recto Verso - - - - - - - - - Arc - - - - - Intersection - - - - - - - - - - Intersection - - - - - - - Make thickness inwards - - - - - - - - Gui::QuantitySpinBox - QWidget -
Gui/QuantitySpinBox.h
-
-
- - Value - modeComboBox - joinComboBox - checkIntersection - checkReverse - buttonRefAdd - buttonRefRemove - listWidgetReferences - - - -
+ + + PartDesignGui::TaskThicknessParameters + + + + 0 + 0 + 321 + 509 + + + + Form + + + + + + + + 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 an item to highlight it +- double-click on an item to see the features + + + + + + + + + Thickness + + + + + + + Qt::TabFocus + + + mm + + + 0.000000000000000 + + + 999999999.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Mode + + + + + + + Join Type + + + + + + + + Skin + + + + + Pipe + + + + + Recto Verso + + + + + + + + + Arc + + + + + Intersection + + + + + + + + + + Intersection + + + + + + + Make thickness inwards + + + + + + + + Gui::QuantitySpinBox + QWidget +
Gui/QuantitySpinBox.h
+
+
+ + Value + modeComboBox + joinComboBox + checkIntersection + checkReverse + buttonRefAdd + buttonRefRemove + listWidgetReferences + + + +