Salome HOME
#1119 Confirmation box for deleting parts
[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   /// Return true if the object is visible. If the object is feature, it returns true
78   /// if all results of the feature are shown
79   /// \param theDisplayer a displayer
80   /// \param theObject an object
81   /// \return a boolean value
82   static bool isVisible(XGUI_Displayer* theDislayer, const ObjectPtr& theObject);
83
84   /// Fills the map by the feature object and shapes, which should be visuaziled
85   /// Gets feature attributes, collect objects to whom the attributes refer
86   /// \param theFeature a current feature
87   /// \param theWorkshop a current workshop
88   /// \param theObjectShapes an output map
89   /// \param theObjectShape an output map of objects
90   static void getFeatureShapes(const FeaturePtr& theFeature,
91                                ModuleBase_IWorkshop* theWorkshop,
92                                QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
93
94   /// Fills the map by the feature object and shapes, which should be visuaziled
95   /// Gets feature attributes, collect objects to whom the attributes refer
96   /// \param theFeature a current feature
97   /// \param theWorkshop a current workshop
98   /// \param theObjectShapes an output map
99   /// \param theObjectShape an output map of objects
100   static void getResultShapes(const FeaturePtr& theFeature,
101                               ModuleBase_IWorkshop* theWorkshop,
102                               QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes,
103                               const bool theListShouldBeCleared = true);
104
105   /// Fills the map by the feature object and shapes, which should be visuaziled
106   /// Gets the active widget, obtain the highlighted presentations if it has such and
107   /// fill map by object and shapes
108   /// \param theWorkshop a current workshop
109   /// \param theObjectShapes an output map of objects
110   static void getHighlightedShapes(ModuleBase_IWorkshop* theWorkshop,
111                                    QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
112
113   /// Returns true if the attribute type belong to reference attribute
114   /// \param theAttribute an attribute
115   /// \return a boolean value
116   static bool isSelectionAttribute(const AttributePtr& theAttribute);
117
118   /// Appends the shape for the result into the container if the result is visible and
119   /// the shape is not null.
120   /// \param theWorkshop a current workshop
121   /// \param theResult an object to be appended
122   /// \param theGeomShape a shape to be appended
123   /// \param theObjectShapes a filled container
124   static void addValue(const ObjectPtr& theObject, const GeomShapePtr& theShape,
125                 const FeaturePtr& theFeature, ModuleBase_IWorkshop* theWorkshop,
126                 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
127
128   /// Appends the shape for the result into the container if the result is visible and
129   /// the shape is not null.
130   /// \param theWorkshop a current workshop
131   /// \param theObject an object to be appended
132   /// \param theGeomShape a shape to be appended
133   /// \param theObjectShapes a filled container
134   static void appendShapeIfVisible(ModuleBase_IWorkshop* theWorkshop,
135                                    const ObjectPtr& theObject,
136                                    GeomShapePtr theGeomShape,
137                                    QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
138
139 private:
140   QMap<ObjectPtr, QList<GeomShapePtr> > myFeatureShapes; /// visualized shapes
141
142   ModuleBase_IWorkshop* myWorkshop; /// current workshop
143   Quantity_Color myShapeColor; /// color of feature depended shapes
144   bool myUseAISWidth; /// flag if the width of a shape object should be used for the shape visualization
145
146   friend class PartSet_CustomPrs;
147 };
148
149
150 #endif