Salome HOME
refs #30 - Sketch base GUI: create, draw lines
[modules/shaper.git] / src / XGUI / XGUI_Displayer.cpp
1 // File:        XGUI_Displayer.cpp
2 // Created:     20 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #include "XGUI_Displayer.h"
6 #include "XGUI_Viewer.h"
7
8 #include <ModelAPI_Document.h>
9
10 #include <AIS_InteractiveContext.hxx>
11 #include <AIS_ListOfInteractive.hxx>
12
13 #include <AIS_Shape.hxx>
14
15 XGUI_Displayer::XGUI_Displayer(XGUI_Viewer* theViewer)
16 : myViewer(theViewer)
17 {
18 }
19
20 XGUI_Displayer::~XGUI_Displayer()
21 {
22 }
23
24 void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
25                              const bool isUpdateViewer)
26 {
27 }
28
29 void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
30                              const TopoDS_Shape& theShape, const bool isUpdateViewer)
31 {
32   Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
33
34   Handle(AIS_Shape) anAIS = new AIS_Shape(theShape);
35   aContext->Display(anAIS, Standard_False);
36
37   if (isUpdateViewer)
38     aContext->UpdateCurrentViewer();
39 }
40
41 void XGUI_Displayer::Erase(boost::shared_ptr<ModelAPI_Feature> theFeature,
42                            const TopoDS_Shape& theShape, const bool isUpdateViewer)
43 {
44   Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
45   aContext->EraseAll();
46   if (isUpdateViewer)
47     aContext->UpdateCurrentViewer();
48 }
49
50 void XGUI_Displayer::LocalSelection(boost::shared_ptr<ModelAPI_Feature> theFeature,
51                                     const TopoDS_Shape& theShape,
52                                     const int theMode, const bool isUpdateViewer)
53 {
54   Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
55
56   Handle(AIS_Shape) anAIS = new AIS_Shape(theShape);
57   aContext->Display(anAIS, Standard_False);
58   AIS_ListOfInteractive anAISList;
59   anAISList.Append(anAIS);
60   myViewer->setLocalSelection(anAISList, theMode, true);
61 }
62
63 void XGUI_Displayer::GlobalSelection(const bool isUpdateViewer)
64 {
65   myViewer->setGlobalSelection(true);
66 }
67