Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / PartSet / PartSet_OperationPrs.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_OperationPrs.h
4 // Created:     01 Jul 2015
5 // Author:      Natalia ERMOLAEVA
6
7 #ifndef PartSet_OperationPrs_H
8 #define PartSet_OperationPrs_H
9
10 #include "PartSet.h"
11
12 #include <ModelAPI_Object.h>
13 #include <ModelAPI_Feature.h>
14 #include <ModelAPI_Result.h>
15 #include <ModelAPI_Attribute.h>
16
17 #include <ModuleBase_IWorkshop.h>
18
19 #include <GeomAPI_Shape.h>
20
21 #include <ViewerData_AISShape.hxx>
22 #include <Standard_DefineHandle.hxx>
23
24 #include <Quantity_Color.hxx>
25 #include <NCollection_List.hxx>
26 #include <NCollection_DataMap.hxx>
27 #include <TopoDS_Shape.hxx>
28 #include <AIS_InteractiveObject.hxx>
29
30 #include <QMap>
31 #include <QList>
32
33 #include <list>
34
35 DEFINE_STANDARD_HANDLE(PartSet_OperationPrs, ViewerData_AISShape)
36
37 class XGUI_Displayer;
38 class SelectMgr_Selection;
39
40 /**
41 * \ingroup GUI
42 * A redefinition of standard AIS Interactive Object in order to provide colored presentation of
43 * a list of shapes. It contains a shapes where the parameter feature refers. It processes the following
44 * types of attributes: ModelAPI_AttributeSelectionList, ModelAPI_AttributeRefAttr,
45 * ModelAPI_AttributeSelection and ModelAPI_AttributeReference.
46 * The selection for this presentation is absent.
47 */
48 class PartSet_OperationPrs : public ViewerData_AISShape
49 {
50 public:
51   /// Constructor
52   Standard_EXPORT PartSet_OperationPrs(ModuleBase_IWorkshop* theWorkshop);
53
54   /// Returns true if the feature contains shapes or results
55   bool hasShapes();
56
57   /// Sets the colors for the presentation compute
58   /// \param theColor an argument shapes color
59   void setShapeColor(const Quantity_Color& theColor);
60
61   /// Switch on using of the AIS presentation with of the shape object increased on the delta
62   void useAISWidth();
63
64   DEFINE_STANDARD_RTTIEXT(PartSet_OperationPrs, ViewerData_AISShape)
65
66 protected:
67   /// Redefinition of virtual function
68   Standard_EXPORT virtual void Compute(
69             const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
70             const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
71
72   /// Redefinition of virtual function
73   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
74                                                 const Standard_Integer aMode) ;
75
76 protected:
77   /// list of visualized shapes
78   /// \return a map of shapes
79   NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)>& shapesMap();
80
81 private:
82   /// Fills the map by the feature object and shapes, which should be visuaziled
83   /// Gets feature attributes, collect objects to whom the attributes refer
84   /// \param theFeature a current feature
85   /// \param theWorkshop a current workshop
86   /// \param theObjectShapes an output map
87   /// \param theObjectShape an output map of objects
88   static void getFeatureShapes(const FeaturePtr& theFeature,
89                                ModuleBase_IWorkshop* theWorkshop,
90                                QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
91
92   /// Fills the map by the feature object and shapes, which should be visuaziled
93   /// Gets feature attributes, collect objects to whom the attributes refer
94   /// \param theFeature a current feature
95   /// \param theWorkshop a current workshop
96   /// \param theObjectShapes an output map
97   /// \param theObjectShape an output map of objects
98   static void getResultShapes(const FeaturePtr& theFeature,
99                               ModuleBase_IWorkshop* theWorkshop,
100                               QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes,
101                               const bool theListShouldBeCleared = true);
102
103   /// Fills the map by the feature object and shapes, which should be visuaziled
104   /// Gets the active widget, obtain the highlighted presentations if it has such and
105   /// fill map by object and shapes
106   /// \param theWorkshop a current workshop
107   /// \param theObjectShapes an output map of objects
108   static void getHighlightedShapes(ModuleBase_IWorkshop* theWorkshop,
109                                    QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
110
111   /// Returns true if the attribute type belong to reference attribute
112   /// \param theAttribute an attribute
113   /// \return a boolean value
114   static bool isSelectionAttribute(const AttributePtr& theAttribute);
115
116   /// Appends the shape for the result into the container if the result is visible and
117   /// the shape is not null.
118   /// \param theWorkshop a current workshop
119   /// \param theResult an object to be appended
120   /// \param theGeomShape a shape to be appended
121   /// \param theObjectShapes a filled container
122   static void addValue(const ObjectPtr& theObject, const GeomShapePtr& theShape,
123                 const FeaturePtr& theFeature, ModuleBase_IWorkshop* theWorkshop,
124                 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
125
126   /// Appends the shape for the result into the container if the result is visible and
127   /// the shape is not null.
128   /// \param theWorkshop a current workshop
129   /// \param theObject an object to be appended
130   /// \param theGeomShape a shape to be appended
131   /// \param theObjectShapes a filled container
132   static void appendShapeIfVisible(ModuleBase_IWorkshop* theWorkshop,
133                                    const ObjectPtr& theObject,
134                                    GeomShapePtr theGeomShape,
135                                    QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
136
137   /// Fills the list of shapes by map of model objects
138   /// \param theFeatureShape a container to find shapes
139   /// \param theShapesMap an out container
140   static void fillShapeList(const QMap<ObjectPtr, QList<GeomShapePtr> >& theFeatureShapes,
141           ModuleBase_IWorkshop* theWorkshop,
142           NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)>& theShapeToPrsMap);
143
144 private:
145   /// list of visualized shapes
146   NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)> myShapeToPrsMap;
147
148   ModuleBase_IWorkshop* myWorkshop; /// current workshop
149   Quantity_Color myShapeColor; /// color of feature depended shapes
150
151   /// flag if the width of a shape object should be used for the shape visualization
152   bool myUseAISWidth;
153
154   friend class PartSet_CustomPrs;
155 };
156
157
158 #endif