Salome HOME
Revert selection of compsolid in RemoveSubshapes feature
[modules/shaper.git] / src / ModuleBase / ModuleBase_ViewerPrs.h
1 // Copyright (C) 2014-2017  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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef ModuleBase_ViewerPrs_H
22 #define ModuleBase_ViewerPrs_H
23
24 #include "ModuleBase.h"
25
26 #include <memory>
27 #include <SelectMgr_EntityOwner.hxx>
28 #include <AIS_InteractiveObject.hxx>
29
30 #include <ModelAPI_Result.h>
31 #include <GeomAPI_Shape.h>
32
33 /**\class ModuleBase_ViewerPrs
34  * \ingroup GUI
35  * \brief Presentation. Provides container to have feature, shape and/or selection owner.
36  */
37 class ModuleBase_ViewerPrs
38 {
39  public:
40   /// Constructor
41   /// \param theResult an object
42   /// \param theShape a viewer shape
43   /// \param theOwner a selection owner
44   MODULEBASE_EXPORT ModuleBase_ViewerPrs(ObjectPtr theResult = ObjectPtr(),
45                                          const GeomShapePtr& theShape = GeomShapePtr(),
46                                          Handle(SelectMgr_EntityOwner) theOwner = NULL);
47
48   /// Destructor
49   MODULEBASE_EXPORT virtual ~ModuleBase_ViewerPrs();
50
51   /// Sets the object.
52   /// \param theResult an object instance
53   MODULEBASE_EXPORT void setObject(ObjectPtr theResult)
54   {
55     myResult = theResult;
56   }
57
58   /// Returns the feature.
59   /// \return a feature instance
60   MODULEBASE_EXPORT ObjectPtr object() const
61   {
62     return myResult;
63   }
64
65   /// Set the presentation owner
66   /// \param theOwner an owner to set
67   MODULEBASE_EXPORT void setOwner(Handle_SelectMgr_EntityOwner theOwner)
68   {
69     myOwner = theOwner;
70   }
71
72   /// Returns the presentation owner
73   /// \return an owner
74   MODULEBASE_EXPORT Handle_SelectMgr_EntityOwner owner() const
75   {
76     return myOwner;
77   }
78
79   /// Sets the shape
80   /// \param theShape a shape instance
81   MODULEBASE_EXPORT void setShape(const GeomShapePtr& theShape)
82   {
83     myShape = theShape;
84   }
85
86   /// Returns the shape
87   /// \return a shape instance
88   MODULEBASE_EXPORT const GeomShapePtr& shape() const
89   {
90     return myShape;
91   }
92
93   /// Set interactive object
94   /// \param theIO an interactive object
95   MODULEBASE_EXPORT void setInteractive(const Handle(AIS_InteractiveObject)& theIO)
96   {
97     myInteractive = theIO;
98   }
99
100   /// Returns interactive object if it is installed
101   MODULEBASE_EXPORT Handle(AIS_InteractiveObject) interactive() const
102   {
103     return myInteractive;
104   }
105
106   /// Returns true if all presentation fields are empty
107   /// \return boolean value
108   MODULEBASE_EXPORT bool isEmpty() const
109   {
110     return (!myShape.get() || myShape->isNull()) &&
111            myOwner.IsNull() && !myResult.get();
112   }
113
114     /// Returns true if all presentation fields are empty
115   /// \return boolean value
116   MODULEBASE_EXPORT bool isEqual(ModuleBase_ViewerPrs* thePrs) const;
117
118   /// Returns True if the current object is equal to the given one
119   /// \param thePrs an object to compare
120   MODULEBASE_EXPORT bool operator==(const ModuleBase_ViewerPrs& thePrs);
121
122  private:
123   ObjectPtr myResult;  /// the feature
124   Handle(SelectMgr_EntityOwner) myOwner;  /// the selection owner
125   GeomShapePtr myShape;  /// the shape
126   Handle(AIS_InteractiveObject) myInteractive;  /// interactive object
127 };
128
129 typedef std::shared_ptr<ModuleBase_ViewerPrs> ModuleBase_ViewerPrsPtr;
130
131 #endif