From: sln Date: Tue, 16 Dec 2008 11:10:10 +0000 (+0000) Subject: 0019819: EDF 643 VISU : Scalar bar ergonomics X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=95314f55b0478748270d9d7da9cd3ee594ae08ea;p=modules%2Fvisu.git 0019819: EDF 643 VISU : Scalar bar ergonomics Scalar bar ergonomics is updated. Two Parameters ?Title width (%)? and ?Title height (%)? are replaced with one parameter ?Title size (%)?. Two Parameters ?Labels width (%)? and ?Labels height (%)? are replaced with one parameter ?Labels size (%)?. Format of labels is stored as integer value specified format precision instead of string value representing format. This integer value is used by Preferences and ?Bar properties? dialog box. All other internal objects (actors and presentations) uses format as string values. Two auxiliary methods VISU_Prs3dUtils::ToFormat() and VISU_Prs3dUtils::ToPrecision() are created for converting precision to format and vice versa. Label ?Dimensions? of ?Scalar bar properties? pane is replaced with ?Dimensions (in % of the size of view)? --- diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index 5a3c623b..4a3effb5 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -37,15 +37,13 @@ - - - - + + - + diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index d4af9d78..db230b69 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -404,16 +404,16 @@ Do you want to enlarge the cache? Labels format - VISU_TITLE_WIDTH - Title width (%): + VISU_TITLE_SIZE + Title size (%): VISU_TITLE_HEIGHT Title height (%): - VISU_LABEL_WIDTH - Label width (%): + VISU_LABEL_SIZE + Label size (%): VISU_LABEL_HEIGHT @@ -862,6 +862,10 @@ Please, refer to the documentation. VisuGUI + + PRECISION + Precision + DLG_LINEWIDTH_CMT1 Set value between @@ -2858,7 +2862,7 @@ Please, provide non-empty resulting presentation. DIMENSIONS_GRP - Dimensions + Dimensions (in % of the size of view) FIELD_RANGE_BTN @@ -3497,6 +3501,18 @@ Please, refer to the documentation. VisuGUI_BarPrefDlg + + DIMENSIONS + Dimensions (in % of the size of widget) + + + WIDTH + Width + + + PRECISION + Precision + &OK @@ -3511,15 +3527,11 @@ Please, refer to the documentation. LBL_TITLE_W - Title width (%) - - - LBL_TITLE_H - Title height (%) + Title size (%) LBL_LABEL_W - Label width (%) + Label size (%) LBL_LABEL_H @@ -3547,7 +3559,11 @@ Please, refer to the documentation. MSG_BIG_SCALE - The common (Title, Label, Bar) width or height should not be greater then 100%. + The common Label size and Bar width or height should not be greater then 100%. + + + MSG_BIG_SCALE_TLT + The Title size should not be greater then 100%. AUTO diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index bcf44217..e52a0e8d 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -3367,9 +3367,12 @@ void VisuGUI::createPreferences() setPreferenceProperty( numlab, "min", 2 ); setPreferenceProperty( numlab, "max", 65 ); - addPreference( tr( "VISU_LABELS_FORMAT" ), colorsLabelsGr, - LightApp_Preferences::String, "VISU", "scalar_bar_label_format" ); + int lPrec = addPreference( tr( "PRECISION" ), colorsLabelsGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_label_precision" ); + setPreferenceProperty( lPrec, "min", 1 ); + setPreferenceProperty( lPrec, "max", 100 ); + int frame = addPreference( "", sbarTab, LightApp_Preferences::Frame, "", "" ); setPreferenceProperty( frame, "orientation", "horizontal" ); @@ -3409,16 +3412,12 @@ void VisuGUI::createPreferences() int hv = addPreference( tr( "VISU_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_height" ); - int twv = addPreference( tr( "VISU_TITLE_WIDTH" ), posVSizeGr, - LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_title_width" ); - int thv = addPreference( tr( "VISU_TITLE_HEIGHT" ), posVSizeGr, - LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_title_height" ); - - int lwv = addPreference( tr( "VISU_LABEL_WIDTH" ), posVSizeGr, - LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_label_width" ); - int lhv = addPreference( tr( "VISU_LABEL_HEIGHT" ), posVSizeGr, - LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_label_height" ); - + int twv = addPreference( tr( "VISU_TITLE_SIZE" ), posVSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_title_size" ); + + int lwv = addPreference( tr( "VISU_LABEL_SIZE" ), posVSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_label_size" ); + int bwv = addPreference( tr( "VISU_BAR_WIDTH" ), posVSizeGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_bar_width" ); int bhv = addPreference( tr( "VISU_BAR_HEIGHT" ), posVSizeGr, @@ -3434,12 +3433,8 @@ void VisuGUI::createPreferences() setPreferenceProperty( hv, "min", 0.0 ); setPreferenceProperty( twv, "min", 0 ); setPreferenceProperty( twv, "special", "auto" ); - setPreferenceProperty( thv, "min", 0 ); - setPreferenceProperty( thv, "special", "auto" ); setPreferenceProperty( lwv, "min", 0 ); setPreferenceProperty( lwv, "special", "auto" ); - setPreferenceProperty( lhv, "min", 0 ); - setPreferenceProperty( lhv, "special", "auto" ); setPreferenceProperty( bwv, "min", 0 ); setPreferenceProperty( bwv, "special", "auto" ); setPreferenceProperty( bhv, "min", 0 ); @@ -3449,9 +3444,7 @@ void VisuGUI::createPreferences() setPreferenceProperty( wv, "max", 1.0 ); setPreferenceProperty( hv, "max", 1.0 ); setPreferenceProperty( twv, "max", 100 ); - setPreferenceProperty( thv, "max", 100 ); setPreferenceProperty( lwv, "max", 100 ); - setPreferenceProperty( lhv, "max", 100 ); setPreferenceProperty( bwv, "max", 100 ); setPreferenceProperty( bhv, "max", 100 ); @@ -3470,19 +3463,15 @@ void VisuGUI::createPreferences() int hh = addPreference( tr( "VISU_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_height" ); - int twh = addPreference( tr( "Title width (%)" ), posHSizeGr, - LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_title_width" ); - int thh = addPreference( tr( "Title height (%)" ), posHSizeGr, - LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_title_height" ); - - int lwh = addPreference( tr( "Label width (%)" ), posHSizeGr, - LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_label_width" ); - int lhh = addPreference( tr( "Label height (%)" ), posHSizeGr, - LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_label_height" ); - - int bwh = addPreference( tr( "Bar width (%)" ), posHSizeGr, + int twh = addPreference( tr( "VISU_TITLE_SIZE" ), posHSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_title_size" ); + + int lwh = addPreference( tr( "VISU_LABEL_SIZE" ), posHSizeGr, + LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_label_size" ); + + int bwh = addPreference( tr( "VISU_BAR_WIDTH" ), posHSizeGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_bar_width" ); - int bhh = addPreference( tr( "Bar height (%)" ), posHSizeGr, + int bhh = addPreference( tr( "VISU_BAR_HEIGHT" ), posHSizeGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_bar_height" ); setPreferenceProperty( xh, "step", 0.1 ); @@ -3495,12 +3484,8 @@ void VisuGUI::createPreferences() setPreferenceProperty( hh, "min", 0.0 ); setPreferenceProperty( twh, "min", 0 ); setPreferenceProperty( twh, "special", "auto" ); - setPreferenceProperty( thh, "min", 0 ); - setPreferenceProperty( thh, "special", "auto" ); setPreferenceProperty( lwh, "min", 0 ); setPreferenceProperty( lwh, "special", "auto" ); - setPreferenceProperty( lhh, "min", 0 ); - setPreferenceProperty( lhh, "special", "auto" ); setPreferenceProperty( bwh, "min", 0 ); setPreferenceProperty( bwh, "special", "auto" ); setPreferenceProperty( bhh, "min", 0 ); @@ -3510,9 +3495,7 @@ void VisuGUI::createPreferences() setPreferenceProperty( wh, "max", 1.0 ); setPreferenceProperty( hh, "max", 1.0 ); setPreferenceProperty( twh, "max", 100 ); - setPreferenceProperty( thh, "max", 100 ); setPreferenceProperty( lwh, "max", 100 ); - setPreferenceProperty( lhh, "max", 100 ); setPreferenceProperty( bwh, "max", 100 ); setPreferenceProperty( bhh, "max", 100 ); @@ -3775,8 +3758,8 @@ void VisuGUI::preferencesChanged( const QString& a, const QString& b) float aTol = 1.00000009999999; QString aWarning; if(b == QString("scalar_bar_vertical_x") || b == QString("scalar_bar_vertical_width")){ - sbX1 = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_x", sbX1); - sbW = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_width", sbW); + sbX1 = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_x", 0.01); + sbW = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_width", 0.05); if(sbX1+sbW > aTol){ aWarning = "Origin and Size Vertical: X+Width > 1\n"; sbX1=0.01; @@ -3786,8 +3769,8 @@ void VisuGUI::preferencesChanged( const QString& a, const QString& b) } } else if(b == QString("scalar_bar_vertical_y") || b == QString("scalar_bar_vertical_height")){ - sbY1 = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_y", sbY1); - sbH = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_height",sbH); + sbY1 = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_y", 0.01); + sbH = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_height",0.5); if(sbY1+sbH > aTol){ aWarning = "Origin and Size Vertical: Y+Height > 1\n"; sbY1=0.01; @@ -3797,8 +3780,8 @@ void VisuGUI::preferencesChanged( const QString& a, const QString& b) } } else if(b == QString("scalar_bar_horizontal_x") || b == QString("scalar_bar_horizontal_width")){ - sbX1 = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_x", sbX1); - sbW = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_width", sbW); + sbX1 = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_x", 0.2); + sbW = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_width", 0.6); if(sbX1+sbW > aTol){ aWarning = "Origin and Size Horizontal: X+Width > 1\n"; sbX1=0.2; @@ -3808,8 +3791,8 @@ void VisuGUI::preferencesChanged( const QString& a, const QString& b) } } else if(b == QString("scalar_bar_horizontal_y") || b == QString("scalar_bar_horizontal_height")){ - sbY1 = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_y", sbY1); - sbH = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_height",sbH); + sbY1 = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_y", 0.01); + sbH = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_height",0.12); if(sbY1+sbH > aTol){ aWarning = "Origin and Size Horizontal: Y+Height > 1\n"; sbY1=0.01; @@ -3817,17 +3800,8 @@ void VisuGUI::preferencesChanged( const QString& a, const QString& b) aResourceMgr->setValue("VISU", "scalar_bar_horizontal_y", sbY1); aResourceMgr->setValue("VISU", "scalar_bar_horizontal_height",sbH); } - } else if(b == QString("scalar_bar_label_format")) { - QString dVal; - dVal.sprintf(aResourceMgr->stringValue("VISU", "scalar_bar_label_format",dVal).toLatin1().data(), 1.1); - if(dVal.toDouble() == 0.) { - aWarning = "Label format is incorrect "; - aWarning += dVal; - aWarning += "\n"; - dVal="%-#6.3g"; - aResourceMgr->setValue("VISU", "scalar_bar_label_format", dVal); - } - } + } + if ( !aWarning.isEmpty() ){ aWarning += "The default values are applied instead."; SUIT_MessageBox::warning(GetDesktop(this), diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index 14826a2f..0ec8c5bd 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -34,6 +34,7 @@ #include "VISU_ColoredPrs3dFactory.hh" #include "VISU_GaussPoints_i.hh" +#include "VISU_Prs3dUtils.hh" #include "VISU_GaussPointsPL.hxx" #include "VISU_OpenGLPointSpriteMapper.hxx" #include "VISU_Convertor.hxx" @@ -81,8 +82,8 @@ VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent): { myVerX = 0.01; myVerY = 0.10; myVerW = 0.10; myVerH = 0.80; myHorX = 0.20; myHorY = 0.01; myHorW = 0.60; myHorH = 0.12; - myVerTW = myVerTH = myVerLW = myVerLH = myVerBW = myVerBH = 0; - myHorTW = myHorTH = myHorLW = myHorLH = myHorBW = myHorBH = 0; + myVerTS = myVerLS = myVerBW = myVerBH = 0; + myHorTS = myHorLS = myHorBW = myHorBH = 0; Imin = 0.0; Imax = 0.0; myRangeMode = -1; @@ -476,22 +477,18 @@ void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs, thePrs->GetBarOrientation()); if(RBvert->isChecked()) { - myVerTW = thePrs->GetTitleWidth(); - myVerTH = thePrs->GetTitleHeight(); - myVerLW = thePrs->GetLabelWidth(); - myVerLH = thePrs->GetLabelHeight(); + myVerTS = thePrs->GetTitleSize(); + myVerLS = thePrs->GetLabelSize(); myVerBW = thePrs->GetBarWidth(); myVerBH = thePrs->GetBarHeight(); } else { - myHorTW = thePrs->GetTitleWidth(); - myHorTH = thePrs->GetTitleHeight(); - myHorLW = thePrs->GetLabelWidth(); - myHorLH = thePrs->GetLabelHeight(); + myHorTS = thePrs->GetTitleSize(); + myHorLS = thePrs->GetLabelSize(); myHorBW = thePrs->GetBarWidth(); myHorBH = thePrs->GetBarHeight(); } - myBarDlg->setLabelsFormat(thePrs->GetLabelsFormat()); + myBarDlg->setLabelsPrecision( VISU::ToPrecision( thePrs->GetLabelsFormat() ) ); myBarDlg->setUnitsVisible(thePrs->IsUnitsVisible()); SpacingSpin->setValue(thePrs->GetSpacing()); @@ -554,7 +551,8 @@ void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs, vtkFloatingPointType R, G, B; thePrs->GetTitleColor(R, G, B); - myBarDlg->setLabelsFormat(thePrs->GetLabelsFormat()); + int lp = VISU::ToPrecision( thePrs->GetLabelsFormat() ); + myBarDlg->setLabelsPrecision( lp ); myBarDlg->setUnitsVisible(thePrs->IsUnitsVisible()); myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)), @@ -597,12 +595,13 @@ int VisuGUI_GaussScalarBarPane::storeToPrsObject(VISU::GaussPoints_i* thePrs) { thePrs->SetLabels(LabelSpin->value()); if(RBvert->isChecked()) { - thePrs->SetRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + thePrs->SetRatios(myVerTS, myVerLS, myVerBW, myVerBH); } else { - thePrs->SetRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + thePrs->SetRatios(myHorTS, myHorLS, myHorBW, myHorBH); } - thePrs->SetLabelsFormat(myBarDlg->getLabelsFormat().toLatin1().data()); + std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() ); + thePrs->SetLabelsFormat( f.c_str() ); thePrs->SetUnitsVisible(myBarDlg->isUnitsVisible()); if (myIsStoreTextProp) { @@ -758,14 +757,14 @@ void VisuGUI_GaussScalarBarPane::onTextPref() void VisuGUI_GaussScalarBarPane::onBarPref() { if(RBvert->isChecked()) - myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH); else - myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH); if(myBarDlg->exec()) { if(RBvert->isChecked()) - myBarDlg->getRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + myBarDlg->getRatios(myVerTS, myVerLS, myVerBW, myVerBH); else - myBarDlg->getRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + myBarDlg->getRatios(myHorTS, myHorLS, myHorBW, myHorBH); } } diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.h b/src/VISUGUI/VisuGUI_GaussPointsDlg.h index e23b9a1e..92210cce 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.h +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.h @@ -101,8 +101,8 @@ class VisuGUI_GaussScalarBarPane : public QWidget//QVBox double Imin, Imax; double myHorX, myHorY, myHorW, myHorH; double myVerX, myVerY, myVerW, myVerH; - int myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH; - int myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH; + int myHorTS, myHorLS, myHorBW, myHorBH; + int myVerTS, myVerLS, myVerBW, myVerBH; int myRangeMode; bool myIsStoreTextProp; diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx index 90368749..756e6114 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx @@ -42,6 +42,7 @@ #include "VISU_ScalarMapAct.h" #include "VISU_ScalarMap_i.hh" #include "VISU_Result_i.hh" +#include "VISU_Prs3dUtils.hh" #include "LightApp_Application.h" @@ -87,9 +88,9 @@ VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent) setWindowTitle(tr("TIT_TEXT_PREF")); setSizeGripEnabled(TRUE); - QVBoxLayout* TopLayout = new QVBoxLayout(this); - TopLayout->setSpacing(6); - TopLayout->setMargin(11); + QVBoxLayout* aMainLay = new QVBoxLayout(this); + aMainLay->setSpacing(6); + aMainLay->setMargin(11); // "Title" grp QGroupBox* aTitleGrp = new QGroupBox ( tr("LBL_TITLE"), this); @@ -109,7 +110,7 @@ VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent) myTitleFont = new SVTK_FontWidget (aHBox); aHBLay->addWidget( myTitleFont ); - TopLayout->addWidget(aTitleGrp); + aMainLay->addWidget(aTitleGrp); // "Labels" grp QGroupBox* aLabelsGrp = new QGroupBox (tr("LBL_LABELS"), this); @@ -125,7 +126,7 @@ VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent) myLabelFont = new SVTK_FontWidget (aHBox); aHBLay->addWidget( myLabelFont ); - TopLayout->addWidget(aLabelsGrp); + aMainLay->addWidget(aLabelsGrp); // Common buttons =========================================================== QGroupBox* GroupButtons = new QGroupBox( this ); @@ -151,7 +152,7 @@ VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent) buttonHelp->setAutoDefault( TRUE ); GroupButtonsLayout->addWidget( buttonHelp, 0, 3 ); - TopLayout->addWidget( GroupButtons ); + aMainLay->addWidget( GroupButtons ); connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); @@ -260,7 +261,8 @@ void VisuGUI_TextPrefDlg::keyPressEvent( QKeyEvent* e ) Constructor */ VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent ) - : QDialog( parent ) + : QDialog( parent ), + myOrientation( 1 ) { setModal( true ); setWindowTitle( tr( "TIT_BAR_PREF" ) ); @@ -268,109 +270,79 @@ VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent ) QString propertyName = QString( "scalar_bar_vertical_" ); - myTitleWidth = myTitleHeight = myLabelWidth = myLabelHeight = myBarWidth = myBarHeight = 0; + myTitleSize = myLabelSize = myBarWidth = myBarHeight = 0; myUnits = true; - myUnitsFormat = "%-#6.3g"; + myPrecision = 3; - QVBoxLayout* TopLayout = new QVBoxLayout( this ); - TopLayout->setSpacing( 6 ); - TopLayout->setMargin( 11 ); + QVBoxLayout* aMainLay = new QVBoxLayout( this ); + aMainLay->setSpacing( 5 ); + aMainLay->setMargin( 5 ); + + // dimensions + + QGroupBox* aDimGrp = new QGroupBox( this ); + QGridLayout* aDimGrpLay = new QGridLayout( aDimGrp ); + aDimGrpLay->setSpacing( 5 ); + aDimGrpLay->setMargin( 5 ); + + myTitleSizeSpin = new QSpinBox( aDimGrp ); + myTitleSizeSpin->setRange( 0, 100 ); + myTitleSizeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myTitleSizeSpin->setMinimumWidth( 70 ); + myTitleSizeSpin->setValue( 0 ); + myTitleSizeSpin->setSpecialValueText( tr( "AUTO" ) ); + QLabel* aTitleSizeLbl = new QLabel( tr( "LBL_TITLE_W" ), aDimGrp ); + + myLabelSizeSpin = new QSpinBox( aDimGrp ); + myLabelSizeSpin->setRange( 0, 100 ); + myLabelSizeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myLabelSizeSpin->setMinimumWidth( 70 ); + myLabelSizeSpin->setValue( 0 ); + myLabelSizeSpin->setSpecialValueText( tr( "AUTO" ) ); + QLabel* aLabelSizeLbl = new QLabel( tr( "LBL_LABEL_W" ), aDimGrp ); + + myBarWidthSpin = new QSpinBox( aDimGrp ); + myBarWidthSpin->setRange( 0, 100 ); + myBarWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myBarWidthSpin->setMinimumWidth( 70 ); + myBarWidthSpin->setValue( 0 ); + myBarWidthSpin->setSpecialValueText( tr( "AUTO" ) ); + QLabel* aBarWidthLbl = new QLabel( tr( "LBL_BAR_W" ), aDimGrp ); + + myBarHeightSpin = new QSpinBox( aDimGrp ); + myBarHeightSpin->setRange( 0, 100 ); + myBarHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myBarHeightSpin->setMinimumWidth( 70 ); + myBarHeightSpin->setValue( 0 ); + myBarHeightSpin->setSpecialValueText( tr( "AUTO" ) ); + QLabel* aBarHeightLbl = new QLabel( tr( "LBL_BAR_H" ), aDimGrp ); + + // format and units + + QLabel* aPrecLbl = new QLabel( tr( "PRECISION" ), aDimGrp ); + myPrecisionSpin = new QSpinBox( aDimGrp ); + myPrecisionSpin->setRange( 1, 100 ); + + myUnitsChk = new QCheckBox( tr( "LBL_SHOW_UNITS" ), aDimGrp ); - QGroupBox* WidthHeightGroup = new QGroupBox ( this ); - QGridLayout* WidthHeightGroupLayout = new QGridLayout( WidthHeightGroup ); - WidthHeightGroupLayout->setAlignment( Qt::AlignTop ); - WidthHeightGroupLayout->setSpacing( 6 ); - WidthHeightGroupLayout->setMargin( 11 ); - - TitleWidthSpin = new QSpinBox( WidthHeightGroup ); - TitleWidthSpin->setRange( 0, 100 ); - TitleWidthSpin->setSingleStep( 1 ); - TitleWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - TitleWidthSpin->setMinimumWidth( 70 ); - TitleWidthSpin->setValue( 0 ); - TitleWidthSpin->setSpecialValueText( tr( "AUTO" ) ); - QLabel* LabelTitleWidth = new QLabel( tr( "LBL_TITLE_W" ), WidthHeightGroup ); - LabelTitleWidth->setBuddy( TitleWidthSpin ); - - TitleHeightSpin = new QSpinBox( WidthHeightGroup ); - TitleHeightSpin->setRange( 0, 100 ); - TitleHeightSpin->setSingleStep( 1 ); - TitleHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - TitleHeightSpin->setMinimumWidth( 70 ); - TitleHeightSpin->setValue( 0 ); - TitleHeightSpin->setSpecialValueText( tr( "AUTO" ) ); - QLabel* LabelTitleHeight = new QLabel( tr( "LBL_TITLE_H" ), WidthHeightGroup ); - LabelTitleHeight->setBuddy( TitleHeightSpin ); - - CBUnits = new QCheckBox( tr( "LBL_SHOW_UNITS" ), WidthHeightGroup ); - CBUnits->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - - LabelWidthSpin = new QSpinBox( WidthHeightGroup ); - LabelWidthSpin->setRange( 0, 100 ); - LabelWidthSpin->setSingleStep( 1 ); - LabelWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - LabelWidthSpin->setMinimumWidth( 70 ); - LabelWidthSpin->setValue( 0 ); - LabelWidthSpin->setSpecialValueText( tr( "AUTO" ) ); - QLabel* LabelLabelWidth = new QLabel( tr( "LBL_LABEL_W" ), WidthHeightGroup ); - LabelLabelWidth->setBuddy( LabelWidthSpin ); - - LabelHeightSpin = new QSpinBox( WidthHeightGroup ); - LabelHeightSpin->setRange( 0, 100 ); - LabelHeightSpin->setSingleStep( 1 ); - LabelHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - LabelHeightSpin->setMinimumWidth( 70 ); - LabelHeightSpin->setValue( 0 ); - LabelHeightSpin->setSpecialValueText( tr( "AUTO" ) ); - QLabel* LabelLabelHeight = new QLabel( tr( "LBL_LABEL_H" ), WidthHeightGroup ); - LabelLabelHeight->setBuddy( LabelHeightSpin ); - - UnitsEdit = new QLineEdit( WidthHeightGroup ); - UnitsEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - UnitsEdit->setMinimumWidth( 35 ); - UnitsEdit->setText( myUnitsFormat ); - QLabel* UnitsLabel = new QLabel( tr( "LBL_UNITS_FORMAT" ), WidthHeightGroup ); - UnitsLabel->setBuddy( UnitsEdit ); - - BarWidthSpin = new QSpinBox( WidthHeightGroup ); - BarWidthSpin->setRange( 0, 100 ); - BarWidthSpin->setSingleStep( 1 ); - BarWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - BarWidthSpin->setMinimumWidth( 70 ); - BarWidthSpin->setValue( 0 ); - BarWidthSpin->setSpecialValueText( tr( "AUTO" ) ); - QLabel* LabelBarWidth = new QLabel( tr( "LBL_BAR_W" ), WidthHeightGroup ); - LabelBarWidth->setBuddy( BarWidthSpin ); - - BarHeightSpin = new QSpinBox( WidthHeightGroup ); - BarHeightSpin->setRange( 0, 100 ); - BarHeightSpin->setSingleStep( 1 ); - BarHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - BarHeightSpin->setMinimumWidth( 70 ); - BarHeightSpin->setValue( 0 ); - BarHeightSpin->setSpecialValueText( tr( "AUTO" ) ); - QLabel* LabelBarHeight = new QLabel( tr( "LBL_BAR_H" ), WidthHeightGroup ); - LabelBarHeight->setBuddy( BarHeightSpin ); - - WidthHeightGroupLayout->addWidget( LabelTitleWidth, 0, 0 ); - WidthHeightGroupLayout->addWidget( TitleWidthSpin, 0, 1 ); - WidthHeightGroupLayout->addWidget( LabelTitleHeight, 0, 2 ); - WidthHeightGroupLayout->addWidget( TitleHeightSpin, 0, 3 ); - WidthHeightGroupLayout->addWidget( CBUnits, 0, 4, 1, 2 ); - WidthHeightGroupLayout->addWidget( LabelLabelWidth, 1, 0 ); - WidthHeightGroupLayout->addWidget( LabelWidthSpin, 1, 1 ); - WidthHeightGroupLayout->addWidget( LabelLabelHeight, 1, 2 ); - WidthHeightGroupLayout->addWidget( LabelHeightSpin, 1, 3 ); - WidthHeightGroupLayout->addWidget( UnitsLabel, 1, 4 ); - WidthHeightGroupLayout->addWidget( UnitsEdit, 1, 5 ); - WidthHeightGroupLayout->addWidget( LabelBarWidth, 2, 0 ); - WidthHeightGroupLayout->addWidget( BarWidthSpin, 2, 1 ); - WidthHeightGroupLayout->addWidget( LabelBarHeight, 2, 2 ); - WidthHeightGroupLayout->addWidget( BarHeightSpin, 2, 3 ); - - TopLayout->addWidget( WidthHeightGroup ); + // layout + + aDimGrpLay->addWidget( aTitleSizeLbl, 0, 0 ); + aDimGrpLay->addWidget( myTitleSizeSpin, 0, 1 ); + aDimGrpLay->addWidget( aLabelSizeLbl, 0, 2 ); + aDimGrpLay->addWidget( myLabelSizeSpin, 0, 3 ); + aDimGrpLay->addWidget( aBarWidthLbl, 1, 0 ); + aDimGrpLay->addWidget( myBarWidthSpin, 1, 1 ); + aDimGrpLay->addWidget( aBarHeightLbl, 1, 2 ); + aDimGrpLay->addWidget( myBarHeightSpin, 1, 3 ); + aDimGrpLay->addWidget( aPrecLbl, 2, 0 ); + aDimGrpLay->addWidget( myPrecisionSpin, 2, 1 ); + aDimGrpLay->addWidget( myUnitsChk, 2, 2, 1, 2 ); + + aMainLay->addWidget( aDimGrp ); // Common buttons =========================================================== + QGroupBox* GroupButtons = new QGroupBox( this ); QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons ); GroupButtonsLayout->setAlignment( Qt::AlignTop ); @@ -393,63 +365,66 @@ VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent ) GroupButtonsLayout->addWidget( buttonCancel ); GroupButtonsLayout->addWidget( buttonHelp ); - TopLayout->addWidget( GroupButtons ); + aMainLay->addWidget( GroupButtons ); connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) ); - connect( TitleWidthSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) ); - connect( TitleHeightSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) ); - connect( LabelWidthSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) ); - connect( LabelHeightSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) ); - connect( BarWidthSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) ); - connect( BarHeightSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) ); - connect( CBUnits, SIGNAL( toggled( bool ) ), this, SIGNAL( updatePreview() ) ); - connect( UnitsEdit, SIGNAL( editingFinished() ), this, SIGNAL( updatePreview() ) ); + connect( myTitleSizeSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) ); + connect( myLabelSizeSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) ); + connect( myBarWidthSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) ); + connect( myBarHeightSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) ); + connect( myUnitsChk, SIGNAL( toggled( bool ) ), this, SIGNAL( updatePreview() ) ); + connect( myPrecisionSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) ); } //---------------------------------------------------------------------------- -void VisuGUI_BarPrefDlg::setRatios( int titleRatioWidth, int titleRatioHeight, - int labelRatioWidth, int labelRatioHeight, - int barRatioWidth, int barRatioHeight ) +void VisuGUI_BarPrefDlg::setRatios( int titleRatioSize, int labelRatioWidth, + int barRatioWidth, int barRatioHeight ) { - TitleWidthSpin->setValue( myTitleWidth = titleRatioWidth ); - TitleHeightSpin->setValue( myTitleHeight = titleRatioHeight ); - LabelWidthSpin->setValue( myLabelWidth = labelRatioWidth ); - LabelHeightSpin->setValue( myLabelHeight = labelRatioHeight ); - BarWidthSpin->setValue( myBarWidth = barRatioWidth ); - BarHeightSpin->setValue( myBarHeight = barRatioHeight ); + myTitleSizeSpin->setValue( myTitleSize = titleRatioSize ); + myLabelSizeSpin->setValue( myLabelSize = labelRatioWidth ); + myBarWidthSpin->setValue( myBarWidth = barRatioWidth ); + myBarHeightSpin->setValue( myBarHeight = barRatioHeight ); } //---------------------------------------------------------------------------- -void VisuGUI_BarPrefDlg::getRatios( int& titleRatioWidth, int& titleRatioHeight, - int& labelRatioWidth, int& labelRatioHeight, - int& barRatioWidth, int& barRatioHeight ) +void VisuGUI_BarPrefDlg::getRatios( int& titleRatioSize, int& labelRatioWidth, + int& barRatioWidth, int& barRatioHeight ) { - titleRatioWidth = TitleWidthSpin->value(); - titleRatioHeight = TitleHeightSpin->value(); - labelRatioWidth = LabelWidthSpin->value(); - labelRatioHeight = LabelHeightSpin->value(); - barRatioWidth = BarWidthSpin->value(); - barRatioHeight = BarHeightSpin->value(); + titleRatioSize = myTitleSizeSpin->value(); + labelRatioWidth = myLabelSizeSpin->value(); + barRatioWidth = myBarWidthSpin->value(); + barRatioHeight = myBarHeightSpin->value(); } //---------------------------------------------------------------------------- -void VisuGUI_BarPrefDlg::setLabelsFormat( const QString& format ) +void VisuGUI_BarPrefDlg::setLabelsPrecision( const int p ) { - UnitsEdit->setText( myUnitsFormat = format ); + myPrecisionSpin->setValue( p ); } +//---------------------------------------------------------------------------- +int VisuGUI_BarPrefDlg::getLabelsPrecision() const +{ + return myPrecisionSpin->value(); +} //---------------------------------------------------------------------------- -QString VisuGUI_BarPrefDlg::getLabelsFormat() +void VisuGUI_BarPrefDlg::setOrientation( const int ori ) { - return UnitsEdit->text(); + myOrientation = ori; } +//---------------------------------------------------------------------------- + +int VisuGUI_BarPrefDlg::getOrientation() const +{ + return myOrientation; +} //---------------------------------------------------------------------------- void VisuGUI_BarPrefDlg::onHelp() @@ -473,14 +448,14 @@ void VisuGUI_BarPrefDlg::onHelp() //---------------------------------------------------------------------------- void VisuGUI_BarPrefDlg::setUnitsVisible(bool isVisible) { - CBUnits->setChecked( myUnits = isVisible ); + myUnitsChk->setChecked( myUnits = isVisible ); } //---------------------------------------------------------------------------- bool VisuGUI_BarPrefDlg::isUnitsVisible() { - return CBUnits->isChecked(); + return myUnitsChk->isChecked(); } @@ -490,14 +465,12 @@ bool VisuGUI_BarPrefDlg::isUnitsVisible() */ void VisuGUI_BarPrefDlg::reject() { - TitleWidthSpin->setValue( myTitleWidth ); - TitleHeightSpin->setValue( myTitleHeight ); - LabelWidthSpin->setValue( myLabelWidth ); - LabelHeightSpin->setValue( myLabelHeight ); - BarWidthSpin->setValue( myBarWidth ); - BarHeightSpin->setValue( myBarHeight ); - CBUnits->setChecked( myUnits ); - UnitsEdit->setText( myUnitsFormat ); + myTitleSizeSpin->setValue( myTitleSize ); + myLabelSizeSpin->setValue( myLabelSize ); + myBarWidthSpin->setValue( myBarWidth ); + myBarHeightSpin->setValue( myBarHeight ); + myUnitsChk->setChecked( myUnits ); + myPrecisionSpin->setValue( myPrecision ); QDialog::reject(); } @@ -509,39 +482,26 @@ void VisuGUI_BarPrefDlg::reject() void VisuGUI_BarPrefDlg::accept() { QString dVal; - dVal.sprintf( UnitsEdit->text().toLatin1().data(), 1.1 ); - if ( dVal.toDouble() == 0. ) { - SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr ( "MSG_LABEL_FORMAT" ) ); + int aBWH = myOrientation == 1 ? myBarWidthSpin->value() : myBarHeightSpin->value(); + if( ( myLabelSizeSpin->value()+ aBWH ) > 100 ) + { + SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE" ) ); + return; } - else { - if( - ( - TitleWidthSpin->value()+ - LabelWidthSpin->value()+ - BarWidthSpin->value() - > 100 - ) || - ( - TitleHeightSpin->value()+ - LabelHeightSpin->value()+ - BarHeightSpin->value() - > 100 - ) - ) { - SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE" ) ); - } - else { - myTitleWidth = TitleWidthSpin->value(); - myTitleHeight = TitleHeightSpin->value(); - myLabelWidth = LabelWidthSpin->value(); - myLabelHeight = LabelHeightSpin->value(); - myBarWidth = BarWidthSpin->value(); - myBarHeight = BarHeightSpin->value(); - myUnits = CBUnits->isChecked(); - myUnitsFormat = UnitsEdit->text(); - QDialog::accept(); - } + + if ( myTitleSizeSpin->value() > 100 ) + { + SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE_TLT" ) ); + return; } + + myTitleSize = myTitleSizeSpin->value(); + myLabelSize = myLabelSizeSpin->value(); + myBarWidth = myBarWidthSpin->value(); + myBarHeight = myBarHeightSpin->value(); + myUnits = myUnitsChk->isChecked(); + myPrecision = myPrecisionSpin->value(); + QDialog::accept(); } @@ -583,10 +543,8 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.); myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.); myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.); - myVerTW = aResourceMgr->integerValue("VISU", propertyName + "title_width", 0); - myVerTH = aResourceMgr->integerValue("VISU", propertyName + "title_height",0); - myVerLW = aResourceMgr->integerValue("VISU", propertyName + "label_width", 0); - myVerLH = aResourceMgr->integerValue("VISU", propertyName + "label_height",0); + myVerTS = aResourceMgr->integerValue("VISU", propertyName + "title_size", 0); + myVerLS = aResourceMgr->integerValue("VISU", propertyName + "label_size", 0); myVerBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0); myVerBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0); @@ -595,10 +553,8 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.); myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.); myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.); - myHorTW = aResourceMgr->integerValue("VISU", propertyName + "title_width", 0); - myHorTH = aResourceMgr->integerValue("VISU", propertyName + "title_height",0); - myHorLW = aResourceMgr->integerValue("VISU", propertyName + "label_width", 0); - myHorLH = aResourceMgr->integerValue("VISU", propertyName + "label_height",0); + myHorTS = aResourceMgr->integerValue("VISU", propertyName + "title_size", 0); + myHorLS = aResourceMgr->integerValue("VISU", propertyName + "label_size", 0); myHorBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0); myHorBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0); @@ -796,12 +752,14 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) } if(RBvert->isChecked()) { - myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH); } else { - myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH); } - myBarDlg->setLabelsFormat(aResourceMgr->stringValue("VISU", propertyName + "label_format", "%-#6.3g")); + int lp = aResourceMgr->integerValue( "VISU", propertyName + "scalar_bar_label_precision", 3 ); + myBarDlg->setLabelsPrecision( lp ); + myBarDlg->setUnitsVisible(aResourceMgr->booleanValue("VISU", propertyName + "display_units", true)); // signals and slots connections =========================================== @@ -1040,24 +998,20 @@ void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs) myScalarMap->GetBarOrientation()); if(RBvert->isChecked()) { - myVerTW = myScalarMap->GetTitleWidth(); - myVerTH = myScalarMap->GetTitleHeight(); - myVerLW = myScalarMap->GetLabelWidth(); - myVerLH = myScalarMap->GetLabelHeight(); + myVerTS = myScalarMap->GetTitleSize(); + myVerLS = myScalarMap->GetLabelSize(); myVerBW = myScalarMap->GetBarWidth(); myVerBH = myScalarMap->GetBarHeight(); - myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH); } else { - myHorTW = myScalarMap->GetTitleWidth(); - myHorTH = myScalarMap->GetTitleHeight(); - myHorLW = myScalarMap->GetLabelWidth(); - myHorLH = myScalarMap->GetLabelHeight(); + myHorTS = myScalarMap->GetTitleSize(); + myHorLS = myScalarMap->GetLabelSize(); myHorBW = myScalarMap->GetBarWidth(); myHorBH = myScalarMap->GetBarHeight(); - myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH); } - myBarDlg->setLabelsFormat(myScalarMap->GetLabelsFormat()); + myBarDlg->setLabelsPrecision( VISU::ToPrecision( myScalarMap->GetLabelsFormat() ) ); myBarDlg->setUnitsVisible(myScalarMap->IsUnitsVisible()); vtkFloatingPointType R, G, B; @@ -1229,11 +1183,12 @@ void VisuGUI_ScalarBarPane::createScalarBar() (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff(); (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff(); - int VerTW, VerTH, VerLW, VerLH, VerBW, VerBH; - myBarDlg->getRatios(VerTW, VerTH, VerLW, VerLH, VerBW, VerBH); - aScalarBarActor->SetRatios(VerTW, VerTH, VerLW, VerLH, VerBW, VerBH); + int VerTS, VerTH, VerLS, VerBW, VerBH; + myBarDlg->getRatios(VerTS, VerLS, VerBW, VerBH); + aScalarBarActor->SetRatios(VerTS, VerLS, VerBW, VerBH); - aScalarBarActor->SetLabelFormat(myBarDlg->getLabelsFormat().toLatin1().data()); + std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() ); + aScalarBarActor->SetLabelFormat( f.c_str() ); aScalarBarActor->Modified(); @@ -1278,12 +1233,13 @@ int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { myScalarMap->SetPosition(XSpin->value(), YSpin->value()); myScalarMap->SetSize(WidthSpin->value(), HeightSpin->value()); if(RBvert->isChecked()) { - myScalarMap->SetRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + myScalarMap->SetRatios(myVerTS, myVerLS, myVerBW, myVerBH); } else { - myScalarMap->SetRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + myScalarMap->SetRatios(myHorTS, myHorLS, myHorBW, myHorBH); } - myScalarMap->SetLabelsFormat(myBarDlg->getLabelsFormat().toLatin1().data()); + std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() ); + myScalarMap->SetLabelsFormat( f.c_str() ); myScalarMap->SetUnitsVisible(myBarDlg->isUnitsVisible()); myScalarMap->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3dBase::VERTICAL : VISU::ColoredPrs3dBase::HORIZONTAL); @@ -1655,14 +1611,15 @@ void VisuGUI_ScalarBarPane::onTextPref() void VisuGUI_ScalarBarPane::onBarPref() { if(RBvert->isChecked()) - myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH); else - myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH); + myBarDlg->setOrientation( getOrientation() ); if(myBarDlg->exec()) { if(RBvert->isChecked()) - myBarDlg->getRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH); + myBarDlg->getRatios(myVerTS, myVerLS, myVerBW, myVerBH); else - myBarDlg->getRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH); + myBarDlg->getRatios(myHorTS, myHorLS, myHorBW, myHorBH); updatePreview(); } } diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.h b/src/VISUGUI/VisuGUI_Prs3dDlg.h index 676487f7..0acefb0c 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.h +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.h @@ -105,18 +105,20 @@ class VisuGUI_BarPrefDlg: public QDialog VisuGUI_BarPrefDlg (QWidget* parent); ~VisuGUI_BarPrefDlg() {}; - void setRatios(int titleRatioWidth, int titleRatioHeight, - int labelRatioWidth, int labelRatioHeight, + void setRatios(int titleRatioSize, int labelRatioWidth, int barRatioWidth, int barRatioHeight); - void getRatios(int& titleRatioWidth, int& titleRatioHeight, - int& labelRatioWidth, int& labelRatioHeight, + void getRatios(int& titleRatioSize, int& labelRatioWidth, int& barRatioWidth, int& barRatioHeight); void setUnitsVisible(bool isVisible); bool isUnitsVisible(); - void setLabelsFormat( const QString& format); - QString getLabelsFormat(); + void setLabelsPrecision( const int p ); + int getLabelsPrecision() const; + + void setOrientation( const int ori ); + int getOrientation() const; + private: void keyPressEvent( QKeyEvent* e ); @@ -130,23 +132,20 @@ class VisuGUI_BarPrefDlg: public QDialog void onHelp(); protected: - QSpinBox* TitleWidthSpin; - QSpinBox* TitleHeightSpin; - QSpinBox* LabelWidthSpin; - QSpinBox* LabelHeightSpin; - QSpinBox* BarWidthSpin; - QSpinBox* BarHeightSpin; - QCheckBox* CBUnits; - QLineEdit* UnitsEdit; - - int myTitleWidth; - int myTitleHeight; - int myLabelWidth; - int myLabelHeight; + QSpinBox* myTitleSizeSpin; + QSpinBox* myLabelSizeSpin; + QSpinBox* myBarWidthSpin; + QSpinBox* myBarHeightSpin; + QCheckBox* myUnitsChk; + QSpinBox* myPrecisionSpin; + + int myTitleSize; + int myLabelSize; int myBarWidth; int myBarHeight; bool myUnits; - QString myUnitsFormat; + int myPrecision; + int myOrientation; }; @@ -219,8 +218,8 @@ class VisuGUI_ScalarBarPane : public QWidget//QVBox double myHorX, myHorY, myHorW, myHorH; double myVerX, myVerY, myVerW, myVerH; - int myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH; - int myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH; + int myHorTS, myHorLS, myHorBW, myHorBH; + int myVerTS, myVerTH, myVerLS, myVerBW, myVerBH; bool myIsStoreTextProp; private slots: diff --git a/src/VISUGUI/VisuGUI_Table3dDlg.cxx b/src/VISUGUI/VisuGUI_Table3dDlg.cxx index 72d1ca18..9bae09a8 100644 --- a/src/VISUGUI/VisuGUI_Table3dDlg.cxx +++ b/src/VISUGUI/VisuGUI_Table3dDlg.cxx @@ -32,6 +32,7 @@ #include "VISU_ColoredPrs3dFactory.hh" #include "VISU_ViewManager_i.hh" +#include "VISU_Prs3dUtils.hh" #include #include @@ -196,10 +197,8 @@ VisuGUI_TableScalarBarPane::VisuGUI_TableScalarBarPane( QWidget* parent ) myVerY = aResourceMgr->doubleValue( "VISU", propertyName + "y", 0. ); myVerW = aResourceMgr->doubleValue( "VISU", propertyName + "width", 0. ); myVerH = aResourceMgr->doubleValue( "VISU", propertyName + "height", 0. ); - myVerTW = aResourceMgr->integerValue( "VISU", propertyName + "title_width", 0 ); - myVerTH = aResourceMgr->integerValue( "VISU", propertyName + "title_height", 0 ); - myVerLW = aResourceMgr->integerValue( "VISU", propertyName + "label_width", 0 ); - myVerLH = aResourceMgr->integerValue( "VISU", propertyName + "label_height", 0 ); + myVerTS = aResourceMgr->integerValue( "VISU", propertyName + "title_size", 0 ); + myVerLS = aResourceMgr->integerValue( "VISU", propertyName + "label_size", 0 ); myVerBW = aResourceMgr->integerValue( "VISU", propertyName + "bar_width", 0 ); myVerBH = aResourceMgr->integerValue( "VISU", propertyName + "bar_height", 0 ); @@ -208,10 +207,8 @@ VisuGUI_TableScalarBarPane::VisuGUI_TableScalarBarPane( QWidget* parent ) myHorY = aResourceMgr->doubleValue( "VISU", propertyName + "y", 0. ); myHorW = aResourceMgr->doubleValue( "VISU", propertyName + "width", 0. ); myHorH = aResourceMgr->doubleValue( "VISU", propertyName + "height", 0. ); - myHorTW = aResourceMgr->integerValue( "VISU", propertyName + "title_width", 0 ); - myHorTH = aResourceMgr->integerValue( "VISU", propertyName + "title_height", 0 ); - myHorLW = aResourceMgr->integerValue( "VISU", propertyName + "label_width", 0 ); - myHorLH = aResourceMgr->integerValue( "VISU", propertyName + "label_height", 0 ); + myHorTS = aResourceMgr->integerValue( "VISU", propertyName + "title_size", 0 ); + myHorLS = aResourceMgr->integerValue( "VISU", propertyName + "label_size", 0 ); myHorBW = aResourceMgr->integerValue( "VISU", propertyName + "bar_width", 0 ); myHorBH = aResourceMgr->integerValue( "VISU", propertyName + "bar_height", 0 ); @@ -356,12 +353,14 @@ VisuGUI_TableScalarBarPane::VisuGUI_TableScalarBarPane( QWidget* parent ) myBarDlg = new VisuGUI_BarPrefDlg( this ); if ( RBvert->isChecked() ) { - myBarDlg->setRatios( myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH ); + myBarDlg->setRatios( myVerTS, myVerLS, myVerBW, myVerBH ); } else { - myBarDlg->setRatios( myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH ); + myBarDlg->setRatios( myHorTS, myHorLS, myHorBW, myHorBH ); } - myBarDlg->setLabelsFormat( aResourceMgr->stringValue( "VISU", propertyName + "label_format", "%-#6.3g" ) ); + int lp = aResourceMgr->integerValue( "VISU", propertyName + "scalar_bar_label_precision", 3 ); + myBarDlg->setLabelsPrecision( lp ); + myBarDlg->setUnitsVisible( aResourceMgr->booleanValue( "VISU", propertyName + "display_units", true ) ); // signals and slots connections =========================================== @@ -381,14 +380,14 @@ VisuGUI_TableScalarBarPane::VisuGUI_TableScalarBarPane( QWidget* parent ) void VisuGUI_TableScalarBarPane::onBarPref() { if ( RBvert->isChecked() ) - myBarDlg->setRatios( myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH ); + myBarDlg->setRatios( myVerTS, myVerLS, myVerBW, myVerBH ); else - myBarDlg->setRatios( myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH ); + myBarDlg->setRatios( myHorTS, myHorLS, myHorBW, myHorBH ); if ( myBarDlg->exec() ) { if ( RBvert->isChecked() ) - myBarDlg->getRatios( myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH ); + myBarDlg->getRatios( myVerTS, myVerLS, myVerBW, myVerBH ); else - myBarDlg->getRatios( myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH ); + myBarDlg->getRatios( myHorTS, myHorLS, myHorBW, myHorBH ); } } @@ -429,15 +428,13 @@ void VisuGUI_TableScalarBarPane::initFromPrsObject( VISU::PointMap3d_i* thePrs ) myBarPrs->GetHeight(), myBarPrs->GetBarOrientation() ); - myVerTW = myBarPrs->GetTitleWidth(); - myVerTH = myBarPrs->GetTitleHeight(); - myVerLW = myBarPrs->GetLabelWidth(); - myVerLH = myBarPrs->GetLabelHeight(); + myVerTS = myBarPrs->GetTitleSize(); + myVerLS = myBarPrs->GetLabelSize(); myVerBW = myBarPrs->GetBarWidth(); myVerBH = myBarPrs->GetBarHeight(); - myBarDlg->setRatios( myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH ); + myBarDlg->setRatios( myVerTS, myVerLS, myVerBW, myVerBH ); - myBarDlg->setLabelsFormat( myBarPrs->GetLabelsFormat() ); + myBarDlg->setLabelsPrecision( VISU::ToPrecision( myBarPrs->GetLabelsFormat() ) ); myBarDlg->setUnitsVisible( myBarPrs->IsUnitsVisible() ); myTextDlg->myTitleFont->SetData( QColor( (int)(R*255.), (int)(G*255.), (int)(B*255.) ), @@ -467,9 +464,14 @@ int VisuGUI_TableScalarBarPane::storeToPrsObject( VISU::PointMap3d_i* thePrs ) { myBarPrs->SetPosition( XSpin->value(), YSpin->value() ); myBarPrs->SetSize( WidthSpin->value(), HeightSpin->value() ); - myBarPrs->SetRatios( myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH ); + if(RBvert->isChecked()) { + myBarPrs->SetRatios(myVerTS, myVerLS, myVerBW, myVerBH); + } else { + myBarPrs->SetRatios(myHorTS, myHorLS, myHorBW, myHorBH); + } - myBarPrs->SetLabelsFormat( myBarDlg->getLabelsFormat().toLatin1().constData() ); + std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() ); + myBarPrs->SetLabelsFormat( f.c_str() ); myBarPrs->SetUnitsVisible( myBarDlg->isUnitsVisible() ); myBarPrs->SetBarOrientation( ( RBvert->isChecked() )? VISU::ColoredPrs3dBase::VERTICAL : VISU::ColoredPrs3dBase::HORIZONTAL ); diff --git a/src/VISUGUI/VisuGUI_Table3dDlg.h b/src/VISUGUI/VisuGUI_Table3dDlg.h index 2257b483..56c339e5 100644 --- a/src/VISUGUI/VisuGUI_Table3dDlg.h +++ b/src/VISUGUI/VisuGUI_Table3dDlg.h @@ -149,8 +149,8 @@ private: double myHorX, myHorY, myHorW, myHorH; double myVerX, myVerY, myVerW, myVerH; - int myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH; - int myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH; + int myHorTS, myHorLS, myHorBW, myHorBH; + int myVerTS, myVerLS, myVerBW, myVerBH; bool myIsStoreTextProp; std::string myTitle;