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>
17 #include <ModuleBase_ViewerPrs.h>
19 #include <AIS_Shape.hxx>
22 XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
23 : ModuleBase_IWorkshop(theWorkshop),
24 myWorkshop(theWorkshop)
26 XGUI_SelectionMgr* aSelector = myWorkshop->selector();
27 connect(aSelector, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
29 XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
32 XGUI_ModuleConnector::~XGUI_ModuleConnector()
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 QObjectPtrList XGUI_ModuleConnector::activeObjects(const QObjectPtrList& theObjList) const
64 QObjectPtrList aActiveOPbjects;
65 ModuleBase_IModule* aModule = myWorkshop->module();
66 // Activate objects only which can be activated
67 foreach (ObjectPtr aObj, theObjList) {
68 if (aModule->canActivateSelection(aObj))
69 aActiveOPbjects.append(aObj);
71 return aActiveOPbjects;
74 void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
76 XGUI_Displayer* aDisp = myWorkshop->displayer();
77 aDisp->activateObjects(theTypes, activeObjects(aDisp->displayedObjects()));
80 void XGUI_ModuleConnector::deactivateSubShapesSelection()
82 // Clear selection modes
83 activateModuleSelectionModes();
86 void XGUI_ModuleConnector::activateModuleSelectionModes()
88 XGUI_Displayer* aDisp = myWorkshop->displayer();
89 myWorkshop->activateObjectsSelection(activeObjects(aDisp->displayedObjects()));
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 ObjectPtr anObject = aDisp->getObject(theAIS);
105 void XGUI_ModuleConnector::setSelected(const QList<ModuleBase_ViewerPrsPtr>& theValues)
107 XGUI_Displayer* aDisp = myWorkshop->displayer();
108 if (theValues.isEmpty()) {
109 myWorkshop->selector()->clearSelection();
111 aDisp->setSelected(theValues);
115 bool XGUI_ModuleConnector::canStartOperation(QString theId)
117 return myWorkshop->operationMgr()->canStartOperation(theId);
120 ModuleBase_Operation* XGUI_ModuleConnector::findStartedOperation(const QString& theId)
122 return myWorkshop->operationMgr()->findOperation(theId);
125 bool XGUI_ModuleConnector::canStopOperation(ModuleBase_Operation* theOperation)
127 return myWorkshop->operationMgr()->canStopOperation(theOperation);
130 void XGUI_ModuleConnector::abortOperation(ModuleBase_Operation* theOperation)
132 myWorkshop->operationMgr()->abortOperation(theOperation);
135 void XGUI_ModuleConnector::updateCommandStatus()
137 myWorkshop->updateCommandStatus();