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
29 #include "VisuGUI_ScalarBarDlg.h"
30 #include "VISU_ScalarMap_i.hh"
31 #include "VISU_ScalarMapPL.hxx"
33 #include "QAD_Application.h"
34 #include "QAD_Desktop.h"
35 #include "QAD_Config.h"
36 #include "QAD_MessageBox.h"
37 #include "VISU_Convertor.hxx"
41 #include <qvalidator.h>
48 VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg(bool SetPref)
49 : QDialog( QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
51 setName( "VisuGUI_ScalarBarDlg" );
52 setCaption( SetPref ? tr( "Scalar Bar Preferences" ) : tr( "Scalar Bar Properties" ) );
53 setSizeGripEnabled( TRUE );
55 myVerX = 0.01; myVerY = 0.10; myVerW = 0.10; myVerH = 0.80;
56 myHorX = 0.20; myHorY = 0.01; myHorW = 0.60; myHorH = 0.12;
57 Imin = 0.0; Imax = 0.0; Fmin = 0.0; Fmax = 0.0; Rmin = 0.0; Rmax = 0.0;
60 QVBoxLayout* TopLayout = new QVBoxLayout( this );
61 TopLayout->setSpacing( 6 );
62 TopLayout->setMargin( 11 );
64 // Range ============================================================
65 RangeGroup = new QButtonGroup( tr( "Scalar range" ), this, "RangeGroup" );
66 RangeGroup->setColumnLayout(0, Qt::Vertical );
67 RangeGroup->layout()->setSpacing( 0 );
68 RangeGroup->layout()->setMargin( 0 );
69 QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() );
70 RangeGroupLayout->setAlignment( Qt::AlignTop );
71 RangeGroupLayout->setSpacing( 6 );
72 RangeGroupLayout->setMargin( 11 );
74 myModeLbl = new QLabel("Scalar Mode", RangeGroup);
76 myModeCombo = new QComboBox(RangeGroup);
77 myModeCombo->insertItem("Modulus");
78 myModeCombo->insertItem("Component 1");
79 myModeCombo->insertItem("Component 2");
80 myModeCombo->insertItem("Component 3");
82 CBLog = new QCheckBox( tr( "Logarithmic scaling" ), RangeGroup );
83 CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
85 RBFrange = new QRadioButton( tr( "Use field range" ), RangeGroup, "RBFrange" );
86 RBIrange = new QRadioButton( tr( "Use imposed range" ), RangeGroup, "RBIrange" );
87 RBFrange->setChecked( true );
89 MinEdit = new QLineEdit( RangeGroup, "MinEdit" );
90 MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
91 MinEdit->setMinimumWidth( 70 );
92 MinEdit->setValidator( new QDoubleValidator(this) );
93 MinEdit->setText( "0.0" );
94 QLabel* MinLabel = new QLabel( tr( "Min:" ), RangeGroup, "MinLabel" );
95 MinLabel->setBuddy(MinEdit);
97 MaxEdit = new QLineEdit( RangeGroup, "MaxEdit" );
98 MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
99 MaxEdit->setMinimumWidth( 70 );
100 MaxEdit->setValidator( new QDoubleValidator(this) );
101 MaxEdit->setText( "0.0" );
102 QLabel* MaxLabel = new QLabel( tr( "Max:" ), RangeGroup, "MaxLabel" );
103 MaxLabel->setBuddy(MaxEdit);
105 RangeGroupLayout->addWidget( myModeLbl, 0, 0 );
106 RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3);
107 RangeGroupLayout->addMultiCellWidget( CBLog, 1, 1, 0, 3);
108 RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1);
109 RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3);
110 RangeGroupLayout->addWidget( MinLabel, 3, 0 );
111 RangeGroupLayout->addWidget( MinEdit, 3, 1 );
112 RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
113 RangeGroupLayout->addWidget( MaxEdit, 3, 3 );
115 TopLayout->addWidget( RangeGroup );
117 // Colors and Labels ========================================================
118 QGroupBox* ColLabGroup = new QGroupBox( tr( "Colors and labels" ), this, "ColLabGroup" );
119 ColLabGroup->setColumnLayout(0, Qt::Vertical );
120 ColLabGroup->layout()->setSpacing( 0 );
121 ColLabGroup->layout()->setMargin( 0 );
122 QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() );
123 ColLabGroupLayout->setAlignment( Qt::AlignTop );
124 ColLabGroupLayout->setSpacing( 6 );
125 ColLabGroupLayout->setMargin( 11 );
127 QLabel* ColorLabel = new QLabel( tr( "Nb. of colors:" ), ColLabGroup, "ColorLabel" );
128 ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup );
129 ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
130 ColorSpin->setMinimumWidth( 70 );
131 ColorSpin->setValue( 64 );
133 QLabel* LabelLabel = new QLabel( tr( "Nb. of labels:" ), ColLabGroup, "LabelLabel" );
134 LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup );
135 LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
136 LabelSpin->setMinimumWidth( 70 );
137 LabelSpin->setValue( 5 );
139 ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
140 ColLabGroupLayout->addWidget( ColorSpin, 0, 1);
141 ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
142 ColLabGroupLayout->addWidget( LabelSpin, 0, 3);
144 TopLayout->addWidget( ColLabGroup );
146 // Orientation ==========================================================
147 QButtonGroup* OrientGroup = new QButtonGroup( tr( "Orientation" ), this, "OrientGroup" );
148 OrientGroup->setColumnLayout(0, Qt::Vertical );
149 OrientGroup->layout()->setSpacing( 0 );
150 OrientGroup->layout()->setMargin( 0 );
151 QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() );
152 OrientGroupLayout->setAlignment( Qt::AlignTop );
153 OrientGroupLayout->setSpacing( 6 );
154 OrientGroupLayout->setMargin( 11 );
156 RBvert = new QRadioButton( tr( "Vertical" ), OrientGroup, "RBvert" );
157 RBvert->setChecked( true );
158 RBhori = new QRadioButton( tr( "Horizontal" ), OrientGroup, "RBhori" );
159 OrientGroupLayout->addWidget( RBvert, 0, 0 );
160 OrientGroupLayout->addWidget( RBhori, 0, 1 );
162 TopLayout->addWidget( OrientGroup );
164 // Origin ===============================================================
165 QGroupBox* OriginGroup = new QGroupBox( tr( "Origin" ), this, "OriginGroup" );
166 OriginGroup->setColumnLayout(0, Qt::Vertical );
167 OriginGroup->layout()->setSpacing( 0 );
168 OriginGroup->layout()->setMargin( 0 );
169 QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() );
170 OriginGroupLayout->setAlignment( Qt::AlignTop );
171 OriginGroupLayout->setSpacing( 6 );
172 OriginGroupLayout->setMargin( 11 );
174 QLabel* XLabel = new QLabel( tr( "X:" ), OriginGroup, "XLabel" );
175 XSpin = new QAD_SpinBoxDbl( OriginGroup, 0.0, 1.0, 0.1 );
176 XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
177 XSpin->setMinimumWidth( 70 );
178 XSpin->setValue( 0.01 );
180 QLabel* YLabel = new QLabel( tr( "Y:" ), OriginGroup, "YLabel" );
181 YSpin = new QAD_SpinBoxDbl( OriginGroup, 0.0, 1.0, 0.1 );
182 YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
183 YSpin->setMinimumWidth( 70 );
184 YSpin->setValue( 0.01 );
186 OriginGroupLayout->addWidget( XLabel, 0, 0);
187 OriginGroupLayout->addWidget( XSpin, 0, 1);
188 OriginGroupLayout->addWidget( YLabel, 0, 2);
189 OriginGroupLayout->addWidget( YSpin, 0, 3);
191 TopLayout->addWidget( OriginGroup );
193 // Dimensions =========================================================
194 QGroupBox* DimGroup = new QGroupBox( tr( "Dimensions" ), this, "DimGroup" );
195 DimGroup->setColumnLayout(0, Qt::Vertical );
196 DimGroup->layout()->setSpacing( 0 );
197 DimGroup->layout()->setMargin( 0 );
198 QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() );
199 DimGroupLayout->setAlignment( Qt::AlignTop );
200 DimGroupLayout->setSpacing( 6 );
201 DimGroupLayout->setMargin( 11 );
203 QLabel* WidthLabel = new QLabel( tr( "Width:" ), DimGroup, "WidthLabel" );
204 WidthSpin = new QAD_SpinBoxDbl( DimGroup, 0.0, 1.0, 0.1 );
205 WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
206 WidthSpin->setMinimumWidth( 70 );
207 WidthSpin->setValue( 0.1 );
209 QLabel* HeightLabel = new QLabel( tr( "Height:" ), DimGroup, "HeightLabel" );
210 HeightSpin = new QAD_SpinBoxDbl( DimGroup, 0.0, 1.0, 0.1 );
211 HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
212 HeightSpin->setMinimumWidth( 70 );
213 HeightSpin->setValue( 0.8 );
215 DimGroupLayout->addWidget( WidthLabel, 0, 0);
216 DimGroupLayout->addWidget( WidthSpin, 0, 1);
217 DimGroupLayout->addWidget( HeightLabel, 0, 2);
218 DimGroupLayout->addWidget( HeightSpin, 0, 3);
220 TopLayout->addWidget( DimGroup );
222 // Save check box ===========================================================
224 CBSave = new QCheckBox( tr( "Save as default values" ), this, "CBSave" );
225 TopLayout->addWidget( CBSave );
231 // Common buttons ===========================================================
232 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
233 GroupButtons->setColumnLayout(0, Qt::Vertical );
234 GroupButtons->layout()->setSpacing( 0 );
235 GroupButtons->layout()->setMargin( 0 );
236 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
237 GroupButtonsLayout->setAlignment( Qt::AlignTop );
238 GroupButtonsLayout->setSpacing( 6 );
239 GroupButtonsLayout->setMargin( 11 );
241 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
242 buttonOk->setAutoDefault( TRUE );
243 buttonOk->setDefault( TRUE );
244 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
245 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
247 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
248 buttonCancel->setAutoDefault( TRUE );
249 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
251 TopLayout->addWidget( GroupButtons );
253 // signals and slots connections ===========================================
254 connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) );
255 connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) );
256 connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
257 connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
258 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
259 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
268 VisuGUI_ScalarBarDlg::~VisuGUI_ScalarBarDlg()
274 * Initializes dialog box values from resources
276 void VisuGUI_ScalarBarDlg::initFromResources() {
277 int sbCol=64,sbLab=5,orient=1;
278 float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8;
279 float sbVmin=0., sbVmax=0.;
282 QString Orientation = QAD_CONFIG->getSetting("Visu:SBOrientation");
283 if ( !Orientation.isEmpty() ) {
284 orient = Orientation.toInt();
294 QString SBXorigin = QAD_CONFIG->getSetting("Visu:SBXorigin");
295 if ( !SBXorigin.isEmpty() )
296 sbX1 = SBXorigin.toFloat();
298 QString SBYorigin = QAD_CONFIG->getSetting("Visu:SBYorigin");
299 if ( !SBYorigin.isEmpty() )
300 sbY1 = SBYorigin.toFloat();
302 QString SBWidth = QAD_CONFIG->getSetting("Visu:SBWidth");
303 if ( !SBWidth.isEmpty() )
304 sbW = SBWidth.toFloat();
306 QString SBHeight = QAD_CONFIG->getSetting("Visu:SBHeight");
307 if ( !SBHeight.isEmpty() )
308 sbH = SBHeight.toFloat();
310 QString SBColors = QAD_CONFIG->getSetting("Visu:SBNumberOfColors");
311 if ( !SBColors.isEmpty() )
312 sbCol = SBColors.toInt();
314 QString SBLabels = QAD_CONFIG->getSetting("Visu:SBNumberOfLabels");
315 if ( !SBLabels.isEmpty() )
316 sbLab = SBLabels.toInt();
318 QString ImpRange = QAD_CONFIG->getSetting("Visu:SBImposeRange");
319 if ( ImpRange.compare("true") == 0 )
322 QString SBVmin = QAD_CONFIG->getSetting("Visu:SBMinimumValue");
323 if ( !SBVmin.isEmpty() )
324 sbVmin = SBVmin.toFloat();
326 QString SBVmax = QAD_CONFIG->getSetting("Visu:SBMaximumValue");
327 if ( !SBVmax.isEmpty() )
328 sbVmax = SBVmax.toFloat();
330 QString aScaling = QAD_CONFIG->getSetting("Visu:SBScaling");
331 if(aScaling.compare("LOGARITHMIC") == 0)
332 setLogarithmic(true);
334 setLogarithmic(false);
336 if((sbX1 < 0.) || (sbY1 < 0.) ||
337 ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
350 if(sbCol < 2) sbCol=2;
351 if(sbCol > 64) sbCol=64;
352 if(sbLab < 2) sbLab=2;
353 if(sbLab > 65) sbLab=65;
355 if(sbVmin > sbVmax) {
360 setRange( sbVmin, sbVmax, 0.0, 0.0, sbRange );
361 setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 1);
362 setScalarBarData( sbCol, sbLab );
368 * Stores dialog values to resources
370 void VisuGUI_ScalarBarDlg::storeToResources() {
371 int orient = (RBvert->isChecked())? 1 : 0;
372 float sbX1 = XSpin->value();
373 float sbY1 = YSpin->value();
374 float sbW = WidthSpin->value();
375 float sbH = HeightSpin->value();
376 int sbCol = ColorSpin->value();
377 int sbLab = LabelSpin->value();
379 if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
393 bool sbRange = RBIrange->isChecked();
394 float sbVmin = (float)(MinEdit->text().toDouble());
395 float sbVmax = (float)(MaxEdit->text().toDouble());
397 if(sbVmin > sbVmax) {
402 QAD_CONFIG->addSetting("Visu:SBOrientation",orient);
403 QAD_CONFIG->addSetting("Visu:SBXorigin",sbX1);
404 QAD_CONFIG->addSetting("Visu:SBYorigin",sbY1);
405 QAD_CONFIG->addSetting("Visu:SBWidth",sbW);
406 QAD_CONFIG->addSetting("Visu:SBHeight",sbH);
407 QAD_CONFIG->addSetting("Visu:SBNumberOfColors",sbCol);
408 QAD_CONFIG->addSetting("Visu:SBNumberOfLabels",sbLab);
410 QAD_CONFIG->addSetting("Visu:SBImposeRange", "true");
412 QAD_CONFIG->addSetting("Visu:SBImposeRange", "false");
413 QAD_CONFIG->addSetting("Visu:SBMinimumValue",sbVmin);
414 QAD_CONFIG->addSetting("Visu:SBMaximumValue",sbVmax);
416 QAD_CONFIG->addSetting("Visu:SBScaling", "LOGARITHMIC");
418 QAD_CONFIG->addSetting("Visu:SBScaling", "LINEAR");
423 * Initialise dialog box from presentation object
425 void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
427 myModeCombo->setCurrentItem(thePrs->GetScalarMode());
428 setPosAndSize( thePrs->GetPosX(),
432 thePrs->GetOrientation());
433 switch(thePrs->GetScaling()){
434 case VISU::LOGARITHMIC :
435 setLogarithmic(true);
438 setLogarithmic(false);
441 thePrs->GetScalarMapPL()->GetSourceRange(aRange);
442 Rmin = aRange[0]; Rmax = aRange[1];
443 setRange( thePrs->GetMin(), thePrs->GetMax(),
444 0.0, 0.0, thePrs->IsRangeFixed() );
445 setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
446 bool isScalarMode = (thePrs->GetField()->myNbComp > 1);
447 myModeLbl->setEnabled(isScalarMode);
448 myModeCombo->setEnabled(isScalarMode);
453 * Store values to presentation object
455 void VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ScalarMap_i* thePrs) {
456 thePrs->SetScalarMode(myModeCombo->currentItem());
457 thePrs->SetPosition(XSpin->value(), YSpin->value());
458 thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
459 thePrs->SetOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
461 thePrs->SetScaling(VISU::LOGARITHMIC);
463 thePrs->SetScaling(VISU::LINEAR);
465 if (RBFrange->isChecked()) {
466 thePrs->SetSourceRange();
468 thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
470 thePrs->SetNbColors(ColorSpin->value());
471 thePrs->SetLabels(LabelSpin->value());
473 if (isToSave()) storeToResources();
479 Called when orientation is changed
481 void VisuGUI_ScalarBarDlg::changeDefaults( int )
483 if ( RBvert->isChecked() ) {
484 XSpin->setValue( myVerX );
485 YSpin->setValue( myVerY );
486 WidthSpin->setValue( myVerW );
487 HeightSpin->setValue( myVerH );
490 XSpin->setValue( myHorX );
491 YSpin->setValue( myHorY );
492 WidthSpin->setValue( myHorW );
493 HeightSpin->setValue( myHorH );
498 Called when Range mode is changed
500 void VisuGUI_ScalarBarDlg::changeRange( int )
503 if ( RBFrange->isChecked() )
505 if ( RBIrange->isChecked() )
507 if ( myRangeMode == mode )
509 //MinSpin->setMaxValue( Fmin );
510 //MaxSpin->setMinValue( Fmax );
511 if ( RBFrange->isChecked() ) {
512 //MinLabel->setEnabled( false );
513 MinEdit->setEnabled( false );
514 //MaxLabel->setEnabled( false );
515 MaxEdit->setEnabled( false );
517 Imin = MinEdit->text().toDouble();
518 Imax = MaxEdit->text().toDouble();
520 MinEdit->setText( QString::number( Rmin ) );
521 MaxEdit->setText( QString::number( Rmax ) );
524 //MinLabel->setEnabled( true );
525 MinEdit->setEnabled( true );
526 //MaxLabel->setEnabled( true );
527 MaxEdit->setEnabled( true );
528 MinEdit->setText( QString::number( Imin ) );
529 MaxEdit->setText( QString::number( Imax ) );
535 Called when X,Y position is changed
537 void VisuGUI_ScalarBarDlg::XYChanged( double )
539 QAD_SpinBoxDbl* snd = (QAD_SpinBoxDbl*)sender();
540 if ( snd == XSpin ) {
541 WidthSpin->setMaxValue( 1.0 - XSpin->value() );
543 if ( snd == YSpin ) {
544 HeightSpin->setMaxValue( 1.0 - YSpin->value() );
549 Sets default values and range mode
551 void VisuGUI_ScalarBarDlg::setRange( double imin, double imax, double fmin, double fmax, bool sbRange )
553 Imin = imin; Imax = imax; Fmin = fmin; Fmax = fmax;
554 if ( RBIrange->isChecked() ) {
555 MinEdit->setText( QString::number( Imin ) );
556 MaxEdit->setText( QString::number( Imax ) );
559 MinEdit->setText( QString::number( Rmin ) );
560 MaxEdit->setText( QString::number( Rmax ) );
564 RBIrange->setChecked( true );
566 RBFrange->setChecked( true );
571 Sets size and position
573 void VisuGUI_ScalarBarDlg::setPosAndSize( double x, double y, double w, double h, bool vert )
580 RBvert->setChecked( true );
587 RBhori->setChecked( true );
593 Sets colors and labels number
595 void VisuGUI_ScalarBarDlg::setScalarBarData( int colors, int labels )
597 ColorSpin->setValue( colors );
598 LabelSpin->setValue( labels );
604 int VisuGUI_ScalarBarDlg::getOrientation()
606 if (RBvert->isChecked() )
613 Gets Scalar Bar's x position
615 double VisuGUI_ScalarBarDlg::getX()
617 return XSpin->value();
621 Gets Scalar Bar's y position
623 double VisuGUI_ScalarBarDlg::getY()
625 return YSpin->value();
629 Gets Scalar Bar's width
631 double VisuGUI_ScalarBarDlg::getWidth()
633 return WidthSpin->value();
637 Gets Scalar Bar's height
639 double VisuGUI_ScalarBarDlg::getHeight()
641 return HeightSpin->value();
645 Gets Scalar Bar's number of colors
647 int VisuGUI_ScalarBarDlg::getNbColors()
649 return ColorSpin->value();
653 Gets Scalar Bar's number of labels
655 int VisuGUI_ScalarBarDlg::getNbLabels()
657 return LabelSpin->value();
661 Returns true if imposed range is used
663 bool VisuGUI_ScalarBarDlg::isIRange()
665 return RBIrange->isChecked();
671 double VisuGUI_ScalarBarDlg::getMin()
673 return MinEdit->text().toDouble();
679 double VisuGUI_ScalarBarDlg::getMax()
681 return MaxEdit->text().toDouble();
685 return true if "save pref" flag is on
687 bool VisuGUI_ScalarBarDlg::isToSave()
689 return CBSave ? CBSave->isChecked() : false;
693 Returns true if "Logarithmic scaling" check box is on
695 bool VisuGUI_ScalarBarDlg::isLogarithmic()
697 return CBLog->isChecked();
701 Sets "Logarithmic scaling" check box on/off
703 void VisuGUI_ScalarBarDlg::setLogarithmic( bool on )
705 CBLog->setChecked( on );
709 Called when <OK> button is clicked, validates data and closes dialog
711 void VisuGUI_ScalarBarDlg::accept()
713 double minVal = MinEdit->text().toDouble();
714 double maxVal = MaxEdit->text().toDouble();
715 if ( RBIrange->isChecked() ) {
716 if (minVal >= maxVal) {
717 QAD_MessageBox::warn1( this,tr("VISU_WARNING"),
718 tr("MSG_MINMAX_VALUES"),
723 // check if logarithmic mode is on and check imposed range to not contain negative values
724 if ( CBLog->isChecked() ) {
725 if ( RBIrange->isChecked() ) {
726 if ( (minVal > 0) && (maxVal > 0) ) {
730 QAD_MessageBox::warn1( this,
732 tr("WRN_LOGARITHMIC_RANGE"),
738 if ( Rmin > 0 && Rmax > 0 ) {
742 QAD_MessageBox::warn1( this,
744 tr("WRN_LOGARITHMIC_FIELD_RANGE"),
746 RBIrange->setChecked(1);
748 //MinEdit->setText( QString::number( Rmin ) );
749 //MaxEdit->setText( QString::number( Rmax ) );