1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // Author : Guillaume Boulant (EDF)
22 #include "MEDModule.hxx"
23 #include "QtHelper.hxx"
25 #include "SALOME_LifeCycleCORBA.hxx"
26 #include "QtxPopupMgr.h"
28 #include <SUIT_Desktop.h>
29 #include <SUIT_ResourceMgr.h>
30 #include <SUIT_Session.h>
31 #include <SalomeApp_Study.h>
33 #ifndef DISABLE_PVVIEWER
34 #include "PVViewer_ViewModel.h"
37 //! The only instance of the reference to engine
38 MED_ORB::MED_Gen_var MEDModule::myEngine;
40 MEDModule::MEDModule() :
41 SalomeApp_Module("MED")
43 // Note also that we can't use the getApp() function here because
44 // the initialize(...) function has not been called yet.
46 init(); // internal initialization
49 MEDModule::~MEDModule()
57 init(); // initialize engine, if necessary
64 // initialize MED module engine (load, if necessary)
65 if ( CORBA::is_nil( myEngine ) ) {
66 Engines::EngineComponent_var comp =
67 SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "MED" );
68 myEngine = MED_ORB::MED_Gen::_narrow( comp );
73 MEDModule::initialize( CAM_Application* app )
75 // call the parent implementation
76 SalomeApp_Module::initialize( app );
78 // The following initializes the GUI widget and associated actions
79 this->createModuleWidgets();
80 this->createModuleActions();
84 MEDModule::engineIOR() const
86 init(); // initialize engine, if necessary
87 CORBA::String_var anIOR = getApp()->orb()->object_to_string( myEngine.in() );
88 return QString( anIOR.in() );
92 MEDModule::iconName() const
94 return tr("ICO_MED_SMALL");
98 MEDModule::windows( QMap<int, int>& theMap ) const
100 // want Object browser, in the left area
101 theMap.insert( SalomeApp_Application::WT_ObjectBrowser,
102 Qt::LeftDockWidgetArea );
103 #ifndef DISABLE_PYCONSOLE
104 // want Python console, in the bottom area
105 theMap.insert( SalomeApp_Application::WT_PyConsole,
106 Qt::BottomDockWidgetArea );
111 MEDModule::viewManagers( QStringList& list ) const
113 #ifndef DISABLE_PVVIEWER
114 list.append( PVViewer_Viewer::Type() );
119 MEDModule::activateModule( SUIT_Study* theStudy )
121 if ( CORBA::is_nil( myEngine ) )
124 // call parent implementation
125 bool bOk = SalomeApp_Module::activateModule( theStudy );
130 setMenuShown( true );
132 setToolShown( true );
134 //this->createStudyComponent(theStudy);
135 _workspaceController->showDockWidgets(true);
136 //this->setDockLayout(StandardApp_Module::DOCKLAYOUT_LEFT_VLARGE);
138 // return the activation status
143 MEDModule::deactivateModule( SUIT_Study* theStudy )
145 _workspaceController->showDockWidgets(false);
146 //this->unsetDockLayout();
149 setMenuShown( false );
151 setToolShown( false );
153 // call parent implementation and return the activation status
154 return SalomeApp_Module::deactivateModule( theStudy );
158 // =====================================================================
159 // This part add custom widgets (a dockwidget containing a tree view
160 // in this example) and add special actions in the toolbox of the
162 // =====================================================================
166 * This function implements the interface StandardApp_Module. It
167 * creates the widgets specific for this module, in particular the
168 * workspace widget and the dataspace widget.
171 MEDModule::createModuleWidgets() {
172 _datasourceController = new DatasourceController(this);
173 _workspaceController = new WorkspaceController(this);
174 _xmedDataModel = new XmedDataModel();
175 _workspaceController->setDataModel(_xmedDataModel);
177 connect(_datasourceController, SIGNAL(datasourceSignal(const DatasourceEvent *)),
178 _workspaceController, SLOT(processDatasourceEvent(const DatasourceEvent *)));
180 connect(_workspaceController, SIGNAL(workspaceSignal(const MEDCALC::MedEvent *)),
181 _datasourceController, SLOT(processWorkspaceEvent(const MEDCALC::MedEvent *)));
185 MEDModule::createModuleActions() {
186 // Creating actions concerning the dataspace
187 _datasourceController->createActions();
188 // Creating actions concerning the workspace
189 _workspaceController->createActions();
193 MEDModule::createStandardAction(const QString& label,
194 QObject * slotobject,
195 const char* slotmember,
196 const QString& iconName,
197 const QString& tooltip)
199 SUIT_Desktop* dsk = getApp()->desktop();
200 SUIT_ResourceMgr* resMgr = getApp()->resourceMgr();
202 // If the tooltip is not defined, we choose instead the label text.
203 QString effToolTip(tooltip);
204 if ( effToolTip.isEmpty() )
207 QAction* action = createAction(-1,
209 resMgr->loadPixmap("MED", iconName),
218 return actionId(action);
222 MEDModule::addActionInPopupMenu(int actionId,const QString& menus,const QString& rule)
224 // _GBO_ for a fine customization of the rule (for example with a
225 // test on the type of the selected object), see the LIGTH module:
226 // implement "LightApp_Selection* createSelection() const;"
228 QtxPopupMgr* mgr = this->popupMgr();
229 this->action( actionId )->setIconVisibleInMenu(true);
230 if (! menus.isEmpty())
231 mgr->insert ( this->action( actionId ), menus, parentId, 0 );
233 mgr->insert ( this->action( actionId ), parentId, 0 );
234 mgr->setRule( this->action( actionId ), rule, QtxPopupMgr::VisibleRule );