1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_OperationPrs.h
4 // Created: 01 Jul 2015
5 // Author: Natalia ERMOLAEVA
7 #ifndef PartSet_OperationPrs_H
8 #define PartSet_OperationPrs_H
12 #include <ModelAPI_Object.h>
13 #include <ModelAPI_Feature.h>
14 #include <ModelAPI_Result.h>
15 #include <ModelAPI_Attribute.h>
17 #include <ModuleBase_IWorkshop.h>
19 #include <GeomAPI_Shape.h>
21 #include <ViewerData_AISShape.hxx>
22 #include <Standard_DefineHandle.hxx>
24 #include <Quantity_Color.hxx>
25 #include <NCollection_List.hxx>
32 DEFINE_STANDARD_HANDLE(PartSet_OperationPrs, ViewerData_AISShape)
38 * A redefinition of standard AIS Interactive Object in order to provide colored presentation of
39 * a list of shapes. It contains a shapes where the parameter feature refers. It processes the following
40 * types of attributes: ModelAPI_AttributeSelectionList, ModelAPI_AttributeRefAttr,
41 * ModelAPI_AttributeSelection and ModelAPI_AttributeReference.
42 * The selection for this presentation is absent.
44 class PartSet_OperationPrs : public ViewerData_AISShape
48 Standard_EXPORT PartSet_OperationPrs(ModuleBase_IWorkshop* theWorkshop);
50 /// Returns true if the feature contains shapes or results
53 /// Sets the colors for the presentation compute
54 /// \param theColor an argument shapes color
55 void setShapeColor(const Quantity_Color& theColor);
57 /// Switch on using of the AIS presentation with of the shape object increased on the delta
60 DEFINE_STANDARD_RTTI(PartSet_OperationPrs)
63 /// Redefinition of virtual function
64 Standard_EXPORT virtual void Compute(
65 const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
66 const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
68 /// Redefinition of virtual function
69 Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
70 const Standard_Integer aMode) ;
73 /// Returns map of feature shapes to be able to fill it outside this class, e.g. in friend
74 /// \return a map of object to shape
75 QMap<ObjectPtr, QList<GeomShapePtr> >& featureShapes() { return myFeatureShapes; }
78 /// Fills the map by the feature object and shapes, which should be visuaziled
79 /// Gets feature attributes, collect objects to whom the attributes refer
80 /// \param theFeature a current feature
81 /// \param theWorkshop a current workshop
82 /// \param theObjectShapes an output map
83 /// \param theObjectShape an output map of objects
84 static void getFeatureShapes(const FeaturePtr& theFeature,
85 ModuleBase_IWorkshop* theWorkshop,
86 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
88 /// Fills the map by the feature object and shapes, which should be visuaziled
89 /// Gets feature attributes, collect objects to whom the attributes refer
90 /// \param theFeature a current feature
91 /// \param theWorkshop a current workshop
92 /// \param theObjectShapes an output map
93 /// \param theObjectShape an output map of objects
94 static void getResultShapes(const FeaturePtr& theFeature,
95 ModuleBase_IWorkshop* theWorkshop,
96 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes,
97 const bool theListShouldBeCleared = true);
99 /// Fills the map by the feature object and shapes, which should be visuaziled
100 /// Gets the active widget, obtain the highlighted presentations if it has such and
101 /// fill map by object and shapes
102 /// \param theWorkshop a current workshop
103 /// \param theObjectShapes an output map of objects
104 static void getHighlightedShapes(ModuleBase_IWorkshop* theWorkshop,
105 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
107 /// Returns true if the attribute type belong to reference attribute
108 /// \param theAttribute an attribute
109 /// \return a boolean value
110 static bool isSelectionAttribute(const AttributePtr& theAttribute);
112 /// Appends the shape for the result into the container if the result is visible and
113 /// the shape is not null.
114 /// \param theWorkshop a current workshop
115 /// \param theResult an object to be appended
116 /// \param theGeomShape a shape to be appended
117 /// \param theObjectShapes a filled container
118 static void addValue(const ObjectPtr& theObject, const GeomShapePtr& theShape,
119 const FeaturePtr& theFeature, ModuleBase_IWorkshop* theWorkshop,
120 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
122 /// Appends the shape for the result into the container if the result is visible and
123 /// the shape is not null.
124 /// \param theWorkshop a current workshop
125 /// \param theObject an object to be appended
126 /// \param theGeomShape a shape to be appended
127 /// \param theObjectShapes a filled container
128 static void appendShapeIfVisible(ModuleBase_IWorkshop* theWorkshop,
129 const ObjectPtr& theObject,
130 GeomShapePtr theGeomShape,
131 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
133 /// Fills the list of shapes by map of model objects
134 /// \param theFeatureShape a container to find shapes
135 /// \param theShapesMap an out container
136 void fillShapeList(const QMap<ObjectPtr, QList<GeomShapePtr> >& theFeatureShapes,
137 NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)>& theShapeToPrsMap);
140 NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)> myShapeToPrsMap; /// list of visualized shapes
142 QMap<ObjectPtr, QList<GeomShapePtr> > myFeatureShapes; /// visualized shapes
144 ModuleBase_IWorkshop* myWorkshop; /// current workshop
145 Quantity_Color myShapeColor; /// color of feature depended shapes
146 bool myUseAISWidth; /// flag if the width of a shape object should be used for the shape visualization
148 friend class PartSet_CustomPrs;