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()));
36 XGUI_ModuleConnector::~XGUI_ModuleConnector()
40 ModuleBase_ISelection* XGUI_ModuleConnector::selection() const
42 return myWorkshop->selector()->selection();
45 ModuleBase_IModule* XGUI_ModuleConnector::module() const
47 return myWorkshop->module();
50 ModuleBase_IViewer* XGUI_ModuleConnector::viewer() const
52 return myWorkshop->viewer();
55 ModuleBase_IPropertyPanel* XGUI_ModuleConnector::propertyPanel() const
57 return myWorkshop->propertyPanel();
60 ModuleBase_Operation* XGUI_ModuleConnector::currentOperation() const
62 return myWorkshop->operationMgr()->currentOperation();
66 QObjectPtrList XGUI_ModuleConnector::activeObjects(const QObjectPtrList& theObjList) const
68 QObjectPtrList aActiveOPbjects;
69 ModuleBase_IModule* aModule = myWorkshop->module();
70 // Activate objects only which can be activated
71 foreach (ObjectPtr aObj, theObjList) {
72 if (aModule->canActivateSelection(aObj))
73 aActiveOPbjects.append(aObj);
75 return aActiveOPbjects;
78 void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
80 QIntList aTypes = theTypes;
82 XGUI_Displayer* aDisp = myWorkshop->displayer();
83 myWorkshop->module()->customSubShapesSelectionModes(aTypes);
84 aDisp->activateObjects(aTypes, activeObjects(aDisp->displayedObjects()));
87 void XGUI_ModuleConnector::deactivateSubShapesSelection()
89 // Clear selection modes
90 activateModuleSelectionModes();
93 void XGUI_ModuleConnector::activateModuleSelectionModes()
95 XGUI_Displayer* aDisp = myWorkshop->displayer();
96 myWorkshop->activateObjectsSelection(activeObjects(aDisp->displayedObjects()));
99 AISObjectPtr XGUI_ModuleConnector::findPresentation(const ObjectPtr& theObject) const
101 XGUI_Displayer* aDisp = myWorkshop->displayer();
102 return aDisp->getAISObject(theObject);
105 ObjectPtr XGUI_ModuleConnector::findPresentedObject(const AISObjectPtr& theAIS) const
107 XGUI_Displayer* aDisp = myWorkshop->displayer();
108 ObjectPtr anObject = aDisp->getObject(theAIS);
112 void XGUI_ModuleConnector::setSelected(const QList<ModuleBase_ViewerPrsPtr>& theValues)
114 XGUI_Displayer* aDisp = myWorkshop->displayer();
115 if (theValues.isEmpty()) {
116 myWorkshop->selector()->clearSelection();
118 aDisp->setSelected(theValues);
122 void XGUI_ModuleConnector::setStatusBarMessage(const QString& theMessage)
124 myWorkshop->setStatusBarMessage(theMessage);
127 bool XGUI_ModuleConnector::canStartOperation(QString theId)
129 return myWorkshop->operationMgr()->canStartOperation(theId);
132 ModuleBase_Operation* XGUI_ModuleConnector::findStartedOperation(const QString& theId)
134 return myWorkshop->operationMgr()->findOperation(theId);
137 bool XGUI_ModuleConnector::canStopOperation(ModuleBase_Operation* theOperation)
139 return myWorkshop->operationMgr()->canStopOperation(theOperation);
142 void XGUI_ModuleConnector::abortOperation(ModuleBase_Operation* theOperation)
144 myWorkshop->operationMgr()->abortOperation(theOperation);
147 void XGUI_ModuleConnector::updateCommandStatus()
149 myWorkshop->updateCommandStatus();
152 QMainWindow* XGUI_ModuleConnector::desktop() const
154 return myWorkshop->desktop();
158 std::shared_ptr<Config_FeatureMessage> XGUI_ModuleConnector::featureInfo(const QString& theId) const
161 return myWorkshop->salomeConnector()->featureInfo(theId);
163 AppElements_Command* aAction =
164 dynamic_cast<AppElements_Command*>(myWorkshop->actionsMgr()->action(theId));
166 return aAction->featureMessage();
167 return std::shared_ptr<Config_FeatureMessage>();