Skip to content

Commit

Permalink
Gui: [skip ci] add method to get bounding boxes of the fixed and mova…
Browse files Browse the repository at this point in the history
…ble groups of manual alignment
  • Loading branch information
wwmayer committed Jan 17, 2020
1 parent 298b1d4 commit fbd5191
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Gui/ManualAlignment.cpp
Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions src/Gui/ManualAlignment.h
Expand Up @@ -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>
Expand Down Expand Up @@ -123,6 +124,10 @@ class GuiExport AlignmentGroup
* 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;
Expand Down Expand Up @@ -170,6 +175,7 @@ class GuiExport MovableGroupModel
bool isEmpty() const;
int count() const;
const MovableGroup& getGroup(int i) const;
Base::BoundBox3d getBoundingBox() const;

protected:
void removeActiveGroup();
Expand Down

0 comments on commit fbd5191

Please sign in to comment.