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)
35 class Handle_AIS_InteractiveObject;
39 * A redefinition of standard AIS Interactive Object in order to provide colored presentation of
40 * a list of shapes. It contains a shapes where the parameter feature refers. It processes the following
41 * types of attributes: ModelAPI_AttributeSelectionList, ModelAPI_AttributeRefAttr,
42 * ModelAPI_AttributeSelection and ModelAPI_AttributeReference.
43 * The selection for this presentation is absent.
45 class PartSet_OperationPrs : public ViewerData_AISShape
49 Standard_EXPORT PartSet_OperationPrs(ModuleBase_IWorkshop* theWorkshop);
51 /// Returns true if the feature contains shapes or results
54 /// Sets the colors for the presentation compute
55 /// \param theColor an argument shapes color
56 void setShapeColor(const Quantity_Color& theColor);
58 /// Switch on using of the AIS presentation with of the shape object increased on the delta
61 DEFINE_STANDARD_RTTI(PartSet_OperationPrs)
64 /// Redefinition of virtual function
65 Standard_EXPORT virtual void Compute(
66 const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
67 const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
69 /// Redefinition of virtual function
70 Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
71 const Standard_Integer aMode) ;
74 /// list of visualized shapes
75 /// \return a map of shapes
76 NCollection_DataMap<TopoDS_Shape, Handle_AIS_InteractiveObject>& shapesMap();
79 /// Fills the map by the feature object and shapes, which should be visuaziled
80 /// Gets feature attributes, collect objects to whom the attributes refer
81 /// \param theFeature a current feature
82 /// \param theWorkshop a current workshop
83 /// \param theObjectShapes an output map
84 /// \param theObjectShape an output map of objects
85 static void getFeatureShapes(const FeaturePtr& theFeature,
86 ModuleBase_IWorkshop* theWorkshop,
87 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
89 /// Fills the map by the feature object and shapes, which should be visuaziled
90 /// Gets feature attributes, collect objects to whom the attributes refer
91 /// \param theFeature a current feature
92 /// \param theWorkshop a current workshop
93 /// \param theObjectShapes an output map
94 /// \param theObjectShape an output map of objects
95 static void getResultShapes(const FeaturePtr& theFeature,
96 ModuleBase_IWorkshop* theWorkshop,
97 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes,
98 const bool theListShouldBeCleared = true);
100 /// Fills the map by the feature object and shapes, which should be visuaziled
101 /// Gets the active widget, obtain the highlighted presentations if it has such and
102 /// fill map by object and shapes
103 /// \param theWorkshop a current workshop
104 /// \param theObjectShapes an output map of objects
105 static void getHighlightedShapes(ModuleBase_IWorkshop* theWorkshop,
106 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
108 /// Returns true if the attribute type belong to reference attribute
109 /// \param theAttribute an attribute
110 /// \return a boolean value
111 static bool isSelectionAttribute(const AttributePtr& theAttribute);
113 /// Appends the shape for the result into the container if the result is visible and
114 /// the shape is not null.
115 /// \param theWorkshop a current workshop
116 /// \param theResult an object to be appended
117 /// \param theGeomShape a shape to be appended
118 /// \param theObjectShapes a filled container
119 static void addValue(const ObjectPtr& theObject, const GeomShapePtr& theShape,
120 const FeaturePtr& theFeature, ModuleBase_IWorkshop* theWorkshop,
121 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
123 /// Appends the shape for the result into the container if the result is visible and
124 /// the shape is not null.
125 /// \param theWorkshop a current workshop
126 /// \param theObject an object to be appended
127 /// \param theGeomShape a shape to be appended
128 /// \param theObjectShapes a filled container
129 static void appendShapeIfVisible(ModuleBase_IWorkshop* theWorkshop,
130 const ObjectPtr& theObject,
131 GeomShapePtr theGeomShape,
132 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
134 /// Fills the list of shapes by map of model objects
135 /// \param theFeatureShape a container to find shapes
136 /// \param theShapesMap an out container
137 static void fillShapeList(const QMap<ObjectPtr, QList<GeomShapePtr> >& theFeatureShapes,
138 ModuleBase_IWorkshop* theWorkshop,
139 NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)>& theShapeToPrsMap);
142 /// list of visualized shapes
143 NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)> myShapeToPrsMap;
145 ModuleBase_IWorkshop* myWorkshop; /// current workshop
146 Quantity_Color myShapeColor; /// color of feature depended shapes
148 /// flag if the width of a shape object should be used for the shape visualization
151 friend class PartSet_CustomPrs;