1 // File: XGUI_Displayer.h
2 // Created: 20 Apr 2014
3 // Author: Natalia ERMOLAEVA
5 #ifndef XGUI_Displayer_H
6 #define XGUI_Displayer_H
11 #include <boost/shared_ptr.hpp>
13 #include <TopoDS_Shape.hxx>
14 #include <AIS_InteractiveObject.hxx>
15 #include <AIS_InteractiveContext.hxx>
16 #include <NCollection_List.hxx>
18 #include <ModelAPI_Feature.h>
20 #include <XGUI_ViewerPrs.h>
27 class ModelAPI_Feature;
30 /**\class XGUI_Displayer
32 * \brief Displayer. Provides mechanizm of display/erase of objects in the viewer
34 class XGUI_EXPORT XGUI_Displayer
38 /// \param theViewer the viewer
39 XGUI_Displayer(XGUI_Workshop* theWorkshop);
41 virtual ~XGUI_Displayer();
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);
47 /// Returns the feature visibility state.
48 /// \param theFeature a feature instance
49 bool isVisible(FeaturePtr theFeature);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
112 /// Erase all presentations
113 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
114 //void EraseAll(const bool isUpdateViewer = true);
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);
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);
124 /// Updates the viewer
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;
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);
141 /// Returns currently installed AIS_InteractiveContext
142 Handle(AIS_InteractiveContext) AISContext() const;
145 XGUI_Workshop* myWorkshop;
147 typedef std::map<FeaturePtr, Handle(AIS_InteractiveObject) > FeatureToAISMap;
148 FeatureToAISMap myFeature2AISObjectMap;