1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI_Preferences_ScalarBarDlg.cxx
24 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
27 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
30 #include "SMESHGUI_SpinBox.h"
31 #include "SMESHGUI_VTKUtils.h"
32 #include "SMESHGUI_Utils.h"
34 #include <SMESH_Actor.h>
36 // SALOME GUI includes
37 #include <SUIT_Desktop.h>
38 #include <SUIT_ResourceMgr.h>
39 #include <SUIT_Session.h>
40 #include <SUIT_MessageBox.h>
42 #include <LightApp_Application.h>
43 #include <LightApp_SelectionMgr.h>
44 #include <SALOME_ListIO.hxx>
45 #include <SalomeApp_IntSpinBox.h>
47 #include <QtxColorButton.h>
50 #include <QButtonGroup>
56 #include <QPushButton>
57 #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 SalomeApp_IntSpinBox( myLabColorGrp );
203 myColorsSpin->setAcceptNames( false ); // No Notebook variables allowed
204 myColorsSpin->setRange( 2, 256 );
205 myColorsSpin->setSingleStep( 1 );
206 myColorsSpin->setMinimumWidth( MINIMUM_WIDTH );
207 myColorsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
209 myLabelsSpin = new SalomeApp_IntSpinBox( myLabColorGrp );
210 myLabelsSpin->setAcceptNames( false ); // No Notebook variables allowed
211 myLabelsSpin->setRange( 2, 65 );
212 myLabelsSpin->setSingleStep( 1 );
213 myLabelsSpin->setMinimumWidth( MINIMUM_WIDTH );
214 myLabelsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
216 myLabColorGrpLayout->addWidget( new QLabel( tr( "SMESH_NUMBEROFCOLORS" ), myLabColorGrp ) );
217 myLabColorGrpLayout->addWidget( myColorsSpin );
218 myLabColorGrpLayout->addWidget( new QLabel( tr( "SMESH_NUMBEROFLABELS" ), myLabColorGrp ) );
219 myLabColorGrpLayout->addWidget( myLabelsSpin );
221 aTopLayout->addWidget( myLabColorGrp );
223 /******************************************************************************/
225 myOrientationGrp = new QGroupBox ( tr( "SMESH_ORIENTATION" ), this );
226 QButtonGroup* aOrientationGrp = new QButtonGroup( this );
227 QHBoxLayout* myOrientationGrpLayout = new QHBoxLayout( myOrientationGrp );
228 myOrientationGrpLayout->setSpacing( SPACING_SIZE ); myOrientationGrpLayout->setMargin( MARGIN_SIZE );
230 myVertRadioBtn = new QRadioButton( tr( "SMESH_VERTICAL" ), myOrientationGrp );
231 myHorizRadioBtn = new QRadioButton( tr( "SMESH_HORIZONTAL" ), myOrientationGrp );
232 myVertRadioBtn->setChecked( true );
234 myOrientationGrpLayout->addWidget( myVertRadioBtn );
235 myOrientationGrpLayout->addWidget( myHorizRadioBtn );
236 aOrientationGrp->addButton(myVertRadioBtn);
237 aOrientationGrp->addButton(myHorizRadioBtn);
239 aTopLayout->addWidget( myOrientationGrp );
241 /******************************************************************************/
243 myOriginDimGrp = new QGroupBox ( tr("SMESH_POSITION_SIZE_SCALARBAR"), this );
244 QGridLayout* myOriginDimGrpLayout = new QGridLayout( myOriginDimGrp );
245 myOriginDimGrpLayout->setSpacing( SPACING_SIZE ); myOriginDimGrpLayout->setMargin( MARGIN_SIZE );
247 myXSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
248 myXSpin->setAcceptNames( false );
249 myXSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" );
250 myXSpin->setMinimumWidth( MINIMUM_WIDTH );
251 myXSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
253 myYSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
254 myYSpin->setAcceptNames( false );
255 myYSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" );
256 myYSpin->setMinimumWidth( MINIMUM_WIDTH );
257 myYSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
259 myWidthSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
260 myWidthSpin->setAcceptNames( false );
261 myWidthSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" );
262 myWidthSpin->setMinimumWidth( MINIMUM_WIDTH );
263 myWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
265 myHeightSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
266 myHeightSpin->setAcceptNames( false );
267 myHeightSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" );
268 myHeightSpin->setMinimumWidth( MINIMUM_WIDTH );
269 myHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
271 myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_X_SCALARBAR" ), myOriginDimGrp ), 0, 0 );
272 myOriginDimGrpLayout->addWidget( myXSpin, 0, 1 );
273 myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_Y_SCALARBAR" ), myOriginDimGrp ), 0, 2 );
274 myOriginDimGrpLayout->addWidget( myYSpin, 0, 3 );
275 myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_WIDTH" ), myOriginDimGrp ), 1, 0 );
276 myOriginDimGrpLayout->addWidget( myWidthSpin, 1, 1 );
277 myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_HEIGHT" ), myOriginDimGrp ), 1, 2 );
278 myOriginDimGrpLayout->addWidget( myHeightSpin, 1, 3 );
280 aTopLayout->addWidget( myOriginDimGrp );
282 /***************************************************************/
284 myButtonGrp = new QGroupBox( this );
285 QHBoxLayout* myButtonGrpLayout = new QHBoxLayout( myButtonGrp );
286 myButtonGrpLayout->setSpacing( SPACING_SIZE ); myButtonGrpLayout->setMargin( MARGIN_SIZE );
288 myOkBtn = new QPushButton( tr( "SMESH_BUT_APPLY_AND_CLOSE" ), myButtonGrp );
289 myOkBtn->setAutoDefault( true ); myOkBtn->setDefault( true );
290 myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), myButtonGrp );
291 myApplyBtn->setAutoDefault( true );
292 myCancelBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), myButtonGrp );
293 myCancelBtn->setAutoDefault( true );
294 myHelpBtn = new QPushButton( tr("SMESH_BUT_HELP"), myButtonGrp );
295 myHelpBtn->setAutoDefault(true);
297 myButtonGrpLayout->addWidget( myOkBtn );
298 myButtonGrpLayout->addSpacing( 10 );
299 myButtonGrpLayout->addWidget( myApplyBtn );
300 myButtonGrpLayout->addSpacing( 10 );
301 myButtonGrpLayout->addStretch();
302 myButtonGrpLayout->addWidget( myCancelBtn );
303 myButtonGrpLayout->addWidget( myHelpBtn );
305 aTopLayout->addWidget( myButtonGrp );
307 /***************************************************************/
309 // --> first init from preferences
310 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
312 QColor titleColor = mgr->colorValue("SMESH", "scalar_bar_title_color",
313 QColor(255, 255, 255));
314 myTitleColorBtn->setColor(titleColor);
315 myTitleFontCombo->setCurrentIndex(0);
316 if (mgr->hasValue("SMESH", "scalar_bar_title_font")) {
317 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
318 if( f.family()=="Arial" )
319 myTitleFontCombo->setCurrentIndex(0);
320 if( f.family()=="Courier" )
321 myTitleFontCombo->setCurrentIndex(1);
322 if( f.family()=="Times")
323 myTitleFontCombo->setCurrentIndex(2);
325 myTitleBoldCheck->setChecked ( f.bold() );
326 myTitleItalicCheck->setChecked( f.italic() );
327 myTitleShadowCheck->setChecked( f.overline() );
330 QColor labelColor = mgr->colorValue("SMESH", "scalar_bar_label_color",
331 QColor(255, 255, 255));
332 myLabelsColorBtn->setColor(labelColor);
333 myLabelsFontCombo->setCurrentIndex(0);
334 if (mgr->hasValue("SMESH", "scalar_bar_label_font")) {
335 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
336 if (f.family() == "Arial")
337 myLabelsFontCombo->setCurrentIndex(0);
338 if (f.family() == "Courier")
339 myLabelsFontCombo->setCurrentIndex(1);
340 if (f.family() == "Times")
341 myLabelsFontCombo->setCurrentIndex(2);
343 myLabelsBoldCheck ->setChecked( f.bold() );
344 myLabelsItalicCheck->setChecked( f.italic() );
345 myLabelsShadowCheck->setChecked( f.overline() );
348 int aNbColors = mgr->integerValue("SMESH", "scalar_bar_num_colors", 64);
349 myColorsSpin->setValue(aNbColors);
351 int aNbLabels = mgr->integerValue("SMESH", "scalar_bar_num_labels", 5);
352 myLabelsSpin->setValue(aNbLabels);
354 int aOrientation = mgr->integerValue( "SMESH", "scalar_bar_orientation", 1 );
355 bool isHoriz = aOrientation == 1;
357 myHorizRadioBtn->setChecked(true);
359 myVertRadioBtn->setChecked(true);
360 myIniOrientation = myVertRadioBtn->isChecked();
362 QString name = isHoriz ? "scalar_bar_horizontal_%1" : "scalar_bar_vertical_%1";
364 myIniX = mgr->doubleValue("SMESH", name.arg( "x" ),
365 myHorizRadioBtn->isChecked() ? DEF_HOR_X : DEF_VER_X);
367 myIniY = mgr->doubleValue("SMESH", name.arg( "y" ),
368 myHorizRadioBtn->isChecked() ? DEF_HOR_Y : DEF_VER_Y);
370 myIniW = mgr->doubleValue("SMESH", name.arg( "width" ),
371 myHorizRadioBtn->isChecked() ? DEF_HOR_W : DEF_VER_W);
373 myIniH = mgr->doubleValue("SMESH", name.arg( "height" ),
374 myHorizRadioBtn->isChecked() ? DEF_HOR_H : DEF_VER_H);
376 setOriginAndSize(myIniX, myIniY, myIniW, myIniH);
378 // --> then init from selection if necessary
379 onSelectionChanged();
381 /***************************************************************/
383 connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( onOk() ) );
384 connect( myApplyBtn, SIGNAL( clicked() ), this, SLOT( onApply() ) );
385 connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( onCancel() ) );
386 connect( myHelpBtn, SIGNAL(clicked()), this, SLOT( onHelp() ) );
387 connect( myXSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
388 connect( myYSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
389 connect( aOrientationGrp, SIGNAL( buttonClicked( int ) ), this, SLOT( onOrientationChanged() ) );
390 connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
391 connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onCancel() ) );
393 myHelpFileName = "about_quality_controls_page.html";
396 //=================================================================================================
398 * SMESHGUI_Preferences_ScalarBarDlg::~SMESHGUI_Preferences_ScalarBarDlg
402 //=================================================================================================
403 SMESHGUI_Preferences_ScalarBarDlg::~SMESHGUI_Preferences_ScalarBarDlg()
407 //=================================================================================================
409 * SMESHGUI_Preferences_ScalarBarDlg::onOk
413 //=================================================================================================
414 void SMESHGUI_Preferences_ScalarBarDlg::onOk()
420 //=================================================================================================
422 * SMESHGUI_Preferences_ScalarBarDlg::onApply
426 //=================================================================================================
427 bool SMESHGUI_Preferences_ScalarBarDlg::onApply()
429 // Scalar Bar properties
432 vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
434 vtkTextProperty* aTitleTextPrp = myScalarBarActor->GetTitleTextProperty();
435 QColor aTColor = myTitleColorBtn->color();
436 aTitleTextPrp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
437 if ( myTitleFontCombo->currentIndex() == 0 )
438 aTitleTextPrp->SetFontFamilyToArial();
439 else if ( myTitleFontCombo->currentIndex() == 1 )
440 aTitleTextPrp->SetFontFamilyToCourier();
442 aTitleTextPrp->SetFontFamilyToTimes();
443 aTitleTextPrp->SetBold( myTitleBoldCheck->isChecked() );
444 aTitleTextPrp->SetItalic( myTitleItalicCheck->isChecked() );
445 aTitleTextPrp->SetShadow( myTitleShadowCheck->isChecked() );
446 myScalarBarActor->SetTitleTextProperty( aTitleTextPrp );
448 vtkTextProperty* aLabelsTextPrp = myScalarBarActor->GetLabelTextProperty();
449 QColor aLColor = myLabelsColorBtn->color();
450 aLabelsTextPrp->SetColor( aLColor.red()/255., aLColor.green()/255., aLColor.blue()/255. );
451 if ( myLabelsFontCombo->currentIndex() == 0 )
452 aLabelsTextPrp->SetFontFamilyToArial();
453 else if ( myLabelsFontCombo->currentIndex() == 1 )
454 aLabelsTextPrp->SetFontFamilyToCourier();
456 aLabelsTextPrp->SetFontFamilyToTimes();
457 aLabelsTextPrp->SetBold( myLabelsBoldCheck->isChecked() );
458 aLabelsTextPrp->SetItalic( myLabelsItalicCheck->isChecked() );
459 aLabelsTextPrp->SetShadow( myLabelsShadowCheck->isChecked() );
460 myScalarBarActor->SetLabelTextProperty( aLabelsTextPrp );
462 myScalarBarActor->SetNumberOfLabels( myLabelsSpin->value() );
463 myScalarBarActor->SetMaximumNumberOfColors( myColorsSpin->value() );
465 if ( myHorizRadioBtn->isChecked() )
466 myScalarBarActor->SetOrientationToHorizontal();
468 myScalarBarActor->SetOrientationToVertical();
470 myScalarBarActor->SetPosition( myXSpin->value(), myYSpin->value() );
471 myScalarBarActor->SetWidth( myWidthSpin->value() );
472 myScalarBarActor->SetHeight( myHeightSpin->value() );
474 double aMin = myMinEdit->text().toDouble();
475 double aMax = myMaxEdit->text().toDouble();
476 vtkLookupTable* myLookupTable =
477 static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
478 myLookupTable->SetRange( aMin, aMax );
479 myLookupTable->SetNumberOfTableValues(myColorsSpin->value());
480 myLookupTable->Build();
481 SMESH::RepaintCurrentView();
485 //=================================================================================================
487 * SMESHGUI_Preferences_ScalarBarDlg::onCancel
491 //=================================================================================================
492 void SMESHGUI_Preferences_ScalarBarDlg::onCancel()
497 //=================================================================================================
499 * SMESHGUI_Preferences_ScalarBarDlg::onHelp
503 //=================================================================================================
504 void SMESHGUI_Preferences_ScalarBarDlg::onHelp()
506 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
508 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
512 platform = "winapplication";
514 platform = "application";
516 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
517 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
518 arg(app->resourceMgr()->stringValue("ExternalBrowser",
520 arg(myHelpFileName));
524 //=================================================================================================
526 * SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged
528 * Called when selection changed
530 //=================================================================================================
531 void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged()
534 mySelectionMgr->selectedObjects(aList);
536 if (aList.Extent() == 1) {
537 Handle(SALOME_InteractiveObject) anIO = aList.First();
538 if( anIO->hasEntry() ) {
539 SMESH_Actor* anActor = SMESH::FindActorByEntry(anIO->getEntry());
540 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
542 vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
544 if ( myScalarBarActor->GetLookupTable() ) {
545 vtkFloatingPointType *range = myScalarBarActor->GetLookupTable()->GetRange();
546 myMinEdit->setText( QString::number( range[0],'g',12 ) );
547 myMaxEdit->setText( QString::number( range[1],'g',12 ) );
550 vtkTextProperty* aTitleTextPrp = myScalarBarActor->GetTitleTextProperty();
551 vtkFloatingPointType aTColor[3];
552 aTitleTextPrp->GetColor( aTColor );
553 myTitleColorBtn->setColor( QColor( (int)( aTColor[0]*255 ), (int)( aTColor[1]*255 ), (int)( aTColor[2]*255 ) ) );
554 myTitleFontCombo->setCurrentIndex( aTitleTextPrp->GetFontFamily() );
555 myTitleBoldCheck->setChecked( aTitleTextPrp->GetBold() );
556 myTitleItalicCheck->setChecked( aTitleTextPrp->GetItalic() );
557 myTitleShadowCheck->setChecked( aTitleTextPrp->GetShadow() );
559 vtkTextProperty* aLabelsTextPrp = myScalarBarActor->GetLabelTextProperty();
560 vtkFloatingPointType aLColor[3];
561 aLabelsTextPrp->GetColor( aLColor );
562 myLabelsColorBtn->setColor( QColor( (int)( aLColor[0]*255 ), (int)( aLColor[1]*255 ), (int)( aLColor[2]*255 ) ) );
563 myLabelsFontCombo->setCurrentIndex( aLabelsTextPrp->GetFontFamily() );
564 myLabelsBoldCheck->setChecked( aLabelsTextPrp->GetBold() );
565 myLabelsItalicCheck->setChecked( aLabelsTextPrp->GetItalic() );
566 myLabelsShadowCheck->setChecked( aLabelsTextPrp->GetShadow() );
568 myLabelsSpin->setValue( myScalarBarActor->GetNumberOfLabels() );
569 myColorsSpin->setValue( myScalarBarActor->GetMaximumNumberOfColors() );
571 if ( myScalarBarActor->GetOrientation() == VTK_ORIENT_VERTICAL )
572 myVertRadioBtn->setChecked( true );
574 myHorizRadioBtn->setChecked( true );
575 myIniOrientation = myVertRadioBtn->isChecked();
577 myIniX = myScalarBarActor->GetPosition()[0];
578 myIniY = myScalarBarActor->GetPosition()[1];
579 myIniW = myScalarBarActor->GetWidth();
580 myIniH = myScalarBarActor->GetHeight();
581 setOriginAndSize( myIniX, myIniY, myIniW, myIniH );
583 myRangeGrp->setEnabled( true );
584 myFontGrp->setEnabled( true );
585 myLabColorGrp->setEnabled( true );
586 myOrientationGrp->setEnabled( true );
587 myOriginDimGrp->setEnabled( true );
588 myOkBtn->setEnabled( true );
589 myApplyBtn->setEnabled( true );
595 myRangeGrp->setEnabled( false );
596 myFontGrp->setEnabled( false );
597 myLabColorGrp->setEnabled( false );
598 myOrientationGrp->setEnabled( false );
599 myOriginDimGrp->setEnabled( false );
600 myOkBtn->setEnabled( false );
601 myApplyBtn->setEnabled( false );
604 //=================================================================================================
606 * SMESHGUI_Preferences_ScalarBarDlg::closeEvent
608 * Close event handler
610 //=================================================================================================
611 void SMESHGUI_Preferences_ScalarBarDlg::closeEvent( QCloseEvent* e )
614 QDialog::closeEvent( e );
617 //=================================================================================================
619 * SMESHGUI_Preferences_ScalarBarDlg::onXYChanged
621 * Called when X, Y values are changed
623 //=================================================================================================
624 void SMESHGUI_Preferences_ScalarBarDlg::onXYChanged()
626 myWidthSpin->setMaximum( 1.0 - myXSpin->value() );
627 myHeightSpin->setMaximum( 1.0 - myYSpin->value() );
630 //=================================================================================================
632 * SMESHGUI_Preferences_ScalarBarDlg::setOriginAndSize
634 * Called when X, Y values are changed
636 //=================================================================================================
637 void SMESHGUI_Preferences_ScalarBarDlg::setOriginAndSize( const double x,
642 blockSignals( true );
643 myXSpin->setValue( x );
644 myYSpin->setValue( y );
645 myWidthSpin->setMaximum( 1.0 );
646 myWidthSpin->setValue( w );
647 myHeightSpin->setMaximum( 1.0 );
648 myHeightSpin->setValue( h );
649 blockSignals( false );
653 //=================================================================================================
655 * SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged
657 * Called when orientation is changed
659 //=================================================================================================
660 void SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged()
662 initScalarBarFromResources();
664 int aOrientation = myVertRadioBtn->isChecked();
665 if ( aOrientation == myIniOrientation )
666 setOriginAndSize( myIniX, myIniY, myIniW, myIniH );
668 setOriginAndSize( aOrientation ? DEF_VER_X : DEF_HOR_X,
669 aOrientation ? DEF_VER_Y : DEF_HOR_Y,
670 aOrientation ? DEF_VER_W : DEF_HOR_W,
671 aOrientation ? DEF_VER_H : DEF_HOR_H );
674 //=================================================================================================
676 * SMESHGUI_Preferences_ScalarBarDlg::initScalarBarFromResources()
678 * Rereading vertical and horizontal default positions from resources.
680 //=================================================================================================
681 void SMESHGUI_Preferences_ScalarBarDlg::initScalarBarFromResources()
683 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
686 // initialize from resoources
689 name = QString("scalar_bar_horizontal_%1");
690 if (mgr->hasValue("SMESH", name.arg( "x" )))
691 DEF_HOR_X = mgr->doubleValue("SMESH", name.arg( "x" ));
692 if (mgr->hasValue("SMESH", name.arg( "y" )))
693 DEF_HOR_Y = mgr->doubleValue("SMESH", name.arg( "y" ));
694 if (mgr->hasValue("SMESH", name.arg( "width" )))
695 DEF_HOR_W = mgr->doubleValue("SMESH", name.arg( "width" ));
696 if (mgr->hasValue("SMESH", name.arg( "height" )))
697 DEF_HOR_H = mgr->doubleValue("SMESH", name.arg( "height" ));
700 name = QString("scalar_bar_vertical_%1");
701 if (mgr->hasValue("SMESH", name.arg( "x" )))
702 DEF_VER_X = mgr->doubleValue("SMESH", name.arg( "x" ));
703 if (mgr->hasValue("SMESH", name.arg( "y" )))
704 DEF_VER_Y = mgr->doubleValue("SMESH", name.arg( "y" ));
705 if (mgr->hasValue("SMESH", name.arg( "width" )))
706 DEF_VER_W = mgr->doubleValue("SMESH", name.arg( "width" ));
707 if (mgr->hasValue("SMESH", name.arg( "height" )))
708 DEF_VER_H = mgr->doubleValue("SMESH", name.arg( "height" ));