Salome HOME
78659c775256679c4a26adc76ed9d96df5e6578a
[modules/med.git] / src / MEDCalc / gui / MEDModule.cxx
1 // Copyright (C) 2007-2021  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 #include <MEDCalcConstants.hxx>
25 #include "MEDCALCGUI_Displayer.hxx"
26
27 #include "SALOME_LifeCycleCORBA.hxx"
28 #include "QtxPopupMgr.h"
29 #include <QtxInfoPanel.h>
30
31 #include <LightApp_Preferences.h>
32 #include <SUIT_Desktop.h>
33 #include <SUIT_ResourceMgr.h>
34 #include <SUIT_Session.h>
35 #include <SUIT_DataBrowser.h>
36 #include <SalomeApp_Study.h>
37 #include <SalomeApp_DataObject.h>
38 #include <SalomeApp_DataModel.h>
39 #include <SUIT_ViewManager.h>
40 #include <SUIT_ViewWindow.h>
41
42 #include <SALOMEconfig.h>
43 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
44 #include <SALOMEDS_SObject.hxx>
45 #include <SALOMEDS_Study.hxx>
46
47 #ifndef DISABLE_PVVIEWER
48 #include <PVViewer_ViewModel.h>
49 #include <PVViewer_GUIElements.h>
50 #endif
51
52 #include "MEDFactoryClient.hxx"
53 #include "MEDPresentationManager_i.hxx"
54 #include "MED_Component_Generator.hxx"
55
56 #include <QTimer>
57 #include <sstream>
58
59 #include <pqAnimationManager.h>
60 #include <pqPVApplicationCore.h>
61 #include <pqAnimationScene.h>
62 #include <pqActiveObjects.h>
63 #include <pqView.h>
64
65 //! The only instance of the reference to engine
66 MED_ORB::MED_Gen_var MEDModule::_MED_engine;
67
68 MEDModule::MEDModule() :
69   SalomeApp_Module("FIELDS"), _studyEditor(0),
70   _datasourceController(0), _workspaceController(0), _presentationController(0),
71   _processingController(0), _pvGuiElements(0),
72   _displayer(nullptr),
73   _enableVisibilityStateUpdate(true)
74 {
75   STDLOG("MEDModule::MEDModule()");
76   // Note also that we can't use the getApp() function here because
77   // the initialize(...) function has not been called yet.
78
79   init(); // internal initialization
80 }
81
82 MEDModule::~MEDModule()
83 {
84   // Clean up engine:
85   STDLOG("MEDModule::~MEDModule(): cleaning up engine side.");
86   _MED_engine->cleanUp();
87   MEDFactoryClient::getFactory()->getPresentationManager()->cleanUp();
88   MEDFactoryClient::getFactory()->getDataManager()->cleanUp();
89
90   if (_studyEditor)
91     delete _studyEditor;
92   if (_datasourceController)
93     delete _datasourceController;
94   //if (_workspaceController)
95   //  delete _workspaceController;
96   if (_presentationController)
97     delete _presentationController;
98   if (_processingController)
99     delete _processingController;
100 }
101
102 MED_ORB::MED_Gen_var
103 MEDModule::engine()
104 {
105   init(); // initialize engine, if necessary
106   return _MED_engine;
107 }
108
109 void
110 MEDModule::init()
111 {
112   // initialize FIELDS module engine (load, if necessary)
113   Engines::EngineComponent_var comp;
114   if ( CORBA::is_nil( _MED_engine ) ) {
115     SALOME_NamingService_Abstract *ns = SalomeApp_Application::namingService();
116     if( dynamic_cast<SALOME_NamingService *>(ns) )
117     {
118       comp = SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "FIELDS" );
119     }
120     else
121     {
122       comp = RetrieveMEDInstance();
123       CORBA::Object_var comp2 = CORBA::Object::_narrow(comp);
124       KERNEL::RegisterCompo("FIELDS",comp2);
125     }
126     _MED_engine = MED_ORB::MED_Gen::_narrow( comp );
127     if (CORBA::is_nil( _MED_engine )) {
128       STDLOG("Could not narrow FIELDS engine");
129     }
130   }
131 }
132
133 //void MEDModule::onEventLoopStarted()
134 //{
135 //  if(!getApp()->isMainEventLoopStarted())
136 //    {
137 //      QTimer::singleShot(100, this, SLOT(onEventLoopStarted()));
138 //      return;
139 //    }
140 //}
141
142 void
143 MEDModule::initialize( CAM_Application* app )
144 {
145   STDLOG("MEDModule::initialize()");
146   // call the parent implementation
147   SalomeApp_Module::initialize( app );
148
149   if (! getApp()->objectBrowser())
150     getApp()->getWindow(SalomeApp_Application::WT_ObjectBrowser);
151
152   // rnv: #20430 [CEA 20428] FIELDS : improvement of simplified visualisations: 
153   //      Disable auto expanding
154   //getApp()->objectBrowser()->setAutoOpenLevel(5);
155
156   if (app && app->desktop()) {
157     connect((QObject*) (getApp()->objectBrowser()->treeView()), SIGNAL(doubleClicked(const QModelIndex&)),
158             this, SLOT(onDblClick(const QModelIndex&)));
159     connect((QObject*) (getApp()->objectBrowser()->treeView()), SIGNAL(clicked(const QModelIndex&)),
160                 this, SLOT(onClick(const QModelIndex&)));
161   }
162
163   // The following initializes the GUI widget and associated actions
164   this->createModuleWidgets();
165   this->createModuleActions();
166
167   // Now that the workspace controller is created, ParaView core application has normally been started,
168   // and hidden GUI elements have been created.  We can fire the VCR toolbar activation:
169   initToolbars();
170 }
171
172 QString
173 MEDModule::engineIOR() const
174 {
175   init(); // initialize engine, if necessary
176   CORBA::String_var anIOR = getApp()->orb()->object_to_string( _MED_engine.in() );
177   return QString( anIOR.in() );
178 }
179
180 QString
181 MEDModule::iconName() const
182 {
183   return tr("ICO_MED_SMALL");
184 }
185
186 void
187 MEDModule::windows( QMap<int, int>& theMap ) const
188 {
189   STDLOG("MEDModule::windows()");
190   // want Object browser, in the left area
191   theMap.insert( SalomeApp_Application::WT_ObjectBrowser,
192                  Qt::LeftDockWidgetArea );
193   // help windows in the right area
194   theMap.insert( SalomeApp_Application::WT_InfoPanel, Qt::RightDockWidgetArea);
195 #ifndef DISABLE_PYCONSOLE
196   // want Python console, in the bottom area
197   theMap.insert( SalomeApp_Application::WT_PyConsole,
198                  Qt::BottomDockWidgetArea );
199 #endif
200 }
201
202 void
203 MEDModule::viewManagers( QStringList& list ) const
204 {
205 #ifndef DISABLE_PVVIEWER
206   list.append( PVViewer_Viewer::Type() );
207 #endif
208 }
209
210 void
211 MEDModule::createPreferences()
212 {
213   int genTab = addPreference(tr("PREF_TAB_GENERAL"));
214
215   int themeGroup = addPreference(tr("PREF_THEME_GROUP"), genTab);
216   setPreferenceProperty(themeGroup, "columns", 2);
217   int icons = addPreference(tr("PREF_ICONS"), themeGroup, LightApp_Preferences::Selector, "MEDCalc", "icons" );
218   QStringList iconsThemes;
219   iconsThemes.append(tr("PREF_ICON_THEME_MODERN"));
220   iconsThemes.append(tr("PREF_ICON_THEME_CLASSIC"));
221   QList<QVariant> indices;
222   indices.append(0);
223   indices.append(1);
224   setPreferenceProperty(icons, "strings", iconsThemes);
225   setPreferenceProperty(icons, "indexes", indices);
226 }
227
228 bool
229 MEDModule::activateModule( SUIT_Study* theStudy )
230 {
231   STDLOG("MEDModule::activateModule()");
232   if ( CORBA::is_nil( _MED_engine ) )
233     return false;
234
235   // call parent implementation
236   bool bOk = SalomeApp_Module::activateModule( theStudy );
237   if (!bOk)
238     return false;
239
240   // show own menus
241   setMenuShown( true );
242   // show own toolbars
243   setToolShown( true );
244
245   // Fill in Help Panel
246   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(application());
247   QtxInfoPanel* ip = app->infoPanel();
248   app->infoPanel()->setTitle(tr("HELP_WELCOME_FIELDS"));
249
250   // short introduction of FIEDS module
251   int gp = ip->addGroup(tr("HELP_GRP_PRESENTATION"));
252   int lp1 = ip->addLabel(tr("HELP_LABEL_PRES1"), gp);
253   int lp2 = ip->addLabel(tr("HELP_LABEL_PRES2"), gp);
254   int lp3 = ip->addLabel(tr("HELP_LABEL_PRES3"), gp);
255
256
257   // getting started Simplified Visu
258   int gv = ip->addGroup(tr("HELP_GRP_VISUALISATION"));
259   int lv1 = ip->addLabel(tr("HELP_LABEL_VISU1"), gv);
260   int av1 = ip->addAction(action(FIELDSOp::OpAddDataSource) , gv);
261   int lv2 = ip->addLabel(tr("HELP_LABEL_VISU2"), gv);
262   int lv3 = ip->addLabel(tr("HELP_LABEL_VISU3"), gv);
263   QString qs31="<ul><li>" + tr("LAB_VIEW_MODE_REPLACE") + "</li></ul>"; 
264   QString qs32="<ul><li>" + tr("LAB_VIEW_MODE_OVERLAP") + "</li></ul>"; 
265   QString qs33="<ul><li>" + tr("LAB_VIEW_MODE_NEW_LAYOUT") + "</li></ul>"; 
266   QString qs34="<ul><li>" + tr("LAB_VIEW_MODE_SPLIT_VIEW") + "</li></ul>"; 
267   int lv31 = ip->addLabel(qs31, gv);
268   int lv32 = ip->addLabel(qs32, gv);
269   int lv33 = ip->addLabel(qs33, gv);
270   int lv34 = ip->addLabel(qs34, gv);
271   int lv4 = ip->addLabel(tr("HELP_LABEL_VISU4"), gv);
272   int av2 = ip->addAction(action(FIELDSOp::OpScalarMap) , gv);
273   int av3 = ip->addAction(action(FIELDSOp::OpContour) , gv);
274   int av4 = ip->addAction(action(FIELDSOp::OpVectorFields) , gv);
275   int av5 = ip->addAction(action(FIELDSOp::OpSlices) , gv);
276   int av6 = ip->addAction(action(FIELDSOp::OpDeflectionShape) , gv);
277   int av7 = ip->addAction(action(FIELDSOp::OpPointSprite) , gv);
278   int av8 = ip->addAction(action(FIELDSOp::OpPlot3D) , gv);
279   int av9 = ip->addAction(action(FIELDSOp::OpStreamLines) , gv);
280   int av10 = ip->addAction(action(FIELDSOp::OpCutSegment) , gv);
281
282   // getting started interpolation
283   int gi = ip->addGroup(tr("HELP_GRP_INTERPOLATION"));
284   int li1 = ip->addLabel(tr("HELP_LABEL_INTERP1"), gi);
285   int li2 = ip->addLabel(tr("HELP_LABEL_INTERP2"), gi);
286   int li3 = ip->addLabel(tr("HELP_LABEL_INTERP3"), gi);
287   int ai1 = ip->addAction(action(FIELDSOp::OpProcessingInterpolation) , gi);
288   int li4 = ip->addLabel(tr("HELP_LABEL_INTERP4"), gi);
289
290   // End of Help Panel
291
292   //this->createStudyComponent(theStudy);
293   _workspaceController->showDockWidgets(true);
294   _presentationController->showDockWidgets(true);
295   //this->setDockLayout(StandardApp_Module::DOCKLAYOUT_LEFT_VLARGE);
296
297   // Mark the start of the main event loop - important for test playback:
298 //  QObject::connect(getApp(), SIGNAL(activated(SUIT_Application *)), this, SLOT(onEventLoopStarted(SUIT_Application *)));
299 //  QTimer::singleShot(0, this, SLOT(onEventLoopStarted()));
300
301   // return the activation status
302
303   QObject::connect(&pqActiveObjects::instance(), SIGNAL(viewChanged(pqView*)), this,
304     SLOT(onViewChanged()), Qt::QueuedConnection);
305
306   return bOk;
307 }
308
309 bool
310 MEDModule::deactivateModule( SUIT_Study* theStudy )
311 {
312   STDLOG("MEDModule::deactivateModule()");
313   _workspaceController->showDockWidgets(false);
314   _presentationController->showDockWidgets(false);
315   //this->unsetDockLayout();
316
317   // hide own menus
318   setMenuShown( false );
319   // hide own toolbars
320   setToolShown( false );
321
322   // call parent implementation and return the activation status
323   return SalomeApp_Module::deactivateModule( theStudy );
324 }
325
326 //
327 // =====================================================================
328 // This part add custom widgets (a dockwidget containing a tree view
329 // in this example) and add special actions in the toolbox of the
330 // module.
331 // =====================================================================
332 //
333
334 /*!
335  * This function implements the interface StandardApp_Module. It
336  * creates the widgets specific for this module, in particular the
337  * workspace widget and the dataspace widget.
338  */
339 void
340 MEDModule::createModuleWidgets() {
341   _studyEditor = new SALOME_AppStudyEditor(getApp());
342   _datasourceController = new DatasourceController(this);
343   _workspaceController = new WorkspaceController(this);
344   _xmedDataModel  = new XmedDataModel();
345   _workspaceController->setDataModel(_xmedDataModel);
346   _presentationController = new PresentationController(this);
347   // ABN: ultimately console driver should be owned by module: everyone needs it, not only WorkspaceController
348   _presentationController->setConsoleDriver(_workspaceController->getConsoleDriver());
349   _processingController = new ProcessingController(this);
350 #ifdef MED_HAS_QTTESTING
351   _testController = new TestController(this);
352 #endif
353
354   connect(_datasourceController, SIGNAL(datasourceSignal(const DatasourceEvent*)),
355     _workspaceController, SLOT(processDatasourceEvent(const DatasourceEvent*)));
356
357   connect(_presentationController, SIGNAL(presentationSignal(const PresentationEvent*)),
358     _presentationController, SLOT(processPresentationEvent(const PresentationEvent*)));
359
360   connect(_processingController, SIGNAL(processingSignal(const ProcessingEvent*)),
361     _workspaceController, SLOT(processProcessingEvent(const ProcessingEvent*)));
362
363   connect(_workspaceController, SIGNAL(workspaceSignal(const MEDCALC::MedEvent*)),
364     _datasourceController, SLOT(processWorkspaceEvent(const MEDCALC::MedEvent*)));
365
366   connect(_workspaceController, SIGNAL(workspaceSignal(const MEDCALC::MedEvent*)),
367     _presentationController, SLOT(processWorkspaceEvent(const MEDCALC::MedEvent*)));
368
369   connect(&pqActiveObjects::instance(), &pqActiveObjects::viewChanged, [this](pqView* view) { this->updateVisibilityState(); });
370
371 }
372
373
374 void MEDModule::updateVisibilityState(const bool all, const QStringList& entries) 
375 {
376   if (!_enableVisibilityStateUpdate) {
377     return;
378   }
379   QStringList allPrsEntries = QStringList();
380   const QStringList& workList = ( all ? allPrsEntries : entries );
381   if (all) {
382     SALOMEDS::Study_var aStudy = KERNEL::getStudyServant();
383     if (aStudy->_is_nil())
384       return;
385     SALOMEDS::SComponent_var father = aStudy->FindComponent("FIELDS");
386     if (father->_is_nil())
387       return;
388     SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(father);
389     SALOMEDS::GenericAttribute_var anAttribute;
390     for (it->InitEx(true); it->More(); it->Next())
391     {
392       SALOMEDS::SObject_var child(it->Value());
393       if (child->FindAttribute(anAttribute, "AttributeParameter"))
394       {
395         SALOMEDS::AttributeParameter_var attrParam = SALOMEDS::AttributeParameter::_narrow(anAttribute);
396         if (!attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN) || !attrParam->GetBool(IS_PRESENTATION) || !attrParam->IsSet(PRESENTATION_ID, PT_INTEGER))
397           continue;
398         allPrsEntries.append(child->GetID());
399       }
400     }
401   }
402   
403   // update visibility state of objects
404   LightApp_Application* app = dynamic_cast<LightApp_Application*>(SUIT_Session::session()->activeApplication());
405   if (!app) 
406     return;
407   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
408   if (!appStudy)
409     return;
410   SUIT_Study* activeStudy = app->activeStudy();
411   if (!activeStudy)
412     return;
413   SUIT_ViewWindow* aViewWindow = app->desktop()->activeWindow();
414   if (!aViewWindow)
415     return;
416   SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
417   if (!aViewManager)
418     return;
419     
420   SUIT_ViewModel * aViewModel = aViewManager->getViewModel();
421   DataObjectList aList;
422   for(const auto& str : workList) {
423     aList.append(appStudy->findObjectByEntry(str));
424   }
425   app->updateVisibilityState(aList, aViewModel);
426
427 }
428
429 void
430 MEDModule::initToolbars()
431 {
432   // VCR and Time toolbars:
433   SUIT_Desktop* dsk = getApp()->desktop();
434   _pvGuiElements = PVViewer_GUIElements::GetInstance(dsk);
435
436   _pvGuiElements->getVCRToolbar();  // make sure VCR toolbar is built
437   _pvGuiElements->setToolBarVisible(false);
438   _pvGuiElements->setVCRTimeToolBarVisible(true);
439
440   // Emit signal in order to make sure that animation scene is set - same trick as in PARAVIS module activation
441   QMetaObject::invokeMethod( pqPVApplicationCore::instance()->animationManager(),
442                              "activeSceneChanged",
443                              Q_ARG( pqAnimationScene*, pqPVApplicationCore::instance()->animationManager()->getActiveScene() ) );
444
445 #ifdef MED_HAS_QTTESTING
446   connect(_workspaceController, SIGNAL(workspaceSignal(const MEDCALC::MedEvent*)),
447     _testController, SLOT(processWorkspaceEvent(const MEDCALC::MedEvent*)));
448 #endif
449 }
450
451 double
452 MEDModule::getCurrentAnimationTimestamp()
453 {
454   double timestamp = pqPVApplicationCore::instance()->animationManager()->getActiveScene()->getAnimationTime();
455   return timestamp;
456 }
457
458 void
459 MEDModule::createModuleActions() {
460   _datasourceController->createActions();
461   _workspaceController->createActions();
462   _presentationController->createActions();
463   _processingController->createActions();
464 #ifdef MED_HAS_QTTESTING
465   _testController->createActions();
466 #endif
467 }
468
469 int
470 MEDModule::createStandardAction(const QString& label,
471                                 QObject* slotobject,
472                                 const char* slotmember,
473                                 const QString& iconName,
474                                 const QString& tooltip,
475                                 int actionid)
476 {
477   SUIT_Desktop* dsk = getApp()->desktop();
478   SUIT_ResourceMgr* resMgr = getApp()->resourceMgr();
479
480   // If the tooltip is not defined, we choose instead the label text.
481   QString effToolTip(tooltip);
482   if ( effToolTip.isEmpty() )
483     effToolTip = label;
484
485   QIcon ico;
486   if (iconName.isEmpty())
487     ico = QIcon();
488   else
489     ico = QIcon(resMgr->loadPixmap("FIELDS", iconName));
490
491   QAction* action = createAction(actionid,
492                                  label,
493                                  ico,
494                                  label,
495                                  effToolTip,
496                                  0,
497                                  dsk,
498                                  false,
499                                  slotobject,
500                                  slotmember
501                                  );
502   return actionId(action);
503 }
504
505 void
506 MEDModule::addActionInPopupMenu(int actionId,const QString& menus,const QString& rule)
507 {
508   // _GBO_ for a fine customization of the rule (for example with a
509   // test on the type of the selected object), see the LIGHT module:
510   // implement "LightApp_Selection*    createSelection() const;"
511   int parentId = -1;
512   QtxPopupMgr* mgr = this->popupMgr();
513   this->action( actionId )->setIconVisibleInMenu(true);
514   if (! menus.isEmpty())
515     mgr->insert ( this->action( actionId ), menus, parentId, 0 );
516   else
517     mgr->insert ( this->action( actionId ), parentId, 0 );
518   mgr->setRule( this->action( actionId ), rule, QtxPopupMgr::VisibleRule );
519 }
520
521 //MEDCALC::ViewModeType
522 //MEDModule::getSelectedViewMode() const
523 //{
524 //  return _presentationController->getSelectedViewMode();
525 //}
526 //
527 //MEDCALC::ColorMapType
528 //MEDModule::getSelectedColorMap() const
529 //{
530 //  return _presentationController->getSelectedColorMap();
531 //}
532 //
533 //MEDCALC::ScalarBarRangeType
534 //MEDModule::getSelectedScalarBarRange() const
535 //{
536 //  return _presentationController->getSelectedScalarBarRange();
537 //}
538
539
540 /**
541  * Returns presentation name, type and ID from the currently selected presentation in the object
542  * browser.
543  */
544 bool
545 MEDModule::itemClickGeneric(std::string & name, std::string & type, int & presId) const
546 {
547   DataObjectList dol = getApp()->objectBrowser()->getSelected();
548   if (dol.isEmpty())
549     return false;
550   SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
551   if (!item)
552     return false;
553   SalomeApp_DataModel *model = dynamic_cast<SalomeApp_DataModel*>(dataModel());
554   if (!model)
555     return false;
556
557   if (item->componentDataType().toStdString() != "FIELDS")
558     return false;
559   _PTR(SObject) obj = item->object();
560   _PTR(GenericAttribute) anAttribute;
561
562   if (! obj->FindAttribute(anAttribute, "AttributeName"))
563     return false;
564   _PTR(AttributeName) attrName(anAttribute);
565   name = attrName->Value();
566
567   if (! obj->FindAttribute(anAttribute, "AttributeParameter"))
568     return false;
569   _PTR(AttributeParameter) attrParam(anAttribute);
570   if (! attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN)
571       || ! attrParam->GetBool(IS_PRESENTATION)) { // Not a presentation
572       return false;
573   }
574 //  if (!attrParam->IsSet(FIELD_ID, PT_INTEGER))
575 //    return false;
576 //  fieldId = attrParam->GetInt(FIELD_ID);
577   if (!attrParam->IsSet(PRESENTATION_ID, PT_INTEGER))
578       return false;
579   presId = attrParam->GetInt(PRESENTATION_ID);
580   if (!attrParam->IsSet(PRESENTATION_TYPE, PT_STRING))
581     return false;
582   type = attrParam->GetString(PRESENTATION_TYPE);
583   return true;
584 }
585
586 void
587 MEDModule::onClick(const QModelIndex & /*index*/)
588 {
589   int presId;
590   std::string name, type;
591   if (!itemClickGeneric(name, type, presId))
592     {
593       // Not a presentation - clear widget:
594       emit presentationSelected(-1, QString(""), QString(""));
595       return;
596     }
597
598 //  STDLOG("Presentation selection");
599 //  std::ostringstream oss;
600 //  oss << fieldId << " / " << presId;
601 //  STDLOG("    - Field id / pres id:   " + oss.str());
602 //  STDLOG("    - Presentation type: " + type);
603 //  STDLOG("    - Presentation name: " + name);
604
605   emit presentationSelected(presId, QString::fromStdString(type), QString::fromStdString(name) );  // caught by PresentationController
606 }
607
608 void
609 MEDModule::onDblClick(const QModelIndex& /*index*/)
610 {
611   int presId;
612   std::string name, type;
613   if (!itemClickGeneric(name, type, presId))
614     return;
615
616 //  STDLOG("Presentation double click");
617 //  STDLOG("  Presentation infos:");
618 //  STDLOG("    - Component:         " + item->componentDataType().toStdString());
619 //  STDLOG("    - Item entry:        " + item->entry().toStdString());
620 //  STDLOG("    - Item name:         " + item->name().toStdString());
621 //  std::ostringstream oss;
622 //  oss << fieldId;
623 //  STDLOG("    - Field id:          " + oss.str());
624 //  STDLOG("    - Presentation name: " + name);
625 }
626
627 void
628 MEDModule::requestSALOMETermination() const
629 {
630   STDLOG("Requesting SALOME termination!!");
631   SUIT_Session::session()->closeSession( SUIT_Session::DONT_SAVE, 1 );  // killServers = True
632 }
633
634
635 //bool MEDModule::hasMainEventLoopStarted() const
636 //{
637 //  return _eventLoopStarted;
638 //}
639
640 int
641 MEDModule::getIntParamFromStudyEditor(SALOMEDS::SObject_var obj, const char* name)
642 {
643   if (obj->_is_nil())
644     return -1;
645
646   SALOMEDS::GenericAttribute_var anAttr;
647   SALOMEDS::AttributeParameter_var aParam;
648   if ( obj->FindAttribute(anAttr,"AttributeParameter") ) {
649     aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
650     if (aParam->IsSet(name, PT_INTEGER))
651       return aParam->GetInt(name);
652   }
653   return -1;
654 }
655
656 LightApp_Displayer* MEDModule::displayer()
657 {
658   if (!_displayer)
659     _displayer = new MEDCALCGUI_Displayer(_presentationController);
660   return _displayer;
661 }
662
663 void MEDModule::visibilityStateUpdateOff() {
664   _enableVisibilityStateUpdate = false;
665 }
666 void MEDModule::visibilityStateUpdateOn() {
667   _enableVisibilityStateUpdate = true;
668 }