From 79995368581832a7b4e1fcdc4a4d3bd1c64b07ec Mon Sep 17 00:00:00 2001 From: Pierre LeMoine Date: Thu, 31 Dec 2020 05:19:30 +0100 Subject: [PATCH] Transform patterns can be created from multiple base features The infrastructure/piping seems to have been in place for a long while. Not tested for all variations of pattern transforms. The major enabler was removing the `break`. Some extra piping added to let the code at call-site decide if to select multiple features or not. --- src/Mod/PartDesign/Gui/Command.cpp | 6 +++--- src/Mod/PartDesign/Gui/CommandBody.cpp | 2 +- src/Mod/PartDesign/Gui/TaskFeaturePick.cpp | 9 +++++++-- src/Mod/PartDesign/Gui/TaskFeaturePick.h | 4 +++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 295da09853..22be4e650b 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -821,7 +821,7 @@ void CmdPartDesignNewSketch::activated(int iMsg) Gui::Control().closeDialog(); Gui::Selection().clearSelection(); - Gui::Control().showDialog(new PartDesignGui::TaskDlgFeaturePick(planes, status, accepter, worker, quitter)); + Gui::Control().showDialog(new PartDesignGui::TaskDlgFeaturePick(planes, status, accepter, worker, true, quitter)); } } } @@ -1151,7 +1151,7 @@ void prepareProfileBased(PartDesign::Body *pcActiveBody, Gui::Command* cmd, cons Gui::Control().closeDialog(); Gui::Selection().clearSelection(); - pickDlg = new PartDesignGui::TaskDlgFeaturePick(sketches, status, accepter, sketch_worker); + pickDlg = new PartDesignGui::TaskDlgFeaturePick(sketches, status, accepter, sketch_worker, true); // Logically dead code because 'bNoSketchWasSelected' must be true //if (!bNoSketchWasSelected && extReference) // pickDlg->showExternal(true); @@ -1979,7 +1979,7 @@ void prepareTransformed(PartDesign::Body *pcActiveBody, Gui::Command* cmd, const Gui::Control().closeDialog(); Gui::Selection().clearSelection(); - Gui::Control().showDialog(new PartDesignGui::TaskDlgFeaturePick(features, status, accepter, worker)); + Gui::Control().showDialog(new PartDesignGui::TaskDlgFeaturePick(features, status, accepter, worker, false)); return; } else if (features.empty()) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid features in this document"), diff --git a/src/Mod/PartDesign/Gui/CommandBody.cpp b/src/Mod/PartDesign/Gui/CommandBody.cpp index f3efffb205..61824c58c5 100644 --- a/src/Mod/PartDesign/Gui/CommandBody.cpp +++ b/src/Mod/PartDesign/Gui/CommandBody.cpp @@ -286,7 +286,7 @@ void CmdPartDesignBody::activated(int iMsg) Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); if (!dlg) { Gui::Selection().clearSelection(); - Gui::Control().showDialog(new PartDesignGui::TaskDlgFeaturePick(planes, status, accepter, worker, quitter)); + Gui::Control().showDialog(new PartDesignGui::TaskDlgFeaturePick(planes, status, accepter, worker, true, quitter)); } } } diff --git a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp index 5d11ba6355..905323e59b 100644 --- a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp @@ -80,6 +80,7 @@ const QString TaskFeaturePick::getFeatureStatusString(const featureStatus st) TaskFeaturePick::TaskFeaturePick(std::vector& objects, const std::vector& status, + bool singleFeatureSelect, QWidget* parent) : TaskBox(Gui::BitmapFactory().pixmap("edit-select-box"), tr("Select feature"), true, parent) @@ -100,6 +101,10 @@ TaskFeaturePick::TaskFeaturePick(std::vector& objects, connect(ui->listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(onDoubleClick(QListWidgetItem *))); + if (!singleFeatureSelect) { + ui->listWidget->setSelectionMode(QAbstractItemView::ExtendedSelection); + } + enum { axisBit=0, planeBit = 1}; // NOTE: generally there shouldn't be more then one origin @@ -276,7 +281,6 @@ std::vector TaskFeaturePick::buildFeatures() result.push_back(obj); } - break; } index++; @@ -525,10 +529,11 @@ TaskDlgFeaturePick::TaskDlgFeaturePick( std::vector &objec const std::vector &status, boost::function)> afunc, boost::function)> wfunc, + bool singleFeatureSelect, boost::function abortfunc /* = NULL */ ) : TaskDialog(), accepted(false) { - pick = new TaskFeaturePick(objects, status); + pick = new TaskFeaturePick(objects, status, singleFeatureSelect); Content.push_back(pick); acceptFunction = afunc; diff --git a/src/Mod/PartDesign/Gui/TaskFeaturePick.h b/src/Mod/PartDesign/Gui/TaskFeaturePick.h index bdce4fd7d6..fa8ff1a1a9 100644 --- a/src/Mod/PartDesign/Gui/TaskFeaturePick.h +++ b/src/Mod/PartDesign/Gui/TaskFeaturePick.h @@ -58,6 +58,7 @@ public: TaskFeaturePick(std::vector &objects, const std::vector &status, + bool singleFeatureSelect, QWidget *parent = 0); ~TaskFeaturePick(); @@ -107,7 +108,8 @@ public: const std::vector &status, boost::function)> acceptfunc, boost::function)> workfunc, - boost::function abortfunc = 0 ); + bool singleFeatureSelect, + boost::function abortfunc = 0); ~TaskDlgFeaturePick(); public: