1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : VisuGUI_ScalarBarDlg.cxx
25 // Author : Laurent CORNABE & Hubert ROLLAND
30 #include "VisuGUI_ScalarBarDlg.h"
33 #include <qvalidator.h>
34 #include "QAD_Application.h"
35 #include "QAD_Desktop.h"
36 #include "QAD_Config.h"
37 #include "QAD_MessageBox.h"
38 #include "VISU_Convertor.hxx"
43 VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg(bool SetPref)
44 : QDialog( QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
46 setName( "VisuGUI_ScalarBarDlg" );
47 setCaption( SetPref ? tr( "Scalar Bar Preferences" ) : tr( "Scalar Bar Properties" ) );
48 setSizeGripEnabled( TRUE );
50 myVerX = 0.01; myVerY = 0.10; myVerW = 0.10; myVerH = 0.80;
51 myHorX = 0.20; myHorY = 0.01; myHorW = 0.60; myHorH = 0.12;
52 Imin = 0.0; Imax = 0.0; Fmin = 0.0; Fmax = 0.0; Rmin = 0.0; Rmax = 0.0;
55 QVBoxLayout* TopLayout = new QVBoxLayout( this );
56 TopLayout->setSpacing( 6 );
57 TopLayout->setMargin( 11 );
59 // Range ============================================================
60 RangeGroup = new QButtonGroup( tr( "Scalar range" ), this, "RangeGroup" );
61 RangeGroup->setColumnLayout(0, Qt::Vertical );
62 RangeGroup->layout()->setSpacing( 0 );
63 RangeGroup->layout()->setMargin( 0 );
64 QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() );
65 RangeGroupLayout->setAlignment( Qt::AlignTop );
66 RangeGroupLayout->setSpacing( 6 );
67 RangeGroupLayout->setMargin( 11 );
69 myModeLbl = new QLabel("Scalar Mode", RangeGroup);
71 myModeCombo = new QComboBox(RangeGroup);
72 myModeCombo->insertItem("Modulus");
73 myModeCombo->insertItem("Component 1");
74 myModeCombo->insertItem("Component 2");
75 myModeCombo->insertItem("Component 3");
77 CBLog = new QCheckBox( tr( "Logarithmic scaling" ), RangeGroup );
78 CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
80 RBFrange = new QRadioButton( tr( "Use field range" ), RangeGroup, "RBFrange" );
81 RBIrange = new QRadioButton( tr( "Use imposed range" ), RangeGroup, "RBIrange" );
82 RBFrange->setChecked( true );
84 MinEdit = new QLineEdit( RangeGroup, "MinEdit" );
85 MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
86 MinEdit->setMinimumWidth( 70 );
87 MinEdit->setValidator( new QDoubleValidator(this) );
88 MinEdit->setText( "0.0" );
89 QLabel* MinLabel = new QLabel( tr( "Min:" ), RangeGroup, "MinLabel" );
90 MinLabel->setBuddy(MinEdit);
92 MaxEdit = new QLineEdit( RangeGroup, "MaxEdit" );
93 MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
94 MaxEdit->setMinimumWidth( 70 );
95 MaxEdit->setValidator( new QDoubleValidator(this) );
96 MaxEdit->setText( "0.0" );
97 QLabel* MaxLabel = new QLabel( tr( "Max:" ), RangeGroup, "MaxLabel" );
98 MaxLabel->setBuddy(MaxEdit);
100 RangeGroupLayout->addWidget( myModeLbl, 0, 0 );
101 RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3);
102 RangeGroupLayout->addMultiCellWidget( CBLog, 1, 1, 0, 3);
103 RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1);
104 RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3);
105 RangeGroupLayout->addWidget( MinLabel, 3, 0 );
106 RangeGroupLayout->addWidget( MinEdit, 3, 1 );
107 RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
108 RangeGroupLayout->addWidget( MaxEdit, 3, 3 );
110 TopLayout->addWidget( RangeGroup );
112 // Colors and Labels ========================================================
113 QGroupBox* ColLabGroup = new QGroupBox( tr( "Colors and labels" ), this, "ColLabGroup" );
114 ColLabGroup->setColumnLayout(0, Qt::Vertical );
115 ColLabGroup->layout()->setSpacing( 0 );
116 ColLabGroup->layout()->setMargin( 0 );
117 QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() );
118 ColLabGroupLayout->setAlignment( Qt::AlignTop );
119 ColLabGroupLayout->setSpacing( 6 );
120 ColLabGroupLayout->setMargin( 11 );
122 QLabel* ColorLabel = new QLabel( tr( "Nb. of colors:" ), ColLabGroup, "ColorLabel" );
123 ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup );
124 ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
125 ColorSpin->setMinimumWidth( 70 );
126 ColorSpin->setValue( 64 );
128 QLabel* LabelLabel = new QLabel( tr( "Nb. of labels:" ), ColLabGroup, "LabelLabel" );
129 LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup );
130 LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
131 LabelSpin->setMinimumWidth( 70 );
132 LabelSpin->setValue( 5 );
134 ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
135 ColLabGroupLayout->addWidget( ColorSpin, 0, 1);
136 ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
137 ColLabGroupLayout->addWidget( LabelSpin, 0, 3);
139 TopLayout->addWidget( ColLabGroup );
141 // Orientation ==========================================================
142 QButtonGroup* OrientGroup = new QButtonGroup( tr( "Orientation" ), this, "OrientGroup" );
143 OrientGroup->setColumnLayout(0, Qt::Vertical );
144 OrientGroup->layout()->setSpacing( 0 );
145 OrientGroup->layout()->setMargin( 0 );
146 QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() );
147 OrientGroupLayout->setAlignment( Qt::AlignTop );
148 OrientGroupLayout->setSpacing( 6 );
149 OrientGroupLayout->setMargin( 11 );
151 RBvert = new QRadioButton( tr( "Vertical" ), OrientGroup, "RBvert" );
152 RBvert->setChecked( true );
153 RBhori = new QRadioButton( tr( "Horizontal" ), OrientGroup, "RBhori" );
154 OrientGroupLayout->addWidget( RBvert, 0, 0 );
155 OrientGroupLayout->addWidget( RBhori, 0, 1 );
157 TopLayout->addWidget( OrientGroup );
159 // Origin ===============================================================
160 QGroupBox* OriginGroup = new QGroupBox( tr( "Origin" ), this, "OriginGroup" );
161 OriginGroup->setColumnLayout(0, Qt::Vertical );
162 OriginGroup->layout()->setSpacing( 0 );
163 OriginGroup->layout()->setMargin( 0 );
164 QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() );
165 OriginGroupLayout->setAlignment( Qt::AlignTop );
166 OriginGroupLayout->setSpacing( 6 );
167 OriginGroupLayout->setMargin( 11 );
169 QLabel* XLabel = new QLabel( tr( "X:" ), OriginGroup, "XLabel" );
170 XSpin = new QAD_SpinBoxDbl( OriginGroup, 0.0, 1.0, 0.1 );
171 XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
172 XSpin->setMinimumWidth( 70 );
173 XSpin->setValue( 0.01 );
175 QLabel* YLabel = new QLabel( tr( "Y:" ), OriginGroup, "YLabel" );
176 YSpin = new QAD_SpinBoxDbl( OriginGroup, 0.0, 1.0, 0.1 );
177 YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
178 YSpin->setMinimumWidth( 70 );
179 YSpin->setValue( 0.01 );
181 OriginGroupLayout->addWidget( XLabel, 0, 0);
182 OriginGroupLayout->addWidget( XSpin, 0, 1);
183 OriginGroupLayout->addWidget( YLabel, 0, 2);
184 OriginGroupLayout->addWidget( YSpin, 0, 3);
186 TopLayout->addWidget( OriginGroup );
188 // Dimensions =========================================================
189 QGroupBox* DimGroup = new QGroupBox( tr( "Dimensions" ), this, "DimGroup" );
190 DimGroup->setColumnLayout(0, Qt::Vertical );
191 DimGroup->layout()->setSpacing( 0 );
192 DimGroup->layout()->setMargin( 0 );
193 QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() );
194 DimGroupLayout->setAlignment( Qt::AlignTop );
195 DimGroupLayout->setSpacing( 6 );
196 DimGroupLayout->setMargin( 11 );
198 QLabel* WidthLabel = new QLabel( tr( "Width:" ), DimGroup, "WidthLabel" );
199 WidthSpin = new QAD_SpinBoxDbl( DimGroup, 0.0, 1.0, 0.1 );
200 WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
201 WidthSpin->setMinimumWidth( 70 );
202 WidthSpin->setValue( 0.1 );
204 QLabel* HeightLabel = new QLabel( tr( "Height:" ), DimGroup, "HeightLabel" );
205 HeightSpin = new QAD_SpinBoxDbl( DimGroup, 0.0, 1.0, 0.1 );
206 HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
207 HeightSpin->setMinimumWidth( 70 );
208 HeightSpin->setValue( 0.8 );
210 DimGroupLayout->addWidget( WidthLabel, 0, 0);
211 DimGroupLayout->addWidget( WidthSpin, 0, 1);
212 DimGroupLayout->addWidget( HeightLabel, 0, 2);
213 DimGroupLayout->addWidget( HeightSpin, 0, 3);
215 TopLayout->addWidget( DimGroup );
217 // Save check box ===========================================================
219 CBSave = new QCheckBox( tr( "Save as default values" ), this, "CBSave" );
220 TopLayout->addWidget( CBSave );
226 // Common buttons ===========================================================
227 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
228 GroupButtons->setColumnLayout(0, Qt::Vertical );
229 GroupButtons->layout()->setSpacing( 0 );
230 GroupButtons->layout()->setMargin( 0 );
231 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
232 GroupButtonsLayout->setAlignment( Qt::AlignTop );
233 GroupButtonsLayout->setSpacing( 6 );
234 GroupButtonsLayout->setMargin( 11 );
236 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
237 buttonOk->setAutoDefault( TRUE );
238 buttonOk->setDefault( TRUE );
239 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
240 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
242 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
243 buttonCancel->setAutoDefault( TRUE );
244 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
246 TopLayout->addWidget( GroupButtons );
248 // signals and slots connections ===========================================
249 connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) );
250 connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) );
251 connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
252 connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
253 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
254 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
263 VisuGUI_ScalarBarDlg::~VisuGUI_ScalarBarDlg()
269 * Initializes dialog box values from resources
271 void VisuGUI_ScalarBarDlg::initFromResources() {
272 int sbCol=64,sbLab=5,orient=1;
273 float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8;
274 float sbVmin=0., sbVmax=0.;
277 QString Orientation = QAD_CONFIG->getSetting("Visu:SBOrientation");
278 if ( !Orientation.isEmpty() ) {
279 orient = Orientation.toInt();
289 QString SBXorigin = QAD_CONFIG->getSetting("Visu:SBXorigin");
290 if ( !SBXorigin.isEmpty() )
291 sbX1 = SBXorigin.toFloat();
293 QString SBYorigin = QAD_CONFIG->getSetting("Visu:SBYorigin");
294 if ( !SBYorigin.isEmpty() )
295 sbY1 = SBYorigin.toFloat();
297 QString SBWidth = QAD_CONFIG->getSetting("Visu:SBWidth");
298 if ( !SBWidth.isEmpty() )
299 sbW = SBWidth.toFloat();
301 QString SBHeight = QAD_CONFIG->getSetting("Visu:SBHeight");
302 if ( !SBHeight.isEmpty() )
303 sbH = SBHeight.toFloat();
305 QString SBColors = QAD_CONFIG->getSetting("Visu:SBNumberOfColors");
306 if ( !SBColors.isEmpty() )
307 sbCol = SBColors.toInt();
309 QString SBLabels = QAD_CONFIG->getSetting("Visu:SBNumberOfLabels");
310 if ( !SBLabels.isEmpty() )
311 sbLab = SBLabels.toInt();
313 QString ImpRange = QAD_CONFIG->getSetting("Visu:SBImposeRange");
314 if ( ImpRange.compare("true") == 0 )
317 QString SBVmin = QAD_CONFIG->getSetting("Visu:SBMinimumValue");
318 if ( !SBVmin.isEmpty() )
319 sbVmin = SBVmin.toFloat();
321 QString SBVmax = QAD_CONFIG->getSetting("Visu:SBMaximumValue");
322 if ( !SBVmax.isEmpty() )
323 sbVmax = SBVmax.toFloat();
325 QString aScaling = QAD_CONFIG->getSetting("Visu:SBScaling");
326 if(aScaling.compare("LOGARITHMIC") == 0)
327 setLogarithmic(true);
329 setLogarithmic(false);
331 if((sbX1 < 0.) || (sbY1 < 0.) ||
332 ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
345 if(sbCol < 2) sbCol=2;
346 if(sbCol > 64) sbCol=64;
347 if(sbLab < 2) sbLab=2;
348 if(sbLab > 65) sbLab=65;
350 if(sbVmin > sbVmax) {
355 setRange( sbVmin, sbVmax, 0.0, 0.0, sbRange );
356 setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 1);
357 setScalarBarData( sbCol, sbLab );
363 * Stores dialog values to resources
365 void VisuGUI_ScalarBarDlg::storeToResources() {
366 int orient = (RBvert->isChecked())? 1 : 0;
367 float sbX1 = XSpin->value();
368 float sbY1 = YSpin->value();
369 float sbW = WidthSpin->value();
370 float sbH = HeightSpin->value();
371 int sbCol = ColorSpin->value();
372 int sbLab = LabelSpin->value();
374 if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
388 bool sbRange = RBIrange->isChecked();
389 float sbVmin = (float)(MinEdit->text().toDouble());
390 float sbVmax = (float)(MaxEdit->text().toDouble());
392 if(sbVmin > sbVmax) {
397 QAD_CONFIG->addSetting("Visu:SBOrientation",orient);
398 QAD_CONFIG->addSetting("Visu:SBXorigin",sbX1);
399 QAD_CONFIG->addSetting("Visu:SBYorigin",sbY1);
400 QAD_CONFIG->addSetting("Visu:SBWidth",sbW);
401 QAD_CONFIG->addSetting("Visu:SBHeight",sbH);
402 QAD_CONFIG->addSetting("Visu:SBNumberOfColors",sbCol);
403 QAD_CONFIG->addSetting("Visu:SBNumberOfLabels",sbLab);
405 QAD_CONFIG->addSetting("Visu:SBImposeRange", "true");
407 QAD_CONFIG->addSetting("Visu:SBImposeRange", "false");
408 QAD_CONFIG->addSetting("Visu:SBMinimumValue",sbVmin);
409 QAD_CONFIG->addSetting("Visu:SBMaximumValue",sbVmax);
411 QAD_CONFIG->addSetting("Visu:SBScaling", "LOGARITHMIC");
413 QAD_CONFIG->addSetting("Visu:SBScaling", "LINEAR");
418 * Initialise dialog box from presentation object
420 void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
421 myModeCombo->setCurrentItem(thePrs->GetScalarMode());
422 setPosAndSize( thePrs->GetPosX(),
426 thePrs->GetOrientation());
427 switch(thePrs->GetScaling()){
428 case VISU::LOGARITHMIC :
429 setLogarithmic(true);
432 setLogarithmic(false);
435 thePrs->GetFieldRange(aRange);
436 Rmin = aRange[0]; Rmax = aRange[1];
437 setRange( thePrs->GetMin(), thePrs->GetMax(),
438 0.0, 0.0, thePrs->isRangeFixed() );
439 setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
440 bool isScalarMode = (thePrs->GetField()->myNbComp > 1);
441 myModeLbl->setEnabled(isScalarMode);
442 myModeCombo->setEnabled(isScalarMode);
447 * Store values to presentation object
449 void VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ScalarMap_i* thePrs) {
450 thePrs->SetScalarMode(myModeCombo->currentItem());
451 thePrs->SetPosition(XSpin->value(), YSpin->value());
452 thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
453 thePrs->SetOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
454 if (RBFrange->isChecked()) {
455 thePrs->CalculateRange();
457 thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
460 thePrs->SetScaling(VISU::LOGARITHMIC);
462 thePrs->SetScaling(VISU::LINEAR);
463 thePrs->SetNbColors(ColorSpin->value());
464 thePrs->SetLabels(LabelSpin->value());
467 if (isToSave()) storeToResources();
473 Called when orientation is changed
475 void VisuGUI_ScalarBarDlg::changeDefaults( int )
477 if ( RBvert->isChecked() ) {
478 XSpin->setValue( myVerX );
479 YSpin->setValue( myVerY );
480 WidthSpin->setValue( myVerW );
481 HeightSpin->setValue( myVerH );
484 XSpin->setValue( myHorX );
485 YSpin->setValue( myHorY );
486 WidthSpin->setValue( myHorW );
487 HeightSpin->setValue( myHorH );
492 Called when Range mode is changed
494 void VisuGUI_ScalarBarDlg::changeRange( int )
497 if ( RBFrange->isChecked() )
499 if ( RBIrange->isChecked() )
501 if ( myRangeMode == mode )
503 //MinSpin->setMaxValue( Fmin );
504 //MaxSpin->setMinValue( Fmax );
505 if ( RBFrange->isChecked() ) {
506 //MinLabel->setEnabled( false );
507 MinEdit->setEnabled( false );
508 //MaxLabel->setEnabled( false );
509 MaxEdit->setEnabled( false );
511 Imin = MinEdit->text().toDouble();
512 Imax = MaxEdit->text().toDouble();
514 MinEdit->setText( QString::number( Rmin ) );
515 MaxEdit->setText( QString::number( Rmax ) );
518 //MinLabel->setEnabled( true );
519 MinEdit->setEnabled( true );
520 //MaxLabel->setEnabled( true );
521 MaxEdit->setEnabled( true );
522 MinEdit->setText( QString::number( Imin ) );
523 MaxEdit->setText( QString::number( Imax ) );
529 Called when X,Y position is changed
531 void VisuGUI_ScalarBarDlg::XYChanged( double )
533 QAD_SpinBoxDbl* snd = (QAD_SpinBoxDbl*)sender();
534 if ( snd == XSpin ) {
535 WidthSpin->setMaxValue( 1.0 - XSpin->value() );
537 if ( snd == YSpin ) {
538 HeightSpin->setMaxValue( 1.0 - YSpin->value() );
543 Sets default values and range mode
545 void VisuGUI_ScalarBarDlg::setRange( double imin, double imax, double fmin, double fmax, bool sbRange )
547 Imin = imin; Imax = imax; Fmin = fmin; Fmax = fmax;
548 if ( RBIrange->isChecked() ) {
549 MinEdit->setText( QString::number( Imin ) );
550 MaxEdit->setText( QString::number( Imax ) );
553 MinEdit->setText( QString::number( Rmin ) );
554 MaxEdit->setText( QString::number( Rmax ) );
558 RBIrange->setChecked( true );
560 RBFrange->setChecked( true );
565 Sets size and position
567 void VisuGUI_ScalarBarDlg::setPosAndSize( double x, double y, double w, double h, bool vert )
574 RBvert->setChecked( true );
581 RBhori->setChecked( true );
587 Sets colors and labels number
589 void VisuGUI_ScalarBarDlg::setScalarBarData( int colors, int labels )
591 ColorSpin->setValue( colors );
592 LabelSpin->setValue( labels );
598 int VisuGUI_ScalarBarDlg::getOrientation()
600 if (RBvert->isChecked() )
607 Gets Scalar Bar's x position
609 double VisuGUI_ScalarBarDlg::getX()
611 return XSpin->value();
615 Gets Scalar Bar's y position
617 double VisuGUI_ScalarBarDlg::getY()
619 return YSpin->value();
623 Gets Scalar Bar's width
625 double VisuGUI_ScalarBarDlg::getWidth()
627 return WidthSpin->value();
631 Gets Scalar Bar's height
633 double VisuGUI_ScalarBarDlg::getHeight()
635 return HeightSpin->value();
639 Gets Scalar Bar's number of colors
641 int VisuGUI_ScalarBarDlg::getNbColors()
643 return ColorSpin->value();
647 Gets Scalar Bar's number of labels
649 int VisuGUI_ScalarBarDlg::getNbLabels()
651 return LabelSpin->value();
655 Returns true if imposed range is used
657 bool VisuGUI_ScalarBarDlg::isIRange()
659 return RBIrange->isChecked();
665 double VisuGUI_ScalarBarDlg::getMin()
667 return MinEdit->text().toDouble();
673 double VisuGUI_ScalarBarDlg::getMax()
675 return MaxEdit->text().toDouble();
679 return true if "save pref" flag is on
681 bool VisuGUI_ScalarBarDlg::isToSave()
683 return CBSave ? CBSave->isChecked() : false;
687 Returns true if "Logarithmic scaling" check box is on
689 bool VisuGUI_ScalarBarDlg::isLogarithmic()
691 return CBLog->isChecked();
695 Sets "Logarithmic scaling" check box on/off
697 void VisuGUI_ScalarBarDlg::setLogarithmic( bool on )
699 CBLog->setChecked( on );
703 Called when <OK> button is clicked, validates data and closes dialog
705 void VisuGUI_ScalarBarDlg::accept()
707 double minVal = MinEdit->text().toDouble();
708 double maxVal = MaxEdit->text().toDouble();
709 if ( RBIrange->isChecked() ) {
710 if (minVal >= maxVal) {
711 QAD_MessageBox::warn1( this,tr("VISU_WARNING"),
712 tr("MSG_MINMAX_VALUES"),
717 // check if logarithmic mode is on and check imposed range to not contain negative values
718 if ( CBLog->isChecked() ) {
719 if ( RBIrange->isChecked() ) {
720 if ( (minVal > 0) && (maxVal > 0) ) {
724 QAD_MessageBox::warn1( this,
726 tr("WRN_LOGARITHMIC_RANGE"),
732 if ( Rmin > 0 && Rmax > 0 ) {
736 QAD_MessageBox::warn1( this,
738 tr("WRN_LOGARITHMIC_FIELD_RANGE"),
740 RBIrange->setChecked(1);
742 //MinEdit->setText( QString::number( Rmin ) );
743 //MaxEdit->setText( QString::number( Rmax ) );