]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_OperationPrs.h
Salome HOME
89d2c252ed795adcab9a8ae1a817b510a775e9ed
[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   /// Sets the operation feature. It is used in Compute method to group the feature parameter shapes
51   /// theFeature a feature
52   void setFeature(const FeaturePtr& theFeature);
53
54   // Recompute internal list of shaped dependent on the current feature
55   void updateShapes();
56
57   /// Returns true if the feature contains shapes or results
58   bool hasShapes();
59
60   /// Sets the colors for the presentation compute
61   /// \param theShapeColor an argument shapes color
62   /// \param theResultColor a color for operation result
63   void setColors(const Quantity_Color& theShapeColor, const Quantity_Color& theResultColor);
64
65   /// Switch on using of the AIS presentation with of the shape object increased on the delta
66   void useAISWidth();
67
68   DEFINE_STANDARD_RTTI(PartSet_OperationPrs)
69
70 protected:
71   /// Redefinition of virtual function
72   Standard_EXPORT virtual void Compute(
73             const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
74             const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
75
76   /// Redefinition of virtual function
77   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
78                                                 const Standard_Integer aMode) ;
79
80 protected:
81   /// Reference to a feature object
82   FeaturePtr getFeature() { return myFeature; }
83
84   /// Returns map of feature shapes to be able to fill it outside this class, e.g. in friend
85   /// \return a map of object to shape
86   QMap<ObjectPtr, QList<GeomShapePtr> >& featureShapes() { return myFeatureShapes; }
87
88 private:
89   /// Return true if the object is visible. If the object is feature, it returns true
90   /// if all results of the feature are shown
91   /// \param theDisplayer a displayer
92   /// \param theObject an object
93   /// \return a boolean value
94   bool isVisible(XGUI_Displayer* theDislayer, const ObjectPtr& theObject);
95
96   /// Fills the map by the feature object and shapes, which should be visuaziled
97   /// Gets feature attributes, collect objects to whom the attributes refer
98   /// \param theFeature a current feature
99   /// \param theWorkshop a current workshop
100   /// \param theObjectShapes an output map
101   /// \param theObjectShape an output map of objects
102   static void getFeatureShapes(const FeaturePtr& theFeature,
103                                ModuleBase_IWorkshop* theWorkshop,
104                                QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
105
106   /// Fills the map by the feature object and shapes, which should be visuaziled
107   /// Gets the active widget, obtain the highlighted presentations if it has such and
108   /// fill map by object and shapes
109   /// \param theWorkshop a current workshop
110   /// \param theObjectShapes an output map of objects
111   static void getHighlightedShapes(ModuleBase_IWorkshop* theWorkshop,
112                                    QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
113
114   /// Returns true if the attribute type belong to reference attribute
115   /// \param theAttribute an attribute
116   /// \return a boolean value
117   static bool isSelectionAttribute(const AttributePtr& theAttribute);
118
119   /// Converts the current workshop to XGUI workshop
120   /// \return a workshop instance
121   XGUI_Workshop* workshop() const;
122
123 private:
124   ModuleBase_IWorkshop* myWorkshop;
125   FeaturePtr myFeature; /// Reference to a feature object
126   QMap<ObjectPtr, QList<GeomShapePtr> > myFeatureShapes; /// visualized shapes
127   std::list<ResultPtr> myFeatureResults; /// visualized feature results
128
129   Quantity_Color myShapeColor; /// color of feature depended shapes
130   Quantity_Color myResultColor; /// color of feature result
131
132   bool myUseAISWidth; /// flag if the width of a shape object should be used for the shape visualization
133
134   friend class PartSet_CustomPrs;
135 };
136
137
138 #endif