From fbd51918ff9c9fb2eef2a494263b3cfb28326c03 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 17 Jan 2020 23:00:26 +0100 Subject: [PATCH] Gui: [skip ci] add method to get bounding boxes of the fixed and movable groups of manual alignment --- src/Gui/ManualAlignment.cpp | 25 +++++++++++++++++++++++++ src/Gui/ManualAlignment.h | 6 ++++++ 2 files changed, 31 insertions(+) diff --git a/src/Gui/ManualAlignment.cpp b/src/Gui/ManualAlignment.cpp index 71f5546b3c..ccb0f2d8c2 100644 --- a/src/Gui/ManualAlignment.cpp +++ b/src/Gui/ManualAlignment.cpp @@ -244,6 +244,21 @@ int AlignmentGroup::count() const return this->_views.size(); } +Base::BoundBox3d AlignmentGroup::getBoundingBox() const +{ + Base::BoundBox3d box; + std::vector::const_iterator it; + for (it = this->_views.begin(); it != this->_views.end(); ++it) { + if ((*it)->isDerivedFrom(Gui::ViewProviderGeometryObject::getClassTypeId())) { + App::GeoFeature* geo = static_cast((*it)->getObject()); + const App::PropertyComplexGeoData* prop = geo->getPropertyOfGeometry(); + if (prop) + box.Add(prop->getBoundingBox()); + } + } + return box; +} + // ------------------------------------------------------------------ MovableGroup::MovableGroup() @@ -334,6 +349,16 @@ const MovableGroup& MovableGroupModel::getGroup(int i) const return this->_groups[i]; } +Base::BoundBox3d MovableGroupModel::getBoundingBox() const +{ + Base::BoundBox3d box; + std::vector::const_iterator it; + for (it = this->_groups.begin(); it != this->_groups.end(); ++it) { + box.Add(it->getBoundingBox()); + } + return box; +} + // ------------------------------------------------------------------ namespace Gui { diff --git a/src/Gui/ManualAlignment.h b/src/Gui/ManualAlignment.h index 6899886341..522f593029 100644 --- a/src/Gui/ManualAlignment.h +++ b/src/Gui/ManualAlignment.h @@ -25,6 +25,7 @@ #define GUI_MANUALALIGNMENT_H #include +#include #include #include #include @@ -123,6 +124,10 @@ public: * Return the number of added views. */ int count() const; + /** + * Get the overall bounding box of all views. + */ + Base::BoundBox3d getBoundingBox() const; protected: std::vector _pickedPoints; @@ -170,6 +175,7 @@ public: bool isEmpty() const; int count() const; const MovableGroup& getGroup(int i) const; + Base::BoundBox3d getBoundingBox() const; protected: void removeActiveGroup();