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"
26 XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
27 : ModuleBase_IWorkshop(theWorkshop),
28 myWorkshop(theWorkshop)
30 XGUI_SelectionMgr* aSelector = myWorkshop->selector();
31 connect(aSelector, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
33 XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
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 XGUI_Displayer* aDisp = myWorkshop->displayer();
81 aDisp->activateObjects(theTypes, activeObjects(aDisp->displayedObjects()));
84 void XGUI_ModuleConnector::deactivateSubShapesSelection()
86 // Clear selection modes
87 activateModuleSelectionModes();
90 void XGUI_ModuleConnector::activateModuleSelectionModes()
92 XGUI_Displayer* aDisp = myWorkshop->displayer();
93 myWorkshop->activateObjectsSelection(activeObjects(aDisp->displayedObjects()));
96 AISObjectPtr XGUI_ModuleConnector::findPresentation(const ObjectPtr& theObject) const
98 XGUI_Displayer* aDisp = myWorkshop->displayer();
99 return aDisp->getAISObject(theObject);
102 ObjectPtr XGUI_ModuleConnector::findPresentedObject(const AISObjectPtr& theAIS) const
104 XGUI_Displayer* aDisp = myWorkshop->displayer();
105 ObjectPtr anObject = aDisp->getObject(theAIS);
109 void XGUI_ModuleConnector::setSelected(const QList<ModuleBase_ViewerPrsPtr>& theValues)
111 XGUI_Displayer* aDisp = myWorkshop->displayer();
112 if (theValues.isEmpty()) {
113 myWorkshop->selector()->clearSelection();
115 aDisp->setSelected(theValues);
119 bool XGUI_ModuleConnector::canStartOperation(QString theId)
121 return myWorkshop->operationMgr()->canStartOperation(theId);
124 ModuleBase_Operation* XGUI_ModuleConnector::findStartedOperation(const QString& theId)
126 return myWorkshop->operationMgr()->findOperation(theId);
129 bool XGUI_ModuleConnector::canStopOperation(ModuleBase_Operation* theOperation)
131 return myWorkshop->operationMgr()->canStopOperation(theOperation);
134 void XGUI_ModuleConnector::abortOperation(ModuleBase_Operation* theOperation)
136 myWorkshop->operationMgr()->abortOperation(theOperation);
139 void XGUI_ModuleConnector::updateCommandStatus()
141 myWorkshop->updateCommandStatus();
144 QMainWindow* XGUI_ModuleConnector::desktop() const
146 return myWorkshop->desktop();
150 std::shared_ptr<Config_FeatureMessage> XGUI_ModuleConnector::featureInfo(const QString& theId) const
153 return myWorkshop->salomeConnector()->featureInfo(theId);
155 AppElements_Command* aAction =
156 dynamic_cast<AppElements_Command*>(myWorkshop->actionsMgr()->action(theId));
158 return aAction->featureMessage();
159 return std::shared_ptr<Config_FeatureMessage>();