Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / ModuleBase / ModuleBase_ViewerPrs.h
1 // File:        ModuleBase_ViewerPrs.h
2 // Created:     20 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #ifndef ModuleBase_ViewerPrs_H
6 #define ModuleBase_ViewerPrs_H
7
8 #include "ModuleBase.h"
9
10 #include <boost/shared_ptr.hpp>
11 #include <TopoDS_Shape.hxx>
12 #include <SelectMgr_EntityOwner.hxx>
13 #include <AIS_InteractiveObject.hxx>
14
15 #include <ModelAPI_Result.h>
16
17 /**\class ModuleBase_ViewerPrs
18  * \ingroup Module base
19  * \brief Presentation. Provides container to have feature, shape and/or selection owner.
20  */
21 class ModuleBase_ViewerPrs
22 {
23 public:
24   /// Constructor
25   ModuleBase_ViewerPrs() {}
26   
27   /// Constructor
28   /// \param theFeature a model feature
29   /// \param theShape a viewer shape
30   /// \param theOwner a selection owner
31   ModuleBase_ViewerPrs(ObjectPtr theResult,
32                  const TopoDS_Shape& theShape,
33                  Handle_SelectMgr_EntityOwner theOwner)
34   : myResult(theResult), myShape(theShape), myOwner(theOwner) {}
35   
36   /// Destructor
37   virtual ~ModuleBase_ViewerPrs() {}
38
39   /// Sets the feature.
40   /// \param theFeature a feature instance
41   void setFeature(ObjectPtr theResult) { myResult = theResult; }
42
43   /// Returns the feature.
44   /// \return a feature instance
45   ObjectPtr object() const { return myResult; }
46
47   /// Returns the presentation owner
48   /// \param the owner
49   void setOwner(Handle_SelectMgr_EntityOwner theOwner) { myOwner = theOwner; }
50
51   /// Returns the presentation owner
52   /// \return an owner
53   Handle_SelectMgr_EntityOwner owner() const { return myOwner; }
54
55   /// Sets the shape
56   /// \param theShape a shape instance
57   void setShape(const TopoDS_Shape& theShape) { myShape = theShape; }
58
59   /// Returns the shape
60   /// \return a shape instance
61   const TopoDS_Shape& shape() const { return myShape; }
62
63   void setInteractive(const Handle(AIS_InteractiveObject)& theIO) { myInteractive = theIO; }
64
65   Handle(AIS_InteractiveObject) interactive() const { return myInteractive; }
66
67   bool operator==(const ModuleBase_ViewerPrs& thePrs)
68   {
69     bool aResult = (myResult.get() == thePrs.object().get());
70     bool aOwner = (myOwner.Access() == thePrs.owner().Access());
71     bool aShape = myShape.IsEqual(thePrs.shape());
72     bool aIO = myInteractive == thePrs.interactive();
73     return aResult && aOwner && aShape && aIO;
74   }
75
76 private:
77   ObjectPtr myResult; /// the feature
78   Handle(SelectMgr_EntityOwner) myOwner; /// the selection owner
79   TopoDS_Shape myShape; /// the shape
80   Handle(AIS_InteractiveObject) myInteractive;
81 };
82
83 #endif