Class for managing internal and external geometry as a single object. More...
#include <GeoList.h>
Public Member Functions | |
GeoListModel (const GeoListModel &)=delete | |
GeoListModel (GeoListModel &&)=default | |
std::vector< T > & | geometryList () |
return a reference to the internal geometry list vector. More... | |
int | getExternalCount () const |
returns the amount of external geometry objects. More... | |
Sketcher::GeoElementId | getGeoElementIdFromVertexId (int vertexId) |
Obtain a GeoElementId class {GeoId, Pos} given a VertexId. More... | |
int | getGeoIdFromGeomListIndex (int index) const |
returns the GeoId index from the index in the geometry in geomlist format with which it was constructed. More... | |
const Sketcher::GeometryFacade * | getGeometryFacadeFromGeoId (int geoId) const |
returns a geometryfacade More... | |
const Part::Geometry * | getGeometryFromGeoId (int geoId) const |
returns the geometry given by the GeoId More... | |
int | getInternalCount () const |
returns the amount of internal (normal, non-external) geometry objects. More... | |
Vector3d | getPoint (const GeoElementId &geid) const |
Returns a point coordinates given GeoElementId {GeoId, Pos}. More... | |
Vector3d | getPoint (int geoId, Sketcher::PointPos pos) const |
Returns a point coordinates given {GeoId, Pos}. More... | |
int | getVertexIdFromGeoElementId (const Sketcher::GeoElementId &geoelementId) const |
Given an GeoElementId {GeoId, Pos}, it returns the index of the vertex in VertexId format. More... | |
GeoListModel & | operator= (const GeoListModel &)=delete |
GeoListModel & | operator= (GeoListModel &&)=default |
~GeoListModel () | |
~GeoListModel () | |
Destructor having type dependent behaviour. More... | |
Static Public Member Functions | |
static const GeoListModel< T > | getGeoListModel (const std::vector< T > &geometrylist, int intgeocount) |
static GeoListModel< T > | getGeoListModel (std::vector< T > &&geometrylist, int intgeocount, bool ownerT=false) |
GeoListModel manages the lifetime of its internal std::vector. More... | |
static const Sketcher::GeometryFacade * | getGeometryFacadeFromGeoId (const std::vector< T > &geometrylist, int geoId) |
returns a geometry facade More... | |
static const Part::Geometry * | getGeometryFromGeoId (const std::vector< T > &geometrylist, int geoId) |
returns the geometry given by the GeoId in the geometrylist in geomlist format provided as a parameter. More... | |
Public Attributes | |
std::vector< T > | geomlist |
Protected Member Functions | |
GeoListModel (const std::vector< GeometryFacadeUniquePtr > &geometrylist, int intgeocount) | |
GeoListModel (const std::vector< T > &geometrylist, int intgeocount) | |
GeoListModel (std::vector< GeometryFacadeUniquePtr > &&geometrylist, int intgeocount, bool ownerT) | |
GeoListModel (std::vector< T > &&geometrylist, int intgeocount, bool ownerT=false) | |
Constructors are protected, use static methods getGeoListModel() to construct the objects instead. More... | |
Class for managing internal and external geometry as a single object.
Internal and external geometries are present in a single geometry vector one after the other.
This class follows the format used by solver facade (sketch.cpp) in: getSolvedSketch().extractGeometry() and by SketchObject in getCompleteGeometry(). Care should be taken that the former may provide the list with a deep copy of the geometry pointers, whereas the second just provides a shallow copy of the pointers.
This class is templated to allow instantiations with list elements being legacy naked pointers (Part::Geometry *) and GeometryFacade smart pointer objects. Convenience typedefs are provided:
using GeoList = GeoListModel<GeometryPtr>; using GeoListFacade = GeoListModel<GeometryFacadeUniquePtr>;
with: using GeometryPtr = Part::Geometry *; using GeometryFacadeUniquePtr = std::unique_ptr<const Sketcher::GeometryFacade>;
N.B.: Note that the index of the geomlist (all layers) and the GeoId can be converted from each other as needed using the member functions (and sometimes the static functions).
|
explicitprotected |
Constructors are protected, use static methods getGeoListModel() to construct the objects instead.
Constructs the object from a list of geometry in geomlist format and the number of internal geometries (non external) present in the list.
geometrylist | the geometry in geomlist format (external after internal in a single vector). |
intgeocount | the number of internal geometries (non external) in the list. |
ownerT | indicates whether the GeoListModel takes ownership of the elements of the std::vector<T> (for pointers) |
|
explicitprotected |
GeoListModel::~GeoListModel |
Destructor having type dependent behaviour.
For GeoListFacade, the smart pointers will be deleted. However, a GeometryFacade does * not * delete the underlying naked pointers by default (which is mostly the desired behaviour as the ownership of the pointers belongs to sketchObject). If GeometryFacade is to delete the underlying naked pointers (because it is a temporal deep copy), then the GeometryFacade needs to get ownership (see setOwner method).
|
delete |
|
default |
|
protected |
|
protected |
Sketcher::GeoListModel< std::unique_ptr< constSketcher::GeometryFacade > >::~GeoListModel | ( | ) |
std::vector< T > & Sketcher::GeoListModel< T >::geometryList | ( | ) |
return a reference to the internal geometry list vector.
References Sketcher::GeoListModel< T >::geomlist.
int Sketcher::GeoListModel< T >::getExternalCount | ( | ) | const |
returns the amount of external geometry objects.
References Sketcher::GeoListModel< T >::geomlist.
Referenced by SketcherGui::EditModeConstraintCoinManager::processConstraints().
Sketcher::GeoElementId GeoListModel::getGeoElementIdFromVertexId | ( | int | vertexId | ) |
Obtain a GeoElementId class {GeoId, Pos} given a VertexId.
A vertexId is a positive index of the vertex, where indices of external geometry taken higher positive values than normal geometry. It is the same format of vertex numbering used in the Sketcher, Sketch.cpp, and ViewProviderSketch.
returns the GeoId index from the index in the geometry in geomlist format with which it was constructed.
index | the index of the list of geometry in geomlist format. |
Referenced by SketcherGui::EditModeGeometryCoinConverter::convert().
|
static |
|
static |
GeoListModel manages the lifetime of its internal std::vector.
This means that while the actual ownership of the T parameter needs to be specified or separately handled. In the absence of that, a new vector will be created and the T elements shallow copied to the internal vector.
The constness of the GeoListModel is tied to the constness of the std::vector from which it is constructed.
References draftfunctions.move::move().
Referenced by Sketcher::Sketch::extractGeoListFacade(), and Sketcher::SketchObject::getGeoListFacade().
|
static |
returns a geometry facade
This is not a problem when the model of the list is a std::unique_ptr<Sketcher::GeometryFacade>, because the lifetime is tied to the model itself.
References Sketcher::GeometryFacade::getFacade().
const Sketcher::GeometryFacade * GeoListModel::getGeometryFacadeFromGeoId | ( | int | geoId | ) | const |
returns a geometryfacade
This is not a problem when the model of the list is a std::unique_ptr<Sketcher::GeometryFacade>, because the lifetime is tied to the GeometryFacade. It will destruct the pointer if it is the owner.
References Sketcher::GeoListModel< T >::getGeometryFacadeFromGeoId().
Referenced by SketcherGui::EditModeGeometryCoinConverter::convert(), Sketcher::GeoListModel< T >::getGeometryFacadeFromGeoId(), and SketcherGui::EditModeGeometryCoinManager::updateGeometryColor().
|
static |
returns the geometry given by the GeoId in the geometrylist in geomlist format provided as a parameter.
geometrylist | the geometry in geomlist format (external after internal in a single vector). |
index | the index of the list of geometry in geomlist format. |
const Part::Geometry * GeoListModel::getGeometryFromGeoId | ( | int | geoId | ) | const |
returns the geometry given by the GeoId
References Sketcher::GeoListModel< T >::getGeometryFromGeoId().
Referenced by SketcherGui::EditModeConstraintCoinManager::drawConstraintIcons(), Sketcher::GeoListModel< T >::getGeometryFromGeoId(), and SketcherGui::EditModeConstraintCoinManager::processConstraints().
int Sketcher::GeoListModel< T >::getInternalCount | ( | ) | const |
returns the amount of internal (normal, non-external) geometry objects.
Referenced by Sketcher::getGeoListFacade(), and SketcherGui::EditModeConstraintCoinManager::processConstraints().
Base::Vector3d GeoListModel::getPoint | ( | const GeoElementId & | geid | ) | const |
Returns a point coordinates given GeoElementId {GeoId, Pos}.
References Sketcher::GeoElementId::GeoId, draftguitools.gui_tool_utils::getPoint, and Sketcher::GeoElementId::Pos.
Referenced by ArchStructure.CommandStructuralSystem::Activated(), PathScripts.PathOpGui.TaskPanelBaseLocationPage::addLocation(), PathScripts.PathDressupTagGui.PathDressupTagTaskPanel::addNewTag(), PathScripts.PathOpGui.TaskPanelBaseLocationPage::editLocation(), PathScripts.PathDressupTagGui.PathDressupTagTaskPanel::editTag(), draftguitools.gui_arcs.Arc_3Points::getPoint(), ArchCurtainWall.CommandArchCurtainWall::getPoint(), ArchTruss.CommandArchTruss::getPoint(), PathScripts.PathDressupTagGui.PathDressupTagTaskPanel::modifyStandardButtons(), and PathScripts.PathOpGui.TaskPanelBaseLocationPage::modifyStandardButtons().
Base::Vector3d GeoListModel::getPoint | ( | int | geoId, |
Sketcher::PointPos | pos | ||
) | const |
Returns a point coordinates given {GeoId, Pos}.
References draftguitools.gui_tool_utils::getPoint.
Referenced by ArchStructure.CommandStructuralSystem::Activated(), PathScripts.PathOpGui.TaskPanelBaseLocationPage::addLocation(), PathScripts.PathDressupTagGui.PathDressupTagTaskPanel::addNewTag(), SketcherGui::EditModeConstraintCoinManager::drawConstraintIcons(), PathScripts.PathOpGui.TaskPanelBaseLocationPage::editLocation(), PathScripts.PathDressupTagGui.PathDressupTagTaskPanel::editTag(), draftguitools.gui_arcs.Arc_3Points::getPoint(), ArchCurtainWall.CommandArchCurtainWall::getPoint(), ArchTruss.CommandArchTruss::getPoint(), PathScripts.PathDressupTagGui.PathDressupTagTaskPanel::modifyStandardButtons(), PathScripts.PathOpGui.TaskPanelBaseLocationPage::modifyStandardButtons(), and SketcherGui::EditModeConstraintCoinManager::processConstraints().
int GeoListModel::getVertexIdFromGeoElementId | ( | const Sketcher::GeoElementId & | geoelementId | ) | const |
Given an GeoElementId {GeoId, Pos}, it returns the index of the vertex in VertexId format.
A vertexId is a positive index of the vertex, where indices of external geometry taken higher positive values than normal geometry. It is the same format of vertex numbering used in the Sketcher, Sketch.cpp, and ViewProviderSketch.
References DraftVecUtils::find().
|
delete |
|
default |
std::vector<T> Sketcher::GeoListModel< T >::geomlist |
Referenced by SketcherGui::EditModeGeometryCoinConverter::convert(), SketcherGui::ViewProviderSketch::draw(), Sketcher::GeoListModel< T >::GeoListModel(), Sketcher::GeoListModel< T >::geometryList(), Sketcher::GeoListModel< T >::getExternalCount(), Sketcher::getGeoListFacade(), and SketcherGui::EditModeConstraintCoinManager::processConstraints().