1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI_Preferences_ScalarBarDlg.cxx
23 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
27 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
30 #include "SMESHGUI_VTKUtils.h"
31 #include "SMESHGUI_Utils.h"
33 #include <SMESH_Actor.h>
35 // SALOME GUI includes
36 #include <SUIT_Desktop.h>
37 #include <SUIT_ResourceMgr.h>
39 #include <LightApp_SelectionMgr.h>
40 #include <SALOME_ListIO.hxx>
42 #include <QtxDoubleSpinBox.h>
43 #include <QtxColorButton.h>
46 #include <QButtonGroup>
52 #include <QPushButton>
53 #include <QRadioButton>
55 #include <QHBoxLayout>
56 #include <QVBoxLayout>
57 #include <QGridLayout>
58 #include <QDoubleValidator>
61 #include <vtkTextProperty.h>
62 #include <vtkScalarBarActor.h>
63 #include <vtkLookupTable.h>
65 #define MINIMUM_WIDTH 70
66 #define MARGIN_SIZE 11
67 #define SPACING_SIZE 6
69 // Only one instance is allowed
70 SMESHGUI_Preferences_ScalarBarDlg* SMESHGUI_Preferences_ScalarBarDlg::myDlg = 0;
72 //=================================================================================================
74 * SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties
76 * Gets the only instance of "Scalar Bar Properties" dialog box
78 //=================================================================================================
79 void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( SMESHGUI* theModule )
82 myDlg = new SMESHGUI_Preferences_ScalarBarDlg( theModule );
87 myDlg->activateWindow();
91 //=================================================================================================
93 * SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg
97 //=================================================================================================
98 SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* theModule )
99 : QDialog( SMESH::GetDesktop( theModule ) ),
100 mySMESHGUI( theModule ),
101 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
113 setAttribute( Qt::WA_DeleteOnClose, true );
114 setWindowTitle( tr("SMESH_PROPERTIES_SCALARBAR") );
115 setSizeGripEnabled(true);
119 /******************************************************************************/
121 QVBoxLayout* aTopLayout = new QVBoxLayout( this );
122 aTopLayout->setSpacing( SPACING_SIZE ); aTopLayout->setMargin( MARGIN_SIZE );
124 /******************************************************************************/
126 myRangeGrp = new QGroupBox ( tr( "SMESH_RANGE_SCALARBAR" ), this );
127 QHBoxLayout* myRangeGrpLayout = new QHBoxLayout( myRangeGrp );
128 myRangeGrpLayout->setSpacing( SPACING_SIZE ); myRangeGrpLayout->setMargin( MARGIN_SIZE );
130 myMinEdit = new QLineEdit( myRangeGrp );
131 myMinEdit->setMinimumWidth( MINIMUM_WIDTH );
132 myMinEdit->setValidator( new QDoubleValidator( this ) );
134 myMaxEdit = new QLineEdit( myRangeGrp );
135 myMaxEdit->setMinimumWidth( MINIMUM_WIDTH );
136 myMaxEdit->setValidator( new QDoubleValidator( this ) );
138 myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MIN" ), myRangeGrp ) );
139 myRangeGrpLayout->addWidget( myMinEdit );
140 myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MAX" ), myRangeGrp ) );
141 myRangeGrpLayout->addWidget( myMaxEdit );
143 aTopLayout->addWidget( myRangeGrp );
145 /******************************************************************************/
147 myFontGrp = new QGroupBox ( tr( "SMESH_FONT_SCALARBAR" ), this );
148 QGridLayout* myFontGrpLayout = new QGridLayout( myFontGrp );
149 myFontGrpLayout->setSpacing( SPACING_SIZE ); myFontGrpLayout->setMargin( MARGIN_SIZE );
151 myTitleColorBtn = new QtxColorButton( myFontGrp );
153 myTitleFontCombo = new QComboBox( myFontGrp );
154 myTitleFontCombo->setMinimumWidth( MINIMUM_WIDTH );
155 myTitleFontCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
156 myTitleFontCombo->addItem( tr( "SMESH_FONT_ARIAL" ) );
157 myTitleFontCombo->addItem( tr( "SMESH_FONT_COURIER" ) );
158 myTitleFontCombo->addItem( tr( "SMESH_FONT_TIMES" ) );
160 myTitleBoldCheck = new QCheckBox( tr( "SMESH_FONT_BOLD" ), myFontGrp );
161 myTitleItalicCheck = new QCheckBox( tr( "SMESH_FONT_ITALIC" ), myFontGrp );
162 myTitleShadowCheck = new QCheckBox( tr( "SMESH_FONT_SHADOW" ), myFontGrp );
164 myLabelsColorBtn = new QtxColorButton( myFontGrp );
166 myLabelsFontCombo = new QComboBox( myFontGrp );
167 myLabelsFontCombo->setMinimumWidth( MINIMUM_WIDTH );
168 myLabelsFontCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
169 myLabelsFontCombo->addItem( tr( "SMESH_FONT_ARIAL" ) );
170 myLabelsFontCombo->addItem( tr( "SMESH_FONT_COURIER" ) );
171 myLabelsFontCombo->addItem( tr( "SMESH_FONT_TIMES" ) );
173 myLabelsBoldCheck = new QCheckBox( tr( "SMESH_FONT_BOLD" ), myFontGrp );
174 myLabelsItalicCheck = new QCheckBox( tr( "SMESH_FONT_ITALIC" ), myFontGrp );
175 myLabelsShadowCheck = new QCheckBox( tr( "SMESH_FONT_SHADOW" ), myFontGrp );
177 myFontGrpLayout->addWidget( new QLabel( tr( "SMESH_TITLE" ), myFontGrp ), 0, 0 );
178 myFontGrpLayout->addWidget( myTitleColorBtn, 0, 1 );
179 myFontGrpLayout->addWidget( myTitleFontCombo, 0, 2 );
180 myFontGrpLayout->addWidget( myTitleBoldCheck, 0, 3 );
181 myFontGrpLayout->addWidget( myTitleItalicCheck, 0, 4 );
182 myFontGrpLayout->addWidget( myTitleShadowCheck, 0, 5 );
184 myFontGrpLayout->addWidget( new QLabel( tr( "SMESH_LABELS" ), myFontGrp ), 1, 0 );
185 myFontGrpLayout->addWidget( myLabelsColorBtn, 1, 1 );
186 myFontGrpLayout->addWidget( myLabelsFontCombo, 1, 2 );
187 myFontGrpLayout->addWidget( myLabelsBoldCheck, 1, 3 );
188 myFontGrpLayout->addWidget( myLabelsItalicCheck, 1, 4 );
189 myFontGrpLayout->addWidget( myLabelsShadowCheck, 1, 5 );
191 aTopLayout->addWidget( myFontGrp );
193 /******************************************************************************/
195 myLabColorGrp = new QGroupBox ( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), this );
196 QHBoxLayout* myLabColorGrpLayout = new QHBoxLayout( myLabColorGrp );
197 myLabColorGrpLayout->setSpacing( SPACING_SIZE ); myLabColorGrpLayout->setMargin( MARGIN_SIZE );
199 myColorsSpin = new QSpinBox( myLabColorGrp );
200 myColorsSpin->setRange( 2, 256 );
201 myColorsSpin->setSingleStep( 1 );
202 myColorsSpin->setMinimumWidth( MINIMUM_WIDTH );
203 myColorsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
205 myLabelsSpin = new QSpinBox( myLabColorGrp );
206 myLabelsSpin->setRange( 2, 65 );
207 myLabelsSpin->setSingleStep( 1 );
208 myLabelsSpin->setMinimumWidth( MINIMUM_WIDTH );
209 myLabelsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
211 myLabColorGrpLayout->addWidget( new QLabel( tr( "SMESH_NUMBEROFCOLORS" ), myLabColorGrp ) );
212 myLabColorGrpLayout->addWidget( myColorsSpin );
213 myLabColorGrpLayout->addWidget( new QLabel( tr( "SMESH_NUMBEROFLABELS" ), myLabColorGrp ) );
214 myLabColorGrpLayout->addWidget( myLabelsSpin );
216 aTopLayout->addWidget( myLabColorGrp );
218 /******************************************************************************/
220 myOrientationGrp = new QGroupBox ( tr( "SMESH_ORIENTATION" ), this );
221 QButtonGroup* aOrientationGrp = new QButtonGroup( this );
222 QHBoxLayout* myOrientationGrpLayout = new QHBoxLayout( myOrientationGrp );
223 myOrientationGrpLayout->setSpacing( SPACING_SIZE ); myOrientationGrpLayout->setMargin( MARGIN_SIZE );
225 myVertRadioBtn = new QRadioButton( tr( "SMESH_VERTICAL" ), myOrientationGrp );
226 myHorizRadioBtn = new QRadioButton( tr( "SMESH_HORIZONTAL" ), myOrientationGrp );
227 myVertRadioBtn->setChecked( true );
229 myOrientationGrpLayout->addWidget( myVertRadioBtn );
230 myOrientationGrpLayout->addWidget( myHorizRadioBtn );
231 aOrientationGrp->addButton(myVertRadioBtn);
232 aOrientationGrp->addButton(myHorizRadioBtn);
234 aTopLayout->addWidget( myOrientationGrp );
236 /******************************************************************************/
238 myOriginDimGrp = new QGroupBox ( tr("SMESH_POSITION_SIZE_SCALARBAR"), this );
239 QGridLayout* myOriginDimGrpLayout = new QGridLayout( myOriginDimGrp );
240 myOriginDimGrpLayout->setSpacing( SPACING_SIZE ); myOriginDimGrpLayout->setMargin( MARGIN_SIZE );
242 myXSpin = new QtxDoubleSpinBox (0.0, 1.0, 0.1, myOriginDimGrp);
243 myXSpin->setMinimumWidth( MINIMUM_WIDTH );
244 myXSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
246 myYSpin = new QtxDoubleSpinBox(0.0, 1.0, 0.1, myOriginDimGrp);
247 myYSpin->setMinimumWidth( MINIMUM_WIDTH );
248 myYSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
250 myWidthSpin = new QtxDoubleSpinBox(0.0, 1.0, 0.1, myOriginDimGrp);
251 myWidthSpin->setMinimumWidth( MINIMUM_WIDTH );
252 myWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
254 myHeightSpin = new QtxDoubleSpinBox(0.0, 1.0, 0.1, myOriginDimGrp);
255 myHeightSpin->setMinimumWidth( MINIMUM_WIDTH );
256 myHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
258 myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_X_SCALARBAR" ), myOriginDimGrp ), 0, 0 );
259 myOriginDimGrpLayout->addWidget( myXSpin, 0, 1 );
260 myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_Y_SCALARBAR" ), myOriginDimGrp ), 0, 2 );
261 myOriginDimGrpLayout->addWidget( myYSpin, 0, 3 );
262 myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_WIDTH" ), myOriginDimGrp ), 1, 0 );
263 myOriginDimGrpLayout->addWidget( myWidthSpin, 1, 1 );
264 myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_HEIGHT" ), myOriginDimGrp ), 1, 2 );
265 myOriginDimGrpLayout->addWidget( myHeightSpin, 1, 3 );
267 aTopLayout->addWidget( myOriginDimGrp );
269 /***************************************************************/
271 myButtonGrp = new QGroupBox( this );
272 QHBoxLayout* myButtonGrpLayout = new QHBoxLayout( myButtonGrp );
273 myButtonGrpLayout->setSpacing( SPACING_SIZE ); myButtonGrpLayout->setMargin( MARGIN_SIZE );
275 myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), myButtonGrp );
276 myOkBtn->setAutoDefault( true ); myOkBtn->setDefault( true );
277 myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), myButtonGrp );
278 myApplyBtn->setAutoDefault( true );
279 myCancelBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), myButtonGrp );
280 myCancelBtn->setAutoDefault( true );
282 myButtonGrpLayout->addWidget( myOkBtn );
283 myButtonGrpLayout->addSpacing( 10 );
284 myButtonGrpLayout->addWidget( myApplyBtn );
285 myButtonGrpLayout->addSpacing( 10 );
286 myButtonGrpLayout->addStretch();
287 myButtonGrpLayout->addWidget( myCancelBtn );
289 aTopLayout->addWidget( myButtonGrp );
291 /***************************************************************/
293 // --> first init from preferences
294 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
296 QColor titleColor = mgr->colorValue("SMESH", "scalar_bar_title_color",
297 QColor(255, 255, 255));
298 myTitleColorBtn->setColor(titleColor);
299 myTitleFontCombo->setCurrentIndex(0);
300 if (mgr->hasValue("SMESH", "scalar_bar_title_font")) {
301 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
302 if( f.family()=="Arial" )
303 myTitleFontCombo->setCurrentIndex(0);
304 if( f.family()=="Courier" )
305 myTitleFontCombo->setCurrentIndex(1);
306 if( f.family()=="Times")
307 myTitleFontCombo->setCurrentIndex(2);
309 myTitleBoldCheck->setChecked ( f.bold() );
310 myTitleItalicCheck->setChecked( f.italic() );
311 myTitleShadowCheck->setChecked( f.underline() );
314 QColor labelColor = mgr->colorValue("SMESH", "scalar_bar_label_color",
315 QColor(255, 255, 255));
316 myLabelsColorBtn->setColor(labelColor);
317 myLabelsFontCombo->setCurrentIndex(0);
318 if (mgr->hasValue("SMESH", "scalar_bar_label_font")) {
319 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
320 if (f.family() == "Arial")
321 myLabelsFontCombo->setCurrentIndex(0);
322 if (f.family() == "Courier")
323 myLabelsFontCombo->setCurrentIndex(1);
324 if (f.family() == "Times")
325 myLabelsFontCombo->setCurrentIndex(2);
327 myLabelsBoldCheck ->setChecked( f.bold() );
328 myLabelsItalicCheck->setChecked( f.italic() );
329 myLabelsShadowCheck->setChecked( f.underline() );
332 int aNbColors = mgr->integerValue("SMESH", "scalar_bar_num_colors", 64);
333 myColorsSpin->setValue(aNbColors);
335 int aNbLabels = mgr->integerValue("SMESH", "scalar_bar_num_labels", 5);
336 myLabelsSpin->setValue(aNbLabels);
338 int aOrientation = mgr->integerValue( "SMESH", "scalar_bar_orientation", 1 );
339 bool isHoriz = aOrientation == 1;
341 myHorizRadioBtn->setChecked(true);
343 myVertRadioBtn->setChecked(true);
344 myIniOrientation = myVertRadioBtn->isChecked();
346 QString name = isHoriz ? "scalar_bar_horizontal_%1" : "scalar_bar_vertical_%1";
348 myIniX = mgr->doubleValue("SMESH", name.arg( "x" ),
349 myHorizRadioBtn->isChecked() ? DEF_HOR_X : DEF_VER_X);
351 myIniY = mgr->doubleValue("SMESH", name.arg( "y" ),
352 myHorizRadioBtn->isChecked() ? DEF_HOR_Y : DEF_VER_Y);
354 myIniW = mgr->doubleValue("SMESH", name.arg( "width" ),
355 myHorizRadioBtn->isChecked() ? DEF_HOR_W : DEF_VER_W);
357 myIniH = mgr->doubleValue("SMESH", name.arg( "height" ),
358 myHorizRadioBtn->isChecked() ? DEF_HOR_H : DEF_VER_H);
360 setOriginAndSize(myIniX, myIniY, myIniW, myIniH);
362 // --> then init from selection if necessary
363 onSelectionChanged();
365 /***************************************************************/
367 connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( onOk() ) );
368 connect( myApplyBtn, SIGNAL( clicked() ), this, SLOT( onApply() ) );
369 connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( onCancel() ) );
370 connect( myXSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
371 connect( myYSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
372 connect( aOrientationGrp, SIGNAL( buttonClicked( int ) ), this, SLOT( onOrientationChanged() ) );
373 connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
374 connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onCancel() ) );
377 //=================================================================================================
379 * SMESHGUI_Preferences_ScalarBarDlg::~SMESHGUI_Preferences_ScalarBarDlg
383 //=================================================================================================
384 SMESHGUI_Preferences_ScalarBarDlg::~SMESHGUI_Preferences_ScalarBarDlg()
388 //=================================================================================================
390 * SMESHGUI_Preferences_ScalarBarDlg::onOk
394 //=================================================================================================
395 void SMESHGUI_Preferences_ScalarBarDlg::onOk()
401 //=================================================================================================
403 * SMESHGUI_Preferences_ScalarBarDlg::onApply
407 //=================================================================================================
408 bool SMESHGUI_Preferences_ScalarBarDlg::onApply()
410 // Scalar Bar properties
413 vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
415 vtkTextProperty* aTitleTextPrp = myScalarBarActor->GetTitleTextProperty();
416 QColor aTColor = myTitleColorBtn->color();
417 aTitleTextPrp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
418 if ( myTitleFontCombo->currentIndex() == 0 )
419 aTitleTextPrp->SetFontFamilyToArial();
420 else if ( myTitleFontCombo->currentIndex() == 1 )
421 aTitleTextPrp->SetFontFamilyToCourier();
423 aTitleTextPrp->SetFontFamilyToTimes();
424 aTitleTextPrp->SetBold( myTitleBoldCheck->isChecked() );
425 aTitleTextPrp->SetItalic( myTitleItalicCheck->isChecked() );
426 aTitleTextPrp->SetShadow( myTitleShadowCheck->isChecked() );
427 myScalarBarActor->SetTitleTextProperty( aTitleTextPrp );
429 vtkTextProperty* aLabelsTextPrp = myScalarBarActor->GetLabelTextProperty();
430 QColor aLColor = myLabelsColorBtn->color();
431 aLabelsTextPrp->SetColor( aLColor.red()/255., aLColor.green()/255., aLColor.blue()/255. );
432 if ( myLabelsFontCombo->currentIndex() == 0 )
433 aLabelsTextPrp->SetFontFamilyToArial();
434 else if ( myLabelsFontCombo->currentIndex() == 1 )
435 aLabelsTextPrp->SetFontFamilyToCourier();
437 aLabelsTextPrp->SetFontFamilyToTimes();
438 aLabelsTextPrp->SetBold( myLabelsBoldCheck->isChecked() );
439 aLabelsTextPrp->SetItalic( myLabelsItalicCheck->isChecked() );
440 aLabelsTextPrp->SetShadow( myLabelsShadowCheck->isChecked() );
441 myScalarBarActor->SetLabelTextProperty( aLabelsTextPrp );
443 myScalarBarActor->SetNumberOfLabels( myLabelsSpin->value() );
444 myScalarBarActor->SetMaximumNumberOfColors( myColorsSpin->value() );
446 if ( myHorizRadioBtn->isChecked() )
447 myScalarBarActor->SetOrientationToHorizontal();
449 myScalarBarActor->SetOrientationToVertical();
451 myScalarBarActor->SetPosition( myXSpin->value(), myYSpin->value() );
452 myScalarBarActor->SetWidth( myWidthSpin->value() );
453 myScalarBarActor->SetHeight( myHeightSpin->value() );
455 double aMin = myMinEdit->text().toDouble();
456 double aMax = myMaxEdit->text().toDouble();
457 vtkLookupTable* myLookupTable =
458 static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
459 myLookupTable->SetRange( aMin, aMax );
460 myLookupTable->SetNumberOfTableValues(myColorsSpin->value());
461 myLookupTable->Build();
462 SMESH::RepaintCurrentView();
466 //=================================================================================================
468 * SMESHGUI_Preferences_ScalarBarDlg::onCancel
472 //=================================================================================================
473 void SMESHGUI_Preferences_ScalarBarDlg::onCancel()
478 //=================================================================================================
480 * SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged
482 * Called when selection changed
484 //=================================================================================================
485 void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged()
488 mySelectionMgr->selectedObjects(aList);
490 if (aList.Extent() == 1) {
491 Handle(SALOME_InteractiveObject) anIO = aList.First();
492 if( anIO->hasEntry() ) {
493 SMESH_Actor* anActor = SMESH::FindActorByEntry(anIO->getEntry());
494 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
496 vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
498 if ( myScalarBarActor->GetLookupTable() ) {
499 vtkFloatingPointType *range = myScalarBarActor->GetLookupTable()->GetRange();
500 myMinEdit->setText( QString::number( range[0],'g',12 ) );
501 myMaxEdit->setText( QString::number( range[1],'g',12 ) );
504 vtkTextProperty* aTitleTextPrp = myScalarBarActor->GetTitleTextProperty();
505 vtkFloatingPointType aTColor[3];
506 aTitleTextPrp->GetColor( aTColor );
507 myTitleColorBtn->setColor( QColor( (int)( aTColor[0]*255 ), (int)( aTColor[1]*255 ), (int)( aTColor[2]*255 ) ) );
508 myTitleFontCombo->setCurrentIndex( aTitleTextPrp->GetFontFamily() );
509 myTitleBoldCheck->setChecked( aTitleTextPrp->GetBold() );
510 myTitleItalicCheck->setChecked( aTitleTextPrp->GetItalic() );
511 myTitleShadowCheck->setChecked( aTitleTextPrp->GetShadow() );
513 vtkTextProperty* aLabelsTextPrp = myScalarBarActor->GetLabelTextProperty();
514 vtkFloatingPointType aLColor[3];
515 aLabelsTextPrp->GetColor( aLColor );
516 myLabelsColorBtn->setColor( QColor( (int)( aLColor[0]*255 ), (int)( aLColor[1]*255 ), (int)( aLColor[2]*255 ) ) );
517 myLabelsFontCombo->setCurrentIndex( aLabelsTextPrp->GetFontFamily() );
518 myLabelsBoldCheck->setChecked( aLabelsTextPrp->GetBold() );
519 myLabelsItalicCheck->setChecked( aLabelsTextPrp->GetItalic() );
520 myLabelsShadowCheck->setChecked( aLabelsTextPrp->GetShadow() );
522 myLabelsSpin->setValue( myScalarBarActor->GetNumberOfLabels() );
523 myColorsSpin->setValue( myScalarBarActor->GetMaximumNumberOfColors() );
525 if ( myScalarBarActor->GetOrientation() == VTK_ORIENT_VERTICAL )
526 myVertRadioBtn->setChecked( true );
528 myHorizRadioBtn->setChecked( true );
529 myIniOrientation = myVertRadioBtn->isChecked();
531 myIniX = myScalarBarActor->GetPosition()[0];
532 myIniY = myScalarBarActor->GetPosition()[1];
533 myIniW = myScalarBarActor->GetWidth();
534 myIniH = myScalarBarActor->GetHeight();
535 setOriginAndSize( myIniX, myIniY, myIniW, myIniH );
537 myRangeGrp->setEnabled( true );
538 myFontGrp->setEnabled( true );
539 myLabColorGrp->setEnabled( true );
540 myOrientationGrp->setEnabled( true );
541 myOriginDimGrp->setEnabled( true );
542 myOkBtn->setEnabled( true );
543 myApplyBtn->setEnabled( true );
549 myRangeGrp->setEnabled( false );
550 myFontGrp->setEnabled( false );
551 myLabColorGrp->setEnabled( false );
552 myOrientationGrp->setEnabled( false );
553 myOriginDimGrp->setEnabled( false );
554 myOkBtn->setEnabled( false );
555 myApplyBtn->setEnabled( false );
558 //=================================================================================================
560 * SMESHGUI_Preferences_ScalarBarDlg::closeEvent
562 * Close event handler
564 //=================================================================================================
565 void SMESHGUI_Preferences_ScalarBarDlg::closeEvent( QCloseEvent* e )
568 QDialog::closeEvent( e );
571 //=================================================================================================
573 * SMESHGUI_Preferences_ScalarBarDlg::onXYChanged
575 * Called when X, Y values are changed
577 //=================================================================================================
578 void SMESHGUI_Preferences_ScalarBarDlg::onXYChanged()
580 myWidthSpin->setMaximum( 1.0 - myXSpin->value() );
581 myHeightSpin->setMaximum( 1.0 - myYSpin->value() );
584 //=================================================================================================
586 * SMESHGUI_Preferences_ScalarBarDlg::setOriginAndSize
588 * Called when X, Y values are changed
590 //=================================================================================================
591 void SMESHGUI_Preferences_ScalarBarDlg::setOriginAndSize( const double x,
596 blockSignals( true );
597 myXSpin->setValue( x );
598 myYSpin->setValue( y );
599 myWidthSpin->setMaximum( 1.0 );
600 myWidthSpin->setValue( w );
601 myHeightSpin->setMaximum( 1.0 );
602 myHeightSpin->setValue( h );
603 blockSignals( false );
607 //=================================================================================================
609 * SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged
611 * Called when orientation is changed
613 //=================================================================================================
614 void SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged()
616 initScalarBarFromResources();
618 int aOrientation = myVertRadioBtn->isChecked();
619 if ( aOrientation == myIniOrientation )
620 setOriginAndSize( myIniX, myIniY, myIniW, myIniH );
622 setOriginAndSize( aOrientation ? DEF_VER_X : DEF_HOR_X,
623 aOrientation ? DEF_VER_Y : DEF_HOR_Y,
624 aOrientation ? DEF_VER_W : DEF_HOR_W,
625 aOrientation ? DEF_VER_H : DEF_HOR_H );
628 //=================================================================================================
630 * SMESHGUI_Preferences_ScalarBarDlg::initScalarBarFromResources()
632 * Rereading vertical and horizontal default positions from resources.
634 //=================================================================================================
635 void SMESHGUI_Preferences_ScalarBarDlg::initScalarBarFromResources()
637 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
640 // initialize from resoources
643 name = QString("scalar_bar_horizontal_%1");
644 if (mgr->hasValue("SMESH", name.arg( "x" )))
645 DEF_HOR_X = mgr->doubleValue("SMESH", name.arg( "x" ));
646 if (mgr->hasValue("SMESH", name.arg( "y" )))
647 DEF_HOR_Y = mgr->doubleValue("SMESH", name.arg( "y" ));
648 if (mgr->hasValue("SMESH", name.arg( "width" )))
649 DEF_HOR_W = mgr->doubleValue("SMESH", name.arg( "width" ));
650 if (mgr->hasValue("SMESH", name.arg( "height" )))
651 DEF_HOR_H = mgr->doubleValue("SMESH", name.arg( "height" ));
654 name = QString("scalar_bar_vertical_%1");
655 if (mgr->hasValue("SMESH", name.arg( "x" )))
656 DEF_VER_X = mgr->doubleValue("SMESH", name.arg( "x" ));
657 if (mgr->hasValue("SMESH", name.arg( "y" )))
658 DEF_VER_Y = mgr->doubleValue("SMESH", name.arg( "y" ));
659 if (mgr->hasValue("SMESH", name.arg( "width" )))
660 DEF_VER_W = mgr->doubleValue("SMESH", name.arg( "width" ));
661 if (mgr->hasValue("SMESH", name.arg( "height" )))
662 DEF_VER_H = mgr->doubleValue("SMESH", name.arg( "height" ));