1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 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
24 // File : VisuGUI_Prs3dDlg.cxx
25 // Author : Laurent CORNABE & Hubert ROLLAND
28 #include "VisuGUI_Prs3dDlg.h"
31 #include "VisuGUI_Tools.h"
32 #include "VisuGUI_ViewTools.h"
33 #include "VisuGUI_InputPane.h"
35 #include "SVTK_ViewWindow.h"
36 #include "SVTK_FontWidget.h"
38 #include "VISUConfig.hh"
39 #include "VISU_Convertor.hxx"
40 #include "VISU_ScalarMapPL.hxx"
41 #include "VISU_ScalarBarActor.hxx"
42 #include "VISU_ScalarMapAct.h"
43 #include "VISU_ScalarMap_i.hh"
44 #include "VISU_Result_i.hh"
46 #include "LightApp_Application.h"
48 #include "SUIT_Session.h"
49 #include "SUIT_MessageBox.h"
50 #include "SUIT_ResourceMgr.h"
52 #include <qcheckbox.h>
53 #include <qlineedit.h>
54 #include <qradiobutton.h>
55 #include <qbuttongroup.h>
56 #include <qgroupbox.h>
58 #include <qpushbutton.h>
59 #include <qcombobox.h>
61 #include <qtoolbutton.h>
63 #include <qvalidator.h>
64 #include <qcolordialog.h>
65 #include <qtabwidget.h>
67 #include "QtxDblSpinBox.h"
69 #include <vtkTextProperty.h>
75 //-----------------------------------------------------------------------
76 // Text Preferences Dialog
77 //-----------------------------------------------------------------------
81 VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent)
82 : QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
84 setName("VisuGUI_TextPrefDlg");
85 setCaption(tr("TIT_TEXT_PREF"));
86 setSizeGripEnabled(TRUE);
88 QVBoxLayout* TopLayout = new QVBoxLayout(this);
89 TopLayout->setSpacing(6);
90 TopLayout->setMargin(11);
93 QGroupBox* aTitleGrp = new QGroupBox (2, Qt::Vertical, tr("LBL_TITLE"), this);
96 myTitleEdt = new QLineEdit (aTitleGrp);
99 QHBox* aHBox = new QHBox (aTitleGrp);
100 aHBox->setSpacing(5);
101 myTitleFont = new SVTK_FontWidget (aHBox);
103 TopLayout->addWidget(aTitleGrp);
106 QGroupBox* aLabelsGrp = new QGroupBox (1, Qt::Vertical, tr("LBL_LABELS"), this);
109 aHBox = new QHBox (aLabelsGrp);
110 aHBox->setSpacing(5);
111 myLabelFont = new SVTK_FontWidget (aHBox);
113 TopLayout->addWidget(aLabelsGrp);
115 // Common buttons ===========================================================
116 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
117 GroupButtons->setColumnLayout(0, Qt::Vertical );
118 GroupButtons->layout()->setSpacing( 0 );
119 GroupButtons->layout()->setMargin( 0 );
120 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
121 GroupButtonsLayout->setAlignment( Qt::AlignTop );
122 GroupButtonsLayout->setSpacing( 6 );
123 GroupButtonsLayout->setMargin( 11 );
125 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
126 buttonOk->setAutoDefault( TRUE );
127 buttonOk->setDefault( TRUE );
128 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
129 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
131 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
132 buttonCancel->setAutoDefault( TRUE );
133 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
135 QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" );
136 buttonHelp->setAutoDefault( TRUE );
137 GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
139 TopLayout->addWidget( GroupButtons );
141 connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
142 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
143 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp()));
147 //----------------------------------------------------------------------------
148 QString VisuGUI_TextPrefDlg::getTitleText()
150 return myTitleEdt->text();
154 //----------------------------------------------------------------------------
155 void VisuGUI_TextPrefDlg::setTitleText(QString theText)
157 myTitleEdt->setText(theText);
161 //----------------------------------------------------------------------------
162 void VisuGUI_TextPrefDlg::setTitleVisible(bool isVisible)
171 //----------------------------------------------------------------------------
172 void VisuGUI_TextPrefDlg::onHelp()
174 QString aHelpFileName = "scalar_map_page.html";
175 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
177 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
178 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
181 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
182 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
183 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
184 QObject::tr("BUT_OK"));
189 //----------------------------------------------------------------------------
190 void VisuGUI_TextPrefDlg::storeBeginValues()
192 myTitle = myTitleEdt->text();
193 myTitleFont->GetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
194 myLabelFont->GetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
198 //----------------------------------------------------------------------------
200 Called when <Cancel> button is clicked, restore begin values
202 void VisuGUI_TextPrefDlg::reject()
204 myTitleEdt->setText(myTitle);
205 myTitleFont->SetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
206 myLabelFont->SetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
212 //----------------------------------------------------------------------------
214 Called when <Ok> button is clicked, store begin values
216 void VisuGUI_TextPrefDlg::accept()
224 //----------------------------------------------------------------------------
226 Provides help on F1 button click
228 void VisuGUI_TextPrefDlg::keyPressEvent( QKeyEvent* e )
230 QDialog::keyPressEvent( e );
231 if ( e->isAccepted() )
234 if ( e->key() == Key_F1 )
241 //-----------------------------------------------------------------------
242 // Scalar Bar Preferences Dialog
243 //-----------------------------------------------------------------------
247 VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg (QWidget* parent)
248 : QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
250 setName("VisuGUI_BarPrefDlg");
251 setCaption(tr("TIT_BAR_PREF"));
252 setSizeGripEnabled(TRUE);
254 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
255 QString propertyName;
256 propertyName = QString("scalar_bar_vertical_");
258 myTitleWidth = myTitleHeight = myLabelWidth = myLabelHeight = myBarWidth = myBarHeight = 0;
260 myUnitsFormat = "%-#6.3g";
262 QVBoxLayout* TopLayout = new QVBoxLayout(this);
263 TopLayout->setSpacing(6);
264 TopLayout->setMargin(11);
266 QGroupBox* WidthHeightGroup = new QGroupBox (tr(""), this, "WidthHeightGroup");
267 WidthHeightGroup->setColumnLayout(0, Qt::Vertical );
268 WidthHeightGroup->layout()->setSpacing( 0 );
269 WidthHeightGroup->layout()->setMargin( 0 );
270 QGridLayout* WidthHeightGroupLayout = new QGridLayout( WidthHeightGroup->layout() );
271 WidthHeightGroupLayout->setAlignment( Qt::AlignTop );
272 WidthHeightGroupLayout->setSpacing( 6 );
273 WidthHeightGroupLayout->setMargin( 11 );
275 QLabel* LabelTitleWidth = new QLabel (tr("LBL_TITLE_W"), WidthHeightGroup, "LabelTitleWidth");
276 TitleWidthSpin = new QSpinBox( 0, 100, 1, WidthHeightGroup );
277 TitleWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
278 TitleWidthSpin->setMinimumWidth( 70 );
279 TitleWidthSpin->setValue( 0 );
280 TitleWidthSpin->setSpecialValueText( tr("AUTO") );
281 WidthHeightGroupLayout->addMultiCellWidget( LabelTitleWidth, 0, 0, 0, 0);
282 WidthHeightGroupLayout->addMultiCellWidget( TitleWidthSpin, 0, 0, 1, 1);
284 QLabel* LabelTitleHeight = new QLabel (tr("LBL_TITLE_H"), WidthHeightGroup, "LabelTitleHeight");
285 TitleHeightSpin = new QSpinBox( 0, 100, 1, WidthHeightGroup );
286 TitleHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
287 TitleHeightSpin->setMinimumWidth( 70 );
288 TitleHeightSpin->setValue( 0 );
289 TitleHeightSpin->setSpecialValueText( tr("AUTO") );
290 WidthHeightGroupLayout->addMultiCellWidget( LabelTitleHeight, 0, 0, 2, 2);
291 WidthHeightGroupLayout->addMultiCellWidget( TitleHeightSpin, 0, 0, 3, 3);
293 CBUnits = new QCheckBox (tr("LBL_SHOW_UNITS"), WidthHeightGroup);
294 CBUnits->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
295 WidthHeightGroupLayout->addMultiCellWidget( CBUnits, 0, 0, 4, 5);
297 QLabel* LabelLabelWidth = new QLabel (tr("LBL_LABEL_W"), WidthHeightGroup, "LabelLabelWidth");
298 LabelWidthSpin = new QSpinBox( 0, 100, 1, WidthHeightGroup );
299 LabelWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
300 LabelWidthSpin->setMinimumWidth( 70 );
301 LabelWidthSpin->setValue( 0 );
302 LabelWidthSpin->setSpecialValueText( tr("AUTO") );
303 WidthHeightGroupLayout->addMultiCellWidget( LabelLabelWidth, 1, 1, 0, 0);
304 WidthHeightGroupLayout->addMultiCellWidget( LabelWidthSpin, 1, 1, 1, 1);
306 QLabel* LabelLabelHeight = new QLabel (tr("LBL_LABEL_H"), WidthHeightGroup, "LabelLabelHeight");
307 LabelHeightSpin = new QSpinBox( 0, 100, 1, WidthHeightGroup );
308 LabelHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
309 LabelHeightSpin->setMinimumWidth( 70 );
310 LabelHeightSpin->setValue( 0 );
311 LabelHeightSpin->setSpecialValueText( tr("AUTO") );
312 WidthHeightGroupLayout->addMultiCellWidget( LabelLabelHeight, 1, 1, 2, 2);
313 WidthHeightGroupLayout->addMultiCellWidget( LabelHeightSpin, 1, 1, 3, 3);
315 UnitsEdit = new QLineEdit(WidthHeightGroup , "UnirsEdit" );
316 UnitsEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
317 UnitsEdit->setMinimumWidth( 35 );
318 UnitsEdit->setText( myUnitsFormat );
319 QLabel* UnitsLabel = new QLabel (tr("LBL_UNITS_FORMAT"), WidthHeightGroup, "UnitsLabel");
320 UnitsLabel->setBuddy(UnitsEdit);
321 WidthHeightGroupLayout->addMultiCellWidget( UnitsLabel, 1, 1, 4, 4);
322 WidthHeightGroupLayout->addMultiCellWidget( UnitsEdit, 1, 1, 5, 5);
324 QLabel* LabelBarWidth = new QLabel (tr("LBL_BAR_W"), WidthHeightGroup, "LabelBarWidth");
325 BarWidthSpin = new QSpinBox( 0, 100, 1, WidthHeightGroup );
326 BarWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
327 BarWidthSpin->setMinimumWidth( 70 );
328 BarWidthSpin->setValue( 0 );
329 BarWidthSpin->setSpecialValueText( tr("AUTO") );
330 WidthHeightGroupLayout->addMultiCellWidget( LabelBarWidth, 2, 2, 0, 0);
331 WidthHeightGroupLayout->addMultiCellWidget( BarWidthSpin, 2, 2, 1, 1);
333 QLabel* LabelBarHeight = new QLabel (tr("LBL_BAR_H"), WidthHeightGroup, "LabelBarHeight");
334 BarHeightSpin = new QSpinBox( 0, 100, 1, WidthHeightGroup );
335 BarHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
336 BarHeightSpin->setMinimumWidth( 70 );
337 BarHeightSpin->setValue( 0 );
338 BarHeightSpin->setSpecialValueText( tr("AUTO") );
339 WidthHeightGroupLayout->addMultiCellWidget( LabelBarHeight, 2, 2, 2, 2);
340 WidthHeightGroupLayout->addMultiCellWidget( BarHeightSpin, 2, 2, 3, 3);
342 TopLayout->addWidget( WidthHeightGroup );
344 // Common buttons ===========================================================
345 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
346 GroupButtons->setColumnLayout(0, Qt::Vertical );
347 GroupButtons->layout()->setSpacing( 0 );
348 GroupButtons->layout()->setMargin( 0 );
349 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
350 GroupButtonsLayout->setAlignment( Qt::AlignTop );
351 GroupButtonsLayout->setSpacing( 6 );
352 GroupButtonsLayout->setMargin( 11 );
354 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
355 buttonOk->setAutoDefault( TRUE );
356 buttonOk->setDefault( TRUE );
357 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
358 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
360 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
361 buttonCancel->setAutoDefault( TRUE );
362 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
364 QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" );
365 buttonHelp->setAutoDefault( TRUE );
366 GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
368 TopLayout->addWidget( GroupButtons );
370 connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
371 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
372 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp()));
373 connect(TitleWidthSpin, SIGNAL(valueChanged( int )), this, SIGNAL(updatePreview()));
374 connect(TitleHeightSpin, SIGNAL(valueChanged( int )), this, SIGNAL(updatePreview()));
375 connect(LabelWidthSpin, SIGNAL(valueChanged( int )), this, SIGNAL(updatePreview()));
376 connect(LabelHeightSpin, SIGNAL(valueChanged( int )), this, SIGNAL(updatePreview()));
377 connect(BarWidthSpin, SIGNAL(valueChanged( int )), this, SIGNAL(updatePreview()));
378 connect(BarHeightSpin, SIGNAL(valueChanged( int )), this, SIGNAL(updatePreview()));
379 connect(CBUnits, SIGNAL( toggled( bool )), this, SIGNAL(updatePreview()));
380 connect(UnitsEdit, SIGNAL( lostFocus() ), this, SIGNAL(updatePreview()));
384 //----------------------------------------------------------------------------
385 void VisuGUI_BarPrefDlg::setRatios(int titleRatioWidth, int titleRatioHeight,
386 int labelRatioWidth, int labelRatioHeight,
387 int barRatioWidth, int barRatioHeight)
389 TitleWidthSpin->setValue( myTitleWidth=titleRatioWidth );
390 TitleHeightSpin->setValue( myTitleHeight=titleRatioHeight );
391 LabelWidthSpin->setValue( myLabelWidth=labelRatioWidth );
392 LabelHeightSpin->setValue( myLabelHeight=labelRatioHeight );
393 BarWidthSpin->setValue( myBarWidth=barRatioWidth );
394 BarHeightSpin->setValue( myBarHeight=barRatioHeight );
398 //----------------------------------------------------------------------------
399 void VisuGUI_BarPrefDlg::getRatios(int& titleRatioWidth, int& titleRatioHeight,
400 int& labelRatioWidth, int& labelRatioHeight,
401 int& barRatioWidth, int& barRatioHeight)
403 titleRatioWidth=TitleWidthSpin->value();
404 titleRatioHeight=TitleHeightSpin->value();
405 labelRatioWidth=LabelWidthSpin->value();
406 labelRatioHeight=LabelHeightSpin->value();
407 barRatioWidth=BarWidthSpin->value();
408 barRatioHeight=BarHeightSpin->value();
412 //----------------------------------------------------------------------------
413 void VisuGUI_BarPrefDlg::setLabelsFormat(QString format)
415 UnitsEdit->setText(myUnitsFormat=format);
419 //----------------------------------------------------------------------------
420 QString VisuGUI_BarPrefDlg::getLabelsFormat()
422 return UnitsEdit->text();
426 //----------------------------------------------------------------------------
427 void VisuGUI_BarPrefDlg::onHelp()
429 QString aHelpFileName = "scalar_map_page.html";
430 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
432 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
433 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
436 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
437 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
438 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
439 QObject::tr("BUT_OK"));
444 //----------------------------------------------------------------------------
445 void VisuGUI_BarPrefDlg::setUnitsVisible(bool isVisible)
447 CBUnits->setChecked(myUnits=isVisible);
451 //----------------------------------------------------------------------------
452 bool VisuGUI_BarPrefDlg::isUnitsVisible()
454 return CBUnits->isChecked();
458 //----------------------------------------------------------------------------
460 Called when <Cancel> button is clicked, restore begin values
462 void VisuGUI_BarPrefDlg::reject()
464 TitleWidthSpin->setValue( myTitleWidth );
465 TitleHeightSpin->setValue( myTitleHeight );
466 LabelWidthSpin->setValue( myLabelWidth );
467 LabelHeightSpin->setValue( myLabelHeight );
468 BarWidthSpin->setValue( myBarWidth );
469 BarHeightSpin->setValue( myBarHeight );
470 CBUnits->setChecked(myUnits);
471 UnitsEdit->setText(myUnitsFormat);
476 //----------------------------------------------------------------------------
478 Called when <Ok> button is clicked, store begin values
480 void VisuGUI_BarPrefDlg::accept()
483 dVal.sprintf(UnitsEdit->text(),1.1);
484 if(dVal.toDouble() == 0.) {
485 SUIT_MessageBox::warn1( this,tr("WRN_VISU"),
486 tr("MSG_LABEL_FORMAT"),
491 TitleWidthSpin->value()+
492 LabelWidthSpin->value()+
493 BarWidthSpin->value()
497 TitleHeightSpin->value()+
498 LabelHeightSpin->value()+
499 BarHeightSpin->value()
503 SUIT_MessageBox::warn1( this,tr("WRN_VISU"),
507 myTitleWidth = TitleWidthSpin->value();
508 myTitleHeight = TitleHeightSpin->value();
509 myLabelWidth = LabelWidthSpin->value();
510 myLabelHeight = LabelHeightSpin->value();
511 myBarWidth = BarWidthSpin->value();
512 myBarHeight = BarHeightSpin->value();
513 myUnits = CBUnits->isChecked();
514 myUnitsFormat = UnitsEdit->text();
521 //----------------------------------------------------------------------------
523 Provides help on F1 button click
525 void VisuGUI_BarPrefDlg::keyPressEvent( QKeyEvent* e )
527 QDialog::keyPressEvent( e );
528 if ( e->isAccepted() )
531 if ( e->key() == Key_F1 )
538 //-----------------------------------------------------------------------
540 //-----------------------------------------------------------------------
544 VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool thePreview):
550 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
551 QString propertyName;
552 propertyName = QString("scalar_bar_vertical_");
553 myVerX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
554 myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
555 myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
556 myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
557 myVerTW = aResourceMgr->integerValue("VISU", propertyName + "title_width", 0);
558 myVerTH = aResourceMgr->integerValue("VISU", propertyName + "title_height",0);
559 myVerLW = aResourceMgr->integerValue("VISU", propertyName + "label_width", 0);
560 myVerLH = aResourceMgr->integerValue("VISU", propertyName + "label_height",0);
561 myVerBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0);
562 myVerBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0);
564 propertyName = QString("scalar_bar_horizontal_");
565 myHorX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
566 myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
567 myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
568 myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
569 myHorTW = aResourceMgr->integerValue("VISU", propertyName + "title_width", 0);
570 myHorTH = aResourceMgr->integerValue("VISU", propertyName + "title_height",0);
571 myHorLW = aResourceMgr->integerValue("VISU", propertyName + "label_width", 0);
572 myHorLH = aResourceMgr->integerValue("VISU", propertyName + "label_height",0);
573 myHorBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0);
574 myHorBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0);
579 // Range ============================================================
580 RangeGroup = new QButtonGroup (tr("SCALAR_RANGE_GRP"), this, "RangeGroup");
581 RangeGroup->setColumnLayout(0, Qt::Vertical );
582 RangeGroup->layout()->setSpacing( 0 );
583 RangeGroup->layout()->setMargin( 0 );
584 QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() );
585 RangeGroupLayout->setAlignment( Qt::AlignTop );
586 RangeGroupLayout->setSpacing( 6 );
587 RangeGroupLayout->setMargin( 11 );
589 myModeLbl = new QLabel("Scalar Mode", RangeGroup);
591 myModeCombo = new QComboBox(RangeGroup);
593 CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), RangeGroup);
594 CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
596 RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), RangeGroup, "RBFrange");
597 RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), RangeGroup, "RBIrange");
598 RBFrange->setChecked( true );
600 MinEdit = new QLineEdit( RangeGroup, "MinEdit" );
601 MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
602 MinEdit->setMinimumWidth( 70 );
603 MinEdit->setValidator( new QDoubleValidator(this) );
604 MinEdit->setText( "0.0" );
605 QLabel* MinLabel = new QLabel (tr("LBL_MIN"), RangeGroup, "MinLabel");
606 MinLabel->setBuddy(MinEdit);
608 MaxEdit = new QLineEdit( RangeGroup, "MaxEdit" );
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"), RangeGroup, "MaxLabel");
614 MaxLabel->setBuddy(MaxEdit);
616 RangeGroupLayout->addWidget( myModeLbl, 0, 0 );
617 RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3);
618 RangeGroupLayout->addMultiCellWidget( CBLog, 1, 1, 0, 3);
619 RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1);
620 RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3);
621 RangeGroupLayout->addWidget( MinLabel, 3, 0 );
622 RangeGroupLayout->addWidget( MinEdit, 3, 1 );
623 RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
624 RangeGroupLayout->addWidget( MaxEdit, 3, 3 );
626 //TopLayout->addWidget( RangeGroup );
628 // Colors and Labels ========================================================
629 QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this, "ColLabGroup");
630 ColLabGroup->setColumnLayout(0, Qt::Vertical );
631 ColLabGroup->layout()->setSpacing( 0 );
632 ColLabGroup->layout()->setMargin( 0 );
633 QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() );
634 ColLabGroupLayout->setAlignment( Qt::AlignTop );
635 ColLabGroupLayout->setSpacing( 6 );
636 ColLabGroupLayout->setMargin( 11 );
638 QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup, "ColorLabel");
639 ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup );
640 ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
641 ColorSpin->setMinimumWidth( 70 );
642 ColorSpin->setValue( 64 );
644 QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup, "LabelLabel");
645 LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup );
646 LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
647 LabelSpin->setMinimumWidth( 70 );
648 LabelSpin->setValue( 5 );
650 ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
651 ColLabGroupLayout->addWidget( ColorSpin, 0, 1);
652 ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
653 ColLabGroupLayout->addWidget( LabelSpin, 0, 3);
655 //TopLayout->addWidget( ColLabGroup );
657 // Orientation ==========================================================
658 QButtonGroup* OrientGroup = new QButtonGroup (tr("ORIENTATION_GRP"), this, "OrientGroup");
659 OrientGroup->setColumnLayout(0, Qt::Vertical );
660 OrientGroup->layout()->setSpacing( 0 );
661 OrientGroup->layout()->setMargin( 0 );
662 QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() );
663 OrientGroupLayout->setAlignment( Qt::AlignTop );
664 OrientGroupLayout->setSpacing( 6 );
665 OrientGroupLayout->setMargin( 11 );
667 RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGroup, "RBvert");
668 RBvert->setChecked( true );
669 RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGroup, "RBhori");
670 OrientGroupLayout->addWidget( RBvert, 0, 0 );
671 OrientGroupLayout->addWidget( RBhori, 0, 1 );
673 // TopLayout->addWidget( OrientGroup );
675 // Origin ===============================================================
676 QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this, "OriginGroup");
677 OriginGroup->setColumnLayout(0, Qt::Vertical );
678 OriginGroup->layout()->setSpacing( 0 );
679 OriginGroup->layout()->setMargin( 0 );
680 QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() );
681 OriginGroupLayout->setAlignment( Qt::AlignTop );
682 OriginGroupLayout->setSpacing( 6 );
683 OriginGroupLayout->setMargin( 11 );
685 QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup, "XLabel");
686 XSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
687 XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
688 XSpin->setMinimumWidth( 70 );
689 XSpin->setValue( 0.01 );
691 QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup, "YLabel");
692 YSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
693 YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
694 YSpin->setMinimumWidth( 70 );
695 YSpin->setValue( 0.01 );
697 OriginGroupLayout->addWidget( XLabel, 0, 0);
698 OriginGroupLayout->addWidget( XSpin, 0, 1);
699 OriginGroupLayout->addWidget( YLabel, 0, 2);
700 OriginGroupLayout->addWidget( YSpin, 0, 3);
702 //TopLayout->addWidget( OriginGroup );
704 // Dimensions =========================================================
705 QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this, "DimGroup");
706 DimGroup->setColumnLayout(0, Qt::Vertical );
707 DimGroup->layout()->setSpacing( 0 );
708 DimGroup->layout()->setMargin( 0 );
709 QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() );
710 DimGroupLayout->setAlignment( Qt::AlignTop );
711 DimGroupLayout->setSpacing( 6 );
712 DimGroupLayout->setMargin( 11 );
714 QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup, "WidthLabel");
715 WidthSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
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, "HeightLabel");
721 HeightSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
722 HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
723 HeightSpin->setMinimumWidth( 70 );
724 HeightSpin->setValue( 0.8 );
726 DimGroupLayout->addWidget( WidthLabel, 0, 0);
727 DimGroupLayout->addWidget( WidthSpin, 0, 1);
728 DimGroupLayout->addWidget( HeightLabel, 0, 2);
729 DimGroupLayout->addWidget( HeightSpin, 0, 3);
731 //TopLayout->addWidget( DimGroup );
733 // Save check box ===========================================================
734 QHBox* aSaveBox = new QHBox(this);
736 CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), aSaveBox, "CBSave");
741 myTextBtn = new QPushButton("Text properties...", aSaveBox);
742 myBarBtn = new QPushButton("Bar properties...", aSaveBox);
743 myTextDlg = new VisuGUI_TextPrefDlg(this);
744 myTextDlg->setTitleVisible(!thePreview);
745 myBarDlg = new VisuGUI_BarPrefDlg(this);
747 QGroupBox* CheckGroup = new QGroupBox("", this, "CheckGroup");
748 CheckGroup->setColumnLayout(0, Qt::Vertical );
749 CheckGroup->layout()->setSpacing( 0 );
750 CheckGroup->layout()->setMargin( 0 );
751 QGridLayout* CheckGroupLayout = new QGridLayout( CheckGroup->layout() );
753 myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), CheckGroup);
754 myPreviewCheck->setChecked(false);
755 CheckGroupLayout->addWidget(myPreviewCheck , 0, 0 );
757 myPreviewCheck->hide();
761 if(RBvert->isChecked()) {
762 myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH);
764 myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH);
767 myBarDlg->setLabelsFormat(aResourceMgr->stringValue("VISU", propertyName + "label_format", "%-#6.3g"));
768 myBarDlg->setUnitsVisible(aResourceMgr->booleanValue("VISU", propertyName + "display_units", true));
770 // signals and slots connections ===========================================
771 connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) );
772 connect( myModeCombo, SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( int ) ) );
773 connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) );
774 connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
775 connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
776 connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
777 connect( myBarBtn, SIGNAL( clicked() ), this, SLOT( onBarPref() ) );
778 connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) );
779 connect( ColorSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
780 connect( LabelSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
781 connect( WidthSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
782 connect( HeightSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
783 connect( CBLog, SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() ));
784 connect( myBarDlg, SIGNAL( updatePreview() ), this, SLOT( updatePreview() ));
786 myIsStoreTextProp = false;
791 * Stores dialog values to resources
793 void VisuGUI_ScalarBarPane::storeToResources() {
794 int orient = (RBvert->isChecked())? 0 : 1;
795 float sbX1 = XSpin->value();
796 float sbY1 = YSpin->value();
797 float sbW = WidthSpin->value();
798 float sbH = HeightSpin->value();
799 int sbCol = ColorSpin->value();
800 int sbLab = LabelSpin->value();
802 if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
816 bool sbRange = RBIrange->isChecked();
817 float sbVmin = (float)(MinEdit->text().toDouble());
818 float sbVmax = (float)(MaxEdit->text().toDouble());
820 if(sbVmin > sbVmax) {
825 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
827 aResourceMgr->setValue("VISU", "scalar_bar_orientation", orient);
829 QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
831 aResourceMgr->setValue("VISU", propertyName + "x", sbX1);
832 aResourceMgr->setValue("VISU", propertyName + "y", sbY1);
833 aResourceMgr->setValue("VISU", propertyName + "width", sbW);
834 aResourceMgr->setValue("VISU", propertyName + "height", sbH);
836 aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol);
837 aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab);
841 aResourceMgr->setValue("VISU", "scalar_range_type", 1);
842 aResourceMgr->setValue("VISU", "scalar_range_min" ,sbVmin);
843 aResourceMgr->setValue("VISU", "scalar_range_max" ,sbVmax);
846 aResourceMgr->setValue("VISU", "scalar_range_type", 0);
848 aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic());
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.setUnderline(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.setUnderline(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();
934 //----------------------------------------------------------------------------
936 * Initialise dialog box from presentation object
938 void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs)
940 myScalarMap = dynamic_cast<VISU::ScalarMap_i*>(thePrs);
945 switch(myScalarMap->GetScaling()){
946 case VISU::LOGARITHMIC :
947 setLogarithmic(true);
950 setLogarithmic(false);
953 // Update myModeCombo
954 const VISU::PField& aField = myScalarMap->GetScalarField();
955 const VISU::TNames& aCompNames = aField->myCompNames;
956 const VISU::TNames& aUnitNames = aField->myUnitNames;
957 int aNbComp = aField->myNbComp;
958 bool isScalarMode = (aNbComp > 1);
959 myModeCombo->clear();
960 myModeCombo->insertItem("<Modulus>");
961 for(int i = 0; i < aNbComp; i++){
962 QString aComponent = QString(aCompNames[i].c_str()).simplifyWhiteSpace();
963 if(aComponent.isNull() || aComponent == "")
964 aComponent = "Component " + QString::number(i+1);
966 aComponent = "[" + QString::number(i+1) + "] " + aComponent;
968 QString anUnit = QString(aUnitNames[i].c_str()).simplifyWhiteSpace();
969 if(anUnit.isNull() || anUnit == "")
972 aComponent = aComponent + ", " + anUnit;
974 myModeCombo->insertItem(aComponent);
977 myModeCombo->setCurrentItem(myScalarMap->GetScalarMode());
979 myModeCombo->setCurrentItem(1);
981 myModeLbl->setEnabled(isScalarMode);
982 myModeCombo->setEnabled(isScalarMode);
984 setRange( myScalarMap->GetMin(), myScalarMap->GetMax(), myScalarMap->IsRangeFixed() );
986 setScalarBarData( myScalarMap->GetNbColors(), myScalarMap->GetLabels() );
989 CORBA::String_var aTitle = myScalarMap->GetTitle();
990 myTextDlg->setTitleText(aTitle.in());
991 myTitle = aTitle.in();
993 vtkFloatingPointType R, G, B;
994 myScalarMap->GetTitleColor(&R, &G, &B);
996 setPosAndSize( myScalarMap->GetPosX(),
997 myScalarMap->GetPosY(),
998 myScalarMap->GetWidth(),
999 myScalarMap->GetHeight(),
1000 myScalarMap->GetBarOrientation());
1002 if(RBvert->isChecked()) {
1003 myVerTW = myScalarMap->GetTitleWidth();
1004 myVerTH = myScalarMap->GetTitleHeight();
1005 myVerLW = myScalarMap->GetLabelWidth();
1006 myVerLH = myScalarMap->GetLabelHeight();
1007 myVerBW = myScalarMap->GetBarWidth();
1008 myVerBH = myScalarMap->GetBarHeight();
1009 myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH);
1011 myHorTW = myScalarMap->GetTitleWidth();
1012 myHorTH = myScalarMap->GetTitleHeight();
1013 myHorLW = myScalarMap->GetLabelWidth();
1014 myHorLH = myScalarMap->GetLabelHeight();
1015 myHorBW = myScalarMap->GetBarWidth();
1016 myHorBH = myScalarMap->GetBarHeight();
1017 myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH);
1020 myBarDlg->setLabelsFormat(myScalarMap->GetLabelsFormat());
1021 myBarDlg->setUnitsVisible(myScalarMap->IsUnitsVisible());
1023 myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
1024 myScalarMap->GetTitFontType(),
1025 myScalarMap->IsBoldTitle(),
1026 myScalarMap->IsItalicTitle(),
1027 myScalarMap->IsShadowTitle());
1030 myScalarMap->GetLabelColor(&R, &G, &B);
1032 myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
1033 myScalarMap->GetLblFontType(),
1034 myScalarMap->IsBoldLabel(),
1035 myScalarMap->IsItalicLabel(),
1036 myScalarMap->IsShadowLabel());
1039 if (myPreviewCheck->isChecked()) {
1047 //----------------------------------------------------------------------------
1048 /*! Slot update preview of scalar bar, if preview is checked
1050 void VisuGUI_ScalarBarPane::updatePreview()
1052 if (myPreviewCheck->isChecked()) {
1053 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
1061 //----------------------------------------------------------------------------
1062 /*! Creating preview scalar bar
1064 void VisuGUI_ScalarBarPane::createScalarBar()
1066 if (VISU::GetActiveViewWindow<SVTK_ViewWindow>() == NULL) return;
1067 if (myPreviewActor != 0) return;
1068 if (myScalarMap == NULL) return;
1070 if (!check()) return;
1071 myScalarMapPL = VISU_ScalarMapPL::New();
1072 if(myScalarMap->GetSpecificPL())
1073 myScalarMapPL->ShallowCopy(myScalarMap->GetSpecificPL(), true);
1075 if ( myBusy ) return;
1080 sbCol = getNbColors();
1081 sbLab = getNbLabels();
1082 if(sbCol < 2) sbCol=2;
1083 if(sbCol > 64) sbCol=64;
1084 if(sbLab < 2) sbLab=2;
1085 if(sbLab > 65) sbLab=65;
1086 myPreviewActor = VISU_ScalarMapAct::New();
1087 VISU_ScalarBarActor* aScalarBarActor = myPreviewActor->GetScalarBar();
1088 myPreviewActor->GetScalarBar()->VisibilityOn();
1089 myPreviewActor->PickableOff();
1091 myScalarMapPL->SetScalarMode(myModeCombo->currentItem());
1093 myScalarMapPL->SetScaling(VISU::LOGARITHMIC);
1095 myScalarMapPL->SetScaling(VISU::LINEAR);
1096 vtkFloatingPointType theRange[2];
1097 if(RBFrange->isChecked()) {
1098 theRange[0] = myScalarMap->GetSourceMin();
1099 theRange[1] = myScalarMap->GetSourceMax();
1101 theRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble();
1102 theRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble();
1104 myScalarMapPL->SetScalarRange(theRange);
1105 myScalarMapPL->SetNbColors(sbCol);
1107 myScalarMapPL->Update();
1109 aScalarBarActor->SetLookupTable(myScalarMapPL->GetBarTable());
1111 if (myTextDlg->getTitleText().latin1() != "") {
1112 VISU::PValForTime aValForTime;
1113 const VISU::PField& aField = myScalarMap->GetScalarField();
1114 const VISU::TValField& aValField = aField->myValField;
1115 VISU::TValField::const_iterator anIter = aValField.find(myScalarMap->GetScalarTimeStampNumber());
1116 if (anIter != aValField.end())
1117 aValForTime = anIter->second;
1120 std::strstream aStream;
1121 const VISU::TTime& aTime = aValForTime->myTime;
1122 aStream<< myTextDlg->getTitleText() <<" ";
1123 if(myBarDlg->isUnitsVisible())
1124 aStream<<VISU_Convertor::GenerateName(aTime)<<std::ends;
1127 aName.sprintf("%g", aTime.first);
1128 aStream << aName << std::ends;
1130 std::string aScalarBarTitle = aStream.str();
1131 aScalarBarActor->SetTitle(aScalarBarTitle.c_str());
1133 aScalarBarActor->SetTitle(myTextDlg->getTitleText().latin1());
1137 aScalarBarActor->SetTitle(myTitle.c_str());
1138 aScalarBarActor->SetOrientation(getOrientation());
1139 aScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
1140 aScalarBarActor->GetPositionCoordinate()->SetValue(getX(),getY());
1141 aScalarBarActor->SetWidth(getWidth());
1142 aScalarBarActor->SetHeight(getHeight());
1143 aScalarBarActor->SetNumberOfLabels(sbLab);
1144 aScalarBarActor->SetMaximumNumberOfColors(sbCol);
1146 // title text property
1148 int aTitleFontFamily;
1152 myTextDlg->myTitleFont->GetData(aTitleColor,aTitleFontFamily,
1153 isTitleBold,isTitleItalic,isTitleShadow);
1154 vtkTextProperty* aTitleProp = aScalarBarActor->GetTitleTextProperty();
1155 aTitleProp->SetFontFamily(aTitleFontFamily);
1156 aTitleProp->SetColor(vtkFloatingPointType(aTitleColor.red())/255.,
1157 vtkFloatingPointType(aTitleColor.green())/255.,
1158 vtkFloatingPointType(aTitleColor.blue())/255.);
1159 (isTitleBold)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
1160 (isTitleItalic)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
1161 (isTitleShadow)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
1163 // label text property
1165 int aLabelFontFamily;
1169 myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
1170 isLabelBold, isLabelItalic, isLabelShadow);
1171 vtkTextProperty* aLabelProp = aScalarBarActor->GetLabelTextProperty();
1172 aLabelProp->SetFontFamily(aLabelFontFamily);
1173 aLabelProp->SetColor(vtkFloatingPointType(aLabelColor.red())/255.,
1174 vtkFloatingPointType(aLabelColor.green())/255.,
1175 vtkFloatingPointType(aLabelColor.blue())/255.);
1176 (isLabelBold)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
1177 (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
1178 (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
1180 int VerTW, VerTH, VerLW, VerLH, VerBW, VerBH;
1181 myBarDlg->getRatios(VerTW, VerTH, VerLW, VerLH, VerBW, VerBH);
1182 aScalarBarActor->SetRatios(VerTW, VerTH, VerLW, VerLH, VerBW, VerBH);
1184 aScalarBarActor->SetLabelFormat(myBarDlg->getLabelsFormat());
1186 aScalarBarActor->Modified();
1188 VISU::GetActiveViewWindow<SVTK_ViewWindow>()->AddActor(myPreviewActor);
1194 //----------------------------------------------------------------------------
1195 /*! Deleting preview scalar bar
1197 void VisuGUI_ScalarBarPane::deleteScalarBar()
1199 if ( myBusy ) return;
1201 if (myPreviewActor == 0) return;
1202 vtkRenderer* aRend = myPreviewActor->GetRenderer();
1203 vtkRenderWindow* aWnd = aRend->GetRenderWindow();
1205 myPreviewActor->RemoveFromRender(aRend);
1206 myPreviewActor->GetScalarBar()->VisibilityOff();
1207 myPreviewActor->Delete();
1211 myScalarMapPL->Delete();
1217 //----------------------------------------------------------------------------
1219 * Store values to presentation object
1221 int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) {
1225 myScalarMap->SetScalarMode(myModeCombo->currentItem());
1226 myScalarMap->SetPosition(XSpin->value(), YSpin->value());
1227 myScalarMap->SetSize(WidthSpin->value(), HeightSpin->value());
1228 if(RBvert->isChecked()) {
1229 myScalarMap->SetRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH);
1231 myScalarMap->SetRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH);
1234 myScalarMap->SetLabelsFormat(myBarDlg->getLabelsFormat());
1235 myScalarMap->SetUnitsVisible(myBarDlg->isUnitsVisible());
1237 myScalarMap->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3d::VERTICAL : VISU::ColoredPrs3d::HORIZONTAL);
1239 myScalarMap->SetScaling(VISU::LOGARITHMIC);
1241 myScalarMap->SetScaling(VISU::LINEAR);
1243 if (RBFrange->isChecked()) {
1244 myScalarMap->SetSourceRange();
1246 myScalarMap->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
1248 myScalarMap->SetNbColors(ColorSpin->value());
1249 myScalarMap->SetLabels(LabelSpin->value());
1251 if (isToSave()) storeToResources();
1253 if (myIsStoreTextProp) {
1255 myScalarMap->SetTitle(myTextDlg->getTitleText().latin1());
1257 QColor aTitColor (255, 255, 255);
1258 int aTitleFontFamily = VTK_ARIAL;
1259 bool isTitleBold = false;
1260 bool isTitleItalic = false;
1261 bool isTitleShadow = false;
1263 myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
1264 isTitleBold, isTitleItalic, isTitleShadow);
1266 myScalarMap->SetBoldTitle(isTitleBold);
1267 myScalarMap->SetItalicTitle(isTitleItalic);
1268 myScalarMap->SetShadowTitle(isTitleShadow);
1269 myScalarMap->SetTitFontType(aTitleFontFamily);
1270 myScalarMap->SetTitleColor(aTitColor.red()/255.,
1271 aTitColor.green()/255.,
1272 aTitColor.blue()/255.);
1275 QColor aLblColor (255, 255, 255);
1276 int aLabelFontFamily = VTK_ARIAL;
1277 bool isLabelBold = false;
1278 bool isLabelItalic = false;
1279 bool isLabelShadow = false;
1281 myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
1282 isLabelBold, isLabelItalic, isLabelShadow);
1284 myScalarMap->SetBoldLabel(isLabelBold);
1285 myScalarMap->SetItalicLabel(isLabelItalic);
1286 myScalarMap->SetShadowLabel(isLabelShadow);
1287 myScalarMap->SetLblFontType(aLabelFontFamily);
1288 myScalarMap->SetLabelColor(aLblColor.red()/255.,
1289 aLblColor.green()/255.,
1290 aLblColor.blue()/255.);
1291 myIsStoreTextProp = false;
1298 //----------------------------------------------------------------------------
1300 Called when orientation is changed
1302 void VisuGUI_ScalarBarPane::changeDefaults( int )
1304 if ( RBvert->isChecked() ) {
1305 XSpin->setValue( myVerX );
1306 YSpin->setValue( myVerY );
1307 WidthSpin->setValue( myVerW );
1308 HeightSpin->setValue( myVerH );
1311 XSpin->setValue( myHorX );
1312 YSpin->setValue( myHorY );
1313 WidthSpin->setValue( myHorW );
1314 HeightSpin->setValue( myHorH );
1320 //----------------------------------------------------------------------------
1322 Called when Range mode is changed
1324 void VisuGUI_ScalarBarPane::changeRange( int )
1326 if ( RBFrange->isChecked() ) {
1327 myScalarMap->SetSourceRange();
1328 MinEdit->setEnabled( false );
1329 MaxEdit->setEnabled( false );
1331 myScalarMap->SetRange(myScalarMap->GetMin(), myScalarMap->GetMax());
1332 MinEdit->setEnabled( true );
1333 MaxEdit->setEnabled( true );
1336 changeScalarMode(myModeCombo->currentItem());
1340 //----------------------------------------------------------------------------
1342 Called when X,Y position is changed
1344 void VisuGUI_ScalarBarPane::XYChanged( double )
1346 QtxDblSpinBox* snd = (QtxDblSpinBox*)sender();
1347 if ( snd == XSpin ) {
1348 WidthSpin->setMaxValue( 1.0 - XSpin->value() );
1350 if ( snd == YSpin ) {
1351 HeightSpin->setMaxValue( 1.0 - YSpin->value() );
1357 //----------------------------------------------------------------------------
1359 Called when scalar mode is changed
1361 void VisuGUI_ScalarBarPane::changeScalarMode( int theMode )
1363 if ( RBFrange->isChecked() ) {
1364 MinEdit->setText( QString::number( myScalarMap->GetComponentMin(theMode) ) );
1365 MaxEdit->setText( QString::number( myScalarMap->GetComponentMax(theMode) ) );
1368 myScalarMap->SetScalarMode(theMode);
1374 //----------------------------------------------------------------------------
1376 Sets default values and range mode
1378 void VisuGUI_ScalarBarPane::setRange( double imin, double imax, bool sbRange )
1380 MinEdit->setText( QString::number( imin ) );
1381 MaxEdit->setText( QString::number( imax ) );
1384 RBIrange->setChecked( true );
1386 RBFrange->setChecked( true );
1388 changeRange( sbRange );
1392 //----------------------------------------------------------------------------
1394 Sets and gets parameters
1396 bool VisuGUI_ScalarBarPane::isIRange() {
1397 return RBIrange->isChecked();
1401 //----------------------------------------------------------------------------
1402 double VisuGUI_ScalarBarPane::getMin() {
1403 return MinEdit->text().toDouble();
1407 //----------------------------------------------------------------------------
1408 double VisuGUI_ScalarBarPane::getMax() {
1409 return MaxEdit->text().toDouble();
1413 //----------------------------------------------------------------------------
1414 double VisuGUI_ScalarBarPane::getX() {
1415 return XSpin->value();
1419 //----------------------------------------------------------------------------
1420 double VisuGUI_ScalarBarPane::getY() {
1421 return YSpin->value();
1425 //----------------------------------------------------------------------------
1426 double VisuGUI_ScalarBarPane::getWidth() {
1427 return WidthSpin->value();
1431 //----------------------------------------------------------------------------
1432 double VisuGUI_ScalarBarPane::getHeight() {
1433 return HeightSpin->value();
1437 //----------------------------------------------------------------------------
1438 int VisuGUI_ScalarBarPane::getNbColors() {
1439 return ColorSpin->value();
1443 //----------------------------------------------------------------------------
1444 int VisuGUI_ScalarBarPane::getNbLabels() {
1445 return LabelSpin->value();
1449 //----------------------------------------------------------------------------
1450 bool VisuGUI_ScalarBarPane::isLogarithmic() {
1451 return CBLog->isChecked();
1455 //----------------------------------------------------------------------------
1456 void VisuGUI_ScalarBarPane::setLogarithmic( bool on ) {
1457 CBLog->setChecked( on );
1461 //----------------------------------------------------------------------------
1463 Sets size and position
1465 void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
1472 RBvert->setChecked( true );
1479 RBhori->setChecked( true );
1481 changeDefaults( 0 );
1485 //----------------------------------------------------------------------------
1487 Sets colors and labels number
1489 void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
1491 ColorSpin->setValue( colors );
1492 LabelSpin->setValue( labels );
1496 //----------------------------------------------------------------------------
1500 int VisuGUI_ScalarBarPane::getOrientation()
1502 if (RBvert->isChecked() )
1509 //----------------------------------------------------------------------------
1511 Called when <OK> button is clicked, validates data and closes dialog
1513 bool VisuGUI_ScalarBarPane::check()
1515 double minVal = MinEdit->text().toDouble();
1516 double maxVal = MaxEdit->text().toDouble();
1517 if ( RBIrange->isChecked() ) {
1518 if (minVal >= maxVal) {
1519 SUIT_MessageBox::warn1( this,tr("WRN_VISU"),
1520 tr("MSG_MINMAX_VALUES"),
1526 // check if logarithmic mode is on and check imposed range to not contain negative values
1527 if ( CBLog->isChecked() ) {
1528 if ( minVal <= 0.0 || maxVal <= 0.0 ) {
1529 if ( RBIrange->isChecked() ) {
1530 SUIT_MessageBox::warn1( this,
1532 tr("WRN_LOGARITHMIC_RANGE"),
1535 SUIT_MessageBox::warn1( this,
1537 tr("WRN_LOGARITHMIC_FIELD_RANGE"),
1539 RBIrange->setChecked(true);
1549 //----------------------------------------------------------------------------
1550 void VisuGUI_ScalarBarPane::onTextPref()
1552 myTextDlg->storeBeginValues();
1553 myIsStoreTextProp = myTextDlg->exec() || myIsStoreTextProp;
1558 //----------------------------------------------------------------------------
1559 void VisuGUI_ScalarBarPane::onBarPref()
1561 if(RBvert->isChecked())
1562 myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH);
1564 myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH);
1565 if(myBarDlg->exec()) {
1566 if(RBvert->isChecked())
1567 myBarDlg->getRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH);
1569 myBarDlg->getRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH);
1575 //----------------------------------------------------------------------------
1576 void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview)
1578 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
1589 //----------------------------------------------------------------------------
1590 VisuGUI_Prs3dDlg::VisuGUI_Prs3dDlg( SalomeApp_Module* theModule ) :
1591 QDialog( VISU::GetDesktop( theModule ), 0, false,
1592 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
1596 //----------------------------------------------------------------------------
1598 Called when <Help> button is clicked, shows the corresponding help page in defined browser
1600 void VisuGUI_Prs3dDlg::onHelp()
1602 QString aHelpFileName = GetContextHelpFilePath();
1603 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1605 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
1606 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
1609 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
1610 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
1611 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
1612 QObject::tr("BUT_OK"));
1617 //----------------------------------------------------------------------------
1618 void VisuGUI_Prs3dDlg::keyPressEvent( QKeyEvent* e )
1620 QDialog::keyPressEvent( e );
1621 if ( e->isAccepted() )
1624 if ( e->key() == Key_F1 ) {
1631 //----------------------------------------------------------------------------
1632 VisuGUI_ScalarBarBaseDlg::VisuGUI_ScalarBarBaseDlg( SalomeApp_Module* theModule, bool thePreview ) :
1633 VisuGUI_Prs3dDlg( theModule )
1635 myScalarPane = new VisuGUI_ScalarBarPane(this, thePreview);
1636 myScalarPane->setMargin( 5 );
1640 VisuGUI_ScalarBarBaseDlg::~VisuGUI_ScalarBarBaseDlg()
1646 //----------------------------------------------------------------------------
1647 void VisuGUI_ScalarBarBaseDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
1650 myScalarPane->initFromPrsObject( thePrs );
1654 //----------------------------------------------------------------------------
1656 Called when <OK> button is clicked, validates data and closes dialog
1658 void VisuGUI_ScalarBarBaseDlg::accept()
1660 if (GetScalarPane()->check())
1661 VisuGUI_Prs3dDlg::accept();
1665 //----------------------------------------------------------------------------
1667 Called when <Cancel> button is clicked, remove preview and closes dialog
1669 void VisuGUI_ScalarBarBaseDlg::reject()
1671 VisuGUI_Prs3dDlg::reject();
1674 //----------------------------------------------------------------------------
1675 VisuGUI_ScalarBarPane* VisuGUI_ScalarBarBaseDlg::GetScalarPane()
1677 return myScalarPane;
1681 //----------------------------------------------------------------------------