Surface: use a single button group for all task boxes
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user