Salome HOME
[Huge] Introducing MEDCalc
[modules/med.git] / src / MEDCalc / gui / MEDModule.cxx
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // Author : Guillaume Boulant (EDF)
21
22 #include "MEDModule.hxx"
23 #include "QtHelper.hxx"
24
25 #include <SALOMEconfig.h>
26 #include CORBA_CLIENT_HEADER(SALOMEDS)
27
28 #include "MEDFactoryClient.hxx"
29 #ifndef DISABLE_PVVIEWER
30 #include "PVViewer_ViewModel.h"
31 #endif
32
33 MEDModule::MEDModule() :
34   StandardApp_Module()
35 {
36   // Note also that we can't use the getApp() function here because
37   // the initialize(...) function has not been called yet.
38
39   this->setModuleName("MED");
40 }
41
42 //
43 // =====================================================================
44 // This part implements the mandatory interface
45 // =====================================================================
46 //
47
48 /*!
49  * Returns the engine of the XMED module, i.e. the SALOME component
50  * associated to the study root of the module.
51  */
52 Engines::EngineComponent_ptr MEDModule::getEngine() const {
53   return MEDFactoryClient::getFactory();
54 }
55
56 /*!
57  * Returns the base file name of the image used for the icon's
58  * module. The file is supposed to be located in the resource
59  * directory of the module.
60  */
61 QString MEDModule::studyIconName() {
62   return tr("ICO_MED_SMALL");
63 }
64
65 //
66 // =====================================================================
67 // This part add custom widgets (a dockwidget containing a tree view
68 // in this example) and add special actions in the toolbox of the
69 // module.
70 // =====================================================================
71 //
72
73 /*!
74  * This function implements the interface StandardApp_Module. It
75  * creates the widgets specific for this module, in particular the
76  * workspace widget and the dataspace widget.
77  */
78 void MEDModule::createModuleWidgets() {
79   _datasourceController = new DatasourceController(this);
80   _workspaceController = new WorkspaceController(this);
81   _xmedDataModel  = new XmedDataModel();
82   _workspaceController->setDataModel(_xmedDataModel);
83
84   connect(_datasourceController, SIGNAL(datasourceSignal(const DatasourceEvent *)),
85     _workspaceController, SLOT(processDatasourceEvent(const DatasourceEvent *)));
86
87   connect(_workspaceController, SIGNAL(workspaceSignal(const MEDCALC::MedEvent *)),
88     _datasourceController, SLOT(processWorkspaceEvent(const MEDCALC::MedEvent *)));
89 }
90
91 bool MEDModule::activateModule( SUIT_Study* theStudy )
92 {
93   bool bOk = StandardApp_Module::activateModule( theStudy );
94   _workspaceController->showDockWidgets(true);
95   this->setDockLayout(StandardApp_Module::DOCKLAYOUT_LEFT_VLARGE);
96   return bOk;
97 }
98 bool MEDModule::deactivateModule( SUIT_Study* theStudy )
99 {
100   _workspaceController->showDockWidgets(false);
101   this->unsetDockLayout();
102   return StandardApp_Module::deactivateModule( theStudy );
103 }
104
105 void MEDModule::createModuleActions() {
106   // Creating actions concerning the dataspace
107   _datasourceController->createActions();
108   // Creating actions concerning the workspace
109   _workspaceController->createActions();
110 }
111
112 void MEDModule::viewManagers( QStringList& list ) const
113 {
114 #ifndef DISABLE_PVVIEWER
115   list.append( PVViewer_Viewer::Type() );
116 #endif
117 }