Salome HOME
Issue #653 - Double and triple click edges -- Fix Debian dynamic_pointer_cast problem...
[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 <TopoDS_Shape.hxx>
14 #include <SelectMgr_EntityOwner.hxx>
15 #include <AIS_InteractiveObject.hxx>
16
17 #include <ModelAPI_Result.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_EXPORT ModuleBase_ViewerPrs
24 {
25  public:
26   /// Constructor
27   ModuleBase_ViewerPrs();
28
29   /// Constructor
30   /// \param theResult an object
31   /// \param theShape a viewer shape
32   /// \param theOwner a selection owner
33   ModuleBase_ViewerPrs(ObjectPtr theResult, const TopoDS_Shape& theShape,
34                        Handle_SelectMgr_EntityOwner theOwner);
35
36   /// Destructor
37   virtual ~ModuleBase_ViewerPrs();
38
39   /// Sets the object.
40   /// \param theResult an object instance
41   void setObject(ObjectPtr theResult)
42   {
43     myResult = theResult;
44   }
45
46   /// Returns the feature.
47   /// \return a feature instance
48   ObjectPtr object() const
49   {
50     return myResult;
51   }
52
53   /// Set the presentation owner
54   /// \param theOwner an owner to set
55   void setOwner(Handle_SelectMgr_EntityOwner theOwner)
56   {
57     myOwner = theOwner;
58   }
59
60   /// Returns the presentation owner
61   /// \return an owner
62   Handle_SelectMgr_EntityOwner owner() const
63   {
64     return myOwner;
65   }
66
67   /// Sets the shape
68   /// \param theShape a shape instance
69   void setShape(const TopoDS_Shape& theShape)
70   {
71     myShape = theShape;
72   }
73
74   /// Returns the shape
75   /// \return a shape instance
76   const TopoDS_Shape& shape() const
77   {
78     return myShape;
79   }
80
81   /// Set interactive object
82   /// \param theIO an interactive object
83   void setInteractive(const Handle(AIS_InteractiveObject)& theIO)
84   {
85     myInteractive = theIO;
86   }
87
88   /// Returns interactive object if it is installed
89   Handle(AIS_InteractiveObject) interactive() const
90   {
91     return myInteractive;
92   }
93
94   /// Returns true if all presentation fields are empty
95   /// \return boolean value
96   bool isEmpty() const
97   {
98     return myShape.IsNull() &&
99            myOwner.IsNull() && !myResult.get();
100   }
101
102   /// Returns True if the current object is equal to the given one
103   /// \param thePrs an object to compare
104   bool operator==(const ModuleBase_ViewerPrs& thePrs)
105   {
106     bool aResult = (myResult.get() == thePrs.object().get());
107     bool aOwner = (myOwner.Access() == thePrs.owner().Access());
108     bool aShape = myShape.IsEqual(thePrs.shape()) == Standard_True;
109     bool aIO = (myInteractive == thePrs.interactive()) == Standard_True;
110     return aResult && aOwner && aShape && aIO;
111   }
112
113  private:
114   ObjectPtr myResult;  /// the feature
115   Handle(SelectMgr_EntityOwner) myOwner;  /// the selection owner
116   TopoDS_Shape myShape;  /// the shape
117   Handle(AIS_InteractiveObject) myInteractive;  /// interactive object
118 };
119
120 #endif