Salome HOME
Issue #1037 Time performance on a big model: cash in widget validated is corrected
[modules/shaper.git] / src / ModuleBase / ModuleBase_ViewerPrs.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_ViewerPrs.h
4 // Created:     20 Apr 2014
5 // Author:      Natalia ERMOLAEVA
6
7 #ifndef ModuleBase_ViewerPrs_H
8 #define ModuleBase_ViewerPrs_H
9
10 #include "ModuleBase.h"
11
12 #include <memory>
13 #include <SelectMgr_EntityOwner.hxx>
14 #include <AIS_InteractiveObject.hxx>
15
16 #include <ModelAPI_Result.h>
17 #include <GeomAPI_Shape.h>
18
19 /**\class ModuleBase_ViewerPrs
20  * \ingroup GUI
21  * \brief Presentation. Provides container to have feature, shape and/or selection owner.
22  */
23 class ModuleBase_ViewerPrs
24 {
25  public:
26   /// Constructor
27   /// \param theResult an object
28   /// \param theShape a viewer shape
29   /// \param theOwner a selection owner
30   MODULEBASE_EXPORT ModuleBase_ViewerPrs(ObjectPtr theResult = ObjectPtr(),
31                                          const GeomShapePtr& theShape = GeomShapePtr(),
32                                          Handle_SelectMgr_EntityOwner theOwner = NULL);
33
34   /// Destructor
35   MODULEBASE_EXPORT virtual ~ModuleBase_ViewerPrs();
36
37   /// Sets the object.
38   /// \param theResult an object instance
39   MODULEBASE_EXPORT void setObject(ObjectPtr theResult)
40   {
41     myResult = theResult;
42   }
43
44   /// Returns the feature.
45   /// \return a feature instance
46   MODULEBASE_EXPORT ObjectPtr object() const
47   {
48     return myResult;
49   }
50
51   /// Set the presentation owner
52   /// \param theOwner an owner to set
53   MODULEBASE_EXPORT void setOwner(Handle_SelectMgr_EntityOwner theOwner)
54   {
55     myOwner = theOwner;
56   }
57
58   /// Returns the presentation owner
59   /// \return an owner
60   MODULEBASE_EXPORT Handle_SelectMgr_EntityOwner owner() const
61   {
62     return myOwner;
63   }
64
65   /// Sets the shape
66   /// \param theShape a shape instance
67   MODULEBASE_EXPORT void setShape(const GeomShapePtr& theShape)
68   {
69     myShape = theShape;
70   }
71
72   /// Returns the shape
73   /// \return a shape instance
74   MODULEBASE_EXPORT const GeomShapePtr& shape() const
75   {
76     return myShape;
77   }
78
79   /// Set interactive object
80   /// \param theIO an interactive object
81   MODULEBASE_EXPORT void setInteractive(const Handle(AIS_InteractiveObject)& theIO)
82   {
83     myInteractive = theIO;
84   }
85
86   /// Returns interactive object if it is installed
87   MODULEBASE_EXPORT Handle(AIS_InteractiveObject) interactive() const
88   {
89     return myInteractive;
90   }
91
92   /// Returns true if all presentation fields are empty
93   /// \return boolean value
94   MODULEBASE_EXPORT bool isEmpty() const
95   {
96     return (!myShape.get() || myShape->isNull()) &&
97            myOwner.IsNull() && !myResult.get();
98   }
99
100     /// Returns true if all presentation fields are empty
101   /// \return boolean value
102   MODULEBASE_EXPORT bool isEqual(ModuleBase_ViewerPrs* thePrs) const;
103
104   /// Returns True if the current object is equal to the given one
105   /// \param thePrs an object to compare
106   MODULEBASE_EXPORT bool operator==(const ModuleBase_ViewerPrs& thePrs);
107
108  private:
109   ObjectPtr myResult;  /// the feature
110   Handle(SelectMgr_EntityOwner) myOwner;  /// the selection owner
111   GeomShapePtr myShape;  /// the shape
112   Handle(AIS_InteractiveObject) myInteractive;  /// interactive object
113 };
114
115 typedef std::shared_ptr<ModuleBase_ViewerPrs> ModuleBase_ViewerPrsPtr;
116
117 #endif