]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_Displayer.h
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 #include <NCollection_List.hxx>
17
18 #include <XGUI_ViewerPrs.h>
19
20 #include <map>
21 #include <vector>
22 #include <list>
23
24 class XGUI_Viewer;
25 class ModelAPI_Feature;
26 class XGUI_Workshop;
27
28 /**\class XGUI_Displayer
29  * \ingroup GUI
30  * \brief Displayer. Provides mechanizm of display/erase of objects in the viewer
31  */
32 class XGUI_EXPORT XGUI_Displayer
33 {
34 public:
35   /// Constructor
36   /// \param theViewer the viewer
37   XGUI_Displayer(XGUI_Workshop* theWorkshop);
38   /// Destructor
39   virtual ~XGUI_Displayer();
40
41   /// Set AIS_InteractiveContext object in case if it was changed
42   /// or can not be initialized in constructor
43   void setAISContext(const Handle(AIS_InteractiveContext)& theAIS);
44
45   /// Returns the feature visibility state.
46   /// \param theFeature a feature instance
47   bool isVisible(boost::shared_ptr<ModelAPI_Feature> theFeature);
48
49   /// Display the feature. Obtain the visualized object from the feature.
50   /// \param theFeature a feature instance
51   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
52   //void Display(boost::shared_ptr<ModelAPI_Feature> theFeature, const bool isUpdateViewer = true);
53
54   /// Display the feature and a shape. This shape would be associated to the given feature
55   /// \param theFeature a feature instance
56   /// \param theShape a shape
57   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
58   //void Display(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape,
59   //             const bool isUpdateViewer = true);
60   
61   /// Returns a list of viewer selected presentations
62   /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
63   /// \return list of presentations
64   std::list<XGUI_ViewerPrs> getSelected(const int theShapeTypeToSkip = -1);
65
66   /// Returns a list of viewer highlited presentations
67   /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
68   /// \return list of presentations
69   std::list<XGUI_ViewerPrs> getHighlighted(const int theShapeTypeToSkip = -1);
70
71   /// Display the shape and activate selection of sub-shapes
72   /// \param theFeature a feature instance
73   /// \param theAIS an AIS object
74   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
75   /// \returns true if the presentation is created
76   bool redisplay(boost::shared_ptr<ModelAPI_Feature> theFeature,
77                  Handle(AIS_InteractiveObject) theAIS,
78                  const int theSelectionMode, const bool isUpdateViewer = true);
79
80   /// Redisplay the shape and activate selection of sub-shapes
81   /// \param theFeature a feature instance
82   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
83   //void redisplay(Handle(AIS_InteractiveObject) theAIS, const bool isUpdateViewer = true);
84
85   /// Display the shape and activate selection of sub-shapes
86   /// \param theFeature a feature instance
87   /// \param theShape a shape
88   /// \param theMode a list of local selection modes
89   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
90   void activateInLocalContext(boost::shared_ptr<ModelAPI_Feature> theFeature,
91                               const std::list<int>& theModes, const bool isUpdateViewer = true);
92
93   /// Stop the current selection and color the given features to the selection color
94   /// \param theFeatures a list of features to be disabled
95   /// \param theToStop the boolean state whether it it stopped or non stopped
96   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
97   void stopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop,
98                      const bool isUpdateViewer);
99
100   /// Set the features are selected
101   /// \param theFeatures a list of features to be selected
102   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
103   void setSelected(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isUpdateViewer);
104
105   /// Erase the feature and a shape.
106   /// \param theFeature a feature instance
107   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
108   void erase(boost::shared_ptr<ModelAPI_Feature> theFeature, const bool isUpdateViewer = true);
109
110   /// Erase all presentations
111   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
112   //void EraseAll(const bool isUpdateViewer = true);
113
114   /// Erase AIS interactive objects, which has an empty feature in the internal map
115   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
116   void eraseDeletedFeatures(const bool isUpdateViewer = true);
117
118   /// Deactivates selection of sub-shapes
119   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
120   void closeLocalContexts(const bool isUpdateViewer = true);
121
122   /// Updates the viewer
123   void updateViewer();
124
125   /// Searches the interactive object by feature
126   /// \param theFeature the feature or NULL if it not visualized
127   /// \return theIO an interactive object
128   Handle(AIS_InteractiveObject) getAISObject(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
129
130 protected:
131   /// Searches the feature by interactive object
132   /// \param theIO an interactive object
133   /// \return feature the feature or NULL if it not visualized
134   boost::shared_ptr<ModelAPI_Feature> getFeature(Handle(AIS_InteractiveObject) theIO) const;
135   /// Deactivate local selection
136   /// \param isUpdateViewer the state wether the viewer should be updated immediatelly
137   void closeAllContexts(const bool isUpdateViewer);
138
139   /// Returns currently installed AIS_InteractiveContext
140   Handle(AIS_InteractiveContext) AISContext() const;
141
142 protected:
143   XGUI_Workshop* myWorkshop;
144
145   typedef std::map<boost::shared_ptr<ModelAPI_Feature>, Handle(AIS_InteractiveObject) > FeatureToAISMap;
146   FeatureToAISMap myFeature2AISObjectMap;
147 };
148
149
150 #endif