Salome HOME
Imrove multi-selector control to provide items multi-selection. Preferences color...
[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_Workshop;
34 class XGUI_Displayer;
35
36 /**
37 * \ingroup GUI
38 * A redefinition of standard AIS Interactive Object in order to provide colored presentation of
39 * a list of shapes. It contains a shapes where the parameter feature refers. It processes the following
40 * types of attributes: ModelAPI_AttributeSelectionList, ModelAPI_AttributeRefAttr,
41 * ModelAPI_AttributeSelection and ModelAPI_AttributeReference.
42 * The selection for this presentation is absent.
43 */
44 class PartSet_OperationPrs : public ViewerData_AISShape
45 {
46 public:
47   /// Constructor
48   Standard_EXPORT PartSet_OperationPrs(ModuleBase_IWorkshop* theWorkshop);
49
50   /// Returns true if the feature contains shapes or results
51   bool hasShapes();
52
53   /// Sets the colors for the presentation compute
54   /// \param theColor an argument shapes color
55   void setShapeColor(const Quantity_Color& theColor);
56
57   /// Switch on using of the AIS presentation with of the shape object increased on the delta
58   void useAISWidth();
59
60   DEFINE_STANDARD_RTTI(PartSet_OperationPrs)
61
62 protected:
63   /// Redefinition of virtual function
64   Standard_EXPORT virtual void Compute(
65             const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
66             const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
67
68   /// Redefinition of virtual function
69   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
70                                                 const Standard_Integer aMode) ;
71
72 protected:
73   /// Returns map of feature shapes to be able to fill it outside this class, e.g. in friend
74   /// \return a map of object to shape
75   QMap<ObjectPtr, QList<GeomShapePtr> >& featureShapes() { return myFeatureShapes; }
76
77 private:
78   /// Return true if the object is visible. If the object is feature, it returns true
79   /// if all results of the feature are shown
80   /// \param theDisplayer a displayer
81   /// \param theObject an object
82   /// \return a boolean value
83   static bool isVisible(XGUI_Displayer* theDislayer, const ObjectPtr& theObject);
84
85   /// Fills the map by the feature object and shapes, which should be visuaziled
86   /// Gets feature attributes, collect objects to whom the attributes refer
87   /// \param theFeature a current feature
88   /// \param theWorkshop a current workshop
89   /// \param theObjectShapes an output map
90   /// \param theObjectShape an output map of objects
91   static void getFeatureShapes(const FeaturePtr& theFeature,
92                                ModuleBase_IWorkshop* theWorkshop,
93                                QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
94
95   /// Fills the map by the feature object and shapes, which should be visuaziled
96   /// Gets feature attributes, collect objects to whom the attributes refer
97   /// \param theFeature a current feature
98   /// \param theWorkshop a current workshop
99   /// \param theObjectShapes an output map
100   /// \param theObjectShape an output map of objects
101   static void getResultShapes(const FeaturePtr& theFeature,
102                               ModuleBase_IWorkshop* theWorkshop,
103                               QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
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   /// Converts the current workshop to XGUI workshop
119   /// \param theWorkshop an interface workshop
120   /// \return a workshop instance
121   static XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop);
122
123 private:
124   QMap<ObjectPtr, QList<GeomShapePtr> > myFeatureShapes; /// visualized shapes
125
126   ModuleBase_IWorkshop* myWorkshop; /// current workshop
127   Quantity_Color myShapeColor; /// color of feature depended shapes
128   bool myUseAISWidth; /// flag if the width of a shape object should be used for the shape visualization
129
130   friend class PartSet_CustomPrs;
131 };
132
133
134 #endif