X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_Preferences_ScalarBarDlg.cxx;h=b17a523ebf13201b94c125bbb9947ae3da79ca93;hb=ffd567ddfa3eae0e41303e5c462c3bbe66065e32;hp=c8da7c26f4463a533f0ffa2fac0c052cecc7d433;hpb=c75bbbb996e0fbfc37b71b5a1da53f8029ced841;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx index c8da7c26f..b17a523eb 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -37,7 +37,7 @@ #include "SUIT_Desktop.h" #include "SUIT_ResourceMgr.h" -#include "SalomeApp_SelectionMgr.h" +#include "LightApp_SelectionMgr.h" #include "SALOME_ListIO.hxx" #include @@ -58,21 +58,12 @@ #include #include -#include +#include #define MINIMUM_WIDTH 70 #define MARGIN_SIZE 11 #define SPACING_SIZE 6 -#define DEF_VER_X 0.01 -#define DEF_VER_Y 0.10 -#define DEF_VER_H 0.80 -#define DEF_VER_W 0.10 -#define DEF_HOR_X 0.20 -#define DEF_HOR_Y 0.01 -#define DEF_HOR_H 0.12 -#define DEF_HOR_W 0.60 - using namespace std; // Only one instance is allowed @@ -125,6 +116,14 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* mySMESHGUI( theModule ), mySelectionMgr( property ? SMESH::GetSelectionMgr( theModule ) : 0 ) { + DEF_VER_X = 0.01; + DEF_VER_Y = 0.10; + DEF_VER_H = 0.80; + DEF_VER_W = 0.10; + DEF_HOR_X = 0.20; + DEF_HOR_Y = 0.01; + DEF_HOR_H = 0.12; + DEF_HOR_W = 0.60; setName("SMESHGUI_Preferences_ScalarBarDlg"); setCaption( property ? tr("SMESH_PROPERTIES_SCALARBAR") : tr("SMESH_PREFERENCES_SCALARBAR")); setSizeGripEnabled(TRUE); @@ -174,6 +173,7 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* myFontGrpLayout->setSpacing( SPACING_SIZE ); myFontGrpLayout->setMargin( MARGIN_SIZE ); myTitleColorBtn = new QToolButton( myFontGrp, "myTitleColorBtn" ); + myTitleColorBtn->setMinimumWidth( 20 ); myTitleFontCombo = new QComboBox( false, myFontGrp, "myTitleFontCombo" ); myTitleFontCombo->setMinimumWidth( MINIMUM_WIDTH ); @@ -187,6 +187,7 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* myTitleShadowCheck = new QCheckBox( tr( "SMESH_FONT_SHADOW" ), myFontGrp, "myTitleShadowCheck" ); myLabelsColorBtn = new QToolButton( myFontGrp, "myLabelsColorBtn" ); + myLabelsColorBtn->setMinimumWidth( 20 ); myLabelsFontCombo = new QComboBox( false, myFontGrp, "myLabelsFontCombo" ); myLabelsFontCombo->setMinimumWidth( MINIMUM_WIDTH ); @@ -519,7 +520,11 @@ bool SMESHGUI_Preferences_ScalarBarDlg::onApply() double aMin = myMinEdit->text().toDouble(); double aMax = myMaxEdit->text().toDouble(); - myScalarBarActor->GetLookupTable()->SetRange( aMin, aMax ); + vtkLookupTable* myLookupTable = + static_cast(myScalarBarActor->GetLookupTable()); + myLookupTable->SetRange( aMin, aMax ); + myLookupTable->SetNumberOfTableValues(myColorsSpin->value()); + myLookupTable->Build(); SMESH::RepaintCurrentView(); } else { // Scalar Bar preferences @@ -635,13 +640,13 @@ void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged() vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor(); if ( myScalarBarActor->GetLookupTable() ) { - float *range = myScalarBarActor->GetLookupTable()->GetRange(); - myMinEdit->setText( QString::number( range[0] ) ); - myMaxEdit->setText( QString::number( range[1] ) ); + vtkFloatingPointType *range = myScalarBarActor->GetLookupTable()->GetRange(); + myMinEdit->setText( QString::number( range[0],'g',12 ) ); + myMaxEdit->setText( QString::number( range[1],'g',12 ) ); } vtkTextProperty* aTitleTextPrp = myScalarBarActor->GetTitleTextProperty(); - float aTColor[3]; + vtkFloatingPointType aTColor[3]; aTitleTextPrp->GetColor( aTColor ); myTitleColorBtn->setPaletteBackgroundColor( QColor( (int)( aTColor[0]*255 ), (int)( aTColor[1]*255 ), (int)( aTColor[2]*255 ) ) ); myTitleFontCombo->setCurrentItem( aTitleTextPrp->GetFontFamily() ); @@ -650,7 +655,7 @@ void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged() myTitleShadowCheck->setChecked( aTitleTextPrp->GetShadow() ); vtkTextProperty* aLabelsTextPrp = myScalarBarActor->GetLabelTextProperty(); - float aLColor[3]; + vtkFloatingPointType aLColor[3]; aLabelsTextPrp->GetColor( aLColor ); myLabelsColorBtn->setPaletteBackgroundColor( QColor( (int)( aLColor[0]*255 ), (int)( aLColor[1]*255 ), (int)( aLColor[2]*255 ) ) ); myLabelsFontCombo->setCurrentItem( aLabelsTextPrp->GetFontFamily() ); @@ -754,6 +759,8 @@ void SMESHGUI_Preferences_ScalarBarDlg::setOriginAndSize( const double x, //================================================================================================= void SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged() { + this->initScalarBarFromResources(); + int aOrientation = myVertRadioBtn->isChecked(); if ( aOrientation == myIniOrientation ) setOriginAndSize( myIniX, myIniY, myIniW, myIniH ); @@ -763,3 +770,41 @@ void SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged() aOrientation ? DEF_VER_W : DEF_HOR_W, aOrientation ? DEF_VER_H : DEF_HOR_H ); } + +//================================================================================================= +/*! + * SMESHGUI_Preferences_ScalarBarDlg::initScalarBarFromResources() + * + * Rereading vertical and horizontal default positions from resources. + */ +//================================================================================================= +void SMESHGUI_Preferences_ScalarBarDlg::initScalarBarFromResources() +{ + SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); + QString name; + if (mgr){ + // initialize from resoources + + // horizontal + name = QString("scalar_bar_horizontal_%1"); + if (mgr->hasValue("SMESH", name.arg( "x" ))) + DEF_HOR_X = mgr->doubleValue("SMESH", name.arg( "x" )); + if (mgr->hasValue("SMESH", name.arg( "y" ))) + DEF_HOR_Y = mgr->doubleValue("SMESH", name.arg( "y" )); + if (mgr->hasValue("SMESH", name.arg( "width" ))) + DEF_HOR_W = mgr->doubleValue("SMESH", name.arg( "width" )); + if (mgr->hasValue("SMESH", name.arg( "height" ))) + DEF_HOR_H = mgr->doubleValue("SMESH", name.arg( "height" )); + + // vertical + name = QString("scalar_bar_vertical_%1"); + if (mgr->hasValue("SMESH", name.arg( "x" ))) + DEF_VER_X = mgr->doubleValue("SMESH", name.arg( "x" )); + if (mgr->hasValue("SMESH", name.arg( "y" ))) + DEF_VER_Y = mgr->doubleValue("SMESH", name.arg( "y" )); + if (mgr->hasValue("SMESH", name.arg( "width" ))) + DEF_VER_W = mgr->doubleValue("SMESH", name.arg( "width" )); + if (mgr->hasValue("SMESH", name.arg( "height" ))) + DEF_VER_H = mgr->doubleValue("SMESH", name.arg( "height" )); + } +}