From 996839c263fd57deff5e7d791fa954fd2a6ca8f2 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 20 Dec 2022 17:57:18 +0100 Subject: [PATCH] Surface: use a single button group for all task boxes --- src/Mod/Surface/Gui/TaskFilling.cpp | 24 +++++++++++++++-------- src/Mod/Surface/Gui/TaskFilling.h | 3 ++- src/Mod/Surface/Gui/TaskFillingEdge.cpp | 16 +++++++-------- src/Mod/Surface/Gui/TaskFillingEdge.h | 2 +- src/Mod/Surface/Gui/TaskFillingVertex.cpp | 16 +++++++-------- src/Mod/Surface/Gui/TaskFillingVertex.h | 2 +- 6 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/Mod/Surface/Gui/TaskFilling.cpp b/src/Mod/Surface/Gui/TaskFilling.cpp index 65fc55414f..b03cd2f001 100644 --- a/src/Mod/Surface/Gui/TaskFilling.cpp +++ b/src/Mod/Surface/Gui/TaskFilling.cpp @@ -266,12 +266,6 @@ FillingPanel::FillingPanel(ViewProviderFilling* vp, Surface::Filling* obj) checkCommand = true; setEditedObject(obj); - // Set up button group - buttonGroup = new Gui::ButtonGroup(this); - buttonGroup->setExclusive(true); - buttonGroup->addButton(ui->buttonEdgeAdd, (int)SelectionMode::AppendEdge); - buttonGroup->addButton(ui->buttonEdgeRemove, (int)SelectionMode::RemoveEdge); - // Create context menu QAction* action = new QAction(tr("Remove"), this); action->setShortcut(QString::fromLatin1("Del")); @@ -293,6 +287,13 @@ FillingPanel::~FillingPanel() delete ui; } +void FillingPanel::appendButtons(Gui::ButtonGroup* buttonGroup) +{ + buttonGroup->addButton(ui->buttonInitFace, int(SelectionMode::InitFace)); + buttonGroup->addButton(ui->buttonEdgeAdd, int(SelectionMode::AppendEdge)); + buttonGroup->addButton(ui->buttonEdgeRemove, int(SelectionMode::RemoveEdge)); +} + // stores object pointer, its old fill type and adjusts radio buttons according to it. void FillingPanel::setEditedObject(Surface::Filling* fea) { @@ -502,9 +503,9 @@ void FillingPanel::on_buttonInitFace_clicked() void FillingPanel::on_buttonEdgeAdd_toggled(bool checked) { if (checked) { - selectionMode = AppendEdge; // 'selectionMode' is passed by reference and changed when the filter is deleted Gui::Selection().addSelectionGate(new ShapeSelection(selectionMode, editedObject)); + selectionMode = AppendEdge; } else if (selectionMode == AppendEdge) { exitSelectionMode(); @@ -514,9 +515,9 @@ void FillingPanel::on_buttonEdgeAdd_toggled(bool checked) void FillingPanel::on_buttonEdgeRemove_toggled(bool checked) { if (checked) { - selectionMode = RemoveEdge; // 'selectionMode' is passed by reference and changed when the filter is deleted Gui::Selection().addSelectionGate(new ShapeSelection(selectionMode, editedObject)); + selectionMode = RemoveEdge; } else if (selectionMode == RemoveEdge) { exitSelectionMode(); @@ -880,8 +881,13 @@ void FillingPanel::exitSelectionMode() TaskFilling::TaskFilling(ViewProviderFilling* vp, Surface::Filling* obj) { + // Set up button group + buttonGroup = new Gui::ButtonGroup(this); + buttonGroup->setExclusive(true); + // first task box widget1 = new FillingPanel(vp, obj); + widget1->appendButtons(buttonGroup); Gui::TaskView::TaskBox* taskbox1 = new Gui::TaskView::TaskBox( Gui::BitmapFactory().pixmap("Surface_Filling"), widget1->windowTitle(), true, nullptr); @@ -890,6 +896,7 @@ TaskFilling::TaskFilling(ViewProviderFilling* vp, Surface::Filling* obj) // second task box widget2 = new FillingEdgePanel(vp, obj); + widget2->appendButtons(buttonGroup); Gui::TaskView::TaskBox* taskbox2 = new Gui::TaskView::TaskBox( QPixmap(), widget2->windowTitle(), true, nullptr); taskbox2->groupLayout()->addWidget(widget2); @@ -898,6 +905,7 @@ TaskFilling::TaskFilling(ViewProviderFilling* vp, Surface::Filling* obj) // third task box widget3 = new FillingVertexPanel(vp, obj); + widget3->appendButtons(buttonGroup); Gui::TaskView::TaskBox* taskbox3 = new Gui::TaskView::TaskBox( QPixmap(), widget3->windowTitle(), true, nullptr); taskbox3->groupLayout()->addWidget(widget3); diff --git a/src/Mod/Surface/Gui/TaskFilling.h b/src/Mod/Surface/Gui/TaskFilling.h index 4322b9037b..d3768f9137 100644 --- a/src/Mod/Surface/Gui/TaskFilling.h +++ b/src/Mod/Surface/Gui/TaskFilling.h @@ -80,7 +80,6 @@ protected: private: Ui_TaskFilling* ui; ViewProviderFilling* vp; - Gui::ButtonGroup *buttonGroup; public: FillingPanel(ViewProviderFilling* vp, Surface::Filling* obj); @@ -91,6 +90,7 @@ public: bool accept(); bool reject(); void setEditedObject(Surface::Filling* obj); + void appendButtons(Gui::ButtonGroup *); protected: void changeEvent(QEvent *e) override; @@ -138,6 +138,7 @@ public: { return QDialogButtonBox::Ok | QDialogButtonBox::Cancel; } private: + Gui::ButtonGroup* buttonGroup; FillingPanel* widget1; FillingEdgePanel* widget2; FillingVertexPanel* widget3; diff --git a/src/Mod/Surface/Gui/TaskFillingEdge.cpp b/src/Mod/Surface/Gui/TaskFillingEdge.cpp index 5b87014d2a..0329b6eab3 100644 --- a/src/Mod/Surface/Gui/TaskFillingEdge.cpp +++ b/src/Mod/Surface/Gui/TaskFillingEdge.cpp @@ -125,12 +125,6 @@ FillingEdgePanel::FillingEdgePanel(ViewProviderFilling* vp, Surface::Filling* ob checkCommand = true; setEditedObject(obj); - // Set up button group - buttonGroup = new Gui::ButtonGroup(this); - buttonGroup->setExclusive(true); - buttonGroup->addButton(ui->buttonUnboundEdgeAdd, (int)SelectionMode::AppendEdge); - buttonGroup->addButton(ui->buttonUnboundEdgeRemove, (int)SelectionMode::RemoveEdge); - // Create context menu QAction* action = new QAction(tr("Remove"), this); action->setShortcut(QString::fromLatin1("Del")); @@ -150,6 +144,12 @@ FillingEdgePanel::~FillingEdgePanel() Gui::Selection().rmvSelectionGate(); } +void FillingEdgePanel::appendButtons(Gui::ButtonGroup* buttonGroup) +{ + buttonGroup->addButton(ui->buttonUnboundEdgeAdd, int(SelectionMode::AppendEdge)); + buttonGroup->addButton(ui->buttonUnboundEdgeRemove, int(SelectionMode::RemoveEdge)); +} + // stores object pointer, its old fill type and adjusts radio buttons according to it. void FillingEdgePanel::setEditedObject(Surface::Filling* fea) { @@ -296,9 +296,9 @@ bool FillingEdgePanel::reject() void FillingEdgePanel::on_buttonUnboundEdgeAdd_toggled(bool checked) { if (checked) { - selectionMode = AppendEdge; // 'selectionMode' is passed by reference and changed when the filter is deleted Gui::Selection().addSelectionGate(new ShapeSelection(selectionMode, editedObject)); + selectionMode = AppendEdge; } else if (selectionMode == AppendEdge) { exitSelectionMode(); @@ -308,9 +308,9 @@ void FillingEdgePanel::on_buttonUnboundEdgeAdd_toggled(bool checked) void FillingEdgePanel::on_buttonUnboundEdgeRemove_toggled(bool checked) { if (checked) { - selectionMode = RemoveEdge; // 'selectionMode' is passed by reference and changed when the filter is deleted Gui::Selection().addSelectionGate(new ShapeSelection(selectionMode, editedObject)); + selectionMode = RemoveEdge; } else if (selectionMode == RemoveEdge) { exitSelectionMode(); diff --git a/src/Mod/Surface/Gui/TaskFillingEdge.h b/src/Mod/Surface/Gui/TaskFillingEdge.h index a9d8d0bd52..5ff0b44fae 100644 --- a/src/Mod/Surface/Gui/TaskFillingEdge.h +++ b/src/Mod/Surface/Gui/TaskFillingEdge.h @@ -64,7 +64,6 @@ protected: private: Ui_TaskFillingEdge* ui; ViewProviderFilling* vp; - Gui::ButtonGroup *buttonGroup; public: FillingEdgePanel(ViewProviderFilling* vp, Surface::Filling* obj); @@ -75,6 +74,7 @@ public: bool accept(); bool reject(); void setEditedObject(Surface::Filling* obj); + void appendButtons(Gui::ButtonGroup *); protected: void changeEvent(QEvent *e) override; diff --git a/src/Mod/Surface/Gui/TaskFillingVertex.cpp b/src/Mod/Surface/Gui/TaskFillingVertex.cpp index b51114682e..3d38679764 100644 --- a/src/Mod/Surface/Gui/TaskFillingVertex.cpp +++ b/src/Mod/Surface/Gui/TaskFillingVertex.cpp @@ -117,12 +117,6 @@ FillingVertexPanel::FillingVertexPanel(ViewProviderFilling* vp, Surface::Filling checkCommand = true; setEditedObject(obj); - // Set up button group - buttonGroup = new Gui::ButtonGroup(this); - buttonGroup->setExclusive(true); - buttonGroup->addButton(ui->buttonVertexAdd, (int)SelectionMode::AppendVertex); - buttonGroup->addButton(ui->buttonVertexRemove, (int)SelectionMode::RemoveVertex); - // Create context menu QAction* action = new QAction(tr("Remove"), this); action->setShortcut(QString::fromLatin1("Del")); @@ -142,6 +136,12 @@ FillingVertexPanel::~FillingVertexPanel() Gui::Selection().rmvSelectionGate(); } +void FillingVertexPanel::appendButtons(Gui::ButtonGroup* buttonGroup) +{ + buttonGroup->addButton(ui->buttonVertexAdd, int(SelectionMode::AppendVertex)); + buttonGroup->addButton(ui->buttonVertexRemove, int(SelectionMode::RemoveVertex)); +} + // stores object pointer, its old fill type and adjusts radio buttons according to it. void FillingVertexPanel::setEditedObject(Surface::Filling* obj) { @@ -233,9 +233,9 @@ void FillingVertexPanel::slotDeletedObject(const Gui::ViewProviderDocumentObject void FillingVertexPanel::on_buttonVertexAdd_toggled(bool checked) { if (checked) { - selectionMode = AppendVertex; // 'selectionMode' is passed by reference and changed when the filter is deleted Gui::Selection().addSelectionGate(new VertexSelection(selectionMode, editedObject)); + selectionMode = AppendVertex; } else if (selectionMode == AppendVertex) { exitSelectionMode(); @@ -245,9 +245,9 @@ void FillingVertexPanel::on_buttonVertexAdd_toggled(bool checked) void FillingVertexPanel::on_buttonVertexRemove_toggled(bool checked) { if (checked) { - selectionMode = RemoveVertex; // 'selectionMode' is passed by reference and changed when the filter is deleted Gui::Selection().addSelectionGate(new VertexSelection(selectionMode, editedObject)); + selectionMode = RemoveVertex; } else if (selectionMode == RemoveVertex) { exitSelectionMode(); diff --git a/src/Mod/Surface/Gui/TaskFillingVertex.h b/src/Mod/Surface/Gui/TaskFillingVertex.h index 8db330bd3f..ad7ef6880e 100644 --- a/src/Mod/Surface/Gui/TaskFillingVertex.h +++ b/src/Mod/Surface/Gui/TaskFillingVertex.h @@ -63,7 +63,6 @@ protected: private: Ui_TaskFillingVertex* ui; ViewProviderFilling* vp; - Gui::ButtonGroup *buttonGroup; public: FillingVertexPanel(ViewProviderFilling* vp, Surface::Filling* obj); @@ -73,6 +72,7 @@ public: void reject(); void checkOpenCommand(); void setEditedObject(Surface::Filling* obj); + void appendButtons(Gui::ButtonGroup *); protected: void changeEvent(QEvent *e) override;