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 <XGUI_ViewerPrs.h>
25 class ModelAPI_Feature;
28 /**\class XGUI_Displayer
30 * \brief Displayer. Provides mechanizm of display/erase of objects in the viewer
32 class XGUI_EXPORT XGUI_Displayer
36 /// \param theViewer the viewer
37 XGUI_Displayer(XGUI_Workshop* theWorkshop);
39 virtual ~XGUI_Displayer();
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);
45 /// Returns the feature visibility state.
46 /// \param theFeature a feature instance
47 bool IsVisible(boost::shared_ptr<ModelAPI_Feature> theFeature);
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);
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);
61 /// Returns the feature, that was displayed with this shape
62 /// \param theShape a shape
63 boost::shared_ptr<ModelAPI_Feature> GetFeature(const TopoDS_Shape& theShape);
65 /// Returns a list of viewer presentations
66 /// \param theShapes list of shapes to find corresponded features
67 /// \return list of presentations
68 std::list<XGUI_ViewerPrs> GetViewerPrs(const NCollection_List<TopoDS_Shape>& theShapes);
70 /// Display the shape and activate selection of sub-shapes
71 /// \param theFeature a feature instance
72 /// \param theShape a shape
73 /// \param theMode a local selection mode
74 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
75 void RedisplayInLocalContext(boost::shared_ptr<ModelAPI_Feature> theFeature,
76 const TopoDS_Shape& theShape,
77 const std::list<int>& theMode, const bool isUpdateViewer = true);
79 /// Erase the feature and a shape.
80 /// \param theFeature a feature instance
81 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
82 void Erase(boost::shared_ptr<ModelAPI_Feature> theFeature, const bool isUpdateViewer = true);
84 /// Erase all presentations
85 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
86 void EraseAll(const bool isUpdateViewer = true);
88 /// Deactivates selection of sub-shapes
89 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
90 void CloseLocalContexts(const bool isUpdateViewer = true);
92 /// Updates the viewer
96 /// Deactivate local selection
97 /// \param isUpdateViewer the state wether the viewer should be updated immediatelly
98 void closeAllContexts(const bool isUpdateViewer);
100 /// Returns currently installed AIS_InteractiveContext
101 Handle(AIS_InteractiveContext) AISContext() const;
104 XGUI_Workshop* myWorkshop;
106 typedef std::map<boost::shared_ptr<ModelAPI_Feature>, Handle(AIS_InteractiveObject) > FeatureToAISMap;
107 FeatureToAISMap myFeature2AISObjectMap;