1 // Copyright (C) 2007-2010 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
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_Preferences_ScalarBarDlg.cxx
25 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
28 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
31 #include "SMESHGUI_SpinBox.h"
32 #include "SMESHGUI_VTKUtils.h"
33 #include "SMESHGUI_Utils.h"
35 #include <SMESH_Actor.h>
37 // SALOME GUI includes
38 #include <SUIT_Desktop.h>
39 #include <SUIT_ResourceMgr.h>
40 #include <SUIT_Session.h>
41 #include <SUIT_MessageBox.h>
43 #include <LightApp_Application.h>
44 #include <LightApp_SelectionMgr.h>
45 #include <SALOME_ListIO.hxx>
46 #include <SalomeApp_IntSpinBox.h>
48 #include <QtxColorButton.h>
51 #include <QButtonGroup>
57 #include <QPushButton>
58 #include <QRadioButton>
59 #include <QHBoxLayout>
60 #include <QVBoxLayout>
61 #include <QGridLayout>
62 #include <QDoubleValidator>
65 #include <vtkTextProperty.h>
66 #include <vtkScalarBarActor.h>
67 #include <vtkLookupTable.h>
69 #define MINIMUM_WIDTH 70
70 #define MARGIN_SIZE 11
71 #define SPACING_SIZE 6
73 // Only one instance is allowed
74 SMESHGUI_Preferences_ScalarBarDlg* SMESHGUI_Preferences_ScalarBarDlg::myDlg = 0;
76 //=================================================================================================
78 * SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties
80 * Gets the only instance of "Scalar Bar Properties" dialog box
82 //=================================================================================================
83 void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( SMESHGUI* theModule )
86 myDlg = new SMESHGUI_Preferences_ScalarBarDlg( theModule );
91 myDlg->activateWindow();
95 //=================================================================================================
97 * SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg
101 //=================================================================================================
102 SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* theModule )
103 : QDialog( SMESH::GetDesktop( theModule ) ),
104 mySMESHGUI( theModule ),
105 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
117 setAttribute( Qt::WA_DeleteOnClose, true );
118 setWindowTitle( tr("SMESH_PROPERTIES_SCALARBAR") );
119 setSizeGripEnabled(true);
123 /******************************************************************************/
125 QVBoxLayout* aTopLayout = new QVBoxLayout( this );
126 aTopLayout->setSpacing( SPACING_SIZE ); aTopLayout->setMargin( MARGIN_SIZE );
128 /******************************************************************************/
130 myRangeGrp = new QGroupBox ( tr( "SMESH_RANGE_SCALARBAR" ), this );
131 QHBoxLayout* myRangeGrpLayout = new QHBoxLayout( myRangeGrp );
132 myRangeGrpLayout->setSpacing( SPACING_SIZE ); myRangeGrpLayout->setMargin( MARGIN_SIZE );
134 myMinEdit = new QLineEdit( myRangeGrp );
135 myMinEdit->setMinimumWidth( MINIMUM_WIDTH );
136 myMinEdit->setValidator( new QDoubleValidator( this ) );
138 myMaxEdit = new QLineEdit( myRangeGrp );
139 myMaxEdit->setMinimumWidth( MINIMUM_WIDTH );
140 myMaxEdit->setValidator( new QDoubleValidator( this ) );
142 myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MIN" ), myRangeGrp ) );
143 myRangeGrpLayout->addWidget( myMinEdit );
144 myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MAX" ), myRangeGrp ) );
145 myRangeGrpLayout->addWidget( myMaxEdit );
147 aTopLayout->addWidget( myRangeGrp );
149 /******************************************************************************/
151 myFontGrp = new QGroupBox ( tr( "SMESH_FONT_SCALARBAR" ), this );
152 QGridLayout* myFontGrpLayout = new QGridLayout( myFontGrp );
153 myFontGrpLayout->setSpacing( SPACING_SIZE ); myFontGrpLayout->setMargin( MARGIN_SIZE );
155 myTitleColorBtn = new QtxColorButton( myFontGrp );
157 myTitleFontCombo = new QComboBox( myFontGrp );
158 myTitleFontCombo->setMinimumWidth( MINIMUM_WIDTH );
159 myTitleFontCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
160 myTitleFontCombo->addItem( tr( "SMESH_FONT_ARIAL" ) );
161 myTitleFontCombo->addItem( tr( "SMESH_FONT_COURIER" ) );
162 myTitleFontCombo->addItem( tr( "SMESH_FONT_TIMES" ) );
164 myTitleBoldCheck = new QCheckBox( tr( "SMESH_FONT_BOLD" ), myFontGrp );
165 myTitleItalicCheck = new QCheckBox( tr( "SMESH_FONT_ITALIC" ), myFontGrp );
166 myTitleShadowCheck = new QCheckBox( tr( "SMESH_FONT_SHADOW" ), myFontGrp );
168 myLabelsColorBtn = new QtxColorButton( myFontGrp );
170 myLabelsFontCombo = new QComboBox( myFontGrp );
171 myLabelsFontCombo->setMinimumWidth( MINIMUM_WIDTH );
172 myLabelsFontCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
173 myLabelsFontCombo->addItem( tr( "SMESH_FONT_ARIAL" ) );
174 myLabelsFontCombo->addItem( tr( "SMESH_FONT_COURIER" ) );
175 myLabelsFontCombo->addItem( tr( "SMESH_FONT_TIMES" ) );
177 myLabelsBoldCheck = new QCheckBox( tr( "SMESH_FONT_BOLD" ), myFontGrp );
178 myLabelsItalicCheck = new QCheckBox( tr( "SMESH_FONT_ITALIC" ), myFontGrp );
179 myLabelsShadowCheck = new QCheckBox( tr( "SMESH_FONT_SHADOW" ), myFontGrp );
181 myFontGrpLayout->addWidget( new QLabel( tr( "SMESH_TITLE" ), myFontGrp ), 0, 0 );
182 myFontGrpLayout->addWidget( myTitleColorBtn, 0, 1 );
183 myFontGrpLayout->addWidget( myTitleFontCombo, 0, 2 );
184 myFontGrpLayout->addWidget( myTitleBoldCheck, 0, 3 );
185 myFontGrpLayout->addWidget( myTitleItalicCheck, 0, 4 );
186 myFontGrpLayout->addWidget( myTitleShadowCheck, 0, 5 );
188 myFontGrpLayout->addWidget( new QLabel( tr( "SMESH_LABELS" ), myFontGrp ), 1, 0 );
189 myFontGrpLayout->addWidget( myLabelsColorBtn, 1, 1 );
190 myFontGrpLayout->addWidget( myLabelsFontCombo, 1, 2 );
191 myFontGrpLayout->addWidget( myLabelsBoldCheck, 1, 3 );
192 myFontGrpLayout->addWidget( myLabelsItalicCheck, 1, 4 );
193 myFontGrpLayout->addWidget( myLabelsShadowCheck, 1, 5 );
195 aTopLayout->addWidget( myFontGrp );
197 /******************************************************************************/
199 myLabColorGrp = new QGroupBox ( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), this );
200 QHBoxLayout* myLabColorGrpLayout = new QHBoxLayout( myLabColorGrp );
201 myLabColorGrpLayout->setSpacing( SPACING_SIZE ); myLabColorGrpLayout->setMargin( MARGIN_SIZE );
203 myColorsSpin = new SalomeApp_IntSpinBox( myLabColorGrp );
204 myColorsSpin->setAcceptNames( false ); // No Notebook variables allowed
205 myColorsSpin->setRange( 2, 256 );
206 myColorsSpin->setSingleStep( 1 );
207 myColorsSpin->setMinimumWidth( MINIMUM_WIDTH );
208 myColorsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
210 myLabelsSpin = new SalomeApp_IntSpinBox( myLabColorGrp );
211 myLabelsSpin->setAcceptNames( false ); // No Notebook variables allowed
212 myLabelsSpin->setRange( 2, 65 );
213 myLabelsSpin->setSingleStep( 1 );
214 myLabelsSpin->setMinimumWidth( MINIMUM_WIDTH );
215 myLabelsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
217 myLabColorGrpLayout->addWidget( new QLabel( tr( "SMESH_NUMBEROFCOLORS" ), myLabColorGrp ) );
218 myLabColorGrpLayout->addWidget( myColorsSpin );
219 myLabColorGrpLayout->addWidget( new QLabel( tr( "SMESH_NUMBEROFLABELS" ), myLabColorGrp ) );
220 myLabColorGrpLayout->addWidget( myLabelsSpin );
222 aTopLayout->addWidget( myLabColorGrp );
224 /******************************************************************************/
226 myOrientationGrp = new QGroupBox ( tr( "SMESH_ORIENTATION" ), this );
227 QButtonGroup* aOrientationGrp = new QButtonGroup( this );
228 QHBoxLayout* myOrientationGrpLayout = new QHBoxLayout( myOrientationGrp );
229 myOrientationGrpLayout->setSpacing( SPACING_SIZE ); myOrientationGrpLayout->setMargin( MARGIN_SIZE );
231 myVertRadioBtn = new QRadioButton( tr( "SMESH_VERTICAL" ), myOrientationGrp );
232 myHorizRadioBtn = new QRadioButton( tr( "SMESH_HORIZONTAL" ), myOrientationGrp );
233 myVertRadioBtn->setChecked( true );
235 myOrientationGrpLayout->addWidget( myVertRadioBtn );
236 myOrientationGrpLayout->addWidget( myHorizRadioBtn );
237 aOrientationGrp->addButton(myVertRadioBtn);
238 aOrientationGrp->addButton(myHorizRadioBtn);
240 aTopLayout->addWidget( myOrientationGrp );
242 /******************************************************************************/
244 myOriginDimGrp = new QGroupBox ( tr("SMESH_POSITION_SIZE_SCALARBAR"), this );
245 QGridLayout* myOriginDimGrpLayout = new QGridLayout( myOriginDimGrp );
246 myOriginDimGrpLayout->setSpacing( SPACING_SIZE ); myOriginDimGrpLayout->setMargin( MARGIN_SIZE );
248 myXSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
249 myXSpin->setAcceptNames( false );
250 myXSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" );
251 myXSpin->setMinimumWidth( MINIMUM_WIDTH );
252 myXSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
254 myYSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
255 myYSpin->setAcceptNames( false );
256 myYSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" );
257 myYSpin->setMinimumWidth( MINIMUM_WIDTH );
258 myYSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
260 myWidthSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
261 myWidthSpin->setAcceptNames( false );
262 myWidthSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" );
263 myWidthSpin->setMinimumWidth( MINIMUM_WIDTH );
264 myWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
266 myHeightSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
267 myHeightSpin->setAcceptNames( false );
268 myHeightSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" );
269 myHeightSpin->setMinimumWidth( MINIMUM_WIDTH );
270 myHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
272 myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_X_SCALARBAR" ), myOriginDimGrp ), 0, 0 );
273 myOriginDimGrpLayout->addWidget( myXSpin, 0, 1 );
274 myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_Y_SCALARBAR" ), myOriginDimGrp ), 0, 2 );
275 myOriginDimGrpLayout->addWidget( myYSpin, 0, 3 );
276 myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_WIDTH" ), myOriginDimGrp ), 1, 0 );
277 myOriginDimGrpLayout->addWidget( myWidthSpin, 1, 1 );
278 myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_HEIGHT" ), myOriginDimGrp ), 1, 2 );
279 myOriginDimGrpLayout->addWidget( myHeightSpin, 1, 3 );
281 aTopLayout->addWidget( myOriginDimGrp );
283 /***************************************************************/
285 myButtonGrp = new QGroupBox( this );
286 QHBoxLayout* myButtonGrpLayout = new QHBoxLayout( myButtonGrp );
287 myButtonGrpLayout->setSpacing( SPACING_SIZE ); myButtonGrpLayout->setMargin( MARGIN_SIZE );
289 myOkBtn = new QPushButton( tr( "SMESH_BUT_APPLY_AND_CLOSE" ), myButtonGrp );
290 myOkBtn->setAutoDefault( true ); myOkBtn->setDefault( true );
291 myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), myButtonGrp );
292 myApplyBtn->setAutoDefault( true );
293 myCancelBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), myButtonGrp );
294 myCancelBtn->setAutoDefault( true );
295 myHelpBtn = new QPushButton( tr("SMESH_BUT_HELP"), myButtonGrp );
296 myHelpBtn->setAutoDefault(true);
298 myButtonGrpLayout->addWidget( myOkBtn );
299 myButtonGrpLayout->addSpacing( 10 );
300 myButtonGrpLayout->addWidget( myApplyBtn );
301 myButtonGrpLayout->addSpacing( 10 );
302 myButtonGrpLayout->addStretch();
303 myButtonGrpLayout->addWidget( myCancelBtn );
304 myButtonGrpLayout->addWidget( myHelpBtn );
306 aTopLayout->addWidget( myButtonGrp );
308 /***************************************************************/
310 // --> first init from preferences
311 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
313 QColor titleColor = mgr->colorValue("SMESH", "scalar_bar_title_color",
314 QColor(255, 255, 255));
315 myTitleColorBtn->setColor(titleColor);
316 myTitleFontCombo->setCurrentIndex(0);
317 if (mgr->hasValue("SMESH", "scalar_bar_title_font")) {
318 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
319 if( f.family()=="Arial" )
320 myTitleFontCombo->setCurrentIndex(0);
321 if( f.family()=="Courier" )
322 myTitleFontCombo->setCurrentIndex(1);
323 if( f.family()=="Times")
324 myTitleFontCombo->setCurrentIndex(2);
326 myTitleBoldCheck->setChecked ( f.bold() );
327 myTitleItalicCheck->setChecked( f.italic() );
328 myTitleShadowCheck->setChecked( f.overline() );
331 QColor labelColor = mgr->colorValue("SMESH", "scalar_bar_label_color",
332 QColor(255, 255, 255));
333 myLabelsColorBtn->setColor(labelColor);
334 myLabelsFontCombo->setCurrentIndex(0);
335 if (mgr->hasValue("SMESH", "scalar_bar_label_font")) {
336 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
337 if (f.family() == "Arial")
338 myLabelsFontCombo->setCurrentIndex(0);
339 if (f.family() == "Courier")
340 myLabelsFontCombo->setCurrentIndex(1);
341 if (f.family() == "Times")
342 myLabelsFontCombo->setCurrentIndex(2);
344 myLabelsBoldCheck ->setChecked( f.bold() );
345 myLabelsItalicCheck->setChecked( f.italic() );
346 myLabelsShadowCheck->setChecked( f.overline() );
349 int aNbColors = mgr->integerValue("SMESH", "scalar_bar_num_colors", 64);
350 myColorsSpin->setValue(aNbColors);
352 int aNbLabels = mgr->integerValue("SMESH", "scalar_bar_num_labels", 5);
353 myLabelsSpin->setValue(aNbLabels);
355 int aOrientation = mgr->integerValue( "SMESH", "scalar_bar_orientation", 1 );
356 bool isHoriz = aOrientation == 1;
358 myHorizRadioBtn->setChecked(true);
360 myVertRadioBtn->setChecked(true);
361 myIniOrientation = myVertRadioBtn->isChecked();
363 QString name = isHoriz ? "scalar_bar_horizontal_%1" : "scalar_bar_vertical_%1";
365 myIniX = mgr->doubleValue("SMESH", name.arg( "x" ),
366 myHorizRadioBtn->isChecked() ? DEF_HOR_X : DEF_VER_X);
368 myIniY = mgr->doubleValue("SMESH", name.arg( "y" ),
369 myHorizRadioBtn->isChecked() ? DEF_HOR_Y : DEF_VER_Y);
371 myIniW = mgr->doubleValue("SMESH", name.arg( "width" ),
372 myHorizRadioBtn->isChecked() ? DEF_HOR_W : DEF_VER_W);
374 myIniH = mgr->doubleValue("SMESH", name.arg( "height" ),
375 myHorizRadioBtn->isChecked() ? DEF_HOR_H : DEF_VER_H);
377 setOriginAndSize(myIniX, myIniY, myIniW, myIniH);
379 // --> then init from selection if necessary
380 onSelectionChanged();
382 /***************************************************************/
384 connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( onOk() ) );
385 connect( myApplyBtn, SIGNAL( clicked() ), this, SLOT( onApply() ) );
386 connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( onCancel() ) );
387 connect( myHelpBtn, SIGNAL(clicked()), this, SLOT( onHelp() ) );
388 connect( myXSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
389 connect( myYSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
390 connect( aOrientationGrp, SIGNAL( buttonClicked( int ) ), this, SLOT( onOrientationChanged() ) );
391 connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
392 connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onCancel() ) );
394 myHelpFileName = "about_quality_controls_page.html";
397 //=================================================================================================
399 * SMESHGUI_Preferences_ScalarBarDlg::~SMESHGUI_Preferences_ScalarBarDlg
403 //=================================================================================================
404 SMESHGUI_Preferences_ScalarBarDlg::~SMESHGUI_Preferences_ScalarBarDlg()
408 //=================================================================================================
410 * SMESHGUI_Preferences_ScalarBarDlg::onOk
414 //=================================================================================================
415 void SMESHGUI_Preferences_ScalarBarDlg::onOk()
421 //=================================================================================================
423 * SMESHGUI_Preferences_ScalarBarDlg::onApply
427 //=================================================================================================
428 bool SMESHGUI_Preferences_ScalarBarDlg::onApply()
430 // Scalar Bar properties
433 vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
435 vtkTextProperty* aTitleTextPrp = myScalarBarActor->GetTitleTextProperty();
436 QColor aTColor = myTitleColorBtn->color();
437 aTitleTextPrp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
438 if ( myTitleFontCombo->currentIndex() == 0 )
439 aTitleTextPrp->SetFontFamilyToArial();
440 else if ( myTitleFontCombo->currentIndex() == 1 )
441 aTitleTextPrp->SetFontFamilyToCourier();
443 aTitleTextPrp->SetFontFamilyToTimes();
444 aTitleTextPrp->SetBold( myTitleBoldCheck->isChecked() );
445 aTitleTextPrp->SetItalic( myTitleItalicCheck->isChecked() );
446 aTitleTextPrp->SetShadow( myTitleShadowCheck->isChecked() );
447 myScalarBarActor->SetTitleTextProperty( aTitleTextPrp );
449 vtkTextProperty* aLabelsTextPrp = myScalarBarActor->GetLabelTextProperty();
450 QColor aLColor = myLabelsColorBtn->color();
451 aLabelsTextPrp->SetColor( aLColor.red()/255., aLColor.green()/255., aLColor.blue()/255. );
452 if ( myLabelsFontCombo->currentIndex() == 0 )
453 aLabelsTextPrp->SetFontFamilyToArial();
454 else if ( myLabelsFontCombo->currentIndex() == 1 )
455 aLabelsTextPrp->SetFontFamilyToCourier();
457 aLabelsTextPrp->SetFontFamilyToTimes();
458 aLabelsTextPrp->SetBold( myLabelsBoldCheck->isChecked() );
459 aLabelsTextPrp->SetItalic( myLabelsItalicCheck->isChecked() );
460 aLabelsTextPrp->SetShadow( myLabelsShadowCheck->isChecked() );
461 myScalarBarActor->SetLabelTextProperty( aLabelsTextPrp );
463 myScalarBarActor->SetNumberOfLabels( myLabelsSpin->value() );
464 myScalarBarActor->SetMaximumNumberOfColors( myColorsSpin->value() );
466 if ( myHorizRadioBtn->isChecked() )
467 myScalarBarActor->SetOrientationToHorizontal();
469 myScalarBarActor->SetOrientationToVertical();
471 myScalarBarActor->SetPosition( myXSpin->value(), myYSpin->value() );
472 myScalarBarActor->SetWidth( myWidthSpin->value() );
473 myScalarBarActor->SetHeight( myHeightSpin->value() );
475 double aMin = myMinEdit->text().toDouble();
476 double aMax = myMaxEdit->text().toDouble();
477 vtkLookupTable* myLookupTable =
478 static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
479 myLookupTable->SetRange( aMin, aMax );
480 myLookupTable->SetNumberOfTableValues(myColorsSpin->value());
481 myLookupTable->Build();
482 SMESH::RepaintCurrentView();
486 //=================================================================================================
488 * SMESHGUI_Preferences_ScalarBarDlg::onCancel
492 //=================================================================================================
493 void SMESHGUI_Preferences_ScalarBarDlg::onCancel()
498 //=================================================================================================
500 * SMESHGUI_Preferences_ScalarBarDlg::onHelp
504 //=================================================================================================
505 void SMESHGUI_Preferences_ScalarBarDlg::onHelp()
507 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
509 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
513 platform = "winapplication";
515 platform = "application";
517 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
518 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
519 arg(app->resourceMgr()->stringValue("ExternalBrowser",
521 arg(myHelpFileName));
525 //=================================================================================================
527 * SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged
529 * Called when selection changed
531 //=================================================================================================
532 void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged()
535 mySelectionMgr->selectedObjects(aList);
537 if (aList.Extent() == 1) {
538 Handle(SALOME_InteractiveObject) anIO = aList.First();
539 if( anIO->hasEntry() ) {
540 SMESH_Actor* anActor = SMESH::FindActorByEntry(anIO->getEntry());
541 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
543 vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
545 if ( myScalarBarActor->GetLookupTable() ) {
546 vtkFloatingPointType *range = myScalarBarActor->GetLookupTable()->GetRange();
547 myMinEdit->setText( QString::number( range[0],'g',12 ) );
548 myMaxEdit->setText( QString::number( range[1],'g',12 ) );
551 vtkTextProperty* aTitleTextPrp = myScalarBarActor->GetTitleTextProperty();
552 vtkFloatingPointType aTColor[3];
553 aTitleTextPrp->GetColor( aTColor );
554 myTitleColorBtn->setColor( QColor( (int)( aTColor[0]*255 ), (int)( aTColor[1]*255 ), (int)( aTColor[2]*255 ) ) );
555 myTitleFontCombo->setCurrentIndex( aTitleTextPrp->GetFontFamily() );
556 myTitleBoldCheck->setChecked( aTitleTextPrp->GetBold() );
557 myTitleItalicCheck->setChecked( aTitleTextPrp->GetItalic() );
558 myTitleShadowCheck->setChecked( aTitleTextPrp->GetShadow() );
560 vtkTextProperty* aLabelsTextPrp = myScalarBarActor->GetLabelTextProperty();
561 vtkFloatingPointType aLColor[3];
562 aLabelsTextPrp->GetColor( aLColor );
563 myLabelsColorBtn->setColor( QColor( (int)( aLColor[0]*255 ), (int)( aLColor[1]*255 ), (int)( aLColor[2]*255 ) ) );
564 myLabelsFontCombo->setCurrentIndex( aLabelsTextPrp->GetFontFamily() );
565 myLabelsBoldCheck->setChecked( aLabelsTextPrp->GetBold() );
566 myLabelsItalicCheck->setChecked( aLabelsTextPrp->GetItalic() );
567 myLabelsShadowCheck->setChecked( aLabelsTextPrp->GetShadow() );
569 myLabelsSpin->setValue( myScalarBarActor->GetNumberOfLabels() );
570 myColorsSpin->setValue( myScalarBarActor->GetMaximumNumberOfColors() );
572 if ( myScalarBarActor->GetOrientation() == VTK_ORIENT_VERTICAL )
573 myVertRadioBtn->setChecked( true );
575 myHorizRadioBtn->setChecked( true );
576 myIniOrientation = myVertRadioBtn->isChecked();
578 myIniX = myScalarBarActor->GetPosition()[0];
579 myIniY = myScalarBarActor->GetPosition()[1];
580 myIniW = myScalarBarActor->GetWidth();
581 myIniH = myScalarBarActor->GetHeight();
582 setOriginAndSize( myIniX, myIniY, myIniW, myIniH );
584 myRangeGrp->setEnabled( true );
585 myFontGrp->setEnabled( true );
586 myLabColorGrp->setEnabled( true );
587 myOrientationGrp->setEnabled( true );
588 myOriginDimGrp->setEnabled( true );
589 myOkBtn->setEnabled( true );
590 myApplyBtn->setEnabled( true );
596 myRangeGrp->setEnabled( false );
597 myFontGrp->setEnabled( false );
598 myLabColorGrp->setEnabled( false );
599 myOrientationGrp->setEnabled( false );
600 myOriginDimGrp->setEnabled( false );
601 myOkBtn->setEnabled( false );
602 myApplyBtn->setEnabled( false );
605 //=================================================================================================
607 * SMESHGUI_Preferences_ScalarBarDlg::closeEvent
609 * Close event handler
611 //=================================================================================================
612 void SMESHGUI_Preferences_ScalarBarDlg::closeEvent( QCloseEvent* e )
615 QDialog::closeEvent( e );
618 //=================================================================================================
620 * SMESHGUI_Preferences_ScalarBarDlg::onXYChanged
622 * Called when X, Y values are changed
624 //=================================================================================================
625 void SMESHGUI_Preferences_ScalarBarDlg::onXYChanged()
627 myWidthSpin->setMaximum( 1.0 - myXSpin->value() );
628 myHeightSpin->setMaximum( 1.0 - myYSpin->value() );
631 //=================================================================================================
633 * SMESHGUI_Preferences_ScalarBarDlg::setOriginAndSize
635 * Called when X, Y values are changed
637 //=================================================================================================
638 void SMESHGUI_Preferences_ScalarBarDlg::setOriginAndSize( const double x,
643 blockSignals( true );
644 myXSpin->setValue( x );
645 myYSpin->setValue( y );
646 myWidthSpin->setMaximum( 1.0 );
647 myWidthSpin->setValue( w );
648 myHeightSpin->setMaximum( 1.0 );
649 myHeightSpin->setValue( h );
650 blockSignals( false );
654 //=================================================================================================
656 * SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged
658 * Called when orientation is changed
660 //=================================================================================================
661 void SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged()
663 initScalarBarFromResources();
665 int aOrientation = myVertRadioBtn->isChecked();
666 if ( aOrientation == myIniOrientation )
667 setOriginAndSize( myIniX, myIniY, myIniW, myIniH );
669 setOriginAndSize( aOrientation ? DEF_VER_X : DEF_HOR_X,
670 aOrientation ? DEF_VER_Y : DEF_HOR_Y,
671 aOrientation ? DEF_VER_W : DEF_HOR_W,
672 aOrientation ? DEF_VER_H : DEF_HOR_H );
675 //=================================================================================================
677 * SMESHGUI_Preferences_ScalarBarDlg::initScalarBarFromResources()
679 * Rereading vertical and horizontal default positions from resources.
681 //=================================================================================================
682 void SMESHGUI_Preferences_ScalarBarDlg::initScalarBarFromResources()
684 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
687 // initialize from resoources
690 name = QString("scalar_bar_horizontal_%1");
691 if (mgr->hasValue("SMESH", name.arg( "x" )))
692 DEF_HOR_X = mgr->doubleValue("SMESH", name.arg( "x" ));
693 if (mgr->hasValue("SMESH", name.arg( "y" )))
694 DEF_HOR_Y = mgr->doubleValue("SMESH", name.arg( "y" ));
695 if (mgr->hasValue("SMESH", name.arg( "width" )))
696 DEF_HOR_W = mgr->doubleValue("SMESH", name.arg( "width" ));
697 if (mgr->hasValue("SMESH", name.arg( "height" )))
698 DEF_HOR_H = mgr->doubleValue("SMESH", name.arg( "height" ));
701 name = QString("scalar_bar_vertical_%1");
702 if (mgr->hasValue("SMESH", name.arg( "x" )))
703 DEF_VER_X = mgr->doubleValue("SMESH", name.arg( "x" ));
704 if (mgr->hasValue("SMESH", name.arg( "y" )))
705 DEF_VER_Y = mgr->doubleValue("SMESH", name.arg( "y" ));
706 if (mgr->hasValue("SMESH", name.arg( "width" )))
707 DEF_VER_W = mgr->doubleValue("SMESH", name.arg( "width" ));
708 if (mgr->hasValue("SMESH", name.arg( "height" )))
709 DEF_VER_H = mgr->doubleValue("SMESH", name.arg( "height" ));