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
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);
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);
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);
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.
77 /// Creates the AIS operation presentation
78 /// \param theFlag an object AIS presentation type
79 void initPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
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);
88 XGUI_Workshop* workshop() const;
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);
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);
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);
109 /// Returns presentation colors according to the flag
110 /// \param theFlag an object AIS presentation type
111 /// \param theShapeColor a color for shapes
112 /// \param theShapeColor a color for results
113 void getAISColors(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
114 Quantity_Color& theShapeColor, Quantity_Color& theResultColor);
118 ModuleBase_IWorkshop* myWorkshop; /// current workshop
119 /// map of presentation type to AIS object
120 QMap<ModuleBase_IModule::ModuleBase_CustomizeFlag, AISObjectPtr> myPresentations;