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 <GeomAPI_AISObject.h>
15 #include <TopoDS_Shape.hxx>
16 #include <AIS_InteractiveObject.hxx>
17 #include <AIS_InteractiveContext.hxx>
18 #include <NCollection_List.hxx>
20 #include <ModelAPI_Result.h>
22 #include <ModuleBase_Definitions.h>
23 #include <ModuleBase_ViewerPrs.h>
30 class ModelAPI_Feature;
33 /**\class XGUI_Displayer
35 * \brief Displayer. Provides mechanizm of display/erase of objects in the viewer
37 class XGUI_EXPORT XGUI_Displayer
41 /// \param theViewer the viewer
42 XGUI_Displayer(XGUI_Workshop* theWorkshop);
44 virtual ~XGUI_Displayer();
46 /// Set AIS_InteractiveContext object in case if it was changed
47 /// or can not be initialized in constructor
48 void setAISContext(const Handle(AIS_InteractiveContext)& theAIS);
50 /// Returns the feature visibility state.
51 /// \param theFeature a feature instance
52 bool isVisible(ObjectPtr theObject);
54 /// Display the feature. Obtain the visualized object from the feature.
55 /// \param theFeature a feature instance
56 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
57 /// Returns true if the Feature succesfully displayed
58 void display(ObjectPtr theObject, bool isUpdateViewer = true);
60 /// Display the given AIS object. To hide this object use corresponde erase method
61 void display(boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdate = true);
63 /// Redisplay the shape and activate selection of sub-shapes
64 /// \param theFeature a feature instance
65 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
66 //void redisplay(Handle(AIS_InteractiveObject) theAIS, const bool isUpdateViewer = true);
68 /// Display the shape and activate selection of sub-shapes
69 /// \param theFeature a feature instance
70 /// \param theShape a shape
71 /// \param theMode a list of local selection modes
72 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
73 void activateInLocalContext(ObjectPtr theFeature, const std::list<int>& theModes,
74 const bool isUpdateViewer = true);
76 /// Stop the current selection and color the given features to the selection color
77 /// \param theFeatures a list of features to be disabled
78 /// \param theToStop the boolean state whether it it stopped or non stopped
79 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
80 void stopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop,
81 const bool isUpdateViewer);
84 * Add presentations which corresponds to the given features to current selection
85 * \param theFeatures a list of features to be selected
86 * isUpdateViewer the parameter whether the viewer should be update immediatelly
88 void setSelected(const QList<ObjectPtr>& theFeatures, bool isUpdateViewer = true);
90 /// Erase the feature and a shape.
91 /// \param theFeature a feature instance
92 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
93 void erase(ObjectPtr theObject, const bool isUpdateViewer = true);
95 /// Erase the given AIS object displayed by corresponded display method
96 void erase(boost::shared_ptr<GeomAPI_AISObject> theAIS, const bool isUpdate = true);
98 /// Erase all presentations
99 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
100 void eraseAll(const bool isUpdateViewer = true);
102 /// Erase AIS interactive objects, which has an empty feature in the internal map
103 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
104 void eraseDeletedResults(const bool isUpdateViewer = true);
106 /// Deactivates selection of sub-shapes
107 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
108 void closeLocalContexts(const bool isUpdateViewer = true);
110 /// Updates the viewer
113 /// Searches the interactive object by feature
114 /// \param theFeature the feature or NULL if it not visualized
115 /// \return theIO an interactive object
116 boost::shared_ptr<GeomAPI_AISObject> getAISObject(ObjectPtr theFeature) const;
118 /// Searches the feature by interactive object
119 /// \param theIO an interactive object
120 /// \return feature the feature or NULL if it not visualized
121 ObjectPtr getObject(Handle(AIS_InteractiveObject) theIO) const;
123 void deactivate(ObjectPtr theFeature);
125 void activate(ObjectPtr theFeature);
127 /// Activates in local context displayed outside of the context.
128 /// \param theModes - selection modes to activate
129 /// \param theFilter - filter for selection
130 void activateObjectsOutOfContext(const std::list<int>& theModes,
131 Handle(SelectMgr_Filter) theFilter);
133 void deactivateObjectsOutOfContext();
136 /// Deactivate local selection
137 /// \param isUpdateViewer the state wether the viewer should be updated immediatelly
138 void closeAllContexts(const bool isUpdateViewer);
140 /// Returns currently installed AIS_InteractiveContext
141 Handle(AIS_InteractiveContext) AISContext() const;
143 /// Display the feature and a shape. This shape would be associated to the given feature
144 /// \param theFeature a feature instance
145 /// \param theAIS AIS presentation
146 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
147 /// Returns true if the Feature succesfully displayed
148 void display(ObjectPtr theObject, boost::shared_ptr<GeomAPI_AISObject> theAIS,
149 bool isUpdateViewer = true);
151 /// Display the shape and activate selection of sub-shapes
152 /// \param theFeature a feature instance
153 /// \param theAIS an AIS object
154 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
155 /// \returns true if the presentation is created
156 //bool redisplay(ObjectPtr theObject,
157 // boost::shared_ptr<GeomAPI_AISObject> theAIS,
158 // const bool isUpdateViewer = true);
160 /** Redisplay the shape if it was displayed
161 * \param theFeature a feature instance
162 * \param isUpdateViewer the parameter whether the viewer should be update immediatelly
164 void redisplay(ObjectPtr theObject, bool isUpdateViewer = true);
167 XGUI_Workshop* myWorkshop;
169 typedef std::map<ObjectPtr, boost::shared_ptr<GeomAPI_AISObject> > ResultToAISMap;
170 ResultToAISMap myResult2AISObjectMap;