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"
14 #include "XGUI_PropertyPanel.h"
16 #include <AIS_Shape.hxx>
19 XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
20 : ModuleBase_IWorkshop(theWorkshop),
21 myWorkshop(theWorkshop)
23 XGUI_SelectionMgr* aSelector = myWorkshop->selector();
24 connect(aSelector, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
26 XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
28 //myDocumentShapeFilter = new ModuleBase_ShapeDocumentFilter(this);
31 XGUI_ModuleConnector::~XGUI_ModuleConnector()
33 //myDocumentShapeFilter.Nullify();
36 ModuleBase_ISelection* XGUI_ModuleConnector::selection() const
38 return myWorkshop->selector()->selection();
41 ModuleBase_IModule* XGUI_ModuleConnector::module() const
43 return myWorkshop->module();
46 ModuleBase_IViewer* XGUI_ModuleConnector::viewer() const
48 return myWorkshop->viewer();
51 ModuleBase_IPropertyPanel* XGUI_ModuleConnector::propertyPanel() const
53 return myWorkshop->propertyPanel();
56 ModuleBase_Operation* XGUI_ModuleConnector::currentOperation() const
58 return myWorkshop->operationMgr()->currentOperation();
62 void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
64 XGUI_Displayer* aDisp = myWorkshop->displayer();
65 // Close context if it was opened in order to clear stsndard selection modes
66 //aDisp->closeLocalContexts(false);
67 //aDisp->openLocalContext();
68 // Convert shape types to selection types
70 foreach(int aType, theTypes) {
71 if (aType > TopAbs_SHAPE)
74 aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)aType));
76 aDisp->activateObjects(aModes);
77 //TODO: We have to open Local context because at neutral point filters don't work (bug 25340)
78 //aDisp->addSelectionFilter(myDocumentShapeFilter);
81 void XGUI_ModuleConnector::deactivateSubShapesSelection()
83 XGUI_Displayer* aDisp = myWorkshop->displayer();
84 // Clear selection modes
86 aDisp->activateObjects(aModes);
87 // The document limitation selection has to be only during operation
88 //aDisp->removeSelectionFilter(myDocumentShapeFilter);
89 //aDisp->closeLocalContexts(false);
92 AISObjectPtr XGUI_ModuleConnector::findPresentation(const ObjectPtr& theObject) const
94 XGUI_Displayer* aDisp = myWorkshop->displayer();
95 return aDisp->getAISObject(theObject);
98 ObjectPtr XGUI_ModuleConnector::findPresentedObject(const AISObjectPtr& theAIS) const
100 XGUI_Displayer* aDisp = myWorkshop->displayer();
101 return aDisp->getObject(theAIS);
104 void XGUI_ModuleConnector::setSelected(const QObjectPtrList& theFeatures)
106 XGUI_Displayer* aDisp = myWorkshop->displayer();
107 if (theFeatures.isEmpty()) {
108 myWorkshop->selector()->clearSelection();
110 aDisp->setSelected(theFeatures);
114 bool XGUI_ModuleConnector::canStartOperation(QString theId)
116 return myWorkshop->operationMgr()->canStartOperation(theId);