Salome HOME
GeomAPI_IPresentation in terface created
[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_Result.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(ObjectPtr theResult,
31                  const TopoDS_Shape& theShape,
32                  Handle_SelectMgr_EntityOwner theOwner)
33   : myResult(theResult), 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(ObjectPtr theResult) { myResult = theResult; }
41
42   /// Returns the feature.
43   /// \return a feature instance
44   ObjectPtr object() const { return myResult; }
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 aResult = (myResult.get() == thePrs.object().get());
65     bool aOwner = (myOwner.Access() == thePrs.owner().Access());
66     bool aShape = myShape.IsEqual(thePrs.shape());
67     return aResult && aOwner && aShape;
68   }
69
70 private:
71   ObjectPtr myResult; /// the feature
72   Handle(SelectMgr_EntityOwner) myOwner; /// the selection owner
73   TopoDS_Shape myShape; /// the shape
74 };
75
76 #endif