1 // Copyright (C) 2016-2024 CEA, EDF
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 #include "PresentationController.hxx"
21 #include <MEDCalcConstants.hxx>
22 #include "MEDModule.hxx"
23 #include "Basics_Utils.hxx"
24 #include "QtxActionGroup.h"
25 #include "QtxActionToolMgr.h"
26 #include "MEDFactoryClient.hxx"
27 #include "MEDPresentationManager_i.hxx"
28 #include "XmedConsoleDriver.hxx"
30 #include "MEDPresentationMeshView.hxx"
31 #include "MEDPresentationScalarMap.hxx"
32 #include "MEDPresentationContour.hxx"
33 #include "MEDPresentationSlices.hxx"
34 #include "MEDPresentationPointSprite.hxx"
35 #include "MEDPresentationVectorField.hxx"
36 #include "MEDPresentationPlot3D.hxx"
37 #include "MEDPresentationStreamLines.hxx"
38 #include "MEDPresentationCutSegment.hxx"
39 #include "MEDPresentationDeflectionShape.hxx"
41 #include "MEDWidgetHelperMeshView.hxx"
42 #include "MEDWidgetHelperScalarMap.hxx"
43 #include "MEDWidgetHelperContour.hxx"
44 #include "MEDWidgetHelperSlices.hxx"
45 #include "MEDWidgetHelperPointSprite.hxx"
46 #include "MEDWidgetHelperPlot3D.hxx"
47 #include "MEDWidgetHelperStreamLines.hxx"
48 #include "MEDWidgetHelperCutSegment.hxx"
49 #include "MEDWidgetHelperVectorField.hxx"
50 #include "MEDWidgetHelperDeflectionShape.hxx"
52 #include <SalomeApp_Application.h>
53 #include <SalomeApp_Study.h>
54 #include <SalomeApp_DataObject.h>
56 #include <SALOME_ListIO.hxx>
57 #include <LightApp_SelectionMgr.h>
59 #include <SALOMEDS_SObject.hxx>
60 #include <SALOMEDS_Study.hxx>
62 #include <SUIT_Desktop.h>
63 #include <SUIT_Session.h>
64 #include <SUIT_ResourceMgr.h>
65 #include <QMessageBox>
69 #include "MEDFactoryClient.hxx"
71 static const int OPTIONS_VIEW_MODE_ID = 943;
72 static const int OPTIONS_VIEW_MODE_REPLACE_ID = 944;
73 static const int OPTIONS_VIEW_MODE_OVERLAP_ID = 945;
74 static const int OPTIONS_VIEW_MODE_NEW_LAYOUT_ID = 946;
75 static const int OPTIONS_VIEW_MODE_SPLIT_VIEW_ID = 947;
77 //! The only instance of the MEDPresentationManager
78 MEDCALC::MEDPresentationManager_ptr PresentationController::_presManager;
80 PresentationController::PresentationController(MEDModule* salomeModule) :
81 _salomeModule(salomeModule),
83 _studyEditor(salomeModule->getStudyEditor()),
85 _currentWidgetHelper(0)
87 STDLOG("Creating a PresentationController");
89 _widgetPresentationParameters = new WidgetPresentationParameters();
91 QMainWindow* parent = salomeModule->getApp()->desktop();
92 _dockWidget = new QDockWidget(parent);
93 _dockWidget->setVisible(false);
94 _dockWidget->setWindowTitle(tr("TITLE_PRESENTATION_PARAMETERS"));
95 _dockWidget->setObjectName(tr("TITLE_PRESENTATION_PARAMETERS"));
96 _dockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
97 _dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
98 _dockWidget->setWidget(_widgetPresentationParameters);
99 parent->addDockWidget(Qt::LeftDockWidgetArea, _dockWidget);
100 //_dockWidget->show();
102 // Retrieve MEDFactory to get MEDPresentationManager (sometimes GUI needs to talk to the engine directly)
103 if ( ! _presManager ) {
104 _presManager = MEDFactoryClient::getFactory()->getPresentationManager();
107 // Connect to the click in the object browser
108 connect(salomeModule, SIGNAL( presentationSelected(int , const QString&, const QString&) ),
109 this, SLOT(onPresentationSelected(int , const QString&, const QString&) ) );
112 PresentationController::~PresentationController()
114 STDLOG("Deleting the resentationController");
115 // Clean allocated widget helpers:
116 for ( std::map<int, MEDWidgetHelper *>::iterator it = _presHelperMap.begin(); it != _presHelperMap.end(); ++it)
117 delete((*it).second);
121 PresentationController::_getIconName(const std::string& name)
123 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
127 // Read value from preferences and suffix name to select icon theme
128 int theme = mgr->integerValue("MEDCalc", "icons");
130 return name + "_MODERN";
131 } else if (theme == 1) {
132 return name + "_CLASSIC";
134 return name + "_DEFAULT";
138 PresentationController::createActions()
140 STDLOG("Creating PresentationController actions");
143 int viewModeToolbarId = _salomeModule->createTool("View Mode", "ViewModeToolbar");
144 QtxActionGroup* ag = _salomeModule->createActionGroup(OPTIONS_VIEW_MODE_ID, true);
145 ag->setText("View mode");
146 ag->setUsesDropDown(true);
147 QString label = tr("LAB_VIEW_MODE_REPLACE");
148 QString tooltip = tr("TIP_VIEW_MODE_REPLACE");
149 QAction* a = _salomeModule->createAction(OPTIONS_VIEW_MODE_REPLACE_ID,label,QIcon(),label,tooltip,0);
150 a->setCheckable(true);
154 label = tr("LAB_VIEW_MODE_OVERLAP");
155 tooltip = tr("TIP_VIEW_MODE_OVERLAP");
156 a = _salomeModule->createAction(OPTIONS_VIEW_MODE_OVERLAP_ID,label,QIcon(),label,tooltip,0);
157 a->setCheckable(true);
160 label = tr("LAB_VIEW_MODE_NEW_LAYOUT");
161 tooltip = tr("TIP_VIEW_MODE_NEW_LAYOUT");
162 a = _salomeModule->createAction(OPTIONS_VIEW_MODE_NEW_LAYOUT_ID,label,QIcon(),label,tooltip,0);
163 a->setCheckable(true);
166 label = tr("LAB_VIEW_MODE_SPLIT_VIEW");
167 tooltip = tr("TIP_VIEW_MODE_SPLIT_VIEW");
168 a = _salomeModule->createAction(OPTIONS_VIEW_MODE_SPLIT_VIEW_ID,label,QIcon(),label,tooltip,0);
169 a->setCheckable(true);
172 _salomeModule->createTool(OPTIONS_VIEW_MODE_ID, viewModeToolbarId);
175 int presentationToolbarId = _salomeModule->createTool("Presentations", "PresentationToolbar");
176 int presentationMenuId = _salomeModule->createMenu(tr("MENU_PRESENTATIONS"), -1, -1, 10);
178 label = tr("LAB_PRESENTATION_MESH_VIEW");
179 tooltip = tr("TIP_PRESENTATION_MESH_VIEW");
180 QString icon = tr(_getIconName("ICO_PRESENTATION_MESH_VIEW").c_str());
182 actionId = _salomeModule->createStandardAction(label,this, SLOT(onVisualizeMeshView()),icon,tooltip);
183 _salomeModule->createTool(actionId, presentationToolbarId);
184 _salomeModule->action(actionId)->setIconVisibleInMenu(true);
185 _salomeModule->createMenu(actionId, presentationMenuId);
187 label = tr("LAB_PRESENTATION_SCALAR_MAP");
188 tooltip = tr("TIP_PRESENTATION_SCALAR_MAP");
189 icon = tr(_getIconName("ICO_PRESENTATION_SCALAR_MAP").c_str());
190 actionId = _salomeModule->createStandardAction(label, this, SLOT(onVisualizeScalarMap()),
191 icon, tooltip, FIELDSOp::OpScalarMap);
192 _salomeModule->createTool(actionId, presentationToolbarId);
193 _salomeModule->action(actionId)->setIconVisibleInMenu(true);
194 _salomeModule->createMenu(actionId, presentationMenuId);
196 label = tr("LAB_PRESENTATION_CONTOUR");
197 tooltip = tr("TIP_PRESENTATION_CONTOUR");
198 icon = tr(_getIconName("ICO_PRESENTATION_CONTOUR").c_str());
199 actionId = _salomeModule->createStandardAction(label, this, SLOT(onVisualizeContour()),
200 icon, tooltip, FIELDSOp::OpContour);
201 _salomeModule->createTool(actionId, presentationToolbarId);
202 _salomeModule->action(actionId)->setIconVisibleInMenu(true);
203 _salomeModule->createMenu(actionId, presentationMenuId);
205 label = tr("LAB_PRESENTATION_VECTOR_FIELD");
206 tooltip = tr("TIP_PRESENTATION_VECTOR_FIELD");
207 icon = tr(_getIconName("ICO_PRESENTATION_VECTOR_FIELD").c_str());
208 actionId = _salomeModule->createStandardAction(label, this, SLOT(onVisualizeVectorField()),
209 icon, tooltip, FIELDSOp::OpVectorFields);
210 _salomeModule->createTool(actionId, presentationToolbarId);
211 _salomeModule->action(actionId)->setIconVisibleInMenu(true);
212 _salomeModule->createMenu(actionId, presentationMenuId);
214 label = tr("LAB_PRESENTATION_SLICES");
215 tooltip = tr("TIP_PRESENTATION_SLICES");
216 icon = tr(_getIconName("ICO_PRESENTATION_SLICES").c_str());
217 actionId = _salomeModule->createStandardAction(label, this, SLOT(onVisualizeSlices()),
218 icon, tooltip, FIELDSOp::OpSlices);
219 _salomeModule->createTool(actionId, presentationToolbarId);
220 _salomeModule->action(actionId)->setIconVisibleInMenu(true);
221 _salomeModule->createMenu(actionId, presentationMenuId);
223 label = tr("LAB_PRESENTATION_DEFLECTION_SHAPE");
224 tooltip = tr("TIP_PRESENTATION_DEFLECTION_SHAPE");
225 icon = tr(_getIconName("ICO_PRESENTATION_DEFLECTION_SHAPE").c_str());
226 actionId = _salomeModule->createStandardAction(label, this, SLOT(onVisualizeDeflectionShape()),
227 icon, tooltip, FIELDSOp::OpDeflectionShape);
228 _salomeModule->createTool(actionId, presentationToolbarId);
229 _salomeModule->action(actionId)->setIconVisibleInMenu(true);
230 _salomeModule->createMenu(actionId, presentationMenuId);
232 label = tr("LAB_PRESENTATION_POINT_SPRITE");
233 tooltip = tr("TIP_PRESENTATION_POINT_SPRITE");
234 icon = tr(_getIconName("ICO_PRESENTATION_POINT_SPRITE").c_str());
235 actionId = _salomeModule->createStandardAction(label, this, SLOT(onVisualizePointSprite()),
236 icon, tooltip, FIELDSOp::OpPointSprite);
237 _salomeModule->createTool(actionId, presentationToolbarId);
238 _salomeModule->action(actionId)->setIconVisibleInMenu(true);
239 _salomeModule->createMenu(actionId, presentationMenuId);
241 // sphinx doc: begin of plot3d gui items
242 label = tr("LAB_PRESENTATION_PLOT3D");
243 tooltip = tr("TIP_PRESENTATION_PLOT3D");
244 icon = tr(_getIconName("ICO_PRESENTATION_PLOT3D").c_str());
245 actionId = _salomeModule->createStandardAction(label, this, SLOT(onVisualizePlot3D()),
246 icon, tooltip, FIELDSOp::OpPlot3D);
247 _salomeModule->createTool(actionId, presentationToolbarId);
248 _salomeModule->action(actionId)->setIconVisibleInMenu(true);
249 _salomeModule->createMenu(actionId, presentationMenuId);
250 // sphinx doc: end of plot3d gui items
252 label = tr("LAB_PRESENTATION_STREAM_LINES");
253 tooltip = tr("TIP_PRESENTATION_STREAM_LINES");
254 icon = tr(_getIconName("ICO_PRESENTATION_STREAM_LINES").c_str());
255 actionId = _salomeModule->createStandardAction(label, this, SLOT(onVisualizeStreamLines()),
256 icon, tooltip, FIELDSOp::OpStreamLines);
257 _salomeModule->createTool(actionId, presentationToolbarId);
258 _salomeModule->action(actionId)->setIconVisibleInMenu(true);
259 _salomeModule->createMenu(actionId, presentationMenuId);
261 label = tr("LAB_PRESENTATION_CUT_SEGMENT");
262 tooltip = tr("TIP_PRESENTATION_CUT_SEGMENT");
263 icon = tr(_getIconName("ICO_PRESENTATION_CUT_SEGMENT").c_str());
264 actionId = _salomeModule->createStandardAction(label, this, SLOT(onVisualizeCutSegment()),
265 icon, tooltip, FIELDSOp::OpCutSegment);
266 _salomeModule->createTool(actionId, presentationToolbarId);
267 _salomeModule->action(actionId)->setIconVisibleInMenu(true);
268 _salomeModule->createMenu(actionId, presentationMenuId);
272 _salomeModule->createMenu(_salomeModule->separator(), presentationMenuId);
274 label = tr("LAB_DELETE_PRESENTATION");
275 tooltip = tr("TIP_DELETE_PRESENTATION");
276 icon = tr("ICO_DELETE_PRESENTATION");
277 actionId = _salomeModule->createStandardAction(label,this, SLOT(onDeletePresentation()),icon,tooltip);
278 // _salomeModule->createTool(actionId, presentationToolbarId);
279 // _salomeModule->action(actionId)->setIconVisibleInMenu(true);
280 _salomeModule->createMenu(actionId, presentationMenuId);
282 // Low level PARAVIS dump
283 label = tr("LAB_PARAVIS_DUMP");
284 tooltip = tr("TIP_PARAVIS_DUMP");
285 actionId = _salomeModule->createStandardAction(label,this,SLOT(onParavisDump()),"");
286 _salomeModule->createMenu(actionId, presentationMenuId);
289 // Actions for popup menu only
294 MEDCALC::ViewModeType
295 PresentationController::getSelectedViewMode() const
297 if (_salomeModule->action(OPTIONS_VIEW_MODE_REPLACE_ID)->isChecked()) {
298 return MEDCALC::VIEW_MODE_REPLACE;
300 else if (_salomeModule->action(OPTIONS_VIEW_MODE_OVERLAP_ID)->isChecked()) {
301 return MEDCALC::VIEW_MODE_OVERLAP;
303 else if (_salomeModule->action(OPTIONS_VIEW_MODE_NEW_LAYOUT_ID)->isChecked()) {
304 return MEDCALC::VIEW_MODE_NEW_LAYOUT;
306 else if (_salomeModule->action(OPTIONS_VIEW_MODE_SPLIT_VIEW_ID)->isChecked()) {
307 return MEDCALC::VIEW_MODE_SPLIT_VIEW;
310 STDLOG("Strange!! No matching view mode found - returning VIEW_MODE_REPLACE.");
311 return MEDCALC::VIEW_MODE_REPLACE;
314 MEDCALC::ColorMapType
315 PresentationController::getSelectedColorMap() const
317 return _widgetPresentationParameters->getColorMap();
320 MEDCALC::ScalarBarRangeType
321 PresentationController::getSelectedScalarBarRange() const
323 return _widgetPresentationParameters->getScalarBarRange();
327 PresentationController::visualize(PresentationEvent::EventType eventType)
329 // Get the selected objects in the study (SObject)
330 SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
332 // For each object, emit a signal to the workspace to request a
333 // visualisation using the tui command (so that the user can see how
334 // to make a view of an object from the tui console).
335 for (int i=0; i<(int)listOfSObject->size(); i++) {
336 SALOMEDS::SObject_var soObj = listOfSObject->at(i);
337 std::string name(_studyEditor->getName(soObj));
338 if (soObj->_is_nil() || name == "MEDCalc")
340 int fieldId = _salomeModule->getIntParamFromStudyEditor(soObj, FIELD_ID);
341 int meshId = _salomeModule->getIntParamFromStudyEditor(soObj, MESH_ID);
342 MEDCALC::FieldHandler* fieldHandler = 0;
343 MEDCALC::MeshHandler* meshHandler = 0;
348 if (eventType != PresentationEvent::EVENT_VIEW_OBJECT_MESH_VIEW)
350 meshHandler = MEDFactoryClient::getDataManager()->getMeshHandler(meshId);
354 if (fieldId < 0) // is it a field series?
356 int fieldSeriesId = _salomeModule->getIntParamFromStudyEditor(soObj, FIELD_SERIES_ID);
357 // If fieldId and fieldSeriesId equals -1, then it means that it is not a field
358 // managed by the MED module, and we stop this function process.
359 if ( fieldSeriesId < 0)
362 // get the current timestamp
363 double timestamp = _salomeModule->getCurrentAnimationTimestamp();
364 // get the field id a the current timestamp
365 fieldId = MEDFactoryClient::getDataManager()->getFieldIdAtTimestamp(fieldSeriesId, timestamp);
367 fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
370 if ((!fieldHandler) && (!meshHandler)) {
371 QMessageBox::warning(_salomeModule->getApp()->desktop(),
372 tr("Operation not allowed"),
373 tr("No field (or mesh) is defined"));
377 PresentationEvent* event = new PresentationEvent();
378 event->eventtype = eventType;
379 event->fieldHandler = fieldHandler;
380 event->meshHandler = meshHandler;
381 emit presentationSignal(event); // --> processPresentationEvent()
386 PresentationController::onVisualizeMeshView()
388 this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_MESH_VIEW);
392 PresentationController::onVisualizeScalarMap()
394 this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP);
398 PresentationController::onVisualizeContour()
400 this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_CONTOUR);
404 PresentationController::onVisualizeVectorField()
406 this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD);
410 PresentationController::onVisualizeSlices()
412 this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_SLICES);
416 PresentationController::onVisualizeDeflectionShape()
418 this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE);
422 PresentationController::onVisualizePointSprite()
424 this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE);
427 // sphinx doc: begin of onVisualizePlot3D
429 PresentationController::onVisualizePlot3D()
431 this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_PLOT3D);
433 // sphinx doc: end of onVisualizePlot3D
436 PresentationController::onVisualizeStreamLines()
438 this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_STREAM_LINES);
442 PresentationController::onVisualizeCutSegment()
444 // Cut segment presentation "creates" new view, so switch off visibility state update
445 // because pqActiveObjects::viewChanged is emmited
446 _salomeModule->visibilityStateUpdateOff();
447 this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_CUT_SEGMENT);
448 _salomeModule->visibilityStateUpdateOn();
449 _salomeModule->updateVisibilityState();
453 PresentationController::onDeletePresentation()
455 // Get the selected objects in the study (SObject)
456 SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
458 // For each object, emit a signal to the workspace to request pres deletion
459 for (int i=0; i<(int)listOfSObject->size(); i++) {
460 SALOMEDS::SObject_var soPres = listOfSObject->at(i);
461 std::string name(_studyEditor->getName(soPres));
462 if (soPres->_is_nil() || name == "MEDCalc")
464 int presId = _salomeModule->getIntParamFromStudyEditor(soPres,PRESENTATION_ID);
465 // If fieldId equals -1, then it means that it is not a field
466 // managed by the MED module, and we stop this function process.
470 PresentationEvent* event = new PresentationEvent();
471 event->eventtype = PresentationEvent::EVENT_DELETE_PRESENTATION;
472 event->presentationId = presId;
473 emit presentationSignal(event); // --> processPresentationEvent()
478 PresentationController::getViewModePython() const
480 MEDCALC::ViewModeType viewMode = getSelectedViewMode();
482 case MEDCALC::VIEW_MODE_REPLACE: return "MEDCALC.VIEW_MODE_REPLACE";
483 case MEDCALC::VIEW_MODE_OVERLAP: return "MEDCALC.VIEW_MODE_OVERLAP";
484 case MEDCALC::VIEW_MODE_NEW_LAYOUT: return "MEDCALC.VIEW_MODE_NEW_LAYOUT";
485 case MEDCALC::VIEW_MODE_SPLIT_VIEW: return "MEDCALC.VIEW_MODE_SPLIT_VIEW";
491 PresentationController::getColorMapPython() const
493 MEDCALC::ColorMapType colorMap = getSelectedColorMap();
495 case MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW: return "MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW";
496 case MEDCALC::COLOR_MAP_COOL_TO_WARM: return "MEDCALC.COLOR_MAP_COOL_TO_WARM";
502 PresentationController::getScalarBarRangePython() const
504 MEDCALC::ScalarBarRangeType scalarBarRange = getSelectedScalarBarRange();
505 switch(scalarBarRange) {
506 case MEDCALC::SCALAR_BAR_ALL_TIMESTEPS: return "MEDCALC.SCALAR_BAR_ALL_TIMESTEPS";
507 case MEDCALC::SCALAR_BAR_CURRENT_TIMESTEP: return "MEDCALC.SCALAR_BAR_CURRENT_TIMESTEP";
508 case MEDCALC::SCALAR_BAR_CUSTOM_RANGE: return "MEDCALC.SCALAR_BAR_CUSTOM_RANGE";
514 PresentationController::getMeshModePython(const int mode) const
516 MEDCALC::MeshModeType mod = static_cast<MEDCALC::MeshModeType>(mode);
518 case MEDCALC::MESH_MODE_WIREFRAME: return "MEDCALC.MESH_MODE_WIREFRAME";
519 case MEDCALC::MESH_MODE_SURFACE: return "MEDCALC.MESH_MODE_SURFACE";
520 case MEDCALC::MESH_MODE_SURFACE_EDGES: return "MEDCALC.MESH_MODE_SURFACE_EDGES";
526 PresentationController::getSliceOrientationPython(const int orientation) const
528 MEDCALC::SliceOrientationType orient = static_cast<MEDCALC::SliceOrientationType>(orientation);
530 case MEDCALC::SLICE_NORMAL_TO_X: return "MEDCALC.SLICE_NORMAL_TO_X";
531 case MEDCALC::SLICE_NORMAL_TO_Y: return "MEDCALC.SLICE_NORMAL_TO_Y";
532 case MEDCALC::SLICE_NORMAL_TO_Z: return "MEDCALC.SLICE_NORMAL_TO_Z";
533 case MEDCALC::SLICE_NORMAL_TO_XY: return "MEDCALC.SLICE_NORMAL_TO_XY";
534 case MEDCALC::SLICE_NORMAL_TO_XZ: return "MEDCALC.SLICE_NORMAL_TO_XZ";
535 case MEDCALC::SLICE_NORMAL_TO_YZ: return "MEDCALC.SLICE_NORMAL_TO_YZ";
536 case MEDCALC::SLICE_NORMAL_TO_XYZ: return "MEDCALC.SLICE_NORMAL_TO_XYZ";
542 PresentationController::getIntegrDirTypePython(const int intDir) const
544 MEDCALC::IntegrationDirType type = static_cast<MEDCALC::IntegrationDirType>(intDir);
546 case MEDCALC::INTEGRATION_DIR_BOTH: return "MEDCALC.INTEGRATION_DIR_BOTH";
547 case MEDCALC::INTEGRATION_DIR_FORWARD: return "MEDCALC.INTEGRATION_DIR_FORWARD";
548 case MEDCALC::INTEGRATION_DIR_BACKWARD: return "MEDCALC.INTEGRATION_DIR_BACKWARD";
555 PresentationController::getPresTypeFromWidgetHelper(int presId) const
557 std::map<int, MEDWidgetHelper *>::const_iterator it =_presHelperMap.find(presId);
558 if (it != _presHelperMap.end())
559 return (*it).second->getPythonTag();
564 PresentationController::emitPresentationSignal(const PresentationEvent* event)
566 emit presentationSignal(event);
570 PresentationController::processPresentationEvent(const PresentationEvent* event) {
571 // --> Send commands to SALOME Python console
572 QString viewMode = getViewModePython();
573 QString colorMap = getColorMapPython();
574 QString scalarBarRange = getScalarBarRangePython();
575 MEDCALC::FieldHandler* fieldHandler = event->fieldHandler;
576 QStringList commands;
578 // [ABN] using event mechanism for all this is awkward? TODO: direct implementation in each
579 // dedicated widget helper class?
581 if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_MESH_VIEW ) {
582 // Do we request mesh view from a field or from a mesh only?
583 int meshId = event->meshHandler ? event->meshHandler->id : event->fieldHandler->meshid;
584 commands += QString("presentation_id = medcalc.MakeMeshView(%1, viewMode=%2)").arg(meshId).arg(viewMode);
585 commands += QString("presentation_id");
587 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) {
588 commands += QString("presentation_id = medcalc.MakeScalarMap(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
589 .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
590 commands += QString("presentation_id");
592 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_CONTOUR ) {
593 commands += QString("presentation_id = medcalc.MakeContour(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
594 .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
595 commands += QString("presentation_id");
597 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SLICES ) {
598 commands += QString("presentation_id = medcalc.MakeSlices(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
599 .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
600 commands += QString("presentation_id");
602 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD ) {
603 commands += QString("presentation_id = medcalc.MakeVectorField(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
604 .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
605 commands += QString("presentation_id");
607 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE ) {
608 commands += QString("presentation_id = medcalc.MakePointSprite(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
609 .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
610 commands += QString("presentation_id");
612 // sphinx doc: begin of plot3d prs creation
613 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_PLOT3D ) {
614 commands += QString("presentation_id = medcalc.MakePlot3D(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
615 .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
616 commands += QString("presentation_id");
618 // sphinx doc: end of plot3d prs creation
619 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_STREAM_LINES ) {
620 commands += QString("presentation_id = medcalc.MakeStreamLines(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
621 .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
622 commands += QString("presentation_id");
624 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_CUT_SEGMENT ) {
625 commands += QString("presentation_id = medcalc.MakeCutSegment(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
626 .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
627 commands += QString("presentation_id");
629 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) {
630 commands += QString("presentation_id = medcalc.MakeDeflectionShape(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
631 .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
632 commands += QString("presentation_id");
636 else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_COMPONENT ) {
637 std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
638 commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId);
639 commands += QString("params.displayedComponent = '%1'").arg(QString::fromStdString(event->aString));
640 commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(typ)).arg(event->presentationId);
642 else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_COLORMAP ) {
643 std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
644 commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId);
645 commands += QString("params.colorMap = %1").arg(getColorMapPython());
646 commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(typ)).arg(event->presentationId);
648 else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_TIME_RANGE ) {
649 bool customRangeFlag =
650 (bool)_presManager->getPresentationIntProperty(event->presentationId, MEDPresentation::PROP_HIDE_DATA_OUTSIDE_CUSTOM_RANGE.c_str());
651 std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
652 commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId);
653 commands += QString("params.scalarBarRange = %1").arg(getScalarBarRangePython());
654 if (getSelectedScalarBarRange() == MEDCALC::SCALAR_BAR_CUSTOM_RANGE) {
655 commands += QString("params.scalarBarRangeArray = [%1, %2]").arg(event->aDouble1).arg(event->aDouble2);
658 if (customRangeFlag) // switch off hideDataOutsideCustomRange
660 commands += QString("params.hideDataOutsideCustomRange = False");
663 commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(typ)).arg(event->presentationId);
665 else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_NB_CONTOUR ) {
666 std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
667 commands += QString("params = medcalc.GetContourParameters(%2)").arg(event->presentationId);
668 commands += QString("params.nbContours = %1").arg(event->anInteger);
669 commands += QString("medcalc.UpdateContour(%1, params)").arg(event->presentationId);
671 else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_MESH_MODE ) {
672 std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
673 commands += QString("params = medcalc.GetMeshViewParameters(%2)").arg(event->presentationId);
674 commands += QString("params.mode = %1").arg(getMeshModePython(event->anInteger));
675 commands += QString("medcalc.UpdateMeshView(%1, params)").arg(event->presentationId);
677 else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_NB_SLICES ) {
678 std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
679 commands += QString("params = medcalc.GetSlicesParameters(%2)").arg(event->presentationId);
680 commands += QString("params.nbSlices = %1").arg(event->anInteger);
681 commands += QString("medcalc.UpdateSlices(%1, params)").arg(event->presentationId);
683 else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_SLICE_ORIENTATION ) {
684 std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
685 commands += QString("params = medcalc.GetSlicesParameters(%2)").arg(event->presentationId);
686 commands += QString("params.orientation = %1").arg(getSliceOrientationPython(event->anInteger));
687 commands += QString("medcalc.UpdateSlices(%1, params)").arg(event->presentationId);
689 // sphinx doc: begin of plot3d prs update
690 else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_PLANE_POS ) {
691 std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
692 commands += QString("params = medcalc.GetPlot3DParameters(%2)").arg(event->presentationId);
693 commands += QString("params.planePos = %1").arg(event->aDouble3);
694 commands += QString("medcalc.UpdatePlot3D(%1, params)").arg(event->presentationId);
696 else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_NORMAL ) {
697 std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
698 commands += QString("params = medcalc.GetPlot3DParameters(%2)").arg(event->presentationId);
699 commands += QString("params.planeNormal = [%1, %2, %3]").arg(event->aDoubleN[0]).arg(event->aDoubleN[1]).arg(event->aDoubleN[2]);
700 commands += QString("medcalc.UpdatePlot3D(%1, params)").arg(event->presentationId);
702 // sphinx doc: end of plot3d prs update
703 else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_CUT_POINT1 ) {
704 std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
705 commands += QString("params = medcalc.GetCutSegmentParameters(%2)").arg(event->presentationId);
706 commands += QString("params.point1 = [%1, %2, %3]").arg(event->aDoubleP1[0]).arg(event->aDoubleP1[1]).arg(event->aDoubleP1[2]);
707 commands += QString("medcalc.UpdateCutSegment(%1, params)").arg(event->presentationId);
709 else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_CUT_POINT2 ) {
710 std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
711 commands += QString("params = medcalc.GetCutSegmentParameters(%2)").arg(event->presentationId);
712 commands += QString("params.point2 = [%1, %2, %3]").arg(event->aDoubleP2[0]).arg(event->aDoubleP2[1]).arg(event->aDoubleP2[2]);
713 commands += QString("medcalc.UpdateCutSegment(%1, params)").arg(event->presentationId);
715 else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_INTEGR_DIR ) {
716 std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
717 commands += QString("params = medcalc.GetStreamLinesParameters(%2)").arg(event->presentationId);
718 commands += QString("params.integrDir = %1").arg(getIntegrDirTypePython(event->anInteger));
719 commands += QString("medcalc.UpdateStreamLines(%1, params)").arg(event->presentationId);
721 else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_CONTOUR_COMPONENT) {
722 std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
723 commands += QString("params = medcalc.GetContourParameters(%2)").arg(event->presentationId);
724 commands += QString("params.contourComponent = '%1'").arg(event->aString.c_str());
725 commands += QString("medcalc.UpdateContour(%1, params)").arg(event->presentationId);
727 else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_SCALE_FACTOR ) {
728 std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
729 commands += QString("params = medcalc.GetVectorFieldParameters(%2)").arg(event->presentationId);
730 commands += QString("params.scaleFactor = %1").arg(event->aDouble3);
731 commands += QString("medcalc.UpdateVectorField(%1, params)").arg(event->presentationId);
734 else if (event->eventtype == PresentationEvent::EVENT_CHANGE_CUSTOM_SCALE_FACTOR) {
735 std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
736 commands += QString("params = medcalc.GetVectorFieldParameters(%2)").arg(event->presentationId);
737 commands += QString("params.customScaleFactor = %1").arg(event->anInteger);
738 if(event->anInteger) {
739 commands += QString("params.scaleFactor = %1").arg(event->aDouble3);
741 commands += QString("medcalc.UpdateVectorField(%1, params)").arg(event->presentationId);
744 else if ( event->eventtype == PresentationEvent::EVENT_DELETE_PRESENTATION ) {
745 commands += QString("medcalc.RemovePresentation(%1)").arg(event->presentationId);
748 else if (event->eventtype == PresentationEvent::EVENT_DISPLAY_PRESENTATION ||
749 event->eventtype == PresentationEvent::EVENT_ERASE_PRESENTATION) {
750 commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(getPresTypeFromWidgetHelper(event->presentationId)))
751 .arg(event->presentationId);
752 QString visility = event->eventtype == PresentationEvent::EVENT_DISPLAY_PRESENTATION ? QString("True") : QString("False");
753 commands += QString("params.visibility = %1").arg(visility);
754 commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(getPresTypeFromWidgetHelper(event->presentationId)))
755 .arg(event->presentationId);
757 else if (event->eventtype == PresentationEvent::EVENT_SCALAR_BAR_VISIBILITY_CHANGED ||
758 event->eventtype == PresentationEvent::EVENT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE_CHANGED) {
759 std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
761 switch (event->eventtype) {
762 case PresentationEvent::EVENT_SCALAR_BAR_VISIBILITY_CHANGED:
763 param = QString("scalarBarVisibility");
765 case PresentationEvent::EVENT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE_CHANGED:
766 param = QString("hideDataOutsideCustomRange");
770 commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId);
771 commands += QString("params.%1 = %2").arg(param).arg( event->anInteger ? QString("True") : QString("False"));
772 if (event->eventtype == PresentationEvent::EVENT_HIDE_DATA_OUTSIDE_CUSTOM_RANGE_CHANGED && event->anInteger) {
773 commands += QString("params.scalarBarRangeArray = [%1, %2]").arg(event->aDouble1).arg(event->aDouble2);
775 commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(typ)).arg(event->presentationId);
777 else if (event->eventtype == PresentationEvent::EVENT_CUSTOM_RANGE_CHANGED)
779 std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
780 commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId);
781 commands += QString("params.scalarBarRangeArray = [%1, %2]").arg(event->aDouble1).arg(event->aDouble2);
782 commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(typ)).arg(event->presentationId);
785 STDLOG("The event "<<event->eventtype<<" is not implemented yet");
787 _consoleDriver->exec(commands);
791 PresentationController::findOrCreateWidgetHelper(MEDCALC::MEDPresentationManager_ptr /*presManager*/, // todo: unused
792 int presId, const std::string& type, const std::string& name )
794 std::map<int, MEDWidgetHelper *>::const_iterator it =_presHelperMap.find(presId);
795 if (it != _presHelperMap.end())
797 MEDWidgetHelper * wh = 0;
798 if (type == MEDPresentationMeshView::TYPE_NAME)
799 wh = new MEDWidgetHelperMeshView(this, _presManager, presId, name, _widgetPresentationParameters);
800 else if (type == MEDPresentationScalarMap::TYPE_NAME)
801 wh = new MEDWidgetHelperScalarMap(this, _presManager, presId, name, _widgetPresentationParameters);
802 else if (type == MEDPresentationContour::TYPE_NAME)
803 wh = new MEDWidgetHelperContour(this, _presManager, presId, name, _widgetPresentationParameters);
804 else if (type == MEDPresentationSlices::TYPE_NAME)
805 wh = new MEDWidgetHelperSlices(this, _presManager, presId, name, _widgetPresentationParameters);
806 else if (type == MEDPresentationVectorField::TYPE_NAME)
807 wh = new MEDWidgetHelperVectorField(this, _presManager, presId, name, _widgetPresentationParameters);
808 else if (type == MEDPresentationPointSprite::TYPE_NAME)
809 wh = new MEDWidgetHelperPointSprite(this, _presManager, presId, name, _widgetPresentationParameters);
810 else if (type == MEDPresentationPlot3D::TYPE_NAME)
811 wh = new MEDWidgetHelperPlot3D(this, _presManager, presId, name, _widgetPresentationParameters);
812 else if (type == MEDPresentationStreamLines::TYPE_NAME)
813 wh = new MEDWidgetHelperStreamLines(this, _presManager, presId, name, _widgetPresentationParameters);
814 else if (type == MEDPresentationCutSegment::TYPE_NAME)
815 wh = new MEDWidgetHelperCutSegment(this, _presManager, presId, name, _widgetPresentationParameters);
816 else if (type == MEDPresentationDeflectionShape::TYPE_NAME)
817 wh = new MEDWidgetHelperDeflectionShape(this, _presManager, presId, name, _widgetPresentationParameters);
820 STDLOG("findOrCreateWidgetHelper(): NOT IMPLEMENTED !!!");
823 _presHelperMap[presId] = wh;
828 PresentationController::onPresentationSelected(int presId, const QString& presType, const QString& presName)
832 if (_widgetPresentationParameters->isShown())
834 _widgetPresentationParameters->toggleWidget(false);
835 if(_currentWidgetHelper)
836 _currentWidgetHelper->releaseWidget();
841 if(_currentWidgetHelper)
842 _currentWidgetHelper->releaseWidget();
843 // Activate corresponding ParaView render view
844 _presManager->activateView(presId);
845 // Update widgets parameters
846 _currentWidgetHelper = findOrCreateWidgetHelper(_presManager, presId, presType.toStdString(), presName.toStdString());
847 _currentWidgetHelper->updateWidget(true);
852 PresentationController::onParavisDump()
854 // Get the selected objects in the study (SObject)
855 SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
857 // For the first object only, request the dump
858 for (int i=0; i<(int)listOfSObject->size(); i++) {
859 SALOMEDS::SObject_var soPres = listOfSObject->at(i);
860 std::string name(_studyEditor->getName(soPres));
861 if (soPres->_is_nil() || name == "MEDCalc")
863 int presId = _salomeModule->getIntParamFromStudyEditor(soPres,PRESENTATION_ID);
864 // If fieldId equals -1, then it means that it is not a field
865 // managed by the MED module, and we stop this function process.
869 std::string dump(_presManager->getParavisDump(presId));
870 std::cerr << "#====== ParaVis dump (presentation " << presId << ") =====" << std::endl;
872 std::cerr << "#====== End of ParaVis dump =============== " << std::endl;
874 break; // stop at the first one
879 PresentationController::updateTreeViewWithNewPresentation(long dataId, long presentationId)
881 if (presentationId < 0) {
882 std::cerr << "Unknown presentation\n";
886 std::string name(_presManager->getPresentationStringProperty(presentationId, MEDPresentation::PROP_NAME.c_str()));
887 std::string type = name;
888 std::string icon = std::string("ICO_") + type;
889 icon = _getIconName(icon);
890 std::string ico = tr(icon.c_str()).toStdString();
892 // Append presentation ID to the displayed name in the OB:
893 std::ostringstream oss;
894 name = tr(name.c_str()).toStdString();
895 oss << name << " (" << presentationId << ")";
897 // Mesh views are always registered at the mesh level:
898 if (type == MEDPresentationMeshView::TYPE_NAME)
900 _salomeModule->engine()->registerPresentationMesh(dataId, oss.str().c_str(), type.c_str(),ico.c_str(), presentationId);
903 _salomeModule->engine()->registerPresentationField(dataId, oss.str().c_str(), type.c_str(),ico.c_str(), presentationId);
905 // update Object browser
906 _salomeModule->getApp()->updateObjectBrowser(true);
908 // auto-select new presentation
909 std::string entry = _salomeModule->engine()->getStudyPresentationEntry(presentationId);
910 SALOME_ListIO selectedObjects;
911 LightApp_Study* lightStudy = dynamic_cast<LightApp_Study*>( _salomeModule->application()->activeStudy() );
912 QString component = lightStudy->componentDataType( entry.c_str() );
913 selectedObjects.Append( new SALOME_InteractiveObject( (const char*)entry.c_str(),
914 (const char*)component.toLatin1(),
915 ""/*refobj->Name().c_str()*/ ) );
916 //QStringList selectedObjects;
917 //selectedObjects << QString(entry.c_str());
918 LightApp_SelectionMgr* aSelectionMgr = _salomeModule->getApp()->selectionMgr();
919 aSelectionMgr->setSelectedObjects(selectedObjects, false);
921 // emit onPresentationSelected
923 _salomeModule->itemClickGeneric(name, type, presId);
924 onPresentationSelected(presId, QString::fromStdString(type), QString::fromStdString(name));
925 updateVisibilityState(presId);
929 PresentationController::updateTreeViewForPresentationRemoval(long presentationId)
931 if (presentationId < 0) {
932 std::cerr << "Unknown presentation\n";
936 _salomeModule->engine()->unregisterPresentation(presentationId);
938 // update Object browser
939 _salomeModule->getApp()->updateObjectBrowser(true);
943 PresentationController::_dealWithReplaceMode()
945 // Deal with replace mode: presentations with invalid IDs have to be removed:
947 MEDCALC::PresentationsList * lstManager = _presManager->getAllPresentations();
948 MED_ORB::PresentationsList * lstModule = _salomeModule->engine()->getStudyPresentations();
949 // The IDs not in the intersection needs deletion:
950 CORBA::Long * last = lstManager->get_buffer() + lstManager->length();
951 for (unsigned i = 0; i < lstModule->length(); i++) {
952 CORBA::Long * ptr = std::find(lstManager->get_buffer(), last, (*lstModule)[i]);
954 STDLOG("Removing pres " << (*lstModule)[i] << " from OB.");
955 // Presentation in module but not in manager anymore: to be deleted from OB:
956 updateTreeViewForPresentationRemoval((*lstModule)[i]);
962 PresentationController::processWorkspaceEvent(const MEDCALC::MedEvent* event)
964 if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) {
965 if (event->dataId == -1) {
966 // A file has been loaded, and we want to create a default presentation (MeshView) for it
967 QString viewMode = getViewModePython();
968 QStringList commands;
969 commands += QString("presentation_id = medcalc.MakeMeshView(medcalc.GetFirstMeshFromDataSource(source_id), viewMode=%1)").arg(viewMode);
970 commands += QString("presentation_id");
971 _consoleDriver->exec(commands);
974 updateTreeViewWithNewPresentation(event->dataId, event->presentationId);
975 _dealWithReplaceMode();
976 // Update parameter widget if shown: some parameters should be updated after presentation has been added
977 if (_currentWidgetHelper)
978 _currentWidgetHelper->updateWidget(false);
981 else if ( event->type == MEDCALC::EVENT_REMOVE_PRESENTATION ) {
982 updateTreeViewForPresentationRemoval(event->presentationId);
983 // Hide parameter widget if necessary:
984 onPresentationSelected(-1, "", "");
986 else if ( event->type == MEDCALC::EVENT_MODIFY_PRESENTATION ) {
987 // Update parameter widget if shown:
988 if(_currentWidgetHelper)
989 _currentWidgetHelper->updateWidget(false);
991 else if (event->type == MEDCALC::EVENT_VISIBILITY_CHANGED) {
992 updateVisibilityState(event->presentationId);
997 PresentationController::showDockWidgets(bool isVisible)
999 _dockWidget->setVisible(isVisible);
1002 void PresentationController::updateVisibilityState(long presId)
1004 char* str = _salomeModule->engine()->getStudyPresentationEntry(presId);
1006 QStringList entries;
1007 entries.append(str);
1008 _salomeModule->updateVisibilityState(false, entries);
1012 std::string PresentationController::presentationName2Type(const std::string& name) {
1013 return std::regex_replace(name, std::regex("MEDPresentation"), std::string(""));
1016 void PresentationController::resetPVSession()
1018 QStringList commands;
1019 commands += QString("pvs.ResetSession()");
1020 _consoleDriver->exec(commands);