Gui: [skip ci] add method to get bounding boxes of the fixed and movable groups of manual alignment

This commit is contained in:
wmayer
2020-01-17 23:00:26 +01:00
parent 298b1d49ac
commit fbd51918ff
2 changed files with 31 additions and 0 deletions

View File

@@ -244,6 +244,21 @@ int AlignmentGroup::count() const
return this->_views.size();
}
Base::BoundBox3d AlignmentGroup::getBoundingBox() const
{
Base::BoundBox3d box;
std::vector<Gui::ViewProviderDocumentObject*>::const_iterator it;
for (it = this->_views.begin(); it != this->_views.end(); ++it) {
if ((*it)->isDerivedFrom(Gui::ViewProviderGeometryObject::getClassTypeId())) {
App::GeoFeature* geo = static_cast<App::GeoFeature*>((*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<MovableGroup>::const_iterator it;
for (it = this->_groups.begin(); it != this->_groups.end(); ++it) {
box.Add(it->getBoundingBox());
}
return box;
}
// ------------------------------------------------------------------
namespace Gui {

View File

@@ -25,6 +25,7 @@
#define GUI_MANUALALIGNMENT_H
#include <QPointer>
#include <Base/BoundBox.h>
#include <Base/Placement.h>
#include <Base/Vector3D.h>
#include <Gui/Application.h>
@@ -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<PickedPoint> _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();