+//=================================================================================================
+SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* theModule )
+ : QDialog( SMESH::GetDesktop( theModule ) ),
+ mySMESHGUI( theModule ),
+ mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+{
+ 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;
+
+ setModal( false );
+ setAttribute( Qt::WA_DeleteOnClose, true );
+ setWindowTitle( tr("SMESH_PROPERTIES_SCALARBAR") );
+ setSizeGripEnabled(true);
+
+ myActor = 0;
+
+ /******************************************************************************/
+ // Top layout
+ QVBoxLayout* aTopLayout = new QVBoxLayout( this );
+ aTopLayout->setSpacing( SPACING_SIZE ); aTopLayout->setMargin( MARGIN_SIZE );
+
+ /******************************************************************************/
+ // Scalar range
+ myRangeGrp = new QGroupBox ( tr( "SMESH_RANGE_SCALARBAR" ), this );
+ //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 ) );
+
+ 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 );
+
+ /******************************************************************************/
+ // Text properties
+ myFontGrp = new QGroupBox ( tr( "SMESH_FONT_SCALARBAR" ), this );
+ QGridLayout* myFontGrpLayout = new QGridLayout( myFontGrp );
+ myFontGrpLayout->setSpacing( SPACING_SIZE ); myFontGrpLayout->setMargin( MARGIN_SIZE );
+
+ myTitleColorBtn = new QtxColorButton( myFontGrp );
+
+ myTitleFontCombo = new QComboBox( myFontGrp );
+ myTitleFontCombo->setMinimumWidth( MINIMUM_WIDTH );
+ myTitleFontCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myTitleFontCombo->addItem( tr( "SMESH_FONT_ARIAL" ) );
+ myTitleFontCombo->addItem( tr( "SMESH_FONT_COURIER" ) );
+ myTitleFontCombo->addItem( tr( "SMESH_FONT_TIMES" ) );
+
+ myTitleBoldCheck = new QCheckBox( tr( "SMESH_FONT_BOLD" ), myFontGrp );
+ myTitleItalicCheck = new QCheckBox( tr( "SMESH_FONT_ITALIC" ), myFontGrp );
+ myTitleShadowCheck = new QCheckBox( tr( "SMESH_FONT_SHADOW" ), myFontGrp );
+
+ myLabelsColorBtn = new QtxColorButton( myFontGrp );
+
+ myLabelsFontCombo = new QComboBox( myFontGrp );
+ myLabelsFontCombo->setMinimumWidth( MINIMUM_WIDTH );
+ myLabelsFontCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myLabelsFontCombo->addItem( tr( "SMESH_FONT_ARIAL" ) );
+ myLabelsFontCombo->addItem( tr( "SMESH_FONT_COURIER" ) );
+ myLabelsFontCombo->addItem( tr( "SMESH_FONT_TIMES" ) );
+
+ myLabelsBoldCheck = new QCheckBox( tr( "SMESH_FONT_BOLD" ), myFontGrp );
+ myLabelsItalicCheck = new QCheckBox( tr( "SMESH_FONT_ITALIC" ), myFontGrp );
+ myLabelsShadowCheck = new QCheckBox( tr( "SMESH_FONT_SHADOW" ), myFontGrp );
+
+ myFontGrpLayout->addWidget( new QLabel( tr( "SMESH_TITLE" ), myFontGrp ), 0, 0 );
+ myFontGrpLayout->addWidget( myTitleColorBtn, 0, 1 );
+ myFontGrpLayout->addWidget( myTitleFontCombo, 0, 2 );
+ myFontGrpLayout->addWidget( myTitleBoldCheck, 0, 3 );
+ myFontGrpLayout->addWidget( myTitleItalicCheck, 0, 4 );
+ myFontGrpLayout->addWidget( myTitleShadowCheck, 0, 5 );
+
+ myFontGrpLayout->addWidget( new QLabel( tr( "SMESH_LABELS" ), myFontGrp ), 1, 0 );
+ myFontGrpLayout->addWidget( myLabelsColorBtn, 1, 1 );
+ myFontGrpLayout->addWidget( myLabelsFontCombo, 1, 2 );
+ myFontGrpLayout->addWidget( myLabelsBoldCheck, 1, 3 );
+ myFontGrpLayout->addWidget( myLabelsItalicCheck, 1, 4 );
+ myFontGrpLayout->addWidget( myLabelsShadowCheck, 1, 5 );
+
+ aTopLayout->addWidget( myFontGrp );
+
+ /******************************************************************************/
+ // Labels & Colors
+ myLabColorGrp = new QGroupBox ( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), this );
+ QHBoxLayout* myLabColorGrpLayout = new QHBoxLayout( myLabColorGrp );
+ myLabColorGrpLayout->setSpacing( SPACING_SIZE ); myLabColorGrpLayout->setMargin( MARGIN_SIZE );
+
+ 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 SalomeApp_IntSpinBox( myLabColorGrp );
+ myLabelsSpin->setAcceptNames( false ); // No Notebook variables allowed
+ myLabelsSpin->setRange( 2, 65 );
+ myLabelsSpin->setSingleStep( 1 );
+ myLabelsSpin->setMinimumWidth( MINIMUM_WIDTH );
+ myLabelsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ myLabColorGrpLayout->addWidget( new QLabel( tr( "SMESH_NUMBEROFCOLORS" ), myLabColorGrp ) );
+ myLabColorGrpLayout->addWidget( myColorsSpin );
+ myLabColorGrpLayout->addWidget( new QLabel( tr( "SMESH_NUMBEROFLABELS" ), myLabColorGrp ) );
+ myLabColorGrpLayout->addWidget( myLabelsSpin );
+
+ aTopLayout->addWidget( myLabColorGrp );
+
+ /******************************************************************************/
+ // Orientation
+ myOrientationGrp = new QGroupBox ( tr( "SMESH_ORIENTATION" ), this );
+ QButtonGroup* aOrientationGrp = new QButtonGroup( this );
+ QHBoxLayout* myOrientationGrpLayout = new QHBoxLayout( myOrientationGrp );
+ myOrientationGrpLayout->setSpacing( SPACING_SIZE ); myOrientationGrpLayout->setMargin( MARGIN_SIZE );
+
+ myVertRadioBtn = new QRadioButton( tr( "SMESH_VERTICAL" ), myOrientationGrp );
+ myHorizRadioBtn = new QRadioButton( tr( "SMESH_HORIZONTAL" ), myOrientationGrp );
+ myVertRadioBtn->setChecked( true );
+
+ myOrientationGrpLayout->addWidget( myVertRadioBtn );
+ myOrientationGrpLayout->addWidget( myHorizRadioBtn );
+ aOrientationGrp->addButton(myVertRadioBtn);
+ aOrientationGrp->addButton(myHorizRadioBtn);
+
+ aTopLayout->addWidget( myOrientationGrp );
+
+ /******************************************************************************/
+ // Position & Size
+ myOriginDimGrp = new QGroupBox ( tr("SMESH_POSITION_SIZE_SCALARBAR"), this );
+ QGridLayout* myOriginDimGrpLayout = new QGridLayout( myOriginDimGrp );
+ myOriginDimGrpLayout->setSpacing( SPACING_SIZE ); myOriginDimGrpLayout->setMargin( MARGIN_SIZE );
+
+ 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 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 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 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 ) );
+
+ myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_X_SCALARBAR" ), myOriginDimGrp ), 0, 0 );
+ myOriginDimGrpLayout->addWidget( myXSpin, 0, 1 );
+ myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_Y_SCALARBAR" ), myOriginDimGrp ), 0, 2 );
+ myOriginDimGrpLayout->addWidget( myYSpin, 0, 3 );
+ myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_WIDTH" ), myOriginDimGrp ), 1, 0 );
+ myOriginDimGrpLayout->addWidget( myWidthSpin, 1, 1 );
+ myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_HEIGHT" ), myOriginDimGrp ), 1, 2 );
+ 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 );
+ myButtonGrpLayout->setSpacing( SPACING_SIZE ); myButtonGrpLayout->setMargin( MARGIN_SIZE );
+
+ myOkBtn = new QPushButton( tr( "SMESH_BUT_APPLY_AND_CLOSE" ), myButtonGrp );
+ myOkBtn->setAutoDefault( true ); myOkBtn->setDefault( true );
+ myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), myButtonGrp );
+ myApplyBtn->setAutoDefault( true );
+ myCancelBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), myButtonGrp );
+ myCancelBtn->setAutoDefault( true );
+ myHelpBtn = new QPushButton( tr("SMESH_BUT_HELP"), myButtonGrp );
+ myHelpBtn->setAutoDefault(true);
+
+ myButtonGrpLayout->addWidget( myOkBtn );
+ myButtonGrpLayout->addSpacing( 10 );
+ myButtonGrpLayout->addWidget( myApplyBtn );
+ myButtonGrpLayout->addSpacing( 10 );
+ myButtonGrpLayout->addStretch();
+ myButtonGrpLayout->addWidget( myCancelBtn );
+ myButtonGrpLayout->addWidget( myHelpBtn );
+
+ aTopLayout->addWidget( myButtonGrp );
+
+ /***************************************************************/
+ // Init
+ // --> first init from preferences
+ SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
+
+ QColor titleColor = mgr->colorValue("SMESH", "scalar_bar_title_color",
+ QColor(255, 255, 255));
+ myTitleColorBtn->setColor(titleColor);
+ myTitleFontCombo->setCurrentIndex(0);
+ if (mgr->hasValue("SMESH", "scalar_bar_title_font")) {
+ QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
+ if( f.family()=="Arial" )
+ myTitleFontCombo->setCurrentIndex(0);
+ if( f.family()=="Courier" )
+ 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));
+ myLabelsColorBtn->setColor(labelColor);
+ myLabelsFontCombo->setCurrentIndex(0);
+ if (mgr->hasValue("SMESH", "scalar_bar_label_font")) {
+ QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
+ if (f.family() == "Arial")
+ myLabelsFontCombo->setCurrentIndex(0);
+ if (f.family() == "Courier")
+ myLabelsFontCombo->setCurrentIndex(1);
+ if (f.family() == "Times")
+ myLabelsFontCombo->setCurrentIndex(2);
+
+ myLabelsBoldCheck ->setChecked( f.bold() );
+ myLabelsItalicCheck->setChecked( f.italic() );
+ myLabelsShadowCheck->setChecked( f.overline() );
+ }
+
+ int aNbColors = mgr->integerValue("SMESH", "scalar_bar_num_colors", 64);
+ myColorsSpin->setValue(aNbColors);
+
+ int aNbLabels = mgr->integerValue("SMESH", "scalar_bar_num_labels", 5);
+ myLabelsSpin->setValue(aNbLabels);
+
+ int aOrientation = mgr->integerValue( "SMESH", "scalar_bar_orientation", 1 );
+ bool isHoriz = aOrientation == 1;
+ if (isHoriz)
+ myHorizRadioBtn->setChecked(true);
+ else
+ myVertRadioBtn->setChecked(true);
+ myIniOrientation = myVertRadioBtn->isChecked();
+
+ 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);
+
+ myIniY = mgr->doubleValue("SMESH", name.arg( "y" ),
+ myHorizRadioBtn->isChecked() ? DEF_HOR_Y : DEF_VER_Y);
+
+ myIniW = mgr->doubleValue("SMESH", name.arg( "width" ),
+ myHorizRadioBtn->isChecked() ? DEF_HOR_W : DEF_VER_W);
+
+ myIniH = mgr->doubleValue("SMESH", name.arg( "height" ),
+ 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();
+
+ /***************************************************************/
+ // Connect section
+ connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( onOk() ) );
+ connect( myApplyBtn, SIGNAL( clicked() ), this, SLOT( onApply() ) );
+ 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( reject() ) );
+
+ myHelpFileName = "quality_page.html";
+}
+
+//=================================================================================================
+/*!
+ * SMESHGUI_Preferences_ScalarBarDlg::~SMESHGUI_Preferences_ScalarBarDlg
+ *
+ * Destructor
+ */
+//=================================================================================================