Salome HOME
Provide local selection for operations outside of sketcher
[modules/shaper.git] / src / XGUI / XGUI_ModuleConnector.cpp
1 // File:        XGUI_ModuleConnector.cpp
2 // Created:     3 June 2014
3 // Author:      Vitaly Smetannikov
4
5 #include "XGUI_ModuleConnector.h"
6 #include "XGUI_Workshop.h"
7 #include "XGUI_ViewerProxy.h"
8 #include "XGUI_SelectionMgr.h"
9 #include "XGUI_Selection.h"
10 #include "XGUI_OperationMgr.h"
11
12 XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
13     : ModuleBase_IWorkshop(theWorkshop),
14       myWorkshop(theWorkshop)
15 {
16   XGUI_SelectionMgr* aSelector = myWorkshop->selector();
17   connect(aSelector, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
18   
19   XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
20
21   connect(anOperationMgr, SIGNAL(operationStarted(ModuleBase_Operation*)), 
22     this, SIGNAL(operationStarted(ModuleBase_Operation*)));
23   connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), 
24     this, SIGNAL(operationStopped(ModuleBase_Operation*)));
25 }
26
27 XGUI_ModuleConnector::~XGUI_ModuleConnector()
28 {
29 }
30
31 ModuleBase_ISelection* XGUI_ModuleConnector::selection() const
32 {
33   return myWorkshop->selector()->selection();
34 }
35
36 ModuleBase_IModule* XGUI_ModuleConnector::module() const
37 {
38   return myWorkshop->module();
39 }
40
41 ModuleBase_IViewer* XGUI_ModuleConnector::viewer() const
42 {
43   return myWorkshop->viewer();
44 }
45
46 ModuleBase_Operation* XGUI_ModuleConnector::currentOperation() const
47 {
48   return myWorkshop->operationMgr()->currentOperation();
49 }
50
51
52 void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
53 {
54   Handle(AIS_InteractiveContext) aAIS = myWorkshop->viewer()->AISContext();
55   if (!aAIS->HasOpenedContext())
56     aAIS->OpenLocalContext();
57   foreach(int aType, theTypes)
58     aAIS->ActivateStandardMode((TopAbs_ShapeEnum)aType);
59 }
60
61 void XGUI_ModuleConnector::deactivateSubShapesSelection()
62 {
63   Handle(AIS_InteractiveContext) aAIS = myWorkshop->viewer()->AISContext();
64   aAIS->CloseAllContexts();
65 }