]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_CustomPrs.h
Salome HOME
ab82997a72817eb4489eadeb2e72a21f5cba4009
[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   /// Constructor
34   /// \param theWorkshop a reference to workshop
35   PARTSET_EXPORT PartSet_CustomPrs(ModuleBase_IWorkshop* theWorkshop);
36   PARTSET_EXPORT virtual ~PartSet_CustomPrs() {};
37
38   /// Returns true if the presentation is active
39   bool isActive();
40
41   /// Initializes the operation presentation by the parameter object and display the presentation
42   /// \param theObject an operation feature source to fill the presentation
43   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
44   /// \returns true if the presentation is displayed
45   bool activate(const FeaturePtr& theObject, const bool theUpdateViewer);
46
47   /// Initializes the operation presentation by empty object and erase the presentation
48   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
49   /// \returns true if the presentation has been displayed and now it is erased
50   bool deactivate(const bool theUpdateViewer);
51
52   /// If the presentation is active[displayed], the shapes of the presentation is recomputed
53   /// and the presentation is redisplayed.
54   /// \param theObject an object to redisplay
55   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
56   /// \returns true if the presentation is redisplayed
57   bool redisplay(const ObjectPtr& theObject,
58                  const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag, const bool theUpdateViewer);
59
60   /// Nullify the operation presentation. For example, it can be useful when the viewer/context
61   /// is closed. If this is not performed and the presentation is assigned in another context,
62   /// it caused erroneus case because the presentation has linkage to the previous context.
63   void clearPrs();
64
65 private:
66   /// Creates the AIS operation presentation
67   void initPrs();
68
69   /// Returns the AIS presentation
70   Handle(PartSet_OperationPrs) getPresentation();
71
72   //! Returns workshop
73   XGUI_Workshop* workshop() const;
74
75   /// Displays the internal presentation in the viewer of workshop
76   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
77   bool displayPresentation(const bool theUpdateViewer);
78
79   /// Erases the internal presentation from the viewer of workshop
80   /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
81   void erasePresentation(const bool theUpdateViewer);
82
83 private:
84   bool myIsActive;
85   ModuleBase_IWorkshop* myWorkshop; /// current workshop
86   AISObjectPtr myOperationPrs; /// the AIS presentation, which is displayed/erased in the viewer
87 };
88
89 #endif