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 QIntList aTypes = theTypes;
84 XGUI_Displayer* aDisp = myWorkshop->displayer();
85 myWorkshop->module()->customSubShapesSelectionModes(aTypes);
86 aDisp->activateObjects(aTypes, activeObjects(aDisp->displayedObjects()));
89 void XGUI_ModuleConnector::deactivateSubShapesSelection()
91 // Clear selection modes
92 activateModuleSelectionModes();
95 void XGUI_ModuleConnector::activateModuleSelectionModes()
97 XGUI_Displayer* aDisp = myWorkshop->displayer();
98 myWorkshop->activateObjectsSelection(activeObjects(aDisp->displayedObjects()));
101 AISObjectPtr XGUI_ModuleConnector::findPresentation(const ObjectPtr& theObject) const
103 XGUI_Displayer* aDisp = myWorkshop->displayer();
104 return aDisp->getAISObject(theObject);
107 ObjectPtr XGUI_ModuleConnector::findPresentedObject(const AISObjectPtr& theAIS) const
109 XGUI_Displayer* aDisp = myWorkshop->displayer();
110 ObjectPtr anObject = aDisp->getObject(theAIS);
114 void XGUI_ModuleConnector::setSelected(const QList<ModuleBase_ViewerPrsPtr>& theValues)
116 XGUI_Displayer* aDisp = myWorkshop->displayer();
117 if (theValues.isEmpty()) {
118 myWorkshop->selector()->clearSelection();
120 aDisp->setSelected(theValues);
124 void XGUI_ModuleConnector::setStatusBarMessage(const QString& theMessage)
126 myWorkshop->setStatusBarMessage(theMessage);
129 bool XGUI_ModuleConnector::canStartOperation(QString theId)
131 return myWorkshop->operationMgr()->canStartOperation(theId);
134 ModuleBase_Operation* XGUI_ModuleConnector::findStartedOperation(const QString& theId)
136 return myWorkshop->operationMgr()->findOperation(theId);
139 bool XGUI_ModuleConnector::canStopOperation(ModuleBase_Operation* theOperation)
141 return myWorkshop->operationMgr()->canStopOperation(theOperation);
144 void XGUI_ModuleConnector::abortOperation(ModuleBase_Operation* theOperation)
146 myWorkshop->operationMgr()->abortOperation(theOperation);
149 void XGUI_ModuleConnector::updateCommandStatus()
151 myWorkshop->updateCommandStatus();
154 QMainWindow* XGUI_ModuleConnector::desktop() const
156 return myWorkshop->desktop();
160 std::shared_ptr<Config_FeatureMessage> XGUI_ModuleConnector::featureInfo(const QString& theId) const
163 return myWorkshop->salomeConnector()->featureInfo(theId);
165 AppElements_Command* aAction =
166 dynamic_cast<AppElements_Command*>(myWorkshop->actionsMgr()->action(theId));
168 return aAction->featureMessage();
169 return std::shared_ptr<Config_FeatureMessage>();