Salome HOME
Merge branch 'master' of newgeom:newgeom
[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
20 class XGUI_Viewer;
21 class ModelAPI_Feature;
22 class XGUI_Workshop;
23
24 /**\class XGUI_Displayer
25  * \ingroup GUI
26  * \brief Displayer. Provides mechanizm of display/erase of objects in the viewer
27  */
28 class XGUI_EXPORT XGUI_Displayer
29 {
30 public:
31   /// Constructor
32   /// \param theViewer the viewer
33   XGUI_Displayer(XGUI_Workshop* theWorkshop);
34   /// Destructor
35   virtual ~XGUI_Displayer();
36
37   /// Set AIS_InteractiveContext object in case if it was changed
38   /// or can not be initialized in constructor
39   void setAISContext(const Handle(AIS_InteractiveContext)& theAIS);
40
41   /// Returns the feature visibility state.
42   /// \param theFeature a feature instance
43   bool IsVisible(boost::shared_ptr<ModelAPI_Feature> theFeature);
44
45   /// Display the feature. Obtain the visualized object from the feature.
46   /// \param theFeature a feature instance
47   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
48   void Display(boost::shared_ptr<ModelAPI_Feature> theFeature, const bool isUpdateViewer = true);
49
50   /// Display the feature and a shape. This shape would be associated to the given feature
51   /// \param theFeature a feature instance
52   /// \param theShape a shape
53   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
54   void Display(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape,
55                const bool isUpdateViewer = true);
56   
57   /// Display the shape and activate selection of sub-shapes
58   /// \param theFeature a feature instance
59   /// \param theShape a shape
60   /// \param theMode a local selection mode
61   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
62   void DisplayInLocalContext(boost::shared_ptr<ModelAPI_Feature> theFeature,
63                              const TopoDS_Shape& theShape,
64                              const int theMode, const bool isUpdateViewer = true);
65
66   /// Erase the feature and a shape.
67   /// \param theFeature a feature instance
68   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
69   void Erase(boost::shared_ptr<ModelAPI_Feature> theFeature, const bool isUpdateViewer = true);
70
71   /// Deactivates selection of sub-shapes
72   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
73   void CloseLocalContexts(const bool isUpdateViewer = true);
74
75 protected:
76   /// Activate local selection
77   /// \param theAIS the list of objects
78   /// \param theMode the selection mode
79   /// \param isUpdateViewer the state wether the viewer should be updated immediatelly
80   void activateInLocalContext(const AIS_ListOfInteractive& theAISObjects, const int theMode,
81                               const bool isUpdateViewer);
82   /// Deactivate local selection
83   /// \param isUpdateViewer the state wether the viewer should be updated immediatelly
84   void closeAllContexts(const bool isUpdateViewer);
85
86   /// Returns currently installed AIS_InteractiveContext
87   Handle(AIS_InteractiveContext) AISContext() const;
88
89 protected:
90   XGUI_Workshop* myWorkshop;
91   std::map<boost::shared_ptr<ModelAPI_Feature>, std::vector<Handle(AIS_InteractiveObject)> > myFeature2AISObjectMap;
92 };
93
94 #endif