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>
38 #include <SUIT_Session.h>
39 #include <SUIT_MessageBox.h>
41 #include <LightApp_Application.h>
42 #include <LightApp_SelectionMgr.h>
43 #include <SALOME_ListIO.hxx>
45 #include <QtxDoubleSpinBox.h>
46 #include <QtxColorButton.h>
49 #include <QButtonGroup>
55 #include <QPushButton>
56 #include <QRadioButton>
58 #include <QHBoxLayout>
59 #include <QVBoxLayout>
60 #include <QGridLayout>
61 #include <QDoubleValidator>
64 #include <vtkTextProperty.h>
65 #include <vtkScalarBarActor.h>
66 #include <vtkLookupTable.h>
68 #define MINIMUM_WIDTH 70
69 #define MARGIN_SIZE 11
70 #define SPACING_SIZE 6
72 // Only one instance is allowed
73 SMESHGUI_Preferences_ScalarBarDlg* SMESHGUI_Preferences_ScalarBarDlg::myDlg = 0;
75 //=================================================================================================
77 * SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties
79 * Gets the only instance of "Scalar Bar Properties" dialog box
81 //=================================================================================================
82 void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( SMESHGUI* theModule )
85 myDlg = new SMESHGUI_Preferences_ScalarBarDlg( theModule );
90 myDlg->activateWindow();
94 //=================================================================================================
96 * SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg
100 //=================================================================================================
101 SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* theModule )
102 : QDialog( SMESH::GetDesktop( theModule ) ),
103 mySMESHGUI( theModule ),
104 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
116 setAttribute( Qt::WA_DeleteOnClose, true );
117 setWindowTitle( tr("SMESH_PROPERTIES_SCALARBAR") );
118 setSizeGripEnabled(true);
122 /******************************************************************************/
124 QVBoxLayout* aTopLayout = new QVBoxLayout( this );
125 aTopLayout->setSpacing( SPACING_SIZE ); aTopLayout->setMargin( MARGIN_SIZE );
127 /******************************************************************************/
129 myRangeGrp = new QGroupBox ( tr( "SMESH_RANGE_SCALARBAR" ), this );
130 QHBoxLayout* myRangeGrpLayout = new QHBoxLayout( myRangeGrp );
131 myRangeGrpLayout->setSpacing( SPACING_SIZE ); myRangeGrpLayout->setMargin( MARGIN_SIZE );
133 myMinEdit = new QLineEdit( myRangeGrp );
134 myMinEdit->setMinimumWidth( MINIMUM_WIDTH );
135 myMinEdit->setValidator( new QDoubleValidator( this ) );
137 myMaxEdit = new QLineEdit( myRangeGrp );
138 myMaxEdit->setMinimumWidth( MINIMUM_WIDTH );
139 myMaxEdit->setValidator( new QDoubleValidator( this ) );
141 myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MIN" ), myRangeGrp ) );
142 myRangeGrpLayout->addWidget( myMinEdit );
143 myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MAX" ), myRangeGrp ) );
144 myRangeGrpLayout->addWidget( myMaxEdit );
146 aTopLayout->addWidget( myRangeGrp );
148 /******************************************************************************/
150 myFontGrp = new QGroupBox ( tr( "SMESH_FONT_SCALARBAR" ), this );
151 QGridLayout* myFontGrpLayout = new QGridLayout( myFontGrp );
152 myFontGrpLayout->setSpacing( SPACING_SIZE ); myFontGrpLayout->setMargin( MARGIN_SIZE );
154 myTitleColorBtn = new QtxColorButton( myFontGrp );
156 myTitleFontCombo = new QComboBox( myFontGrp );
157 myTitleFontCombo->setMinimumWidth( MINIMUM_WIDTH );
158 myTitleFontCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
159 myTitleFontCombo->addItem( tr( "SMESH_FONT_ARIAL" ) );
160 myTitleFontCombo->addItem( tr( "SMESH_FONT_COURIER" ) );
161 myTitleFontCombo->addItem( tr( "SMESH_FONT_TIMES" ) );
163 myTitleBoldCheck = new QCheckBox( tr( "SMESH_FONT_BOLD" ), myFontGrp );
164 myTitleItalicCheck = new QCheckBox( tr( "SMESH_FONT_ITALIC" ), myFontGrp );
165 myTitleShadowCheck = new QCheckBox( tr( "SMESH_FONT_SHADOW" ), myFontGrp );
167 myLabelsColorBtn = new QtxColorButton( myFontGrp );
169 myLabelsFontCombo = new QComboBox( myFontGrp );
170 myLabelsFontCombo->setMinimumWidth( MINIMUM_WIDTH );
171 myLabelsFontCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
172 myLabelsFontCombo->addItem( tr( "SMESH_FONT_ARIAL" ) );
173 myLabelsFontCombo->addItem( tr( "SMESH_FONT_COURIER" ) );
174 myLabelsFontCombo->addItem( tr( "SMESH_FONT_TIMES" ) );
176 myLabelsBoldCheck = new QCheckBox( tr( "SMESH_FONT_BOLD" ), myFontGrp );
177 myLabelsItalicCheck = new QCheckBox( tr( "SMESH_FONT_ITALIC" ), myFontGrp );
178 myLabelsShadowCheck = new QCheckBox( tr( "SMESH_FONT_SHADOW" ), myFontGrp );
180 myFontGrpLayout->addWidget( new QLabel( tr( "SMESH_TITLE" ), myFontGrp ), 0, 0 );
181 myFontGrpLayout->addWidget( myTitleColorBtn, 0, 1 );
182 myFontGrpLayout->addWidget( myTitleFontCombo, 0, 2 );
183 myFontGrpLayout->addWidget( myTitleBoldCheck, 0, 3 );
184 myFontGrpLayout->addWidget( myTitleItalicCheck, 0, 4 );
185 myFontGrpLayout->addWidget( myTitleShadowCheck, 0, 5 );
187 myFontGrpLayout->addWidget( new QLabel( tr( "SMESH_LABELS" ), myFontGrp ), 1, 0 );
188 myFontGrpLayout->addWidget( myLabelsColorBtn, 1, 1 );
189 myFontGrpLayout->addWidget( myLabelsFontCombo, 1, 2 );
190 myFontGrpLayout->addWidget( myLabelsBoldCheck, 1, 3 );
191 myFontGrpLayout->addWidget( myLabelsItalicCheck, 1, 4 );
192 myFontGrpLayout->addWidget( myLabelsShadowCheck, 1, 5 );
194 aTopLayout->addWidget( myFontGrp );
196 /******************************************************************************/
198 myLabColorGrp = new QGroupBox ( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), this );
199 QHBoxLayout* myLabColorGrpLayout = new QHBoxLayout( myLabColorGrp );
200 myLabColorGrpLayout->setSpacing( SPACING_SIZE ); myLabColorGrpLayout->setMargin( MARGIN_SIZE );
202 myColorsSpin = new QSpinBox( myLabColorGrp );
203 myColorsSpin->setRange( 2, 256 );
204 myColorsSpin->setSingleStep( 1 );
205 myColorsSpin->setMinimumWidth( MINIMUM_WIDTH );
206 myColorsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
208 myLabelsSpin = new QSpinBox( myLabColorGrp );
209 myLabelsSpin->setRange( 2, 65 );
210 myLabelsSpin->setSingleStep( 1 );
211 myLabelsSpin->setMinimumWidth( MINIMUM_WIDTH );
212 myLabelsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
214 myLabColorGrpLayout->addWidget( new QLabel( tr( "SMESH_NUMBEROFCOLORS" ), myLabColorGrp ) );
215 myLabColorGrpLayout->addWidget( myColorsSpin );
216 myLabColorGrpLayout->addWidget( new QLabel( tr( "SMESH_NUMBEROFLABELS" ), myLabColorGrp ) );
217 myLabColorGrpLayout->addWidget( myLabelsSpin );
219 aTopLayout->addWidget( myLabColorGrp );
221 /******************************************************************************/
223 myOrientationGrp = new QGroupBox ( tr( "SMESH_ORIENTATION" ), this );
224 QButtonGroup* aOrientationGrp = new QButtonGroup( this );
225 QHBoxLayout* myOrientationGrpLayout = new QHBoxLayout( myOrientationGrp );
226 myOrientationGrpLayout->setSpacing( SPACING_SIZE ); myOrientationGrpLayout->setMargin( MARGIN_SIZE );
228 myVertRadioBtn = new QRadioButton( tr( "SMESH_VERTICAL" ), myOrientationGrp );
229 myHorizRadioBtn = new QRadioButton( tr( "SMESH_HORIZONTAL" ), myOrientationGrp );
230 myVertRadioBtn->setChecked( true );
232 myOrientationGrpLayout->addWidget( myVertRadioBtn );
233 myOrientationGrpLayout->addWidget( myHorizRadioBtn );
234 aOrientationGrp->addButton(myVertRadioBtn);
235 aOrientationGrp->addButton(myHorizRadioBtn);
237 aTopLayout->addWidget( myOrientationGrp );
239 /******************************************************************************/
241 myOriginDimGrp = new QGroupBox ( tr("SMESH_POSITION_SIZE_SCALARBAR"), this );
242 QGridLayout* myOriginDimGrpLayout = new QGridLayout( myOriginDimGrp );
243 myOriginDimGrpLayout->setSpacing( SPACING_SIZE ); myOriginDimGrpLayout->setMargin( MARGIN_SIZE );
245 myXSpin = new QtxDoubleSpinBox (0.0, 1.0, 0.1, myOriginDimGrp);
246 myXSpin->setMinimumWidth( MINIMUM_WIDTH );
247 myXSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
249 myYSpin = new QtxDoubleSpinBox(0.0, 1.0, 0.1, myOriginDimGrp);
250 myYSpin->setMinimumWidth( MINIMUM_WIDTH );
251 myYSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
253 myWidthSpin = new QtxDoubleSpinBox(0.0, 1.0, 0.1, myOriginDimGrp);
254 myWidthSpin->setMinimumWidth( MINIMUM_WIDTH );
255 myWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
257 myHeightSpin = new QtxDoubleSpinBox(0.0, 1.0, 0.1, myOriginDimGrp);
258 myHeightSpin->setMinimumWidth( MINIMUM_WIDTH );
259 myHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
261 myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_X_SCALARBAR" ), myOriginDimGrp ), 0, 0 );
262 myOriginDimGrpLayout->addWidget( myXSpin, 0, 1 );
263 myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_Y_SCALARBAR" ), myOriginDimGrp ), 0, 2 );
264 myOriginDimGrpLayout->addWidget( myYSpin, 0, 3 );
265 myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_WIDTH" ), myOriginDimGrp ), 1, 0 );
266 myOriginDimGrpLayout->addWidget( myWidthSpin, 1, 1 );
267 myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_HEIGHT" ), myOriginDimGrp ), 1, 2 );
268 myOriginDimGrpLayout->addWidget( myHeightSpin, 1, 3 );
270 aTopLayout->addWidget( myOriginDimGrp );
272 /***************************************************************/
274 myButtonGrp = new QGroupBox( this );
275 QHBoxLayout* myButtonGrpLayout = new QHBoxLayout( myButtonGrp );
276 myButtonGrpLayout->setSpacing( SPACING_SIZE ); myButtonGrpLayout->setMargin( MARGIN_SIZE );
278 myOkBtn = new QPushButton( tr( "SMESH_BUT_APPLY_AND_CLOSE" ), myButtonGrp );
279 myOkBtn->setAutoDefault( true ); myOkBtn->setDefault( true );
280 myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), myButtonGrp );
281 myApplyBtn->setAutoDefault( true );
282 myCancelBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), myButtonGrp );
283 myCancelBtn->setAutoDefault( true );
284 myHelpBtn = new QPushButton( tr("SMESH_BUT_HELP"), myButtonGrp );
285 myHelpBtn->setAutoDefault(true);
287 myButtonGrpLayout->addWidget( myOkBtn );
288 myButtonGrpLayout->addSpacing( 10 );
289 myButtonGrpLayout->addWidget( myApplyBtn );
290 myButtonGrpLayout->addSpacing( 10 );
291 myButtonGrpLayout->addStretch();
292 myButtonGrpLayout->addWidget( myCancelBtn );
293 myButtonGrpLayout->addWidget( myHelpBtn );
295 aTopLayout->addWidget( myButtonGrp );
297 /***************************************************************/
299 // --> first init from preferences
300 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
302 QColor titleColor = mgr->colorValue("SMESH", "scalar_bar_title_color",
303 QColor(255, 255, 255));
304 myTitleColorBtn->setColor(titleColor);
305 myTitleFontCombo->setCurrentIndex(0);
306 if (mgr->hasValue("SMESH", "scalar_bar_title_font")) {
307 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
308 if( f.family()=="Arial" )
309 myTitleFontCombo->setCurrentIndex(0);
310 if( f.family()=="Courier" )
311 myTitleFontCombo->setCurrentIndex(1);
312 if( f.family()=="Times")
313 myTitleFontCombo->setCurrentIndex(2);
315 myTitleBoldCheck->setChecked ( f.bold() );
316 myTitleItalicCheck->setChecked( f.italic() );
317 myTitleShadowCheck->setChecked( f.overline() );
320 QColor labelColor = mgr->colorValue("SMESH", "scalar_bar_label_color",
321 QColor(255, 255, 255));
322 myLabelsColorBtn->setColor(labelColor);
323 myLabelsFontCombo->setCurrentIndex(0);
324 if (mgr->hasValue("SMESH", "scalar_bar_label_font")) {
325 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
326 if (f.family() == "Arial")
327 myLabelsFontCombo->setCurrentIndex(0);
328 if (f.family() == "Courier")
329 myLabelsFontCombo->setCurrentIndex(1);
330 if (f.family() == "Times")
331 myLabelsFontCombo->setCurrentIndex(2);
333 myLabelsBoldCheck ->setChecked( f.bold() );
334 myLabelsItalicCheck->setChecked( f.italic() );
335 myLabelsShadowCheck->setChecked( f.overline() );
338 int aNbColors = mgr->integerValue("SMESH", "scalar_bar_num_colors", 64);
339 myColorsSpin->setValue(aNbColors);
341 int aNbLabels = mgr->integerValue("SMESH", "scalar_bar_num_labels", 5);
342 myLabelsSpin->setValue(aNbLabels);
344 int aOrientation = mgr->integerValue( "SMESH", "scalar_bar_orientation", 1 );
345 bool isHoriz = aOrientation == 1;
347 myHorizRadioBtn->setChecked(true);
349 myVertRadioBtn->setChecked(true);
350 myIniOrientation = myVertRadioBtn->isChecked();
352 QString name = isHoriz ? "scalar_bar_horizontal_%1" : "scalar_bar_vertical_%1";
354 myIniX = mgr->doubleValue("SMESH", name.arg( "x" ),
355 myHorizRadioBtn->isChecked() ? DEF_HOR_X : DEF_VER_X);
357 myIniY = mgr->doubleValue("SMESH", name.arg( "y" ),
358 myHorizRadioBtn->isChecked() ? DEF_HOR_Y : DEF_VER_Y);
360 myIniW = mgr->doubleValue("SMESH", name.arg( "width" ),
361 myHorizRadioBtn->isChecked() ? DEF_HOR_W : DEF_VER_W);
363 myIniH = mgr->doubleValue("SMESH", name.arg( "height" ),
364 myHorizRadioBtn->isChecked() ? DEF_HOR_H : DEF_VER_H);
366 setOriginAndSize(myIniX, myIniY, myIniW, myIniH);
368 // --> then init from selection if necessary
369 onSelectionChanged();
371 /***************************************************************/
373 connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( onOk() ) );
374 connect( myApplyBtn, SIGNAL( clicked() ), this, SLOT( onApply() ) );
375 connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( onCancel() ) );
376 connect( myHelpBtn, SIGNAL(clicked()), this, SLOT( onHelp() ) );
377 connect( myXSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
378 connect( myYSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
379 connect( aOrientationGrp, SIGNAL( buttonClicked( int ) ), this, SLOT( onOrientationChanged() ) );
380 connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
381 connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onCancel() ) );
383 myHelpFileName = "about_quality_controls_page.html";
386 //=================================================================================================
388 * SMESHGUI_Preferences_ScalarBarDlg::~SMESHGUI_Preferences_ScalarBarDlg
392 //=================================================================================================
393 SMESHGUI_Preferences_ScalarBarDlg::~SMESHGUI_Preferences_ScalarBarDlg()
397 //=================================================================================================
399 * SMESHGUI_Preferences_ScalarBarDlg::onOk
403 //=================================================================================================
404 void SMESHGUI_Preferences_ScalarBarDlg::onOk()
410 //=================================================================================================
412 * SMESHGUI_Preferences_ScalarBarDlg::onApply
416 //=================================================================================================
417 bool SMESHGUI_Preferences_ScalarBarDlg::onApply()
419 // Scalar Bar properties
422 vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
424 vtkTextProperty* aTitleTextPrp = myScalarBarActor->GetTitleTextProperty();
425 QColor aTColor = myTitleColorBtn->color();
426 aTitleTextPrp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
427 if ( myTitleFontCombo->currentIndex() == 0 )
428 aTitleTextPrp->SetFontFamilyToArial();
429 else if ( myTitleFontCombo->currentIndex() == 1 )
430 aTitleTextPrp->SetFontFamilyToCourier();
432 aTitleTextPrp->SetFontFamilyToTimes();
433 aTitleTextPrp->SetBold( myTitleBoldCheck->isChecked() );
434 aTitleTextPrp->SetItalic( myTitleItalicCheck->isChecked() );
435 aTitleTextPrp->SetShadow( myTitleShadowCheck->isChecked() );
436 myScalarBarActor->SetTitleTextProperty( aTitleTextPrp );
438 vtkTextProperty* aLabelsTextPrp = myScalarBarActor->GetLabelTextProperty();
439 QColor aLColor = myLabelsColorBtn->color();
440 aLabelsTextPrp->SetColor( aLColor.red()/255., aLColor.green()/255., aLColor.blue()/255. );
441 if ( myLabelsFontCombo->currentIndex() == 0 )
442 aLabelsTextPrp->SetFontFamilyToArial();
443 else if ( myLabelsFontCombo->currentIndex() == 1 )
444 aLabelsTextPrp->SetFontFamilyToCourier();
446 aLabelsTextPrp->SetFontFamilyToTimes();
447 aLabelsTextPrp->SetBold( myLabelsBoldCheck->isChecked() );
448 aLabelsTextPrp->SetItalic( myLabelsItalicCheck->isChecked() );
449 aLabelsTextPrp->SetShadow( myLabelsShadowCheck->isChecked() );
450 myScalarBarActor->SetLabelTextProperty( aLabelsTextPrp );
452 myScalarBarActor->SetNumberOfLabels( myLabelsSpin->value() );
453 myScalarBarActor->SetMaximumNumberOfColors( myColorsSpin->value() );
455 if ( myHorizRadioBtn->isChecked() )
456 myScalarBarActor->SetOrientationToHorizontal();
458 myScalarBarActor->SetOrientationToVertical();
460 myScalarBarActor->SetPosition( myXSpin->value(), myYSpin->value() );
461 myScalarBarActor->SetWidth( myWidthSpin->value() );
462 myScalarBarActor->SetHeight( myHeightSpin->value() );
464 double aMin = myMinEdit->text().toDouble();
465 double aMax = myMaxEdit->text().toDouble();
466 vtkLookupTable* myLookupTable =
467 static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
468 myLookupTable->SetRange( aMin, aMax );
469 myLookupTable->SetNumberOfTableValues(myColorsSpin->value());
470 myLookupTable->Build();
471 SMESH::RepaintCurrentView();
475 //=================================================================================================
477 * SMESHGUI_Preferences_ScalarBarDlg::onCancel
481 //=================================================================================================
482 void SMESHGUI_Preferences_ScalarBarDlg::onCancel()
487 //=================================================================================================
489 * SMESHGUI_Preferences_ScalarBarDlg::onHelp
493 //=================================================================================================
494 void SMESHGUI_Preferences_ScalarBarDlg::onHelp()
496 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
498 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
502 platform = "winapplication";
504 platform = "application";
506 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
507 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
508 arg(app->resourceMgr()->stringValue("ExternalBrowser",
510 arg(myHelpFileName));
514 //=================================================================================================
516 * SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged
518 * Called when selection changed
520 //=================================================================================================
521 void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged()
524 mySelectionMgr->selectedObjects(aList);
526 if (aList.Extent() == 1) {
527 Handle(SALOME_InteractiveObject) anIO = aList.First();
528 if( anIO->hasEntry() ) {
529 SMESH_Actor* anActor = SMESH::FindActorByEntry(anIO->getEntry());
530 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
532 vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
534 if ( myScalarBarActor->GetLookupTable() ) {
535 vtkFloatingPointType *range = myScalarBarActor->GetLookupTable()->GetRange();
536 myMinEdit->setText( QString::number( range[0],'g',12 ) );
537 myMaxEdit->setText( QString::number( range[1],'g',12 ) );
540 vtkTextProperty* aTitleTextPrp = myScalarBarActor->GetTitleTextProperty();
541 vtkFloatingPointType aTColor[3];
542 aTitleTextPrp->GetColor( aTColor );
543 myTitleColorBtn->setColor( QColor( (int)( aTColor[0]*255 ), (int)( aTColor[1]*255 ), (int)( aTColor[2]*255 ) ) );
544 myTitleFontCombo->setCurrentIndex( aTitleTextPrp->GetFontFamily() );
545 myTitleBoldCheck->setChecked( aTitleTextPrp->GetBold() );
546 myTitleItalicCheck->setChecked( aTitleTextPrp->GetItalic() );
547 myTitleShadowCheck->setChecked( aTitleTextPrp->GetShadow() );
549 vtkTextProperty* aLabelsTextPrp = myScalarBarActor->GetLabelTextProperty();
550 vtkFloatingPointType aLColor[3];
551 aLabelsTextPrp->GetColor( aLColor );
552 myLabelsColorBtn->setColor( QColor( (int)( aLColor[0]*255 ), (int)( aLColor[1]*255 ), (int)( aLColor[2]*255 ) ) );
553 myLabelsFontCombo->setCurrentIndex( aLabelsTextPrp->GetFontFamily() );
554 myLabelsBoldCheck->setChecked( aLabelsTextPrp->GetBold() );
555 myLabelsItalicCheck->setChecked( aLabelsTextPrp->GetItalic() );
556 myLabelsShadowCheck->setChecked( aLabelsTextPrp->GetShadow() );
558 myLabelsSpin->setValue( myScalarBarActor->GetNumberOfLabels() );
559 myColorsSpin->setValue( myScalarBarActor->GetMaximumNumberOfColors() );
561 if ( myScalarBarActor->GetOrientation() == VTK_ORIENT_VERTICAL )
562 myVertRadioBtn->setChecked( true );
564 myHorizRadioBtn->setChecked( true );
565 myIniOrientation = myVertRadioBtn->isChecked();
567 myIniX = myScalarBarActor->GetPosition()[0];
568 myIniY = myScalarBarActor->GetPosition()[1];
569 myIniW = myScalarBarActor->GetWidth();
570 myIniH = myScalarBarActor->GetHeight();
571 setOriginAndSize( myIniX, myIniY, myIniW, myIniH );
573 myRangeGrp->setEnabled( true );
574 myFontGrp->setEnabled( true );
575 myLabColorGrp->setEnabled( true );
576 myOrientationGrp->setEnabled( true );
577 myOriginDimGrp->setEnabled( true );
578 myOkBtn->setEnabled( true );
579 myApplyBtn->setEnabled( true );
585 myRangeGrp->setEnabled( false );
586 myFontGrp->setEnabled( false );
587 myLabColorGrp->setEnabled( false );
588 myOrientationGrp->setEnabled( false );
589 myOriginDimGrp->setEnabled( false );
590 myOkBtn->setEnabled( false );
591 myApplyBtn->setEnabled( false );
594 //=================================================================================================
596 * SMESHGUI_Preferences_ScalarBarDlg::closeEvent
598 * Close event handler
600 //=================================================================================================
601 void SMESHGUI_Preferences_ScalarBarDlg::closeEvent( QCloseEvent* e )
604 QDialog::closeEvent( e );
607 //=================================================================================================
609 * SMESHGUI_Preferences_ScalarBarDlg::onXYChanged
611 * Called when X, Y values are changed
613 //=================================================================================================
614 void SMESHGUI_Preferences_ScalarBarDlg::onXYChanged()
616 myWidthSpin->setMaximum( 1.0 - myXSpin->value() );
617 myHeightSpin->setMaximum( 1.0 - myYSpin->value() );
620 //=================================================================================================
622 * SMESHGUI_Preferences_ScalarBarDlg::setOriginAndSize
624 * Called when X, Y values are changed
626 //=================================================================================================
627 void SMESHGUI_Preferences_ScalarBarDlg::setOriginAndSize( const double x,
632 blockSignals( true );
633 myXSpin->setValue( x );
634 myYSpin->setValue( y );
635 myWidthSpin->setMaximum( 1.0 );
636 myWidthSpin->setValue( w );
637 myHeightSpin->setMaximum( 1.0 );
638 myHeightSpin->setValue( h );
639 blockSignals( false );
643 //=================================================================================================
645 * SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged
647 * Called when orientation is changed
649 //=================================================================================================
650 void SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged()
652 initScalarBarFromResources();
654 int aOrientation = myVertRadioBtn->isChecked();
655 if ( aOrientation == myIniOrientation )
656 setOriginAndSize( myIniX, myIniY, myIniW, myIniH );
658 setOriginAndSize( aOrientation ? DEF_VER_X : DEF_HOR_X,
659 aOrientation ? DEF_VER_Y : DEF_HOR_Y,
660 aOrientation ? DEF_VER_W : DEF_HOR_W,
661 aOrientation ? DEF_VER_H : DEF_HOR_H );
664 //=================================================================================================
666 * SMESHGUI_Preferences_ScalarBarDlg::initScalarBarFromResources()
668 * Rereading vertical and horizontal default positions from resources.
670 //=================================================================================================
671 void SMESHGUI_Preferences_ScalarBarDlg::initScalarBarFromResources()
673 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
676 // initialize from resoources
679 name = QString("scalar_bar_horizontal_%1");
680 if (mgr->hasValue("SMESH", name.arg( "x" )))
681 DEF_HOR_X = mgr->doubleValue("SMESH", name.arg( "x" ));
682 if (mgr->hasValue("SMESH", name.arg( "y" )))
683 DEF_HOR_Y = mgr->doubleValue("SMESH", name.arg( "y" ));
684 if (mgr->hasValue("SMESH", name.arg( "width" )))
685 DEF_HOR_W = mgr->doubleValue("SMESH", name.arg( "width" ));
686 if (mgr->hasValue("SMESH", name.arg( "height" )))
687 DEF_HOR_H = mgr->doubleValue("SMESH", name.arg( "height" ));
690 name = QString("scalar_bar_vertical_%1");
691 if (mgr->hasValue("SMESH", name.arg( "x" )))
692 DEF_VER_X = mgr->doubleValue("SMESH", name.arg( "x" ));
693 if (mgr->hasValue("SMESH", name.arg( "y" )))
694 DEF_VER_Y = mgr->doubleValue("SMESH", name.arg( "y" ));
695 if (mgr->hasValue("SMESH", name.arg( "width" )))
696 DEF_VER_W = mgr->doubleValue("SMESH", name.arg( "width" ));
697 if (mgr->hasValue("SMESH", name.arg( "height" )))
698 DEF_VER_H = mgr->doubleValue("SMESH", name.arg( "height" ));