1 // File: XGUI_Displayer.cpp
2 // Created: 20 Apr 2014
3 // Author: Natalia ERMOLAEVA
5 #include "XGUI_Displayer.h"
6 #include "XGUI_Viewer.h"
8 #include <ModelAPI_Document.h>
10 #include <AIS_InteractiveContext.hxx>
11 #include <AIS_ListOfInteractive.hxx>
12 #include <AIS_ListIteratorOfListOfInteractive.hxx>
14 #include <AIS_Shape.hxx>
16 XGUI_Displayer::XGUI_Displayer(XGUI_Viewer* theViewer)
21 XGUI_Displayer::~XGUI_Displayer()
25 void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
26 const bool isUpdateViewer)
30 void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
31 const TopoDS_Shape& theShape, const bool isUpdateViewer)
33 Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
35 Handle(AIS_Shape) anAIS = new AIS_Shape(theShape);
36 std::vector<Handle(AIS_InteractiveObject)> aDispAIS;
37 if (myFeature2AISObjectMap.find(theFeature) != myFeature2AISObjectMap.end()) {
38 aDispAIS = myFeature2AISObjectMap[theFeature];
40 aDispAIS.push_back(anAIS);
41 myFeature2AISObjectMap[theFeature] = aDispAIS;
43 aContext->Display(anAIS, Standard_False);
46 aContext->UpdateCurrentViewer();
49 void XGUI_Displayer::Erase(boost::shared_ptr<ModelAPI_Feature> theFeature,
50 const bool isUpdateViewer)
52 if (myFeature2AISObjectMap.find(theFeature) == myFeature2AISObjectMap.end())
55 std::vector<Handle(AIS_InteractiveObject)> aDispAIS = myFeature2AISObjectMap[theFeature];
56 std::vector<Handle(AIS_InteractiveObject)>::const_iterator anIt = aDispAIS.begin(),
57 aLast = aDispAIS.end();
58 Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
59 for (; anIt != aLast; anIt++) {
60 Handle(AIS_InteractiveObject) anAIS = *anIt;
61 Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anAIS);
62 if (anAISShape.IsNull())
64 aContext->Erase(anAISShape);
68 aContext->UpdateCurrentViewer();
71 void XGUI_Displayer::LocalSelection(boost::shared_ptr<ModelAPI_Feature> theFeature,
72 const TopoDS_Shape& theShape,
73 const int theMode, const bool isUpdateViewer)
75 Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
77 Handle(AIS_Shape) anAIS = new AIS_Shape(theShape);
78 std::vector<Handle(AIS_InteractiveObject)> aDispAIS;
79 if (myFeature2AISObjectMap.find(theFeature) != myFeature2AISObjectMap.end()) {
80 aDispAIS = myFeature2AISObjectMap[theFeature];
82 aDispAIS.push_back(anAIS);
83 myFeature2AISObjectMap[theFeature] = aDispAIS;
84 aContext->Display(anAIS, Standard_False);
86 AIS_ListOfInteractive anAISList;
87 anAISList.Append(anAIS);
88 myViewer->setLocalSelection(anAISList, theMode, true);
91 void XGUI_Displayer::GlobalSelection(const bool isUpdateViewer)
93 myViewer->setGlobalSelection(true);