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 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);
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);
71 /// Display the shape and activate selection of sub-shapes
72 /// \param theFeature a feature instance
73 /// \param theShape a shape
74 /// \param theMode a local selection mode
75 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
76 void Redisplay(boost::shared_ptr<ModelAPI_Feature> theFeature,
77 const TopoDS_Shape& theShape, const bool isUpdateViewer = true);
79 /// Display the shape and activate selection of sub-shapes
80 /// \param theFeature a feature instance
81 /// \param theShape a shape
82 /// \param theMode a list of local selection modes
83 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
84 void ActivateInLocalContext(boost::shared_ptr<ModelAPI_Feature> theFeature,
85 const std::list<int>& theModes, const bool isUpdateViewer = true);
87 /// Stop the current selection and color the given features to the selection color
88 /// \param theFeatures a list of features to be disabled
89 /// \param theToStop the boolean state whether it it stopped or non stopped
90 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
91 void StopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop,
92 const bool isUpdateViewer);
94 /// Set the features are selected
95 /// \param theFeatures a list of features to be selected
96 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
97 void SetSelected(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isUpdateViewer);
99 /// Erase the feature and a shape.
100 /// \param theFeature a feature instance
101 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
102 void Erase(boost::shared_ptr<ModelAPI_Feature> theFeature, const bool isUpdateViewer = true);
104 /// Erase all presentations
105 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
106 void EraseAll(const bool isUpdateViewer = true);
108 /// Erase AIS interactive objects, which has an empty feature in the internal map
109 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
110 void EraseDeletedFeatures(const bool isUpdateViewer = true);
112 /// Deactivates selection of sub-shapes
113 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
114 void CloseLocalContexts(const bool isUpdateViewer = true);
116 /// Updates the viewer
120 /// Searches the feature by interactive object
121 /// \param theIO an interactive object
122 /// \return feature the feature or NULL if it not visualized
123 boost::shared_ptr<ModelAPI_Feature> GetFeature(Handle(AIS_InteractiveObject) theIO);
124 /// Deactivate local selection
125 /// \param isUpdateViewer the state wether the viewer should be updated immediatelly
126 void CloseAllContexts(const bool isUpdateViewer);
128 /// Returns currently installed AIS_InteractiveContext
129 Handle(AIS_InteractiveContext) AISContext() const;
132 XGUI_Workshop* myWorkshop;
134 typedef std::map<boost::shared_ptr<ModelAPI_Feature>, Handle(AIS_InteractiveObject) > FeatureToAISMap;
135 FeatureToAISMap myFeature2AISObjectMap;