From 5fc83687538cb83c65c973b81912bac1883310e1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 17 Sep 2018 17:06:58 +0200 Subject: [PATCH] add convenience method addSelection(SelectionObject) --- src/Gui/Selection.cpp | 21 +++++++++++++++++++++ src/Gui/Selection.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/src/Gui/Selection.cpp b/src/Gui/Selection.cpp index ff33f586d0..13a2124aa0 100644 --- a/src/Gui/Selection.cpp +++ b/src/Gui/Selection.cpp @@ -773,6 +773,27 @@ bool SelectionSingleton::addSelection(const char* pDocName, const char* pObjectN } } +bool SelectionSingleton::addSelection(const SelectionObject& obj) +{ + const std::vector& subNames = obj.getSubNames(); + const std::vector points = obj.getPickedPoints(); + if (!subNames.empty() && subNames.size() == points.size()) { + bool ok = true; + for (std::size_t i=0; i(pnt.x), + static_cast(pnt.y), + static_cast(pnt.z)); + } + return ok; + } + else { + return addSelection(obj.getDocName(), obj.getFeatName(), subNames); + } +} + void SelectionSingleton::rmvSelection(const char* pDocName, const char* pObjectName, const char* pSubName) { std::vector rmvList; diff --git a/src/Gui/Selection.h b/src/Gui/Selection.h index 02d4925e5a..e68988191f 100644 --- a/src/Gui/Selection.h +++ b/src/Gui/Selection.h @@ -222,6 +222,8 @@ public: bool addSelection(const char* pDocName, const char* pObjectName=0, const char* pSubName=0, float x=0, float y=0, float z=0); /// Add to selection with several sub-elements bool addSelection(const char* pDocName, const char* pObjectName, const std::vector& pSubNames); + /// Add to selection + bool addSelection(const SelectionObject&); /// Remove from selection (for internal use) void rmvSelection(const char* pDocName, const char* pObjectName=0, const char* pSubName=0); /// Set the selection for a document