Salome HOME
Issue #1369: fix for wire base validator
[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
26 #include <QMap>
27 #include <QList>
28
29 #include <list>
30
31 DEFINE_STANDARD_HANDLE(PartSet_OperationPrs, ViewerData_AISShape)
32
33 class XGUI_Displayer;
34
35 /**
36 * \ingroup GUI
37 * A redefinition of standard AIS Interactive Object in order to provide colored presentation of
38 * a list of shapes. It contains a shapes where the parameter feature refers. It processes the following
39 * types of attributes: ModelAPI_AttributeSelectionList, ModelAPI_AttributeRefAttr,
40 * ModelAPI_AttributeSelection and ModelAPI_AttributeReference.
41 * The selection for this presentation is absent.
42 */
43 class PartSet_OperationPrs : public ViewerData_AISShape
44 {
45 public:
46   /// Constructor
47   Standard_EXPORT PartSet_OperationPrs(ModuleBase_IWorkshop* theWorkshop);
48
49   /// Returns true if the feature contains shapes or results
50   bool hasShapes();
51
52   /// Sets the colors for the presentation compute
53   /// \param theColor an argument shapes color
54   void setShapeColor(const Quantity_Color& theColor);
55
56   /// Switch on using of the AIS presentation with of the shape object increased on the delta
57   void useAISWidth();
58
59   DEFINE_STANDARD_RTTI(PartSet_OperationPrs)
60
61 protected:
62   /// Redefinition of virtual function
63   Standard_EXPORT virtual void Compute(
64             const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
65             const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
66
67   /// Redefinition of virtual function
68   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
69                                                 const Standard_Integer aMode) ;
70
71 protected:
72   /// Returns map of feature shapes to be able to fill it outside this class, e.g. in friend
73   /// \return a map of object to shape
74   QMap<ObjectPtr, QList<GeomShapePtr> >& featureShapes() { return myFeatureShapes; }
75
76 private:
77   /// Fills the map by the feature object and shapes, which should be visuaziled
78   /// Gets feature attributes, collect objects to whom the attributes refer
79   /// \param theFeature a current feature
80   /// \param theWorkshop a current workshop
81   /// \param theObjectShapes an output map
82   /// \param theObjectShape an output map of objects
83   static void getFeatureShapes(const FeaturePtr& theFeature,
84                                ModuleBase_IWorkshop* theWorkshop,
85                                QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
86
87   /// Fills the map by the feature object and shapes, which should be visuaziled
88   /// Gets feature attributes, collect objects to whom the attributes refer
89   /// \param theFeature a current feature
90   /// \param theWorkshop a current workshop
91   /// \param theObjectShapes an output map
92   /// \param theObjectShape an output map of objects
93   static void getResultShapes(const FeaturePtr& theFeature,
94                               ModuleBase_IWorkshop* theWorkshop,
95                               QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes,
96                               const bool theListShouldBeCleared = true);
97
98   /// Fills the map by the feature object and shapes, which should be visuaziled
99   /// Gets the active widget, obtain the highlighted presentations if it has such and
100   /// fill map by object and shapes
101   /// \param theWorkshop a current workshop
102   /// \param theObjectShapes an output map of objects
103   static void getHighlightedShapes(ModuleBase_IWorkshop* theWorkshop,
104                                    QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
105
106   /// Returns true if the attribute type belong to reference attribute
107   /// \param theAttribute an attribute
108   /// \return a boolean value
109   static bool isSelectionAttribute(const AttributePtr& theAttribute);
110
111   /// Appends the shape for the result into the container if the result is visible and
112   /// the shape is not null.
113   /// \param theWorkshop a current workshop
114   /// \param theResult an object to be appended
115   /// \param theGeomShape a shape to be appended
116   /// \param theObjectShapes a filled container
117   static void addValue(const ObjectPtr& theObject, const GeomShapePtr& theShape,
118                 const FeaturePtr& theFeature, ModuleBase_IWorkshop* theWorkshop,
119                 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
120
121   /// Appends the shape for the result into the container if the result is visible and
122   /// the shape is not null.
123   /// \param theWorkshop a current workshop
124   /// \param theObject an object to be appended
125   /// \param theGeomShape a shape to be appended
126   /// \param theObjectShapes a filled container
127   static void appendShapeIfVisible(ModuleBase_IWorkshop* theWorkshop,
128                                    const ObjectPtr& theObject,
129                                    GeomShapePtr theGeomShape,
130                                    QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
131
132 private:
133   QMap<ObjectPtr, QList<GeomShapePtr> > myFeatureShapes; /// visualized shapes
134
135   ModuleBase_IWorkshop* myWorkshop; /// current workshop
136   Quantity_Color myShapeColor; /// color of feature depended shapes
137   bool myUseAISWidth; /// flag if the width of a shape object should be used for the shape visualization
138
139   friend class PartSet_CustomPrs;
140 };
141
142
143 #endif