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();
88 myWorkshop->activateObjectsSelection(activeObjects(aDisp->displayedObjects()));
91 AISObjectPtr XGUI_ModuleConnector::findPresentation(const ObjectPtr& theObject) const
93 XGUI_Displayer* aDisp = myWorkshop->displayer();
94 return aDisp->getAISObject(theObject);
97 ObjectPtr XGUI_ModuleConnector::findPresentedObject(const AISObjectPtr& theAIS) const
99 XGUI_Displayer* aDisp = myWorkshop->displayer();
100 ObjectPtr anObject = aDisp->getObject(theAIS);
104 void XGUI_ModuleConnector::setSelected(const QList<ModuleBase_ViewerPrsPtr>& theValues)
106 XGUI_Displayer* aDisp = myWorkshop->displayer();
107 if (theValues.isEmpty()) {
108 myWorkshop->selector()->clearSelection();
110 aDisp->setSelected(theValues);
114 bool XGUI_ModuleConnector::canStartOperation(QString theId)
116 return myWorkshop->operationMgr()->canStartOperation(theId);
119 ModuleBase_Operation* XGUI_ModuleConnector::findStartedOperation(const QString& theId)
121 return myWorkshop->operationMgr()->findOperation(theId);
124 bool XGUI_ModuleConnector::canStopOperation(ModuleBase_Operation* theOperation)
126 return myWorkshop->operationMgr()->canStopOperation(theOperation);
129 void XGUI_ModuleConnector::abortOperation(ModuleBase_Operation* theOperation)
131 myWorkshop->operationMgr()->abortOperation(theOperation);
134 void XGUI_ModuleConnector::updateCommandStatus()
136 myWorkshop->updateCommandStatus();