]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI_Prs3dDlg.cxx
Salome HOME
d0cb296d057e8381b051f423adcc62cb9b1e0443
[modules/visu.git] / src / VISUGUI / VisuGUI_Prs3dDlg.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  VISU VISUGUI : GUI of VISU component
23 //  File   : VisuGUI_Prs3dDlg.cxx
24 //  Author : Laurent CORNABE & Hubert ROLLAND
25 //  Module : VISU
26
27 #include "VisuGUI_Prs3dDlg.h"
28
29 #include "VisuGUI.h"
30 #include "VisuGUI_Tools.h"
31 #include "VisuGUI_ViewTools.h"
32 #include "VisuGUI_InputPane.h"
33
34 #include "SVTK_ViewWindow.h"
35 #include "SVTK_FontWidget.h"
36
37 #include "VISUConfig.hh"
38 #include "VISU_Convertor.hxx"
39 #include "VISU_MeshValue.hxx"
40 #include "VISU_Structures_impl.hxx"
41 #include "VISU_ScalarMapPL.hxx"
42 #include "VISU_ScalarBarActor.hxx"
43 #include "VISU_ScalarMapAct.h"
44 #include "VISU_ScalarMap_i.hh"
45 #include "VISU_Result_i.hh"
46 #include "VISU_Prs3dUtils.hh"
47
48 #include "LightApp_Application.h"
49
50 #include "SUIT_Session.h"
51 #include "SUIT_MessageBox.h"
52 #include "SUIT_ResourceMgr.h"
53 #include "SUIT_Desktop.h"
54
55 #include <QCheckBox>
56 #include <QLineEdit>
57 #include <QRadioButton>
58 #include <QButtonGroup>
59 #include <QGroupBox>
60 #include <QLabel>
61 #include <QPushButton>
62 #include <QComboBox>
63 #include <QToolButton>
64 #include <QLayout>
65 #include <QValidator>
66 #include <QColorDialog>
67 #include <QTabWidget>
68 #include <QKeyEvent>
69 #include <QGridLayout>
70
71 #include "QtxDoubleSpinBox.h"
72
73 #include <vtkTextProperty.h>
74
75 #include <limits.h>
76
77 using namespace std;
78
79 //-----------------------------------------------------------------------
80 // Text Preferences Dialog
81 //-----------------------------------------------------------------------
82 /*!
83   Constructor
84 */
85 VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent)
86   : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
87 {
88   setModal( true );
89   setWindowTitle(tr("TIT_TEXT_PREF"));
90   setSizeGripEnabled(TRUE);
91
92   QVBoxLayout* aMainLay = new QVBoxLayout(this);
93   aMainLay->setSpacing(6);
94   aMainLay->setMargin(11);
95
96   // "Title" grp
97   QGroupBox* aTitleGrp = new QGroupBox ( tr("LBL_TITLE"), this);
98   QVBoxLayout* aVBLay = new QVBoxLayout( aTitleGrp );
99
100   //   edit line
101   myTitleEdt = new QLineEdit (aTitleGrp);
102   aVBLay->addWidget( myTitleEdt);
103
104   //   font
105   QWidget* aHBox = new QWidget (aTitleGrp);
106   aVBLay->addWidget( aHBox );
107
108   QHBoxLayout* aHBLay = new QHBoxLayout( aHBox );
109   aHBLay->setSpacing(5);
110
111   myTitleFont = new SVTK_FontWidget (aHBox);
112   aHBLay->addWidget( myTitleFont );
113
114   aMainLay->addWidget(aTitleGrp);
115
116   // "Labels" grp
117   QGroupBox* aLabelsGrp = new QGroupBox (tr("LBL_LABELS"), this);
118   aVBLay = new QVBoxLayout( aLabelsGrp );
119
120   //   font
121   aHBox = new QWidget (aLabelsGrp);
122   aVBLay->addWidget( aHBox );
123
124   aHBLay = new QHBoxLayout( aHBox );
125   aHBLay->setSpacing(5);
126
127   myLabelFont = new SVTK_FontWidget (aHBox);
128   aHBLay->addWidget( myLabelFont );
129
130   aMainLay->addWidget(aLabelsGrp);
131
132   // Common buttons ===========================================================
133   QGroupBox* GroupButtons = new QGroupBox( this );
134   //GroupButtons->setColumnLayout(0, Qt::Vertical );
135   //GroupButtons->layout()->setSpacing( 0 );
136   //GroupButtons->layout()->setMargin( 0 );
137   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons );
138   GroupButtonsLayout->setAlignment( Qt::AlignTop );
139   GroupButtonsLayout->setSpacing( 6 );
140   GroupButtonsLayout->setMargin( 11 );
141
142   QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons );
143   buttonOk->setAutoDefault( TRUE );
144   buttonOk->setDefault( TRUE );
145   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
146   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
147
148   QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons );
149   buttonCancel->setAutoDefault( TRUE );
150   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
151
152   QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons );
153   buttonHelp->setAutoDefault( TRUE );
154   GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
155
156   aMainLay->addWidget( GroupButtons );
157
158   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(accept()));
159   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
160   connect(buttonHelp,   SIGNAL(clicked()), this, SLOT(onHelp()));
161 }
162
163
164 //----------------------------------------------------------------------------
165 QString VisuGUI_TextPrefDlg::getTitleText()
166 {
167   return myTitleEdt->text();
168 }
169
170
171 //----------------------------------------------------------------------------
172 void VisuGUI_TextPrefDlg::setTitleText( const QString& theText )
173 {
174   myTitleEdt->setText(theText);
175 }
176
177
178 //----------------------------------------------------------------------------
179 void VisuGUI_TextPrefDlg::setTitleVisible(bool isVisible)
180 {
181   if(isVisible)
182     myTitleEdt->show();
183   else
184     myTitleEdt->hide();
185 }
186
187
188 //----------------------------------------------------------------------------
189 void VisuGUI_TextPrefDlg::onHelp()
190 {
191   QString aHelpFileName = "scalar_map_page.html";
192   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
193   if (app) {
194     VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
195     app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
196   }
197   else {
198     SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
199                              QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
200                              arg(app->resourceMgr()->stringValue("ExternalBrowser",
201                                                                  "application")).arg(aHelpFileName),
202                              QObject::tr("BUT_OK"));
203   }
204 }
205
206
207 //----------------------------------------------------------------------------
208 void VisuGUI_TextPrefDlg::storeBeginValues()
209 {
210   myTitle = myTitleEdt->text();
211   myTitleFont->GetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
212   myLabelFont->GetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
213 }
214
215
216 //----------------------------------------------------------------------------
217 /*!
218   Called when <Cancel> button is clicked, restore begin values
219 */
220 void VisuGUI_TextPrefDlg::reject()
221 {
222   myTitleEdt->setText(myTitle);
223   myTitleFont->SetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
224   myLabelFont->SetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
225
226   QDialog::reject();
227 }
228
229
230 //----------------------------------------------------------------------------
231 /*!
232   Called when <Ok> button is clicked, store begin values
233 */
234 void VisuGUI_TextPrefDlg::accept()
235 {
236   storeBeginValues();
237
238   QDialog::accept();
239 }
240
241
242 //----------------------------------------------------------------------------
243 /*!
244   Provides help on F1 button click
245 */
246 void VisuGUI_TextPrefDlg::keyPressEvent( QKeyEvent* e )
247 {
248   QDialog::keyPressEvent( e );
249   if ( e->isAccepted() )
250     return;
251
252   if ( e->key() == Qt::Key_F1 )
253     {
254       e->accept();
255       onHelp();
256     }
257 }
258
259 //-----------------------------------------------------------------------
260 // Scalar Bar Preferences Dialog
261 //-----------------------------------------------------------------------
262 /*!
263   Constructor
264 */
265 VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent )
266   : QDialog( parent ),
267     myOrientation( 1 )
268 {
269   setModal( true );
270   setWindowTitle( tr( "TIT_BAR_PREF" ) );
271   setSizeGripEnabled( true );
272
273   QString propertyName = QString( "scalar_bar_vertical_" );
274
275   myTitleSize = myLabelSize = myBarWidth = myBarHeight = 0;
276   myUnits = true;
277   myPrecision = 3;
278
279   QVBoxLayout* aMainLay = new QVBoxLayout( this );
280   aMainLay->setSpacing( 5 );
281   aMainLay->setMargin( 5 );
282
283   // dimensions
284
285   QGroupBox* aDimGrp = new QGroupBox( this );
286   QGridLayout* aDimGrpLay = new QGridLayout( aDimGrp );
287   aDimGrpLay->setSpacing( 5 );
288   aDimGrpLay->setMargin( 5 );
289
290   myTitleSizeSpin = new QSpinBox( aDimGrp );
291   myTitleSizeSpin->setRange( 0, 100 );
292   myTitleSizeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
293   myTitleSizeSpin->setMinimumWidth( 70 );
294   myTitleSizeSpin->setValue( 0 );
295   myTitleSizeSpin->setSpecialValueText( tr( "AUTO" ) );
296   QLabel* aTitleSizeLbl = new QLabel( tr( "LBL_TITLE_W" ), aDimGrp );
297
298   myLabelSizeSpin = new QSpinBox( aDimGrp );
299   myLabelSizeSpin->setRange( 0, 100 );
300   myLabelSizeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
301   myLabelSizeSpin->setMinimumWidth( 70 );
302   myLabelSizeSpin->setValue( 0 );
303   myLabelSizeSpin->setSpecialValueText( tr( "AUTO" ) );
304   QLabel* aLabelSizeLbl = new QLabel( tr( "LBL_LABEL_W" ), aDimGrp );
305
306   myBarWidthSpin = new QSpinBox( aDimGrp );
307   myBarWidthSpin->setRange( 0, 100 );
308   myBarWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
309   myBarWidthSpin->setMinimumWidth( 70 );
310   myBarWidthSpin->setValue( 0 );
311   myBarWidthSpin->setSpecialValueText( tr( "AUTO" ) );
312   QLabel* aBarWidthLbl = new QLabel( tr( "LBL_BAR_W" ), aDimGrp );
313
314   myBarHeightSpin = new QSpinBox( aDimGrp );
315   myBarHeightSpin->setRange( 0, 100 );
316   myBarHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
317   myBarHeightSpin->setMinimumWidth( 70 );
318   myBarHeightSpin->setValue( 0 );
319   myBarHeightSpin->setSpecialValueText( tr( "AUTO" ) );
320   QLabel* aBarHeightLbl = new QLabel( tr( "LBL_BAR_H" ), aDimGrp );
321
322   // format and units
323
324   QLabel* aPrecLbl = new QLabel( tr( "PRECISION" ), aDimGrp );
325   myPrecisionSpin = new QSpinBox( aDimGrp );
326   myPrecisionSpin->setRange( 1, 100 );
327
328   myUnitsChk = new QCheckBox( tr( "LBL_SHOW_UNITS" ), aDimGrp );
329
330   // layout
331
332   aDimGrpLay->addWidget( aTitleSizeLbl,  0, 0 );
333   aDimGrpLay->addWidget( myTitleSizeSpin,   0, 1 );
334   aDimGrpLay->addWidget( aLabelSizeLbl,  0, 2 );
335   aDimGrpLay->addWidget( myLabelSizeSpin,   0, 3 );
336   aDimGrpLay->addWidget( aBarWidthLbl,   1, 0 );
337   aDimGrpLay->addWidget( myBarWidthSpin,    1, 1 );
338   aDimGrpLay->addWidget( aBarHeightLbl,  1, 2 );
339   aDimGrpLay->addWidget( myBarHeightSpin,   1, 3 );
340   aDimGrpLay->addWidget( aPrecLbl, 2, 0 );
341   aDimGrpLay->addWidget( myPrecisionSpin, 2, 1 );
342   aDimGrpLay->addWidget( myUnitsChk, 2, 2, 1, 2 );
343
344   aMainLay->addWidget( aDimGrp );
345
346   // Common buttons ===========================================================
347
348   QGroupBox* GroupButtons = new QGroupBox( this );
349   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
350   GroupButtonsLayout->setAlignment( Qt::AlignTop );
351   GroupButtonsLayout->setSpacing( 6 );
352   GroupButtonsLayout->setMargin( 11 );
353
354   QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons );
355   buttonOk->setAutoDefault( true );
356   buttonOk->setDefault( true );
357
358   QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons );
359   buttonCancel->setAutoDefault( true );
360
361   QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons );
362   buttonHelp->setAutoDefault( true );
363
364   GroupButtonsLayout->addWidget( buttonOk );
365   GroupButtonsLayout->addSpacing( 5 );
366   GroupButtonsLayout->addStretch();
367   GroupButtonsLayout->addWidget( buttonCancel );
368   GroupButtonsLayout->addWidget( buttonHelp );
369
370   aMainLay->addWidget( GroupButtons );
371
372   connect( buttonOk,        SIGNAL( clicked() ),           this, SLOT( accept() ) );
373   connect( buttonCancel,    SIGNAL( clicked() ),           this, SLOT( reject() ) );
374   connect( buttonHelp,      SIGNAL( clicked() ),           this, SLOT( onHelp() ) );
375   connect( myTitleSizeSpin,  SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
376   connect( myLabelSizeSpin,  SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
377   connect( myBarWidthSpin,    SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
378   connect( myBarHeightSpin,   SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
379   connect( myUnitsChk,         SIGNAL( toggled( bool ) ),     this, SIGNAL( updatePreview() ) );
380   connect( myPrecisionSpin,  SIGNAL( valueChanged( int ) ), this, SIGNAL( updatePreview() ) );
381 }
382
383
384 //----------------------------------------------------------------------------
385 void VisuGUI_BarPrefDlg::setRatios( int titleRatioSize, int labelRatioWidth,
386                                     int barRatioWidth, int barRatioHeight )
387 {
388   myTitleSizeSpin->setValue( myTitleSize = titleRatioSize );
389   myLabelSizeSpin->setValue( myLabelSize = labelRatioWidth );
390   myBarWidthSpin->setValue( myBarWidth = barRatioWidth );
391   myBarHeightSpin->setValue( myBarHeight = barRatioHeight );
392 }
393
394
395 //----------------------------------------------------------------------------
396 void VisuGUI_BarPrefDlg::getRatios( int& titleRatioSize, int& labelRatioWidth,
397                                     int& barRatioWidth, int& barRatioHeight )
398 {
399   titleRatioSize  = myTitleSizeSpin->value();
400   labelRatioWidth  = myLabelSizeSpin->value();
401   barRatioWidth    = myBarWidthSpin->value();
402   barRatioHeight   = myBarHeightSpin->value();
403 }
404
405
406 //----------------------------------------------------------------------------
407 void VisuGUI_BarPrefDlg::setLabelsPrecision( const int p )
408 {
409   myPrecisionSpin->setValue( p );
410 }
411
412 //----------------------------------------------------------------------------
413 int VisuGUI_BarPrefDlg::getLabelsPrecision() const
414 {
415   return myPrecisionSpin->value();
416 }
417
418 //----------------------------------------------------------------------------
419 void VisuGUI_BarPrefDlg::setOrientation( const int ori )
420 {
421   myOrientation = ori;
422 }
423
424 //----------------------------------------------------------------------------
425
426 int VisuGUI_BarPrefDlg::getOrientation() const
427 {
428   return myOrientation;
429 }
430
431 //----------------------------------------------------------------------------
432 void VisuGUI_BarPrefDlg::onHelp()
433 {
434   QString aHelpFileName = "scalar_map_page.html";
435   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
436   if (app) {
437     VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
438     app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
439   }
440   else {
441     SUIT_MessageBox::warning( this, tr( "WRN_WARNING" ),
442                               tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
443                               arg( app->resourceMgr()->stringValue( "ExternalBrowser",
444                                                                     "application" ) ).
445                               arg( aHelpFileName ) );
446   }
447 }
448
449
450 //----------------------------------------------------------------------------
451 void VisuGUI_BarPrefDlg::setUnitsVisible(bool isVisible)
452 {
453   myUnitsChk->setChecked( myUnits = isVisible );
454 }
455
456
457 //----------------------------------------------------------------------------
458 bool VisuGUI_BarPrefDlg::isUnitsVisible()
459 {
460   return myUnitsChk->isChecked();
461 }
462
463
464 //----------------------------------------------------------------------------
465 /*!
466   Called when <Cancel> button is clicked, restore begin values
467 */
468 void VisuGUI_BarPrefDlg::reject()
469 {
470   myTitleSizeSpin->setValue( myTitleSize );
471   myLabelSizeSpin->setValue( myLabelSize );
472   myBarWidthSpin->setValue( myBarWidth );
473   myBarHeightSpin->setValue( myBarHeight );
474   myUnitsChk->setChecked( myUnits );
475   myPrecisionSpin->setValue( myPrecision );
476   QDialog::reject();
477 }
478
479
480 //----------------------------------------------------------------------------
481 /*!
482   Called when <Ok> button is clicked, store begin values
483 */
484 void VisuGUI_BarPrefDlg::accept()
485 {
486   QString dVal;
487   int aBWH = myOrientation == 1 ? myBarWidthSpin->value() : myBarHeightSpin->value();
488   if( ( myLabelSizeSpin->value()+ aBWH ) > 100 )
489   {
490     SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE" ) );
491     return;
492   }
493
494   if ( myTitleSizeSpin->value() > 100 )
495   {
496     SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE_TLT" ) );
497     return;
498   }
499
500   myTitleSize = myTitleSizeSpin->value();
501   myLabelSize = myLabelSizeSpin->value();
502   myBarWidth = myBarWidthSpin->value();
503   myBarHeight = myBarHeightSpin->value();
504   myUnits = myUnitsChk->isChecked();
505   myPrecision = myPrecisionSpin->value();
506   QDialog::accept();
507 }
508
509
510 //----------------------------------------------------------------------------
511 /*!
512   Provides help on F1 button click
513 */
514 void VisuGUI_BarPrefDlg::keyPressEvent( QKeyEvent* e )
515 {
516   QDialog::keyPressEvent( e );
517   if ( e->isAccepted() )
518     return;
519
520   if ( e->key() == Qt::Key_F1 ) {
521     e->accept();
522     onHelp();
523   }
524 }
525
526
527 //-----------------------------------------------------------------------
528 // Scalar Bar Pane
529 //-----------------------------------------------------------------------
530
531 /*!
532   Constructor
533 */
534 VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool theIsDisplayGaussMetric, bool thePreview )
535   : QWidget( parent ),
536     myPreviewActor( 0 ),
537     myScalarMap( 0 ),
538     myScalarMapPL( 0 ),
539     myIsDisplayGaussMetric( theIsDisplayGaussMetric )
540 {
541   QVBoxLayout* aMainLayout = new QVBoxLayout( this );
542   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
543   QString propertyName;
544   propertyName = QString("scalar_bar_vertical_");
545   myVerX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
546   myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
547   myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
548   myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
549   myVerTS = aResourceMgr->integerValue("VISU", propertyName + "title_size", 0);
550   myVerLS = aResourceMgr->integerValue("VISU", propertyName + "label_size", 0);
551   myVerBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0);
552   myVerBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0);
553
554   propertyName = QString("scalar_bar_horizontal_");
555   myHorX  = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
556   myHorY  = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
557   myHorW  = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
558   myHorH  = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
559   myHorTS = aResourceMgr->integerValue("VISU", propertyName + "title_size", 0);
560   myHorLS = aResourceMgr->integerValue("VISU", propertyName + "label_size", 0);
561   myHorBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0);
562   myHorBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0);
563
564   //aMainLayout->setSpacing(6);
565
566   // Range ============================================================
567   RangeGroup = new QButtonGroup ( this );
568   QGroupBox* aGB = new QGroupBox( tr("SCALAR_RANGE_GRP"),this  );
569   aMainLayout->addWidget( aGB );
570   QGridLayout* RangeGroupLayout = new QGridLayout( aGB );
571   RangeGroupLayout->setAlignment( Qt::AlignTop );
572   //RangeGroupLayout->setSpacing( 6 );
573   //RangeGroupLayout->setMargin( 11 );
574
575   myModeLbl = new QLabel("Scalar Mode", aGB);
576
577   myModeCombo = new QComboBox(aGB);
578
579   CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), aGB);
580   CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
581
582   myGaussMetricLabel = new QLabel( tr("VISU_GAUSS_METRIC"), aGB );
583   myGaussMetric = new QComboBox( aGB );
584   myGaussMetric->addItem( tr("VISU_GAUSS_METRIC_AVERAGE") );
585   myGaussMetric->addItem( tr("VISU_GAUSS_METRIC_MINIMUM") );
586   myGaussMetric->addItem( tr("VISU_GAUSS_METRIC_MAXIMUM") );
587   myGaussMetric->setToolTip( tr("VISU_GAUSS_METRIC_TOOLTIP") );
588
589   if( !myIsDisplayGaussMetric ) {
590     myGaussMetricLabel->hide();
591     myGaussMetric->hide();
592   }
593
594   RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), aGB);
595   RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), aGB);
596   RangeGroup->addButton( RBFrange, 0 );
597   RangeGroup->addButton( RBIrange, 1 );
598   RBFrange->setChecked( true );
599
600   int aPrecision = aResourceMgr->integerValue( "VISU", "floating_point_precision", 0 );
601   QDoubleValidator* dv = new QDoubleValidator(this);
602   dv->setDecimals(aPrecision);
603
604   MinEdit = new QLineEdit( aGB );
605   MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
606   //MinEdit->setMinimumWidth( 70 );
607   MinEdit->setValidator( dv );
608   MinEdit->setText( "0.0" );
609   QLabel* MinLabel = new QLabel (tr("LBL_MIN"), aGB);
610   MinLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
611   MinLabel->setBuddy(MinEdit);
612
613   MaxEdit = new QLineEdit( aGB );
614   MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
615   //MaxEdit->setMinimumWidth( 70 );
616   MaxEdit->setValidator( dv );
617   MaxEdit->setText( "0.0" );
618   QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), aGB);
619   MaxLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
620   MaxLabel->setBuddy(MaxEdit);
621
622   RangeGroupLayout->addWidget( myModeLbl, 0, 0, 1, 1 );
623   RangeGroupLayout->addWidget( myModeCombo, 0, 1, 1, 2);
624   RangeGroupLayout->addWidget( CBLog, 0, 3, 1, 1);
625   RangeGroupLayout->addWidget( myGaussMetricLabel, 1, 0, 1, 1);
626   RangeGroupLayout->addWidget( myGaussMetric, 1, 1, 1, 3);
627   RangeGroupLayout->addWidget( RBFrange, 2, 0, 1, 2);
628   RangeGroupLayout->addWidget( RBIrange, 2, 2, 1, 2);
629   RangeGroupLayout->addWidget( MinLabel, 3, 0 );
630   RangeGroupLayout->addWidget( MinEdit,  3, 1 );
631   RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
632   RangeGroupLayout->addWidget( MaxEdit,  3, 3 );
633
634   // Colors and Labels ========================================================
635   QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this);
636   aMainLayout->addWidget( ColLabGroup );
637   QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup );
638   ColLabGroupLayout->setAlignment( Qt::AlignTop );
639   //ColLabGroupLayout->setSpacing( 6 );
640   //ColLabGroupLayout->setMargin( 11 );
641
642   QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup);
643   ColorSpin = new QSpinBox( ColLabGroup );
644   ColorSpin->setMinimum( 2 );
645   ColorSpin->setMaximum( 256 );
646   ColorSpin->setSingleStep( 1 );
647   ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
648   //ColorSpin->setMinimumWidth( 70 );
649   ColorSpin->setValue( 64 );
650
651   QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup);
652   LabelSpin = new QSpinBox( ColLabGroup );
653   LabelSpin->setMinimum( 2 );
654   LabelSpin->setMaximum( 65 );
655   LabelSpin->setSingleStep( 1 );
656
657   LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
658   //LabelSpin->setMinimumWidth( 70 );
659   LabelSpin->setValue( 5 );
660
661   ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
662   ColLabGroupLayout->addWidget( ColorSpin,  0, 1);
663   ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
664   ColLabGroupLayout->addWidget( LabelSpin,  0, 3);
665
666   // Orientation ==========================================================
667   QButtonGroup* OrientGroup = new QButtonGroup ( this );
668   QGroupBox* OrientGB = new QGroupBox( tr("ORIENTATION_GRP"),this );
669   aMainLayout->addWidget( OrientGB );
670   QGridLayout* OrientGroupLayout = new QGridLayout( OrientGB );
671   OrientGroupLayout->setAlignment( Qt::AlignTop );
672   //OrientGroupLayout->setSpacing( 6 );
673   //OrientGroupLayout->setMargin( 11 );
674
675   RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGB);
676   RBvert->setChecked( true );
677   RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGB);
678   OrientGroup->addButton( RBvert );
679   OrientGroup->addButton( RBhori );
680   OrientGroupLayout->addWidget( RBvert, 0, 0 );
681   OrientGroupLayout->addWidget( RBhori, 0, 1 );
682
683   // Origin ===============================================================
684   QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this);
685   aMainLayout->addWidget( OriginGroup );
686   QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup );
687   OriginGroupLayout->setAlignment( Qt::AlignTop );
688   //OriginGroupLayout->setSpacing( 6 );
689   //OriginGroupLayout->setMargin( 11 );
690
691   QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup);
692   XSpin = new QtxDoubleSpinBox( OriginGroup );
693   VISU::initSpinBox(XSpin, 0.0, +1.0);
694   XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
695   //XSpin->setMinimumWidth( 70 );
696   XSpin->setValue( 0.01 );
697
698   QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup);
699   YSpin = new QtxDoubleSpinBox( OriginGroup );
700   VISU::initSpinBox(YSpin, 0.0, +1.0);
701   YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
702   //YSpin->setMinimumWidth( 70 );
703   YSpin->setValue( 0.1 );
704
705   OriginGroupLayout->addWidget( XLabel, 0, 0);
706   OriginGroupLayout->addWidget( XSpin,  0, 1);
707   OriginGroupLayout->addWidget( YLabel, 0, 2);
708   OriginGroupLayout->addWidget( YSpin,  0, 3);
709
710   // Dimensions =========================================================
711   QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this );
712   aMainLayout->addWidget( DimGroup );
713   QGridLayout* DimGroupLayout = new QGridLayout( DimGroup );
714   DimGroupLayout->setAlignment( Qt::AlignTop );
715   //DimGroupLayout->setSpacing( 6 );
716   //DimGroupLayout->setMargin( 11 );
717
718   QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup);
719   WidthSpin = new QtxDoubleSpinBox( DimGroup );
720   VISU::initSpinBox(WidthSpin, 0.0, +1.0);
721   WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
722   //WidthSpin->setMinimumWidth( 70 );
723   WidthSpin->setValue( 0.1 );
724
725   QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup);
726   HeightSpin = new QtxDoubleSpinBox( DimGroup );
727   VISU::initSpinBox(HeightSpin, 0.0, +1.0);
728   HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
729   //HeightSpin->setMinimumWidth( 70 );
730   HeightSpin->setValue( 0.8 );
731
732   DimGroupLayout->addWidget( WidthLabel, 0, 0);
733   DimGroupLayout->addWidget( WidthSpin,  0, 1);
734   DimGroupLayout->addWidget( HeightLabel, 0, 2);
735   DimGroupLayout->addWidget( HeightSpin,  0, 3);
736
737   // Save check box ===========================================================
738   QWidget* aSaveBox = new QWidget(this);
739   aMainLayout->addWidget( aSaveBox );
740   QHBoxLayout* aVBLay = new QHBoxLayout( aSaveBox );
741   aVBLay->addWidget( myTextBtn = new QPushButton("Text properties...", aSaveBox) );
742   aVBLay->addWidget( myBarBtn  = new QPushButton("Bar properties...",  aSaveBox) );
743
744   aMainLayout->addWidget( myTextDlg = new VisuGUI_TextPrefDlg(this) );
745   myTextDlg->setTitleVisible(!thePreview);
746   myBarDlg = new VisuGUI_BarPrefDlg(this);
747
748   QGroupBox* CheckGroup = new QGroupBox("", this );
749   aMainLayout->addWidget( CheckGroup );
750   //QHBoxLayout* CheckGroupLayout = new QHBoxLayout( CheckGroup );
751   QGridLayout* CheckGroupLayout = new QGridLayout( CheckGroup );
752
753   myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), CheckGroup);
754   myPreviewCheck->setChecked(false);
755   CheckGroupLayout->addWidget(myPreviewCheck, 0, 0);
756
757   myHideBar = new QCheckBox(tr("HIDE_SCALAR_BAR"), CheckGroup);
758   myHideBar->setChecked(false);
759   CheckGroupLayout->addWidget(myHideBar, 0, 1);
760
761 // RKV : Begin
762   CBDistr = new QCheckBox (tr("SHOW_DISTRIBUTION"), CheckGroup);
763   CheckGroupLayout->addWidget(CBDistr, 1, 0);
764 // RKV : End
765   if (!thePreview) {
766     CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), CheckGroup);
767     CheckGroupLayout->addWidget( CBSave, 1, 1 );
768   }
769   else {
770     CBSave = 0;
771     myPreviewCheck->hide();
772     CheckGroup->hide();
773   }
774
775   if(RBvert->isChecked()) {
776     myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH);
777   } else {
778     myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH);
779   }
780
781   int lp = aResourceMgr->integerValue( "VISU", propertyName + "scalar_bar_label_precision", 3 );
782   myBarDlg->setLabelsPrecision( lp );
783
784   myBarDlg->setUnitsVisible(aResourceMgr->booleanValue("VISU", propertyName + "display_units", true));
785
786   // signals and slots connections ===========================================
787   connect( RBFrange,   SIGNAL( toggled( bool ) ), this, SLOT( onFieldRange( bool ) ) );
788   connect( RBIrange,   SIGNAL( toggled( bool ) ), this, SLOT( onImposedRange( bool ) ) );
789
790   connect( myModeCombo,    SIGNAL( activated( int ) ),       this, SLOT( changeScalarMode( int ) ) );
791   connect( myGaussMetric,  SIGNAL( activated( int ) ),       this, SLOT( changeGaussMetric( int ) ) );
792   connect( OrientGroup,    SIGNAL( buttonClicked( int ) ),   this, SLOT( changeDefaults( int ) ) );
793   connect( XSpin,          SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
794   connect( YSpin,          SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
795   connect( myTextBtn,      SIGNAL( clicked() ),              this, SLOT( onTextPref() ) );
796   connect( myBarBtn,       SIGNAL( clicked() ),              this, SLOT( onBarPref() ) );
797   connect( myPreviewCheck, SIGNAL( toggled( bool )),         this, SLOT( onPreviewCheck( bool ) ) );
798
799   connect( CBDistr,        SIGNAL( toggled( bool ) ),        this, SLOT( onShowDistribution( bool ) )); // RKV
800
801   connect( ColorSpin,      SIGNAL( valueChanged( int ) ),    this, SLOT( updatePreview() ));
802   connect( LabelSpin,      SIGNAL( valueChanged( int ) ),    this, SLOT( updatePreview() ));
803   connect( WidthSpin,      SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
804   connect( HeightSpin,     SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
805   connect( CBLog,          SIGNAL( toggled( bool ) ),        this, SLOT( updatePreview() ));
806   connect( myBarDlg,       SIGNAL( updatePreview() ),        this, SLOT( updatePreview() ));
807   changeDefaults( 0 );
808   myIsStoreTextProp = false;
809   myBusy = false;
810 }
811
812 /**
813  * Stores dialog values to resources
814  */
815 void VisuGUI_ScalarBarPane::storeToResources() {
816   int orient = (RBvert->isChecked())? 0 : 1;
817   float sbX1   = XSpin->value();
818   float sbY1   = YSpin->value();
819   float sbW    = WidthSpin->value();
820   float sbH    = HeightSpin->value();
821   int sbCol  = ColorSpin->value();
822   int sbLab  = LabelSpin->value();
823
824   if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
825     if(orient == 0) {
826       sbX1=0.01;
827       sbY1=0.1;
828       sbW=0.1;
829       sbH=0.8;
830     } else {
831       sbX1=0.1;
832       sbY1=0.01;
833       sbW=0.8;
834       sbH=0.08;
835     }
836   }
837
838   bool sbRange = RBIrange->isChecked();
839   float sbVmin = (float)(MinEdit->text().toDouble());
840   float sbVmax = (float)(MaxEdit->text().toDouble());
841
842   if(sbVmin > sbVmax) {
843     sbVmin=0.;
844     sbVmax=0.;
845   }
846
847   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
848
849   aResourceMgr->setValue("VISU", "scalar_bar_orientation", orient);
850
851   QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
852
853   aResourceMgr->setValue("VISU", propertyName + "x", sbX1);
854   aResourceMgr->setValue("VISU", propertyName + "y", sbY1);
855   aResourceMgr->setValue("VISU", propertyName + "width", sbW);
856   aResourceMgr->setValue("VISU", propertyName + "height", sbH);
857
858   aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol);
859   aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab);
860
861   if(sbRange)
862     {
863       aResourceMgr->setValue("VISU", "scalar_range_type", 1);
864       aResourceMgr->setValue("VISU", "scalar_range_min" ,sbVmin);
865       aResourceMgr->setValue("VISU", "scalar_range_max" ,sbVmax);
866     }
867   else
868     aResourceMgr->setValue("VISU", "scalar_range_type", 0);
869
870   aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic());
871   aResourceMgr->setValue("VISU", "scalar_bar_show_distribution", isShowDistribution()); // RKV
872
873   ////
874
875   if (myIsStoreTextProp) {
876     // "Title"
877     QColor aTitleColor (255, 255, 255);
878     int aTitleFontFamily = VTK_ARIAL;
879     bool isTitleBold = false;
880     bool isTitleItalic = false;
881     bool isTitleShadow = false;
882
883     myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily,
884                                     isTitleBold, isTitleItalic, isTitleShadow);
885
886     QFont aTitleFont;
887
888     aTitleFont.setBold(isTitleBold);
889     aTitleFont.setItalic(isTitleItalic);
890     aTitleFont.setOverline(isTitleShadow);
891
892     QString titleFontFamily;
893     switch (aTitleFontFamily) {
894     case VTK_ARIAL:
895       titleFontFamily = "Arial";
896       break;
897     case VTK_COURIER:
898       titleFontFamily = "Courier";
899       break;
900     case VTK_TIMES:
901       titleFontFamily = "Times";
902       break;
903     }
904     aTitleFont.setFamily(titleFontFamily);
905
906     aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont);
907
908     aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor);
909
910     // "Label"
911     QColor aLabelColor (255, 255, 255);
912     int aLabelFontFamily = VTK_ARIAL;
913     bool isLabelBold = false;
914     bool isLabelItalic = false;
915     bool isLabelShadow = false;
916
917     myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
918                                     isLabelBold, isLabelItalic, isLabelShadow);
919
920
921     QFont aLabelFont;
922
923     aLabelFont.setBold(isLabelBold);
924     aLabelFont.setItalic(isLabelItalic);
925     aLabelFont.setOverline(isLabelShadow);
926
927     QString labelFontFamily;
928     switch (aLabelFontFamily) {
929     case VTK_ARIAL:
930       labelFontFamily = "Arial";
931       break;
932     case VTK_COURIER:
933       labelFontFamily = "Courier";
934       break;
935     case VTK_TIMES:
936       labelFontFamily = "Times";
937       break;
938     }
939
940     aLabelFont.setFamily(labelFontFamily);
941
942     aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont);
943
944     aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor);
945   }
946 }
947
948 //----------------------------------------------------------------------------
949 VisuGUI_ScalarBarPane::~VisuGUI_ScalarBarPane()
950 {
951   deleteScalarBar();
952   if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
953     aViewWindow->Repaint();
954 }
955
956 //----------------------------------------------------------------------------
957 /**
958  * Initialise dialog box from presentation object
959  */
960 void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs)
961 {
962   myScalarMap = dynamic_cast<VISU::ScalarMap_i*>(thePrs);
963
964   if( !myScalarMap )
965     return;
966
967   switch(myScalarMap->GetScaling()){
968   case VISU::LOGARITHMIC :
969     setLogarithmic(true);
970     break;
971   default:
972     setLogarithmic(false);
973   }
974
975   // Update myModeCombo
976   const VISU::PField& aField = myScalarMap->GetScalarField();
977   const VISU::TNames& aCompNames = aField->myCompNames;
978   const VISU::TNames& aUnitNames = aField->myUnitNames;
979   int aNbComp = aField->myNbComp;
980   bool isScalarMode = (aNbComp > 1);
981   myModeCombo->clear();
982   myModeCombo->addItem("<Modulus>");
983   for(int i = 0; i < aNbComp; i++){
984     QString aComponent = QString(aCompNames[i].c_str()).simplified();
985     if(aComponent.isNull() || aComponent == "")
986       aComponent = "Component " + QString::number(i+1);
987     else
988       aComponent = "[" + QString::number(i+1) + "] " + aComponent;
989
990     QString anUnit = QString(aUnitNames[i].c_str()).simplified();
991     if(anUnit.isNull() || anUnit == "")
992       anUnit = "-";
993
994     aComponent = aComponent + ", " + anUnit;
995
996     myModeCombo->addItem(aComponent);
997   }
998
999   myModeCombo->setCurrentIndex(myScalarMap->GetScalarMode());
1000   if ( aNbComp == 1 )
1001     myModeCombo->setCurrentIndex(1);
1002
1003   myModeLbl->setEnabled(isScalarMode);
1004   myModeCombo->setEnabled(isScalarMode);
1005
1006   // Gauss Metric option should be visible only if at least one
1007   // of mesh values on geometry is based on multiple gauss points
1008   bool isEnableGaussMetric = false;
1009   if( myIsDisplayGaussMetric ) {
1010     const VISU::TValField& aValField = aField->myValField;
1011     VISU::TValField::const_iterator anIter = aValField.find(myScalarMap->GetScalarTimeStampNumber());
1012     if ( anIter != aValField.end() ) {
1013       VISU::PValForTime aValForTime = anIter->second;
1014       if( aValForTime && aValForTime->GetMaxNbGauss() > 1 )
1015         isEnableGaussMetric = true;
1016     }
1017   }
1018
1019   myGaussMetricLabel->setEnabled(isEnableGaussMetric);
1020   myGaussMetric->setEnabled(isEnableGaussMetric);
1021   if( isEnableGaussMetric )
1022     myGaussMetric->setCurrentIndex((int)myScalarMap->GetGaussMetric());
1023
1024   setRange( myScalarMap->GetMin(), myScalarMap->GetMax(), myScalarMap->IsRangeFixed() );
1025
1026   setScalarBarData( myScalarMap->GetNbColors(), myScalarMap->GetLabels() );
1027   setShowDistribution( myScalarMap->GetIsDistributionVisible() );
1028
1029   // "Title"
1030   CORBA::String_var aTitle = myScalarMap->GetTitle();
1031   myTextDlg->setTitleText(aTitle.in());
1032   myTitle = aTitle.in();
1033
1034   setPosAndSize( myScalarMap->GetPosX(),
1035                  myScalarMap->GetPosY(),
1036                  myScalarMap->GetWidth(),
1037                  myScalarMap->GetHeight(),
1038                  myScalarMap->GetBarOrientation());
1039
1040   if(RBvert->isChecked()) {
1041     myVerTS = myScalarMap->GetTitleSize();
1042     myVerLS = myScalarMap->GetLabelSize();
1043     myVerBW = myScalarMap->GetBarWidth();
1044     myVerBH = myScalarMap->GetBarHeight();
1045     myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1046   } else {
1047     myHorTS = myScalarMap->GetTitleSize();
1048     myHorLS = myScalarMap->GetLabelSize();
1049     myHorBW = myScalarMap->GetBarWidth();
1050     myHorBH = myScalarMap->GetBarHeight();
1051     myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1052   }
1053
1054   myBarDlg->setLabelsPrecision( VISU::ToPrecision( myScalarMap->GetLabelsFormat() ) );
1055   myBarDlg->setUnitsVisible(myScalarMap->IsUnitsVisible());
1056
1057   vtkFloatingPointType R, G, B;
1058   myScalarMap->GetTitleColor(R, G, B);
1059
1060   QColor aTextColor = QColor((int)(R*255.), (int)(G*255.), (int)(B*255.));
1061
1062   myTextDlg->myTitleFont->SetData(aTextColor,
1063                                   myScalarMap->GetTitFontType(),
1064                                   myScalarMap->IsBoldTitle(),
1065                                   myScalarMap->IsItalicTitle(),
1066                                   myScalarMap->IsShadowTitle());
1067
1068   // "Labels"
1069   myScalarMap->GetLabelColor(R, G, B);
1070
1071   QColor aLabelColor = QColor((int)(R*255.), (int)(G*255.), (int)(B*255.));
1072
1073   myTextDlg->myLabelFont->SetData(aLabelColor,
1074                                   myScalarMap->GetLblFontType(),
1075                                   myScalarMap->IsBoldLabel(),
1076                                   myScalarMap->IsItalicLabel(),
1077                                   myScalarMap->IsShadowLabel());
1078
1079   myHideBar->setChecked(!myScalarMap->IsBarVisible());
1080
1081   // Draw Preview
1082   if (myPreviewCheck->isChecked()) {
1083     createScalarBar();
1084     updatePreview();
1085   }
1086
1087 }
1088
1089
1090 //----------------------------------------------------------------------------
1091 /*! Slot update preview of scalar bar, if preview is checked
1092  */
1093 void VisuGUI_ScalarBarPane::updatePreview()
1094 {
1095   if (myPreviewCheck->isChecked()) {
1096     if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
1097       deleteScalarBar();
1098       createScalarBar();
1099       vf->Repaint();
1100     }
1101   }
1102 }
1103
1104 //----------------------------------------------------------------------------
1105 /*! Creating preview scalar bar
1106  */
1107 void VisuGUI_ScalarBarPane::createScalarBar()
1108 {
1109   if (VISU::GetActiveViewWindow<SVTK_ViewWindow>() == NULL) return;
1110   if (myPreviewActor != 0) return;
1111   if (myScalarMap == NULL) return;
1112
1113   if (!check()) return;
1114   myScalarMapPL = VISU_ScalarMapPL::New();
1115   if(myScalarMap->GetSpecificPL())
1116     myScalarMapPL->ShallowCopy(myScalarMap->GetSpecificPL(), true);
1117
1118   if ( myBusy ) return;
1119
1120   myBusy = true;
1121
1122   int sbCol,sbLab;
1123   sbCol = getNbColors();
1124   sbLab = getNbLabels();
1125   if(sbCol < 2) sbCol=2;
1126   if(sbCol > 64) sbCol=64;
1127   if(sbLab < 2) sbLab=2;
1128   if(sbLab > 65) sbLab=65;
1129   myPreviewActor = VISU_ScalarMapAct::New();
1130   VISU_ScalarBarActor* aScalarBarActor = myPreviewActor->GetScalarBar();
1131   myPreviewActor->GetScalarBar()->VisibilityOn();
1132   myPreviewActor->PickableOff();
1133   //myPreviewActor->SetBarVisibility(!myHideBar->isChecked());
1134
1135   myScalarMapPL->SetScalarMode(myModeCombo->currentIndex());
1136   if(isLogarithmic())
1137     myScalarMapPL->SetScaling(VISU::LOGARITHMIC);
1138   else
1139     myScalarMapPL->SetScaling(VISU::LINEAR);
1140
1141   if( myGaussMetric->isVisible() )
1142     myScalarMapPL->SetGaussMetric((VISU::TGaussMetric)myGaussMetric->currentIndex());
1143
1144   if ( RBFrange->isChecked() ) {
1145     myScalarMapPL->SetSourceRange();
1146   } else {
1147     vtkFloatingPointType aRange[2];
1148     aRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble();
1149     aRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble();
1150     myScalarMapPL->SetScalarRange( aRange );
1151   }
1152
1153   myScalarMapPL->SetNbColors(sbCol);
1154   myScalarMapPL->Update();
1155
1156   aScalarBarActor->SetLookupTable(myScalarMapPL->GetBarTable());
1157   aScalarBarActor->SetDistribution( myScalarMapPL->GetDistribution() );
1158   aScalarBarActor->SetDistributionVisibility( isShowDistribution() );
1159
1160   if (!myTextDlg->getTitleText().isEmpty()) {
1161     VISU::PValForTime aValForTime;
1162     const VISU::PField& aField = myScalarMap->GetScalarField();
1163     const VISU::TValField& aValField = aField->myValField;
1164     VISU::TValField::const_iterator anIter = aValField.find(myScalarMap->GetScalarTimeStampNumber());
1165     if (anIter != aValField.end())
1166       aValForTime = anIter->second;
1167
1168     if (aValForTime) {
1169       std::strstream aStream;
1170       const VISU::TTime& aTime = aValForTime->myTime;
1171       aStream<< myTextDlg->getTitleText().toLatin1().data() <<" ";
1172       if(myBarDlg->isUnitsVisible())
1173         aStream<<VISU_Convertor::GenerateName(aTime)<<std::ends;
1174       else {
1175         QString aName;
1176         aName.sprintf("%g", aTime.first);
1177         aStream << aName.toLatin1().data() << std::ends;
1178       }
1179       std::string aScalarBarTitle = aStream.str();
1180       aScalarBarActor->SetTitle(aScalarBarTitle.c_str());
1181     } else {
1182       aScalarBarActor->SetTitle(myTextDlg->getTitleText().toLatin1().data());
1183     }
1184   }
1185   else
1186     aScalarBarActor->SetTitle(myTitle.c_str());
1187   aScalarBarActor->SetOrientation(getOrientation());
1188   aScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
1189   aScalarBarActor->GetPositionCoordinate()->SetValue(getX(),getY());
1190   aScalarBarActor->SetWidth(getWidth());
1191   aScalarBarActor->SetHeight(getHeight());
1192   aScalarBarActor->SetNumberOfLabels(sbLab);
1193   aScalarBarActor->SetMaximumNumberOfColors(sbCol);
1194
1195   // title text property
1196   QColor aTitleColor;
1197   int aTitleFontFamily;
1198   bool isTitleBold;
1199   bool isTitleItalic;
1200   bool isTitleShadow;
1201   myTextDlg->myTitleFont->GetData(aTitleColor,aTitleFontFamily,
1202                                   isTitleBold,isTitleItalic,isTitleShadow);
1203   vtkTextProperty* aTitleProp = aScalarBarActor->GetTitleTextProperty();
1204   aTitleProp->SetFontFamily(aTitleFontFamily);
1205   aTitleProp->SetColor(vtkFloatingPointType(aTitleColor.red())/255.,
1206                        vtkFloatingPointType(aTitleColor.green())/255.,
1207                        vtkFloatingPointType(aTitleColor.blue())/255.);
1208   (isTitleBold)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
1209   (isTitleItalic)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
1210   (isTitleShadow)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
1211
1212   // label text property
1213   QColor aLabelColor;
1214   int aLabelFontFamily;
1215   bool isLabelBold;
1216   bool isLabelItalic;
1217   bool isLabelShadow;
1218   myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
1219                                   isLabelBold, isLabelItalic, isLabelShadow);
1220   vtkTextProperty* aLabelProp = aScalarBarActor->GetLabelTextProperty();
1221   aLabelProp->SetFontFamily(aLabelFontFamily);
1222   aLabelProp->SetColor(vtkFloatingPointType(aLabelColor.red())/255.,
1223                        vtkFloatingPointType(aLabelColor.green())/255.,
1224                        vtkFloatingPointType(aLabelColor.blue())/255.);
1225   (isLabelBold)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
1226   (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
1227   (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
1228
1229   int VerTS, VerLS, VerBW, VerBH;
1230   myBarDlg->getRatios(VerTS, VerLS, VerBW, VerBH);
1231   aScalarBarActor->SetRatios(VerTS, VerLS, VerBW, VerBH);
1232
1233   std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() );
1234   aScalarBarActor->SetLabelFormat( f.c_str() );
1235
1236   aScalarBarActor->Modified();
1237
1238   VISU::GetActiveViewWindow<SVTK_ViewWindow>()->AddActor(myPreviewActor);
1239
1240   myBusy = false;
1241 }
1242
1243
1244 //----------------------------------------------------------------------------
1245 /*! Deleting preview scalar bar
1246  */
1247 void VisuGUI_ScalarBarPane::deleteScalarBar()
1248 {
1249   if ( myBusy ) return;
1250
1251   if (myPreviewActor == 0) return;
1252   vtkRenderer* aRend       = myPreviewActor->GetRenderer();
1253   vtkRenderWindow* aWnd = aRend->GetRenderWindow();
1254   if(aRend && aWnd)
1255     myPreviewActor->RemoveFromRender(aRend);
1256   myPreviewActor->GetScalarBar()->VisibilityOff();
1257   myPreviewActor->Delete();
1258   myPreviewActor = 0;
1259
1260   if (myScalarMapPL){
1261     myScalarMapPL->Delete();
1262     myScalarMapPL = 0;
1263   }
1264 }
1265
1266
1267 //----------------------------------------------------------------------------
1268 /**
1269  * Store values to presentation object
1270  */
1271 int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) {
1272   if( !myScalarMap )
1273     return 0;
1274
1275   myScalarMap->SetScalarMode(myModeCombo->currentIndex());
1276   if( myGaussMetric->isVisible() )
1277     myScalarMap->SetGaussMetric((VISU::GaussMetric)myGaussMetric->currentIndex());
1278   myScalarMap->SetPosition(XSpin->value(), YSpin->value());
1279   myScalarMap->SetSize(WidthSpin->value(), HeightSpin->value());
1280   if(RBvert->isChecked()) {
1281     myScalarMap->SetRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1282   } else {
1283     myScalarMap->SetRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1284   }
1285
1286   std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() );
1287   myScalarMap->SetLabelsFormat( f.c_str() );
1288   myScalarMap->SetUnitsVisible(myBarDlg->isUnitsVisible());
1289
1290   myScalarMap->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3dBase::VERTICAL : VISU::ColoredPrs3dBase::HORIZONTAL);
1291   if(isLogarithmic())
1292     myScalarMap->SetScaling(VISU::LOGARITHMIC);
1293   else
1294     myScalarMap->SetScaling(VISU::LINEAR);
1295
1296   if ( RBFrange->isChecked() ) {
1297     myScalarMap->SetSourceRange();
1298   } else {
1299     myScalarMap->SetRange( MinEdit->text().toDouble(), MaxEdit->text().toDouble() );
1300   }
1301   myScalarMap->SetNbColors(ColorSpin->value());
1302   myScalarMap->SetLabels(LabelSpin->value());
1303   myScalarMap->SetIsDistributionVisible(isShowDistribution()); // RKV
1304
1305   myScalarMap->SetBarVisible(!myHideBar->isChecked());
1306
1307   if (isToSave()) storeToResources();
1308
1309   if (myIsStoreTextProp) {
1310     // "Title"
1311     myScalarMap->SetTitle(myTextDlg->getTitleText().toLatin1().data());
1312
1313     QColor aTitColor (255, 255, 255);
1314     int aTitleFontFamily = VTK_ARIAL;
1315     bool isTitleBold = false;
1316     bool isTitleItalic = false;
1317     bool isTitleShadow = false;
1318
1319     myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
1320                                     isTitleBold, isTitleItalic, isTitleShadow);
1321
1322     myScalarMap->SetBoldTitle(isTitleBold);
1323     myScalarMap->SetItalicTitle(isTitleItalic);
1324     myScalarMap->SetShadowTitle(isTitleShadow);
1325     myScalarMap->SetTitFontType(aTitleFontFamily);
1326     myScalarMap->SetTitleColor(aTitColor.red()/255.,
1327                           aTitColor.green()/255.,
1328                           aTitColor.blue()/255.);
1329
1330     // "Label"
1331     QColor aLblColor (255, 255, 255);
1332     int aLabelFontFamily = VTK_ARIAL;
1333     bool isLabelBold = false;
1334     bool isLabelItalic = false;
1335     bool isLabelShadow = false;
1336
1337     myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
1338                                     isLabelBold, isLabelItalic, isLabelShadow);
1339
1340     myScalarMap->SetBoldLabel(isLabelBold);
1341     myScalarMap->SetItalicLabel(isLabelItalic);
1342     myScalarMap->SetShadowLabel(isLabelShadow);
1343     myScalarMap->SetLblFontType(aLabelFontFamily);
1344     myScalarMap->SetLabelColor(aLblColor.red()/255.,
1345                                aLblColor.green()/255.,
1346                                aLblColor.blue()/255.);
1347     myIsStoreTextProp = false;
1348   }
1349
1350   return 1;
1351 }
1352
1353
1354 //----------------------------------------------------------------------------
1355 /*!
1356   Called when orientation is changed
1357 */
1358 void VisuGUI_ScalarBarPane::changeDefaults( int )
1359 {
1360   if ( RBvert->isChecked() ) {
1361     XSpin->setValue( myVerX );
1362     YSpin->setValue( myVerY );
1363     WidthSpin->setValue( myVerW );
1364     HeightSpin->setValue( myVerH );
1365   }
1366   else {
1367     XSpin->setValue( myHorX );
1368     YSpin->setValue( myHorY );
1369     WidthSpin->setValue( myHorW );
1370     HeightSpin->setValue( myHorH );
1371   }
1372   updatePreview();
1373 }
1374
1375
1376 //----------------------------------------------------------------------------
1377 /*!
1378   Called when Range mode is changed
1379 */
1380 void VisuGUI_ScalarBarPane::onFieldRange( bool isOn )
1381 {
1382   if (isOn) {
1383     myScalarMap->SetSourceRange();
1384     MinEdit->setEnabled( false );
1385     MaxEdit->setEnabled( false );
1386     changeScalarMode(myModeCombo->currentIndex());
1387   }
1388 }
1389
1390 void VisuGUI_ScalarBarPane::onImposedRange( bool isOn )
1391 {
1392   if (isOn) {
1393     myScalarMap->SetRange( myScalarMap->GetSourceMin(), myScalarMap->GetSourceMax() );
1394     MinEdit->setEnabled( true );
1395     MaxEdit->setEnabled( true );
1396     changeScalarMode(myModeCombo->currentIndex());
1397   }
1398 }
1399
1400 void VisuGUI_ScalarBarPane::onShowDistribution( bool isOn )
1401 {
1402   myScalarMap->SetIsDistributionVisible(isOn);
1403   updatePreview();
1404 }
1405
1406 void VisuGUI_ScalarBarPane::changeRange( int )
1407 {
1408   if ( RBFrange->isChecked() ) {
1409     myScalarMap->SetSourceRange();
1410     MinEdit->setEnabled( false );
1411     MaxEdit->setEnabled( false );
1412   } else {
1413     myScalarMap->SetRange( myScalarMap->GetSourceMin(), myScalarMap->GetSourceMax() );
1414     MinEdit->setEnabled( true );
1415     MaxEdit->setEnabled( true );
1416   }
1417
1418   changeScalarMode(myModeCombo->currentIndex());
1419 }
1420
1421
1422 //----------------------------------------------------------------------------
1423 /*!
1424   Called when X,Y position is changed
1425 */
1426 void VisuGUI_ScalarBarPane::XYChanged( double )
1427 {
1428   QtxDoubleSpinBox* snd = (QtxDoubleSpinBox*)sender();
1429   if ( snd == XSpin ) {
1430     WidthSpin->setMaximum( 1.0 - XSpin->value() );
1431   }
1432   if ( snd == YSpin ) {
1433     HeightSpin->setMaximum( 1.0 - YSpin->value() );
1434   }
1435   updatePreview();
1436 }
1437
1438
1439 //----------------------------------------------------------------------------
1440 /*!
1441   Called when scalar mode is changed
1442 */
1443 void VisuGUI_ScalarBarPane::changeScalarMode( int theMode )
1444 {
1445   myScalarMap->SetScalarMode(theMode);
1446
1447   if ( RBFrange->isChecked() ) {
1448     SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1449     int aPrecision = aResourceMgr->integerValue("VISU", "floating_point_precision", 0);
1450
1451     MinEdit->setText(QString::number(myScalarMap->GetSourceMin(), 'g', aPrecision));
1452     MaxEdit->setText(QString::number(myScalarMap->GetSourceMax(), 'g', aPrecision));
1453   }
1454
1455   updatePreview();
1456 }
1457
1458
1459 //----------------------------------------------------------------------------
1460 /*!
1461   Called when scalar mode is changed
1462 */
1463 void VisuGUI_ScalarBarPane::changeGaussMetric( int theGaussMetric )
1464 {
1465   myScalarMap->SetGaussMetric((VISU::GaussMetric)theGaussMetric);
1466
1467   if ( RBFrange->isChecked() ) {
1468     SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1469     int aPrecision = aResourceMgr->integerValue("VISU", "floating_point_precision", 0);
1470
1471     MinEdit->setText(QString::number(myScalarMap->GetSourceMin(), 'g', aPrecision));
1472     MaxEdit->setText(QString::number(myScalarMap->GetSourceMax(), 'g', aPrecision));
1473   }
1474
1475   updatePreview();
1476 }
1477
1478
1479 //----------------------------------------------------------------------------
1480 /*!
1481   Sets default values and range mode
1482 */
1483 void VisuGUI_ScalarBarPane::setRange( double imin, double imax, bool sbRange )
1484 {
1485   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1486   int aPrecision = aResourceMgr->integerValue("VISU", "floating_point_precision", 0);
1487
1488   MinEdit->setText(QString::number(imin, 'g', aPrecision));
1489   MaxEdit->setText(QString::number(imax, 'g', aPrecision));
1490
1491   if( sbRange )
1492     RBIrange->setChecked( true );
1493   else
1494     RBFrange->setChecked( true );
1495
1496   changeRange( sbRange );
1497 }
1498
1499
1500 //----------------------------------------------------------------------------
1501 /*!
1502   Sets and gets parameters
1503 */
1504 bool VisuGUI_ScalarBarPane::isIRange() {
1505   return RBIrange->isChecked();
1506 }
1507
1508
1509 //----------------------------------------------------------------------------
1510 double VisuGUI_ScalarBarPane::getMin() {
1511   return MinEdit->text().toDouble();
1512 }
1513
1514
1515 //----------------------------------------------------------------------------
1516 double VisuGUI_ScalarBarPane::getMax() {
1517   return MaxEdit->text().toDouble();
1518 }
1519
1520
1521 //----------------------------------------------------------------------------
1522 double VisuGUI_ScalarBarPane::getX() {
1523   return XSpin->value();
1524 }
1525
1526
1527 //----------------------------------------------------------------------------
1528 double VisuGUI_ScalarBarPane::getY() {
1529   return YSpin->value();
1530 }
1531
1532
1533 //----------------------------------------------------------------------------
1534 double VisuGUI_ScalarBarPane::getWidth() {
1535   return WidthSpin->value();
1536 }
1537
1538
1539 //----------------------------------------------------------------------------
1540 double VisuGUI_ScalarBarPane::getHeight() {
1541   return HeightSpin->value();
1542 }
1543
1544
1545 //----------------------------------------------------------------------------
1546 int VisuGUI_ScalarBarPane::getNbColors() {
1547   return ColorSpin->value();
1548 }
1549
1550
1551 //----------------------------------------------------------------------------
1552 int VisuGUI_ScalarBarPane::getNbLabels() {
1553   return LabelSpin->value();
1554 }
1555
1556
1557 //----------------------------------------------------------------------------
1558 bool VisuGUI_ScalarBarPane::isLogarithmic() {
1559   return CBLog->isChecked();
1560 }
1561
1562
1563 //----------------------------------------------------------------------------
1564 void VisuGUI_ScalarBarPane::setLogarithmic( bool on ) {
1565   CBLog->setChecked( on );
1566 }
1567
1568 //----------------------------------------------------------------------------
1569 bool VisuGUI_ScalarBarPane::isShowDistribution() {
1570   return CBDistr->isChecked();
1571 }
1572
1573
1574 //----------------------------------------------------------------------------
1575 void VisuGUI_ScalarBarPane::setShowDistribution( bool on ) {
1576   CBDistr->setChecked( on );
1577 }
1578
1579 // RKV : End
1580 //----------------------------------------------------------------------------
1581 bool VisuGUI_ScalarBarPane::isToSave() {
1582   return CBSave ? CBSave->isChecked() : false;
1583 }
1584
1585 //----------------------------------------------------------------------------
1586 /*!
1587   Sets size and position
1588 */
1589 void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
1590 {
1591   if ( vert ) {
1592     myVerX = x;
1593     myVerY = y;
1594     myVerW = w;
1595     myVerH = h;
1596     RBvert->setChecked( true );
1597   }
1598   else {
1599     myHorX = x;
1600     myHorY = y;
1601     myHorW = w;
1602     myHorH = h;
1603     RBhori->setChecked( true );
1604   }
1605   changeDefaults( 0 );
1606 }
1607
1608
1609 //----------------------------------------------------------------------------
1610 /*!
1611   Sets colors and labels number
1612 */
1613 void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
1614 {
1615   ColorSpin->setValue( colors );
1616   LabelSpin->setValue( labels );
1617 }
1618
1619
1620 //----------------------------------------------------------------------------
1621 /*!
1622   Gets orientation
1623 */
1624 int  VisuGUI_ScalarBarPane::getOrientation()
1625 {
1626   if (RBvert->isChecked() )
1627     return  1;
1628   else
1629     return 0;
1630 }
1631
1632
1633 //----------------------------------------------------------------------------
1634 /*!
1635   Called when <OK> button is clicked, validates data and closes dialog
1636 */
1637 bool VisuGUI_ScalarBarPane::check()
1638 {
1639   double minVal = MinEdit->text().toDouble();
1640   double maxVal = MaxEdit->text().toDouble();
1641   if ( RBIrange->isChecked() ) {
1642     if (minVal >= maxVal) {
1643       SUIT_MessageBox::warning( this,tr("WRN_VISU"),
1644                              tr("MSG_MINMAX_VALUES"),
1645                              tr("BUT_OK"));
1646       return false;
1647     }
1648   }
1649
1650   // check if logarithmic mode is on and check imposed range to not contain negative values
1651   if ( CBLog->isChecked() ) {
1652     if ( minVal <= 0.0 || maxVal <= 0.0 ) {
1653       if ( RBIrange->isChecked() ) {
1654         SUIT_MessageBox::warning( this,
1655                                   tr("WRN_VISU"),
1656                                   tr("WRN_LOGARITHMIC_RANGE"),
1657                                   tr("BUT_OK"));
1658       } else {
1659         if ( minVal == 0 || maxVal == 0 )
1660           SUIT_MessageBox::warning( this,
1661                                   tr("WRN_VISU"),
1662                                   tr("WRN_LOGARITHMIC_RANGE"),
1663                                   tr("BUT_OK"));
1664         else
1665           SUIT_MessageBox::warning( this,
1666                                     tr("WRN_VISU"),
1667                                     tr("WRN_LOGARITHMIC_FIELD_RANGE"),
1668                                     tr("BUT_OK"));
1669         RBIrange->setChecked(true);
1670         changeRange(1);
1671       }
1672       return false;
1673     }
1674   }
1675   return true;
1676 }
1677
1678
1679 //----------------------------------------------------------------------------
1680 void VisuGUI_ScalarBarPane::onTextPref()
1681 {
1682   myTextDlg->storeBeginValues();
1683   myIsStoreTextProp = myTextDlg->exec() || myIsStoreTextProp;
1684   updatePreview();
1685 }
1686
1687
1688 //----------------------------------------------------------------------------
1689 void VisuGUI_ScalarBarPane::onBarPref()
1690 {
1691   if(RBvert->isChecked())
1692     myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1693   else
1694     myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1695   myBarDlg->setOrientation( getOrientation() );
1696   if(myBarDlg->exec()) {
1697     if(RBvert->isChecked())
1698       myBarDlg->getRatios(myVerTS, myVerLS, myVerBW, myVerBH);
1699     else
1700       myBarDlg->getRatios(myHorTS, myHorLS, myHorBW, myHorBH);
1701     updatePreview();
1702   }
1703 }
1704
1705
1706 //----------------------------------------------------------------------------
1707 void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview)
1708 {
1709   if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
1710     if (thePreview) {
1711       createScalarBar();
1712     } else {
1713       deleteScalarBar();
1714     }
1715     vf->Repaint();
1716   }
1717 }
1718
1719 VisuGUI_Prs3dDlg::VisuGUI_Prs3dDlg( SalomeApp_Module* theModule )
1720   : QDialog( VISU::GetDesktop( theModule ), Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
1721 {
1722 }
1723
1724 //----------------------------------------------------------------------------
1725 /*!
1726   Called when <Help> button is clicked, shows the corresponding help page in defined browser
1727 */
1728 void VisuGUI_Prs3dDlg::onHelp()
1729 {
1730   QString aHelpFileName = GetContextHelpFilePath();
1731   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1732   if (app) {
1733     VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
1734     app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
1735   }
1736   else {
1737     SUIT_MessageBox::warning( this, tr( "WRN_WARNING" ),
1738                               tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
1739                               arg( app->resourceMgr()->stringValue( "ExternalBrowser",
1740                                                                    "application" ) ).
1741                               arg( aHelpFileName ) );
1742   }
1743 }
1744
1745
1746 //----------------------------------------------------------------------------
1747 void VisuGUI_Prs3dDlg::keyPressEvent( QKeyEvent* e )
1748 {
1749   QDialog::keyPressEvent( e );
1750   if ( e->isAccepted() )
1751     return;
1752
1753   if ( e->key() == Qt::Key_F1 ) {
1754     e->accept();
1755     onHelp();
1756   }
1757 }
1758
1759 //----------------------------------------------------------------------------
1760 VisuGUI_ScalarBarBaseDlg::VisuGUI_ScalarBarBaseDlg( SalomeApp_Module* theModule, bool theIsDisplayGaussMetric, bool thePreview ) :
1761   VisuGUI_Prs3dDlg( theModule )
1762 {
1763   myScalarPane = new VisuGUI_ScalarBarPane(this, theIsDisplayGaussMetric, thePreview);
1764   myScalarPane->layout()->setMargin( 5 );
1765 }
1766
1767
1768 VisuGUI_ScalarBarBaseDlg::~VisuGUI_ScalarBarBaseDlg()
1769 {
1770 }
1771
1772
1773 //----------------------------------------------------------------------------
1774 void VisuGUI_ScalarBarBaseDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
1775                                                   bool theInit )
1776 {
1777   myScalarPane->initFromPrsObject( thePrs );
1778 }
1779
1780
1781 //----------------------------------------------------------------------------
1782 /*!
1783   Called when <OK> button is clicked, validates data and closes dialog
1784 */
1785 void VisuGUI_ScalarBarBaseDlg::accept()
1786 {
1787   if (GetScalarPane()->check())
1788     VisuGUI_Prs3dDlg::accept();
1789 }
1790
1791
1792 //----------------------------------------------------------------------------
1793 /*!
1794   Called when <Cancel> button is clicked, remove preview and closes dialog
1795 */
1796 void VisuGUI_ScalarBarBaseDlg::reject()
1797 {
1798   VisuGUI_Prs3dDlg::reject();
1799 }
1800
1801 //----------------------------------------------------------------------------
1802 VisuGUI_ScalarBarPane* VisuGUI_ScalarBarBaseDlg::GetScalarPane()
1803 {
1804   return myScalarPane;
1805 }
1806
1807
1808 //----------------------------------------------------------------------------