]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_OperationPrs.h
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 presentation if the feature is presentable
104   /// \param theFeature a current feature
105   /// \param theWorkshop a current workshop
106   /// \param theObjectShapes an output map
107   /// \param theObjectShape an output map of objects
108   static void getPresentationShapes(const FeaturePtr& theFeature,
109                               ModuleBase_IWorkshop* theWorkshop,
110                               QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes,
111                               const bool theListShouldBeCleared = true);
112
113   /// Fills the map by the feature object and shapes, which should be visuaziled
114   /// Gets the active widget, obtain the highlighted presentations if it has such and
115   /// fill map by object and shapes
116   /// \param theWorkshop a current workshop
117   /// \param theObjectShapes an output map of objects
118   static void getHighlightedShapes(ModuleBase_IWorkshop* theWorkshop,
119                                    QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
120
121   /// Returns true if the attribute type belong to reference attribute
122   /// \param theAttribute an attribute
123   /// \return a boolean value
124   static bool isSelectionAttribute(const AttributePtr& theAttribute);
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 theResult an object to be appended
130   /// \param theGeomShape a shape to be appended
131   /// \param theObjectShapes a filled container
132   static void addValue(const ObjectPtr& theObject, const GeomShapePtr& theShape,
133                 const FeaturePtr& theFeature, ModuleBase_IWorkshop* theWorkshop,
134                 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
135
136   /// Appends the shape for the result into the container if the result is visible and
137   /// the shape is not null.
138   /// \param theWorkshop a current workshop
139   /// \param theObject an object to be appended
140   /// \param theGeomShape a shape to be appended
141   /// \param theObjectShapes a filled container
142   static void appendShapeIfVisible(ModuleBase_IWorkshop* theWorkshop,
143                                    const ObjectPtr& theObject,
144                                    GeomShapePtr theGeomShape,
145                                    QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
146
147   /// Fills the list of shapes by map of model objects
148   /// \param theFeatureShape a container to find shapes
149   /// \param theShapesMap an out container
150   static void fillShapeList(const QMap<ObjectPtr, QList<GeomShapePtr> >& theFeatureShapes,
151           ModuleBase_IWorkshop* theWorkshop,
152           NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)>& theShapeToPrsMap);
153
154 private:
155   /// list of visualized shapes
156   NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)> myShapeToPrsMap;
157
158   ModuleBase_IWorkshop* myWorkshop; /// current workshop
159   Quantity_Color myShapeColor; /// color of feature depended shapes
160
161   /// flag if the width of a shape object should be used for the shape visualization
162   bool myUseAISWidth;
163
164   friend class PartSet_CustomPrs;
165 };
166
167
168 #endif