Utils: New Function to retrieve the VisualLayerId
This commit is contained in:
committed by
abdullahtahiriyo
parent
873e34cd6e
commit
c2e0c86d93
@@ -29,6 +29,7 @@
|
||||
#include <Mod/Sketcher/App/GeoEnum.h>
|
||||
|
||||
#include "AutoConstraint.h"
|
||||
#include "ViewProviderSketchGeometryExtension.h"
|
||||
|
||||
|
||||
namespace App {
|
||||
@@ -156,5 +157,23 @@ auto toPointerVector(const std::vector<std::unique_ptr<T>> & vector) {
|
||||
return vp;
|
||||
}
|
||||
|
||||
/** returns the visual layer id (not the one of the GeometryFacade, but the index to PropertyVisualLayerList) from a geometry or GeometryFacade.
|
||||
* NOTE: If the geometry or geometryfacade does not have a corresponding ViewProviderSketchGeometryExtension, the default layer (layer 0) is returned.
|
||||
* */
|
||||
template <typename T>
|
||||
auto getSafeGeomLayerId(T geom)
|
||||
{
|
||||
int layerId = 0;
|
||||
|
||||
if(geom->hasExtension(SketcherGui::ViewProviderSketchGeometryExtension::getClassTypeId())) {
|
||||
auto vpext = std::static_pointer_cast<const SketcherGui::ViewProviderSketchGeometryExtension>(
|
||||
geom->getExtension(SketcherGui::ViewProviderSketchGeometryExtension::getClassTypeId()).lock());
|
||||
|
||||
layerId = vpext->getVisualLayerId();
|
||||
}
|
||||
|
||||
return layerId;
|
||||
}
|
||||
|
||||
#endif // SKETCHERGUI_Recompute_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user