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