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