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"
15 #include "XGUI_ActionsMgr.h"
17 #include <ModuleBase_IModule.h>
18 #include <ModuleBase_ViewerPrs.h>
20 #include <AIS_Shape.hxx>
23 #include "AppElements_Command.h"
25 #include "XGUI_SalomeConnector.h"
28 XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
29 : ModuleBase_IWorkshop(theWorkshop),
30 myWorkshop(theWorkshop)
32 XGUI_SelectionMgr* aSelector = myWorkshop->selector();
33 connect(aSelector, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
35 XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
38 XGUI_ModuleConnector::~XGUI_ModuleConnector()
42 ModuleBase_ISelection* XGUI_ModuleConnector::selection() const
44 return myWorkshop->selector()->selection();
47 ModuleBase_IModule* XGUI_ModuleConnector::module() const
49 return myWorkshop->module();
52 ModuleBase_IViewer* XGUI_ModuleConnector::viewer() const
54 return myWorkshop->viewer();
57 ModuleBase_IPropertyPanel* XGUI_ModuleConnector::propertyPanel() const
59 return myWorkshop->propertyPanel();
62 ModuleBase_Operation* XGUI_ModuleConnector::currentOperation() const
64 return myWorkshop->operationMgr()->currentOperation();
68 QObjectPtrList XGUI_ModuleConnector::activeObjects(const QObjectPtrList& theObjList) const
70 QObjectPtrList aActiveOPbjects;
71 ModuleBase_IModule* aModule = myWorkshop->module();
72 // Activate objects only which can be activated
73 foreach (ObjectPtr aObj, theObjList) {
74 if (aModule->canActivateSelection(aObj))
75 aActiveOPbjects.append(aObj);
77 return aActiveOPbjects;
80 void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
82 XGUI_Displayer* aDisp = myWorkshop->displayer();
83 aDisp->activateObjects(theTypes, activeObjects(aDisp->displayedObjects()));
86 void XGUI_ModuleConnector::deactivateSubShapesSelection()
88 // Clear selection modes
89 activateModuleSelectionModes();
92 void XGUI_ModuleConnector::activateModuleSelectionModes()
94 XGUI_Displayer* aDisp = myWorkshop->displayer();
95 myWorkshop->activateObjectsSelection(activeObjects(aDisp->displayedObjects()));
98 AISObjectPtr XGUI_ModuleConnector::findPresentation(const ObjectPtr& theObject) const
100 XGUI_Displayer* aDisp = myWorkshop->displayer();
101 return aDisp->getAISObject(theObject);
104 ObjectPtr XGUI_ModuleConnector::findPresentedObject(const AISObjectPtr& theAIS) const
106 XGUI_Displayer* aDisp = myWorkshop->displayer();
107 ObjectPtr anObject = aDisp->getObject(theAIS);
111 void XGUI_ModuleConnector::setSelected(const QList<ModuleBase_ViewerPrsPtr>& theValues)
113 XGUI_Displayer* aDisp = myWorkshop->displayer();
114 if (theValues.isEmpty()) {
115 myWorkshop->selector()->clearSelection();
117 aDisp->setSelected(theValues);
121 void XGUI_ModuleConnector::setStatusBarMessage(const QString& theMessage)
123 myWorkshop->setStatusBarMessage(theMessage);
126 bool XGUI_ModuleConnector::canStartOperation(QString theId)
128 return myWorkshop->operationMgr()->canStartOperation(theId);
131 ModuleBase_Operation* XGUI_ModuleConnector::findStartedOperation(const QString& theId)
133 return myWorkshop->operationMgr()->findOperation(theId);
136 bool XGUI_ModuleConnector::canStopOperation(ModuleBase_Operation* theOperation)
138 return myWorkshop->operationMgr()->canStopOperation(theOperation);
141 void XGUI_ModuleConnector::abortOperation(ModuleBase_Operation* theOperation)
143 myWorkshop->operationMgr()->abortOperation(theOperation);
146 void XGUI_ModuleConnector::updateCommandStatus()
148 myWorkshop->updateCommandStatus();
151 QMainWindow* XGUI_ModuleConnector::desktop() const
153 return myWorkshop->desktop();
157 std::shared_ptr<Config_FeatureMessage> XGUI_ModuleConnector::featureInfo(const QString& theId) const
160 return myWorkshop->salomeConnector()->featureInfo(theId);
162 AppElements_Command* aAction =
163 dynamic_cast<AppElements_Command*>(myWorkshop->actionsMgr()->action(theId));
165 return aAction->featureMessage();
166 return std::shared_ptr<Config_FeatureMessage>();