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 <ModuleBase_IModule.h>
18 #include <AIS_Shape.hxx>
21 XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
22 : ModuleBase_IWorkshop(theWorkshop),
23 myWorkshop(theWorkshop)
25 XGUI_SelectionMgr* aSelector = myWorkshop->selector();
26 connect(aSelector, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
28 XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
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_IPropertyPanel* XGUI_ModuleConnector::propertyPanel() const
55 return myWorkshop->propertyPanel();
58 ModuleBase_Operation* XGUI_ModuleConnector::currentOperation() const
60 return myWorkshop->operationMgr()->currentOperation();
64 void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
66 XGUI_Displayer* aDisp = myWorkshop->displayer();
67 // Close context if it was opened in order to clear stsndard selection modes
68 //aDisp->closeLocalContexts(false);
69 //aDisp->openLocalContext();
70 // Convert shape types to selection types
72 foreach(int aType, theTypes) {
73 if (aType > TopAbs_SHAPE)
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 // Clear selection modes
88 // TODO: check on OCC6.9.0
89 // the module current active modes should not be deactivated in order to save the objects selected
90 // the deactivate object in the mode of selection leads to the object is deselected in the viewer.
91 // But, in OCC6.8.0 this deselection does not happened automatically. It is necessary to call
92 // ClearOutdatedSelection, but this method has an error in the realization, which should be fixed in
93 // the OCC6.9.0 release. Moreother, it is possible that ClearOutdatedSelection will be called inside
94 // Deactivate method of AIS_InteractiveContext. In this case, we need not call it.
95 module()->activeSelectionModes(aModes);
96 aDisp->activateObjects(aModes);
97 // The document limitation selection has to be only during operation
98 //aDisp->removeSelectionFilter(myDocumentShapeFilter);
99 //aDisp->closeLocalContexts(false);
102 AISObjectPtr XGUI_ModuleConnector::findPresentation(const ObjectPtr& theObject) const
104 XGUI_Displayer* aDisp = myWorkshop->displayer();
105 return aDisp->getAISObject(theObject);
108 ObjectPtr XGUI_ModuleConnector::findPresentedObject(const AISObjectPtr& theAIS) const
110 XGUI_Displayer* aDisp = myWorkshop->displayer();
111 return aDisp->getObject(theAIS);
114 void XGUI_ModuleConnector::setSelected(const QObjectPtrList& theFeatures)
116 XGUI_Displayer* aDisp = myWorkshop->displayer();
117 if (theFeatures.isEmpty()) {
118 myWorkshop->selector()->clearSelection();
120 aDisp->setSelected(theFeatures);
124 bool XGUI_ModuleConnector::canStartOperation(QString theId)
126 return myWorkshop->operationMgr()->canStartOperation(theId);