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();
31 XGUI_ModuleConnector::~XGUI_ModuleConnector()
35 ModuleBase_ISelection* XGUI_ModuleConnector::selection() const
37 return myWorkshop->selector()->selection();
40 ModuleBase_IModule* XGUI_ModuleConnector::module() const
42 return myWorkshop->module();
45 ModuleBase_IViewer* XGUI_ModuleConnector::viewer() const
47 return myWorkshop->viewer();
50 ModuleBase_IPropertyPanel* XGUI_ModuleConnector::propertyPanel() const
52 return myWorkshop->propertyPanel();
55 ModuleBase_Operation* XGUI_ModuleConnector::currentOperation() const
57 return myWorkshop->operationMgr()->currentOperation();
61 QObjectPtrList XGUI_ModuleConnector::activeObjects(const QObjectPtrList& theObjList) const
63 QObjectPtrList aActiveOPbjects;
64 ModuleBase_IModule* aModule = myWorkshop->module();
65 // Activate objects only which can be activated
66 foreach (ObjectPtr aObj, theObjList) {
67 if (aModule->canActivateSelection(aObj))
68 aActiveOPbjects.append(aObj);
70 return aActiveOPbjects;
73 void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
75 XGUI_Displayer* aDisp = myWorkshop->displayer();
76 aDisp->activateObjects(theTypes, activeObjects(aDisp->displayedObjects()));
79 void XGUI_ModuleConnector::deactivateSubShapesSelection()
81 // Clear selection modes
82 activateModuleSelectionModes();
85 void XGUI_ModuleConnector::activateModuleSelectionModes()
87 XGUI_Displayer* aDisp = myWorkshop->displayer();
89 module()->activeSelectionModes(aModes);
90 aDisp->activateObjects(aModes, activeObjects(aDisp->displayedObjects()));
93 AISObjectPtr XGUI_ModuleConnector::findPresentation(const ObjectPtr& theObject) const
95 XGUI_Displayer* aDisp = myWorkshop->displayer();
96 return aDisp->getAISObject(theObject);
99 ObjectPtr XGUI_ModuleConnector::findPresentedObject(const AISObjectPtr& theAIS) const
101 XGUI_Displayer* aDisp = myWorkshop->displayer();
102 ObjectPtr anObject = aDisp->getObject(theAIS);
106 void XGUI_ModuleConnector::setSelected(const QList<ModuleBase_ViewerPrs>& theValues)
108 XGUI_Displayer* aDisp = myWorkshop->displayer();
109 if (theValues.isEmpty()) {
110 myWorkshop->selector()->clearSelection();
112 aDisp->setSelected(theValues);
116 bool XGUI_ModuleConnector::canStartOperation(QString theId)
118 return myWorkshop->operationMgr()->canStartOperation(theId);
121 ModuleBase_Operation* XGUI_ModuleConnector::findStartedOperation(const QString& theId)
123 return myWorkshop->operationMgr()->findOperation(theId);
126 bool XGUI_ModuleConnector::canStopOperation(ModuleBase_Operation* theOperation)
128 return myWorkshop->operationMgr()->canStopOperation(theOperation);
131 void XGUI_ModuleConnector::abortOperation(ModuleBase_Operation* theOperation)
133 myWorkshop->operationMgr()->abortOperation(theOperation);