Salome HOME
Merge branch 'vsr/make_test' into Dev_1.5.0
[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 <ModelAPI_Object.h>
15 #include <ModelAPI_Result.h>
16 #include <ModelAPI_Feature.h>
17
18 #include <GeomAPI_ICustomPrs.h>
19 #include <GeomAPI_AISObject.h>
20 #include <GeomAPI_Shape.h>
21
22 class ModuleBase_IWorkshop;
23 class XGUI_Workshop;
24
25 /**
26  * This is the module custom presentation, which manage an AIS presentation, that can be filled
27  * by a feature and visualized in the viewer additionally to usual workshop objects.
28 */
29 class PartSet_CustomPrs
30 {
31 public:
32   /// Constructor
33   /// \param theWorkshop a reference to workshop
34   PARTSET_EXPORT PartSet_CustomPrs(ModuleBase_IWorkshop* theWorkshop);
35   PARTSET_EXPORT virtual ~PartSet_CustomPrs() {};
36
37   /// Returns true if the presentation is active
38   bool isActive();
39
40   /// Initializes the operation presentation by the parameter object and display the presentation
41   /// \param theObject an operation feature source to fill the presentation
42   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
43   /// \returns true if the presentation is displayed
44   bool activate(const FeaturePtr& theObject, const bool theUpdateViewer);
45
46   /// Initializes the operation presentation by empty object and erase the presentation
47   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
48   /// \returns true if the presentation has been displayed and now it is erased
49   bool deactivate(const bool theUpdateViewer);
50
51   /// If the presentation is active[displayed], the shapes of the presentation is recomputed
52   /// and the presentation is redisplayed.
53   /// \param theObject an object to redisplay
54   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
55   /// \returns true if the presentation is redisplayed
56   bool redisplay(const ObjectPtr& theObject, const bool theUpdateViewer);
57
58   /// Nullify the operation presentation. For example, it can be useful when the viewer/context
59   /// is closed. If this is not performed and the presentation is assigned in another context,
60   /// it caused erroneus case because the presentation has linkage to the previous context.
61   void clearPrs();
62
63 private:
64   /// Creates the AIS operation presentation
65   void initPrs();
66
67   /// Returns the AIS presentation
68   Handle(PartSet_OperationPrs) getPresentation();
69
70   //! Returns workshop
71   XGUI_Workshop* workshop() const;
72
73   /// Displays the internal presentation in the viewer of workshop
74   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
75   void displayPresentation(const bool theUpdateViewer);
76
77   /// Erases the internal presentation from the viewer of workshop
78   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
79   void erasePresentation(const bool theUpdateViewer);
80
81   /// Sets color, point size and width of the presentation
82   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
83   void customizePresentation(const bool theUpdateViewer);
84
85 private:
86   bool myIsActive;
87   ModuleBase_IWorkshop* myWorkshop; /// current workshop
88   AISObjectPtr myOperationPrs; /// the AIS presentation, which is displayed/erased in the viewer
89 };
90
91 #endif