Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1
[modules/shaper.git] / src / XGUI / XGUI_ModuleConnector.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        XGUI_ModuleConnector.cpp
4 // Created:     3 June 2014
5 // Author:      Vitaly Smetannikov
6
7 #include "XGUI_ModuleConnector.h"
8 #include "XGUI_Workshop.h"
9 #include "XGUI_ViewerProxy.h"
10 #include "XGUI_SelectionMgr.h"
11 #include "XGUI_Selection.h"
12 #include "XGUI_OperationMgr.h"
13 #include "XGUI_Displayer.h"
14
15 #include <AIS_Shape.hxx>
16
17
18 XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
19     : ModuleBase_IWorkshop(theWorkshop),
20       myWorkshop(theWorkshop)
21 {
22   XGUI_SelectionMgr* aSelector = myWorkshop->selector();
23   connect(aSelector, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
24   
25   XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
26
27   //myDocumentShapeFilter = new ModuleBase_ShapeDocumentFilter(this);
28 }
29
30 XGUI_ModuleConnector::~XGUI_ModuleConnector()
31 {
32   //myDocumentShapeFilter.Nullify();
33 }
34
35 ModuleBase_ISelection* XGUI_ModuleConnector::selection() const
36 {
37   return myWorkshop->selector()->selection();
38 }
39
40 ModuleBase_IModule* XGUI_ModuleConnector::module() const
41 {
42   return myWorkshop->module();
43 }
44
45 ModuleBase_IViewer* XGUI_ModuleConnector::viewer() const
46 {
47   return myWorkshop->viewer();
48 }
49
50 ModuleBase_Operation* XGUI_ModuleConnector::currentOperation() const
51 {
52   return myWorkshop->operationMgr()->currentOperation();
53 }
54
55
56 void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
57 {
58   XGUI_Displayer* aDisp = myWorkshop->displayer();
59   // Close context if it was opened in order to clear stsndard selection modes
60   //aDisp->closeLocalContexts(false);
61   //aDisp->openLocalContext();
62   // Convert shape types to selection types
63   QIntList aModes;
64   foreach(int aType, theTypes) {
65     aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)aType));
66   }
67   aDisp->activateObjects(aModes);
68   //TODO: We have to open Local context because at neutral point filters don't work (bug 25340)
69   //aDisp->addSelectionFilter(myDocumentShapeFilter);
70 }
71
72 void XGUI_ModuleConnector::deactivateSubShapesSelection()
73 {
74   XGUI_Displayer* aDisp = myWorkshop->displayer();
75   // Clear selection modes
76   QIntList aModes;
77   aDisp->activateObjects(aModes);
78   // The document limitation selection has to be only during operation
79   //aDisp->removeSelectionFilter(myDocumentShapeFilter);
80   //aDisp->closeLocalContexts(false);
81 }
82
83 AISObjectPtr XGUI_ModuleConnector::findPresentation(const ObjectPtr& theObject) const
84 {
85   XGUI_Displayer* aDisp = myWorkshop->displayer();
86   return aDisp->getAISObject(theObject);
87 }
88
89 ObjectPtr XGUI_ModuleConnector::findPresentedObject(const AISObjectPtr& theAIS) const
90 {
91   XGUI_Displayer* aDisp = myWorkshop->displayer();
92   return aDisp->getObject(theAIS);
93 }
94
95 void XGUI_ModuleConnector::setSelected(const QObjectPtrList& theFeatures)
96 {
97   XGUI_Displayer* aDisp = myWorkshop->displayer();
98   aDisp->setSelected(theFeatures);
99 }
100
101 bool XGUI_ModuleConnector::canStartOperation(QString theId)
102 {
103   return myWorkshop->operationMgr()->canStartOperation(theId);
104 }