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