1 // Copyright (C) 2007-2011 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 // VISU VISUGUI : GUI of VISU component
24 // File : VisuGUI_Prs3dDlg.cxx
25 // Author : Laurent CORNABE & Hubert ROLLAND
28 #include "VisuGUI_Prs3dDlg.h"
31 #include "VisuGUI_Tools.h"
32 #include "VisuGUI_ViewTools.h"
33 #include "VisuGUI_InputPane.h"
35 #include "SVTK_ViewWindow.h"
36 #include "SVTK_FontWidget.h"
38 #include "VISUConfig.hh"
39 #include "VISU_Convertor.hxx"
40 #include "VISU_MeshValue.hxx"
41 #include "VISU_Structures_impl.hxx"
42 #include "VISU_ScalarMapPL.hxx"
43 #include "VISU_ScalarBarActor.hxx"
44 #include "VISU_ScalarMapAct.h"
45 #include "VISU_ScalarMap_i.hh"
46 #include "VISU_Result_i.hh"
47 #include "VISU_Prs3dUtils.hh"
49 #include <SalomeApp_IntSpinBox.h>
50 #include <SalomeApp_DoubleSpinBox.h>
51 #include "LightApp_Application.h"
53 #include "SUIT_Session.h"
54 #include "SUIT_MessageBox.h"
55 #include "SUIT_ResourceMgr.h"
56 #include "SUIT_Desktop.h"
60 #include <QRadioButton>
61 #include <QButtonGroup>
64 #include <QPushButton>
66 #include <QToolButton>
69 #include <QColorDialog>
72 #include <QGridLayout>
74 #include <vtkTextProperty.h>
78 //-----------------------------------------------------------------------
79 // Text Preferences Dialog
80 //-----------------------------------------------------------------------
84 VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent)
85 : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
88 setWindowTitle(tr("TIT_TEXT_PREF"));
89 setSizeGripEnabled(TRUE);
91 QVBoxLayout* aMainLay = new QVBoxLayout(this);
92 aMainLay->setSpacing(6);
93 aMainLay->setMargin(11);
96 QGroupBox* aTitleGrp = new QGroupBox ( tr("LBL_TITLE"), this);
97 QVBoxLayout* aVBLay = new QVBoxLayout( aTitleGrp );
100 myTitleEdt = new QLineEdit (aTitleGrp);
101 aVBLay->addWidget( myTitleEdt);
104 QWidget* aHBox = new QWidget (aTitleGrp);
105 aVBLay->addWidget( aHBox );
107 QHBoxLayout* aHBLay = new QHBoxLayout( aHBox );
108 aHBLay->setSpacing(5);
110 myTitleFont = new SVTK_FontWidget (aHBox);
111 myTitleFont->Initialize();
112 aHBLay->addWidget( myTitleFont );
114 aMainLay->addWidget(aTitleGrp);
117 QGroupBox* aLabelsGrp = new QGroupBox (tr("LBL_LABELS"), this);
118 aVBLay = new QVBoxLayout( aLabelsGrp );
121 aHBox = new QWidget (aLabelsGrp);
122 aVBLay->addWidget( aHBox );
124 aHBLay = new QHBoxLayout( aHBox );
125 aHBLay->setSpacing(5);
127 myLabelFont = new SVTK_FontWidget (aHBox);
128 myLabelFont->Initialize();
129 aHBLay->addWidget( myLabelFont );
131 aMainLay->addWidget(aLabelsGrp);
133 // Common buttons ===========================================================
134 QGroupBox* GroupButtons = new QGroupBox( this );
135 //GroupButtons->setColumnLayout(0, Qt::Vertical );
136 //GroupButtons->layout()->setSpacing( 0 );
137 //GroupButtons->layout()->setMargin( 0 );
138 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons );
139 GroupButtonsLayout->setAlignment( Qt::AlignTop );
140 GroupButtonsLayout->setSpacing( 6 );
141 GroupButtonsLayout->setMargin( 11 );
143 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons );
144 buttonOk->setAutoDefault( TRUE );
145 buttonOk->setDefault( TRUE );
146 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
147 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
149 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons );
150 buttonCancel->setAutoDefault( TRUE );
151 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
153 QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons );
154 buttonHelp->setAutoDefault( TRUE );
155 GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
157 aMainLay->addWidget( GroupButtons );
159 connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
160 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
161 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp()));
165 //----------------------------------------------------------------------------
166 QString VisuGUI_TextPrefDlg::getTitleText()
168 return myTitleEdt->text();
172 //----------------------------------------------------------------------------
173 void VisuGUI_TextPrefDlg::setTitleText( const QString& theText )
175 myTitleEdt->setText(theText);
179 //----------------------------------------------------------------------------
180 void VisuGUI_TextPrefDlg::setTitleVisible(bool isVisible)
189 //----------------------------------------------------------------------------
190 void VisuGUI_TextPrefDlg::onHelp()
192 QString aHelpFileName = "scalar_map_page.html";
193 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
195 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
196 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
199 SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
200 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
201 arg(app->resourceMgr()->stringValue("ExternalBrowser",
202 "application")).arg(aHelpFileName),
203 QObject::tr("BUT_OK"));
208 //----------------------------------------------------------------------------
209 void VisuGUI_TextPrefDlg::storeBeginValues()
211 myTitle = myTitleEdt->text();
212 myTitleFont->GetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
213 myLabelFont->GetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
217 //----------------------------------------------------------------------------
219 Called when <Cancel> button is clicked, restore begin values
221 void VisuGUI_TextPrefDlg::reject()
223 myTitleEdt->setText(myTitle);
224 myTitleFont->SetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
225 myLabelFont->SetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
231 //----------------------------------------------------------------------------
233 Called when <Ok> button is clicked, store begin values
235 void VisuGUI_TextPrefDlg::accept()
243 //----------------------------------------------------------------------------
245 Provides help on F1 button click
247 void VisuGUI_TextPrefDlg::keyPressEvent( QKeyEvent* e )
249 QDialog::keyPressEvent( e );
250 if ( e->isAccepted() )
253 if ( e->key() == Qt::Key_F1 )
260 //-----------------------------------------------------------------------
261 // Scalar Bar Preferences Dialog
262 //-----------------------------------------------------------------------
266 VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent )
271 setWindowTitle( tr( "TIT_BAR_PREF" ) );
272 setSizeGripEnabled( true );
274 QString propertyName = QString( "scalar_bar_vertical_" );
276 myTitleSize = myLabelSize = myBarWidth = myBarHeight = 0;
280 QVBoxLayout* aMainLay = new QVBoxLayout( this );
281 aMainLay->setSpacing( 5 );
282 aMainLay->setMargin( 5 );
286 QGroupBox* aDimGrp = new QGroupBox( this );
287 QGridLayout* aDimGrpLay = new QGridLayout( aDimGrp );
288 aDimGrpLay->setSpacing( 5 );
289 aDimGrpLay->setMargin( 5 );
291 myTitleSizeSpin = new SalomeApp_IntSpinBox( aDimGrp );
292 myTitleSizeSpin->setAcceptNames( false );
293 myTitleSizeSpin->setRange( 0, 100 );
294 myTitleSizeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
295 myTitleSizeSpin->setMinimumWidth( 70 );
296 myTitleSizeSpin->setValue( 0 );
297 myTitleSizeSpin->setSpecialValueText( tr( "AUTO" ) );
298 QLabel* aTitleSizeLbl = new QLabel( tr( "LBL_TITLE_W" ), aDimGrp );
300 myLabelSizeSpin = new SalomeApp_IntSpinBox( aDimGrp );
301 myLabelSizeSpin->setAcceptNames( false );
302 myLabelSizeSpin->setRange( 0, 100 );
303 myLabelSizeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
304 myLabelSizeSpin->setMinimumWidth( 70 );
305 myLabelSizeSpin->setValue( 0 );
306 myLabelSizeSpin->setSpecialValueText( tr( "AUTO" ) );
307 QLabel* aLabelSizeLbl = new QLabel( tr( "LBL_LABEL_W" ), aDimGrp );
309 myBarWidthSpin = new SalomeApp_IntSpinBox( aDimGrp );
310 myBarWidthSpin->setAcceptNames( false );
311 myBarWidthSpin->setRange( 0, 100 );
312 myBarWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
313 myBarWidthSpin->setMinimumWidth( 70 );
314 myBarWidthSpin->setValue( 0 );
315 myBarWidthSpin->setSpecialValueText( tr( "AUTO" ) );
316 QLabel* aBarWidthLbl = new QLabel( tr( "LBL_BAR_W" ), aDimGrp );
318 myBarHeightSpin = new SalomeApp_IntSpinBox( aDimGrp );
319 myBarHeightSpin->setAcceptNames( false );
320 myBarHeightSpin->setRange( 0, 100 );
321 myBarHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
322 myBarHeightSpin->setMinimumWidth( 70 );
323 myBarHeightSpin->setValue( 0 );
324 myBarHeightSpin->setSpecialValueText( tr( "AUTO" ) );
325 QLabel* aBarHeightLbl = new QLabel( tr( "LBL_BAR_H" ), aDimGrp );
329 QLabel* aPrecLbl = new QLabel( tr( "PRECISION" ), aDimGrp );
330 myPrecisionSpin = new SalomeApp_IntSpinBox( aDimGrp );
331 myPrecisionSpin->setAcceptNames( false );
332 myPrecisionSpin->setRange( 1, 100 );
334 myUnitsChk = new QCheckBox( tr( "LBL_SHOW_UNITS" ), aDimGrp );
338 aDimGrpLay->addWidget( aTitleSizeLbl, 0, 0 );
339 aDimGrpLay->addWidget( myTitleSizeSpin, 0, 1 );
340 aDimGrpLay->addWidget( aLabelSizeLbl, 0, 2 );
341 aDimGrpLay->addWidget( myLabelSizeSpin, 0, 3 );
342 aDimGrpLay->addWidget( aBarWidthLbl, 1, 0 );
343 aDimGrpLay->addWidget( myBarWidthSpin, 1, 1 );
344 aDimGrpLay->addWidget( aBarHeightLbl, 1, 2 );
345 aDimGrpLay->addWidget( myBarHeightSpin, 1, 3 );
346 aDimGrpLay->addWidget( aPrecLbl, 2, 0 );
347 aDimGrpLay->addWidget( myPrecisionSpin, 2, 1 );
348 aDimGrpLay->addWidget( myUnitsChk, 2, 2, 1, 2 );
350 aMainLay->addWidget( aDimGrp );
352 // Common buttons ===========================================================
354 QGroupBox* GroupButtons = new QGroupBox( this );
355 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
356 GroupButtonsLayout->setAlignment( Qt::AlignTop );
357 GroupButtonsLayout->setSpacing( 6 );
358 GroupButtonsLayout->setMargin( 11 );
360 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons );
361 buttonOk->setAutoDefault( true );
362 buttonOk->setDefault( true );
364 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons );
365 buttonCancel->setAutoDefault( true );
367 QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons );
368 buttonHelp->setAutoDefault( true );
370 GroupButtonsLayout->addWidget( buttonOk );
371 GroupButtonsLayout->addSpacing( 5 );
372 GroupButtonsLayout->addStretch();
373 GroupButtonsLayout->addWidget( buttonCancel );
374 GroupButtonsLayout->addWidget( buttonHelp );
376 aMainLay->addWidget( GroupButtons );
378 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
379 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
380 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
381 connect( myTitleSizeSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
382 connect( myLabelSizeSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
383 connect( myBarWidthSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
384 connect( myBarHeightSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
385 connect( myUnitsChk, SIGNAL( toggled( bool ) ), this, SIGNAL( updatePreview() ) );
386 connect( myPrecisionSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
390 //----------------------------------------------------------------------------
391 void VisuGUI_BarPrefDlg::setRatios( int titleRatioSize, int labelRatioWidth,
392 int barRatioWidth, int barRatioHeight )
394 myTitleSizeSpin->setValue( myTitleSize = titleRatioSize );
395 myLabelSizeSpin->setValue( myLabelSize = labelRatioWidth );
396 myBarWidthSpin->setValue( myBarWidth = barRatioWidth );
397 myBarHeightSpin->setValue( myBarHeight = barRatioHeight );
401 //----------------------------------------------------------------------------
402 void VisuGUI_BarPrefDlg::getRatios( int& titleRatioSize, int& labelRatioWidth,
403 int& barRatioWidth, int& barRatioHeight )
405 titleRatioSize = myTitleSizeSpin->value();
406 labelRatioWidth = myLabelSizeSpin->value();
407 barRatioWidth = myBarWidthSpin->value();
408 barRatioHeight = myBarHeightSpin->value();
412 //----------------------------------------------------------------------------
413 void VisuGUI_BarPrefDlg::setLabelsPrecision( const int p )
415 myPrecisionSpin->setValue( p );
418 //----------------------------------------------------------------------------
419 int VisuGUI_BarPrefDlg::getLabelsPrecision() const
421 return myPrecisionSpin->value();
424 //----------------------------------------------------------------------------
425 void VisuGUI_BarPrefDlg::setOrientation( const int ori )
430 //----------------------------------------------------------------------------
432 int VisuGUI_BarPrefDlg::getOrientation() const
434 return myOrientation;
437 //----------------------------------------------------------------------------
438 void VisuGUI_BarPrefDlg::onHelp()
440 QString aHelpFileName = "scalar_map_page.html";
441 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
443 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
444 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
447 SUIT_MessageBox::warning( this, tr( "WRN_WARNING" ),
448 tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
449 arg( app->resourceMgr()->stringValue( "ExternalBrowser",
451 arg( aHelpFileName ) );
456 //----------------------------------------------------------------------------
457 void VisuGUI_BarPrefDlg::setUnitsVisible(bool isVisible)
459 myUnitsChk->setChecked( myUnits = isVisible );
463 //----------------------------------------------------------------------------
464 bool VisuGUI_BarPrefDlg::isUnitsVisible()
466 return myUnitsChk->isChecked();
470 //----------------------------------------------------------------------------
472 Called when <Cancel> button is clicked, restore begin values
474 void VisuGUI_BarPrefDlg::reject()
476 myTitleSizeSpin->setValue( myTitleSize );
477 myLabelSizeSpin->setValue( myLabelSize );
478 myBarWidthSpin->setValue( myBarWidth );
479 myBarHeightSpin->setValue( myBarHeight );
480 myUnitsChk->setChecked( myUnits );
481 myPrecisionSpin->setValue( myPrecision );
486 //----------------------------------------------------------------------------
488 Called when <Ok> button is clicked, store begin values
490 void VisuGUI_BarPrefDlg::accept()
493 int aBWH = myOrientation == 1 ? myBarWidthSpin->value() : myBarHeightSpin->value();
494 if( ( myLabelSizeSpin->value()+ aBWH ) > 100 )
496 SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE" ) );
500 if ( myTitleSizeSpin->value() > 100 )
502 SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE_TLT" ) );
506 myTitleSize = myTitleSizeSpin->value();
507 myLabelSize = myLabelSizeSpin->value();
508 myBarWidth = myBarWidthSpin->value();
509 myBarHeight = myBarHeightSpin->value();
510 myUnits = myUnitsChk->isChecked();
511 myPrecision = myPrecisionSpin->value();
516 //----------------------------------------------------------------------------
518 Provides help on F1 button click
520 void VisuGUI_BarPrefDlg::keyPressEvent( QKeyEvent* e )
522 QDialog::keyPressEvent( e );
523 if ( e->isAccepted() )
526 if ( e->key() == Qt::Key_F1 ) {
533 //-----------------------------------------------------------------------
535 //-----------------------------------------------------------------------
540 VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool theIsDisplayGaussMetric, bool thePreview )
545 myIsDisplayGaussMetric( theIsDisplayGaussMetric )
547 QVBoxLayout* aMainLayout = new QVBoxLayout( this );
548 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
549 QString propertyName;
550 propertyName = QString("scalar_bar_vertical_");
551 myVerX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
552 myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
553 myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
554 myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
555 myVerTS = aResourceMgr->integerValue("VISU", propertyName + "title_size", 0);
556 myVerLS = aResourceMgr->integerValue("VISU", propertyName + "label_size", 0);
557 myVerBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0);
558 myVerBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0);
560 propertyName = QString("scalar_bar_horizontal_");
561 myHorX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
562 myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
563 myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
564 myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
565 myHorTS = aResourceMgr->integerValue("VISU", propertyName + "title_size", 0);
566 myHorLS = aResourceMgr->integerValue("VISU", propertyName + "label_size", 0);
567 myHorBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0);
568 myHorBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0);
570 //aMainLayout->setSpacing(6);
572 // Range ============================================================
573 RangeGroup = new QButtonGroup ( this );
574 QGroupBox* aGB = new QGroupBox( tr("SCALAR_RANGE_GRP"),this );
575 aMainLayout->addWidget( aGB );
576 QGridLayout* RangeGroupLayout = new QGridLayout( aGB );
577 RangeGroupLayout->setAlignment( Qt::AlignTop );
578 //RangeGroupLayout->setSpacing( 6 );
579 //RangeGroupLayout->setMargin( 11 );
581 myModeLbl = new QLabel("Scalar Mode", aGB);
583 myModeCombo = new QComboBox(aGB);
585 CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), aGB);
586 CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
588 myGaussMetricLabel = new QLabel( tr("VISU_GAUSS_METRIC"), aGB );
589 myGaussMetric = new QComboBox( aGB );
590 myGaussMetric->addItem( tr("VISU_GAUSS_METRIC_AVERAGE") );
591 myGaussMetric->addItem( tr("VISU_GAUSS_METRIC_MINIMUM") );
592 myGaussMetric->addItem( tr("VISU_GAUSS_METRIC_MAXIMUM") );
593 myGaussMetric->setToolTip( tr("VISU_GAUSS_METRIC_TOOLTIP") );
595 if( !myIsDisplayGaussMetric ) {
596 myGaussMetricLabel->hide();
597 myGaussMetric->hide();
600 RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), aGB);
601 RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), aGB);
602 RangeGroup->addButton( RBFrange, 0 );
603 RangeGroup->addButton( RBIrange, 1 );
604 RBFrange->setChecked( true );
606 int aPrecision = qAbs( aResourceMgr->integerValue( "VISU", "visual_data_precision", 0 ) );
607 QDoubleValidator* dv = new QDoubleValidator(this);
608 dv->setDecimals(aPrecision);
610 MinEdit = new QLineEdit( aGB );
611 MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
612 //MinEdit->setMinimumWidth( 70 );
613 MinEdit->setValidator( dv );
614 MinEdit->setText( "0.0" );
615 QLabel* MinLabel = new QLabel (tr("LBL_MIN"), aGB);
616 MinLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
617 MinLabel->setBuddy(MinEdit);
619 MaxEdit = new QLineEdit( aGB );
620 MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
621 //MaxEdit->setMinimumWidth( 70 );
622 MaxEdit->setValidator( dv );
623 MaxEdit->setText( "0.0" );
624 QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), aGB);
625 MaxLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
626 MaxLabel->setBuddy(MaxEdit);
628 RangeGroupLayout->addWidget( myModeLbl, 0, 0, 1, 1 );
629 RangeGroupLayout->addWidget( myModeCombo, 0, 1, 1, 2);
630 RangeGroupLayout->addWidget( CBLog, 0, 3, 1, 1);
631 RangeGroupLayout->addWidget( myGaussMetricLabel, 1, 0, 1, 1);
632 RangeGroupLayout->addWidget( myGaussMetric, 1, 1, 1, 3);
633 RangeGroupLayout->addWidget( RBFrange, 2, 0, 1, 2);
634 RangeGroupLayout->addWidget( RBIrange, 2, 2, 1, 2);
635 RangeGroupLayout->addWidget( MinLabel, 3, 0 );
636 RangeGroupLayout->addWidget( MinEdit, 3, 1 );
637 RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
638 RangeGroupLayout->addWidget( MaxEdit, 3, 3 );
640 // Colors and Labels ========================================================
641 QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this);
642 aMainLayout->addWidget( ColLabGroup );
643 QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup );
644 ColLabGroupLayout->setAlignment( Qt::AlignTop );
645 //ColLabGroupLayout->setSpacing( 6 );
646 //ColLabGroupLayout->setMargin( 11 );
648 QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup);
649 ColorSpin = new SalomeApp_IntSpinBox( ColLabGroup );
650 ColorSpin->setAcceptNames( false );
651 ColorSpin->setMinimum( 2 );
652 ColorSpin->setMaximum( 256 );
653 ColorSpin->setSingleStep( 1 );
654 ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
655 //ColorSpin->setMinimumWidth( 70 );
656 ColorSpin->setValue( 64 );
658 QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup);
659 LabelSpin = new SalomeApp_IntSpinBox( ColLabGroup );
660 LabelSpin->setAcceptNames( false );
661 LabelSpin->setMinimum( 2 );
662 LabelSpin->setMaximum( 65 );
663 LabelSpin->setSingleStep( 1 );
665 LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
666 //LabelSpin->setMinimumWidth( 70 );
667 LabelSpin->setValue( 5 );
669 ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
670 ColLabGroupLayout->addWidget( ColorSpin, 0, 1);
671 ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
672 ColLabGroupLayout->addWidget( LabelSpin, 0, 3);
674 // Orientation ==========================================================
675 QButtonGroup* OrientGroup = new QButtonGroup ( this );
676 QGroupBox* OrientGB = new QGroupBox( tr("ORIENTATION_GRP"),this );
677 aMainLayout->addWidget( OrientGB );
678 QGridLayout* OrientGroupLayout = new QGridLayout( OrientGB );
679 OrientGroupLayout->setAlignment( Qt::AlignTop );
680 //OrientGroupLayout->setSpacing( 6 );
681 //OrientGroupLayout->setMargin( 11 );
683 RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGB);
684 RBvert->setChecked( true );
685 RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGB);
686 OrientGroup->addButton( RBvert );
687 OrientGroup->addButton( RBhori );
688 OrientGroupLayout->addWidget( RBvert, 0, 0 );
689 OrientGroupLayout->addWidget( RBhori, 0, 1 );
691 // Origin ===============================================================
692 QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this);
693 aMainLayout->addWidget( OriginGroup );
694 QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup );
695 OriginGroupLayout->setAlignment( Qt::AlignTop );
696 //OriginGroupLayout->setSpacing( 6 );
697 //OriginGroupLayout->setMargin( 11 );
699 QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup);
700 XSpin = new SalomeApp_DoubleSpinBox( OriginGroup );
701 VISU::initSpinBox( XSpin, 0.0, +1.0, .1, "parametric_precision" );
702 XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
703 //XSpin->setMinimumWidth( 70 );
704 XSpin->setValue( 0.01 );
706 QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup);
707 YSpin = new SalomeApp_DoubleSpinBox( OriginGroup );
708 VISU::initSpinBox( YSpin, 0.0, +1.0, .1, "parametric_precision" );
709 YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
710 //YSpin->setMinimumWidth( 70 );
711 YSpin->setValue( 0.1 );
713 OriginGroupLayout->addWidget( XLabel, 0, 0);
714 OriginGroupLayout->addWidget( XSpin, 0, 1);
715 OriginGroupLayout->addWidget( YLabel, 0, 2);
716 OriginGroupLayout->addWidget( YSpin, 0, 3);
718 // Dimensions =========================================================
719 QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this );
720 aMainLayout->addWidget( DimGroup );
721 QGridLayout* DimGroupLayout = new QGridLayout( DimGroup );
722 DimGroupLayout->setAlignment( Qt::AlignTop );
723 //DimGroupLayout->setSpacing( 6 );
724 //DimGroupLayout->setMargin( 11 );
726 QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup);
727 WidthSpin = new SalomeApp_DoubleSpinBox( DimGroup );
728 VISU::initSpinBox( WidthSpin, 0.0, +1.0, .1, "parametric_precision" );
729 WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
730 //WidthSpin->setMinimumWidth( 70 );
731 WidthSpin->setValue( 0.1 );
733 QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup);
734 HeightSpin = new SalomeApp_DoubleSpinBox( DimGroup );
735 VISU::initSpinBox( HeightSpin, 0.0, +1.0, .1, "parametric_precision" );
736 HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
737 //HeightSpin->setMinimumWidth( 70 );
738 HeightSpin->setValue( 0.8 );
740 DimGroupLayout->addWidget( WidthLabel, 0, 0);
741 DimGroupLayout->addWidget( WidthSpin, 0, 1);
742 DimGroupLayout->addWidget( HeightLabel, 0, 2);
743 DimGroupLayout->addWidget( HeightSpin, 0, 3);
745 // Save check box ===========================================================
746 QWidget* aSaveBox = new QWidget(this);
747 aMainLayout->addWidget( aSaveBox );
748 QHBoxLayout* aVBLay = new QHBoxLayout( aSaveBox );
749 aVBLay->addWidget( myTextBtn = new QPushButton("Text properties...", aSaveBox) );
750 aVBLay->addWidget( myBarBtn = new QPushButton("Bar properties...", aSaveBox) );
752 aMainLayout->addWidget( myTextDlg = new VisuGUI_TextPrefDlg(this) );
753 myTextDlg->setTitleVisible(!thePreview);
754 myBarDlg = new VisuGUI_BarPrefDlg(this);
756 QGroupBox* CheckGroup = new QGroupBox("", this );
757 aMainLayout->addWidget( CheckGroup );
758 //QHBoxLayout* CheckGroupLayout = new QHBoxLayout( CheckGroup );
759 QGridLayout* CheckGroupLayout = new QGridLayout( CheckGroup );
761 myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), CheckGroup);
762 myPreviewCheck->setChecked(false);
763 CheckGroupLayout->addWidget(myPreviewCheck, 0, 0);
765 myHideBar = new QCheckBox(tr("HIDE_SCALAR_BAR"), CheckGroup);
766 myHideBar->setChecked(false);
767 CheckGroupLayout->addWidget(myHideBar, 0, 1);
770 CBDistr = new QCheckBox (tr("SHOW_DISTRIBUTION"), CheckGroup);
771 CheckGroupLayout->addWidget(CBDistr, 1, 0);
774 CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), CheckGroup);
775 CheckGroupLayout->addWidget( CBSave, 1, 1 );
779 myPreviewCheck->hide();
783 if(RBvert->isChecked()) {
784 myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH);
786 myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH);
789 int lp = aResourceMgr->integerValue( "VISU", propertyName + "scalar_bar_label_precision", 3 );
790 myBarDlg->setLabelsPrecision( lp );
792 myBarDlg->setUnitsVisible(aResourceMgr->booleanValue("VISU", propertyName + "display_units", true));
794 // signals and slots connections ===========================================
795 connect( RBFrange, SIGNAL( toggled( bool ) ), this, SLOT( onFieldRange( bool ) ) );
796 connect( RBIrange, SIGNAL( toggled( bool ) ), this, SLOT( onImposedRange( bool ) ) );
798 connect( myModeCombo, SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( int ) ) );
799 connect( myGaussMetric, SIGNAL( activated( int ) ), this, SLOT( changeGaussMetric( int ) ) );
800 connect( OrientGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( changeDefaults( int ) ) );
801 connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
802 connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
803 connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
804 connect( myBarBtn, SIGNAL( clicked() ), this, SLOT( onBarPref() ) );
805 connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) );
807 connect( CBDistr, SIGNAL( toggled( bool ) ), this, SLOT( onShowDistribution( bool ) )); // RKV
809 connect( ColorSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
810 connect( LabelSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
811 connect( WidthSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
812 connect( HeightSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
813 connect( CBLog, SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() ));
814 connect( myBarDlg, SIGNAL( updatePreview() ), this, SLOT( updatePreview() ));
816 myIsStoreTextProp = false;
821 * Stores dialog values to resources
823 void VisuGUI_ScalarBarPane::storeToResources() {
824 int orient = (RBvert->isChecked())? 0 : 1;
825 float sbX1 = XSpin->value();
826 float sbY1 = YSpin->value();
827 float sbW = WidthSpin->value();
828 float sbH = HeightSpin->value();
829 int sbCol = ColorSpin->value();
830 int sbLab = LabelSpin->value();
832 if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
846 bool sbRange = RBIrange->isChecked();
847 float sbVmin = (float)(MinEdit->text().toDouble());
848 float sbVmax = (float)(MaxEdit->text().toDouble());
850 if(sbVmin > sbVmax) {
855 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
857 aResourceMgr->setValue("VISU", "scalar_bar_orientation", orient);
859 QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
861 aResourceMgr->setValue("VISU", propertyName + "x", sbX1);
862 aResourceMgr->setValue("VISU", propertyName + "y", sbY1);
863 aResourceMgr->setValue("VISU", propertyName + "width", sbW);
864 aResourceMgr->setValue("VISU", propertyName + "height", sbH);
866 aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol);
867 aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab);
871 aResourceMgr->setValue("VISU", "scalar_range_type", 1);
872 aResourceMgr->setValue("VISU", "scalar_range_min" ,sbVmin);
873 aResourceMgr->setValue("VISU", "scalar_range_max" ,sbVmax);
876 aResourceMgr->setValue("VISU", "scalar_range_type", 0);
878 aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic());
879 aResourceMgr->setValue("VISU", "scalar_bar_show_distribution", isShowDistribution()); // RKV
883 if (myIsStoreTextProp) {
885 QColor aTitleColor (255, 255, 255);
886 int aTitleFontFamily = VTK_ARIAL;
887 bool isTitleBold = false;
888 bool isTitleItalic = false;
889 bool isTitleShadow = false;
891 myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily,
892 isTitleBold, isTitleItalic, isTitleShadow);
896 aTitleFont.setBold(isTitleBold);
897 aTitleFont.setItalic(isTitleItalic);
898 aTitleFont.setOverline(isTitleShadow);
900 QString titleFontFamily;
901 switch (aTitleFontFamily) {
903 titleFontFamily = "Arial";
906 titleFontFamily = "Courier";
909 titleFontFamily = "Times";
912 aTitleFont.setFamily(titleFontFamily);
914 aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont);
916 aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor);
919 QColor aLabelColor (255, 255, 255);
920 int aLabelFontFamily = VTK_ARIAL;
921 bool isLabelBold = false;
922 bool isLabelItalic = false;
923 bool isLabelShadow = false;
925 myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
926 isLabelBold, isLabelItalic, isLabelShadow);
931 aLabelFont.setBold(isLabelBold);
932 aLabelFont.setItalic(isLabelItalic);
933 aLabelFont.setOverline(isLabelShadow);
935 QString labelFontFamily;
936 switch (aLabelFontFamily) {
938 labelFontFamily = "Arial";
941 labelFontFamily = "Courier";
944 labelFontFamily = "Times";
948 aLabelFont.setFamily(labelFontFamily);
950 aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont);
952 aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor);
956 //----------------------------------------------------------------------------
957 VisuGUI_ScalarBarPane::~VisuGUI_ScalarBarPane()
960 if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
961 aViewWindow->Repaint();
964 //----------------------------------------------------------------------------
966 * Initialise dialog box from presentation object
968 void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs)
970 myScalarMap = dynamic_cast<VISU::ScalarMap_i*>(thePrs);
975 switch(myScalarMap->GetScaling()){
976 case VISU::LOGARITHMIC :
977 setLogarithmic(true);
980 setLogarithmic(false);
983 // Update myModeCombo
984 const VISU::PField& aField = myScalarMap->GetScalarField();
985 const VISU::TNames& aCompNames = aField->myCompNames;
986 const VISU::TNames& aUnitNames = aField->myUnitNames;
987 int aNbComp = aField->myNbComp;
988 bool isScalarMode = (aNbComp > 1);
989 myModeCombo->clear();
990 myModeCombo->addItem("<Modulus>");
991 for(int i = 0; i < aNbComp; i++){
992 QString aComponent = QString(aCompNames[i].c_str()).simplified();
993 if(aComponent.isNull() || aComponent == "")
994 aComponent = "Component " + QString::number(i+1);
996 aComponent = "[" + QString::number(i+1) + "] " + aComponent;
998 QString anUnit = QString(aUnitNames[i].c_str()).simplified();
999 if(anUnit.isNull() || anUnit == "")
1002 aComponent = aComponent + ", " + anUnit;
1004 myModeCombo->addItem(aComponent);
1007 myModeCombo->setCurrentIndex(myScalarMap->GetScalarMode());
1009 myModeCombo->setCurrentIndex(1);
1011 myModeLbl->setEnabled(isScalarMode);
1012 myModeCombo->setEnabled(isScalarMode);
1014 // Gauss Metric option should be visible only if at least one
1015 // of mesh values on geometry is based on multiple gauss points
1016 bool isEnableGaussMetric = false;
1017 if( myIsDisplayGaussMetric ) {
1018 const VISU::TValField& aValField = aField->myValField;
1019 VISU::TValField::const_iterator anIter = aValField.find(myScalarMap->GetScalarTimeStampNumber());
1020 if ( anIter != aValField.end() ) {
1021 VISU::PValForTime aValForTime = anIter->second;
1022 if( aValForTime && aValForTime->GetMaxNbGauss() > 1 )
1023 isEnableGaussMetric = true;
1027 myGaussMetricLabel->setEnabled(isEnableGaussMetric);
1028 myGaussMetric->setEnabled(isEnableGaussMetric);
1029 if( isEnableGaussMetric )
1030 myGaussMetric->setCurrentIndex((int)myScalarMap->GetGaussMetric());
1032 setRange( myScalarMap->GetMin(), myScalarMap->GetMax(), myScalarMap->IsRangeFixed() );
1034 setScalarBarData( myScalarMap->GetNbColors(), myScalarMap->GetLabels() );
1035 setShowDistribution( myScalarMap->GetIsDistributionVisible() );
1038 CORBA::String_var aTitle = myScalarMap->GetTitle();
1039 myTextDlg->setTitleText(aTitle.in());
1040 myTitle = aTitle.in();
1042 setPosAndSize( myScalarMap->GetPosX(),
1043 myScalarMap->GetPosY(),
1044 myScalarMap->GetWidth(),
1045 myScalarMap->GetHeight(),
1046 myScalarMap->GetBarOrientation());
1048 if(RBvert->isChecked()) {
1049 myVerTS = myScalarMap->GetTitleSize();
1050 myVerLS = myScalarMap->GetLabelSize();
1051 myVerBW = myScalarMap->GetBarWidth();
1052 myVerBH = myScalarMap->GetBarHeight();
1053 myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1055 myHorTS = myScalarMap->GetTitleSize();
1056 myHorLS = myScalarMap->GetLabelSize();
1057 myHorBW = myScalarMap->GetBarWidth();
1058 myHorBH = myScalarMap->GetBarHeight();
1059 myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1062 myBarDlg->setLabelsPrecision( VISU::ToPrecision( myScalarMap->GetLabelsFormat() ) );
1063 myBarDlg->setUnitsVisible(myScalarMap->IsUnitsVisible());
1065 vtkFloatingPointType R, G, B;
1066 myScalarMap->GetTitleColor(R, G, B);
1068 QColor aTextColor = QColor((int)(R*255.), (int)(G*255.), (int)(B*255.));
1070 myTextDlg->myTitleFont->SetData(aTextColor,
1071 myScalarMap->GetTitFontType(),
1072 myScalarMap->IsBoldTitle(),
1073 myScalarMap->IsItalicTitle(),
1074 myScalarMap->IsShadowTitle());
1077 myScalarMap->GetLabelColor(R, G, B);
1079 QColor aLabelColor = QColor((int)(R*255.), (int)(G*255.), (int)(B*255.));
1081 myTextDlg->myLabelFont->SetData(aLabelColor,
1082 myScalarMap->GetLblFontType(),
1083 myScalarMap->IsBoldLabel(),
1084 myScalarMap->IsItalicLabel(),
1085 myScalarMap->IsShadowLabel());
1087 myHideBar->setChecked(!myScalarMap->IsBarVisible());
1090 if (myPreviewCheck->isChecked()) {
1098 //----------------------------------------------------------------------------
1099 /*! Slot update preview of scalar bar, if preview is checked
1101 void VisuGUI_ScalarBarPane::updatePreview()
1103 if (myPreviewCheck->isChecked()) {
1104 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
1112 //----------------------------------------------------------------------------
1113 /*! Creating preview scalar bar
1115 void VisuGUI_ScalarBarPane::createScalarBar()
1117 if (VISU::GetActiveViewWindow<SVTK_ViewWindow>() == NULL) return;
1118 if (myPreviewActor != 0) return;
1119 if (myScalarMap == NULL) return;
1121 if (!check()) return;
1122 myScalarMapPL = VISU_ScalarMapPL::New();
1123 if(myScalarMap->GetSpecificPL())
1124 myScalarMapPL->ShallowCopy(myScalarMap->GetSpecificPL(), true);
1126 if ( myBusy ) return;
1131 sbCol = getNbColors();
1132 sbLab = getNbLabels();
1133 if(sbCol < 2) sbCol=2;
1134 if(sbCol > 64) sbCol=64;
1135 if(sbLab < 2) sbLab=2;
1136 if(sbLab > 65) sbLab=65;
1137 myPreviewActor = VISU_ScalarMapAct::New();
1138 VISU_ScalarBarActor* aScalarBarActor = myPreviewActor->GetScalarBar();
1139 myPreviewActor->GetScalarBar()->VisibilityOn();
1140 myPreviewActor->PickableOff();
1141 //myPreviewActor->SetBarVisibility(!myHideBar->isChecked());
1143 myScalarMapPL->SetScalarMode(myModeCombo->currentIndex());
1145 myScalarMapPL->SetScaling(VISU::LOGARITHMIC);
1147 myScalarMapPL->SetScaling(VISU::LINEAR);
1149 if( myGaussMetric->isVisible() )
1150 myScalarMapPL->SetGaussMetric((VISU::TGaussMetric)myGaussMetric->currentIndex());
1152 if ( RBFrange->isChecked() ) {
1153 myScalarMapPL->SetSourceRange();
1155 vtkFloatingPointType aRange[2];
1156 aRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble();
1157 aRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble();
1158 myScalarMapPL->SetScalarRange( aRange );
1161 myScalarMapPL->SetNbColors(sbCol);
1162 myScalarMapPL->Update();
1164 aScalarBarActor->SetLookupTable(myScalarMapPL->GetBarTable());
1165 aScalarBarActor->SetDistribution( myScalarMapPL->GetDistribution() );
1166 aScalarBarActor->SetDistributionVisibility( isShowDistribution() );
1168 if (!myTextDlg->getTitleText().isEmpty()) {
1169 VISU::PValForTime aValForTime;
1170 const VISU::PField& aField = myScalarMap->GetScalarField();
1171 const VISU::TValField& aValField = aField->myValField;
1172 VISU::TValField::const_iterator anIter = aValField.find(myScalarMap->GetScalarTimeStampNumber());
1173 if (anIter != aValField.end())
1174 aValForTime = anIter->second;
1177 std::stringstream aStream;
1178 const VISU::TTime& aTime = aValForTime->myTime;
1179 aStream<< myTextDlg->getTitleText().toLatin1().data() <<" ";
1180 if(myBarDlg->isUnitsVisible())
1181 aStream<<VISU_Convertor::GenerateName(aTime)<<std::ends;
1184 aName.sprintf("%g", aTime.first);
1185 aStream << aName.toLatin1().data() << std::ends;
1187 std::string aScalarBarTitle = aStream.str();
1188 aScalarBarActor->SetTitle(aScalarBarTitle.c_str());
1190 aScalarBarActor->SetTitle(myTextDlg->getTitleText().toLatin1().data());
1194 aScalarBarActor->SetTitle(myTitle.c_str());
1195 aScalarBarActor->SetOrientation(getOrientation());
1196 aScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
1197 aScalarBarActor->GetPositionCoordinate()->SetValue(getX(),getY());
1198 aScalarBarActor->SetWidth(getWidth());
1199 aScalarBarActor->SetHeight(getHeight());
1200 aScalarBarActor->SetNumberOfLabels(sbLab);
1201 aScalarBarActor->SetMaximumNumberOfColors(sbCol);
1203 // title text property
1205 int aTitleFontFamily;
1209 myTextDlg->myTitleFont->GetData(aTitleColor,aTitleFontFamily,
1210 isTitleBold,isTitleItalic,isTitleShadow);
1211 vtkTextProperty* aTitleProp = aScalarBarActor->GetTitleTextProperty();
1212 aTitleProp->SetFontFamily(aTitleFontFamily);
1213 aTitleProp->SetColor(vtkFloatingPointType(aTitleColor.red())/255.,
1214 vtkFloatingPointType(aTitleColor.green())/255.,
1215 vtkFloatingPointType(aTitleColor.blue())/255.);
1216 (isTitleBold)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
1217 (isTitleItalic)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
1218 (isTitleShadow)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
1220 // label text property
1222 int aLabelFontFamily;
1226 myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
1227 isLabelBold, isLabelItalic, isLabelShadow);
1228 vtkTextProperty* aLabelProp = aScalarBarActor->GetLabelTextProperty();
1229 aLabelProp->SetFontFamily(aLabelFontFamily);
1230 aLabelProp->SetColor(vtkFloatingPointType(aLabelColor.red())/255.,
1231 vtkFloatingPointType(aLabelColor.green())/255.,
1232 vtkFloatingPointType(aLabelColor.blue())/255.);
1233 (isLabelBold)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
1234 (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
1235 (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
1237 int VerTS, VerLS, VerBW, VerBH;
1238 myBarDlg->getRatios(VerTS, VerLS, VerBW, VerBH);
1239 aScalarBarActor->SetRatios(VerTS, VerLS, VerBW, VerBH);
1241 std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() );
1242 aScalarBarActor->SetLabelFormat( f.c_str() );
1244 aScalarBarActor->Modified();
1246 VISU::GetActiveViewWindow<SVTK_ViewWindow>()->AddActor(myPreviewActor);
1252 //----------------------------------------------------------------------------
1253 /*! Deleting preview scalar bar
1255 void VisuGUI_ScalarBarPane::deleteScalarBar()
1257 if ( myBusy ) return;
1259 if (myPreviewActor == 0) return;
1260 vtkRenderer* aRend = myPreviewActor->GetRenderer();
1261 vtkRenderWindow* aWnd = aRend->GetRenderWindow();
1263 myPreviewActor->RemoveFromRender(aRend);
1264 myPreviewActor->GetScalarBar()->VisibilityOff();
1265 myPreviewActor->Delete();
1269 myScalarMapPL->Delete();
1275 //----------------------------------------------------------------------------
1277 * Store values to presentation object
1279 int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) {
1283 myScalarMap->SetScalarMode(myModeCombo->currentIndex());
1284 if( myGaussMetric->isVisible() )
1285 myScalarMap->SetGaussMetric((VISU::GaussMetric)myGaussMetric->currentIndex());
1286 myScalarMap->SetPosition(XSpin->value(), YSpin->value());
1287 myScalarMap->SetSize(WidthSpin->value(), HeightSpin->value());
1288 if(RBvert->isChecked()) {
1289 myScalarMap->SetRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1291 myScalarMap->SetRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1294 std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() );
1295 myScalarMap->SetLabelsFormat( f.c_str() );
1296 myScalarMap->SetUnitsVisible(myBarDlg->isUnitsVisible());
1298 myScalarMap->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3dBase::VERTICAL : VISU::ColoredPrs3dBase::HORIZONTAL);
1300 myScalarMap->SetScaling(VISU::LOGARITHMIC);
1302 myScalarMap->SetScaling(VISU::LINEAR);
1304 if ( RBFrange->isChecked() ) {
1305 myScalarMap->SetSourceRange();
1307 myScalarMap->SetRange( MinEdit->text().toDouble(), MaxEdit->text().toDouble() );
1309 myScalarMap->SetNbColors(ColorSpin->value());
1310 myScalarMap->SetLabels(LabelSpin->value());
1311 myScalarMap->SetIsDistributionVisible(isShowDistribution()); // RKV
1313 myScalarMap->SetBarVisible(!myHideBar->isChecked());
1315 if (isToSave()) storeToResources();
1317 if (myIsStoreTextProp) {
1319 myScalarMap->SetTitle(myTextDlg->getTitleText().toLatin1().data());
1321 QColor aTitColor (255, 255, 255);
1322 int aTitleFontFamily = VTK_ARIAL;
1323 bool isTitleBold = false;
1324 bool isTitleItalic = false;
1325 bool isTitleShadow = false;
1327 myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
1328 isTitleBold, isTitleItalic, isTitleShadow);
1330 myScalarMap->SetBoldTitle(isTitleBold);
1331 myScalarMap->SetItalicTitle(isTitleItalic);
1332 myScalarMap->SetShadowTitle(isTitleShadow);
1333 myScalarMap->SetTitFontType(aTitleFontFamily);
1334 myScalarMap->SetTitleColor(aTitColor.red()/255.,
1335 aTitColor.green()/255.,
1336 aTitColor.blue()/255.);
1339 QColor aLblColor (255, 255, 255);
1340 int aLabelFontFamily = VTK_ARIAL;
1341 bool isLabelBold = false;
1342 bool isLabelItalic = false;
1343 bool isLabelShadow = false;
1345 myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
1346 isLabelBold, isLabelItalic, isLabelShadow);
1348 myScalarMap->SetBoldLabel(isLabelBold);
1349 myScalarMap->SetItalicLabel(isLabelItalic);
1350 myScalarMap->SetShadowLabel(isLabelShadow);
1351 myScalarMap->SetLblFontType(aLabelFontFamily);
1352 myScalarMap->SetLabelColor(aLblColor.red()/255.,
1353 aLblColor.green()/255.,
1354 aLblColor.blue()/255.);
1355 myIsStoreTextProp = false;
1362 //----------------------------------------------------------------------------
1364 Called when orientation is changed
1366 void VisuGUI_ScalarBarPane::changeDefaults( int )
1368 if ( RBvert->isChecked() ) {
1369 XSpin->setValue( myVerX );
1370 YSpin->setValue( myVerY );
1371 WidthSpin->setValue( myVerW );
1372 HeightSpin->setValue( myVerH );
1375 XSpin->setValue( myHorX );
1376 YSpin->setValue( myHorY );
1377 WidthSpin->setValue( myHorW );
1378 HeightSpin->setValue( myHorH );
1384 //----------------------------------------------------------------------------
1386 Called when Range mode is changed
1388 void VisuGUI_ScalarBarPane::onFieldRange( bool isOn )
1391 myScalarMap->SetSourceRange();
1392 MinEdit->setEnabled( false );
1393 MaxEdit->setEnabled( false );
1394 changeScalarMode(myModeCombo->currentIndex());
1398 void VisuGUI_ScalarBarPane::onImposedRange( bool isOn )
1401 myScalarMap->SetRange( myScalarMap->GetSourceMin(), myScalarMap->GetSourceMax() );
1402 MinEdit->setEnabled( true );
1403 MaxEdit->setEnabled( true );
1404 changeScalarMode(myModeCombo->currentIndex());
1408 void VisuGUI_ScalarBarPane::onShowDistribution( bool isOn )
1410 myScalarMap->SetIsDistributionVisible(isOn);
1414 void VisuGUI_ScalarBarPane::changeRange( int )
1416 if ( RBFrange->isChecked() ) {
1417 myScalarMap->SetSourceRange();
1418 MinEdit->setEnabled( false );
1419 MaxEdit->setEnabled( false );
1421 myScalarMap->SetRange( myScalarMap->GetSourceMin(), myScalarMap->GetSourceMax() );
1422 MinEdit->setEnabled( true );
1423 MaxEdit->setEnabled( true );
1426 changeScalarMode(myModeCombo->currentIndex());
1430 //----------------------------------------------------------------------------
1432 Called when X,Y position is changed
1434 void VisuGUI_ScalarBarPane::XYChanged( double )
1436 SalomeApp_DoubleSpinBox* snd = (SalomeApp_DoubleSpinBox*)sender();
1437 if ( snd == XSpin ) {
1438 WidthSpin->setMaximum( 1.0 - XSpin->value() );
1440 if ( snd == YSpin ) {
1441 HeightSpin->setMaximum( 1.0 - YSpin->value() );
1447 //----------------------------------------------------------------------------
1449 Called when scalar mode is changed
1451 void VisuGUI_ScalarBarPane::changeScalarMode( int theMode )
1453 myScalarMap->SetScalarMode(theMode);
1455 if ( RBFrange->isChecked() ) {
1456 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1457 int aPrecision = qAbs( aResourceMgr->integerValue("VISU", "visual_data_precision", 0) );
1459 MinEdit->setText(QString::number(myScalarMap->GetSourceMin(), 'g', aPrecision));
1460 MaxEdit->setText(QString::number(myScalarMap->GetSourceMax(), 'g', aPrecision));
1467 //----------------------------------------------------------------------------
1469 Called when scalar mode is changed
1471 void VisuGUI_ScalarBarPane::changeGaussMetric( int theGaussMetric )
1473 myScalarMap->SetGaussMetric((VISU::GaussMetric)theGaussMetric);
1475 if ( RBFrange->isChecked() ) {
1476 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1477 int aPrecision = qAbs( aResourceMgr->integerValue("VISU", "visual_data_precision", 0) );
1479 MinEdit->setText(QString::number(myScalarMap->GetSourceMin(), 'g', aPrecision));
1480 MaxEdit->setText(QString::number(myScalarMap->GetSourceMax(), 'g', aPrecision));
1487 //----------------------------------------------------------------------------
1489 Sets default values and range mode
1491 void VisuGUI_ScalarBarPane::setRange( double imin, double imax, bool sbRange )
1493 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1494 int aPrecision = qAbs( aResourceMgr->integerValue("VISU", "visual_data_precision", 0) );
1496 MinEdit->setText(QString::number(imin, 'g', aPrecision+1)); // VSR +1 is for 'g' format
1497 MaxEdit->setText(QString::number(imax, 'g', aPrecision+1)); // VSR +1 is for 'g' format
1500 RBIrange->setChecked( true );
1502 RBFrange->setChecked( true );
1504 changeRange( sbRange );
1508 //----------------------------------------------------------------------------
1510 Sets and gets parameters
1512 bool VisuGUI_ScalarBarPane::isIRange() {
1513 return RBIrange->isChecked();
1517 //----------------------------------------------------------------------------
1518 double VisuGUI_ScalarBarPane::getMin() {
1519 return MinEdit->text().toDouble();
1523 //----------------------------------------------------------------------------
1524 double VisuGUI_ScalarBarPane::getMax() {
1525 return MaxEdit->text().toDouble();
1529 //----------------------------------------------------------------------------
1530 double VisuGUI_ScalarBarPane::getX() {
1531 return XSpin->value();
1535 //----------------------------------------------------------------------------
1536 double VisuGUI_ScalarBarPane::getY() {
1537 return YSpin->value();
1541 //----------------------------------------------------------------------------
1542 double VisuGUI_ScalarBarPane::getWidth() {
1543 return WidthSpin->value();
1547 //----------------------------------------------------------------------------
1548 double VisuGUI_ScalarBarPane::getHeight() {
1549 return HeightSpin->value();
1553 //----------------------------------------------------------------------------
1554 int VisuGUI_ScalarBarPane::getNbColors() {
1555 return ColorSpin->value();
1559 //----------------------------------------------------------------------------
1560 int VisuGUI_ScalarBarPane::getNbLabels() {
1561 return LabelSpin->value();
1565 //----------------------------------------------------------------------------
1566 bool VisuGUI_ScalarBarPane::isLogarithmic() {
1567 return CBLog->isChecked();
1571 //----------------------------------------------------------------------------
1572 void VisuGUI_ScalarBarPane::setLogarithmic( bool on ) {
1573 CBLog->setChecked( on );
1576 //----------------------------------------------------------------------------
1577 bool VisuGUI_ScalarBarPane::isShowDistribution() {
1578 return CBDistr->isChecked();
1582 //----------------------------------------------------------------------------
1583 void VisuGUI_ScalarBarPane::setShowDistribution( bool on ) {
1584 CBDistr->setChecked( on );
1588 //----------------------------------------------------------------------------
1589 bool VisuGUI_ScalarBarPane::isToSave() {
1590 return CBSave ? CBSave->isChecked() : false;
1593 //----------------------------------------------------------------------------
1595 Sets size and position
1597 void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
1604 RBvert->setChecked( true );
1611 RBhori->setChecked( true );
1613 changeDefaults( 0 );
1617 //----------------------------------------------------------------------------
1619 Sets colors and labels number
1621 void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
1623 ColorSpin->setValue( colors );
1624 LabelSpin->setValue( labels );
1628 //----------------------------------------------------------------------------
1632 int VisuGUI_ScalarBarPane::getOrientation()
1634 if (RBvert->isChecked() )
1641 //----------------------------------------------------------------------------
1643 Called when <OK> button is clicked, validates data and closes dialog
1645 bool VisuGUI_ScalarBarPane::check()
1647 double minVal = MinEdit->text().toDouble();
1648 double maxVal = MaxEdit->text().toDouble();
1649 if ( RBIrange->isChecked() ) {
1650 if (minVal >= maxVal) {
1651 SUIT_MessageBox::warning( this,tr("WRN_VISU"),
1652 tr("MSG_MINMAX_VALUES"),
1658 // check if logarithmic mode is on and check imposed range to not contain negative values
1659 if ( CBLog->isChecked() ) {
1660 if ( minVal <= 0.0 || maxVal <= 0.0 ) {
1661 if ( RBIrange->isChecked() ) {
1662 SUIT_MessageBox::warning( this,
1664 tr("WRN_LOGARITHMIC_RANGE"),
1667 if ( minVal == 0 || maxVal == 0 )
1668 SUIT_MessageBox::warning( this,
1670 tr("WRN_LOGARITHMIC_RANGE"),
1673 SUIT_MessageBox::warning( this,
1675 tr("WRN_LOGARITHMIC_FIELD_RANGE"),
1677 RBIrange->setChecked(true);
1687 //----------------------------------------------------------------------------
1688 void VisuGUI_ScalarBarPane::onTextPref()
1690 myTextDlg->storeBeginValues();
1691 myIsStoreTextProp = myTextDlg->exec() || myIsStoreTextProp;
1696 //----------------------------------------------------------------------------
1697 void VisuGUI_ScalarBarPane::onBarPref()
1699 if(RBvert->isChecked())
1700 myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1702 myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1703 myBarDlg->setOrientation( getOrientation() );
1704 if(myBarDlg->exec()) {
1705 if(RBvert->isChecked())
1706 myBarDlg->getRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1708 myBarDlg->getRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1714 //----------------------------------------------------------------------------
1715 void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview)
1717 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
1727 VisuGUI_Prs3dDlg::VisuGUI_Prs3dDlg( SalomeApp_Module* theModule )
1728 : QDialog( VISU::GetDesktop( theModule ), Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
1732 //----------------------------------------------------------------------------
1734 Called when <Help> button is clicked, shows the corresponding help page in defined browser
1736 void VisuGUI_Prs3dDlg::onHelp()
1738 QString aHelpFileName = GetContextHelpFilePath();
1739 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1741 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
1742 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
1745 SUIT_MessageBox::warning( this, tr( "WRN_WARNING" ),
1746 tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1747 arg( app->resourceMgr()->stringValue( "ExternalBrowser",
1749 arg( aHelpFileName ) );
1754 //----------------------------------------------------------------------------
1755 void VisuGUI_Prs3dDlg::keyPressEvent( QKeyEvent* e )
1757 QDialog::keyPressEvent( e );
1758 if ( e->isAccepted() )
1761 if ( e->key() == Qt::Key_F1 ) {
1767 //----------------------------------------------------------------------------
1768 VisuGUI_ScalarBarBaseDlg::VisuGUI_ScalarBarBaseDlg( SalomeApp_Module* theModule, bool theIsDisplayGaussMetric, bool thePreview ) :
1769 VisuGUI_Prs3dDlg( theModule )
1771 myScalarPane = new VisuGUI_ScalarBarPane(this, theIsDisplayGaussMetric, thePreview);
1772 myScalarPane->layout()->setMargin( 5 );
1776 VisuGUI_ScalarBarBaseDlg::~VisuGUI_ScalarBarBaseDlg()
1781 //----------------------------------------------------------------------------
1782 void VisuGUI_ScalarBarBaseDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
1785 myScalarPane->initFromPrsObject( thePrs );
1789 //----------------------------------------------------------------------------
1791 Called when <OK> button is clicked, validates data and closes dialog
1793 void VisuGUI_ScalarBarBaseDlg::accept()
1795 if (GetScalarPane()->check())
1796 VisuGUI_Prs3dDlg::accept();
1800 //----------------------------------------------------------------------------
1802 Called when <Cancel> button is clicked, remove preview and closes dialog
1804 void VisuGUI_ScalarBarBaseDlg::reject()
1806 VisuGUI_Prs3dDlg::reject();
1809 //----------------------------------------------------------------------------
1810 VisuGUI_ScalarBarPane* VisuGUI_ScalarBarBaseDlg::GetScalarPane()
1812 return myScalarPane;
1816 //----------------------------------------------------------------------------