Salome HOME
Update copyrights
[modules/shaper.git] / src / ModuleBase / ModuleBase_ViewerPrs.h
1 // Copyright (C) 2014-2019  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef ModuleBase_ViewerPrs_H
21 #define ModuleBase_ViewerPrs_H
22
23 #include "ModuleBase.h"
24
25 #include <memory>
26 #include <SelectMgr_EntityOwner.hxx>
27 #include <AIS_InteractiveObject.hxx>
28
29 #include <ModelAPI_Result.h>
30 #include <GeomAPI_Shape.h>
31
32 /**\class ModuleBase_ViewerPrs
33  * \ingroup GUI
34  * \brief Presentation. Provides container to have feature, shape and/or selection owner.
35  */
36 class ModuleBase_ViewerPrs
37 {
38  public:
39   /// Constructor
40   /// \param theResult an object
41   /// \param theShape a viewer shape
42   /// \param theOwner a selection owner
43   MODULEBASE_EXPORT ModuleBase_ViewerPrs(ObjectPtr theResult = ObjectPtr(),
44                                          const GeomShapePtr& theShape = GeomShapePtr(),
45                                          Handle(SelectMgr_EntityOwner) theOwner = NULL);
46
47   /// Destructor
48   MODULEBASE_EXPORT virtual ~ModuleBase_ViewerPrs();
49
50   /// Sets the object.
51   /// \param theResult an object instance
52   MODULEBASE_EXPORT void setObject(ObjectPtr theResult)
53   {
54     myResult = theResult;
55   }
56
57   /// Returns the feature.
58   /// \return a feature instance
59   MODULEBASE_EXPORT ObjectPtr object() const
60   {
61     return myResult;
62   }
63
64   /// Set the presentation owner
65   /// \param theOwner an owner to set
66   MODULEBASE_EXPORT void setOwner(Handle_SelectMgr_EntityOwner theOwner)
67   {
68     myOwner = theOwner;
69   }
70
71   /// Returns the presentation owner
72   /// \return an owner
73   MODULEBASE_EXPORT Handle_SelectMgr_EntityOwner owner() const
74   {
75     return myOwner;
76   }
77
78   /// Sets the shape
79   /// \param theShape a shape instance
80   MODULEBASE_EXPORT void setShape(const GeomShapePtr& theShape)
81   {
82     myShape = theShape;
83   }
84
85   /// Returns the shape
86   /// \return a shape instance
87   MODULEBASE_EXPORT const GeomShapePtr& shape() const
88   {
89     return myShape;
90   }
91
92   /// Set interactive object
93   /// \param theIO an interactive object
94   MODULEBASE_EXPORT void setInteractive(const Handle(AIS_InteractiveObject)& theIO)
95   {
96     myInteractive = theIO;
97   }
98
99   /// Returns interactive object if it is installed
100   MODULEBASE_EXPORT Handle(AIS_InteractiveObject) interactive() const
101   {
102     return myInteractive;
103   }
104
105   /// Returns true if all presentation fields are empty
106   /// \return boolean value
107   MODULEBASE_EXPORT bool isEmpty() const
108   {
109     return (!myShape.get() || myShape->isNull()) &&
110            myOwner.IsNull() && !myResult.get();
111   }
112
113     /// Returns true if all presentation fields are empty
114   /// \return boolean value
115   MODULEBASE_EXPORT bool isEqual(ModuleBase_ViewerPrs* thePrs) const;
116
117   /// Returns True if the current object is equal to the given one
118   /// \param thePrs an object to compare
119   MODULEBASE_EXPORT bool operator==(const ModuleBase_ViewerPrs& thePrs);
120
121  private:
122   ObjectPtr myResult;  /// the feature
123   Handle(SelectMgr_EntityOwner) myOwner;  /// the selection owner
124   GeomShapePtr myShape;  /// the shape
125   Handle(AIS_InteractiveObject) myInteractive;  /// interactive object
126 };
127
128 typedef std::shared_ptr<ModuleBase_ViewerPrs> ModuleBase_ViewerPrsPtr;
129
130 #endif