Salome HOME
NRI : Correction 1.1a version.
[modules/visu.git] / src / VISUGUI / VisuGUI_ScalarBarDlg.cxx
1 using namespace std;
2 //  File      : VisuGUI_ScalarBarDlg.cxx
3 //  Created   : Wed Aug 01 10:23:06 2001
4 //  Author    : Laurent CORNABE & Hubert ROLLAND 
5 //  Project   : SALOME
6 //  Module    : VISUGUI
7 //  Copyright : PRINCIPIA
8 //  $Header$
9
10 #include "VisuGUI_ScalarBarDlg.h"
11 #include <qlayout.h>
12 #include "QAD_Application.h"
13 #include "QAD_Desktop.h"
14 #include "QAD_Config.h"
15 #include "VISU_Convertor.hxx"
16
17
18 static double MAXVALUE = 1.0E+300;
19 /*!
20   Constructor
21 */
22 VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg(bool SetPref)
23     : QDialog( QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
24 {
25   setName( "VisuGUI_ScalarBarDlg" );
26   setCaption( SetPref ? tr( "Scalar Bar Preferences" ) : tr( "Scalar Bar Properties" ) );
27   setSizeGripEnabled( TRUE );
28   
29   myVerX = 0.01;  myVerY = 0.10;  myVerW = 0.10;  myVerH = 0.80;
30   myHorX = 0.20;  myHorY = 0.01;  myHorW = 0.60;  myHorH = 0.12;
31   
32   QVBoxLayout* TopLayout = new QVBoxLayout( this ); 
33   TopLayout->setSpacing( 6 );
34   TopLayout->setMargin( 11 );
35
36   // Range ============================================================
37   QButtonGroup* RangeGroup = new QButtonGroup( tr( "Scalar range" ), this, "RangeGroup" );
38   RangeGroup->setColumnLayout(0, Qt::Vertical );
39   RangeGroup->layout()->setSpacing( 0 );
40   RangeGroup->layout()->setMargin( 0 );
41   QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() );
42   RangeGroupLayout->setAlignment( Qt::AlignTop );
43   RangeGroupLayout->setSpacing( 6 );
44   RangeGroupLayout->setMargin( 11 );
45   
46   myModeLbl = new QLabel("Scalar Mode", RangeGroup);
47   
48   myModeCombo = new QComboBox(RangeGroup);
49   myModeCombo->insertItem("Modulus");
50   myModeCombo->insertItem("Component 1");
51   myModeCombo->insertItem("Component 2");
52   myModeCombo->insertItem("Component 3");
53
54   CBLog = new QCheckBox( tr( "Logarithmic scaling" ), RangeGroup );
55   CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
56   
57   RBFrange = new QRadioButton( tr( "Use field range" ), RangeGroup, "RBFrange" );
58   RBIrange = new QRadioButton( tr( "Use imposed range" ), RangeGroup, "RBIrange" );
59   RBIrange->setChecked( true );
60
61   MinSpin = new QAD_SpinBoxDbl( RangeGroup, -MAXVALUE, MAXVALUE, 0.1 );
62   MinSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
63   MinSpin->setMinimumWidth( 70 );
64   MinSpin->setValue( 0 );
65   QLabel* MinLabel = new QLabel( tr( "Min:" ), RangeGroup, "MinLabel" );
66   MinLabel->setBuddy(MinSpin);
67
68   MaxSpin = new QAD_SpinBoxDbl( RangeGroup, -MAXVALUE, MAXVALUE, 0.1 );
69   MaxSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
70   MaxSpin->setMinimumWidth( 70 );
71   MaxSpin->setValue( 0 );
72   QLabel* MaxLabel = new QLabel( tr( "Max:" ), RangeGroup, "MaxLabel" );
73   MaxLabel->setBuddy(MaxSpin);
74
75   RangeGroupLayout->addWidget( myModeLbl, 0, 0 );
76   RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3);
77   RangeGroupLayout->addMultiCellWidget( CBLog, 1, 1, 0, 3);
78   RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1);
79   RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3);
80   RangeGroupLayout->addWidget( MinLabel, 3, 0 );
81   RangeGroupLayout->addWidget( MinSpin,  3, 1 );
82   RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
83   RangeGroupLayout->addWidget( MaxSpin,  3, 3 );
84
85   TopLayout->addWidget( RangeGroup );
86
87   // Colors and Labels ========================================================
88   QGroupBox* ColLabGroup = new QGroupBox( tr( "Colors and labels" ), this, "ColLabGroup" );
89   ColLabGroup->setColumnLayout(0, Qt::Vertical );
90   ColLabGroup->layout()->setSpacing( 0 );
91   ColLabGroup->layout()->setMargin( 0 );
92   QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() );
93   ColLabGroupLayout->setAlignment( Qt::AlignTop );
94   ColLabGroupLayout->setSpacing( 6 );
95   ColLabGroupLayout->setMargin( 11 );
96
97   QLabel* ColorLabel = new QLabel( tr( "Nb. of colors:" ), ColLabGroup, "ColorLabel" );
98   ColorSpin = new QSpinBox( 2, 64, 1, ColLabGroup );
99   ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
100   ColorSpin->setMinimumWidth( 70 );
101   ColorSpin->setValue( 64 );
102
103   QLabel* LabelLabel = new QLabel( tr( "Nb. of labels:" ), ColLabGroup, "LabelLabel" );
104   LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup );
105   LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
106   LabelSpin->setMinimumWidth( 70 );
107   LabelSpin->setValue( 5 );
108   
109   ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
110   ColLabGroupLayout->addWidget( ColorSpin,  0, 1);
111   ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
112   ColLabGroupLayout->addWidget( LabelSpin,  0, 3);
113
114   TopLayout->addWidget( ColLabGroup );
115
116   // Orientation ==========================================================
117   QButtonGroup* OrientGroup = new QButtonGroup( tr( "Orientation" ), this, "OrientGroup" );
118   OrientGroup->setColumnLayout(0, Qt::Vertical );
119   OrientGroup->layout()->setSpacing( 0 );
120   OrientGroup->layout()->setMargin( 0 );
121   QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() );
122   OrientGroupLayout->setAlignment( Qt::AlignTop );
123   OrientGroupLayout->setSpacing( 6 );
124   OrientGroupLayout->setMargin( 11 );
125
126   RBvert = new QRadioButton( tr( "Vertical" ), OrientGroup, "RBvert" );
127   RBvert->setChecked( true );
128   RBhori = new QRadioButton( tr( "Horizontal" ), OrientGroup, "RBhori" );
129   OrientGroupLayout->addWidget( RBvert, 0, 0 );
130   OrientGroupLayout->addWidget( RBhori, 0, 1 );
131   
132   TopLayout->addWidget( OrientGroup );
133
134   // Origin ===============================================================
135   QGroupBox* OriginGroup = new QGroupBox( tr( "Origin" ), this, "OriginGroup" );
136   OriginGroup->setColumnLayout(0, Qt::Vertical );
137   OriginGroup->layout()->setSpacing( 0 );
138   OriginGroup->layout()->setMargin( 0 );
139   QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() );
140   OriginGroupLayout->setAlignment( Qt::AlignTop );
141   OriginGroupLayout->setSpacing( 6 );
142   OriginGroupLayout->setMargin( 11 );
143
144   QLabel* XLabel = new QLabel( tr( "X:" ), OriginGroup, "XLabel" );
145   XSpin = new QAD_SpinBoxDbl( OriginGroup, 0.0, 1.0, 0.1 );
146   XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
147   XSpin->setMinimumWidth( 70 );
148   XSpin->setValue( 0.01 );
149
150   QLabel* YLabel = new QLabel( tr( "Y:" ), OriginGroup, "YLabel" );
151   YSpin = new QAD_SpinBoxDbl( OriginGroup, 0.0, 1.0, 0.1 );
152   YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
153   YSpin->setMinimumWidth( 70 );
154   YSpin->setValue( 0.01 );
155   
156   OriginGroupLayout->addWidget( XLabel, 0, 0);
157   OriginGroupLayout->addWidget( XSpin,  0, 1);
158   OriginGroupLayout->addWidget( YLabel, 0, 2);
159   OriginGroupLayout->addWidget( YSpin,  0, 3);
160
161   TopLayout->addWidget( OriginGroup );
162
163   // Dimensions =========================================================
164   QGroupBox* DimGroup = new QGroupBox( tr( "Dimensions" ), this, "DimGroup" );
165   DimGroup->setColumnLayout(0, Qt::Vertical );
166   DimGroup->layout()->setSpacing( 0 );
167   DimGroup->layout()->setMargin( 0 );
168   QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() );
169   DimGroupLayout->setAlignment( Qt::AlignTop );
170   DimGroupLayout->setSpacing( 6 );
171   DimGroupLayout->setMargin( 11 );
172
173   QLabel* WidthLabel = new QLabel( tr( "Width:" ), DimGroup, "WidthLabel" );
174   WidthSpin = new QAD_SpinBoxDbl( DimGroup, 0.0, 1.0, 0.1 );
175   WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
176   WidthSpin->setMinimumWidth( 70 );
177   WidthSpin->setValue( 0.1 );
178
179   QLabel* HeightLabel = new QLabel( tr( "Height:" ), DimGroup, "HeightLabel" );
180   HeightSpin = new QAD_SpinBoxDbl( DimGroup, 0.0, 1.0, 0.1 );
181   HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
182   HeightSpin->setMinimumWidth( 70 );
183   HeightSpin->setValue( 0.8 );
184   
185   DimGroupLayout->addWidget( WidthLabel, 0, 0);
186   DimGroupLayout->addWidget( WidthSpin,  0, 1);
187   DimGroupLayout->addWidget( HeightLabel, 0, 2);
188   DimGroupLayout->addWidget( HeightSpin,  0, 3);
189
190   TopLayout->addWidget( DimGroup );
191
192   // Save check box ===========================================================
193   if ( !SetPref ) {
194     CBSave = new QCheckBox( tr( "Save as default values" ), this, "CBSave" );
195     TopLayout->addWidget( CBSave );
196   }
197   else {
198     CBSave = 0;
199   }
200
201   // Common buttons ===========================================================
202   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
203   GroupButtons->setColumnLayout(0, Qt::Vertical );
204   GroupButtons->layout()->setSpacing( 0 );
205   GroupButtons->layout()->setMargin( 0 );
206   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
207   GroupButtonsLayout->setAlignment( Qt::AlignTop );
208   GroupButtonsLayout->setSpacing( 6 );
209   GroupButtonsLayout->setMargin( 11 );
210
211   QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
212   buttonOk->setAutoDefault( TRUE );
213   buttonOk->setDefault( TRUE );
214   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
215   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
216
217   QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
218   buttonCancel->setAutoDefault( TRUE );
219   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
220
221   TopLayout->addWidget( GroupButtons );
222
223   // signals and slots connections ===========================================
224   connect( RangeGroup,   SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) );
225   connect( OrientGroup,  SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) );
226   connect( XSpin,        SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
227   connect( YSpin,        SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
228   connect( buttonOk,     SIGNAL( clicked() ),      this, SLOT( accept() ) );
229   connect( buttonCancel, SIGNAL( clicked() ),      this, SLOT( reject() ) );
230
231   changeRange( 0 );
232   changeDefaults( 0 );
233 }
234
235 /*!
236   Destructor
237 */
238 VisuGUI_ScalarBarDlg::~VisuGUI_ScalarBarDlg()
239 {
240 }
241
242
243 /**
244  * Initializes dialog box values from resources
245  */
246 void VisuGUI_ScalarBarDlg::initFromResources() {
247   int sbCol=64,sbLab=5,orient=1;
248   float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8;
249   float sbVmin=0., sbVmax=0.;
250   bool sbRange=false;
251   
252   QString Orientation = QAD_CONFIG->getSetting("Visu:SBOrientation");
253   if ( !Orientation.isEmpty() ) {
254     orient = Orientation.toInt();
255     if(orient != 1) {
256       orient=0;
257       sbX1=0.2;
258       sbY1=0.01;
259       sbW=0.6;
260       sbH=0.12;
261     }
262   }
263
264   QString SBXorigin = QAD_CONFIG->getSetting("Visu:SBXorigin");
265   if ( !SBXorigin.isEmpty() )
266     sbX1 = SBXorigin.toFloat();
267   
268   QString SBYorigin = QAD_CONFIG->getSetting("Visu:SBYorigin");
269   if ( !SBYorigin.isEmpty() )
270     sbY1 = SBYorigin.toFloat();
271   
272   QString SBWidth = QAD_CONFIG->getSetting("Visu:SBWidth");
273   if ( !SBWidth.isEmpty() )
274     sbW = SBWidth.toFloat();
275   
276   QString SBHeight = QAD_CONFIG->getSetting("Visu:SBHeight");
277   if ( !SBHeight.isEmpty() )
278     sbH = SBHeight.toFloat();
279   
280   QString SBColors = QAD_CONFIG->getSetting("Visu:SBNumberOfColors");
281   if ( !SBColors.isEmpty() )
282     sbCol = SBColors.toInt();
283   
284   QString SBLabels = QAD_CONFIG->getSetting("Visu:SBNumberOfLabels");
285   if ( !SBLabels.isEmpty() )
286     sbLab = SBLabels.toInt();
287   
288   QString ImpRange = QAD_CONFIG->getSetting("Visu:SBImposeRange");
289   if ( ImpRange.compare("true") == 0 )
290     sbRange=true;
291   
292   QString SBVmin = QAD_CONFIG->getSetting("Visu:SBMinimumValue");
293   if ( !SBVmin.isEmpty() )
294     sbVmin = SBVmin.toFloat();
295   
296   QString SBVmax = QAD_CONFIG->getSetting("Visu:SBMaximumValue");
297   if ( !SBVmax.isEmpty() )
298     sbVmax = SBVmax.toFloat();
299   
300   QString aScaling = QAD_CONFIG->getSetting("Visu:SBScaling");
301   if(aScaling.compare("LOGARITHMIC") == 0) 
302     setLogarithmic(true);
303   else 
304     setLogarithmic(false);
305
306   if((sbX1 < 0.) || (sbY1 < 0.) || 
307      ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
308     if(orient == 1) {
309       sbX1=0.01;
310       sbY1=0.1;
311       sbW=0.1;
312       sbH=0.8;
313     } else {
314       sbX1=0.2;
315       sbY1=0.01;
316       sbW=0.6;
317       sbH=0.12;
318     }
319   }
320   if(sbCol < 2) sbCol=2;
321   if(sbCol > 64) sbCol=64;
322   if(sbLab < 2) sbLab=2;
323   if(sbLab > 65) sbLab=65;
324
325   if(sbVmin > sbVmax) {
326     sbVmin=0.;
327     sbVmax=0.;
328   }
329   
330   setRange( sbVmin, sbVmax, 0.0, 0.0, sbRange );
331   setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 1);
332   setScalarBarData( sbCol, sbLab );
333 }
334
335
336
337 /**
338  * Stores dialog values to resources
339  */
340 void VisuGUI_ScalarBarDlg::storeToResources() {
341   int orient = (RBvert->isChecked())? 1 : 0;
342   float sbX1   = XSpin->value();
343   float sbY1   = YSpin->value();
344   float sbW    = WidthSpin->value();
345   float sbH    = HeightSpin->value();
346   int sbCol  = ColorSpin->value();
347   int sbLab  = LabelSpin->value();
348   
349   if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
350     if(orient == 1) {
351       sbX1=0.01;
352       sbY1=0.1;
353       sbW=0.17;
354       sbH=0.8;
355     } else {
356       sbX1=0.2;
357       sbY1=0.01;
358       sbW=0.6;
359       sbH=0.12;
360     }
361   }
362   
363   bool sbRange = RBIrange->isChecked();
364   float sbVmin = MinSpin->value();
365   float sbVmax = MaxSpin->value();
366   
367   if(sbVmin > sbVmax) {
368     sbVmin=0.;
369     sbVmax=0.;
370   }
371   
372   QAD_CONFIG->addSetting("Visu:SBOrientation",orient);
373   QAD_CONFIG->addSetting("Visu:SBXorigin",sbX1);
374   QAD_CONFIG->addSetting("Visu:SBYorigin",sbY1);
375   QAD_CONFIG->addSetting("Visu:SBWidth",sbW);
376   QAD_CONFIG->addSetting("Visu:SBHeight",sbH);
377   QAD_CONFIG->addSetting("Visu:SBNumberOfColors",sbCol);
378   QAD_CONFIG->addSetting("Visu:SBNumberOfLabels",sbLab);
379   if(sbRange)
380     QAD_CONFIG->addSetting("Visu:SBImposeRange", "true");
381   else
382     QAD_CONFIG->addSetting("Visu:SBImposeRange", "false");
383   QAD_CONFIG->addSetting("Visu:SBMinimumValue",sbVmin);
384   QAD_CONFIG->addSetting("Visu:SBMaximumValue",sbVmax);
385   if(isLogarithmic())
386     QAD_CONFIG->addSetting("Visu:SBScaling", "LOGARITHMIC");
387   else
388     QAD_CONFIG->addSetting("Visu:SBScaling", "LINEAR");
389 }
390
391
392 /**
393  * Initialise dialog box from presentation object
394  */
395 void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
396   myModeCombo->setCurrentItem(thePrs->GetScalarMode());
397   setPosAndSize( thePrs->GetPosX(), 
398                  thePrs->GetPosY(), 
399                  thePrs->GetWidth(), 
400                  thePrs->GetHeight(), 
401                  thePrs->GetOrientation());
402   switch(thePrs->GetScaling()){
403   case VISU::LOGARITHMIC : 
404     setLogarithmic(true);
405     break;
406   default:  
407     setLogarithmic(false);
408   }
409   setRange( thePrs->GetMin(), thePrs->GetMax(), 
410             0.0, 0.0, thePrs->isRangeFixed() );
411   setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
412   bool isScalarMode = (thePrs->GetField()->myNbComp > 1);
413   myModeLbl->setEnabled(isScalarMode);
414   myModeCombo->setEnabled(isScalarMode);
415 }
416
417
418 /**
419  * Store values to presentation object
420  */
421 void VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ScalarMap_i* thePrs) {
422   thePrs->SetScalarMode(myModeCombo->currentItem());
423   thePrs->SetPosition(XSpin->value(), YSpin->value());
424   thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
425   thePrs->SetOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
426   if(isLogarithmic()) 
427     thePrs->SetScaling(VISU::LOGARITHMIC); 
428   else
429     thePrs->SetScaling(VISU::LINEAR);
430   if (RBFrange->isChecked()) {
431     thePrs->CalculateRange();
432   } else {
433     thePrs->SetRange(MinSpin->value(), MaxSpin->value());
434   }    
435   thePrs->SetNbColors(ColorSpin->value());
436   thePrs->SetLabels(LabelSpin->value());
437   thePrs->Update();
438
439   if (isToSave()) storeToResources();
440 }
441
442
443
444 /*!
445   Called when orientation is changed
446 */
447 void VisuGUI_ScalarBarDlg::changeDefaults( int )
448 {
449   if ( RBvert->isChecked() ) {
450     XSpin->setValue( myVerX );
451     YSpin->setValue( myVerY );
452     WidthSpin->setValue( myVerW );
453     HeightSpin->setValue( myVerH );
454   }
455   else {
456     XSpin->setValue( myHorX );
457     YSpin->setValue( myHorY );
458     WidthSpin->setValue( myHorW );
459     HeightSpin->setValue( myHorH );
460   }
461 }
462
463 /*!
464   Called when Range mode is changed
465 */
466 void VisuGUI_ScalarBarDlg::changeRange( int )
467 {
468   //MinSpin->setMaxValue( Fmin );
469   //MaxSpin->setMinValue( Fmax );
470   if ( RBFrange->isChecked() ) { 
471     //MinLabel->setEnabled( false );
472     MinSpin->setEnabled( false );
473     //MaxLabel->setEnabled( false );
474     MaxSpin->setEnabled( false );
475     MinSpin->setValue( Fmin );
476     MaxSpin->setValue( Fmax );
477   }
478   else {
479     //MinLabel->setEnabled( true );
480     MinSpin->setEnabled( true );
481     //MaxLabel->setEnabled( true );
482     MaxSpin->setEnabled( true );
483     MinSpin->setValue( Imin );
484     MaxSpin->setValue( Imax );
485   }
486 }
487
488 /*!
489   Called when X,Y position is changed
490 */
491 void VisuGUI_ScalarBarDlg::XYChanged( double )
492 {
493   QAD_SpinBoxDbl* snd = (QAD_SpinBoxDbl*)sender();
494   if ( snd == XSpin ) {
495     WidthSpin->setMaxValue( 1.0 - XSpin->value() );
496   }
497   if ( snd == YSpin ) {
498     HeightSpin->setMaxValue( 1.0 - YSpin->value() );
499   }
500 }
501
502 /*!
503   Sets default values and range mode
504 */
505 void VisuGUI_ScalarBarDlg::setRange( double imin, double imax, double fmin, double fmax, bool sbRange )
506 {
507   Imin = imin; Imax = imax; Fmin = fmin; Fmax = fmax;
508   if( sbRange )
509     RBIrange->setChecked( true );
510   else
511     RBFrange->setChecked( true );
512   changeRange( 0 );
513 }
514
515 /*!
516   Sets size and position
517 */
518 void VisuGUI_ScalarBarDlg::setPosAndSize( double x, double y, double w, double h, bool vert )
519 {
520   if ( vert ) {
521     myVerX = x;
522     myVerY = y;
523     myVerW = w;
524     myVerH = h;
525     RBvert->setChecked( true );
526   }
527   else {
528     myHorX = x;
529     myHorY = y;
530     myHorW = w;
531     myHorH = h;
532     RBhori->setChecked( true );
533   }
534   changeDefaults( 0 );
535 }
536
537 /*!
538   Sets colors and labels number
539 */
540 void VisuGUI_ScalarBarDlg::setScalarBarData( int colors, int labels ) 
541 {
542   ColorSpin->setValue( colors );
543   LabelSpin->setValue( labels );
544 }
545
546 /*!
547   Gets orientation
548 */
549 int  VisuGUI_ScalarBarDlg::getOrientation() 
550 {
551   if (RBvert->isChecked() )
552     return  1;
553   else
554     return 0;
555 }
556
557 /*!
558   Gets Scalar Bar's x position
559 */
560 double VisuGUI_ScalarBarDlg::getX()
561 {
562   return XSpin->value();
563 }
564
565 /*!
566   Gets Scalar Bar's y position
567 */
568 double VisuGUI_ScalarBarDlg::getY()
569 {
570   return YSpin->value();
571 }
572
573 /*!
574   Gets Scalar Bar's width
575 */
576 double VisuGUI_ScalarBarDlg::getWidth()
577 {
578   return WidthSpin->value();
579 }
580
581 /*!
582   Gets Scalar Bar's height
583 */
584 double VisuGUI_ScalarBarDlg::getHeight()
585 {
586   return HeightSpin->value();
587 }
588
589 /*!
590   Gets Scalar Bar's number of colors
591 */
592 int VisuGUI_ScalarBarDlg::getNbColors()
593 {
594   return ColorSpin->value();
595 }
596
597 /*!
598   Gets Scalar Bar's number of labels
599 */
600 int VisuGUI_ScalarBarDlg::getNbLabels()
601 {
602   return LabelSpin->value();
603 }
604
605 /*!
606   Returns true if imposed range is used
607 */
608 bool VisuGUI_ScalarBarDlg::isIRange()
609 {
610   return RBIrange->isChecked();
611 }
612
613 /*!
614   Gets Min value
615 */
616 double VisuGUI_ScalarBarDlg::getMin()
617 {
618   return MinSpin->value();
619 }
620
621 /*!
622   Gets Max value
623 */
624 double VisuGUI_ScalarBarDlg::getMax()
625 {
626   return MaxSpin->value();
627 }
628
629 /*!
630   return true if "save pref" flag is on
631 */
632 bool VisuGUI_ScalarBarDlg::isToSave()
633 {
634   return CBSave ? CBSave->isChecked() : false;
635 }
636
637 /*!
638   Returns true if "Logarithmic scaling" check box is on
639 */
640 bool VisuGUI_ScalarBarDlg::isLogarithmic()
641 {
642   return CBLog->isChecked();
643 }
644
645 /*!
646   Sets "Logarithmic scaling" check box on/off
647 */
648 void VisuGUI_ScalarBarDlg::setLogarithmic( bool on )
649 {
650   CBLog->setChecked( on );
651 }