]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_Displayer.h
Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / XGUI / XGUI_Displayer.h
1 // File:        XGUI_Displayer.h
2 // Created:     20 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #ifndef XGUI_Displayer_H
6 #define XGUI_Displayer_H
7
8 #include "XGUI.h"
9
10 #include <QString>
11 #include <boost/shared_ptr.hpp>
12
13 #include <TopoDS_Shape.hxx>
14 #include <AIS_InteractiveObject.hxx>
15 #include <AIS_InteractiveContext.hxx>
16
17 #include <map>
18 #include <vector>
19 #include <list>
20
21 class XGUI_Viewer;
22 class ModelAPI_Feature;
23 class XGUI_Workshop;
24
25 /**\class XGUI_Displayer
26  * \ingroup GUI
27  * \brief Displayer. Provides mechanizm of display/erase of objects in the viewer
28  */
29 class XGUI_EXPORT XGUI_Displayer
30 {
31 public:
32   /// Constructor
33   /// \param theViewer the viewer
34   XGUI_Displayer(XGUI_Workshop* theWorkshop);
35   /// Destructor
36   virtual ~XGUI_Displayer();
37
38   /// Set AIS_InteractiveContext object in case if it was changed
39   /// or can not be initialized in constructor
40   void setAISContext(const Handle(AIS_InteractiveContext)& theAIS);
41
42   /// Returns the feature visibility state.
43   /// \param theFeature a feature instance
44   bool IsVisible(boost::shared_ptr<ModelAPI_Feature> theFeature);
45
46   /// Display the feature. Obtain the visualized object from the feature.
47   /// \param theFeature a feature instance
48   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
49   void Display(boost::shared_ptr<ModelAPI_Feature> theFeature, const bool isUpdateViewer = true);
50
51   /// Display the feature and a shape. This shape would be associated to the given feature
52   /// \param theFeature a feature instance
53   /// \param theShape a shape
54   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
55   void Display(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape,
56                const bool isUpdateViewer = true);
57   
58   /// Returns the feature, that was displayed with this shape
59   /// \param theShape a shape
60   boost::shared_ptr<ModelAPI_Feature> GetFeature( const TopoDS_Shape& theShape );
61
62   /// Display the shape and activate selection of sub-shapes
63   /// \param theFeature a feature instance
64   /// \param theShape a shape
65   /// \param theMode a local selection mode
66   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
67   void RedisplayInLocalContext(boost::shared_ptr<ModelAPI_Feature> theFeature,
68                              const TopoDS_Shape& theShape,
69                              const std::list<int>& theMode, const bool isUpdateViewer = true);
70
71   /// Erase the feature and a shape.
72   /// \param theFeature a feature instance
73   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
74   void Erase(boost::shared_ptr<ModelAPI_Feature> theFeature, const bool isUpdateViewer = true);
75
76   /// Deactivates selection of sub-shapes
77   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
78   void CloseLocalContexts(const bool isUpdateViewer = true);
79
80 protected:
81   /// Deactivate local selection
82   /// \param isUpdateViewer the state wether the viewer should be updated immediatelly
83   void closeAllContexts(const bool isUpdateViewer);
84
85   /// Returns currently installed AIS_InteractiveContext
86   Handle(AIS_InteractiveContext) AISContext() const;
87
88 protected:
89   XGUI_Workshop* myWorkshop;
90
91   typedef std::map<boost::shared_ptr<ModelAPI_Feature>, Handle(AIS_InteractiveObject) > FeatureToAISMap;
92   FeatureToAISMap myFeature2AISObjectMap;
93 };
94
95 #endif