]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_CustomPrs.h
Salome HOME
Imrove multi-selector control to provide items multi-selection. Preferences color...
[modules/shaper.git] / src / PartSet / PartSet_CustomPrs.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_CustomPrs.hxx
4 // Created:     30 Jun 2015
5 // Author:      Natalia ERMOLAEVA
6
7 #ifndef PartSet_CustomPrs_H
8 #define PartSet_CustomPrs_H
9
10 #include "PartSet.h"
11
12 #include "PartSet_OperationPrs.h"
13
14 #include <ModuleBase_IModule.h>
15 #include <ModelAPI_Object.h>
16 #include <ModelAPI_Result.h>
17 #include <ModelAPI_Feature.h>
18
19 #include <GeomAPI_ICustomPrs.h>
20 #include <GeomAPI_AISObject.h>
21 #include <GeomAPI_Shape.h>
22
23 class ModuleBase_IWorkshop;
24 class XGUI_Workshop;
25
26 /**
27  * This is the module custom presentation, which manage an AIS presentation, that can be filled
28  * by a feature and visualized in the viewer additionally to usual workshop objects.
29 */
30 class PartSet_CustomPrs
31 {
32 public:
33   /// Returns yellow color
34   static const std::string OPERATION_PARAMETER_COLOR() { return "255, 255, 0"; }
35   /// Returns green color
36   static const std::string OPERATION_RESULT_COLOR() { return "0,225, 0"; }
37   /// Returns color between white and color of highlight
38   /// highlight color is equal Quantity_Color(0.5,1,1) or QColor(122, 255,255) // 188
39   static const std::string OPERATION_HIGHLIGHT_COLOR() { return "188, 255, 255"; }
40
41 public:
42   /// Constructor
43   /// \param theWorkshop a reference to workshop
44   PARTSET_EXPORT PartSet_CustomPrs(ModuleBase_IWorkshop* theWorkshop);
45   PARTSET_EXPORT virtual ~PartSet_CustomPrs() {};
46
47   /// Returns true if the presentation is active
48   bool isActive();
49
50   /// Initializes the operation presentation by the parameter object and display the presentation
51   /// \param theObject an operation feature source to fill the presentation
52   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
53   /// \returns true if the presentation is displayed
54   bool activate(const FeaturePtr& theObject, const bool theUpdateViewer);
55
56   /// Initializes the operation presentation by empty object and erase the presentation
57   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
58   /// \returns true if the presentation has been displayed and now it is erased
59   bool deactivate(const bool theUpdateViewer);
60
61   /// If the presentation is active[displayed], the shapes of the presentation is recomputed
62   /// and the presentation is redisplayed.
63   /// \param theObject an object to redisplay
64   /// \param theFlag an object AIS presentation type
65   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
66   /// \returns true if the presentation is redisplayed
67   bool redisplay(const ObjectPtr& theObject,
68                  const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
69                  const bool theUpdateViewer);
70
71   /// Nullify all internal presentations. For example, it can be useful when the viewer/context
72   /// is closed. If this is not performed and the presentation is assigned in another context,
73   /// it caused erroneus case because the presentation has linkage to the previous context.
74   void clearPrs();
75
76 private:
77   /// Creates the AIS operation presentation
78   /// \param theFlag an object AIS presentation type
79   void initPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
80
81   /// Gets an AIS presentation by the flag
82   /// \param theFlag an object AIS presentation type
83   /// \return the AIS prsentation
84   Handle(PartSet_OperationPrs) getPresentation(
85                             const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
86
87   //! Returns workshop
88   XGUI_Workshop* workshop() const;
89
90   /// Displays the internal presentation in the viewer of workshop
91   /// \param theFlag an object AIS presentation type
92   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
93   /// \param returns whether the presentation is displayed/redisplayed
94   bool displayPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
95                            const bool theUpdateViewer);
96
97   /// Erases the internal presentation from the viewer of workshop
98   /// \param theFlag an object AIS presentation type
99   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
100   void erasePresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
101                          const bool theUpdateViewer);
102
103   /// Nullify the operation presentation. For example, it can be useful when the viewer/context
104   /// is closed. If this is not performed and the presentation is assigned in another context,
105   /// it caused erroneus case because the presentation has linkage to the previous context.
106   /// \param theFlag an object AIS presentation type
107   void clearPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
108
109   /// Returns presentation color according to the flag
110   /// \param theFlag an object AIS presentation type
111   /// \return theShapeColor a color
112   Quantity_Color getShapeColor(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
113
114 private:
115   bool myIsActive; /// State whether the presentation is activated/deactivated
116   FeaturePtr myFeature; /// Reference to a feature object
117   ModuleBase_IWorkshop* myWorkshop; /// current workshop
118   /// map of presentation type to AIS object
119   QMap<ModuleBase_IModule::ModuleBase_CustomizeFlag, AISObjectPtr> myPresentations;
120 };
121
122 #endif