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_ScalarMapPL.hxx"
40 #include "VISU_ScalarBarActor.hxx"
41 #include "VISU_ScalarMapAct.h"
42 #include "VISU_ScalarMap_i.hh"
43 #include "VISU_Result_i.hh"
44 #include "VISU_Prs3dUtils.hh"
46 #include "LightApp_Application.h"
48 #include "SUIT_Session.h"
49 #include "SUIT_MessageBox.h"
50 #include "SUIT_ResourceMgr.h"
51 #include "SUIT_Desktop.h"
55 #include <QRadioButton>
56 #include <QButtonGroup>
59 #include <QPushButton>
61 #include <QToolButton>
64 #include <QColorDialog>
67 #include <QGridLayout>
69 #include "QtxDoubleSpinBox.h"
71 #include <vtkTextProperty.h>
77 //-----------------------------------------------------------------------
78 // Text Preferences Dialog
79 //-----------------------------------------------------------------------
83 VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent)
84 : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
87 setWindowTitle(tr("TIT_TEXT_PREF"));
88 setSizeGripEnabled(TRUE);
90 QVBoxLayout* aMainLay = new QVBoxLayout(this);
91 aMainLay->setSpacing(6);
92 aMainLay->setMargin(11);
95 QGroupBox* aTitleGrp = new QGroupBox ( tr("LBL_TITLE"), this);
96 QVBoxLayout* aVBLay = new QVBoxLayout( aTitleGrp );
99 myTitleEdt = new QLineEdit (aTitleGrp);
100 aVBLay->addWidget( myTitleEdt);
103 QWidget* aHBox = new QWidget (aTitleGrp);
104 aVBLay->addWidget( aHBox );
106 QHBoxLayout* aHBLay = new QHBoxLayout( aHBox );
107 aHBLay->setSpacing(5);
109 myTitleFont = new SVTK_FontWidget (aHBox);
110 aHBLay->addWidget( myTitleFont );
112 aMainLay->addWidget(aTitleGrp);
115 QGroupBox* aLabelsGrp = new QGroupBox (tr("LBL_LABELS"), this);
116 aVBLay = new QVBoxLayout( aLabelsGrp );
119 aHBox = new QWidget (aLabelsGrp);
120 aVBLay->addWidget( aHBox );
122 aHBLay = new QHBoxLayout( aHBox );
123 aHBLay->setSpacing(5);
125 myLabelFont = new SVTK_FontWidget (aHBox);
126 aHBLay->addWidget( myLabelFont );
128 aMainLay->addWidget(aLabelsGrp);
130 // Common buttons ===========================================================
131 QGroupBox* GroupButtons = new QGroupBox( this );
132 //GroupButtons->setColumnLayout(0, Qt::Vertical );
133 //GroupButtons->layout()->setSpacing( 0 );
134 //GroupButtons->layout()->setMargin( 0 );
135 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons );
136 GroupButtonsLayout->setAlignment( Qt::AlignTop );
137 GroupButtonsLayout->setSpacing( 6 );
138 GroupButtonsLayout->setMargin( 11 );
140 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons );
141 buttonOk->setAutoDefault( TRUE );
142 buttonOk->setDefault( TRUE );
143 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
144 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
146 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons );
147 buttonCancel->setAutoDefault( TRUE );
148 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
150 QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons );
151 buttonHelp->setAutoDefault( TRUE );
152 GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
154 aMainLay->addWidget( GroupButtons );
156 connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
157 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
158 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp()));
162 //----------------------------------------------------------------------------
163 QString VisuGUI_TextPrefDlg::getTitleText()
165 return myTitleEdt->text();
169 //----------------------------------------------------------------------------
170 void VisuGUI_TextPrefDlg::setTitleText( const QString& theText )
172 myTitleEdt->setText(theText);
176 //----------------------------------------------------------------------------
177 void VisuGUI_TextPrefDlg::setTitleVisible(bool isVisible)
186 //----------------------------------------------------------------------------
187 void VisuGUI_TextPrefDlg::onHelp()
189 QString aHelpFileName = "scalar_map_page.html";
190 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
192 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
193 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
196 SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
197 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
198 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
199 QObject::tr("BUT_OK"));
204 //----------------------------------------------------------------------------
205 void VisuGUI_TextPrefDlg::storeBeginValues()
207 myTitle = myTitleEdt->text();
208 myTitleFont->GetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
209 myLabelFont->GetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
213 //----------------------------------------------------------------------------
215 Called when <Cancel> button is clicked, restore begin values
217 void VisuGUI_TextPrefDlg::reject()
219 myTitleEdt->setText(myTitle);
220 myTitleFont->SetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
221 myLabelFont->SetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
227 //----------------------------------------------------------------------------
229 Called when <Ok> button is clicked, store begin values
231 void VisuGUI_TextPrefDlg::accept()
239 //----------------------------------------------------------------------------
241 Provides help on F1 button click
243 void VisuGUI_TextPrefDlg::keyPressEvent( QKeyEvent* e )
245 QDialog::keyPressEvent( e );
246 if ( e->isAccepted() )
249 if ( e->key() == Qt::Key_F1 )
256 //-----------------------------------------------------------------------
257 // Scalar Bar Preferences Dialog
258 //-----------------------------------------------------------------------
262 VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent )
267 setWindowTitle( tr( "TIT_BAR_PREF" ) );
268 setSizeGripEnabled( true );
270 QString propertyName = QString( "scalar_bar_vertical_" );
272 myTitleSize = myLabelSize = myBarWidth = myBarHeight = 0;
276 QVBoxLayout* aMainLay = new QVBoxLayout( this );
277 aMainLay->setSpacing( 5 );
278 aMainLay->setMargin( 5 );
282 QGroupBox* aDimGrp = new QGroupBox( this );
283 QGridLayout* aDimGrpLay = new QGridLayout( aDimGrp );
284 aDimGrpLay->setSpacing( 5 );
285 aDimGrpLay->setMargin( 5 );
287 myTitleSizeSpin = new QSpinBox( aDimGrp );
288 myTitleSizeSpin->setRange( 0, 100 );
289 myTitleSizeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
290 myTitleSizeSpin->setMinimumWidth( 70 );
291 myTitleSizeSpin->setValue( 0 );
292 myTitleSizeSpin->setSpecialValueText( tr( "AUTO" ) );
293 QLabel* aTitleSizeLbl = new QLabel( tr( "LBL_TITLE_W" ), aDimGrp );
295 myLabelSizeSpin = new QSpinBox( aDimGrp );
296 myLabelSizeSpin->setRange( 0, 100 );
297 myLabelSizeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
298 myLabelSizeSpin->setMinimumWidth( 70 );
299 myLabelSizeSpin->setValue( 0 );
300 myLabelSizeSpin->setSpecialValueText( tr( "AUTO" ) );
301 QLabel* aLabelSizeLbl = new QLabel( tr( "LBL_LABEL_W" ), aDimGrp );
303 myBarWidthSpin = new QSpinBox( aDimGrp );
304 myBarWidthSpin->setRange( 0, 100 );
305 myBarWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
306 myBarWidthSpin->setMinimumWidth( 70 );
307 myBarWidthSpin->setValue( 0 );
308 myBarWidthSpin->setSpecialValueText( tr( "AUTO" ) );
309 QLabel* aBarWidthLbl = new QLabel( tr( "LBL_BAR_W" ), aDimGrp );
311 myBarHeightSpin = new QSpinBox( aDimGrp );
312 myBarHeightSpin->setRange( 0, 100 );
313 myBarHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
314 myBarHeightSpin->setMinimumWidth( 70 );
315 myBarHeightSpin->setValue( 0 );
316 myBarHeightSpin->setSpecialValueText( tr( "AUTO" ) );
317 QLabel* aBarHeightLbl = new QLabel( tr( "LBL_BAR_H" ), aDimGrp );
321 QLabel* aPrecLbl = new QLabel( tr( "PRECISION" ), aDimGrp );
322 myPrecisionSpin = new QSpinBox( aDimGrp );
323 myPrecisionSpin->setRange( 1, 100 );
325 myUnitsChk = new QCheckBox( tr( "LBL_SHOW_UNITS" ), aDimGrp );
329 aDimGrpLay->addWidget( aTitleSizeLbl, 0, 0 );
330 aDimGrpLay->addWidget( myTitleSizeSpin, 0, 1 );
331 aDimGrpLay->addWidget( aLabelSizeLbl, 0, 2 );
332 aDimGrpLay->addWidget( myLabelSizeSpin, 0, 3 );
333 aDimGrpLay->addWidget( aBarWidthLbl, 1, 0 );
334 aDimGrpLay->addWidget( myBarWidthSpin, 1, 1 );
335 aDimGrpLay->addWidget( aBarHeightLbl, 1, 2 );
336 aDimGrpLay->addWidget( myBarHeightSpin, 1, 3 );
337 aDimGrpLay->addWidget( aPrecLbl, 2, 0 );
338 aDimGrpLay->addWidget( myPrecisionSpin, 2, 1 );
339 aDimGrpLay->addWidget( myUnitsChk, 2, 2, 1, 2 );
341 aMainLay->addWidget( aDimGrp );
343 // Common buttons ===========================================================
345 QGroupBox* GroupButtons = new QGroupBox( this );
346 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
347 GroupButtonsLayout->setAlignment( Qt::AlignTop );
348 GroupButtonsLayout->setSpacing( 6 );
349 GroupButtonsLayout->setMargin( 11 );
351 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons );
352 buttonOk->setAutoDefault( true );
353 buttonOk->setDefault( true );
355 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons );
356 buttonCancel->setAutoDefault( true );
358 QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons );
359 buttonHelp->setAutoDefault( true );
361 GroupButtonsLayout->addWidget( buttonOk );
362 GroupButtonsLayout->addSpacing( 5 );
363 GroupButtonsLayout->addStretch();
364 GroupButtonsLayout->addWidget( buttonCancel );
365 GroupButtonsLayout->addWidget( buttonHelp );
367 aMainLay->addWidget( GroupButtons );
369 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
370 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
371 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
372 connect( myTitleSizeSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
373 connect( myLabelSizeSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
374 connect( myBarWidthSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
375 connect( myBarHeightSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
376 connect( myUnitsChk, SIGNAL( toggled( bool ) ), this, SIGNAL( updatePreview() ) );
377 connect( myPrecisionSpin, SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
381 //----------------------------------------------------------------------------
382 void VisuGUI_BarPrefDlg::setRatios( int titleRatioSize, int labelRatioWidth,
383 int barRatioWidth, int barRatioHeight )
385 myTitleSizeSpin->setValue( myTitleSize = titleRatioSize );
386 myLabelSizeSpin->setValue( myLabelSize = labelRatioWidth );
387 myBarWidthSpin->setValue( myBarWidth = barRatioWidth );
388 myBarHeightSpin->setValue( myBarHeight = barRatioHeight );
392 //----------------------------------------------------------------------------
393 void VisuGUI_BarPrefDlg::getRatios( int& titleRatioSize, int& labelRatioWidth,
394 int& barRatioWidth, int& barRatioHeight )
396 titleRatioSize = myTitleSizeSpin->value();
397 labelRatioWidth = myLabelSizeSpin->value();
398 barRatioWidth = myBarWidthSpin->value();
399 barRatioHeight = myBarHeightSpin->value();
403 //----------------------------------------------------------------------------
404 void VisuGUI_BarPrefDlg::setLabelsPrecision( const int p )
406 myPrecisionSpin->setValue( p );
409 //----------------------------------------------------------------------------
410 int VisuGUI_BarPrefDlg::getLabelsPrecision() const
412 return myPrecisionSpin->value();
415 //----------------------------------------------------------------------------
416 void VisuGUI_BarPrefDlg::setOrientation( const int ori )
421 //----------------------------------------------------------------------------
423 int VisuGUI_BarPrefDlg::getOrientation() const
425 return myOrientation;
428 //----------------------------------------------------------------------------
429 void VisuGUI_BarPrefDlg::onHelp()
431 QString aHelpFileName = "scalar_map_page.html";
432 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
434 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
435 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
438 SUIT_MessageBox::warning( this, tr( "WRN_WARNING" ),
439 tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
440 arg( app->resourceMgr()->stringValue( "ExternalBrowser",
442 arg( aHelpFileName ) );
447 //----------------------------------------------------------------------------
448 void VisuGUI_BarPrefDlg::setUnitsVisible(bool isVisible)
450 myUnitsChk->setChecked( myUnits = isVisible );
454 //----------------------------------------------------------------------------
455 bool VisuGUI_BarPrefDlg::isUnitsVisible()
457 return myUnitsChk->isChecked();
461 //----------------------------------------------------------------------------
463 Called when <Cancel> button is clicked, restore begin values
465 void VisuGUI_BarPrefDlg::reject()
467 myTitleSizeSpin->setValue( myTitleSize );
468 myLabelSizeSpin->setValue( myLabelSize );
469 myBarWidthSpin->setValue( myBarWidth );
470 myBarHeightSpin->setValue( myBarHeight );
471 myUnitsChk->setChecked( myUnits );
472 myPrecisionSpin->setValue( myPrecision );
477 //----------------------------------------------------------------------------
479 Called when <Ok> button is clicked, store begin values
481 void VisuGUI_BarPrefDlg::accept()
484 int aBWH = myOrientation == 1 ? myBarWidthSpin->value() : myBarHeightSpin->value();
485 if( ( myLabelSizeSpin->value()+ aBWH ) > 100 )
487 SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE" ) );
491 if ( myTitleSizeSpin->value() > 100 )
493 SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE_TLT" ) );
497 myTitleSize = myTitleSizeSpin->value();
498 myLabelSize = myLabelSizeSpin->value();
499 myBarWidth = myBarWidthSpin->value();
500 myBarHeight = myBarHeightSpin->value();
501 myUnits = myUnitsChk->isChecked();
502 myPrecision = myPrecisionSpin->value();
507 //----------------------------------------------------------------------------
509 Provides help on F1 button click
511 void VisuGUI_BarPrefDlg::keyPressEvent( QKeyEvent* e )
513 QDialog::keyPressEvent( e );
514 if ( e->isAccepted() )
517 if ( e->key() == Qt::Key_F1 ) {
524 //-----------------------------------------------------------------------
526 //-----------------------------------------------------------------------
531 VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview )
537 QVBoxLayout* aMainLayout = new QVBoxLayout( this );
538 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
539 QString propertyName;
540 propertyName = QString("scalar_bar_vertical_");
541 myVerX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
542 myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
543 myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
544 myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
545 myVerTS = aResourceMgr->integerValue("VISU", propertyName + "title_size", 0);
546 myVerLS = aResourceMgr->integerValue("VISU", propertyName + "label_size", 0);
547 myVerBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0);
548 myVerBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0);
550 propertyName = QString("scalar_bar_horizontal_");
551 myHorX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
552 myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
553 myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
554 myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
555 myHorTS = aResourceMgr->integerValue("VISU", propertyName + "title_size", 0);
556 myHorLS = aResourceMgr->integerValue("VISU", propertyName + "label_size", 0);
557 myHorBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0);
558 myHorBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0);
560 //aMainLayout->setSpacing(6);
562 // Range ============================================================
563 RangeGroup = new QButtonGroup ( this );
564 QGroupBox* aGB = new QGroupBox( tr("SCALAR_RANGE_GRP"),this );
565 aMainLayout->addWidget( aGB );
566 QGridLayout* RangeGroupLayout = new QGridLayout( aGB );
567 RangeGroupLayout->setAlignment( Qt::AlignTop );
568 //RangeGroupLayout->setSpacing( 6 );
569 //RangeGroupLayout->setMargin( 11 );
571 myModeLbl = new QLabel("Scalar Mode", aGB);
573 myModeCombo = new QComboBox(aGB);
575 CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), aGB);
576 CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
578 RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), aGB);
579 RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), aGB);
580 RangeGroup->addButton( RBFrange, 0 );
581 RangeGroup->addButton( RBIrange, 1 );
582 RBFrange->setChecked( true );
584 MinEdit = new QLineEdit( aGB );
585 MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
586 //MinEdit->setMinimumWidth( 70 );
587 MinEdit->setValidator( new QDoubleValidator(this) );
588 MinEdit->setText( "0.0" );
589 QLabel* MinLabel = new QLabel (tr("LBL_MIN"), aGB);
590 MinLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
591 MinLabel->setBuddy(MinEdit);
593 MaxEdit = new QLineEdit( aGB );
594 MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
595 //MaxEdit->setMinimumWidth( 70 );
596 MaxEdit->setValidator( new QDoubleValidator(this) );
597 MaxEdit->setText( "0.0" );
598 QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), aGB);
599 MaxLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
600 MaxLabel->setBuddy(MaxEdit);
602 RangeGroupLayout->addWidget( myModeLbl, 0, 0, 1, 1 );
603 RangeGroupLayout->addWidget( myModeCombo, 0, 1, 1, 2);
604 RangeGroupLayout->addWidget( CBLog, 0, 3, 1, 1);
605 RangeGroupLayout->addWidget( RBFrange, 1, 0, 1, 2);
606 RangeGroupLayout->addWidget( RBIrange, 1, 2, 1, 2);
607 RangeGroupLayout->addWidget( MinLabel, 2, 0 );
608 RangeGroupLayout->addWidget( MinEdit, 2, 1 );
609 RangeGroupLayout->addWidget( MaxLabel, 2, 2 );
610 RangeGroupLayout->addWidget( MaxEdit, 2, 3 );
612 // Colors and Labels ========================================================
613 QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this);
614 aMainLayout->addWidget( ColLabGroup );
615 QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup );
616 ColLabGroupLayout->setAlignment( Qt::AlignTop );
617 //ColLabGroupLayout->setSpacing( 6 );
618 //ColLabGroupLayout->setMargin( 11 );
620 QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup);
621 ColorSpin = new QSpinBox( ColLabGroup );
622 ColorSpin->setMinimum( 2 );
623 ColorSpin->setMaximum( 256 );
624 ColorSpin->setSingleStep( 1 );
625 ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
626 //ColorSpin->setMinimumWidth( 70 );
627 ColorSpin->setValue( 64 );
629 QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup);
630 LabelSpin = new QSpinBox( ColLabGroup );
631 LabelSpin->setMinimum( 2 );
632 LabelSpin->setMaximum( 65 );
633 LabelSpin->setSingleStep( 1 );
635 LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
636 //LabelSpin->setMinimumWidth( 70 );
637 LabelSpin->setValue( 5 );
639 ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
640 ColLabGroupLayout->addWidget( ColorSpin, 0, 1);
641 ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
642 ColLabGroupLayout->addWidget( LabelSpin, 0, 3);
644 // Orientation ==========================================================
645 QButtonGroup* OrientGroup = new QButtonGroup ( this );
646 QGroupBox* OrientGB = new QGroupBox( tr("ORIENTATION_GRP"),this );
647 aMainLayout->addWidget( OrientGB );
648 QGridLayout* OrientGroupLayout = new QGridLayout( OrientGB );
649 OrientGroupLayout->setAlignment( Qt::AlignTop );
650 //OrientGroupLayout->setSpacing( 6 );
651 //OrientGroupLayout->setMargin( 11 );
653 RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGB);
654 RBvert->setChecked( true );
655 RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGB);
656 OrientGroup->addButton( RBvert );
657 OrientGroup->addButton( RBhori );
658 OrientGroupLayout->addWidget( RBvert, 0, 0 );
659 OrientGroupLayout->addWidget( RBhori, 0, 1 );
661 // Origin ===============================================================
662 QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this);
663 aMainLayout->addWidget( OriginGroup );
664 QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup );
665 OriginGroupLayout->setAlignment( Qt::AlignTop );
666 //OriginGroupLayout->setSpacing( 6 );
667 //OriginGroupLayout->setMargin( 11 );
669 QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup);
670 XSpin = new QtxDoubleSpinBox( OriginGroup );
671 VISU::initSpinBox(XSpin, 0.0, +1.0);
672 XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
673 //XSpin->setMinimumWidth( 70 );
674 XSpin->setValue( 0.01 );
676 QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup);
677 YSpin = new QtxDoubleSpinBox( OriginGroup );
678 VISU::initSpinBox(YSpin, 0.0, +1.0);
679 YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
680 //YSpin->setMinimumWidth( 70 );
681 YSpin->setValue( 0.1 );
683 OriginGroupLayout->addWidget( XLabel, 0, 0);
684 OriginGroupLayout->addWidget( XSpin, 0, 1);
685 OriginGroupLayout->addWidget( YLabel, 0, 2);
686 OriginGroupLayout->addWidget( YSpin, 0, 3);
688 // Dimensions =========================================================
689 QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this );
690 aMainLayout->addWidget( DimGroup );
691 QGridLayout* DimGroupLayout = new QGridLayout( DimGroup );
692 DimGroupLayout->setAlignment( Qt::AlignTop );
693 //DimGroupLayout->setSpacing( 6 );
694 //DimGroupLayout->setMargin( 11 );
696 QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup);
697 WidthSpin = new QtxDoubleSpinBox( DimGroup );
698 VISU::initSpinBox(WidthSpin, 0.0, +1.0);
699 WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
700 //WidthSpin->setMinimumWidth( 70 );
701 WidthSpin->setValue( 0.1 );
703 QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup);
704 HeightSpin = new QtxDoubleSpinBox( DimGroup );
705 VISU::initSpinBox(HeightSpin, 0.0, +1.0);
706 HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
707 //HeightSpin->setMinimumWidth( 70 );
708 HeightSpin->setValue( 0.8 );
710 DimGroupLayout->addWidget( WidthLabel, 0, 0);
711 DimGroupLayout->addWidget( WidthSpin, 0, 1);
712 DimGroupLayout->addWidget( HeightLabel, 0, 2);
713 DimGroupLayout->addWidget( HeightSpin, 0, 3);
715 // Save check box ===========================================================
716 QWidget* aSaveBox = new QWidget(this);
717 aMainLayout->addWidget( aSaveBox );
718 QHBoxLayout* aVBLay = new QHBoxLayout( aSaveBox );
719 aVBLay->addWidget( myTextBtn = new QPushButton("Text properties...", aSaveBox) );
720 aVBLay->addWidget( myBarBtn = new QPushButton("Bar properties...", aSaveBox) );
722 aMainLayout->addWidget( myTextDlg = new VisuGUI_TextPrefDlg(this) );
723 myTextDlg->setTitleVisible(!thePreview);
724 myBarDlg = new VisuGUI_BarPrefDlg(this);
726 QGroupBox* CheckGroup = new QGroupBox("", this );
727 aMainLayout->addWidget( CheckGroup );
728 //QHBoxLayout* CheckGroupLayout = new QHBoxLayout( CheckGroup );
729 QGridLayout* CheckGroupLayout = new QGridLayout( CheckGroup );
731 myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), CheckGroup);
732 myPreviewCheck->setChecked(false);
733 CheckGroupLayout->addWidget(myPreviewCheck, 0, 0);
735 myHideBar = new QCheckBox(tr("HIDE_SCALAR_BAR"), CheckGroup);
736 myHideBar->setChecked(false);
737 CheckGroupLayout->addWidget(myHideBar, 0, 1);
740 CBDistr = new QCheckBox (tr("SHOW_DISTRIBUTION"), CheckGroup);
741 CheckGroupLayout->addWidget(CBDistr, 1, 0);
744 CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), CheckGroup);
745 CheckGroupLayout->addWidget( CBSave, 1, 1 );
749 myPreviewCheck->hide();
753 if(RBvert->isChecked()) {
754 myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH);
756 myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH);
759 int lp = aResourceMgr->integerValue( "VISU", propertyName + "scalar_bar_label_precision", 3 );
760 myBarDlg->setLabelsPrecision( lp );
762 myBarDlg->setUnitsVisible(aResourceMgr->booleanValue("VISU", propertyName + "display_units", true));
764 // signals and slots connections ===========================================
765 connect( RBFrange, SIGNAL( toggled( bool ) ), this, SLOT( onFieldRange( bool ) ) );
766 connect( RBIrange, SIGNAL( toggled( bool ) ), this, SLOT( onImposedRange( bool ) ) );
768 connect( myModeCombo, SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( int ) ) );
769 connect( OrientGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( changeDefaults( int ) ) );
770 connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
771 connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
772 connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
773 connect( myBarBtn, SIGNAL( clicked() ), this, SLOT( onBarPref() ) );
774 connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) );
776 connect( CBDistr, SIGNAL( toggled( bool ) ), this, SLOT( onShowDistribution( bool ) )); // RKV
778 connect( ColorSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
779 connect( LabelSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
780 connect( WidthSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
781 connect( HeightSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
782 connect( CBLog, SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() ));
783 connect( myBarDlg, SIGNAL( updatePreview() ), this, SLOT( updatePreview() ));
785 myIsStoreTextProp = false;
790 * Stores dialog values to resources
792 void VisuGUI_ScalarBarPane::storeToResources() {
793 int orient = (RBvert->isChecked())? 0 : 1;
794 float sbX1 = XSpin->value();
795 float sbY1 = YSpin->value();
796 float sbW = WidthSpin->value();
797 float sbH = HeightSpin->value();
798 int sbCol = ColorSpin->value();
799 int sbLab = LabelSpin->value();
801 if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
815 bool sbRange = RBIrange->isChecked();
816 float sbVmin = (float)(MinEdit->text().toDouble());
817 float sbVmax = (float)(MaxEdit->text().toDouble());
819 if(sbVmin > sbVmax) {
824 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
826 aResourceMgr->setValue("VISU", "scalar_bar_orientation", orient);
828 QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
830 aResourceMgr->setValue("VISU", propertyName + "x", sbX1);
831 aResourceMgr->setValue("VISU", propertyName + "y", sbY1);
832 aResourceMgr->setValue("VISU", propertyName + "width", sbW);
833 aResourceMgr->setValue("VISU", propertyName + "height", sbH);
835 aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol);
836 aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab);
840 aResourceMgr->setValue("VISU", "scalar_range_type", 1);
841 aResourceMgr->setValue("VISU", "scalar_range_min" ,sbVmin);
842 aResourceMgr->setValue("VISU", "scalar_range_max" ,sbVmax);
845 aResourceMgr->setValue("VISU", "scalar_range_type", 0);
847 aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic());
848 aResourceMgr->setValue("VISU", "scalar_bar_show_distribution", isShowDistribution()); // RKV
852 if (myIsStoreTextProp) {
854 QColor aTitleColor (255, 255, 255);
855 int aTitleFontFamily = VTK_ARIAL;
856 bool isTitleBold = false;
857 bool isTitleItalic = false;
858 bool isTitleShadow = false;
860 myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily,
861 isTitleBold, isTitleItalic, isTitleShadow);
865 aTitleFont.setBold(isTitleBold);
866 aTitleFont.setItalic(isTitleItalic);
867 aTitleFont.setOverline(isTitleShadow);
869 QString titleFontFamily;
870 switch (aTitleFontFamily) {
872 titleFontFamily = "Arial";
875 titleFontFamily = "Courier";
878 titleFontFamily = "Times";
881 aTitleFont.setFamily(titleFontFamily);
883 aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont);
885 aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor);
888 QColor aLabelColor (255, 255, 255);
889 int aLabelFontFamily = VTK_ARIAL;
890 bool isLabelBold = false;
891 bool isLabelItalic = false;
892 bool isLabelShadow = false;
894 myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
895 isLabelBold, isLabelItalic, isLabelShadow);
900 aLabelFont.setBold(isLabelBold);
901 aLabelFont.setItalic(isLabelItalic);
902 aLabelFont.setOverline(isLabelShadow);
904 QString labelFontFamily;
905 switch (aLabelFontFamily) {
907 labelFontFamily = "Arial";
910 labelFontFamily = "Courier";
913 labelFontFamily = "Times";
917 aLabelFont.setFamily(labelFontFamily);
919 aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont);
921 aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor);
925 //----------------------------------------------------------------------------
926 VisuGUI_ScalarBarPane::~VisuGUI_ScalarBarPane()
929 if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
930 aViewWindow->Repaint();
933 //----------------------------------------------------------------------------
935 * Initialise dialog box from presentation object
937 void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs)
939 myScalarMap = dynamic_cast<VISU::ScalarMap_i*>(thePrs);
944 switch(myScalarMap->GetScaling()){
945 case VISU::LOGARITHMIC :
946 setLogarithmic(true);
949 setLogarithmic(false);
952 // Update myModeCombo
953 const VISU::PField& aField = myScalarMap->GetScalarField();
954 const VISU::TNames& aCompNames = aField->myCompNames;
955 const VISU::TNames& aUnitNames = aField->myUnitNames;
956 int aNbComp = aField->myNbComp;
957 bool isScalarMode = (aNbComp > 1);
958 myModeCombo->clear();
959 myModeCombo->addItem("<Modulus>");
960 for(int i = 0; i < aNbComp; i++){
961 QString aComponent = QString(aCompNames[i].c_str()).simplified();
962 if(aComponent.isNull() || aComponent == "")
963 aComponent = "Component " + QString::number(i+1);
965 aComponent = "[" + QString::number(i+1) + "] " + aComponent;
967 QString anUnit = QString(aUnitNames[i].c_str()).simplified();
968 if(anUnit.isNull() || anUnit == "")
971 aComponent = aComponent + ", " + anUnit;
973 myModeCombo->addItem(aComponent);
976 myModeCombo->setCurrentIndex(myScalarMap->GetScalarMode());
978 myModeCombo->setCurrentIndex(1);
980 myModeLbl->setEnabled(isScalarMode);
981 myModeCombo->setEnabled(isScalarMode);
983 setRange( myScalarMap->GetMin(), myScalarMap->GetMax(), myScalarMap->IsRangeFixed() );
985 setScalarBarData( myScalarMap->GetNbColors(), myScalarMap->GetLabels() );
986 setShowDistribution( myScalarMap->GetIsDistributionVisible() );
989 CORBA::String_var aTitle = myScalarMap->GetTitle();
990 myTextDlg->setTitleText(aTitle.in());
991 myTitle = aTitle.in();
993 setPosAndSize( myScalarMap->GetPosX(),
994 myScalarMap->GetPosY(),
995 myScalarMap->GetWidth(),
996 myScalarMap->GetHeight(),
997 myScalarMap->GetBarOrientation());
999 if(RBvert->isChecked()) {
1000 myVerTS = myScalarMap->GetTitleSize();
1001 myVerLS = myScalarMap->GetLabelSize();
1002 myVerBW = myScalarMap->GetBarWidth();
1003 myVerBH = myScalarMap->GetBarHeight();
1004 myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1006 myHorTS = myScalarMap->GetTitleSize();
1007 myHorLS = myScalarMap->GetLabelSize();
1008 myHorBW = myScalarMap->GetBarWidth();
1009 myHorBH = myScalarMap->GetBarHeight();
1010 myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1013 myBarDlg->setLabelsPrecision( VISU::ToPrecision( myScalarMap->GetLabelsFormat() ) );
1014 myBarDlg->setUnitsVisible(myScalarMap->IsUnitsVisible());
1016 vtkFloatingPointType R, G, B;
1017 myScalarMap->GetTitleColor(R, G, B);
1019 QColor aTextColor = QColor((int)(R*255.), (int)(G*255.), (int)(B*255.));
1021 myTextDlg->myTitleFont->SetData(aTextColor,
1022 myScalarMap->GetTitFontType(),
1023 myScalarMap->IsBoldTitle(),
1024 myScalarMap->IsItalicTitle(),
1025 myScalarMap->IsShadowTitle());
1028 myScalarMap->GetLabelColor(R, G, B);
1030 QColor aLabelColor = QColor((int)(R*255.), (int)(G*255.), (int)(B*255.));
1032 myTextDlg->myLabelFont->SetData(aLabelColor,
1033 myScalarMap->GetLblFontType(),
1034 myScalarMap->IsBoldLabel(),
1035 myScalarMap->IsItalicLabel(),
1036 myScalarMap->IsShadowLabel());
1038 myHideBar->setChecked(!myScalarMap->IsBarVisible());
1041 if (myPreviewCheck->isChecked()) {
1049 //----------------------------------------------------------------------------
1050 /*! Slot update preview of scalar bar, if preview is checked
1052 void VisuGUI_ScalarBarPane::updatePreview()
1054 if (myPreviewCheck->isChecked()) {
1055 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
1063 //----------------------------------------------------------------------------
1064 /*! Creating preview scalar bar
1066 void VisuGUI_ScalarBarPane::createScalarBar()
1068 if (VISU::GetActiveViewWindow<SVTK_ViewWindow>() == NULL) return;
1069 if (myPreviewActor != 0) return;
1070 if (myScalarMap == NULL) return;
1072 if (!check()) return;
1073 myScalarMapPL = VISU_ScalarMapPL::New();
1074 if(myScalarMap->GetSpecificPL())
1075 myScalarMapPL->ShallowCopy(myScalarMap->GetSpecificPL(), true);
1077 if ( myBusy ) return;
1082 sbCol = getNbColors();
1083 sbLab = getNbLabels();
1084 if(sbCol < 2) sbCol=2;
1085 if(sbCol > 64) sbCol=64;
1086 if(sbLab < 2) sbLab=2;
1087 if(sbLab > 65) sbLab=65;
1088 myPreviewActor = VISU_ScalarMapAct::New();
1089 VISU_ScalarBarActor* aScalarBarActor = myPreviewActor->GetScalarBar();
1090 myPreviewActor->GetScalarBar()->VisibilityOn();
1091 myPreviewActor->PickableOff();
1092 //myPreviewActor->SetBarVisibility(!myHideBar->isChecked());
1094 myScalarMapPL->SetScalarMode(myModeCombo->currentIndex());
1096 myScalarMapPL->SetScaling(VISU::LOGARITHMIC);
1098 myScalarMapPL->SetScaling(VISU::LINEAR);
1100 if ( RBFrange->isChecked() ) {
1101 myScalarMapPL->SetSourceRange();
1103 vtkFloatingPointType aRange[2];
1104 aRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble();
1105 aRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble();
1106 myScalarMapPL->SetScalarRange( aRange );
1109 myScalarMapPL->SetNbColors(sbCol);
1110 myScalarMapPL->Update();
1112 aScalarBarActor->SetLookupTable(myScalarMapPL->GetBarTable());
1113 aScalarBarActor->SetDistribution( myScalarMapPL->GetDistribution() );
1114 aScalarBarActor->SetDistributionVisibility( isShowDistribution() );
1116 if (!myTextDlg->getTitleText().isEmpty()) {
1117 VISU::PValForTime aValForTime;
1118 const VISU::PField& aField = myScalarMap->GetScalarField();
1119 const VISU::TValField& aValField = aField->myValField;
1120 VISU::TValField::const_iterator anIter = aValField.find(myScalarMap->GetScalarTimeStampNumber());
1121 if (anIter != aValField.end())
1122 aValForTime = anIter->second;
1125 std::strstream aStream;
1126 const VISU::TTime& aTime = aValForTime->myTime;
1127 aStream<< myTextDlg->getTitleText().toLatin1().data() <<" ";
1128 if(myBarDlg->isUnitsVisible())
1129 aStream<<VISU_Convertor::GenerateName(aTime)<<std::ends;
1132 aName.sprintf("%g", aTime.first);
1133 aStream << aName.toLatin1().data() << std::ends;
1135 std::string aScalarBarTitle = aStream.str();
1136 aScalarBarActor->SetTitle(aScalarBarTitle.c_str());
1138 aScalarBarActor->SetTitle(myTextDlg->getTitleText().toLatin1().data());
1142 aScalarBarActor->SetTitle(myTitle.c_str());
1143 aScalarBarActor->SetOrientation(getOrientation());
1144 aScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
1145 aScalarBarActor->GetPositionCoordinate()->SetValue(getX(),getY());
1146 aScalarBarActor->SetWidth(getWidth());
1147 aScalarBarActor->SetHeight(getHeight());
1148 aScalarBarActor->SetNumberOfLabels(sbLab);
1149 aScalarBarActor->SetMaximumNumberOfColors(sbCol);
1151 // title text property
1153 int aTitleFontFamily;
1157 myTextDlg->myTitleFont->GetData(aTitleColor,aTitleFontFamily,
1158 isTitleBold,isTitleItalic,isTitleShadow);
1159 vtkTextProperty* aTitleProp = aScalarBarActor->GetTitleTextProperty();
1160 aTitleProp->SetFontFamily(aTitleFontFamily);
1161 aTitleProp->SetColor(vtkFloatingPointType(aTitleColor.red())/255.,
1162 vtkFloatingPointType(aTitleColor.green())/255.,
1163 vtkFloatingPointType(aTitleColor.blue())/255.);
1164 (isTitleBold)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
1165 (isTitleItalic)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
1166 (isTitleShadow)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
1168 // label text property
1170 int aLabelFontFamily;
1174 myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
1175 isLabelBold, isLabelItalic, isLabelShadow);
1176 vtkTextProperty* aLabelProp = aScalarBarActor->GetLabelTextProperty();
1177 aLabelProp->SetFontFamily(aLabelFontFamily);
1178 aLabelProp->SetColor(vtkFloatingPointType(aLabelColor.red())/255.,
1179 vtkFloatingPointType(aLabelColor.green())/255.,
1180 vtkFloatingPointType(aLabelColor.blue())/255.);
1181 (isLabelBold)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
1182 (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
1183 (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
1185 int VerTS, VerTH, VerLS, VerBW, VerBH;
1186 myBarDlg->getRatios(VerTS, VerLS, VerBW, VerBH);
1187 aScalarBarActor->SetRatios(VerTS, VerLS, VerBW, VerBH);
1189 std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() );
1190 aScalarBarActor->SetLabelFormat( f.c_str() );
1192 aScalarBarActor->Modified();
1194 VISU::GetActiveViewWindow<SVTK_ViewWindow>()->AddActor(myPreviewActor);
1200 //----------------------------------------------------------------------------
1201 /*! Deleting preview scalar bar
1203 void VisuGUI_ScalarBarPane::deleteScalarBar()
1205 if ( myBusy ) return;
1207 if (myPreviewActor == 0) return;
1208 vtkRenderer* aRend = myPreviewActor->GetRenderer();
1209 vtkRenderWindow* aWnd = aRend->GetRenderWindow();
1211 myPreviewActor->RemoveFromRender(aRend);
1212 myPreviewActor->GetScalarBar()->VisibilityOff();
1213 myPreviewActor->Delete();
1217 myScalarMapPL->Delete();
1223 //----------------------------------------------------------------------------
1225 * Store values to presentation object
1227 int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) {
1231 myScalarMap->SetScalarMode(myModeCombo->currentIndex());
1232 myScalarMap->SetPosition(XSpin->value(), YSpin->value());
1233 myScalarMap->SetSize(WidthSpin->value(), HeightSpin->value());
1234 if(RBvert->isChecked()) {
1235 myScalarMap->SetRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1237 myScalarMap->SetRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1240 std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() );
1241 myScalarMap->SetLabelsFormat( f.c_str() );
1242 myScalarMap->SetUnitsVisible(myBarDlg->isUnitsVisible());
1244 myScalarMap->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3dBase::VERTICAL : VISU::ColoredPrs3dBase::HORIZONTAL);
1246 myScalarMap->SetScaling(VISU::LOGARITHMIC);
1248 myScalarMap->SetScaling(VISU::LINEAR);
1250 if ( RBFrange->isChecked() ) {
1251 myScalarMap->SetSourceRange();
1253 myScalarMap->SetRange( MinEdit->text().toDouble(), MaxEdit->text().toDouble() );
1255 myScalarMap->SetNbColors(ColorSpin->value());
1256 myScalarMap->SetLabels(LabelSpin->value());
1257 myScalarMap->SetIsDistributionVisible(isShowDistribution()); // RKV
1259 myScalarMap->SetBarVisible(!myHideBar->isChecked());
1261 if (isToSave()) storeToResources();
1263 if (myIsStoreTextProp) {
1265 myScalarMap->SetTitle(myTextDlg->getTitleText().toLatin1().data());
1267 QColor aTitColor (255, 255, 255);
1268 int aTitleFontFamily = VTK_ARIAL;
1269 bool isTitleBold = false;
1270 bool isTitleItalic = false;
1271 bool isTitleShadow = false;
1273 myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
1274 isTitleBold, isTitleItalic, isTitleShadow);
1276 myScalarMap->SetBoldTitle(isTitleBold);
1277 myScalarMap->SetItalicTitle(isTitleItalic);
1278 myScalarMap->SetShadowTitle(isTitleShadow);
1279 myScalarMap->SetTitFontType(aTitleFontFamily);
1280 myScalarMap->SetTitleColor(aTitColor.red()/255.,
1281 aTitColor.green()/255.,
1282 aTitColor.blue()/255.);
1285 QColor aLblColor (255, 255, 255);
1286 int aLabelFontFamily = VTK_ARIAL;
1287 bool isLabelBold = false;
1288 bool isLabelItalic = false;
1289 bool isLabelShadow = false;
1291 myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
1292 isLabelBold, isLabelItalic, isLabelShadow);
1294 myScalarMap->SetBoldLabel(isLabelBold);
1295 myScalarMap->SetItalicLabel(isLabelItalic);
1296 myScalarMap->SetShadowLabel(isLabelShadow);
1297 myScalarMap->SetLblFontType(aLabelFontFamily);
1298 myScalarMap->SetLabelColor(aLblColor.red()/255.,
1299 aLblColor.green()/255.,
1300 aLblColor.blue()/255.);
1301 myIsStoreTextProp = false;
1308 //----------------------------------------------------------------------------
1310 Called when orientation is changed
1312 void VisuGUI_ScalarBarPane::changeDefaults( int )
1314 if ( RBvert->isChecked() ) {
1315 XSpin->setValue( myVerX );
1316 YSpin->setValue( myVerY );
1317 WidthSpin->setValue( myVerW );
1318 HeightSpin->setValue( myVerH );
1321 XSpin->setValue( myHorX );
1322 YSpin->setValue( myHorY );
1323 WidthSpin->setValue( myHorW );
1324 HeightSpin->setValue( myHorH );
1330 //----------------------------------------------------------------------------
1332 Called when Range mode is changed
1334 void VisuGUI_ScalarBarPane::onFieldRange( bool isOn )
1337 myScalarMap->SetSourceRange();
1338 MinEdit->setEnabled( false );
1339 MaxEdit->setEnabled( false );
1340 changeScalarMode(myModeCombo->currentIndex());
1344 void VisuGUI_ScalarBarPane::onImposedRange( bool isOn )
1347 myScalarMap->SetRange( myScalarMap->GetSourceMin(), myScalarMap->GetSourceMax() );
1348 MinEdit->setEnabled( true );
1349 MaxEdit->setEnabled( true );
1350 changeScalarMode(myModeCombo->currentIndex());
1354 void VisuGUI_ScalarBarPane::onShowDistribution( bool isOn )
1356 myScalarMap->SetIsDistributionVisible(isOn);
1360 void VisuGUI_ScalarBarPane::changeRange( int )
1362 if ( RBFrange->isChecked() ) {
1363 myScalarMap->SetSourceRange();
1364 MinEdit->setEnabled( false );
1365 MaxEdit->setEnabled( false );
1367 myScalarMap->SetRange( myScalarMap->GetSourceMin(), myScalarMap->GetSourceMax() );
1368 MinEdit->setEnabled( true );
1369 MaxEdit->setEnabled( true );
1372 changeScalarMode(myModeCombo->currentIndex());
1376 //----------------------------------------------------------------------------
1378 Called when X,Y position is changed
1380 void VisuGUI_ScalarBarPane::XYChanged( double )
1382 QtxDoubleSpinBox* snd = (QtxDoubleSpinBox*)sender();
1383 if ( snd == XSpin ) {
1384 WidthSpin->setMaximum( 1.0 - XSpin->value() );
1386 if ( snd == YSpin ) {
1387 HeightSpin->setMaximum( 1.0 - YSpin->value() );
1393 //----------------------------------------------------------------------------
1395 Called when scalar mode is changed
1397 void VisuGUI_ScalarBarPane::changeScalarMode( int theMode )
1399 myScalarMap->SetScalarMode(theMode);
1401 if ( RBFrange->isChecked() ) {
1402 MinEdit->setText( QString::number( myScalarMap->GetSourceMin() ) );
1403 MaxEdit->setText( QString::number( myScalarMap->GetSourceMax() ) );
1410 //----------------------------------------------------------------------------
1412 Sets default values and range mode
1414 void VisuGUI_ScalarBarPane::setRange( double imin, double imax, bool sbRange )
1416 MinEdit->setText( QString::number( imin ) );
1417 MaxEdit->setText( QString::number( imax ) );
1419 RBIrange->setChecked( true );
1421 RBFrange->setChecked( true );
1423 changeRange( sbRange );
1427 //----------------------------------------------------------------------------
1429 Sets and gets parameters
1431 bool VisuGUI_ScalarBarPane::isIRange() {
1432 return RBIrange->isChecked();
1436 //----------------------------------------------------------------------------
1437 double VisuGUI_ScalarBarPane::getMin() {
1438 return MinEdit->text().toDouble();
1442 //----------------------------------------------------------------------------
1443 double VisuGUI_ScalarBarPane::getMax() {
1444 return MaxEdit->text().toDouble();
1448 //----------------------------------------------------------------------------
1449 double VisuGUI_ScalarBarPane::getX() {
1450 return XSpin->value();
1454 //----------------------------------------------------------------------------
1455 double VisuGUI_ScalarBarPane::getY() {
1456 return YSpin->value();
1460 //----------------------------------------------------------------------------
1461 double VisuGUI_ScalarBarPane::getWidth() {
1462 return WidthSpin->value();
1466 //----------------------------------------------------------------------------
1467 double VisuGUI_ScalarBarPane::getHeight() {
1468 return HeightSpin->value();
1472 //----------------------------------------------------------------------------
1473 int VisuGUI_ScalarBarPane::getNbColors() {
1474 return ColorSpin->value();
1478 //----------------------------------------------------------------------------
1479 int VisuGUI_ScalarBarPane::getNbLabels() {
1480 return LabelSpin->value();
1484 //----------------------------------------------------------------------------
1485 bool VisuGUI_ScalarBarPane::isLogarithmic() {
1486 return CBLog->isChecked();
1490 //----------------------------------------------------------------------------
1491 void VisuGUI_ScalarBarPane::setLogarithmic( bool on ) {
1492 CBLog->setChecked( on );
1495 //----------------------------------------------------------------------------
1496 bool VisuGUI_ScalarBarPane::isShowDistribution() {
1497 return CBDistr->isChecked();
1501 //----------------------------------------------------------------------------
1502 void VisuGUI_ScalarBarPane::setShowDistribution( bool on ) {
1503 CBDistr->setChecked( on );
1507 //----------------------------------------------------------------------------
1508 bool VisuGUI_ScalarBarPane::isToSave() {
1509 return CBSave ? CBSave->isChecked() : false;
1512 //----------------------------------------------------------------------------
1514 Sets size and position
1516 void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
1523 RBvert->setChecked( true );
1530 RBhori->setChecked( true );
1532 changeDefaults( 0 );
1536 //----------------------------------------------------------------------------
1538 Sets colors and labels number
1540 void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
1542 ColorSpin->setValue( colors );
1543 LabelSpin->setValue( labels );
1547 //----------------------------------------------------------------------------
1551 int VisuGUI_ScalarBarPane::getOrientation()
1553 if (RBvert->isChecked() )
1560 //----------------------------------------------------------------------------
1562 Called when <OK> button is clicked, validates data and closes dialog
1564 bool VisuGUI_ScalarBarPane::check()
1566 double minVal = MinEdit->text().toDouble();
1567 double maxVal = MaxEdit->text().toDouble();
1568 if ( RBIrange->isChecked() ) {
1569 if (minVal >= maxVal) {
1570 SUIT_MessageBox::warning( this,tr("WRN_VISU"),
1571 tr("MSG_MINMAX_VALUES"),
1577 // check if logarithmic mode is on and check imposed range to not contain negative values
1578 if ( CBLog->isChecked() ) {
1579 if ( minVal <= 0.0 || maxVal <= 0.0 ) {
1580 if ( RBIrange->isChecked() ) {
1581 SUIT_MessageBox::warning( this,
1583 tr("WRN_LOGARITHMIC_RANGE"),
1586 if ( minVal == 0 || maxVal == 0 )
1587 SUIT_MessageBox::warning( this,
1589 tr("WRN_LOGARITHMIC_RANGE"),
1592 SUIT_MessageBox::warning( this,
1594 tr("WRN_LOGARITHMIC_FIELD_RANGE"),
1596 RBIrange->setChecked(true);
1606 //----------------------------------------------------------------------------
1607 void VisuGUI_ScalarBarPane::onTextPref()
1609 myTextDlg->storeBeginValues();
1610 myIsStoreTextProp = myTextDlg->exec() || myIsStoreTextProp;
1615 //----------------------------------------------------------------------------
1616 void VisuGUI_ScalarBarPane::onBarPref()
1618 if(RBvert->isChecked())
1619 myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1621 myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1622 myBarDlg->setOrientation( getOrientation() );
1623 if(myBarDlg->exec()) {
1624 if(RBvert->isChecked())
1625 myBarDlg->getRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1627 myBarDlg->getRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1633 //----------------------------------------------------------------------------
1634 void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview)
1636 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
1646 VisuGUI_Prs3dDlg::VisuGUI_Prs3dDlg( SalomeApp_Module* theModule )
1647 : QDialog( VISU::GetDesktop( theModule ), Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
1651 //----------------------------------------------------------------------------
1653 Called when <Help> button is clicked, shows the corresponding help page in defined browser
1655 void VisuGUI_Prs3dDlg::onHelp()
1657 QString aHelpFileName = GetContextHelpFilePath();
1658 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1660 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
1661 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
1664 SUIT_MessageBox::warning( this, tr( "WRN_WARNING" ),
1665 tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1666 arg( app->resourceMgr()->stringValue( "ExternalBrowser",
1668 arg( aHelpFileName ) );
1673 //----------------------------------------------------------------------------
1674 void VisuGUI_Prs3dDlg::keyPressEvent( QKeyEvent* e )
1676 QDialog::keyPressEvent( e );
1677 if ( e->isAccepted() )
1680 if ( e->key() == Qt::Key_F1 ) {
1686 //----------------------------------------------------------------------------
1687 VisuGUI_ScalarBarBaseDlg::VisuGUI_ScalarBarBaseDlg( SalomeApp_Module* theModule, bool thePreview ) :
1688 VisuGUI_Prs3dDlg( theModule )
1690 myScalarPane = new VisuGUI_ScalarBarPane(this, thePreview);
1691 myScalarPane->layout()->setMargin( 5 );
1695 VisuGUI_ScalarBarBaseDlg::~VisuGUI_ScalarBarBaseDlg()
1700 //----------------------------------------------------------------------------
1701 void VisuGUI_ScalarBarBaseDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
1704 myScalarPane->initFromPrsObject( thePrs );
1708 //----------------------------------------------------------------------------
1710 Called when <OK> button is clicked, validates data and closes dialog
1712 void VisuGUI_ScalarBarBaseDlg::accept()
1714 if (GetScalarPane()->check())
1715 VisuGUI_Prs3dDlg::accept();
1719 //----------------------------------------------------------------------------
1721 Called when <Cancel> button is clicked, remove preview and closes dialog
1723 void VisuGUI_ScalarBarBaseDlg::reject()
1725 VisuGUI_Prs3dDlg::reject();
1728 //----------------------------------------------------------------------------
1729 VisuGUI_ScalarBarPane* VisuGUI_ScalarBarBaseDlg::GetScalarPane()
1731 return myScalarPane;
1735 //----------------------------------------------------------------------------