1 // File: XGUI_ModuleConnector.cpp
2 // Created: 3 June 2014
3 // Author: Vitaly Smetannikov
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 #include "XGUI_Displayer.h"
13 #include <AIS_Shape.hxx>
16 XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
17 : ModuleBase_IWorkshop(theWorkshop),
18 myWorkshop(theWorkshop)
20 XGUI_SelectionMgr* aSelector = myWorkshop->selector();
21 connect(aSelector, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
23 XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
25 connect(anOperationMgr, SIGNAL(operationStarted(ModuleBase_Operation*)),
26 this, SIGNAL(operationStarted(ModuleBase_Operation*)));
27 connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
28 this, SIGNAL(operationStopped(ModuleBase_Operation*)));
30 myDocumentShapeFilter = new ModuleBase_ShapeDocumentFilter(this);
33 XGUI_ModuleConnector::~XGUI_ModuleConnector()
35 myDocumentShapeFilter.Nullify();
38 ModuleBase_ISelection* XGUI_ModuleConnector::selection() const
40 return myWorkshop->selector()->selection();
43 ModuleBase_IModule* XGUI_ModuleConnector::module() const
45 return myWorkshop->module();
48 ModuleBase_IViewer* XGUI_ModuleConnector::viewer() const
50 return myWorkshop->viewer();
53 ModuleBase_Operation* XGUI_ModuleConnector::currentOperation() const
55 return myWorkshop->operationMgr()->currentOperation();
59 void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
61 XGUI_Displayer* aDisp = myWorkshop->displayer();
62 // Close context if it was opened in order to clear stsndard selection modes
63 aDisp->closeLocalContexts(false);
64 aDisp->openLocalContext();
65 // Convert shape types to selection types
67 foreach(int aType, theTypes) {
68 aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)aType));
70 aDisp->activateObjectsOutOfContext(aModes);
71 //TODO: We have to open Local context because at neutral point filters don't work (bug 25340)
72 aDisp->addSelectionFilter(myDocumentShapeFilter);
75 void XGUI_ModuleConnector::deactivateSubShapesSelection()
77 XGUI_Displayer* aDisp = myWorkshop->displayer();
78 // The document limitation selection has to be only during operation
79 aDisp->removeSelectionFilter(myDocumentShapeFilter);
80 aDisp->closeLocalContexts(false);
83 AISObjectPtr XGUI_ModuleConnector::findPresentation(const ObjectPtr& theObject) const
85 XGUI_Displayer* aDisp = myWorkshop->displayer();
86 return aDisp->getAISObject(theObject);
89 ObjectPtr XGUI_ModuleConnector::findPresentedObject(const AISObjectPtr& theAIS) const
91 XGUI_Displayer* aDisp = myWorkshop->displayer();
92 return aDisp->getObject(theAIS);
95 void XGUI_ModuleConnector::setSelected(const QList<ObjectPtr>& theFeatures)
97 XGUI_Displayer* aDisp = myWorkshop->displayer();
98 aDisp->setSelected(theFeatures);