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