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