From adc4b4a641f227c2cf9b7b9b583a0fc2fef5f9bb Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 17 Sep 2018 17:27:21 +0200 Subject: [PATCH] remove limit to only allow vertexes of a model --- src/Gui/Placement.cpp | 25 ++++++++----------------- src/Gui/Placement.h | 8 ++++++-- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/Gui/Placement.cpp b/src/Gui/Placement.cpp index 9db46cf97a..f253f85900 100644 --- a/src/Gui/Placement.cpp +++ b/src/Gui/Placement.cpp @@ -82,11 +82,7 @@ public: Placement::Placement(QWidget* parent, Qt::WindowFlags fl) : Gui::LocationDialog(parent, fl) { - std::vector selection = Gui::Selection().getSelectionEx(); - if (selection.size()>=1){ - documentName = selection[0].getDocName(); //save info so we can reselect - featureName = selection[0].getFeatName(); //after select points button clicked - } + selectionObjects = Gui::Selection().getSelectionEx(); propertyName = "Placement"; // default name ui = new Ui_PlacementComp(this); @@ -310,17 +306,14 @@ void Placement::on_selectedVertex_clicked() bool success=false; std::vector selection = Gui::Selection().getSelectionEx(); std::vector picked; - std::vector subnames; - //combine all pickedpoints and subnames into single vectors + //combine all pickedpoints into single vector //even if points are from separate objects for (std::vector::iterator it=selection.begin(); it!=selection.end(); ++it){ std::vector points = it->getPickedPoints(); picked.insert(picked.begin(),points.begin(),points.end()); - std::vector names = it->getSubNames(); - subnames.insert(subnames.begin(),names.begin(),names.end()); } - if (picked.size()==1 && (std::string(subnames[0]).substr(0,6)==std::string("Vertex") - || std::string(subnames[0]).substr(0,5)==std::string("Point"))){ + + if (picked.size() == 1) { ui->xCnt->setValue(picked[0].x); ui->yCnt->setValue(picked[0].y); ui->zCnt->setValue(picked[0].z); @@ -328,10 +321,8 @@ void Placement::on_selectedVertex_clicked() cntOfMass.y=picked[0].y; cntOfMass.z=picked[0].z; success=true; - } else if (picked.size()==2 && (std::string(subnames[0]).substr(0,6)==std::string("Vertex") - || std::string(subnames[0]).substr(0,5)==std::string("Point")) - && (std::string(subnames[1]).substr(0,6)==std::string("Vertex") - || std::string(subnames[1]).substr(0,5)==std::string("Point"))){ + } + else if (picked.size() == 2) { //average the coords to get center of rotation ui->xCnt->setValue((picked[0].x+picked[1].x)/2.0); ui->yCnt->setValue((picked[0].y+picked[1].y)/2.0); @@ -358,7 +349,8 @@ void Placement::on_selectedVertex_clicked() //of the same object the rotation still gets applied twice Gui::Selection().clearSelection(); //reselect original object that was selected when placment dlg first opened - Gui::Selection().addSelection(documentName.c_str(),featureName.c_str()); + for (auto it : selectionObjects) + Gui::Selection().addSelection(it); ui->rotationInput->setCurrentIndex(0); //use rotation with axis instead of euler ui->stackedWidget->setCurrentIndex(0); success=true; @@ -366,7 +358,6 @@ void Placement::on_selectedVertex_clicked() if (!success){ Base::Console().Warning("Placement selection error. Select either 1 or 2 points.\n"); - ui->xCnt->setValue(0); ui->yCnt->setValue(0); ui->zCnt->setValue(0); diff --git a/src/Gui/Placement.h b/src/Gui/Placement.h index 95e4c035c5..b194600f2e 100644 --- a/src/Gui/Placement.h +++ b/src/Gui/Placement.h @@ -24,6 +24,7 @@ #define GUI_PLACEMENT_H #include +#include #include #include #include @@ -94,8 +95,11 @@ private: Base::Vector3d cntOfMass; std::string propertyName; // the name of the placement property std::set documents; - std::string documentName; //store these so we can reselect original object - std::string featureName; //after user selects points and clicks Selected point(s) + /** + * store these so we can reselect original object + * after user selects points and clicks Selected point(s) + */ + std::vector selectionObjects; friend class TaskPlacement; };