1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_CustomPrs.hxx
4 // Created: 30 Jun 2015
5 // Author: Natalia ERMOLAEVA
7 #ifndef PartSet_CustomPrs_H
8 #define PartSet_CustomPrs_H
12 #include "PartSet_OperationPrs.h"
14 #include <ModuleBase_IModule.h>
15 #include <ModelAPI_Object.h>
16 #include <ModelAPI_Result.h>
17 #include <ModelAPI_Feature.h>
19 #include <GeomAPI_ICustomPrs.h>
20 #include <GeomAPI_AISObject.h>
21 #include <GeomAPI_Shape.h>
23 class ModuleBase_IWorkshop;
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.
30 class PartSet_CustomPrs
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"; }
43 /// \param theWorkshop a reference to workshop
44 PARTSET_EXPORT PartSet_CustomPrs(ModuleBase_IWorkshop* theWorkshop);
45 PARTSET_EXPORT virtual ~PartSet_CustomPrs() {};
47 /// Returns true if the presentation is active
48 /// \param theFlag an object AIS presentation type
49 bool isActive(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
51 /// Initializes the operation presentation by the parameter object and display the presentation
52 /// \param theObject an operation feature source to fill the presentation
53 /// \param theFlag an object AIS presentation type
54 /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
55 /// \returns true if the presentation is displayed
56 bool activate(const FeaturePtr& theObject,
57 const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
58 const bool theUpdateViewer);
60 /// Initializes the operation presentation by empty object and erase the presentation
61 /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
62 /// \param theFlag an object AIS presentation type
63 /// \returns true if the presentation has been displayed and now it is erased
64 bool deactivate(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
65 const bool theUpdateViewer);
67 /// If the presentation is active[displayed], the shapes of the presentation is recomputed
68 /// and the presentation is redisplayed.
69 /// \param theObject an object to redisplay
70 /// \param theFlag an object AIS presentation type
71 /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
72 /// \returns true if the presentation is redisplayed
73 bool redisplay(const ObjectPtr& theObject,
74 const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
75 const bool theUpdateViewer);
77 /// Nullify all internal presentations. For example, it can be useful when the viewer/context
78 /// is closed. If this is not performed and the presentation is assigned in another context,
79 /// it caused erroneus case because the presentation has linkage to the previous context.
83 /// Creates the AIS operation presentation
84 /// \param theFlag an object AIS presentation type
85 void initPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
87 /// Gets an AIS presentation by the flag
88 /// \param theFlag an object AIS presentation type
89 /// \return the AIS prsentation
90 Handle(PartSet_OperationPrs) getPresentation(
91 const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
94 XGUI_Workshop* workshop() const;
96 /// Displays the internal presentation in the viewer of workshop
97 /// \param theFlag an object AIS presentation type
98 /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
99 /// \param returns whether the presentation is displayed/redisplayed
100 bool displayPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
101 const bool theUpdateViewer);
103 /// Erases the internal presentation from the viewer of workshop
104 /// \param theFlag an object AIS presentation type
105 /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
106 void erasePresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
107 const bool theUpdateViewer);
109 /// Nullify the operation presentation. For example, it can be useful when the viewer/context
110 /// is closed. If this is not performed and the presentation is assigned in another context,
111 /// it caused erroneus case because the presentation has linkage to the previous context.
112 /// \param theFlag an object AIS presentation type
113 void clearPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
115 /// Returns presentation color according to the flag
116 /// \param theFlag an object AIS presentation type
117 /// \return theShapeColor a color
118 Quantity_Color getShapeColor(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
121 FeaturePtr myFeature; /// Reference to a feature object
122 ModuleBase_IWorkshop* myWorkshop; /// current workshop
123 /// map of presentation type to AIS object
124 QMap<ModuleBase_IModule::ModuleBase_CustomizeFlag, AISObjectPtr> myPresentations;
125 /// State whether the presentation is activated/deactivated
126 QMap<ModuleBase_IModule::ModuleBase_CustomizeFlag, bool> myIsActive;