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