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
14 #include <ModelAPI_Feature.h>
15
16 /**\class ModuleBase_ViewerPrs
17  * \ingroup Module base
18  * \brief Presentation. Provides container to have feature, shape and/or selection owner.
19  */
20 class ModuleBase_ViewerPrs
21 {
22 public:
23   /// Constructor
24   ModuleBase_ViewerPrs() {}
25   
26   /// Constructor
27   /// \param theFeature a model feature
28   /// \param theShape a viewer shape
29   /// \param theOwner a selection owner
30   ModuleBase_ViewerPrs(FeaturePtr theFeature,
31                  const TopoDS_Shape& theShape,
32                  Handle_SelectMgr_EntityOwner theOwner)
33   : myFeature(theFeature), myShape(theShape), myOwner(theOwner) {}
34   
35   /// Destructor
36   virtual ~ModuleBase_ViewerPrs() {}
37
38   /// Sets the feature.
39   /// \param theFeature a feature instance
40   void setFeature(FeaturePtr theFeature) { myFeature = theFeature; }
41
42   /// Returns the feature.
43   /// \return a feature instance
44   FeaturePtr feature() const { return myFeature; }
45
46   /// Returns the presentation owner
47   /// \param the owner
48   void setOwner(Handle_SelectMgr_EntityOwner theOwner) { myOwner = theOwner; }
49
50   /// Returns the presentation owner
51   /// \return an owner
52   Handle_SelectMgr_EntityOwner owner() const { return myOwner; }
53
54   /// Sets the shape
55   /// \param theShape a shape instance
56   void setShape(const TopoDS_Shape& theShape) { myShape = theShape; }
57
58   /// Returns the shape
59   /// \return a shape instance
60   const TopoDS_Shape& shape() const { return myShape; }
61
62   bool operator==(const ModuleBase_ViewerPrs& thePrs)
63   {
64     bool aFeature = (myFeature.get() == thePrs.feature().get());
65     bool aOwner = (myOwner.Access() == thePrs.owner().Access());
66     bool aShape = myShape.IsEqual(thePrs.shape());
67     return aFeature && aOwner && aShape;
68   }
69
70 private:
71   FeaturePtr myFeature; /// the feature
72   Handle(SelectMgr_EntityOwner) myOwner; /// the selection owner
73   TopoDS_Shape myShape; /// the shape
74 };
75
76 #endif