1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: XGUI_ModuleConnector.cpp
4 // Created: 3 June 2014
5 // Author: Vitaly Smetannikov
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"
15 #include <AIS_Shape.hxx>
18 XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
19 : ModuleBase_IWorkshop(theWorkshop),
20 myWorkshop(theWorkshop)
22 XGUI_SelectionMgr* aSelector = myWorkshop->selector();
23 connect(aSelector, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
25 XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
27 connect(anOperationMgr, SIGNAL(operationStarted(ModuleBase_Operation*)),
28 SIGNAL(operationStarted(ModuleBase_Operation*)));
29 connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
30 SIGNAL(operationStopped(ModuleBase_Operation*)));
31 connect(anOperationMgr, SIGNAL(operationResumed(ModuleBase_Operation*)),
32 SIGNAL(operationResumed(ModuleBase_Operation*)));
33 connect(anOperationMgr, SIGNAL(operationComitted(ModuleBase_Operation*)),
34 SIGNAL(operationComitted(ModuleBase_Operation*)));
35 connect(anOperationMgr, SIGNAL(operationAborted(ModuleBase_Operation*)),
36 SIGNAL(operationAborted(ModuleBase_Operation*)));
38 //myDocumentShapeFilter = new ModuleBase_ShapeDocumentFilter(this);
41 XGUI_ModuleConnector::~XGUI_ModuleConnector()
43 //myDocumentShapeFilter.Nullify();
46 ModuleBase_ISelection* XGUI_ModuleConnector::selection() const
48 return myWorkshop->selector()->selection();
51 ModuleBase_IModule* XGUI_ModuleConnector::module() const
53 return myWorkshop->module();
56 ModuleBase_IViewer* XGUI_ModuleConnector::viewer() const
58 return myWorkshop->viewer();
61 ModuleBase_Operation* XGUI_ModuleConnector::currentOperation() const
63 return myWorkshop->operationMgr()->currentOperation();
67 void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
69 XGUI_Displayer* aDisp = myWorkshop->displayer();
70 // Close context if it was opened in order to clear stsndard selection modes
71 aDisp->closeLocalContexts(false);
72 aDisp->openLocalContext();
73 // Convert shape types to selection types
75 foreach(int aType, theTypes) {
76 aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)aType));
78 aDisp->activateObjects(aModes);
79 //TODO: We have to open Local context because at neutral point filters don't work (bug 25340)
80 //aDisp->addSelectionFilter(myDocumentShapeFilter);
83 void XGUI_ModuleConnector::deactivateSubShapesSelection()
85 XGUI_Displayer* aDisp = myWorkshop->displayer();
86 // The document limitation selection has to be only during operation
87 //aDisp->removeSelectionFilter(myDocumentShapeFilter);
88 aDisp->closeLocalContexts(false);
91 AISObjectPtr XGUI_ModuleConnector::findPresentation(const ObjectPtr& theObject) const
93 XGUI_Displayer* aDisp = myWorkshop->displayer();
94 return aDisp->getAISObject(theObject);
97 ObjectPtr XGUI_ModuleConnector::findPresentedObject(const AISObjectPtr& theAIS) const
99 XGUI_Displayer* aDisp = myWorkshop->displayer();
100 return aDisp->getObject(theAIS);
103 void XGUI_ModuleConnector::setSelected(const QObjectPtrList& theFeatures)
105 XGUI_Displayer* aDisp = myWorkshop->displayer();
106 aDisp->setSelected(theFeatures);
109 bool XGUI_ModuleConnector::canStartOperation(QString theId)
111 return myWorkshop->operationMgr()->canStartOperation(theId);