X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_Preferences_ScalarBarDlg.cxx;h=7e64eb06c7f02180bb99688361c5876dec617e8e;hp=a6d44e57a2c9ccb6c1b3e83add38bc754a5d7e99;hb=44d75c1021a72e6c0880f70c26348d021fdf699d;hpb=0635c9fc80f67d1e5dc0e94ec85f487286a92070 diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx index a6d44e57a..7e64eb06c 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx @@ -1,36 +1,41 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // SMESH SMESHGUI : GUI for SMESH component // File : SMESHGUI_Preferences_ScalarBarDlg.cxx // Author : Nicolas REJNERI, Open CASCADE S.A.S. // SMESH includes -// + #include "SMESHGUI_Preferences_ScalarBarDlg.h" #include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_Utils.h" #include +#include +#include +#include // SALOME GUI includes #include @@ -41,8 +46,8 @@ #include #include #include +#include -#include #include // Qt includes @@ -54,7 +59,6 @@ #include #include #include -#include #include #include #include @@ -62,7 +66,6 @@ // VTK includes #include -#include #include #define MINIMUM_WIDTH 70 @@ -127,22 +130,28 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* /******************************************************************************/ // Scalar range myRangeGrp = new QGroupBox ( tr( "SMESH_RANGE_SCALARBAR" ), this ); - QHBoxLayout* myRangeGrpLayout = new QHBoxLayout( myRangeGrp ); + //QHBoxLayout* myRangeGrpLayout = new QHBoxLayout( myRangeGrp ); + QGridLayout* myRangeGrpLayout = new QGridLayout( myRangeGrp ); myRangeGrpLayout->setSpacing( SPACING_SIZE ); myRangeGrpLayout->setMargin( MARGIN_SIZE ); - + myMinEdit = new QLineEdit( myRangeGrp ); myMinEdit->setMinimumWidth( MINIMUM_WIDTH ); myMinEdit->setValidator( new QDoubleValidator( this ) ); - + myMaxEdit = new QLineEdit( myRangeGrp ); myMaxEdit->setMinimumWidth( MINIMUM_WIDTH ); myMaxEdit->setValidator( new QDoubleValidator( this ) ); - - myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MIN" ), myRangeGrp ) ); - myRangeGrpLayout->addWidget( myMinEdit ); - myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MAX" ), myRangeGrp ) ); - myRangeGrpLayout->addWidget( myMaxEdit ); - + + myLogarithmicCheck = new QCheckBox (myRangeGrp); + myLogarithmicCheck->setText(tr("SMESH_LOGARITHMIC_SCALARBAR")); + myLogarithmicCheck->setChecked(false); + + myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MIN" ), myRangeGrp ), 0, 0, 1, 1 ); + myRangeGrpLayout->addWidget( myMinEdit, 0, 1, 1, 1 ); + myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MAX" ), myRangeGrp ), 0, 2, 1, 1 ); + myRangeGrpLayout->addWidget( myMaxEdit, 0, 3, 1, 1 ); + myRangeGrpLayout->addWidget( myLogarithmicCheck, 1, 0, 1, 4 ); + aTopLayout->addWidget( myRangeGrp ); /******************************************************************************/ @@ -199,13 +208,15 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* QHBoxLayout* myLabColorGrpLayout = new QHBoxLayout( myLabColorGrp ); myLabColorGrpLayout->setSpacing( SPACING_SIZE ); myLabColorGrpLayout->setMargin( MARGIN_SIZE ); - myColorsSpin = new QSpinBox( myLabColorGrp ); + myColorsSpin = new SalomeApp_IntSpinBox( myLabColorGrp ); + myColorsSpin->setAcceptNames( false ); // No Notebook variables allowed myColorsSpin->setRange( 2, 256 ); myColorsSpin->setSingleStep( 1 ); myColorsSpin->setMinimumWidth( MINIMUM_WIDTH ); myColorsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myLabelsSpin = new QSpinBox( myLabColorGrp ); + myLabelsSpin = new SalomeApp_IntSpinBox( myLabColorGrp ); + myLabelsSpin->setAcceptNames( false ); // No Notebook variables allowed myLabelsSpin->setRange( 2, 65 ); myLabelsSpin->setSingleStep( 1 ); myLabelsSpin->setMinimumWidth( MINIMUM_WIDTH ); @@ -242,19 +253,27 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* QGridLayout* myOriginDimGrpLayout = new QGridLayout( myOriginDimGrp ); myOriginDimGrpLayout->setSpacing( SPACING_SIZE ); myOriginDimGrpLayout->setMargin( MARGIN_SIZE ); - myXSpin = new QtxDoubleSpinBox (0.0, 1.0, 0.1, myOriginDimGrp); + myXSpin = new SMESHGUI_SpinBox(myOriginDimGrp); + myXSpin->setAcceptNames( false ); + myXSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" ); myXSpin->setMinimumWidth( MINIMUM_WIDTH ); myXSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myYSpin = new QtxDoubleSpinBox(0.0, 1.0, 0.1, myOriginDimGrp); + myYSpin = new SMESHGUI_SpinBox(myOriginDimGrp); + myYSpin->setAcceptNames( false ); + myYSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" ); myYSpin->setMinimumWidth( MINIMUM_WIDTH ); myYSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myWidthSpin = new QtxDoubleSpinBox(0.0, 1.0, 0.1, myOriginDimGrp); + myWidthSpin = new SMESHGUI_SpinBox(myOriginDimGrp); + myWidthSpin->setAcceptNames( false ); + myWidthSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" ); myWidthSpin->setMinimumWidth( MINIMUM_WIDTH ); myWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myHeightSpin = new QtxDoubleSpinBox(0.0, 1.0, 0.1, myOriginDimGrp); + myHeightSpin = new SMESHGUI_SpinBox(myOriginDimGrp); + myHeightSpin->setAcceptNames( false ); + myHeightSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" ); myHeightSpin->setMinimumWidth( MINIMUM_WIDTH ); myHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); @@ -268,8 +287,35 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* myOriginDimGrpLayout->addWidget( myHeightSpin, 1, 3 ); aTopLayout->addWidget( myOriginDimGrp ); + /******************************************************************************/ - /***************************************************************/ + // Destribution + myDistributionGrp = new QGroupBox ( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), this ); + myDistributionGrp->setCheckable(true); + QHBoxLayout* aDistributionGrpLayout = new QHBoxLayout( myDistributionGrp ); + aDistributionGrpLayout->setSpacing( SPACING_SIZE ); aDistributionGrpLayout->setMargin( MARGIN_SIZE ); + + myDistribColorGrp = new QButtonGroup( this ); + + myDMonoColor = new QRadioButton( tr( "SMESH_MONOCOLOR" ) , myDistributionGrp ); + myDMultiColor = new QRadioButton( tr( "SMESH_MULTICOLOR" ), myDistributionGrp ); + myDMonoColor->setChecked( true ); + + myDistribColorGrp->addButton(myDMonoColor);myDistribColorGrp->setId(myDMonoColor,1); + myDistribColorGrp->addButton(myDMultiColor);myDistribColorGrp->setId(myDMultiColor,2); + + aDistributionGrpLayout->addWidget( myDMultiColor ); + aDistributionGrpLayout->addWidget( myDMonoColor ); + + //Color of the Distribution in monocolor case: + myDistributionColorLbl = new QLabel( tr( "SMESH_DISTRIBUTION_COLOR" ), myDistributionGrp ); + aDistributionGrpLayout->addWidget( myDistributionColorLbl ); + myMonoColorBtn = new QtxColorButton( myDistributionGrp ); + aDistributionGrpLayout->addWidget(myMonoColorBtn); + + aTopLayout->addWidget(myDistributionGrp); + + /******************************************************************************/ // Common buttons myButtonGrp = new QGroupBox( this ); QHBoxLayout* myButtonGrpLayout = new QHBoxLayout( myButtonGrp ); @@ -300,7 +346,7 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); QColor titleColor = mgr->colorValue("SMESH", "scalar_bar_title_color", - QColor(255, 255, 255)); + QColor(255, 255, 255)); myTitleColorBtn->setColor(titleColor); myTitleFontCombo->setCurrentIndex(0); if (mgr->hasValue("SMESH", "scalar_bar_title_font")) { @@ -311,14 +357,14 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* myTitleFontCombo->setCurrentIndex(1); if( f.family()=="Times") myTitleFontCombo->setCurrentIndex(2); - + myTitleBoldCheck->setChecked ( f.bold() ); myTitleItalicCheck->setChecked( f.italic() ); myTitleShadowCheck->setChecked( f.overline() ); } - - QColor labelColor = mgr->colorValue("SMESH", "scalar_bar_label_color", - QColor(255, 255, 255)); + + QColor labelColor = mgr->colorValue("SMESH", "scalar_bar_label_color", + QColor(255, 255, 255)); myLabelsColorBtn->setColor(labelColor); myLabelsFontCombo->setCurrentIndex(0); if (mgr->hasValue("SMESH", "scalar_bar_label_font")) { @@ -329,7 +375,7 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* myLabelsFontCombo->setCurrentIndex(1); if (f.family() == "Times") myLabelsFontCombo->setCurrentIndex(2); - + myLabelsBoldCheck ->setChecked( f.bold() ); myLabelsItalicCheck->setChecked( f.italic() ); myLabelsShadowCheck->setChecked( f.overline() ); @@ -351,20 +397,38 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* QString name = isHoriz ? "scalar_bar_horizontal_%1" : "scalar_bar_vertical_%1"; - myIniX = mgr->doubleValue("SMESH", name.arg( "x" ), - myHorizRadioBtn->isChecked() ? DEF_HOR_X : DEF_VER_X); + myIniX = mgr->doubleValue("SMESH", name.arg( "x" ), + myHorizRadioBtn->isChecked() ? DEF_HOR_X : DEF_VER_X); myIniY = mgr->doubleValue("SMESH", name.arg( "y" ), - myHorizRadioBtn->isChecked() ? DEF_HOR_Y : DEF_VER_Y); + myHorizRadioBtn->isChecked() ? DEF_HOR_Y : DEF_VER_Y); myIniW = mgr->doubleValue("SMESH", name.arg( "width" ), - myHorizRadioBtn->isChecked() ? DEF_HOR_W : DEF_VER_W); + myHorizRadioBtn->isChecked() ? DEF_HOR_W : DEF_VER_W); myIniH = mgr->doubleValue("SMESH", name.arg( "height" ), - myHorizRadioBtn->isChecked() ? DEF_HOR_H : DEF_VER_H); + myHorizRadioBtn->isChecked() ? DEF_HOR_H : DEF_VER_H); setOriginAndSize(myIniX, myIniY, myIniW, myIniH); + + bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility"); + myDistributionGrp->setChecked(distributionVisibility); + + int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0); + if( coloringType == SMESH_MONOCOLOR_TYPE ) { + myDMonoColor->setChecked(true); + onDistributionChanged(myDistribColorGrp->id(myDMonoColor)); + } else { + myDMultiColor->setChecked(true); + onDistributionChanged(myDistribColorGrp->id(myDMultiColor)); + + } + + QColor distributionColor = mgr->colorValue("SMESH", "distribution_color", + QColor(255, 255, 255)); + myMonoColorBtn->setColor(distributionColor); + // --> then init from selection if necessary onSelectionChanged(); @@ -372,15 +436,19 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* // Connect section connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( onOk() ) ); connect( myApplyBtn, SIGNAL( clicked() ), this, SLOT( onApply() ) ); - connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( onCancel() ) ); + connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( myHelpBtn, SIGNAL(clicked()), this, SLOT( onHelp() ) ); + connect( myMinEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( onMinMaxChanged() ) ); + connect( myMaxEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( onMinMaxChanged() ) ); connect( myXSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) ); connect( myYSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) ); connect( aOrientationGrp, SIGNAL( buttonClicked( int ) ), this, SLOT( onOrientationChanged() ) ); + connect( myDistributionGrp, SIGNAL( toggled(bool) ), this, SLOT(onDistributionActivated(bool)) ); + connect( myDistribColorGrp, SIGNAL( buttonClicked( int ) ), this, SLOT( onDistributionChanged( int ) ) ); connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); - connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onCancel() ) ); + connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( reject() ) ); - myHelpFileName = "about_quality_controls_page.html"; + myHelpFileName = "quality_page.html"; } //================================================================================================= @@ -404,7 +472,7 @@ SMESHGUI_Preferences_ScalarBarDlg::~SMESHGUI_Preferences_ScalarBarDlg() void SMESHGUI_Preferences_ScalarBarDlg::onOk() { if ( onApply() ) - onCancel(); + reject(); } //================================================================================================= @@ -419,7 +487,7 @@ bool SMESHGUI_Preferences_ScalarBarDlg::onApply() // Scalar Bar properties if (!myActor) return false; - vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor(); + SMESH_ScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor(); vtkTextProperty* aTitleTextPrp = myScalarBarActor->GetTitleTextProperty(); QColor aTColor = myTitleColorBtn->color(); @@ -450,7 +518,6 @@ bool SMESHGUI_Preferences_ScalarBarDlg::onApply() myScalarBarActor->SetLabelTextProperty( aLabelsTextPrp ); myScalarBarActor->SetNumberOfLabels( myLabelsSpin->value() ); - myScalarBarActor->SetMaximumNumberOfColors( myColorsSpin->value() ); if ( myHorizRadioBtn->isChecked() ) myScalarBarActor->SetOrientationToHorizontal(); @@ -461,27 +528,76 @@ bool SMESHGUI_Preferences_ScalarBarDlg::onApply() myScalarBarActor->SetWidth( myWidthSpin->value() ); myScalarBarActor->SetHeight( myHeightSpin->value() ); + // Distribution + bool distributionTypeChanged = false, colorChanged=false; + myScalarBarActor->SetDistributionVisibility((int)myDistributionGrp->isChecked()); + if( myDistributionGrp->isChecked() ) { + int ColoringType = myDMultiColor->isChecked() ? SMESH_MULTICOLOR_TYPE : SMESH_MONOCOLOR_TYPE; + distributionTypeChanged = (ColoringType != myScalarBarActor->GetDistributionColoringType()); + if (distributionTypeChanged) + myScalarBarActor->SetDistributionColoringType(ColoringType); + + if( !myDMultiColor->isChecked() ) { + QColor aTColor = myMonoColorBtn->color(); + double rgb[3], oldRgb[3];; + rgb [0] = aTColor.red()/255.; + rgb [1] = aTColor.green()/255.; + rgb [2] = aTColor.blue()/255.; + myScalarBarActor->GetDistributionColor(oldRgb); + colorChanged = (rgb[0] != oldRgb[0] || rgb[1] != oldRgb[1] || rgb[2] != oldRgb[2]); + if(colorChanged) + myScalarBarActor->SetDistributionColor(rgb); + } + } + double aMin = myMinEdit->text().toDouble(); double aMax = myMaxEdit->text().toDouble(); vtkLookupTable* myLookupTable = static_cast(myScalarBarActor->GetLookupTable()); + double oldMinMax[2] = { myLookupTable->GetRange()[0], myLookupTable->GetRange()[1] }; + bool rangeChanges = ( fabs( oldMinMax[0] - aMin ) + fabs( oldMinMax[1] - aMax ) > + 0.001 * ( aMax-aMin + oldMinMax[1]-oldMinMax[0] )); + + bool nbColorsChanged = (myColorsSpin->value() != myScalarBarActor->GetMaximumNumberOfColors()); + if(nbColorsChanged) + myScalarBarActor->SetMaximumNumberOfColors(myColorsSpin->value()); + myLookupTable->SetRange( aMin, aMax ); myLookupTable->SetNumberOfTableValues(myColorsSpin->value()); + + bool scaleChanged = (myLogarithmicCheck->isChecked() != (myLookupTable->GetScale() == VTK_SCALE_LOG10)); + if (scaleChanged) + myLookupTable->SetScale(myLogarithmicCheck->isChecked() ? VTK_SCALE_LOG10 : VTK_SCALE_LINEAR); + myLookupTable->Build(); + + if (nbColorsChanged || rangeChanges || scaleChanged) + myActor->UpdateDistribution(); + +#ifndef DISABLE_PLOT2DVIEWER + if( myActor->GetPlot2Histogram() && + (nbColorsChanged || + rangeChanges || + distributionTypeChanged || + colorChanged )) + SMESH::ProcessIn2DViewers(myActor); +#endif + SMESH::RepaintCurrentView(); return true; } //================================================================================================= /*! - * SMESHGUI_Preferences_ScalarBarDlg::onCancel + * SMESHGUI_Preferences_ScalarBarDlg::reject * * Cancel button slot */ //================================================================================================= -void SMESHGUI_Preferences_ScalarBarDlg::onCancel() +void SMESHGUI_Preferences_ScalarBarDlg::reject() { - close(); + myDlg = 0; + QDialog::reject(); } //================================================================================================= @@ -494,7 +610,7 @@ void SMESHGUI_Preferences_ScalarBarDlg::onCancel() void SMESHGUI_Preferences_ScalarBarDlg::onHelp() { LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); - if (app) + if (app) app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName); else { QString platform; @@ -504,10 +620,10 @@ void SMESHGUI_Preferences_ScalarBarDlg::onHelp() platform = "application"; #endif SUIT_MessageBox::warning(this, tr("WRN_WARNING"), - tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). - arg(app->resourceMgr()->stringValue("ExternalBrowser", - platform)). - arg(myHelpFileName)); + tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", + platform)). + arg(myHelpFileName)); } } @@ -528,56 +644,75 @@ void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged() if( anIO->hasEntry() ) { SMESH_Actor* anActor = SMESH::FindActorByEntry(anIO->getEntry()); if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) { - myActor = anActor; - vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor(); - - if ( myScalarBarActor->GetLookupTable() ) { - 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(); - vtkFloatingPointType aTColor[3]; - aTitleTextPrp->GetColor( aTColor ); - myTitleColorBtn->setColor( QColor( (int)( aTColor[0]*255 ), (int)( aTColor[1]*255 ), (int)( aTColor[2]*255 ) ) ); - myTitleFontCombo->setCurrentIndex( aTitleTextPrp->GetFontFamily() ); - myTitleBoldCheck->setChecked( aTitleTextPrp->GetBold() ); - myTitleItalicCheck->setChecked( aTitleTextPrp->GetItalic() ); - myTitleShadowCheck->setChecked( aTitleTextPrp->GetShadow() ); - - vtkTextProperty* aLabelsTextPrp = myScalarBarActor->GetLabelTextProperty(); - vtkFloatingPointType aLColor[3]; - aLabelsTextPrp->GetColor( aLColor ); - myLabelsColorBtn->setColor( QColor( (int)( aLColor[0]*255 ), (int)( aLColor[1]*255 ), (int)( aLColor[2]*255 ) ) ); - myLabelsFontCombo->setCurrentIndex( aLabelsTextPrp->GetFontFamily() ); - myLabelsBoldCheck->setChecked( aLabelsTextPrp->GetBold() ); - myLabelsItalicCheck->setChecked( aLabelsTextPrp->GetItalic() ); - myLabelsShadowCheck->setChecked( aLabelsTextPrp->GetShadow() ); - - myLabelsSpin->setValue( myScalarBarActor->GetNumberOfLabels() ); - myColorsSpin->setValue( myScalarBarActor->GetMaximumNumberOfColors() ); - - if ( myScalarBarActor->GetOrientation() == VTK_ORIENT_VERTICAL ) - myVertRadioBtn->setChecked( true ); - else - myHorizRadioBtn->setChecked( true ); - myIniOrientation = myVertRadioBtn->isChecked(); - - myIniX = myScalarBarActor->GetPosition()[0]; - myIniY = myScalarBarActor->GetPosition()[1]; - myIniW = myScalarBarActor->GetWidth(); - myIniH = myScalarBarActor->GetHeight(); - setOriginAndSize( myIniX, myIniY, myIniW, myIniH ); - - myRangeGrp->setEnabled( true ); - myFontGrp->setEnabled( true ); - myLabColorGrp->setEnabled( true ); - myOrientationGrp->setEnabled( true ); - myOriginDimGrp->setEnabled( true ); - myOkBtn->setEnabled( true ); - myApplyBtn->setEnabled( true ); - return; + myActor = anActor; + SMESH_ScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor(); + + if ( myScalarBarActor->GetLookupTable() ) { + vtkLookupTable* aLookupTable = static_cast(myScalarBarActor->GetLookupTable()); + + double *range = aLookupTable->GetRange(); + myMinEdit->setText( QString::number( range[0],'g',12 ) ); + myMaxEdit->setText( QString::number( range[1],'g',12 ) ); + myLogarithmicCheck->setChecked(aLookupTable->GetScale() == VTK_SCALE_LOG10); + //myLogarithmicCheck->setEnabled(range[0] > 1e-07 && range[1] > 1e-07); + myLogarithmicCheck->setEnabled(range[0] != range[1]); + } + + vtkTextProperty* aTitleTextPrp = myScalarBarActor->GetTitleTextProperty(); + double aTColor[3]; + aTitleTextPrp->GetColor( aTColor ); + myTitleColorBtn->setColor( QColor( (int)( aTColor[0]*255 ), (int)( aTColor[1]*255 ), (int)( aTColor[2]*255 ) ) ); + myTitleFontCombo->setCurrentIndex( aTitleTextPrp->GetFontFamily() ); + myTitleBoldCheck->setChecked( aTitleTextPrp->GetBold() ); + myTitleItalicCheck->setChecked( aTitleTextPrp->GetItalic() ); + myTitleShadowCheck->setChecked( aTitleTextPrp->GetShadow() ); + + vtkTextProperty* aLabelsTextPrp = myScalarBarActor->GetLabelTextProperty(); + double aLColor[3]; + aLabelsTextPrp->GetColor( aLColor ); + myLabelsColorBtn->setColor( QColor( (int)( aLColor[0]*255 ), (int)( aLColor[1]*255 ), (int)( aLColor[2]*255 ) ) ); + myLabelsFontCombo->setCurrentIndex( aLabelsTextPrp->GetFontFamily() ); + myLabelsBoldCheck->setChecked( aLabelsTextPrp->GetBold() ); + myLabelsItalicCheck->setChecked( aLabelsTextPrp->GetItalic() ); + myLabelsShadowCheck->setChecked( aLabelsTextPrp->GetShadow() ); + + myLabelsSpin->setValue( myScalarBarActor->GetNumberOfLabels() ); + myColorsSpin->setValue( myScalarBarActor->GetMaximumNumberOfColors() ); + + if ( myScalarBarActor->GetOrientation() == VTK_ORIENT_VERTICAL ) + myVertRadioBtn->setChecked( true ); + else + myHorizRadioBtn->setChecked( true ); + myIniOrientation = myVertRadioBtn->isChecked(); + + myIniX = myScalarBarActor->GetPosition()[0]; + myIniY = myScalarBarActor->GetPosition()[1]; + myIniW = myScalarBarActor->GetWidth(); + myIniH = myScalarBarActor->GetHeight(); + setOriginAndSize( myIniX, myIniY, myIniW, myIniH ); + + int coloringType = myScalarBarActor->GetDistributionColoringType(); + myScalarBarActor->GetDistributionColor( aTColor ); + myMonoColorBtn->setColor( QColor( (int)( aTColor[0]*255 ), (int)( aTColor[1]*255 ), (int)( aTColor[2]*255 ) ) ); + if ( coloringType == SMESH_MONOCOLOR_TYPE ) { + myDMonoColor->setChecked(true); + onDistributionChanged(myDistribColorGrp->id(myDMonoColor)); + } else { + myDMultiColor->setChecked(true); + onDistributionChanged(myDistribColorGrp->id(myDMultiColor)); + } + myDistributionGrp->setChecked((bool)myScalarBarActor->GetDistributionVisibility()); + onDistributionActivated(myScalarBarActor->GetDistributionVisibility()); + + myRangeGrp->setEnabled( true ); + myFontGrp->setEnabled( true ); + myLabColorGrp->setEnabled( true ); + myOrientationGrp->setEnabled( true ); + myOriginDimGrp->setEnabled( true ); + myOkBtn->setEnabled( true ); + myApplyBtn->setEnabled( true ); + myDistributionGrp->setEnabled( true ); + return; } } } @@ -589,19 +724,23 @@ void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged() myOriginDimGrp->setEnabled( false ); myOkBtn->setEnabled( false ); myApplyBtn->setEnabled( false ); + myDistributionGrp->setEnabled( false ); } //================================================================================================= /*! - * SMESHGUI_Preferences_ScalarBarDlg::closeEvent + * SMESHGUI_Preferences_ScalarBarDlg::onMinMaxChanged * - * Close event handler + * Called when Scalar Range values are changed */ //================================================================================================= -void SMESHGUI_Preferences_ScalarBarDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_Preferences_ScalarBarDlg::onMinMaxChanged() { - myDlg = 0; - QDialog::closeEvent( e ); + double aMin = myMinEdit->text().toDouble(); + double aMax = myMaxEdit->text().toDouble(); + bool isLogarithmicEnabled = (aMin > 1e-07 && aMax > 1e-07); + myLogarithmicCheck->setChecked(isLogarithmicEnabled); + myLogarithmicCheck->setEnabled(isLogarithmicEnabled); } //================================================================================================= @@ -625,9 +764,9 @@ void SMESHGUI_Preferences_ScalarBarDlg::onXYChanged() */ //================================================================================================= void SMESHGUI_Preferences_ScalarBarDlg::setOriginAndSize( const double x, - const double y, - const double w, - const double h ) + const double y, + const double w, + const double h ) { blockSignals( true ); myXSpin->setValue( x ); @@ -640,6 +779,42 @@ void SMESHGUI_Preferences_ScalarBarDlg::setOriginAndSize( const double x, onXYChanged(); } + +//================================================================================================= +/*! + * SMESHGUI_Preferences_ScalarBarDlg::onDistributionChanged + * + * Called when coloring type of the distribution is changed + */ +//================================================================================================= +void SMESHGUI_Preferences_ScalarBarDlg::onDistributionChanged( int id ) { + + bool isActive = myDistribColorGrp->id(myDMonoColor) == id; + + myMonoColorBtn->setEnabled(isActive); + myDistributionColorLbl->setEnabled(isActive); +} +//================================================================================================= +/*! + * SMESHGUI_Preferences_ScalarBarDlg::onDistributionActivated + * + * Called when distribution group check box is changed + */ +//================================================================================================= +void SMESHGUI_Preferences_ScalarBarDlg::onDistributionActivated(bool on) { + if(on) { + if(myDMonoColor->isChecked()) + onDistributionChanged(myDistribColorGrp->id(myDMonoColor) ); + else if(myDMultiColor->isChecked()) + onDistributionChanged(myDistribColorGrp->id(myDMultiColor) ); + } + else { + myMonoColorBtn->setEnabled(false); + myDistributionColorLbl->setEnabled(false); + } +} + + //================================================================================================= /*! * SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged @@ -656,9 +831,9 @@ void SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged() setOriginAndSize( myIniX, myIniY, myIniW, myIniH ); else setOriginAndSize( aOrientation ? DEF_VER_X : DEF_HOR_X, - aOrientation ? DEF_VER_Y : DEF_HOR_Y, - aOrientation ? DEF_VER_W : DEF_HOR_W, - aOrientation ? DEF_VER_H : DEF_HOR_H ); + aOrientation ? DEF_VER_Y : DEF_HOR_Y, + aOrientation ? DEF_VER_W : DEF_HOR_W, + aOrientation ? DEF_VER_H : DEF_HOR_H ); } //================================================================================================= @@ -674,7 +849,7 @@ void SMESHGUI_Preferences_ScalarBarDlg::initScalarBarFromResources() QString name; if (mgr){ // initialize from resoources - + // horizontal name = QString("scalar_bar_horizontal_%1"); if (mgr->hasValue("SMESH", name.arg( "x" )))