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_Feature.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(FeaturePtr theFeature);
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 bool display(FeaturePtr theFeature, bool isUpdateViewer = true);
60 /// Display the feature and a shape. This shape would be associated to the given feature
61 /// \param theFeature a feature instance
62 /// \param theAIS AIS presentation
63 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
64 /// Returns true if the Feature succesfully displayed
65 bool display(FeaturePtr theFeature, boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdateViewer = true);
67 /// Display the shape and activate selection of sub-shapes
68 /// \param theFeature a feature instance
69 /// \param theAIS an AIS object
70 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
71 /// \returns true if the presentation is created
72 bool redisplay(FeaturePtr theFeature,
73 boost::shared_ptr<GeomAPI_AISObject> theAIS,
74 const bool isUpdateViewer = true);
76 /** Redisplay the shape if it was displayed
77 * \param theFeature a feature instance
78 * \param isUpdateViewer the parameter whether the viewer should be update immediatelly
80 bool redisplay(FeaturePtr theFeature, 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 QFeatureList& theFeatures, const bool isStop,
100 const bool isUpdateViewer);
103 * Add presentations which corresponds to the given features to current selection
104 * \param theFeatures a list of features to be selected
105 * isUpdateViewer the parameter whether the viewer should be update immediatelly
107 void setSelected(const QFeatureList& theFeatures, bool isUpdateViewer = true);
109 /// Erase the feature and a shape.
110 /// \param theFeature a feature instance
111 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
112 void erase(FeaturePtr theFeature, const bool isUpdateViewer = true);
114 /// Erase all presentations
115 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
116 //void EraseAll(const bool isUpdateViewer = true);
118 /// Erase AIS interactive objects, which has an empty feature in the internal map
119 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
120 void eraseDeletedFeatures(const bool isUpdateViewer = true);
122 /// Deactivates selection of sub-shapes
123 /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
124 void closeLocalContexts(const bool isUpdateViewer = true);
126 /// Updates the viewer
129 /// Searches the interactive object by feature
130 /// \param theFeature the feature or NULL if it not visualized
131 /// \return theIO an interactive object
132 boost::shared_ptr<GeomAPI_AISObject> getAISObject(FeaturePtr theFeature) const;
134 /// Searches the feature by interactive object
135 /// \param theIO an interactive object
136 /// \return feature the feature or NULL if it not visualized
137 FeaturePtr getFeature(Handle(AIS_InteractiveObject) theIO) const;
140 /// Deactivate local selection
141 /// \param isUpdateViewer the state wether the viewer should be updated immediatelly
142 void closeAllContexts(const bool isUpdateViewer);
144 /// Returns currently installed AIS_InteractiveContext
145 Handle(AIS_InteractiveContext) AISContext() const;
148 XGUI_Workshop* myWorkshop;
150 typedef std::map<FeaturePtr, boost::shared_ptr<GeomAPI_AISObject> > FeatureToAISMap;
151 FeatureToAISMap myFeature2AISObjectMap;