Salome HOME
ModuleBase_ViewerPrs is wrapped into shared_ptr: remove include of this class from...
[modules/shaper.git] / src / XGUI / XGUI_ModuleConnector.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        XGUI_ModuleConnector.cpp
4 // Created:     3 June 2014
5 // Author:      Vitaly Smetannikov
6
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
16 #include <ModuleBase_IModule.h>
17 #include <ModuleBase_ViewerPrs.h>
18
19 #include <AIS_Shape.hxx>
20
21
22 XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
23     : ModuleBase_IWorkshop(theWorkshop),
24       myWorkshop(theWorkshop)
25 {
26   XGUI_SelectionMgr* aSelector = myWorkshop->selector();
27   connect(aSelector, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
28   
29   XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
30 }
31
32 XGUI_ModuleConnector::~XGUI_ModuleConnector()
33 {
34 }
35
36 ModuleBase_ISelection* XGUI_ModuleConnector::selection() const
37 {
38   return myWorkshop->selector()->selection();
39 }
40
41 ModuleBase_IModule* XGUI_ModuleConnector::module() const
42 {
43   return myWorkshop->module();
44 }
45
46 ModuleBase_IViewer* XGUI_ModuleConnector::viewer() const
47 {
48   return myWorkshop->viewer();
49 }
50
51 ModuleBase_IPropertyPanel* XGUI_ModuleConnector::propertyPanel() const
52 {
53   return myWorkshop->propertyPanel();
54 }
55
56 ModuleBase_Operation* XGUI_ModuleConnector::currentOperation() const
57 {
58   return myWorkshop->operationMgr()->currentOperation();
59 }
60
61
62 QObjectPtrList XGUI_ModuleConnector::activeObjects(const QObjectPtrList& theObjList) const
63 {
64   QObjectPtrList aActiveOPbjects;
65   ModuleBase_IModule* aModule = myWorkshop->module();
66   // Activate objects only which can be activated
67   foreach (ObjectPtr aObj, theObjList) {
68     if (aModule->canActivateSelection(aObj))
69       aActiveOPbjects.append(aObj);
70   }
71   return aActiveOPbjects;
72 }
73
74 void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
75 {
76   XGUI_Displayer* aDisp = myWorkshop->displayer();
77   aDisp->activateObjects(theTypes, activeObjects(aDisp->displayedObjects()));
78 }
79
80 void XGUI_ModuleConnector::deactivateSubShapesSelection()
81 {
82   // Clear selection modes
83   activateModuleSelectionModes();
84 }
85
86 void XGUI_ModuleConnector::activateModuleSelectionModes()
87 {
88   XGUI_Displayer* aDisp = myWorkshop->displayer();
89   myWorkshop->activateObjectsSelection(activeObjects(aDisp->displayedObjects()));
90 }
91
92 AISObjectPtr XGUI_ModuleConnector::findPresentation(const ObjectPtr& theObject) const
93 {
94   XGUI_Displayer* aDisp = myWorkshop->displayer();
95   return aDisp->getAISObject(theObject);
96 }
97
98 ObjectPtr XGUI_ModuleConnector::findPresentedObject(const AISObjectPtr& theAIS) const
99 {
100   XGUI_Displayer* aDisp = myWorkshop->displayer();
101   ObjectPtr anObject = aDisp->getObject(theAIS);
102   return anObject;
103 }
104
105 void XGUI_ModuleConnector::setSelected(const QList<ModuleBase_ViewerPrsPtr>& theValues)
106 {
107   XGUI_Displayer* aDisp = myWorkshop->displayer();
108   if (theValues.isEmpty()) {
109     myWorkshop->selector()->clearSelection();
110   } else {
111     aDisp->setSelected(theValues);
112   }    
113 }
114
115 bool XGUI_ModuleConnector::canStartOperation(QString theId)
116 {
117   return myWorkshop->operationMgr()->canStartOperation(theId);
118 }
119
120 ModuleBase_Operation* XGUI_ModuleConnector::findStartedOperation(const QString& theId)
121 {
122   return myWorkshop->operationMgr()->findOperation(theId);
123 }
124
125 bool XGUI_ModuleConnector::canStopOperation(ModuleBase_Operation* theOperation)
126 {
127   return myWorkshop->operationMgr()->canStopOperation(theOperation);
128 }
129
130 void XGUI_ModuleConnector::abortOperation(ModuleBase_Operation* theOperation)
131 {
132   myWorkshop->operationMgr()->abortOperation(theOperation);
133 }
134
135 void XGUI_ModuleConnector::updateCommandStatus()
136 {
137   myWorkshop->updateCommandStatus();
138 }