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 // VISU VISUGUI : GUI of VISU component
23 // File : VisuGUI_Prs3dDlg.cxx
24 // Author : Laurent CORNABE & Hubert ROLLAND
27 #include "VisuGUI_Prs3dDlg.h"
30 #include "VisuGUI_Tools.h"
31 #include "VisuGUI_ViewTools.h"
32 #include "VisuGUI_InputPane.h"
34 #include "SVTK_ViewWindow.h"
35 #include "SVTK_FontWidget.h"
37 #include "VISUConfig.hh"
38 #include "VISU_Convertor.hxx"
39 #include "VISU_MeshValue.hxx"
40 #include "VISU_Structures_impl.hxx"
41 #include "VISU_ScalarMapPL.hxx"
42 #include "VISU_ScalarBarActor.hxx"
43 #include "VISU_ScalarMapAct.h"
44 #include "VISU_ScalarMap_i.hh"
45 #include "VISU_Result_i.hh"
46 #include "VISU_Prs3dUtils.hh"
48 #include "LightApp_Application.h"
50 #include "SUIT_Session.h"
51 #include "SUIT_MessageBox.h"
52 #include "SUIT_ResourceMgr.h"
53 #include "SUIT_Desktop.h"
57 #include <QRadioButton>
58 #include <QButtonGroup>
61 #include <QPushButton>
63 #include <QToolButton>
66 #include <QColorDialog>
69 #include <QGridLayout>
71 #include "QtxDoubleSpinBox.h"
73 #include <vtkTextProperty.h>
79 //-----------------------------------------------------------------------
80 // Text Preferences Dialog
81 //-----------------------------------------------------------------------
85 VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent)
86 : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
89 setWindowTitle(tr("TIT_TEXT_PREF"));
90 setSizeGripEnabled(TRUE);
92 QVBoxLayout* aMainLay = new QVBoxLayout(this);
93 aMainLay->setSpacing(6);
94 aMainLay->setMargin(11);
97 QGroupBox* aTitleGrp = new QGroupBox ( tr("LBL_TITLE"), this);
98 QVBoxLayout* aVBLay = new QVBoxLayout( aTitleGrp );
101 myTitleEdt = new QLineEdit (aTitleGrp);
102 aVBLay->addWidget( myTitleEdt);
105 QWidget* aHBox = new QWidget (aTitleGrp);
106 aVBLay->addWidget( aHBox );
108 QHBoxLayout* aHBLay = new QHBoxLayout( aHBox );
109 aHBLay->setSpacing(5);
111 myTitleFont = new SVTK_FontWidget (aHBox);
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 aHBLay->addWidget( myLabelFont );
130 aMainLay->addWidget(aLabelsGrp);
132 // Common buttons ===========================================================
133 QGroupBox* GroupButtons = new QGroupBox( this );
134 //GroupButtons->setColumnLayout(0, Qt::Vertical );
135 //GroupButtons->layout()->setSpacing( 0 );
136 //GroupButtons->layout()->setMargin( 0 );
137 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons );
138 GroupButtonsLayout->setAlignment( Qt::AlignTop );
139 GroupButtonsLayout->setSpacing( 6 );
140 GroupButtonsLayout->setMargin( 11 );
142 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons );
143 buttonOk->setAutoDefault( TRUE );
144 buttonOk->setDefault( TRUE );
145 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
146 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
148 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons );
149 buttonCancel->setAutoDefault( TRUE );
150 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
152 QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons );
153 buttonHelp->setAutoDefault( TRUE );
154 GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
156 aMainLay->addWidget( GroupButtons );
158 connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
159 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
160 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp()));
164 //----------------------------------------------------------------------------
165 QString VisuGUI_TextPrefDlg::getTitleText()
167 return myTitleEdt->text();
171 //----------------------------------------------------------------------------
172 void VisuGUI_TextPrefDlg::setTitleText( const QString& theText )
174 myTitleEdt->setText(theText);
178 //----------------------------------------------------------------------------
179 void VisuGUI_TextPrefDlg::setTitleVisible(bool isVisible)
188 //----------------------------------------------------------------------------
189 void VisuGUI_TextPrefDlg::onHelp()
191 QString aHelpFileName = "scalar_map_page.html";
192 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
194 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
195 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
198 SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
199 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
200 arg(app->resourceMgr()->stringValue("ExternalBrowser",
201 "application")).arg(aHelpFileName),
202 QObject::tr("BUT_OK"));
207 //----------------------------------------------------------------------------
208 void VisuGUI_TextPrefDlg::storeBeginValues()
210 myTitle = myTitleEdt->text();
211 myTitleFont->GetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
212 myLabelFont->GetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
216 //----------------------------------------------------------------------------
218 Called when <Cancel> button is clicked, restore begin values
220 void VisuGUI_TextPrefDlg::reject()
222 myTitleEdt->setText(myTitle);
223 myTitleFont->SetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
224 myLabelFont->SetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
230 //----------------------------------------------------------------------------
232 Called when <Ok> button is clicked, store begin values
234 void VisuGUI_TextPrefDlg::accept()
242 //----------------------------------------------------------------------------
244 Provides help on F1 button click
246 void VisuGUI_TextPrefDlg::keyPressEvent( QKeyEvent* e )
248 QDialog::keyPressEvent( e );
249 if ( e->isAccepted() )
252 if ( e->key() == Qt::Key_F1 )
259 //-----------------------------------------------------------------------
260 // Scalar Bar Preferences Dialog
261 //-----------------------------------------------------------------------
265 VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent )
270 setWindowTitle( tr( "TIT_BAR_PREF" ) );
271 setSizeGripEnabled( true );
273 QString propertyName = QString( "scalar_bar_vertical_" );
275 myTitleSize = myLabelSize = myBarWidth = myBarHeight = 0;
279 QVBoxLayout* aMainLay = new QVBoxLayout( this );
280 aMainLay->setSpacing( 5 );
281 aMainLay->setMargin( 5 );
285 QGroupBox* aDimGrp = new QGroupBox( this );
286 QGridLayout* aDimGrpLay = new QGridLayout( aDimGrp );
287 aDimGrpLay->setSpacing( 5 );
288 aDimGrpLay->setMargin( 5 );
290 myTitleSizeSpin = new QSpinBox( aDimGrp );
291 myTitleSizeSpin->setRange( 0, 100 );
292 myTitleSizeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
293 myTitleSizeSpin->setMinimumWidth( 70 );
294 myTitleSizeSpin->setValue( 0 );
295 myTitleSizeSpin->setSpecialValueText( tr( "AUTO" ) );
296 QLabel* aTitleSizeLbl = new QLabel( tr( "LBL_TITLE_W" ), aDimGrp );
298 myLabelSizeSpin = new QSpinBox( aDimGrp );
299 myLabelSizeSpin->setRange( 0, 100 );
300 myLabelSizeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
301 myLabelSizeSpin->setMinimumWidth( 70 );
302 myLabelSizeSpin->setValue( 0 );
303 myLabelSizeSpin->setSpecialValueText( tr( "AUTO" ) );
304 QLabel* aLabelSizeLbl = new QLabel( tr( "LBL_LABEL_W" ), aDimGrp );
306 myBarWidthSpin = new QSpinBox( aDimGrp );
307 myBarWidthSpin->setRange( 0, 100 );
308 myBarWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
309 myBarWidthSpin->setMinimumWidth( 70 );
310 myBarWidthSpin->setValue( 0 );
311 myBarWidthSpin->setSpecialValueText( tr( "AUTO" ) );
312 QLabel* aBarWidthLbl = new QLabel( tr( "LBL_BAR_W" ), aDimGrp );
314 myBarHeightSpin = new QSpinBox( aDimGrp );
315 myBarHeightSpin->setRange( 0, 100 );
316 myBarHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
317 myBarHeightSpin->setMinimumWidth( 70 );
318 myBarHeightSpin->setValue( 0 );
319 myBarHeightSpin->setSpecialValueText( tr( "AUTO" ) );
320 QLabel* aBarHeightLbl = new QLabel( tr( "LBL_BAR_H" ), aDimGrp );
324 QLabel* aPrecLbl = new QLabel( tr( "PRECISION" ), aDimGrp );
325 myPrecisionSpin = new QSpinBox( aDimGrp );
326 myPrecisionSpin->setRange( 1, 100 );
328 myUnitsChk = new QCheckBox( tr( "LBL_SHOW_UNITS" ), aDimGrp );
332 aDimGrpLay->addWidget( aTitleSizeLbl, 0, 0 );
333 aDimGrpLay->addWidget( myTitleSizeSpin, 0, 1 );
334 aDimGrpLay->addWidget( aLabelSizeLbl, 0, 2 );
335 aDimGrpLay->addWidget( myLabelSizeSpin, 0, 3 );
336 aDimGrpLay->addWidget( aBarWidthLbl, 1, 0 );
337 aDimGrpLay->addWidget( myBarWidthSpin, 1, 1 );
338 aDimGrpLay->addWidget( aBarHeightLbl, 1, 2 );
339 aDimGrpLay->addWidget( myBarHeightSpin, 1, 3 );
340 aDimGrpLay->addWidget( aPrecLbl, 2, 0 );
341 aDimGrpLay->addWidget( myPrecisionSpin, 2, 1 );
342 aDimGrpLay->addWidget( myUnitsChk, 2, 2, 1, 2 );
344 aMainLay->addWidget( aDimGrp );
346 // Common buttons ===========================================================
348 QGroupBox* GroupButtons = new QGroupBox( this );
349 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
350 GroupButtonsLayout->setAlignment( Qt::AlignTop );
351 GroupButtonsLayout->setSpacing( 6 );
352 GroupButtonsLayout->setMargin( 11 );
354 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons );
355 buttonOk->setAutoDefault( true );
356 buttonOk->setDefault( true );
358 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons );
359 buttonCancel->setAutoDefault( true );
361 QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons );
362 buttonHelp->setAutoDefault( true );
364 GroupButtonsLayout->addWidget( buttonOk );
365 GroupButtonsLayout->addSpacing( 5 );
366 GroupButtonsLayout->addStretch();
367 GroupButtonsLayout->addWidget( buttonCancel );
368 GroupButtonsLayout->addWidget( buttonHelp );
370 aMainLay->addWidget( GroupButtons );
372 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
373 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
374 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
375 connect( myTitleSizeSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
376 connect( myLabelSizeSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
377 connect( myBarWidthSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
378 connect( myBarHeightSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
379 connect( myUnitsChk, SIGNAL( toggled( bool ) ), this, SIGNAL( updatePreview() ) );
380 connect( myPrecisionSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
384 //----------------------------------------------------------------------------
385 void VisuGUI_BarPrefDlg::setRatios( int titleRatioSize, int labelRatioWidth,
386 int barRatioWidth, int barRatioHeight )
388 myTitleSizeSpin->setValue( myTitleSize = titleRatioSize );
389 myLabelSizeSpin->setValue( myLabelSize = labelRatioWidth );
390 myBarWidthSpin->setValue( myBarWidth = barRatioWidth );
391 myBarHeightSpin->setValue( myBarHeight = barRatioHeight );
395 //----------------------------------------------------------------------------
396 void VisuGUI_BarPrefDlg::getRatios( int& titleRatioSize, int& labelRatioWidth,
397 int& barRatioWidth, int& barRatioHeight )
399 titleRatioSize = myTitleSizeSpin->value();
400 labelRatioWidth = myLabelSizeSpin->value();
401 barRatioWidth = myBarWidthSpin->value();
402 barRatioHeight = myBarHeightSpin->value();
406 //----------------------------------------------------------------------------
407 void VisuGUI_BarPrefDlg::setLabelsPrecision( const int p )
409 myPrecisionSpin->setValue( p );
412 //----------------------------------------------------------------------------
413 int VisuGUI_BarPrefDlg::getLabelsPrecision() const
415 return myPrecisionSpin->value();
418 //----------------------------------------------------------------------------
419 void VisuGUI_BarPrefDlg::setOrientation( const int ori )
424 //----------------------------------------------------------------------------
426 int VisuGUI_BarPrefDlg::getOrientation() const
428 return myOrientation;
431 //----------------------------------------------------------------------------
432 void VisuGUI_BarPrefDlg::onHelp()
434 QString aHelpFileName = "scalar_map_page.html";
435 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
437 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
438 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
441 SUIT_MessageBox::warning( this, tr( "WRN_WARNING" ),
442 tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
443 arg( app->resourceMgr()->stringValue( "ExternalBrowser",
445 arg( aHelpFileName ) );
450 //----------------------------------------------------------------------------
451 void VisuGUI_BarPrefDlg::setUnitsVisible(bool isVisible)
453 myUnitsChk->setChecked( myUnits = isVisible );
457 //----------------------------------------------------------------------------
458 bool VisuGUI_BarPrefDlg::isUnitsVisible()
460 return myUnitsChk->isChecked();
464 //----------------------------------------------------------------------------
466 Called when <Cancel> button is clicked, restore begin values
468 void VisuGUI_BarPrefDlg::reject()
470 myTitleSizeSpin->setValue( myTitleSize );
471 myLabelSizeSpin->setValue( myLabelSize );
472 myBarWidthSpin->setValue( myBarWidth );
473 myBarHeightSpin->setValue( myBarHeight );
474 myUnitsChk->setChecked( myUnits );
475 myPrecisionSpin->setValue( myPrecision );
480 //----------------------------------------------------------------------------
482 Called when <Ok> button is clicked, store begin values
484 void VisuGUI_BarPrefDlg::accept()
487 int aBWH = myOrientation == 1 ? myBarWidthSpin->value() : myBarHeightSpin->value();
488 if( ( myLabelSizeSpin->value()+ aBWH ) > 100 )
490 SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE" ) );
494 if ( myTitleSizeSpin->value() > 100 )
496 SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE_TLT" ) );
500 myTitleSize = myTitleSizeSpin->value();
501 myLabelSize = myLabelSizeSpin->value();
502 myBarWidth = myBarWidthSpin->value();
503 myBarHeight = myBarHeightSpin->value();
504 myUnits = myUnitsChk->isChecked();
505 myPrecision = myPrecisionSpin->value();
510 //----------------------------------------------------------------------------
512 Provides help on F1 button click
514 void VisuGUI_BarPrefDlg::keyPressEvent( QKeyEvent* e )
516 QDialog::keyPressEvent( e );
517 if ( e->isAccepted() )
520 if ( e->key() == Qt::Key_F1 ) {
527 //-----------------------------------------------------------------------
529 //-----------------------------------------------------------------------
534 VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool theIsDisplayGaussMetric, bool thePreview )
539 myIsDisplayGaussMetric( theIsDisplayGaussMetric )
541 QVBoxLayout* aMainLayout = new QVBoxLayout( this );
542 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
543 QString propertyName;
544 propertyName = QString("scalar_bar_vertical_");
545 myVerX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
546 myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
547 myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
548 myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
549 myVerTS = aResourceMgr->integerValue("VISU", propertyName + "title_size", 0);
550 myVerLS = aResourceMgr->integerValue("VISU", propertyName + "label_size", 0);
551 myVerBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0);
552 myVerBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0);
554 propertyName = QString("scalar_bar_horizontal_");
555 myHorX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
556 myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
557 myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
558 myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
559 myHorTS = aResourceMgr->integerValue("VISU", propertyName + "title_size", 0);
560 myHorLS = aResourceMgr->integerValue("VISU", propertyName + "label_size", 0);
561 myHorBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0);
562 myHorBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0);
564 //aMainLayout->setSpacing(6);
566 // Range ============================================================
567 RangeGroup = new QButtonGroup ( this );
568 QGroupBox* aGB = new QGroupBox( tr("SCALAR_RANGE_GRP"),this );
569 aMainLayout->addWidget( aGB );
570 QGridLayout* RangeGroupLayout = new QGridLayout( aGB );
571 RangeGroupLayout->setAlignment( Qt::AlignTop );
572 //RangeGroupLayout->setSpacing( 6 );
573 //RangeGroupLayout->setMargin( 11 );
575 myModeLbl = new QLabel("Scalar Mode", aGB);
577 myModeCombo = new QComboBox(aGB);
579 CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), aGB);
580 CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
582 myGaussMetricLabel = new QLabel( tr("VISU_GAUSS_METRIC"), aGB );
583 myGaussMetric = new QComboBox( aGB );
584 myGaussMetric->addItem( tr("VISU_GAUSS_METRIC_AVERAGE") );
585 myGaussMetric->addItem( tr("VISU_GAUSS_METRIC_MINIMUM") );
586 myGaussMetric->addItem( tr("VISU_GAUSS_METRIC_MAXIMUM") );
587 myGaussMetric->setToolTip( tr("VISU_GAUSS_METRIC_TOOLTIP") );
589 if( !myIsDisplayGaussMetric ) {
590 myGaussMetricLabel->hide();
591 myGaussMetric->hide();
594 RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), aGB);
595 RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), aGB);
596 RangeGroup->addButton( RBFrange, 0 );
597 RangeGroup->addButton( RBIrange, 1 );
598 RBFrange->setChecked( true );
600 int aPrecision = aResourceMgr->integerValue( "VISU", "floating_point_precision", 0 );
601 QDoubleValidator* dv = new QDoubleValidator(this);
602 dv->setDecimals(aPrecision);
604 MinEdit = new QLineEdit( aGB );
605 MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
606 //MinEdit->setMinimumWidth( 70 );
607 MinEdit->setValidator( dv );
608 MinEdit->setText( "0.0" );
609 QLabel* MinLabel = new QLabel (tr("LBL_MIN"), aGB);
610 MinLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
611 MinLabel->setBuddy(MinEdit);
613 MaxEdit = new QLineEdit( aGB );
614 MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
615 //MaxEdit->setMinimumWidth( 70 );
616 MaxEdit->setValidator( dv );
617 MaxEdit->setText( "0.0" );
618 QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), aGB);
619 MaxLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
620 MaxLabel->setBuddy(MaxEdit);
622 RangeGroupLayout->addWidget( myModeLbl, 0, 0, 1, 1 );
623 RangeGroupLayout->addWidget( myModeCombo, 0, 1, 1, 2);
624 RangeGroupLayout->addWidget( CBLog, 0, 3, 1, 1);
625 RangeGroupLayout->addWidget( myGaussMetricLabel, 1, 0, 1, 1);
626 RangeGroupLayout->addWidget( myGaussMetric, 1, 1, 1, 3);
627 RangeGroupLayout->addWidget( RBFrange, 2, 0, 1, 2);
628 RangeGroupLayout->addWidget( RBIrange, 2, 2, 1, 2);
629 RangeGroupLayout->addWidget( MinLabel, 3, 0 );
630 RangeGroupLayout->addWidget( MinEdit, 3, 1 );
631 RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
632 RangeGroupLayout->addWidget( MaxEdit, 3, 3 );
634 // Colors and Labels ========================================================
635 QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this);
636 aMainLayout->addWidget( ColLabGroup );
637 QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup );
638 ColLabGroupLayout->setAlignment( Qt::AlignTop );
639 //ColLabGroupLayout->setSpacing( 6 );
640 //ColLabGroupLayout->setMargin( 11 );
642 QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup);
643 ColorSpin = new QSpinBox( ColLabGroup );
644 ColorSpin->setMinimum( 2 );
645 ColorSpin->setMaximum( 256 );
646 ColorSpin->setSingleStep( 1 );
647 ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
648 //ColorSpin->setMinimumWidth( 70 );
649 ColorSpin->setValue( 64 );
651 QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup);
652 LabelSpin = new QSpinBox( ColLabGroup );
653 LabelSpin->setMinimum( 2 );
654 LabelSpin->setMaximum( 65 );
655 LabelSpin->setSingleStep( 1 );
657 LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
658 //LabelSpin->setMinimumWidth( 70 );
659 LabelSpin->setValue( 5 );
661 ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
662 ColLabGroupLayout->addWidget( ColorSpin, 0, 1);
663 ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
664 ColLabGroupLayout->addWidget( LabelSpin, 0, 3);
666 // Orientation ==========================================================
667 QButtonGroup* OrientGroup = new QButtonGroup ( this );
668 QGroupBox* OrientGB = new QGroupBox( tr("ORIENTATION_GRP"),this );
669 aMainLayout->addWidget( OrientGB );
670 QGridLayout* OrientGroupLayout = new QGridLayout( OrientGB );
671 OrientGroupLayout->setAlignment( Qt::AlignTop );
672 //OrientGroupLayout->setSpacing( 6 );
673 //OrientGroupLayout->setMargin( 11 );
675 RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGB);
676 RBvert->setChecked( true );
677 RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGB);
678 OrientGroup->addButton( RBvert );
679 OrientGroup->addButton( RBhori );
680 OrientGroupLayout->addWidget( RBvert, 0, 0 );
681 OrientGroupLayout->addWidget( RBhori, 0, 1 );
683 // Origin ===============================================================
684 QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this);
685 aMainLayout->addWidget( OriginGroup );
686 QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup );
687 OriginGroupLayout->setAlignment( Qt::AlignTop );
688 //OriginGroupLayout->setSpacing( 6 );
689 //OriginGroupLayout->setMargin( 11 );
691 QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup);
692 XSpin = new QtxDoubleSpinBox( OriginGroup );
693 VISU::initSpinBox(XSpin, 0.0, +1.0);
694 XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
695 //XSpin->setMinimumWidth( 70 );
696 XSpin->setValue( 0.01 );
698 QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup);
699 YSpin = new QtxDoubleSpinBox( OriginGroup );
700 VISU::initSpinBox(YSpin, 0.0, +1.0);
701 YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
702 //YSpin->setMinimumWidth( 70 );
703 YSpin->setValue( 0.1 );
705 OriginGroupLayout->addWidget( XLabel, 0, 0);
706 OriginGroupLayout->addWidget( XSpin, 0, 1);
707 OriginGroupLayout->addWidget( YLabel, 0, 2);
708 OriginGroupLayout->addWidget( YSpin, 0, 3);
710 // Dimensions =========================================================
711 QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this );
712 aMainLayout->addWidget( DimGroup );
713 QGridLayout* DimGroupLayout = new QGridLayout( DimGroup );
714 DimGroupLayout->setAlignment( Qt::AlignTop );
715 //DimGroupLayout->setSpacing( 6 );
716 //DimGroupLayout->setMargin( 11 );
718 QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup);
719 WidthSpin = new QtxDoubleSpinBox( DimGroup );
720 VISU::initSpinBox(WidthSpin, 0.0, +1.0);
721 WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
722 //WidthSpin->setMinimumWidth( 70 );
723 WidthSpin->setValue( 0.1 );
725 QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup);
726 HeightSpin = new QtxDoubleSpinBox( DimGroup );
727 VISU::initSpinBox(HeightSpin, 0.0, +1.0);
728 HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
729 //HeightSpin->setMinimumWidth( 70 );
730 HeightSpin->setValue( 0.8 );
732 DimGroupLayout->addWidget( WidthLabel, 0, 0);
733 DimGroupLayout->addWidget( WidthSpin, 0, 1);
734 DimGroupLayout->addWidget( HeightLabel, 0, 2);
735 DimGroupLayout->addWidget( HeightSpin, 0, 3);
737 // Save check box ===========================================================
738 QWidget* aSaveBox = new QWidget(this);
739 aMainLayout->addWidget( aSaveBox );
740 QHBoxLayout* aVBLay = new QHBoxLayout( aSaveBox );
741 aVBLay->addWidget( myTextBtn = new QPushButton("Text properties...", aSaveBox) );
742 aVBLay->addWidget( myBarBtn = new QPushButton("Bar properties...", aSaveBox) );
744 aMainLayout->addWidget( myTextDlg = new VisuGUI_TextPrefDlg(this) );
745 myTextDlg->setTitleVisible(!thePreview);
746 myBarDlg = new VisuGUI_BarPrefDlg(this);
748 QGroupBox* CheckGroup = new QGroupBox("", this );
749 aMainLayout->addWidget( CheckGroup );
750 //QHBoxLayout* CheckGroupLayout = new QHBoxLayout( CheckGroup );
751 QGridLayout* CheckGroupLayout = new QGridLayout( CheckGroup );
753 myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), CheckGroup);
754 myPreviewCheck->setChecked(false);
755 CheckGroupLayout->addWidget(myPreviewCheck, 0, 0);
757 myHideBar = new QCheckBox(tr("HIDE_SCALAR_BAR"), CheckGroup);
758 myHideBar->setChecked(false);
759 CheckGroupLayout->addWidget(myHideBar, 0, 1);
762 CBDistr = new QCheckBox (tr("SHOW_DISTRIBUTION"), CheckGroup);
763 CheckGroupLayout->addWidget(CBDistr, 1, 0);
766 CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), CheckGroup);
767 CheckGroupLayout->addWidget( CBSave, 1, 1 );
771 myPreviewCheck->hide();
775 if(RBvert->isChecked()) {
776 myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH);
778 myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH);
781 int lp = aResourceMgr->integerValue( "VISU", propertyName + "scalar_bar_label_precision", 3 );
782 myBarDlg->setLabelsPrecision( lp );
784 myBarDlg->setUnitsVisible(aResourceMgr->booleanValue("VISU", propertyName + "display_units", true));
786 // signals and slots connections ===========================================
787 connect( RBFrange, SIGNAL( toggled( bool ) ), this, SLOT( onFieldRange( bool ) ) );
788 connect( RBIrange, SIGNAL( toggled( bool ) ), this, SLOT( onImposedRange( bool ) ) );
790 connect( myModeCombo, SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( int ) ) );
791 connect( myGaussMetric, SIGNAL( activated( int ) ), this, SLOT( changeGaussMetric( int ) ) );
792 connect( OrientGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( changeDefaults( int ) ) );
793 connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
794 connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
795 connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
796 connect( myBarBtn, SIGNAL( clicked() ), this, SLOT( onBarPref() ) );
797 connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) );
799 connect( CBDistr, SIGNAL( toggled( bool ) ), this, SLOT( onShowDistribution( bool ) )); // RKV
801 connect( ColorSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
802 connect( LabelSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
803 connect( WidthSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
804 connect( HeightSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
805 connect( CBLog, SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() ));
806 connect( myBarDlg, SIGNAL( updatePreview() ), this, SLOT( updatePreview() ));
808 myIsStoreTextProp = false;
813 * Stores dialog values to resources
815 void VisuGUI_ScalarBarPane::storeToResources() {
816 int orient = (RBvert->isChecked())? 0 : 1;
817 float sbX1 = XSpin->value();
818 float sbY1 = YSpin->value();
819 float sbW = WidthSpin->value();
820 float sbH = HeightSpin->value();
821 int sbCol = ColorSpin->value();
822 int sbLab = LabelSpin->value();
824 if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
838 bool sbRange = RBIrange->isChecked();
839 float sbVmin = (float)(MinEdit->text().toDouble());
840 float sbVmax = (float)(MaxEdit->text().toDouble());
842 if(sbVmin > sbVmax) {
847 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
849 aResourceMgr->setValue("VISU", "scalar_bar_orientation", orient);
851 QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
853 aResourceMgr->setValue("VISU", propertyName + "x", sbX1);
854 aResourceMgr->setValue("VISU", propertyName + "y", sbY1);
855 aResourceMgr->setValue("VISU", propertyName + "width", sbW);
856 aResourceMgr->setValue("VISU", propertyName + "height", sbH);
858 aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol);
859 aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab);
863 aResourceMgr->setValue("VISU", "scalar_range_type", 1);
864 aResourceMgr->setValue("VISU", "scalar_range_min" ,sbVmin);
865 aResourceMgr->setValue("VISU", "scalar_range_max" ,sbVmax);
868 aResourceMgr->setValue("VISU", "scalar_range_type", 0);
870 aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic());
871 aResourceMgr->setValue("VISU", "scalar_bar_show_distribution", isShowDistribution()); // RKV
875 if (myIsStoreTextProp) {
877 QColor aTitleColor (255, 255, 255);
878 int aTitleFontFamily = VTK_ARIAL;
879 bool isTitleBold = false;
880 bool isTitleItalic = false;
881 bool isTitleShadow = false;
883 myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily,
884 isTitleBold, isTitleItalic, isTitleShadow);
888 aTitleFont.setBold(isTitleBold);
889 aTitleFont.setItalic(isTitleItalic);
890 aTitleFont.setOverline(isTitleShadow);
892 QString titleFontFamily;
893 switch (aTitleFontFamily) {
895 titleFontFamily = "Arial";
898 titleFontFamily = "Courier";
901 titleFontFamily = "Times";
904 aTitleFont.setFamily(titleFontFamily);
906 aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont);
908 aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor);
911 QColor aLabelColor (255, 255, 255);
912 int aLabelFontFamily = VTK_ARIAL;
913 bool isLabelBold = false;
914 bool isLabelItalic = false;
915 bool isLabelShadow = false;
917 myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
918 isLabelBold, isLabelItalic, isLabelShadow);
923 aLabelFont.setBold(isLabelBold);
924 aLabelFont.setItalic(isLabelItalic);
925 aLabelFont.setOverline(isLabelShadow);
927 QString labelFontFamily;
928 switch (aLabelFontFamily) {
930 labelFontFamily = "Arial";
933 labelFontFamily = "Courier";
936 labelFontFamily = "Times";
940 aLabelFont.setFamily(labelFontFamily);
942 aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont);
944 aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor);
948 //----------------------------------------------------------------------------
949 VisuGUI_ScalarBarPane::~VisuGUI_ScalarBarPane()
952 if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
953 aViewWindow->Repaint();
956 //----------------------------------------------------------------------------
958 * Initialise dialog box from presentation object
960 void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs)
962 myScalarMap = dynamic_cast<VISU::ScalarMap_i*>(thePrs);
967 switch(myScalarMap->GetScaling()){
968 case VISU::LOGARITHMIC :
969 setLogarithmic(true);
972 setLogarithmic(false);
975 // Update myModeCombo
976 const VISU::PField& aField = myScalarMap->GetScalarField();
977 const VISU::TNames& aCompNames = aField->myCompNames;
978 const VISU::TNames& aUnitNames = aField->myUnitNames;
979 int aNbComp = aField->myNbComp;
980 bool isScalarMode = (aNbComp > 1);
981 myModeCombo->clear();
982 myModeCombo->addItem("<Modulus>");
983 for(int i = 0; i < aNbComp; i++){
984 QString aComponent = QString(aCompNames[i].c_str()).simplified();
985 if(aComponent.isNull() || aComponent == "")
986 aComponent = "Component " + QString::number(i+1);
988 aComponent = "[" + QString::number(i+1) + "] " + aComponent;
990 QString anUnit = QString(aUnitNames[i].c_str()).simplified();
991 if(anUnit.isNull() || anUnit == "")
994 aComponent = aComponent + ", " + anUnit;
996 myModeCombo->addItem(aComponent);
999 myModeCombo->setCurrentIndex(myScalarMap->GetScalarMode());
1001 myModeCombo->setCurrentIndex(1);
1003 myModeLbl->setEnabled(isScalarMode);
1004 myModeCombo->setEnabled(isScalarMode);
1006 // Gauss Metric option should be visible only if at least one
1007 // of mesh values on geometry is based on multiple gauss points
1008 bool isEnableGaussMetric = false;
1009 if( myIsDisplayGaussMetric ) {
1010 const VISU::TValField& aValField = aField->myValField;
1011 VISU::TValField::const_iterator anIter = aValField.find(myScalarMap->GetScalarTimeStampNumber());
1012 if ( anIter != aValField.end() ) {
1013 VISU::PValForTime aValForTime = anIter->second;
1014 if( aValForTime && aValForTime->GetMaxNbGauss() > 1 )
1015 isEnableGaussMetric = true;
1019 myGaussMetricLabel->setEnabled(isEnableGaussMetric);
1020 myGaussMetric->setEnabled(isEnableGaussMetric);
1021 if( isEnableGaussMetric )
1022 myGaussMetric->setCurrentIndex((int)myScalarMap->GetGaussMetric());
1024 setRange( myScalarMap->GetMin(), myScalarMap->GetMax(), myScalarMap->IsRangeFixed() );
1026 setScalarBarData( myScalarMap->GetNbColors(), myScalarMap->GetLabels() );
1027 setShowDistribution( myScalarMap->GetIsDistributionVisible() );
1030 CORBA::String_var aTitle = myScalarMap->GetTitle();
1031 myTextDlg->setTitleText(aTitle.in());
1032 myTitle = aTitle.in();
1034 setPosAndSize( myScalarMap->GetPosX(),
1035 myScalarMap->GetPosY(),
1036 myScalarMap->GetWidth(),
1037 myScalarMap->GetHeight(),
1038 myScalarMap->GetBarOrientation());
1040 if(RBvert->isChecked()) {
1041 myVerTS = myScalarMap->GetTitleSize();
1042 myVerLS = myScalarMap->GetLabelSize();
1043 myVerBW = myScalarMap->GetBarWidth();
1044 myVerBH = myScalarMap->GetBarHeight();
1045 myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1047 myHorTS = myScalarMap->GetTitleSize();
1048 myHorLS = myScalarMap->GetLabelSize();
1049 myHorBW = myScalarMap->GetBarWidth();
1050 myHorBH = myScalarMap->GetBarHeight();
1051 myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1054 myBarDlg->setLabelsPrecision( VISU::ToPrecision( myScalarMap->GetLabelsFormat() ) );
1055 myBarDlg->setUnitsVisible(myScalarMap->IsUnitsVisible());
1057 vtkFloatingPointType R, G, B;
1058 myScalarMap->GetTitleColor(R, G, B);
1060 QColor aTextColor = QColor((int)(R*255.), (int)(G*255.), (int)(B*255.));
1062 myTextDlg->myTitleFont->SetData(aTextColor,
1063 myScalarMap->GetTitFontType(),
1064 myScalarMap->IsBoldTitle(),
1065 myScalarMap->IsItalicTitle(),
1066 myScalarMap->IsShadowTitle());
1069 myScalarMap->GetLabelColor(R, G, B);
1071 QColor aLabelColor = QColor((int)(R*255.), (int)(G*255.), (int)(B*255.));
1073 myTextDlg->myLabelFont->SetData(aLabelColor,
1074 myScalarMap->GetLblFontType(),
1075 myScalarMap->IsBoldLabel(),
1076 myScalarMap->IsItalicLabel(),
1077 myScalarMap->IsShadowLabel());
1079 myHideBar->setChecked(!myScalarMap->IsBarVisible());
1082 if (myPreviewCheck->isChecked()) {
1090 //----------------------------------------------------------------------------
1091 /*! Slot update preview of scalar bar, if preview is checked
1093 void VisuGUI_ScalarBarPane::updatePreview()
1095 if (myPreviewCheck->isChecked()) {
1096 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
1104 //----------------------------------------------------------------------------
1105 /*! Creating preview scalar bar
1107 void VisuGUI_ScalarBarPane::createScalarBar()
1109 if (VISU::GetActiveViewWindow<SVTK_ViewWindow>() == NULL) return;
1110 if (myPreviewActor != 0) return;
1111 if (myScalarMap == NULL) return;
1113 if (!check()) return;
1114 myScalarMapPL = VISU_ScalarMapPL::New();
1115 if(myScalarMap->GetSpecificPL())
1116 myScalarMapPL->ShallowCopy(myScalarMap->GetSpecificPL(), true);
1118 if ( myBusy ) return;
1123 sbCol = getNbColors();
1124 sbLab = getNbLabels();
1125 if(sbCol < 2) sbCol=2;
1126 if(sbCol > 64) sbCol=64;
1127 if(sbLab < 2) sbLab=2;
1128 if(sbLab > 65) sbLab=65;
1129 myPreviewActor = VISU_ScalarMapAct::New();
1130 VISU_ScalarBarActor* aScalarBarActor = myPreviewActor->GetScalarBar();
1131 myPreviewActor->GetScalarBar()->VisibilityOn();
1132 myPreviewActor->PickableOff();
1133 //myPreviewActor->SetBarVisibility(!myHideBar->isChecked());
1135 myScalarMapPL->SetScalarMode(myModeCombo->currentIndex());
1137 myScalarMapPL->SetScaling(VISU::LOGARITHMIC);
1139 myScalarMapPL->SetScaling(VISU::LINEAR);
1141 if( myGaussMetric->isVisible() )
1142 myScalarMapPL->SetGaussMetric((VISU::TGaussMetric)myGaussMetric->currentIndex());
1144 if ( RBFrange->isChecked() ) {
1145 myScalarMapPL->SetSourceRange();
1147 vtkFloatingPointType aRange[2];
1148 aRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble();
1149 aRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble();
1150 myScalarMapPL->SetScalarRange( aRange );
1153 myScalarMapPL->SetNbColors(sbCol);
1154 myScalarMapPL->Update();
1156 aScalarBarActor->SetLookupTable(myScalarMapPL->GetBarTable());
1157 aScalarBarActor->SetDistribution( myScalarMapPL->GetDistribution() );
1158 aScalarBarActor->SetDistributionVisibility( isShowDistribution() );
1160 if (!myTextDlg->getTitleText().isEmpty()) {
1161 VISU::PValForTime aValForTime;
1162 const VISU::PField& aField = myScalarMap->GetScalarField();
1163 const VISU::TValField& aValField = aField->myValField;
1164 VISU::TValField::const_iterator anIter = aValField.find(myScalarMap->GetScalarTimeStampNumber());
1165 if (anIter != aValField.end())
1166 aValForTime = anIter->second;
1169 std::strstream aStream;
1170 const VISU::TTime& aTime = aValForTime->myTime;
1171 aStream<< myTextDlg->getTitleText().toLatin1().data() <<" ";
1172 if(myBarDlg->isUnitsVisible())
1173 aStream<<VISU_Convertor::GenerateName(aTime)<<std::ends;
1176 aName.sprintf("%g", aTime.first);
1177 aStream << aName.toLatin1().data() << std::ends;
1179 std::string aScalarBarTitle = aStream.str();
1180 aScalarBarActor->SetTitle(aScalarBarTitle.c_str());
1182 aScalarBarActor->SetTitle(myTextDlg->getTitleText().toLatin1().data());
1186 aScalarBarActor->SetTitle(myTitle.c_str());
1187 aScalarBarActor->SetOrientation(getOrientation());
1188 aScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
1189 aScalarBarActor->GetPositionCoordinate()->SetValue(getX(),getY());
1190 aScalarBarActor->SetWidth(getWidth());
1191 aScalarBarActor->SetHeight(getHeight());
1192 aScalarBarActor->SetNumberOfLabels(sbLab);
1193 aScalarBarActor->SetMaximumNumberOfColors(sbCol);
1195 // title text property
1197 int aTitleFontFamily;
1201 myTextDlg->myTitleFont->GetData(aTitleColor,aTitleFontFamily,
1202 isTitleBold,isTitleItalic,isTitleShadow);
1203 vtkTextProperty* aTitleProp = aScalarBarActor->GetTitleTextProperty();
1204 aTitleProp->SetFontFamily(aTitleFontFamily);
1205 aTitleProp->SetColor(vtkFloatingPointType(aTitleColor.red())/255.,
1206 vtkFloatingPointType(aTitleColor.green())/255.,
1207 vtkFloatingPointType(aTitleColor.blue())/255.);
1208 (isTitleBold)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
1209 (isTitleItalic)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
1210 (isTitleShadow)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
1212 // label text property
1214 int aLabelFontFamily;
1218 myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
1219 isLabelBold, isLabelItalic, isLabelShadow);
1220 vtkTextProperty* aLabelProp = aScalarBarActor->GetLabelTextProperty();
1221 aLabelProp->SetFontFamily(aLabelFontFamily);
1222 aLabelProp->SetColor(vtkFloatingPointType(aLabelColor.red())/255.,
1223 vtkFloatingPointType(aLabelColor.green())/255.,
1224 vtkFloatingPointType(aLabelColor.blue())/255.);
1225 (isLabelBold)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
1226 (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
1227 (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
1229 int VerTS, VerLS, VerBW, VerBH;
1230 myBarDlg->getRatios(VerTS, VerLS, VerBW, VerBH);
1231 aScalarBarActor->SetRatios(VerTS, VerLS, VerBW, VerBH);
1233 std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() );
1234 aScalarBarActor->SetLabelFormat( f.c_str() );
1236 aScalarBarActor->Modified();
1238 VISU::GetActiveViewWindow<SVTK_ViewWindow>()->AddActor(myPreviewActor);
1244 //----------------------------------------------------------------------------
1245 /*! Deleting preview scalar bar
1247 void VisuGUI_ScalarBarPane::deleteScalarBar()
1249 if ( myBusy ) return;
1251 if (myPreviewActor == 0) return;
1252 vtkRenderer* aRend = myPreviewActor->GetRenderer();
1253 vtkRenderWindow* aWnd = aRend->GetRenderWindow();
1255 myPreviewActor->RemoveFromRender(aRend);
1256 myPreviewActor->GetScalarBar()->VisibilityOff();
1257 myPreviewActor->Delete();
1261 myScalarMapPL->Delete();
1267 //----------------------------------------------------------------------------
1269 * Store values to presentation object
1271 int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) {
1275 myScalarMap->SetScalarMode(myModeCombo->currentIndex());
1276 if( myGaussMetric->isVisible() )
1277 myScalarMap->SetGaussMetric((VISU::GaussMetric)myGaussMetric->currentIndex());
1278 myScalarMap->SetPosition(XSpin->value(), YSpin->value());
1279 myScalarMap->SetSize(WidthSpin->value(), HeightSpin->value());
1280 if(RBvert->isChecked()) {
1281 myScalarMap->SetRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1283 myScalarMap->SetRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1286 std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() );
1287 myScalarMap->SetLabelsFormat( f.c_str() );
1288 myScalarMap->SetUnitsVisible(myBarDlg->isUnitsVisible());
1290 myScalarMap->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3dBase::VERTICAL : VISU::ColoredPrs3dBase::HORIZONTAL);
1292 myScalarMap->SetScaling(VISU::LOGARITHMIC);
1294 myScalarMap->SetScaling(VISU::LINEAR);
1296 if ( RBFrange->isChecked() ) {
1297 myScalarMap->SetSourceRange();
1299 myScalarMap->SetRange( MinEdit->text().toDouble(), MaxEdit->text().toDouble() );
1301 myScalarMap->SetNbColors(ColorSpin->value());
1302 myScalarMap->SetLabels(LabelSpin->value());
1303 myScalarMap->SetIsDistributionVisible(isShowDistribution()); // RKV
1305 myScalarMap->SetBarVisible(!myHideBar->isChecked());
1307 if (isToSave()) storeToResources();
1309 if (myIsStoreTextProp) {
1311 myScalarMap->SetTitle(myTextDlg->getTitleText().toLatin1().data());
1313 QColor aTitColor (255, 255, 255);
1314 int aTitleFontFamily = VTK_ARIAL;
1315 bool isTitleBold = false;
1316 bool isTitleItalic = false;
1317 bool isTitleShadow = false;
1319 myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
1320 isTitleBold, isTitleItalic, isTitleShadow);
1322 myScalarMap->SetBoldTitle(isTitleBold);
1323 myScalarMap->SetItalicTitle(isTitleItalic);
1324 myScalarMap->SetShadowTitle(isTitleShadow);
1325 myScalarMap->SetTitFontType(aTitleFontFamily);
1326 myScalarMap->SetTitleColor(aTitColor.red()/255.,
1327 aTitColor.green()/255.,
1328 aTitColor.blue()/255.);
1331 QColor aLblColor (255, 255, 255);
1332 int aLabelFontFamily = VTK_ARIAL;
1333 bool isLabelBold = false;
1334 bool isLabelItalic = false;
1335 bool isLabelShadow = false;
1337 myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
1338 isLabelBold, isLabelItalic, isLabelShadow);
1340 myScalarMap->SetBoldLabel(isLabelBold);
1341 myScalarMap->SetItalicLabel(isLabelItalic);
1342 myScalarMap->SetShadowLabel(isLabelShadow);
1343 myScalarMap->SetLblFontType(aLabelFontFamily);
1344 myScalarMap->SetLabelColor(aLblColor.red()/255.,
1345 aLblColor.green()/255.,
1346 aLblColor.blue()/255.);
1347 myIsStoreTextProp = false;
1354 //----------------------------------------------------------------------------
1356 Called when orientation is changed
1358 void VisuGUI_ScalarBarPane::changeDefaults( int )
1360 if ( RBvert->isChecked() ) {
1361 XSpin->setValue( myVerX );
1362 YSpin->setValue( myVerY );
1363 WidthSpin->setValue( myVerW );
1364 HeightSpin->setValue( myVerH );
1367 XSpin->setValue( myHorX );
1368 YSpin->setValue( myHorY );
1369 WidthSpin->setValue( myHorW );
1370 HeightSpin->setValue( myHorH );
1376 //----------------------------------------------------------------------------
1378 Called when Range mode is changed
1380 void VisuGUI_ScalarBarPane::onFieldRange( bool isOn )
1383 myScalarMap->SetSourceRange();
1384 MinEdit->setEnabled( false );
1385 MaxEdit->setEnabled( false );
1386 changeScalarMode(myModeCombo->currentIndex());
1390 void VisuGUI_ScalarBarPane::onImposedRange( bool isOn )
1393 myScalarMap->SetRange( myScalarMap->GetSourceMin(), myScalarMap->GetSourceMax() );
1394 MinEdit->setEnabled( true );
1395 MaxEdit->setEnabled( true );
1396 changeScalarMode(myModeCombo->currentIndex());
1400 void VisuGUI_ScalarBarPane::onShowDistribution( bool isOn )
1402 myScalarMap->SetIsDistributionVisible(isOn);
1406 void VisuGUI_ScalarBarPane::changeRange( int )
1408 if ( RBFrange->isChecked() ) {
1409 myScalarMap->SetSourceRange();
1410 MinEdit->setEnabled( false );
1411 MaxEdit->setEnabled( false );
1413 myScalarMap->SetRange( myScalarMap->GetSourceMin(), myScalarMap->GetSourceMax() );
1414 MinEdit->setEnabled( true );
1415 MaxEdit->setEnabled( true );
1418 changeScalarMode(myModeCombo->currentIndex());
1422 //----------------------------------------------------------------------------
1424 Called when X,Y position is changed
1426 void VisuGUI_ScalarBarPane::XYChanged( double )
1428 QtxDoubleSpinBox* snd = (QtxDoubleSpinBox*)sender();
1429 if ( snd == XSpin ) {
1430 WidthSpin->setMaximum( 1.0 - XSpin->value() );
1432 if ( snd == YSpin ) {
1433 HeightSpin->setMaximum( 1.0 - YSpin->value() );
1439 //----------------------------------------------------------------------------
1441 Called when scalar mode is changed
1443 void VisuGUI_ScalarBarPane::changeScalarMode( int theMode )
1445 myScalarMap->SetScalarMode(theMode);
1447 if ( RBFrange->isChecked() ) {
1448 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1449 int aPrecision = aResourceMgr->integerValue("VISU", "floating_point_precision", 0);
1451 MinEdit->setText(QString::number(myScalarMap->GetSourceMin(), 'g', aPrecision));
1452 MaxEdit->setText(QString::number(myScalarMap->GetSourceMax(), 'g', aPrecision));
1459 //----------------------------------------------------------------------------
1461 Called when scalar mode is changed
1463 void VisuGUI_ScalarBarPane::changeGaussMetric( int theGaussMetric )
1465 myScalarMap->SetGaussMetric((VISU::GaussMetric)theGaussMetric);
1467 if ( RBFrange->isChecked() ) {
1468 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1469 int aPrecision = aResourceMgr->integerValue("VISU", "floating_point_precision", 0);
1471 MinEdit->setText(QString::number(myScalarMap->GetSourceMin(), 'g', aPrecision));
1472 MaxEdit->setText(QString::number(myScalarMap->GetSourceMax(), 'g', aPrecision));
1479 //----------------------------------------------------------------------------
1481 Sets default values and range mode
1483 void VisuGUI_ScalarBarPane::setRange( double imin, double imax, bool sbRange )
1485 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1486 int aPrecision = aResourceMgr->integerValue("VISU", "floating_point_precision", 0);
1488 MinEdit->setText(QString::number(imin, 'g', aPrecision));
1489 MaxEdit->setText(QString::number(imax, 'g', aPrecision));
1492 RBIrange->setChecked( true );
1494 RBFrange->setChecked( true );
1496 changeRange( sbRange );
1500 //----------------------------------------------------------------------------
1502 Sets and gets parameters
1504 bool VisuGUI_ScalarBarPane::isIRange() {
1505 return RBIrange->isChecked();
1509 //----------------------------------------------------------------------------
1510 double VisuGUI_ScalarBarPane::getMin() {
1511 return MinEdit->text().toDouble();
1515 //----------------------------------------------------------------------------
1516 double VisuGUI_ScalarBarPane::getMax() {
1517 return MaxEdit->text().toDouble();
1521 //----------------------------------------------------------------------------
1522 double VisuGUI_ScalarBarPane::getX() {
1523 return XSpin->value();
1527 //----------------------------------------------------------------------------
1528 double VisuGUI_ScalarBarPane::getY() {
1529 return YSpin->value();
1533 //----------------------------------------------------------------------------
1534 double VisuGUI_ScalarBarPane::getWidth() {
1535 return WidthSpin->value();
1539 //----------------------------------------------------------------------------
1540 double VisuGUI_ScalarBarPane::getHeight() {
1541 return HeightSpin->value();
1545 //----------------------------------------------------------------------------
1546 int VisuGUI_ScalarBarPane::getNbColors() {
1547 return ColorSpin->value();
1551 //----------------------------------------------------------------------------
1552 int VisuGUI_ScalarBarPane::getNbLabels() {
1553 return LabelSpin->value();
1557 //----------------------------------------------------------------------------
1558 bool VisuGUI_ScalarBarPane::isLogarithmic() {
1559 return CBLog->isChecked();
1563 //----------------------------------------------------------------------------
1564 void VisuGUI_ScalarBarPane::setLogarithmic( bool on ) {
1565 CBLog->setChecked( on );
1568 //----------------------------------------------------------------------------
1569 bool VisuGUI_ScalarBarPane::isShowDistribution() {
1570 return CBDistr->isChecked();
1574 //----------------------------------------------------------------------------
1575 void VisuGUI_ScalarBarPane::setShowDistribution( bool on ) {
1576 CBDistr->setChecked( on );
1580 //----------------------------------------------------------------------------
1581 bool VisuGUI_ScalarBarPane::isToSave() {
1582 return CBSave ? CBSave->isChecked() : false;
1585 //----------------------------------------------------------------------------
1587 Sets size and position
1589 void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
1596 RBvert->setChecked( true );
1603 RBhori->setChecked( true );
1605 changeDefaults( 0 );
1609 //----------------------------------------------------------------------------
1611 Sets colors and labels number
1613 void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
1615 ColorSpin->setValue( colors );
1616 LabelSpin->setValue( labels );
1620 //----------------------------------------------------------------------------
1624 int VisuGUI_ScalarBarPane::getOrientation()
1626 if (RBvert->isChecked() )
1633 //----------------------------------------------------------------------------
1635 Called when <OK> button is clicked, validates data and closes dialog
1637 bool VisuGUI_ScalarBarPane::check()
1639 double minVal = MinEdit->text().toDouble();
1640 double maxVal = MaxEdit->text().toDouble();
1641 if ( RBIrange->isChecked() ) {
1642 if (minVal >= maxVal) {
1643 SUIT_MessageBox::warning( this,tr("WRN_VISU"),
1644 tr("MSG_MINMAX_VALUES"),
1650 // check if logarithmic mode is on and check imposed range to not contain negative values
1651 if ( CBLog->isChecked() ) {
1652 if ( minVal <= 0.0 || maxVal <= 0.0 ) {
1653 if ( RBIrange->isChecked() ) {
1654 SUIT_MessageBox::warning( this,
1656 tr("WRN_LOGARITHMIC_RANGE"),
1659 if ( minVal == 0 || maxVal == 0 )
1660 SUIT_MessageBox::warning( this,
1662 tr("WRN_LOGARITHMIC_RANGE"),
1665 SUIT_MessageBox::warning( this,
1667 tr("WRN_LOGARITHMIC_FIELD_RANGE"),
1669 RBIrange->setChecked(true);
1679 //----------------------------------------------------------------------------
1680 void VisuGUI_ScalarBarPane::onTextPref()
1682 myTextDlg->storeBeginValues();
1683 myIsStoreTextProp = myTextDlg->exec() || myIsStoreTextProp;
1688 //----------------------------------------------------------------------------
1689 void VisuGUI_ScalarBarPane::onBarPref()
1691 if(RBvert->isChecked())
1692 myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1694 myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1695 myBarDlg->setOrientation( getOrientation() );
1696 if(myBarDlg->exec()) {
1697 if(RBvert->isChecked())
1698 myBarDlg->getRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1700 myBarDlg->getRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1706 //----------------------------------------------------------------------------
1707 void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview)
1709 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
1719 VisuGUI_Prs3dDlg::VisuGUI_Prs3dDlg( SalomeApp_Module* theModule )
1720 : QDialog( VISU::GetDesktop( theModule ), Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
1724 //----------------------------------------------------------------------------
1726 Called when <Help> button is clicked, shows the corresponding help page in defined browser
1728 void VisuGUI_Prs3dDlg::onHelp()
1730 QString aHelpFileName = GetContextHelpFilePath();
1731 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1733 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
1734 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
1737 SUIT_MessageBox::warning( this, tr( "WRN_WARNING" ),
1738 tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1739 arg( app->resourceMgr()->stringValue( "ExternalBrowser",
1741 arg( aHelpFileName ) );
1746 //----------------------------------------------------------------------------
1747 void VisuGUI_Prs3dDlg::keyPressEvent( QKeyEvent* e )
1749 QDialog::keyPressEvent( e );
1750 if ( e->isAccepted() )
1753 if ( e->key() == Qt::Key_F1 ) {
1759 //----------------------------------------------------------------------------
1760 VisuGUI_ScalarBarBaseDlg::VisuGUI_ScalarBarBaseDlg( SalomeApp_Module* theModule, bool theIsDisplayGaussMetric, bool thePreview ) :
1761 VisuGUI_Prs3dDlg( theModule )
1763 myScalarPane = new VisuGUI_ScalarBarPane(this, theIsDisplayGaussMetric, thePreview);
1764 myScalarPane->layout()->setMargin( 5 );
1768 VisuGUI_ScalarBarBaseDlg::~VisuGUI_ScalarBarBaseDlg()
1773 //----------------------------------------------------------------------------
1774 void VisuGUI_ScalarBarBaseDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
1777 myScalarPane->initFromPrsObject( thePrs );
1781 //----------------------------------------------------------------------------
1783 Called when <OK> button is clicked, validates data and closes dialog
1785 void VisuGUI_ScalarBarBaseDlg::accept()
1787 if (GetScalarPane()->check())
1788 VisuGUI_Prs3dDlg::accept();
1792 //----------------------------------------------------------------------------
1794 Called when <Cancel> button is clicked, remove preview and closes dialog
1796 void VisuGUI_ScalarBarBaseDlg::reject()
1798 VisuGUI_Prs3dDlg::reject();
1801 //----------------------------------------------------------------------------
1802 VisuGUI_ScalarBarPane* VisuGUI_ScalarBarBaseDlg::GetScalarPane()
1804 return myScalarPane;
1808 //----------------------------------------------------------------------------