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", "application")).arg(aHelpFileName),
201 QObject::tr("BUT_OK"));
206 //----------------------------------------------------------------------------
207 void VisuGUI_TextPrefDlg::storeBeginValues()
209 myTitle = myTitleEdt->text();
210 myTitleFont->GetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
211 myLabelFont->GetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
215 //----------------------------------------------------------------------------
217 Called when <Cancel> button is clicked, restore begin values
219 void VisuGUI_TextPrefDlg::reject()
221 myTitleEdt->setText(myTitle);
222 myTitleFont->SetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
223 myLabelFont->SetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
229 //----------------------------------------------------------------------------
231 Called when <Ok> button is clicked, store begin values
233 void VisuGUI_TextPrefDlg::accept()
241 //----------------------------------------------------------------------------
243 Provides help on F1 button click
245 void VisuGUI_TextPrefDlg::keyPressEvent( QKeyEvent* e )
247 QDialog::keyPressEvent( e );
248 if ( e->isAccepted() )
251 if ( e->key() == Qt::Key_F1 )
258 //-----------------------------------------------------------------------
259 // Scalar Bar Preferences Dialog
260 //-----------------------------------------------------------------------
264 VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent )
269 setWindowTitle( tr( "TIT_BAR_PREF" ) );
270 setSizeGripEnabled( true );
272 QString propertyName = QString( "scalar_bar_vertical_" );
274 myTitleSize = myLabelSize = myBarWidth = myBarHeight = 0;
278 QVBoxLayout* aMainLay = new QVBoxLayout( this );
279 aMainLay->setSpacing( 5 );
280 aMainLay->setMargin( 5 );
284 QGroupBox* aDimGrp = new QGroupBox( this );
285 QGridLayout* aDimGrpLay = new QGridLayout( aDimGrp );
286 aDimGrpLay->setSpacing( 5 );
287 aDimGrpLay->setMargin( 5 );
289 myTitleSizeSpin = new QSpinBox( aDimGrp );
290 myTitleSizeSpin->setRange( 0, 100 );
291 myTitleSizeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
292 myTitleSizeSpin->setMinimumWidth( 70 );
293 myTitleSizeSpin->setValue( 0 );
294 myTitleSizeSpin->setSpecialValueText( tr( "AUTO" ) );
295 QLabel* aTitleSizeLbl = new QLabel( tr( "LBL_TITLE_W" ), aDimGrp );
297 myLabelSizeSpin = new QSpinBox( aDimGrp );
298 myLabelSizeSpin->setRange( 0, 100 );
299 myLabelSizeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
300 myLabelSizeSpin->setMinimumWidth( 70 );
301 myLabelSizeSpin->setValue( 0 );
302 myLabelSizeSpin->setSpecialValueText( tr( "AUTO" ) );
303 QLabel* aLabelSizeLbl = new QLabel( tr( "LBL_LABEL_W" ), aDimGrp );
305 myBarWidthSpin = new QSpinBox( aDimGrp );
306 myBarWidthSpin->setRange( 0, 100 );
307 myBarWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
308 myBarWidthSpin->setMinimumWidth( 70 );
309 myBarWidthSpin->setValue( 0 );
310 myBarWidthSpin->setSpecialValueText( tr( "AUTO" ) );
311 QLabel* aBarWidthLbl = new QLabel( tr( "LBL_BAR_W" ), aDimGrp );
313 myBarHeightSpin = new QSpinBox( aDimGrp );
314 myBarHeightSpin->setRange( 0, 100 );
315 myBarHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
316 myBarHeightSpin->setMinimumWidth( 70 );
317 myBarHeightSpin->setValue( 0 );
318 myBarHeightSpin->setSpecialValueText( tr( "AUTO" ) );
319 QLabel* aBarHeightLbl = new QLabel( tr( "LBL_BAR_H" ), aDimGrp );
323 QLabel* aPrecLbl = new QLabel( tr( "PRECISION" ), aDimGrp );
324 myPrecisionSpin = new QSpinBox( aDimGrp );
325 myPrecisionSpin->setRange( 1, 100 );
327 myUnitsChk = new QCheckBox( tr( "LBL_SHOW_UNITS" ), aDimGrp );
331 aDimGrpLay->addWidget( aTitleSizeLbl, 0, 0 );
332 aDimGrpLay->addWidget( myTitleSizeSpin, 0, 1 );
333 aDimGrpLay->addWidget( aLabelSizeLbl, 0, 2 );
334 aDimGrpLay->addWidget( myLabelSizeSpin, 0, 3 );
335 aDimGrpLay->addWidget( aBarWidthLbl, 1, 0 );
336 aDimGrpLay->addWidget( myBarWidthSpin, 1, 1 );
337 aDimGrpLay->addWidget( aBarHeightLbl, 1, 2 );
338 aDimGrpLay->addWidget( myBarHeightSpin, 1, 3 );
339 aDimGrpLay->addWidget( aPrecLbl, 2, 0 );
340 aDimGrpLay->addWidget( myPrecisionSpin, 2, 1 );
341 aDimGrpLay->addWidget( myUnitsChk, 2, 2, 1, 2 );
343 aMainLay->addWidget( aDimGrp );
345 // Common buttons ===========================================================
347 QGroupBox* GroupButtons = new QGroupBox( this );
348 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
349 GroupButtonsLayout->setAlignment( Qt::AlignTop );
350 GroupButtonsLayout->setSpacing( 6 );
351 GroupButtonsLayout->setMargin( 11 );
353 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons );
354 buttonOk->setAutoDefault( true );
355 buttonOk->setDefault( true );
357 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons );
358 buttonCancel->setAutoDefault( true );
360 QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons );
361 buttonHelp->setAutoDefault( true );
363 GroupButtonsLayout->addWidget( buttonOk );
364 GroupButtonsLayout->addSpacing( 5 );
365 GroupButtonsLayout->addStretch();
366 GroupButtonsLayout->addWidget( buttonCancel );
367 GroupButtonsLayout->addWidget( buttonHelp );
369 aMainLay->addWidget( GroupButtons );
371 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
372 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
373 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
374 connect( myTitleSizeSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
375 connect( myLabelSizeSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
376 connect( myBarWidthSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
377 connect( myBarHeightSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
378 connect( myUnitsChk, SIGNAL( toggled( bool ) ), this, SIGNAL( updatePreview() ) );
379 connect( myPrecisionSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
383 //----------------------------------------------------------------------------
384 void VisuGUI_BarPrefDlg::setRatios( int titleRatioSize, int labelRatioWidth,
385 int barRatioWidth, int barRatioHeight )
387 myTitleSizeSpin->setValue( myTitleSize = titleRatioSize );
388 myLabelSizeSpin->setValue( myLabelSize = labelRatioWidth );
389 myBarWidthSpin->setValue( myBarWidth = barRatioWidth );
390 myBarHeightSpin->setValue( myBarHeight = barRatioHeight );
394 //----------------------------------------------------------------------------
395 void VisuGUI_BarPrefDlg::getRatios( int& titleRatioSize, int& labelRatioWidth,
396 int& barRatioWidth, int& barRatioHeight )
398 titleRatioSize = myTitleSizeSpin->value();
399 labelRatioWidth = myLabelSizeSpin->value();
400 barRatioWidth = myBarWidthSpin->value();
401 barRatioHeight = myBarHeightSpin->value();
405 //----------------------------------------------------------------------------
406 void VisuGUI_BarPrefDlg::setLabelsPrecision( const int p )
408 myPrecisionSpin->setValue( p );
411 //----------------------------------------------------------------------------
412 int VisuGUI_BarPrefDlg::getLabelsPrecision() const
414 return myPrecisionSpin->value();
417 //----------------------------------------------------------------------------
418 void VisuGUI_BarPrefDlg::setOrientation( const int ori )
423 //----------------------------------------------------------------------------
425 int VisuGUI_BarPrefDlg::getOrientation() const
427 return myOrientation;
430 //----------------------------------------------------------------------------
431 void VisuGUI_BarPrefDlg::onHelp()
433 QString aHelpFileName = "scalar_map_page.html";
434 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
436 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
437 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
440 SUIT_MessageBox::warning( this, tr( "WRN_WARNING" ),
441 tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
442 arg( app->resourceMgr()->stringValue( "ExternalBrowser",
444 arg( aHelpFileName ) );
449 //----------------------------------------------------------------------------
450 void VisuGUI_BarPrefDlg::setUnitsVisible(bool isVisible)
452 myUnitsChk->setChecked( myUnits = isVisible );
456 //----------------------------------------------------------------------------
457 bool VisuGUI_BarPrefDlg::isUnitsVisible()
459 return myUnitsChk->isChecked();
463 //----------------------------------------------------------------------------
465 Called when <Cancel> button is clicked, restore begin values
467 void VisuGUI_BarPrefDlg::reject()
469 myTitleSizeSpin->setValue( myTitleSize );
470 myLabelSizeSpin->setValue( myLabelSize );
471 myBarWidthSpin->setValue( myBarWidth );
472 myBarHeightSpin->setValue( myBarHeight );
473 myUnitsChk->setChecked( myUnits );
474 myPrecisionSpin->setValue( myPrecision );
479 //----------------------------------------------------------------------------
481 Called when <Ok> button is clicked, store begin values
483 void VisuGUI_BarPrefDlg::accept()
486 int aBWH = myOrientation == 1 ? myBarWidthSpin->value() : myBarHeightSpin->value();
487 if( ( myLabelSizeSpin->value()+ aBWH ) > 100 )
489 SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE" ) );
493 if ( myTitleSizeSpin->value() > 100 )
495 SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE_TLT" ) );
499 myTitleSize = myTitleSizeSpin->value();
500 myLabelSize = myLabelSizeSpin->value();
501 myBarWidth = myBarWidthSpin->value();
502 myBarHeight = myBarHeightSpin->value();
503 myUnits = myUnitsChk->isChecked();
504 myPrecision = myPrecisionSpin->value();
509 //----------------------------------------------------------------------------
511 Provides help on F1 button click
513 void VisuGUI_BarPrefDlg::keyPressEvent( QKeyEvent* e )
515 QDialog::keyPressEvent( e );
516 if ( e->isAccepted() )
519 if ( e->key() == Qt::Key_F1 ) {
526 //-----------------------------------------------------------------------
528 //-----------------------------------------------------------------------
533 VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool theIsDisplayGaussMetric, bool thePreview )
538 myIsDisplayGaussMetric( theIsDisplayGaussMetric )
540 QVBoxLayout* aMainLayout = new QVBoxLayout( this );
541 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
542 QString propertyName;
543 propertyName = QString("scalar_bar_vertical_");
544 myVerX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
545 myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
546 myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
547 myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
548 myVerTS = aResourceMgr->integerValue("VISU", propertyName + "title_size", 0);
549 myVerLS = aResourceMgr->integerValue("VISU", propertyName + "label_size", 0);
550 myVerBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0);
551 myVerBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0);
553 propertyName = QString("scalar_bar_horizontal_");
554 myHorX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
555 myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
556 myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
557 myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
558 myHorTS = aResourceMgr->integerValue("VISU", propertyName + "title_size", 0);
559 myHorLS = aResourceMgr->integerValue("VISU", propertyName + "label_size", 0);
560 myHorBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0);
561 myHorBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0);
563 //aMainLayout->setSpacing(6);
565 // Range ============================================================
566 RangeGroup = new QButtonGroup ( this );
567 QGroupBox* aGB = new QGroupBox( tr("SCALAR_RANGE_GRP"),this );
568 aMainLayout->addWidget( aGB );
569 QGridLayout* RangeGroupLayout = new QGridLayout( aGB );
570 RangeGroupLayout->setAlignment( Qt::AlignTop );
571 //RangeGroupLayout->setSpacing( 6 );
572 //RangeGroupLayout->setMargin( 11 );
574 myModeLbl = new QLabel("Scalar Mode", aGB);
576 myModeCombo = new QComboBox(aGB);
578 CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), aGB);
579 CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
581 myGaussMetricLabel = new QLabel( tr("VISU_GAUSS_METRIC"), aGB );
582 myGaussMetric = new QComboBox( aGB );
583 myGaussMetric->addItem( tr("VISU_GAUSS_METRIC_AVERAGE") );
584 myGaussMetric->addItem( tr("VISU_GAUSS_METRIC_MINIMUM") );
585 myGaussMetric->addItem( tr("VISU_GAUSS_METRIC_MAXIMUM") );
586 myGaussMetric->setToolTip( tr("VISU_GAUSS_METRIC_TOOLTIP") );
588 if( !myIsDisplayGaussMetric ) {
589 myGaussMetricLabel->hide();
590 myGaussMetric->hide();
593 RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), aGB);
594 RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), aGB);
595 RangeGroup->addButton( RBFrange, 0 );
596 RangeGroup->addButton( RBIrange, 1 );
597 RBFrange->setChecked( true );
599 MinEdit = new QLineEdit( aGB );
600 MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
601 //MinEdit->setMinimumWidth( 70 );
602 MinEdit->setValidator( new QDoubleValidator(this) );
603 MinEdit->setText( "0.0" );
604 QLabel* MinLabel = new QLabel (tr("LBL_MIN"), aGB);
605 MinLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
606 MinLabel->setBuddy(MinEdit);
608 MaxEdit = new QLineEdit( aGB );
609 MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
610 //MaxEdit->setMinimumWidth( 70 );
611 MaxEdit->setValidator( new QDoubleValidator(this) );
612 MaxEdit->setText( "0.0" );
613 QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), aGB);
614 MaxLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
615 MaxLabel->setBuddy(MaxEdit);
617 RangeGroupLayout->addWidget( myModeLbl, 0, 0, 1, 1 );
618 RangeGroupLayout->addWidget( myModeCombo, 0, 1, 1, 2);
619 RangeGroupLayout->addWidget( CBLog, 0, 3, 1, 1);
620 RangeGroupLayout->addWidget( myGaussMetricLabel, 1, 0, 1, 1);
621 RangeGroupLayout->addWidget( myGaussMetric, 1, 1, 1, 3);
622 RangeGroupLayout->addWidget( RBFrange, 2, 0, 1, 2);
623 RangeGroupLayout->addWidget( RBIrange, 2, 2, 1, 2);
624 RangeGroupLayout->addWidget( MinLabel, 3, 0 );
625 RangeGroupLayout->addWidget( MinEdit, 3, 1 );
626 RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
627 RangeGroupLayout->addWidget( MaxEdit, 3, 3 );
629 // Colors and Labels ========================================================
630 QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this);
631 aMainLayout->addWidget( ColLabGroup );
632 QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup );
633 ColLabGroupLayout->setAlignment( Qt::AlignTop );
634 //ColLabGroupLayout->setSpacing( 6 );
635 //ColLabGroupLayout->setMargin( 11 );
637 QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup);
638 ColorSpin = new QSpinBox( ColLabGroup );
639 ColorSpin->setMinimum( 2 );
640 ColorSpin->setMaximum( 256 );
641 ColorSpin->setSingleStep( 1 );
642 ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
643 //ColorSpin->setMinimumWidth( 70 );
644 ColorSpin->setValue( 64 );
646 QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup);
647 LabelSpin = new QSpinBox( ColLabGroup );
648 LabelSpin->setMinimum( 2 );
649 LabelSpin->setMaximum( 65 );
650 LabelSpin->setSingleStep( 1 );
652 LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
653 //LabelSpin->setMinimumWidth( 70 );
654 LabelSpin->setValue( 5 );
656 ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
657 ColLabGroupLayout->addWidget( ColorSpin, 0, 1);
658 ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
659 ColLabGroupLayout->addWidget( LabelSpin, 0, 3);
661 // Orientation ==========================================================
662 QButtonGroup* OrientGroup = new QButtonGroup ( this );
663 QGroupBox* OrientGB = new QGroupBox( tr("ORIENTATION_GRP"),this );
664 aMainLayout->addWidget( OrientGB );
665 QGridLayout* OrientGroupLayout = new QGridLayout( OrientGB );
666 OrientGroupLayout->setAlignment( Qt::AlignTop );
667 //OrientGroupLayout->setSpacing( 6 );
668 //OrientGroupLayout->setMargin( 11 );
670 RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGB);
671 RBvert->setChecked( true );
672 RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGB);
673 OrientGroup->addButton( RBvert );
674 OrientGroup->addButton( RBhori );
675 OrientGroupLayout->addWidget( RBvert, 0, 0 );
676 OrientGroupLayout->addWidget( RBhori, 0, 1 );
678 // Origin ===============================================================
679 QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this);
680 aMainLayout->addWidget( OriginGroup );
681 QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup );
682 OriginGroupLayout->setAlignment( Qt::AlignTop );
683 //OriginGroupLayout->setSpacing( 6 );
684 //OriginGroupLayout->setMargin( 11 );
686 QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup);
687 XSpin = new QtxDoubleSpinBox( OriginGroup );
688 VISU::initSpinBox(XSpin, 0.0, +1.0);
689 XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
690 //XSpin->setMinimumWidth( 70 );
691 XSpin->setValue( 0.01 );
693 QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup);
694 YSpin = new QtxDoubleSpinBox( OriginGroup );
695 VISU::initSpinBox(YSpin, 0.0, +1.0);
696 YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
697 //YSpin->setMinimumWidth( 70 );
698 YSpin->setValue( 0.1 );
700 OriginGroupLayout->addWidget( XLabel, 0, 0);
701 OriginGroupLayout->addWidget( XSpin, 0, 1);
702 OriginGroupLayout->addWidget( YLabel, 0, 2);
703 OriginGroupLayout->addWidget( YSpin, 0, 3);
705 // Dimensions =========================================================
706 QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this );
707 aMainLayout->addWidget( DimGroup );
708 QGridLayout* DimGroupLayout = new QGridLayout( DimGroup );
709 DimGroupLayout->setAlignment( Qt::AlignTop );
710 //DimGroupLayout->setSpacing( 6 );
711 //DimGroupLayout->setMargin( 11 );
713 QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup);
714 WidthSpin = new QtxDoubleSpinBox( DimGroup );
715 VISU::initSpinBox(WidthSpin, 0.0, +1.0);
716 WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
717 //WidthSpin->setMinimumWidth( 70 );
718 WidthSpin->setValue( 0.1 );
720 QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup);
721 HeightSpin = new QtxDoubleSpinBox( DimGroup );
722 VISU::initSpinBox(HeightSpin, 0.0, +1.0);
723 HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
724 //HeightSpin->setMinimumWidth( 70 );
725 HeightSpin->setValue( 0.8 );
727 DimGroupLayout->addWidget( WidthLabel, 0, 0);
728 DimGroupLayout->addWidget( WidthSpin, 0, 1);
729 DimGroupLayout->addWidget( HeightLabel, 0, 2);
730 DimGroupLayout->addWidget( HeightSpin, 0, 3);
732 // Save check box ===========================================================
733 QWidget* aSaveBox = new QWidget(this);
734 aMainLayout->addWidget( aSaveBox );
735 QHBoxLayout* aVBLay = new QHBoxLayout( aSaveBox );
736 aVBLay->addWidget( myTextBtn = new QPushButton("Text properties...", aSaveBox) );
737 aVBLay->addWidget( myBarBtn = new QPushButton("Bar properties...", aSaveBox) );
739 aMainLayout->addWidget( myTextDlg = new VisuGUI_TextPrefDlg(this) );
740 myTextDlg->setTitleVisible(!thePreview);
741 myBarDlg = new VisuGUI_BarPrefDlg(this);
743 QGroupBox* CheckGroup = new QGroupBox("", this );
744 aMainLayout->addWidget( CheckGroup );
745 //QHBoxLayout* CheckGroupLayout = new QHBoxLayout( CheckGroup );
746 QGridLayout* CheckGroupLayout = new QGridLayout( CheckGroup );
748 myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), CheckGroup);
749 myPreviewCheck->setChecked(false);
750 CheckGroupLayout->addWidget(myPreviewCheck, 0, 0);
752 myHideBar = new QCheckBox(tr("HIDE_SCALAR_BAR"), CheckGroup);
753 myHideBar->setChecked(false);
754 CheckGroupLayout->addWidget(myHideBar, 0, 1);
757 CBDistr = new QCheckBox (tr("SHOW_DISTRIBUTION"), CheckGroup);
758 CheckGroupLayout->addWidget(CBDistr, 1, 0);
761 CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), CheckGroup);
762 CheckGroupLayout->addWidget( CBSave, 1, 1 );
766 myPreviewCheck->hide();
770 if(RBvert->isChecked()) {
771 myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH);
773 myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH);
776 int lp = aResourceMgr->integerValue( "VISU", propertyName + "scalar_bar_label_precision", 3 );
777 myBarDlg->setLabelsPrecision( lp );
779 myBarDlg->setUnitsVisible(aResourceMgr->booleanValue("VISU", propertyName + "display_units", true));
781 // signals and slots connections ===========================================
782 connect( RBFrange, SIGNAL( toggled( bool ) ), this, SLOT( onFieldRange( bool ) ) );
783 connect( RBIrange, SIGNAL( toggled( bool ) ), this, SLOT( onImposedRange( bool ) ) );
785 connect( myModeCombo, SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( int ) ) );
786 connect( myGaussMetric, SIGNAL( activated( int ) ), this, SLOT( changeGaussMetric( int ) ) );
787 connect( OrientGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( changeDefaults( int ) ) );
788 connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
789 connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
790 connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
791 connect( myBarBtn, SIGNAL( clicked() ), this, SLOT( onBarPref() ) );
792 connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) );
794 connect( CBDistr, SIGNAL( toggled( bool ) ), this, SLOT( onShowDistribution( bool ) )); // RKV
796 connect( ColorSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
797 connect( LabelSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
798 connect( WidthSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
799 connect( HeightSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
800 connect( CBLog, SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() ));
801 connect( myBarDlg, SIGNAL( updatePreview() ), this, SLOT( updatePreview() ));
803 myIsStoreTextProp = false;
808 * Stores dialog values to resources
810 void VisuGUI_ScalarBarPane::storeToResources() {
811 int orient = (RBvert->isChecked())? 0 : 1;
812 float sbX1 = XSpin->value();
813 float sbY1 = YSpin->value();
814 float sbW = WidthSpin->value();
815 float sbH = HeightSpin->value();
816 int sbCol = ColorSpin->value();
817 int sbLab = LabelSpin->value();
819 if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
833 bool sbRange = RBIrange->isChecked();
834 float sbVmin = (float)(MinEdit->text().toDouble());
835 float sbVmax = (float)(MaxEdit->text().toDouble());
837 if(sbVmin > sbVmax) {
842 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
844 aResourceMgr->setValue("VISU", "scalar_bar_orientation", orient);
846 QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
848 aResourceMgr->setValue("VISU", propertyName + "x", sbX1);
849 aResourceMgr->setValue("VISU", propertyName + "y", sbY1);
850 aResourceMgr->setValue("VISU", propertyName + "width", sbW);
851 aResourceMgr->setValue("VISU", propertyName + "height", sbH);
853 aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol);
854 aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab);
858 aResourceMgr->setValue("VISU", "scalar_range_type", 1);
859 aResourceMgr->setValue("VISU", "scalar_range_min" ,sbVmin);
860 aResourceMgr->setValue("VISU", "scalar_range_max" ,sbVmax);
863 aResourceMgr->setValue("VISU", "scalar_range_type", 0);
865 aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic());
866 aResourceMgr->setValue("VISU", "scalar_bar_show_distribution", isShowDistribution()); // RKV
870 if (myIsStoreTextProp) {
872 QColor aTitleColor (255, 255, 255);
873 int aTitleFontFamily = VTK_ARIAL;
874 bool isTitleBold = false;
875 bool isTitleItalic = false;
876 bool isTitleShadow = false;
878 myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily,
879 isTitleBold, isTitleItalic, isTitleShadow);
883 aTitleFont.setBold(isTitleBold);
884 aTitleFont.setItalic(isTitleItalic);
885 aTitleFont.setOverline(isTitleShadow);
887 QString titleFontFamily;
888 switch (aTitleFontFamily) {
890 titleFontFamily = "Arial";
893 titleFontFamily = "Courier";
896 titleFontFamily = "Times";
899 aTitleFont.setFamily(titleFontFamily);
901 aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont);
903 aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor);
906 QColor aLabelColor (255, 255, 255);
907 int aLabelFontFamily = VTK_ARIAL;
908 bool isLabelBold = false;
909 bool isLabelItalic = false;
910 bool isLabelShadow = false;
912 myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
913 isLabelBold, isLabelItalic, isLabelShadow);
918 aLabelFont.setBold(isLabelBold);
919 aLabelFont.setItalic(isLabelItalic);
920 aLabelFont.setOverline(isLabelShadow);
922 QString labelFontFamily;
923 switch (aLabelFontFamily) {
925 labelFontFamily = "Arial";
928 labelFontFamily = "Courier";
931 labelFontFamily = "Times";
935 aLabelFont.setFamily(labelFontFamily);
937 aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont);
939 aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor);
943 //----------------------------------------------------------------------------
944 VisuGUI_ScalarBarPane::~VisuGUI_ScalarBarPane()
947 if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
948 aViewWindow->Repaint();
951 //----------------------------------------------------------------------------
953 * Initialise dialog box from presentation object
955 void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs)
957 myScalarMap = dynamic_cast<VISU::ScalarMap_i*>(thePrs);
962 switch(myScalarMap->GetScaling()){
963 case VISU::LOGARITHMIC :
964 setLogarithmic(true);
967 setLogarithmic(false);
970 // Update myModeCombo
971 const VISU::PField& aField = myScalarMap->GetScalarField();
972 const VISU::TNames& aCompNames = aField->myCompNames;
973 const VISU::TNames& aUnitNames = aField->myUnitNames;
974 int aNbComp = aField->myNbComp;
975 bool isScalarMode = (aNbComp > 1);
976 myModeCombo->clear();
977 myModeCombo->addItem("<Modulus>");
978 for(int i = 0; i < aNbComp; i++){
979 QString aComponent = QString(aCompNames[i].c_str()).simplified();
980 if(aComponent.isNull() || aComponent == "")
981 aComponent = "Component " + QString::number(i+1);
983 aComponent = "[" + QString::number(i+1) + "] " + aComponent;
985 QString anUnit = QString(aUnitNames[i].c_str()).simplified();
986 if(anUnit.isNull() || anUnit == "")
989 aComponent = aComponent + ", " + anUnit;
991 myModeCombo->addItem(aComponent);
994 myModeCombo->setCurrentIndex(myScalarMap->GetScalarMode());
996 myModeCombo->setCurrentIndex(1);
998 myModeLbl->setEnabled(isScalarMode);
999 myModeCombo->setEnabled(isScalarMode);
1001 // Gauss Metric option should be visible only if at least one
1002 // of mesh values on geometry is based on multiple gauss points
1003 bool isEnableGaussMetric = false;
1004 if( myIsDisplayGaussMetric ) {
1005 const VISU::TValField& aValField = aField->myValField;
1006 VISU::TValField::const_iterator anIter = aValField.find(myScalarMap->GetScalarTimeStampNumber());
1007 if ( anIter != aValField.end() ) {
1008 VISU::PValForTime aValForTime = anIter->second;
1009 if( aValForTime && aValForTime->GetMaxNbGauss() > 1 )
1010 isEnableGaussMetric = true;
1014 myGaussMetricLabel->setEnabled(isEnableGaussMetric);
1015 myGaussMetric->setEnabled(isEnableGaussMetric);
1016 if( isEnableGaussMetric )
1017 myGaussMetric->setCurrentIndex((int)myScalarMap->GetGaussMetric());
1019 setRange( myScalarMap->GetMin(), myScalarMap->GetMax(), myScalarMap->IsRangeFixed() );
1021 setScalarBarData( myScalarMap->GetNbColors(), myScalarMap->GetLabels() );
1022 setShowDistribution( myScalarMap->GetIsDistributionVisible() );
1025 CORBA::String_var aTitle = myScalarMap->GetTitle();
1026 myTextDlg->setTitleText(aTitle.in());
1027 myTitle = aTitle.in();
1029 setPosAndSize( myScalarMap->GetPosX(),
1030 myScalarMap->GetPosY(),
1031 myScalarMap->GetWidth(),
1032 myScalarMap->GetHeight(),
1033 myScalarMap->GetBarOrientation());
1035 if(RBvert->isChecked()) {
1036 myVerTS = myScalarMap->GetTitleSize();
1037 myVerLS = myScalarMap->GetLabelSize();
1038 myVerBW = myScalarMap->GetBarWidth();
1039 myVerBH = myScalarMap->GetBarHeight();
1040 myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1042 myHorTS = myScalarMap->GetTitleSize();
1043 myHorLS = myScalarMap->GetLabelSize();
1044 myHorBW = myScalarMap->GetBarWidth();
1045 myHorBH = myScalarMap->GetBarHeight();
1046 myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1049 myBarDlg->setLabelsPrecision( VISU::ToPrecision( myScalarMap->GetLabelsFormat() ) );
1050 myBarDlg->setUnitsVisible(myScalarMap->IsUnitsVisible());
1052 vtkFloatingPointType R, G, B;
1053 myScalarMap->GetTitleColor(R, G, B);
1055 QColor aTextColor = QColor((int)(R*255.), (int)(G*255.), (int)(B*255.));
1057 myTextDlg->myTitleFont->SetData(aTextColor,
1058 myScalarMap->GetTitFontType(),
1059 myScalarMap->IsBoldTitle(),
1060 myScalarMap->IsItalicTitle(),
1061 myScalarMap->IsShadowTitle());
1064 myScalarMap->GetLabelColor(R, G, B);
1066 QColor aLabelColor = QColor((int)(R*255.), (int)(G*255.), (int)(B*255.));
1068 myTextDlg->myLabelFont->SetData(aLabelColor,
1069 myScalarMap->GetLblFontType(),
1070 myScalarMap->IsBoldLabel(),
1071 myScalarMap->IsItalicLabel(),
1072 myScalarMap->IsShadowLabel());
1074 myHideBar->setChecked(!myScalarMap->IsBarVisible());
1077 if (myPreviewCheck->isChecked()) {
1085 //----------------------------------------------------------------------------
1086 /*! Slot update preview of scalar bar, if preview is checked
1088 void VisuGUI_ScalarBarPane::updatePreview()
1090 if (myPreviewCheck->isChecked()) {
1091 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
1099 //----------------------------------------------------------------------------
1100 /*! Creating preview scalar bar
1102 void VisuGUI_ScalarBarPane::createScalarBar()
1104 if (VISU::GetActiveViewWindow<SVTK_ViewWindow>() == NULL) return;
1105 if (myPreviewActor != 0) return;
1106 if (myScalarMap == NULL) return;
1108 if (!check()) return;
1109 myScalarMapPL = VISU_ScalarMapPL::New();
1110 if(myScalarMap->GetSpecificPL())
1111 myScalarMapPL->ShallowCopy(myScalarMap->GetSpecificPL(), true);
1113 if ( myBusy ) return;
1118 sbCol = getNbColors();
1119 sbLab = getNbLabels();
1120 if(sbCol < 2) sbCol=2;
1121 if(sbCol > 64) sbCol=64;
1122 if(sbLab < 2) sbLab=2;
1123 if(sbLab > 65) sbLab=65;
1124 myPreviewActor = VISU_ScalarMapAct::New();
1125 VISU_ScalarBarActor* aScalarBarActor = myPreviewActor->GetScalarBar();
1126 myPreviewActor->GetScalarBar()->VisibilityOn();
1127 myPreviewActor->PickableOff();
1128 //myPreviewActor->SetBarVisibility(!myHideBar->isChecked());
1130 myScalarMapPL->SetScalarMode(myModeCombo->currentIndex());
1132 myScalarMapPL->SetScaling(VISU::LOGARITHMIC);
1134 myScalarMapPL->SetScaling(VISU::LINEAR);
1136 if( myGaussMetric->isVisible() )
1137 myScalarMapPL->SetGaussMetric((VISU::TGaussMetric)myGaussMetric->currentIndex());
1139 if ( RBFrange->isChecked() ) {
1140 myScalarMapPL->SetSourceRange();
1142 vtkFloatingPointType aRange[2];
1143 aRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble();
1144 aRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble();
1145 myScalarMapPL->SetScalarRange( aRange );
1148 myScalarMapPL->SetNbColors(sbCol);
1149 myScalarMapPL->Update();
1151 aScalarBarActor->SetLookupTable(myScalarMapPL->GetBarTable());
1152 aScalarBarActor->SetDistribution( myScalarMapPL->GetDistribution() );
1153 aScalarBarActor->SetDistributionVisibility( isShowDistribution() );
1155 if (!myTextDlg->getTitleText().isEmpty()) {
1156 VISU::PValForTime aValForTime;
1157 const VISU::PField& aField = myScalarMap->GetScalarField();
1158 const VISU::TValField& aValField = aField->myValField;
1159 VISU::TValField::const_iterator anIter = aValField.find(myScalarMap->GetScalarTimeStampNumber());
1160 if (anIter != aValField.end())
1161 aValForTime = anIter->second;
1164 std::strstream aStream;
1165 const VISU::TTime& aTime = aValForTime->myTime;
1166 aStream<< myTextDlg->getTitleText().toLatin1().data() <<" ";
1167 if(myBarDlg->isUnitsVisible())
1168 aStream<<VISU_Convertor::GenerateName(aTime)<<std::ends;
1171 aName.sprintf("%g", aTime.first);
1172 aStream << aName.toLatin1().data() << std::ends;
1174 std::string aScalarBarTitle = aStream.str();
1175 aScalarBarActor->SetTitle(aScalarBarTitle.c_str());
1177 aScalarBarActor->SetTitle(myTextDlg->getTitleText().toLatin1().data());
1181 aScalarBarActor->SetTitle(myTitle.c_str());
1182 aScalarBarActor->SetOrientation(getOrientation());
1183 aScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
1184 aScalarBarActor->GetPositionCoordinate()->SetValue(getX(),getY());
1185 aScalarBarActor->SetWidth(getWidth());
1186 aScalarBarActor->SetHeight(getHeight());
1187 aScalarBarActor->SetNumberOfLabels(sbLab);
1188 aScalarBarActor->SetMaximumNumberOfColors(sbCol);
1190 // title text property
1192 int aTitleFontFamily;
1196 myTextDlg->myTitleFont->GetData(aTitleColor,aTitleFontFamily,
1197 isTitleBold,isTitleItalic,isTitleShadow);
1198 vtkTextProperty* aTitleProp = aScalarBarActor->GetTitleTextProperty();
1199 aTitleProp->SetFontFamily(aTitleFontFamily);
1200 aTitleProp->SetColor(vtkFloatingPointType(aTitleColor.red())/255.,
1201 vtkFloatingPointType(aTitleColor.green())/255.,
1202 vtkFloatingPointType(aTitleColor.blue())/255.);
1203 (isTitleBold)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
1204 (isTitleItalic)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
1205 (isTitleShadow)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
1207 // label text property
1209 int aLabelFontFamily;
1213 myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
1214 isLabelBold, isLabelItalic, isLabelShadow);
1215 vtkTextProperty* aLabelProp = aScalarBarActor->GetLabelTextProperty();
1216 aLabelProp->SetFontFamily(aLabelFontFamily);
1217 aLabelProp->SetColor(vtkFloatingPointType(aLabelColor.red())/255.,
1218 vtkFloatingPointType(aLabelColor.green())/255.,
1219 vtkFloatingPointType(aLabelColor.blue())/255.);
1220 (isLabelBold)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
1221 (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
1222 (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
1224 int VerTS, VerTH, VerLS, VerBW, VerBH;
1225 myBarDlg->getRatios(VerTS, VerLS, VerBW, VerBH);
1226 aScalarBarActor->SetRatios(VerTS, VerLS, VerBW, VerBH);
1228 std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() );
1229 aScalarBarActor->SetLabelFormat( f.c_str() );
1231 aScalarBarActor->Modified();
1233 VISU::GetActiveViewWindow<SVTK_ViewWindow>()->AddActor(myPreviewActor);
1239 //----------------------------------------------------------------------------
1240 /*! Deleting preview scalar bar
1242 void VisuGUI_ScalarBarPane::deleteScalarBar()
1244 if ( myBusy ) return;
1246 if (myPreviewActor == 0) return;
1247 vtkRenderer* aRend = myPreviewActor->GetRenderer();
1248 vtkRenderWindow* aWnd = aRend->GetRenderWindow();
1250 myPreviewActor->RemoveFromRender(aRend);
1251 myPreviewActor->GetScalarBar()->VisibilityOff();
1252 myPreviewActor->Delete();
1256 myScalarMapPL->Delete();
1262 //----------------------------------------------------------------------------
1264 * Store values to presentation object
1266 int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) {
1270 myScalarMap->SetScalarMode(myModeCombo->currentIndex());
1271 if( myGaussMetric->isVisible() )
1272 myScalarMap->SetGaussMetric((VISU::GaussMetric)myGaussMetric->currentIndex());
1273 myScalarMap->SetPosition(XSpin->value(), YSpin->value());
1274 myScalarMap->SetSize(WidthSpin->value(), HeightSpin->value());
1275 if(RBvert->isChecked()) {
1276 myScalarMap->SetRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1278 myScalarMap->SetRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1281 std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() );
1282 myScalarMap->SetLabelsFormat( f.c_str() );
1283 myScalarMap->SetUnitsVisible(myBarDlg->isUnitsVisible());
1285 myScalarMap->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3dBase::VERTICAL : VISU::ColoredPrs3dBase::HORIZONTAL);
1287 myScalarMap->SetScaling(VISU::LOGARITHMIC);
1289 myScalarMap->SetScaling(VISU::LINEAR);
1291 if ( RBFrange->isChecked() ) {
1292 myScalarMap->SetSourceRange();
1294 myScalarMap->SetRange( MinEdit->text().toDouble(), MaxEdit->text().toDouble() );
1296 myScalarMap->SetNbColors(ColorSpin->value());
1297 myScalarMap->SetLabels(LabelSpin->value());
1298 myScalarMap->SetIsDistributionVisible(isShowDistribution()); // RKV
1300 myScalarMap->SetBarVisible(!myHideBar->isChecked());
1302 if (isToSave()) storeToResources();
1304 if (myIsStoreTextProp) {
1306 myScalarMap->SetTitle(myTextDlg->getTitleText().toLatin1().data());
1308 QColor aTitColor (255, 255, 255);
1309 int aTitleFontFamily = VTK_ARIAL;
1310 bool isTitleBold = false;
1311 bool isTitleItalic = false;
1312 bool isTitleShadow = false;
1314 myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
1315 isTitleBold, isTitleItalic, isTitleShadow);
1317 myScalarMap->SetBoldTitle(isTitleBold);
1318 myScalarMap->SetItalicTitle(isTitleItalic);
1319 myScalarMap->SetShadowTitle(isTitleShadow);
1320 myScalarMap->SetTitFontType(aTitleFontFamily);
1321 myScalarMap->SetTitleColor(aTitColor.red()/255.,
1322 aTitColor.green()/255.,
1323 aTitColor.blue()/255.);
1326 QColor aLblColor (255, 255, 255);
1327 int aLabelFontFamily = VTK_ARIAL;
1328 bool isLabelBold = false;
1329 bool isLabelItalic = false;
1330 bool isLabelShadow = false;
1332 myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
1333 isLabelBold, isLabelItalic, isLabelShadow);
1335 myScalarMap->SetBoldLabel(isLabelBold);
1336 myScalarMap->SetItalicLabel(isLabelItalic);
1337 myScalarMap->SetShadowLabel(isLabelShadow);
1338 myScalarMap->SetLblFontType(aLabelFontFamily);
1339 myScalarMap->SetLabelColor(aLblColor.red()/255.,
1340 aLblColor.green()/255.,
1341 aLblColor.blue()/255.);
1342 myIsStoreTextProp = false;
1349 //----------------------------------------------------------------------------
1351 Called when orientation is changed
1353 void VisuGUI_ScalarBarPane::changeDefaults( int )
1355 if ( RBvert->isChecked() ) {
1356 XSpin->setValue( myVerX );
1357 YSpin->setValue( myVerY );
1358 WidthSpin->setValue( myVerW );
1359 HeightSpin->setValue( myVerH );
1362 XSpin->setValue( myHorX );
1363 YSpin->setValue( myHorY );
1364 WidthSpin->setValue( myHorW );
1365 HeightSpin->setValue( myHorH );
1371 //----------------------------------------------------------------------------
1373 Called when Range mode is changed
1375 void VisuGUI_ScalarBarPane::onFieldRange( bool isOn )
1378 myScalarMap->SetSourceRange();
1379 MinEdit->setEnabled( false );
1380 MaxEdit->setEnabled( false );
1381 changeScalarMode(myModeCombo->currentIndex());
1385 void VisuGUI_ScalarBarPane::onImposedRange( bool isOn )
1388 myScalarMap->SetRange( myScalarMap->GetSourceMin(), myScalarMap->GetSourceMax() );
1389 MinEdit->setEnabled( true );
1390 MaxEdit->setEnabled( true );
1391 changeScalarMode(myModeCombo->currentIndex());
1395 void VisuGUI_ScalarBarPane::onShowDistribution( bool isOn )
1397 myScalarMap->SetIsDistributionVisible(isOn);
1401 void VisuGUI_ScalarBarPane::changeRange( int )
1403 if ( RBFrange->isChecked() ) {
1404 myScalarMap->SetSourceRange();
1405 MinEdit->setEnabled( false );
1406 MaxEdit->setEnabled( false );
1408 myScalarMap->SetRange( myScalarMap->GetSourceMin(), myScalarMap->GetSourceMax() );
1409 MinEdit->setEnabled( true );
1410 MaxEdit->setEnabled( true );
1413 changeScalarMode(myModeCombo->currentIndex());
1417 //----------------------------------------------------------------------------
1419 Called when X,Y position is changed
1421 void VisuGUI_ScalarBarPane::XYChanged( double )
1423 QtxDoubleSpinBox* snd = (QtxDoubleSpinBox*)sender();
1424 if ( snd == XSpin ) {
1425 WidthSpin->setMaximum( 1.0 - XSpin->value() );
1427 if ( snd == YSpin ) {
1428 HeightSpin->setMaximum( 1.0 - YSpin->value() );
1434 //----------------------------------------------------------------------------
1436 Called when scalar mode is changed
1438 void VisuGUI_ScalarBarPane::changeScalarMode( int theMode )
1440 myScalarMap->SetScalarMode(theMode);
1442 if ( RBFrange->isChecked() ) {
1443 MinEdit->setText( QString::number( myScalarMap->GetSourceMin() ) );
1444 MaxEdit->setText( QString::number( myScalarMap->GetSourceMax() ) );
1451 //----------------------------------------------------------------------------
1453 Called when scalar mode is changed
1455 void VisuGUI_ScalarBarPane::changeGaussMetric( int theGaussMetric )
1457 myScalarMap->SetGaussMetric((VISU::GaussMetric)theGaussMetric);
1459 if ( RBFrange->isChecked() ) {
1460 MinEdit->setText( QString::number( myScalarMap->GetSourceMin() ) );
1461 MaxEdit->setText( QString::number( myScalarMap->GetSourceMax() ) );
1468 //----------------------------------------------------------------------------
1470 Sets default values and range mode
1472 void VisuGUI_ScalarBarPane::setRange( double imin, double imax, bool sbRange )
1474 MinEdit->setText( QString::number( imin ) );
1475 MaxEdit->setText( QString::number( imax ) );
1477 RBIrange->setChecked( true );
1479 RBFrange->setChecked( true );
1481 changeRange( sbRange );
1485 //----------------------------------------------------------------------------
1487 Sets and gets parameters
1489 bool VisuGUI_ScalarBarPane::isIRange() {
1490 return RBIrange->isChecked();
1494 //----------------------------------------------------------------------------
1495 double VisuGUI_ScalarBarPane::getMin() {
1496 return MinEdit->text().toDouble();
1500 //----------------------------------------------------------------------------
1501 double VisuGUI_ScalarBarPane::getMax() {
1502 return MaxEdit->text().toDouble();
1506 //----------------------------------------------------------------------------
1507 double VisuGUI_ScalarBarPane::getX() {
1508 return XSpin->value();
1512 //----------------------------------------------------------------------------
1513 double VisuGUI_ScalarBarPane::getY() {
1514 return YSpin->value();
1518 //----------------------------------------------------------------------------
1519 double VisuGUI_ScalarBarPane::getWidth() {
1520 return WidthSpin->value();
1524 //----------------------------------------------------------------------------
1525 double VisuGUI_ScalarBarPane::getHeight() {
1526 return HeightSpin->value();
1530 //----------------------------------------------------------------------------
1531 int VisuGUI_ScalarBarPane::getNbColors() {
1532 return ColorSpin->value();
1536 //----------------------------------------------------------------------------
1537 int VisuGUI_ScalarBarPane::getNbLabels() {
1538 return LabelSpin->value();
1542 //----------------------------------------------------------------------------
1543 bool VisuGUI_ScalarBarPane::isLogarithmic() {
1544 return CBLog->isChecked();
1548 //----------------------------------------------------------------------------
1549 void VisuGUI_ScalarBarPane::setLogarithmic( bool on ) {
1550 CBLog->setChecked( on );
1553 //----------------------------------------------------------------------------
1554 bool VisuGUI_ScalarBarPane::isShowDistribution() {
1555 return CBDistr->isChecked();
1559 //----------------------------------------------------------------------------
1560 void VisuGUI_ScalarBarPane::setShowDistribution( bool on ) {
1561 CBDistr->setChecked( on );
1565 //----------------------------------------------------------------------------
1566 bool VisuGUI_ScalarBarPane::isToSave() {
1567 return CBSave ? CBSave->isChecked() : false;
1570 //----------------------------------------------------------------------------
1572 Sets size and position
1574 void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
1581 RBvert->setChecked( true );
1588 RBhori->setChecked( true );
1590 changeDefaults( 0 );
1594 //----------------------------------------------------------------------------
1596 Sets colors and labels number
1598 void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
1600 ColorSpin->setValue( colors );
1601 LabelSpin->setValue( labels );
1605 //----------------------------------------------------------------------------
1609 int VisuGUI_ScalarBarPane::getOrientation()
1611 if (RBvert->isChecked() )
1618 //----------------------------------------------------------------------------
1620 Called when <OK> button is clicked, validates data and closes dialog
1622 bool VisuGUI_ScalarBarPane::check()
1624 double minVal = MinEdit->text().toDouble();
1625 double maxVal = MaxEdit->text().toDouble();
1626 if ( RBIrange->isChecked() ) {
1627 if (minVal >= maxVal) {
1628 SUIT_MessageBox::warning( this,tr("WRN_VISU"),
1629 tr("MSG_MINMAX_VALUES"),
1635 // check if logarithmic mode is on and check imposed range to not contain negative values
1636 if ( CBLog->isChecked() ) {
1637 if ( minVal <= 0.0 || maxVal <= 0.0 ) {
1638 if ( RBIrange->isChecked() ) {
1639 SUIT_MessageBox::warning( this,
1641 tr("WRN_LOGARITHMIC_RANGE"),
1644 if ( minVal == 0 || maxVal == 0 )
1645 SUIT_MessageBox::warning( this,
1647 tr("WRN_LOGARITHMIC_RANGE"),
1650 SUIT_MessageBox::warning( this,
1652 tr("WRN_LOGARITHMIC_FIELD_RANGE"),
1654 RBIrange->setChecked(true);
1664 //----------------------------------------------------------------------------
1665 void VisuGUI_ScalarBarPane::onTextPref()
1667 myTextDlg->storeBeginValues();
1668 myIsStoreTextProp = myTextDlg->exec() || myIsStoreTextProp;
1673 //----------------------------------------------------------------------------
1674 void VisuGUI_ScalarBarPane::onBarPref()
1676 if(RBvert->isChecked())
1677 myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1679 myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1680 myBarDlg->setOrientation( getOrientation() );
1681 if(myBarDlg->exec()) {
1682 if(RBvert->isChecked())
1683 myBarDlg->getRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1685 myBarDlg->getRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1691 //----------------------------------------------------------------------------
1692 void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview)
1694 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
1704 VisuGUI_Prs3dDlg::VisuGUI_Prs3dDlg( SalomeApp_Module* theModule )
1705 : QDialog( VISU::GetDesktop( theModule ), Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
1709 //----------------------------------------------------------------------------
1711 Called when <Help> button is clicked, shows the corresponding help page in defined browser
1713 void VisuGUI_Prs3dDlg::onHelp()
1715 QString aHelpFileName = GetContextHelpFilePath();
1716 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1718 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
1719 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
1722 SUIT_MessageBox::warning( this, tr( "WRN_WARNING" ),
1723 tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1724 arg( app->resourceMgr()->stringValue( "ExternalBrowser",
1726 arg( aHelpFileName ) );
1731 //----------------------------------------------------------------------------
1732 void VisuGUI_Prs3dDlg::keyPressEvent( QKeyEvent* e )
1734 QDialog::keyPressEvent( e );
1735 if ( e->isAccepted() )
1738 if ( e->key() == Qt::Key_F1 ) {
1744 //----------------------------------------------------------------------------
1745 VisuGUI_ScalarBarBaseDlg::VisuGUI_ScalarBarBaseDlg( SalomeApp_Module* theModule, bool theIsDisplayGaussMetric, bool thePreview ) :
1746 VisuGUI_Prs3dDlg( theModule )
1748 myScalarPane = new VisuGUI_ScalarBarPane(this, theIsDisplayGaussMetric, thePreview);
1749 myScalarPane->layout()->setMargin( 5 );
1753 VisuGUI_ScalarBarBaseDlg::~VisuGUI_ScalarBarBaseDlg()
1758 //----------------------------------------------------------------------------
1759 void VisuGUI_ScalarBarBaseDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
1762 myScalarPane->initFromPrsObject( thePrs );
1766 //----------------------------------------------------------------------------
1768 Called when <OK> button is clicked, validates data and closes dialog
1770 void VisuGUI_ScalarBarBaseDlg::accept()
1772 if (GetScalarPane()->check())
1773 VisuGUI_Prs3dDlg::accept();
1777 //----------------------------------------------------------------------------
1779 Called when <Cancel> button is clicked, remove preview and closes dialog
1781 void VisuGUI_ScalarBarBaseDlg::reject()
1783 VisuGUI_Prs3dDlg::reject();
1786 //----------------------------------------------------------------------------
1787 VisuGUI_ScalarBarPane* VisuGUI_ScalarBarBaseDlg::GetScalarPane()
1789 return myScalarPane;
1793 //----------------------------------------------------------------------------