// SMESH SMESHGUI : GUI for SMESH component
//
// Copyright (C) 2003 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 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
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// 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 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
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// Module : SMESH
// $Header$
-using namespace std;
#include "SMESHGUI_Preferences_ScalarBarDlg.h"
+
#include "SMESHGUI.h"
+#include "SMESHGUI_VTKUtils.h"
+#include "SMESHGUI_Utils.h"
+
+#include "SMESH_Actor.h"
+
+#include "SUIT_Desktop.h"
+#include "SUIT_ResourceMgr.h"
+
+#include "LightApp_SelectionMgr.h"
+#include "SALOME_ListIO.hxx"
+
+#include <QtxDblSpinBox.h>
#include <qbuttongroup.h>
#include <qcheckbox.h>
#include <vtkTextProperty.h>
#include <vtkScalarBarActor.h>
-
-#include "QAD_SpinBoxDbl.h"
-#include "QAD_Config.h"
-#include "SALOME_Selection.h"
-#include "SMESHGUI.h"
-#include "SMESH_Actor.h"
+#include <vtkScalarsToColors.h>
#define MINIMUM_WIDTH 70
#define MARGIN_SIZE 11
#define DEF_HOR_H 0.12
#define DEF_HOR_W 0.60
+using namespace std;
+
// Only one instance is allowed
SMESHGUI_Preferences_ScalarBarDlg* SMESHGUI_Preferences_ScalarBarDlg::myDlg = 0;
* Gets the only instance of "Scalar Bar Properties" dialog box
*/
//=================================================================================================
-void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties(QWidget* parent,
- SALOME_Selection* Sel)
+void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( SMESHGUI* theModule )
{
- if ( !myDlg ) {
- myDlg = new SMESHGUI_Preferences_ScalarBarDlg( parent, Sel, false );
+ if (!myDlg) {
+ myDlg = new SMESHGUI_Preferences_ScalarBarDlg( theModule, true);
myDlg->show();
- }
- else {
+ } else {
myDlg->show();
myDlg->setActiveWindow();
myDlg->raise();
* Opens "Scalar Bar Preferences" dialog box
*/
//=================================================================================================
-void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( QWidget* parent )
+void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( SMESHGUI* theModule )
{
- SMESHGUI_Preferences_ScalarBarDlg* aDlg = new SMESHGUI_Preferences_ScalarBarDlg( parent, 0, true );
+ SMESHGUI_Preferences_ScalarBarDlg* aDlg =
+ new SMESHGUI_Preferences_ScalarBarDlg( theModule, false);
aDlg->exec();
}
* Constructor
*/
//=================================================================================================
-SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg(QWidget* parent,
- SALOME_Selection* Sel,
- bool modal)
- : QDialog( parent, 0, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
+SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* theModule, bool property, bool modal )
+ : QDialog( SMESH::GetDesktop( theModule ), 0, modal, WStyle_Customize | WStyle_NormalBorder |
+ WStyle_Title | WStyle_SysMenu | WDestructiveClose ),
+ mySMESHGUI( theModule ),
+ mySelectionMgr( property ? SMESH::GetSelectionMgr( theModule ) : 0 )
{
- setName( "SMESHGUI_Preferences_ScalarBarDlg" );
- setCaption( Sel ? tr( "SMESH_PROPERTIES_SCALARBAR" ) : tr( "SMESH_PREFERENCES_SCALARBAR" ) );
- setSizeGripEnabled( TRUE );
+ setName("SMESHGUI_Preferences_ScalarBarDlg");
+ setCaption( property ? tr("SMESH_PROPERTIES_SCALARBAR") : tr("SMESH_PREFERENCES_SCALARBAR"));
+ setSizeGripEnabled(TRUE);
- mySelection = Sel;
myActor = 0;
/******************************************************************************/
/******************************************************************************/
// Scalar range
- if ( mySelection ) {
+ if ( mySelectionMgr ) {
myRangeGrp = new QGroupBox ( tr( "SMESH_RANGE_SCALARBAR" ), this, "myRangeGrp" );
myRangeGrp->setColumnLayout( 0, Qt::Vertical );
myRangeGrp->layout()->setSpacing( 0 ); myRangeGrp->layout()->setMargin( 0 );
QGridLayout* myRangeGrpLayout = new QGridLayout( myRangeGrp->layout() );
myRangeGrpLayout->setAlignment( Qt::AlignTop );
myRangeGrpLayout->setSpacing( SPACING_SIZE ); myRangeGrpLayout->setMargin( MARGIN_SIZE );
-
+
myMinEdit = new QLineEdit( myRangeGrp, "myMinEdit" );
myMinEdit->setMinimumWidth( MINIMUM_WIDTH );
myMinEdit->setValidator( new QDoubleValidator( this ) );
QGridLayout* myFontGrpLayout = new QGridLayout( myFontGrp->layout() );
myFontGrpLayout->setAlignment( Qt::AlignTop );
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 );
myTitleFontCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
myTitleFontCombo->insertItem( tr( "SMESH_FONT_ARIAL" ) );
myTitleFontCombo->insertItem( tr( "SMESH_FONT_COURIER" ) );
myTitleFontCombo->insertItem( tr( "SMESH_FONT_TIMES" ) );
-
+
myTitleBoldCheck = new QCheckBox( tr( "SMESH_FONT_BOLD" ), myFontGrp, "myTitleBoldCheck" );
myTitleItalicCheck = new QCheckBox( tr( "SMESH_FONT_ITALIC" ), myFontGrp, "myTitleItalicCheck" );
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 );
myLabelsFontCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
myLabelsFontCombo->insertItem( tr( "SMESH_FONT_ARIAL" ) );
myLabelsFontCombo->insertItem( tr( "SMESH_FONT_COURIER" ) );
myLabelsFontCombo->insertItem( tr( "SMESH_FONT_TIMES" ) );
-
+
myLabelsBoldCheck = new QCheckBox( tr( "SMESH_FONT_BOLD" ), myFontGrp, "myLabelsBoldCheck" );
myLabelsItalicCheck = new QCheckBox( tr( "SMESH_FONT_ITALIC" ), myFontGrp, "myLabelsItalicCheck" );
myLabelsShadowCheck = new QCheckBox( tr( "SMESH_FONT_SHADOW" ), myFontGrp, "myLabelsShadowCheck" );
myFontGrpLayout->addWidget( myTitleBoldCheck, 0, 3 );
myFontGrpLayout->addWidget( myTitleItalicCheck, 0, 4 );
myFontGrpLayout->addWidget( myTitleShadowCheck, 0, 5 );
-
+
myFontGrpLayout->addWidget( new QLabel( tr( "SMESH_LABELS" ), myFontGrp, "myFontLabelsLab" ), 1, 0 );
myFontGrpLayout->addWidget( myLabelsColorBtn, 1, 1 );
myFontGrpLayout->addWidget( myLabelsFontCombo, 1, 2 );
QGridLayout* myLabColorGrpLayout = new QGridLayout( myLabColorGrp->layout() );
myLabColorGrpLayout->setAlignment( Qt::AlignTop );
myLabColorGrpLayout->setSpacing( SPACING_SIZE ); myLabColorGrpLayout->setMargin( MARGIN_SIZE );
-
+
myColorsSpin = new QSpinBox( 2, 256, 1, myLabColorGrp, "myColorsSpin" );
myColorsSpin->setMinimumWidth( MINIMUM_WIDTH );
myColorsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
QGridLayout* myOrientationGrpLayout = new QGridLayout( myOrientationGrp->layout() );
myOrientationGrpLayout->setAlignment( Qt::AlignTop );
myOrientationGrpLayout->setSpacing( SPACING_SIZE ); myOrientationGrpLayout->setMargin( MARGIN_SIZE );
-
+
myVertRadioBtn = new QRadioButton( tr( "SMESH_VERTICAL" ), myOrientationGrp, "myVertRadioBtn" );
myHorizRadioBtn = new QRadioButton( tr( "SMESH_HORIZONTAL" ), myOrientationGrp, "myHorizRadioBtn" );
myVertRadioBtn->setChecked( true );
/******************************************************************************/
// Position & Size
- myOriginDimGrp = new QGroupBox ( tr( "SMESH_POSITION_SIZE_SCALARBAR" ), this, "myOriginDimGrp" );
- myOriginDimGrp->setColumnLayout( 0, Qt::Vertical );
+ myOriginDimGrp = new QGroupBox (tr("SMESH_POSITION_SIZE_SCALARBAR"), this, "myOriginDimGrp");
+ myOriginDimGrp->setColumnLayout(0, Qt::Vertical);
myOriginDimGrp->layout()->setSpacing( 0 ); myOriginDimGrp->layout()->setMargin( 0 );
QGridLayout* myOriginDimGrpLayout = new QGridLayout( myOriginDimGrp->layout() );
myOriginDimGrpLayout->setAlignment( Qt::AlignTop );
myOriginDimGrpLayout->setSpacing( SPACING_SIZE ); myOriginDimGrpLayout->setMargin( MARGIN_SIZE );
-
- myXSpin = new QAD_SpinBoxDbl( myOriginDimGrp, 0.0, 1.0, 0.1 );
+
+ myXSpin = new QtxDblSpinBox (0.0, 1.0, 0.1, myOriginDimGrp);
myXSpin->setMinimumWidth( MINIMUM_WIDTH );
myXSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myYSpin = new QAD_SpinBoxDbl( myOriginDimGrp, 0.0, 1.0, 0.1 );
+ myYSpin = new QtxDblSpinBox(0.0, 1.0, 0.1, myOriginDimGrp);
myYSpin->setMinimumWidth( MINIMUM_WIDTH );
myYSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myWidthSpin = new QAD_SpinBoxDbl( myOriginDimGrp, 0.0, 1.0, 0.1 );
+ myWidthSpin = new QtxDblSpinBox(0.0, 1.0, 0.1, myOriginDimGrp);
myWidthSpin->setMinimumWidth( MINIMUM_WIDTH );
myWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myHeightSpin = new QAD_SpinBoxDbl( myOriginDimGrp, 0.0, 1.0, 0.1 );
+ myHeightSpin = new QtxDblSpinBox(0.0, 1.0, 0.1, myOriginDimGrp);
myHeightSpin->setMinimumWidth( MINIMUM_WIDTH );
myHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), myButtonGrp, "myOkBtn" );
myOkBtn->setAutoDefault( TRUE ); myOkBtn->setDefault( TRUE );
myButtonGrpLayout->addWidget( myOkBtn );
- if ( mySelection ) {
+ if ( mySelectionMgr ) {
myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), myButtonGrp, "myApplyBtn" );
myApplyBtn->setAutoDefault( TRUE );
myButtonGrpLayout->addWidget( myApplyBtn );
}
myButtonGrpLayout->addStretch();
myCancelBtn = new QPushButton( tr( "SMESH_BUT_CANCEL" ), myButtonGrp, "myCancelBtn" );
- if ( mySelection )
+ if ( mySelectionMgr )
myCancelBtn->setText( tr( "SMESH_BUT_CLOSE" ) );
myCancelBtn->setAutoDefault( TRUE );
myButtonGrpLayout->addWidget( myCancelBtn );
/***************************************************************/
// Init
// --> first init from preferences
- QColor titleColor( 255, 255, 255 );
- if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleColor" ) ) {
- QStringList aTColor = QStringList::split( ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleColor" ), false );
- titleColor = QColor( ( aTColor.count() > 0 ? aTColor[0].toInt() : 255 ),
- ( aTColor.count() > 1 ? aTColor[1].toInt() : 255 ),
- ( aTColor.count() > 2 ? aTColor[2].toInt() : 255 ) );
+ SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
+
+ QColor titleColor (255, 255, 255);
+ if (mgr && mgr->hasValue("SMESH", "scalar_bar_title_color")) {
+ QStringList aTColor =
+ QStringList::split(":", mgr->stringValue("SMESH", "scalar_bar_title_color"), false);
+ titleColor = QColor((aTColor.count() > 0 ? aTColor[0].toInt() : 255),
+ (aTColor.count() > 1 ? aTColor[1].toInt() : 255),
+ (aTColor.count() > 2 ? aTColor[2].toInt() : 255));
}
- myTitleColorBtn->setPaletteBackgroundColor( titleColor );
- myTitleFontCombo->setCurrentItem( 0 );
- if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleFont" ) ) {
- if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Arial" )
- myTitleFontCombo->setCurrentItem( 0 );
- if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Courier" )
- myTitleFontCombo->setCurrentItem( 1 );
- if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Times" )
- myTitleFontCombo->setCurrentItem( 2 );
+ myTitleColorBtn->setPaletteBackgroundColor(titleColor);
+ myTitleFontCombo->setCurrentItem(0);
+ if (mgr && mgr->hasValue("SMESH", "scalar_bar_title_font")) {
+ QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
+ if( f.family()=="Arial" )
+ myTitleFontCombo->setCurrentItem(0);
+ if( f.family()=="Courier" )
+ myTitleFontCombo->setCurrentItem(1);
+ if( f.family()=="Times")
+ myTitleFontCombo->setCurrentItem(2);
+
+ myTitleBoldCheck->setChecked ( f.bold() );
+ myTitleItalicCheck->setChecked( f.italic() );
+ myTitleShadowCheck->setChecked( f.underline() );
}
- myTitleBoldCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleBold" ) == "true" );
- myTitleItalicCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleItalic" ) == "true" );
- myTitleShadowCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleShadow" ) == "true" );
-
- QColor labelColor( 255, 255, 255 );
- if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelColor" ) ) {
- QStringList aLColor = QStringList::split( ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelColor" ), false );
- labelColor = QColor( ( aLColor.count() > 0 ? aLColor[0].toInt() : 255 ),
- ( aLColor.count() > 1 ? aLColor[1].toInt() : 255 ),
- ( aLColor.count() > 2 ? aLColor[2].toInt() : 255 ) );
+
+ QColor labelColor (255, 255, 255);
+ if (mgr && mgr->hasValue("SMESH", "scalar_bar_label_color")) {
+ QStringList aLColor =
+ QStringList::split(":", mgr->stringValue("SMESH", "scalar_bar_label_color"), false);
+ labelColor = QColor((aLColor.count() > 0 ? aLColor[0].toInt() : 255),
+ (aLColor.count() > 1 ? aLColor[1].toInt() : 255),
+ (aLColor.count() > 2 ? aLColor[2].toInt() : 255));
}
- myLabelsColorBtn->setPaletteBackgroundColor( labelColor );
- myLabelsFontCombo->setCurrentItem( 0 );
- if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelFont" ) ) {
- if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Arial" )
- myLabelsFontCombo->setCurrentItem( 0 );
- if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Courier" )
- myLabelsFontCombo->setCurrentItem( 1 );
- if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Times" )
- myLabelsFontCombo->setCurrentItem( 2 );
+ myLabelsColorBtn->setPaletteBackgroundColor(labelColor);
+ myLabelsFontCombo->setCurrentItem(0);
+ if (mgr && mgr->hasValue("SMESH", "scalar_bar_label_font")) {
+ QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
+ if (f.family() == "Arial")
+ myLabelsFontCombo->setCurrentItem(0);
+ if (f.family() == "Courier")
+ myLabelsFontCombo->setCurrentItem(1);
+ if (f.family() == "Times")
+ myLabelsFontCombo->setCurrentItem(2);
+
+ myLabelsBoldCheck ->setChecked( f.bold() );
+ myLabelsItalicCheck->setChecked( f.italic() );
+ myLabelsShadowCheck->setChecked( f.underline() );
}
- myLabelsBoldCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelBold" ) == "true" );
- myLabelsItalicCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelItalic" ) == "true" );
- myLabelsShadowCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelShadow" ) == "true" );
int aNbColors = 64;
- if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfColors" ) )
- aNbColors = QAD_CONFIG->getSetting( "SMESH:ScalarBarNbOfColors" ).toInt();
- myColorsSpin->setValue( aNbColors );
- int aNbLabels = 5;
- if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfLabels" ) )
- aNbLabels = QAD_CONFIG->getSetting( "SMESH:ScalarBarNbOfLabels" ).toInt();
- myLabelsSpin->setValue( aNbLabels );
+ if (mgr && mgr->hasValue("SMESH", "scalar_bar_num_colors"))
+ aNbColors = mgr->integerValue("SMESH", "scalar_bar_num_colors");
+ myColorsSpin->setValue(aNbColors);
- QString aOrientation = QAD_CONFIG->getSetting( "SMESH:ScalarBarOrientation" );
- if ( aOrientation == "Horizontal" )
- myHorizRadioBtn->setChecked( true );
+ int aNbLabels = 5;
+ if (mgr && mgr->hasValue("SMESH", "scalar_bar_num_labels"))
+ aNbLabels = mgr->integerValue("SMESH", "scalar_bar_num_labels");
+ myLabelsSpin->setValue(aNbLabels);
+
+ int aOrientation = ( mgr ? mgr->integerValue( "SMESH", "scalar_bar_orientation", 1 ) : 1 );
+ bool isHoriz = ( aOrientation==1 );
+ if (aOrientation == 1)
+ myHorizRadioBtn->setChecked(true);
else
- myVertRadioBtn->setChecked( true );
+ myVertRadioBtn->setChecked(true);
myIniOrientation = myVertRadioBtn->isChecked();
- if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarXPosition" ) )
- myIniX = QAD_CONFIG->getSetting( "SMESH:ScalarBarXPosition" ).toDouble();
+ QString name = isHoriz ? "scalar_bar_horizontal_%1" : "scalar_bar_vertical_%1";
+ if (mgr && mgr->hasValue("SMESH", name.arg( "x" )))
+ myIniX = mgr->doubleValue("SMESH", name.arg( "x" ));
else
myIniX = myHorizRadioBtn->isChecked() ? DEF_HOR_X : DEF_VER_X;
- if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarYPosition" ) )
- myIniY = QAD_CONFIG->getSetting( "SMESH:ScalarBarYPosition" ).toDouble();
+
+ if (mgr && mgr->hasValue("SMESH", name.arg( "y" )))
+ myIniY = mgr->doubleValue("SMESH", name.arg( "y" ));
else
myIniY = myHorizRadioBtn->isChecked() ? DEF_HOR_Y : DEF_VER_Y;
- if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarWidth" ) )
- myIniW = QAD_CONFIG->getSetting( "SMESH:ScalarBarWidth" ).toDouble();
+
+ if (mgr && mgr->hasValue("SMESH", name.arg( "width" )))
+ myIniW = mgr->doubleValue("SMESH", name.arg( "width" ));
else
myIniW = myHorizRadioBtn->isChecked() ? DEF_HOR_W : DEF_VER_W;
- if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarHeight" ) )
- myIniH = QAD_CONFIG->getSetting( "SMESH:ScalarBarHeight" ).toDouble();
+
+ if (mgr && mgr->hasValue("SMESH", name.arg( "height" )))
+ myIniH = mgr->doubleValue("SMESH", name.arg( "height" ));
else
myIniH = myHorizRadioBtn->isChecked() ? DEF_HOR_H : DEF_VER_H;
- setOriginAndSize( myIniX, myIniY, myIniW, myIniH );
- if ( mySelection ) {
+ setOriginAndSize(myIniX, myIniY, myIniW, myIniH);
+
+ if (mySelectionMgr) {
// --> then init from selection if necessary
onSelectionChanged();
}
-
+
/***************************************************************/
// Connect section
connect( myTitleColorBtn, SIGNAL( clicked() ), this, SLOT( onTitleColor() ) );
connect( myXSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
connect( myYSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
connect( myOrientationGrp, SIGNAL( clicked( int ) ), this, SLOT( onOrientationChanged() ) );
- if ( mySelection ) {
+ if ( mySelectionMgr ) {
connect( myApplyBtn, SIGNAL( clicked() ), this, SLOT( onApply() ) );
- connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
+ connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
}
- connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onCancel() ) ) ;
+ connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onCancel() ) ) ;
}
//=================================================================================================
//=================================================================================================
bool SMESHGUI_Preferences_ScalarBarDlg::onApply()
{
- if ( mySelection ) {
+ if (mySelectionMgr) {
// Scalar Bar properties
- if ( !myActor )
+ if (!myActor)
return false;
vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
double aMin = myMinEdit->text().toDouble();
double aMax = myMaxEdit->text().toDouble();
myScalarBarActor->GetLookupTable()->SetRange( aMin, aMax );
- SMESHGUI::GetSMESHGUI()->UpdateView();
- }
- else {
+ SMESH::RepaintCurrentView();
+ } else {
// Scalar Bar preferences
+ SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
+ if (!mgr) return false;
+
QColor titleColor = myTitleColorBtn->paletteBackgroundColor();
- QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleColor", QString().sprintf( "%d:%d:%d", titleColor.red(), titleColor.green(), titleColor.blue() ) );
- if ( myTitleFontCombo->currentItem() == 0 )
- QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleFont", "Arial" );
- else if ( myTitleFontCombo->currentItem() == 1 )
- QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleFont", "Courier" );
+ mgr->setValue("SMESH", "scalar_bar_title_color", titleColor );
+
+ QFont f;
+ if (myTitleFontCombo->currentItem() == 0)
+ f.setFamily( "Arial" );
+ else if (myTitleFontCombo->currentItem() == 1)
+ f.setFamily( "Courier" );
else
- QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleFont", "Times" );
- QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleBold", myTitleBoldCheck->isChecked() ? "true" : "false" );
- QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleItalic", myTitleItalicCheck->isChecked() ? "true" : "false" );
- QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleShadow", myTitleShadowCheck->isChecked() ? "true" : "false" );
+ f.setFamily( "Times");
+
+ f.setBold( myTitleBoldCheck ->isChecked() );
+ f.setItalic( myTitleItalicCheck->isChecked() );
+ f.setUnderline( myTitleShadowCheck->isChecked() );
+ mgr->setValue( "SMESH", "scalar_bar_title_font", f );
QColor labelColor = myLabelsColorBtn->paletteBackgroundColor();
- QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelColor", QString().sprintf( "%d:%d:%d", labelColor.red(), labelColor.green(),labelColor. blue() ) );
- if ( myLabelsFontCombo->currentItem() == 0 )
- QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelFont", "Arial" );
+ mgr->setValue("SMESH", "scalar_bar_label_color", labelColor );
+
+ if (myLabelsFontCombo->currentItem() == 0)
+ f.setFamily( "Arial" );
else if ( myLabelsFontCombo->currentItem() == 1 )
- QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelFont", "Courier" );
+ f.setFamily( "Courier");
else
- QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelFont", "Times" );
- QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelBold", myLabelsBoldCheck->isChecked() ? "true" : "false" );
- QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelItalic", myLabelsItalicCheck->isChecked() ? "true" : "false" );
- QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelShadow", myLabelsShadowCheck->isChecked() ? "true" : "false" );
-
- QAD_CONFIG->addSetting( "SMESH:ScalarBarNbOfColors", myColorsSpin->value() );
- QAD_CONFIG->addSetting( "SMESH:ScalarBarNbOfLabels", myLabelsSpin->value() );
-
- QAD_CONFIG->addSetting( "SMESH:ScalarBarOrientation", myHorizRadioBtn->isChecked() ? "Horizontal" : "Vertical" );
-
- QAD_CONFIG->addSetting( "SMESH:ScalarBarXPosition", myXSpin->value() );
- QAD_CONFIG->addSetting( "SMESH:ScalarBarYPosition", myYSpin->value() );
- QAD_CONFIG->addSetting( "SMESH:ScalarBarWidth", myWidthSpin->value() );
- QAD_CONFIG->addSetting( "SMESH:ScalarBarHeight", myHeightSpin->value() );
+ f.setFamily( "Times");
+
+ f.setBold( myLabelsBoldCheck ->isChecked() );
+ f.setItalic( myLabelsItalicCheck->isChecked() );
+ f.setUnderline( myLabelsShadowCheck->isChecked() );
+ mgr->setValue( "SMESH", "scalar_bar_label_font", f );
+
+ mgr->setValue("SMESH", "scalar_bar_num_colors", myColorsSpin->value());
+ mgr->setValue("SMESH", "scalar_bar_num_labels", myLabelsSpin->value());
+
+ mgr->setValue("SMESH", "scalar_bar_orientation", myHorizRadioBtn->isChecked() ? 1 : 0 );
+
+ QString name = myHorizRadioBtn->isChecked() ? "scalar_bar_horizontal_%1" : "scalar_bar_vertical_%1";
+ mgr->setValue("SMESH", name.arg( "x" ), myXSpin->value());
+ mgr->setValue("SMESH", name.arg( "y" ), myYSpin->value());
+ mgr->setValue("SMESH", name.arg( "width" ), myWidthSpin->value());
+ mgr->setValue("SMESH", name.arg( "height" ), myHeightSpin->value());
}
return true;
}
{
QColor aColor = myTitleColorBtn->paletteBackgroundColor();
aColor = QColorDialog::getColor( aColor, this );
- if ( aColor.isValid() )
+ if ( aColor.isValid() )
myTitleColorBtn->setPaletteBackgroundColor( aColor );
}
{
QColor aColor = myLabelsColorBtn->paletteBackgroundColor();
aColor = QColorDialog::getColor( aColor, this );
- if ( aColor.isValid() )
+ if ( aColor.isValid() )
myLabelsColorBtn->setPaletteBackgroundColor( aColor );
}
//=================================================================================================
void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged()
{
- if( mySelection ) {
- if ( mySelection->IObjectCount() == 1 ) {
- Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject();
+ if (mySelectionMgr) {
+ SALOME_ListIO aList;
+ mySelectionMgr->selectedObjects(aList);
+
+ if (aList.Extent() == 1) {
+ Handle(SALOME_InteractiveObject) anIO = aList.First();
if( anIO->hasEntry() ) {
- Standard_Boolean isOk;
- SMESH_Actor* anActor = SMESHGUI::GetSMESHGUI()->FindActorByEntry( anIO->getEntry(), isOk, true );
- if ( isOk && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
+ SMESH_Actor* anActor = SMESH::FindActorByEntry(anIO->getEntry());
+ if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
myActor = anActor;
vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
-
- double aMin = 0.0, aMax = 0.0;
+
if ( myScalarBarActor->GetLookupTable() ) {
float *range = myScalarBarActor->GetLookupTable()->GetRange();
myMinEdit->setText( QString::number( range[0] ) );
else
myHorizRadioBtn->setChecked( true );
myIniOrientation = myVertRadioBtn->isChecked();
-
+
myIniX = myScalarBarActor->GetPosition()[0];
myIniY = myScalarBarActor->GetPosition()[1];
myIniW = myScalarBarActor->GetWidth();
//=================================================================================================
void SMESHGUI_Preferences_ScalarBarDlg::closeEvent( QCloseEvent* e )
{
- if ( mySelection ) // "Properties" dialog box
+ if ( mySelectionMgr ) // "Properties" dialog box
myDlg = 0;
QDialog::closeEvent( e );
}
* Called when orientation is changed
*/
//=================================================================================================
-void SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged()
+void SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged()
{
int aOrientation = myVertRadioBtn->isChecked();
if ( aOrientation == myIniOrientation )
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,
+ 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 );
}