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