Salome HOME
bos #20430 [CEA 20428] FIELDS : improvement of simplified visualisations: fix problem...
[modules/med.git] / src / MEDCalc / gui / dialogs / WidgetPresentationParameters.cxx
1 // Copyright (C) 2016-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 #ifdef WIN32
21 #define NOMINMAX
22 #endif
23
24 #include "WidgetPresentationParameters.hxx"
25 #include <Basics_Utils.hxx>
26
27 #include <limits>
28
29 using namespace std;
30
31 WidgetPresentationParameters::WidgetPresentationParameters(QWidget* parent)
32   : QWidget(parent), _blockSig(false)
33 {
34   _ui.setupUi(this); // To be done first
35
36   toggleWidget(false);
37   QObject::connect(_ui.comboBoxCompo,          SIGNAL(activated(int)),
38                    this,                       SLOT(onComboCompoIndexChanged(int)) );
39   QObject::connect(_ui.comboBoxMesh,           SIGNAL(activated(int)),
40                      this,                     SLOT(onComboMeshIndexChanged(int)) );
41   QObject::connect(_ui.comboBoxScalarBarRange, SIGNAL(activated(int)),
42                    this,                       SLOT(onComboScalarBarRangeIndexChanged(int)) );
43   QObject::connect(_ui.comboBoxColorMap,       SIGNAL(activated(int)),
44                    this,                       SLOT(onComboColorMapIndexChanged(int)) );
45   QObject::connect(_ui.comboBoxSliceOrient,    SIGNAL(activated(int)),
46                    this,                       SLOT(onComboOrientIndexChanged(int)) );
47   QObject::connect(_ui.comboBoxIntegrDir,      SIGNAL(activated(int)),
48                    this,                       SLOT(onComboIntegrDirIndexChanged(int)) );
49   QObject::connect(_ui.comboBoxContComp,       SIGNAL(activated(int)),
50                    this,                       SLOT(onComboContCompIndexChanged(int)) );
51   QObject::connect(_ui.spinBox,                SIGNAL(editingFinished()),
52                      this,                     SLOT(onSpinBoxEditingFinished()) );
53   QObject::connect(_ui.checkBoxShowScalarBar,  SIGNAL(stateChanged(int)),
54                      this,                     SLOT(onCheckboxScalarBarVisibilityChanged(int)));
55   QObject::connect(_ui.checkBoxCustomRange,    SIGNAL(stateChanged(int)),
56                      this,                     SLOT(onCheckboxCustomRangeChanged(int)));
57   QObject::connect(_ui.checkBoxScaleFactor,    SIGNAL(stateChanged(int)),
58                      this,                     SLOT(onCheckboxScaleFactorChanged(int)));
59   QObject::connect(_ui.checkBoxScaleFactor,    SIGNAL(stateChanged(int)),
60                      this,                     SLOT(onCheckboxCustomScaleFactorChanged(int)));
61   QObject::connect(_ui.spinCustomRangeMin,     SIGNAL(editingFinished()),
62                      this,                     SLOT(onSpinboxCustomRangeChanged()));
63   QObject::connect(_ui.spinCustomRangeMax,     SIGNAL(editingFinished()),
64                      this,                     SLOT(onSpinboxCustomRangeChanged()));
65   QObject::connect(_ui.spinScaleFactor,        SIGNAL(editingFinished()),
66                      this,                     SLOT(onSpinboxScaleFactorChanged()));
67   QObject::connect(_ui.checkBoxHideDataOutsideCR, SIGNAL(stateChanged(int)),
68                      this,                        SLOT(onCheckboxHideDataOutsideCustomRangeChanged(int)));
69   QObject::connect(_ui.spinNormalX,            SIGNAL(editingFinished()),
70                      this,                     SLOT(onSpinNormalEditingFinished()) );
71   QObject::connect(_ui.spinNormalY,            SIGNAL(editingFinished()),
72                      this,                     SLOT(onSpinNormalEditingFinished()) );
73   QObject::connect(_ui.spinNormalZ,            SIGNAL(editingFinished()),
74                      this,                     SLOT(onSpinNormalEditingFinished()) );
75   QObject::connect(_ui.spinPoint1_X,           SIGNAL(editingFinished()),
76                      this,                     SLOT(onSpinCutPoint1EditingFinished()) );
77   QObject::connect(_ui.spinPoint1_Y,           SIGNAL(editingFinished()),
78                      this,                     SLOT(onSpinCutPoint1EditingFinished()) );
79   QObject::connect(_ui.spinPoint1_Z,           SIGNAL(editingFinished()),
80                      this,                     SLOT(onSpinCutPoint1EditingFinished()) );
81   QObject::connect(_ui.spinPoint2_X,           SIGNAL(editingFinished()),
82                      this,                     SLOT(onSpinCutPoint2EditingFinished()) );
83   QObject::connect(_ui.spinPoint2_Y,           SIGNAL(editingFinished()),
84                      this,                     SLOT(onSpinCutPoint2EditingFinished()) );
85   QObject::connect(_ui.spinPoint2_Z,           SIGNAL(editingFinished()),
86                      this,                     SLOT(onSpinCutPoint2EditingFinished()) );
87   QObject::connect(_ui.spinPlanePos,           SIGNAL(editingFinished()),
88                      this,                     SLOT(onSpinPlanePosEditingFinished()) );
89
90    // Disable Custom Range Spin boxes
91   _ui.spinCustomRangeMax->setEnabled(false);
92   _ui.spinCustomRangeMin->setEnabled(false);
93   _ui.spinScaleFactor->setEnabled(false);
94   _ui.checkBoxHideDataOutsideCR->setEnabled(false);
95
96   // Min and max values
97   _ui.spinCustomRangeMin->setRange(std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max());
98   _ui.spinCustomRangeMax->setRange(std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max());
99   
100   _ui.spinCustomRangeMin->setDecimals(6);
101   _ui.spinCustomRangeMax->setDecimals(6);
102   
103   _ui.spinNormalX->setRange(0.0, 1.0);
104   _ui.spinNormalY->setRange(0.0, 1.0);
105   _ui.spinNormalZ->setRange(0.0, 1.0);
106   _ui.spinPlanePos->setRange(0.0, 1.0);
107 }
108
109 void
110 WidgetPresentationParameters::onComboCompoIndexChanged(int idx)
111 {
112   if (!_blockSig) emit comboCompoIndexChanged(idx);
113 }
114
115 void
116 WidgetPresentationParameters::onComboOrientIndexChanged(int idx)
117 {
118   if (!_blockSig) emit comboOrientIndexChanged(idx);
119 }
120
121
122 void
123 WidgetPresentationParameters::onComboMeshIndexChanged(int idx)
124 {
125   if (!_blockSig) emit comboMeshIndexChanged(idx);
126 }
127
128 void
129 WidgetPresentationParameters::onComboColorMapIndexChanged(int idx)
130 {
131   if (!_blockSig) emit comboColorMapIndexChanged(idx);
132 }
133
134 void
135 WidgetPresentationParameters::onComboScalarBarRangeIndexChanged(int idx)
136 {
137   if (!_blockSig) emit comboScalarBarRangeIndexChanged(idx);
138 }
139
140 void
141 WidgetPresentationParameters::onComboIntegrDirIndexChanged(int idx)
142 {
143   if (!_blockSig) emit comboIntegrDirIndexChanged(idx);
144 }
145
146 void
147 WidgetPresentationParameters::onComboContCompIndexChanged(int idx)
148 {
149   if (!_blockSig) emit comboContCompIndexChanged(idx);
150 }
151
152 void
153 WidgetPresentationParameters::onCheckboxScalarBarVisibilityChanged(int flag)
154 {
155   if (!_blockSig) emit checkboxScalarBarVisibilityChanged(flag);
156 }
157
158 void
159 WidgetPresentationParameters::onCheckboxCustomRangeChanged(int flag)
160 {
161   _ui.spinCustomRangeMin->setEnabled(flag);
162   _ui.spinCustomRangeMax->setEnabled(flag);
163   _ui.checkBoxHideDataOutsideCR->setEnabled(flag);
164   _ui.comboBoxScalarBarRange->setEnabled(!flag);
165   if (!_blockSig) emit checkboxCustomRangeChanged(flag);
166 }
167
168 void
169 WidgetPresentationParameters::onCheckboxScaleFactorChanged(int flag)
170 {
171   _ui.spinScaleFactor->setEnabled(flag);
172   if (!_blockSig) emit checkboxScaleFactorChanged(flag);
173 }
174
175 void
176 WidgetPresentationParameters::onSpinboxCustomRangeChanged()
177 {
178   if (!_blockSig) emit spinboxCustomRangeChanged(_ui.spinCustomRangeMin->value(),
179                                                  _ui.spinCustomRangeMax->value());
180 }
181
182 void
183 WidgetPresentationParameters::onSpinboxScaleFactorChanged()
184 {
185   if (!_blockSig) emit spinboxScaleFactorChaged(_ui.spinScaleFactor->value());
186 }
187
188 void
189 WidgetPresentationParameters::
190 onCheckboxHideDataOutsideCustomRangeChanged(int flag)
191 {
192   if (!_blockSig) emit checkboxHideDataOutsideCustomRangeChanged(flag);
193 }
194
195 void
196 WidgetPresentationParameters::
197 onCheckboxCustomScaleFactorChanged(int flag) {
198   if (!_blockSig) emit checkboxCustomScaleFactorChanged(flag);
199 }
200
201 void
202 WidgetPresentationParameters::onSpinBoxEditingFinished()
203 {
204   if (!_blockSig) emit spinBoxValueChanged(_ui.spinBox->value());
205 }
206
207 void
208 WidgetPresentationParameters::onSpinNormalEditingFinished()
209 {
210   if (!_blockSig) emit spinNormalValuesChanged(_ui.spinNormalX->value(),
211                                                _ui.spinNormalY->value(),
212                                                _ui.spinNormalZ->value());
213 }
214
215 void
216 WidgetPresentationParameters::onSpinCutPoint1EditingFinished()
217 {
218   if (!_blockSig) emit spinCutPoint1ValuesChanged(_ui.spinPoint1_X->value(),
219                                                   _ui.spinPoint1_Y->value(),
220                                                   _ui.spinPoint1_Z->value());
221 }
222
223 void
224 WidgetPresentationParameters::onSpinCutPoint2EditingFinished()
225 {
226   if (!_blockSig) emit spinCutPoint2ValuesChanged(_ui.spinPoint2_X->value(),
227                                                   _ui.spinPoint2_Y->value(),
228                                                   _ui.spinPoint2_Z->value());
229 }
230
231 void
232 WidgetPresentationParameters::onSpinPlanePosEditingFinished()
233 {
234   if (!_blockSig) emit spinPlanePosValueChanged(_ui.spinPlanePos->value());
235 }
236
237 void
238 WidgetPresentationParameters::hidePlot3D()
239 {
240   _ui.labelCutPlanePosition->hide();
241   _ui.spinPlanePos->hide();
242 }
243
244 void
245 WidgetPresentationParameters::hideContourComponent()
246 {
247   _ui.labelContourComp->hide();
248   _ui.comboBoxContComp->hide();
249 }
250
251 void
252 WidgetPresentationParameters::toggleCommonFieldWidget(bool show)
253 {
254   _blockSig = true;
255   _ui.commonWidget->setEnabled(show);
256   _blockSig = false;
257 }
258
259 void
260 WidgetPresentationParameters::toggleWidget(bool show)
261 {
262   toggleCommonFieldWidget(true);
263   if (!show)
264     {
265       _blockSig = true;
266       _ui.widgetDynamic->hide();
267       setPresName(tr("LAB_DEFAULT_DYN_TITLE").toStdString());
268       // reset colorMap and scalarBarRange:
269       setColorMap(MEDCALC::COLOR_MAP_DEFAULT);
270       setScalarBarRange(MEDCALC::SCALAR_BAR_RANGE_DEFAULT);
271     }
272   else
273     {
274       _ui.widgetDynamic->show();
275       // It is the WidgetHelper responsibility to re-show the widgets it needs
276       _ui.labelCompo->hide();
277       _ui.comboBoxCompo->hide();
278       _ui.labelMeshMode->hide();
279       _ui.comboBoxMesh->hide();
280       _ui.labelSpinBox->hide();
281       _ui.spinBox->hide();
282       _ui.labelSliceOrient->hide();
283       _ui.comboBoxSliceOrient->hide();
284       _ui.labelCutPlaneNormal->hide();
285       _ui.labelCutPlanePosition->hide();
286       _ui.spinNormalX->hide();
287       _ui.spinNormalY->hide();
288       _ui.spinNormalZ->hide();
289       _ui.spinPlanePos->hide();
290       _ui.labelIntegrDir->hide();
291       _ui.comboBoxIntegrDir->hide();
292       _ui.labelPoint1->hide();
293       _ui.spinPoint1_X->hide();
294       _ui.spinPoint1_Y->hide();
295       _ui.spinPoint1_Z->hide();
296       _ui.labelPoint2->hide();
297       _ui.spinPoint2_X->hide();
298       _ui.spinPoint2_Y->hide();
299       _ui.spinPoint2_Z->hide();
300       _ui.labelContourComp->hide();
301       _ui.comboBoxContComp->hide();
302       _ui.checkBoxScaleFactor->hide();
303       _ui.spinScaleFactor->hide();
304       _blockSig = false;
305     }
306 }
307
308 bool
309 WidgetPresentationParameters::isShown() const
310 {
311   return _ui.widgetDynamic->isVisible();
312 }
313
314 string
315 WidgetPresentationParameters::getComponent() const
316 {
317   if (_ui.comboBoxCompo->count() > 1 && _ui.comboBoxCompo->count() <= 4)
318     if (_ui.comboBoxCompo->currentIndex() == 0) // Euclidean norm
319       return "";
320
321   return _ui.comboBoxCompo->currentText().toStdString();
322 }
323
324 void
325 WidgetPresentationParameters::setComponents(vector<string> compos, int selecIndex)
326 {
327   _blockSig = true;
328
329   // Show the widget:
330   _ui.labelCompo->show();
331   _ui.comboBoxCompo->show();
332
333   _ui.comboBoxCompo->clear();
334   bool vectorField = (compos.size() > 1 && compos.size() <= 3);
335   if (vectorField)
336     _ui.comboBoxCompo->addItem(tr("LAB_EUCLIDEAN_NORM"));
337   for(vector<string>::const_iterator it = compos.begin(); it != compos.end(); ++it)
338     _ui.comboBoxCompo->addItem(QString::fromStdString(*it));
339   if (!vectorField)
340     _ui.comboBoxCompo->setCurrentIndex(std::max(0, selecIndex-1));
341   else
342     _ui.comboBoxCompo->setCurrentIndex(selecIndex);
343
344   _blockSig = false;
345 }
346
347 void
348 WidgetPresentationParameters::setNbContour(int nbContour)
349 {
350   _blockSig = true;
351
352   if (nbContour <= 0)
353     {
354       //TODO throw?
355       STDLOG("WidgetPresentationParameters::setNbContour(): invalid number of contours!");
356     }
357
358   // Show the widget:
359   _ui.labelSpinBox->setText(tr("LAB_NB_CONTOURS").arg(MEDCALC::NB_CONTOURS_MAX));
360
361   _ui.labelSpinBox->show();
362   _ui.spinBox->show();
363   _ui.spinBox->setRange(1, MEDCALC::NB_CONTOURS_MAX);
364   _ui.spinBox->setValue(nbContour);
365
366   _blockSig = false;
367 }
368
369 void
370 WidgetPresentationParameters::setNbSlices(int nbSlices)
371 {
372   _blockSig = true;
373
374   if (nbSlices <= 0)
375     {
376       //TODO throw?
377       STDLOG("WidgetPresentationParameters::setNbSlices(): invalid number of slices!");
378     }
379
380   // Show the widget:
381   _ui.labelSpinBox->setText(tr("LAB_NB_SLICES").arg(MEDCALC::NB_SLICES_MAX));
382   _ui.labelSpinBox->show();
383   _ui.spinBox->show();
384   _ui.spinBox->setRange(1, MEDCALC::NB_SLICES_MAX);
385   _ui.spinBox->setValue(nbSlices);
386
387   _blockSig = false;
388 }
389
390 int WidgetPresentationParameters::getNbContour() const
391 {
392   return _ui.spinBox->value();
393 }
394
395 int WidgetPresentationParameters::getNbSlices() const
396 {
397   return _ui.spinBox->value();
398 }
399
400
401 void
402 WidgetPresentationParameters::setScalarBarRange(MEDCALC::ScalarBarRangeType sbrange)
403 {
404   _blockSig = true;
405
406   int idx = -1;
407   if (sbrange == MEDCALC::SCALAR_BAR_ALL_TIMESTEPS)
408     idx = _ui.comboBoxScalarBarRange->findText(tr("LAB_ALL_TIMESTEPS"));
409   else if (sbrange == MEDCALC::SCALAR_BAR_CURRENT_TIMESTEP)
410     idx = _ui.comboBoxScalarBarRange->findText(tr("LAB_CURRENT_TIMESTEP"));
411
412   if (idx >= 0) {
413       _ui.comboBoxScalarBarRange->setCurrentIndex(idx);
414       _ui.checkBoxCustomRange->setChecked(false);
415   }
416   else {
417     if (sbrange == MEDCALC::SCALAR_BAR_CUSTOM_RANGE) {
418       _ui.checkBoxCustomRange->setChecked(true);
419     } else {
420       STDLOG("Strange!! No matching found - unable to set scalar bar range in GUI.");
421     }
422   }
423   _blockSig = false;
424 }
425
426 void
427 WidgetPresentationParameters::setColorMap(MEDCALC::ColorMapType colorMap)
428 {
429   _blockSig = true;
430
431   int idx = -1;
432   if (colorMap == MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW)
433     idx = _ui.comboBoxColorMap->findText(tr("LAB_BLUE_TO_RED"));
434   else if (colorMap == MEDCALC::COLOR_MAP_COOL_TO_WARM)
435     idx = _ui.comboBoxColorMap->findText(tr("LAB_COOL_TO_WARM"));
436
437   if (idx >= 0)
438   {
439     _ui.comboBoxColorMap->setCurrentIndex(idx);
440   }
441   else
442   {
443     STDLOG("Strange!! No matching found - unable to set color map in GUI.");
444   }
445
446   _blockSig = false;
447 }
448
449 void
450 WidgetPresentationParameters::setMeshMode(MEDCALC::MeshModeType mode)
451 {
452   _blockSig = true;
453
454   // Show the widget:
455   _ui.labelMeshMode->show();
456   _ui.comboBoxMesh->show();
457
458   int idx;
459   switch(mode)
460   {
461     case MEDCALC::MESH_MODE_WIREFRAME:
462       idx = _ui.comboBoxMesh->findText(tr("LAB_MESH_WIREFRAME"));
463       break;
464     case MEDCALC::MESH_MODE_SURFACE:
465       idx = _ui.comboBoxMesh->findText(tr("LAB_MESH_SURFACE"));
466       break;
467     case MEDCALC::MESH_MODE_SURFACE_EDGES:
468       idx = _ui.comboBoxMesh->findText(tr("LAB_MESH_SURF_EDGES"));
469       break;
470     default:
471       idx = -1;
472   }
473   if (idx >= 0)
474   {
475     _ui.comboBoxMesh->setCurrentIndex(idx);
476   }
477   else
478   {
479     STDLOG("Strange!! No matching found - unable to set mesh mode in GUI.");
480   }
481
482   _blockSig = false;
483 }
484
485 void
486 WidgetPresentationParameters::setIntegrationDir(MEDCALC::IntegrationDirType iDir)
487 {
488   _blockSig = true;
489
490   // Show the widget;
491   _ui.labelIntegrDir->show();
492   _ui.comboBoxIntegrDir->show();
493
494   int idx;
495   switch(iDir)
496   {
497     case MEDCALC::INTEGRATION_DIR_BOTH:
498       idx = _ui.comboBoxIntegrDir->findText(tr("LAB_INTEGR_DIR_BOTH"));
499       break;
500     case MEDCALC::INTEGRATION_DIR_FORWARD:
501       idx = _ui.comboBoxIntegrDir->findText(tr("LAB_INTEGR_DIR_FORWARD"));
502       break;
503     case MEDCALC::INTEGRATION_DIR_BACKWARD:
504       idx = _ui.comboBoxIntegrDir->findText(tr("LAB_INTEGR_DIR_BACKWARD"));
505       break;
506     default:
507       idx = -1;
508   }
509   if (idx >= 0)
510   {
511     _ui.comboBoxIntegrDir->setCurrentIndex(idx);
512   }
513   else
514   {
515     STDLOG("Strange!! No matching found - unable to set integration direction in GUI.");
516   }
517
518   _blockSig = false;
519 }
520
521 void
522 WidgetPresentationParameters::setContourComponents(std::vector<std::string> compos, int selecIndex)
523 {
524   _blockSig = true;
525
526   // Show the widget;
527   _ui.labelContourComp->show();
528   _ui.comboBoxContComp->show();
529
530   _ui.comboBoxContComp->clear();
531   bool vectorField = (compos.size() > 1 && compos.size() <= 3);
532   if (vectorField)
533     _ui.comboBoxContComp->addItem(tr("LAB_EUCLIDEAN_NORM"));
534   for (vector<string>::const_iterator it = compos.begin(); it != compos.end(); ++it)
535     _ui.comboBoxContComp->addItem(QString::fromStdString(*it));
536   if (!vectorField)
537     _ui.comboBoxContComp->setCurrentIndex(std::max(0, selecIndex - 1));
538   else
539     _ui.comboBoxContComp->setCurrentIndex(selecIndex);
540
541   _blockSig = false;
542 }
543
544 void
545 WidgetPresentationParameters::setSliceOrientation(MEDCALC::SliceOrientationType orient)
546 {
547   _blockSig = true;
548
549   // Show the widget:
550   _ui.labelSliceOrient->show();
551   _ui.comboBoxSliceOrient->show();
552
553   int idx;
554   switch(orient)
555   {
556     case MEDCALC::SLICE_NORMAL_TO_X:
557       idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_X"));
558       break;
559     case MEDCALC::SLICE_NORMAL_TO_Y:
560       idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_Y"));
561       break;
562     case MEDCALC::SLICE_NORMAL_TO_Z:
563       idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_Z"));
564       break;
565     case MEDCALC::SLICE_NORMAL_TO_XY:
566       idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_XY"));
567       break;
568     case MEDCALC::SLICE_NORMAL_TO_XZ:
569       idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_XZ"));
570       break;
571     case MEDCALC::SLICE_NORMAL_TO_YZ:
572       idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_YZ"));
573       break;
574     case MEDCALC::SLICE_NORMAL_TO_XYZ:
575       idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_XYZ"));
576       break;
577     default:
578       idx = -1;
579   }
580   if (idx >= 0)
581   {
582     _ui.comboBoxSliceOrient->setCurrentIndex(idx);
583   }
584   else
585   {
586     STDLOG("Strange!! No matching found - unable to set slice orientation in GUI.");
587   }
588
589   _blockSig = false;
590 }
591
592
593 MEDCALC::SliceOrientationType
594 WidgetPresentationParameters::getSliceOrientation() const
595 {
596   QString sbrange = _ui.comboBoxSliceOrient->currentText();
597   if (sbrange == tr("LAB_SLICE_NORMAL_TO_X")) {
598       return MEDCALC::SLICE_NORMAL_TO_X;
599   }
600   else if (sbrange == tr("LAB_SLICE_NORMAL_TO_Y")) {
601       return MEDCALC::SLICE_NORMAL_TO_Y;
602   }
603   else if (sbrange == tr("LAB_SLICE_NORMAL_TO_Z")) {
604       return MEDCALC::SLICE_NORMAL_TO_Z;
605   }
606   else if (sbrange == tr("LAB_SLICE_NORMAL_TO_XY")) {
607       return MEDCALC::SLICE_NORMAL_TO_XY;
608   }
609   else if (sbrange == tr("LAB_SLICE_NORMAL_TO_XZ")) {
610       return MEDCALC::SLICE_NORMAL_TO_XZ;
611   }
612   else if (sbrange == tr("LAB_SLICE_NORMAL_TO_YZ")) {
613       return MEDCALC::SLICE_NORMAL_TO_YZ;
614   }
615   else if (sbrange == tr("LAB_SLICE_NORMAL_TO_XYZ")) {
616       return MEDCALC::SLICE_NORMAL_TO_XYZ;
617   }
618   // Should not happen
619   STDLOG("Strange!! No matching found - returning SLICE_NORMAL_TO_X.");
620   return MEDCALC::SLICE_NORMAL_TO_X;
621 }
622
623 MEDCALC::MeshModeType
624 WidgetPresentationParameters::getMeshMode() const
625 {
626   QString mesm = _ui.comboBoxMesh->currentText();
627   if (mesm == tr("LAB_MESH_WIREFRAME")) {
628       return MEDCALC::MESH_MODE_WIREFRAME;
629   }
630   else if (mesm == tr("LAB_MESH_SURFACE")) {
631       return MEDCALC::MESH_MODE_SURFACE;
632   }
633   else if (mesm == tr("LAB_MESH_SURF_EDGES")) {
634       return MEDCALC::MESH_MODE_SURFACE_EDGES;
635   }
636   // Should not happen
637   STDLOG("Strange!! No matching found - returning MESH_MODE_WIREFRAME.");
638   return MEDCALC::MESH_MODE_WIREFRAME;
639 }
640
641 MEDCALC::IntegrationDirType 
642 WidgetPresentationParameters::getIntegrationDir() const
643 {
644   QString iDir = _ui.comboBoxIntegrDir->currentText();
645   if (iDir == tr("LAB_INTEGR_DIR_BOTH")) {
646       return MEDCALC::INTEGRATION_DIR_BOTH;
647   }
648   else if (iDir == tr("LAB_INTEGR_DIR_FORWARD")) {
649       return MEDCALC::INTEGRATION_DIR_FORWARD;
650   }
651   else if (iDir == tr("LAB_INTEGR_DIR_BACKWARD")) {
652       return MEDCALC::INTEGRATION_DIR_BACKWARD;
653   }
654   // Should not happen
655   STDLOG("Strange!! No matching found - returning LAB_INTEGR_DIR_BOTH.");
656   return MEDCALC::INTEGRATION_DIR_BOTH;
657 }
658
659 std::string 
660 WidgetPresentationParameters::getContourComponent() const
661 {
662   if (_ui.comboBoxContComp->count() > 1 && _ui.comboBoxContComp->count() <= 4)
663     if (_ui.comboBoxContComp->currentIndex() == 0) // Euclidean norm
664       return "";
665   return _ui.comboBoxContComp->currentText().toStdString();
666 }
667
668 MEDCALC::ScalarBarRangeType
669 WidgetPresentationParameters::getScalarBarRange() const
670 {
671   if (_ui.checkBoxCustomRange->isChecked()) {
672     return  MEDCALC::SCALAR_BAR_CUSTOM_RANGE;
673   }
674   QString sbrange = _ui.comboBoxScalarBarRange->currentText();
675   if (sbrange == tr("LAB_ALL_TIMESTEPS")) {
676     return MEDCALC::SCALAR_BAR_ALL_TIMESTEPS;
677   }
678   else if (sbrange == tr("LAB_CURRENT_TIMESTEP")) {
679     return MEDCALC::SCALAR_BAR_CURRENT_TIMESTEP;
680   }
681   // Should not happen
682   STDLOG("Strange!! No matching found - returning SCALAR_BAR_ALL_TIMESTEPS.");
683   return MEDCALC::SCALAR_BAR_ALL_TIMESTEPS;
684 }
685
686 //double
687 //WidgetPresentationParameters::getScalarBarTimestep() const
688 //{
689 //  return _ui.doubleSpinBoxTimeStep->value();
690 //}
691 //
692 //double
693 //WidgetPresentationParameters::getScalarBarMinVal() const
694 //{
695 //  return _ui.doubleSpinBoxMinVal->value();
696 //}
697 //
698 //double
699 //WidgetPresentationParameters::getScalarBarMaxVal() const
700 //{
701 //  return _ui.doubleSpinBoxMaxVal->value();
702 //}
703
704 MEDCALC::ColorMapType
705 WidgetPresentationParameters::getColorMap() const
706 {
707   QString colorMap = _ui.comboBoxColorMap->currentText();
708   if (colorMap == tr("LAB_BLUE_TO_RED")) {
709     return MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW;
710   }
711   else if (colorMap == tr("LAB_COOL_TO_WARM")) {
712     return MEDCALC::COLOR_MAP_COOL_TO_WARM;
713   }
714   // Should not happen
715   STDLOG("Strange!! No matching color map found - returning blue to red.");
716   return MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW;
717 }
718
719 void
720 WidgetPresentationParameters::setPresName(const std::string& name)
721 {
722   _ui.labelPresName->setText(QString::fromStdString(name));
723   QFont f(_ui.labelPresName->font());
724   f.setItalic(true);
725   _ui.labelPresName->setFont(f);
726 }
727
728
729 void 
730 WidgetPresentationParameters::getScalarBarRangeValue(double* arr) const 
731 {
732   arr[0] = _ui.spinCustomRangeMin->value();
733   arr[1] = _ui.spinCustomRangeMax->value();
734 }
735
736 void WidgetPresentationParameters::setScalarBarRangeValue(double aMin, double aMax) {
737   _blockSig = true;
738   _ui.spinCustomRangeMin->setValue(aMin);
739   _ui.spinCustomRangeMax->setValue(aMax);
740   _blockSig = false;
741 }
742
743 void WidgetPresentationParameters::setScaleFactor(double scale) {
744   _blockSig = true;
745
746   // Show widget:
747   _ui.checkBoxScaleFactor->show();
748   _ui.spinScaleFactor->show();
749
750   _ui.spinScaleFactor->setValue(scale);
751   _blockSig = false;
752 }
753
754 void WidgetPresentationParameters::getNormal(double* arr) const
755 {
756   arr[0] = _ui.spinNormalX->value();
757   arr[1] = _ui.spinNormalY->value();
758   arr[2] = _ui.spinNormalZ->value();
759 }
760
761 void
762 WidgetPresentationParameters::setNormal(const double normX, const double normY, const double normZ)
763 {
764   _blockSig = true;
765   _ui.labelCutPlaneNormal->show();
766   _ui.spinNormalX->show();
767   _ui.spinNormalY->show();
768   _ui.spinNormalZ->show();
769   _ui.spinNormalX->setValue(normX);
770   _ui.spinNormalY->setValue(normY);
771   _ui.spinNormalZ->setValue(normZ);
772   _blockSig = false;
773 }
774
775 void WidgetPresentationParameters::getCutPoint1(double* arr) const
776 {
777   arr[0] = _ui.spinPoint1_X->value();
778   arr[1] = _ui.spinPoint1_Y->value();
779   arr[2] = _ui.spinPoint1_Z->value();
780 }
781
782 void
783 WidgetPresentationParameters::setCutPoint1(const double x, const double y, const double z)
784 {
785   _blockSig = true;
786   _ui.labelPoint1->show();
787   _ui.spinPoint1_X->show();
788   _ui.spinPoint1_Y->show();
789   _ui.spinPoint1_Z->show();
790   _ui.spinPoint1_X->setValue(x);
791   _ui.spinPoint1_Y->setValue(y);
792   _ui.spinPoint1_Z->setValue(z);
793   _blockSig = false;
794 }
795
796 void WidgetPresentationParameters::getCutPoint2(double* arr) const
797 {
798   arr[0] = _ui.spinPoint2_X->value();
799   arr[1] = _ui.spinPoint2_Y->value();
800   arr[2] = _ui.spinPoint2_Z->value();
801 }
802
803 void
804 WidgetPresentationParameters::setCutPoint2(const double x, const double y, const double z)
805 {
806   _blockSig = true;
807   _ui.labelPoint2->show();
808   _ui.spinPoint2_X->show();
809   _ui.spinPoint2_Y->show();
810   _ui.spinPoint2_Z->show();
811   _ui.spinPoint2_X->setValue(x);
812   _ui.spinPoint2_Y->setValue(y);
813   _ui.spinPoint2_Z->setValue(z);
814   _blockSig = false;
815 }
816
817 double WidgetPresentationParameters::getPlanePosition() const
818 {
819   return _ui.spinPlanePos->value();
820 }
821
822 void WidgetPresentationParameters::setPlanePosition(double pos)
823 {
824   _blockSig = true;
825   _ui.labelCutPlanePosition->show();
826   _ui.spinPlanePos->show();
827   _ui.spinPlanePos->setValue(pos);
828   _blockSig = false;
829 }
830
831 bool WidgetPresentationParameters::getScalarBarVisibility() const {
832   return _ui.checkBoxShowScalarBar->isChecked();
833 }
834
835 void WidgetPresentationParameters::setScalarBarVisibility(const bool visibility) {
836   _blockSig = true;
837   _ui.checkBoxShowScalarBar->setChecked(visibility);
838   _blockSig = false;
839 }
840
841 bool WidgetPresentationParameters::getHideDataOutsideCustomRange() const {
842   return _ui.checkBoxHideDataOutsideCR->isChecked();
843 }
844
845 void WidgetPresentationParameters::setHideDataOutsideCustomRange(const bool flag) {
846   _blockSig = true;
847   _ui.checkBoxHideDataOutsideCR->setChecked(flag);
848   _blockSig = false;
849 }
850
851 void WidgetPresentationParameters::setScaleFactorFlag(const bool flag) {
852   _blockSig = true;
853   _ui.checkBoxScaleFactor->setChecked(flag);
854   _blockSig = false;
855 }