Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/visu.git] / src / VISUGUI / VisuGUI_ScalarBarDlg.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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //
24 //  File   : VisuGUI_ScalarBarDlg.cxx
25 //  Author : Laurent CORNABE & Hubert ROLLAND
26 //  Module : VISU
27 //  $Header$
28
29 #include "VisuGUI_ScalarBarDlg.h"
30
31 #include "VisuGUI.h"
32 #include "VisuGUI_Tools.h"
33 #include "VisuGUI_ViewTools.h"
34
35 #include "SVTK_ViewWindow.h"
36 #include "SVTK_FontWidget.h"
37
38 #include "VISUConfig.hh"
39 #include "VISU_Convertor.hxx"
40
41 #include "VISU_ScalarMapPL.hxx"
42 #include "VISU_ScalarMap_i.hh"
43 #include "VISU_ScalarMapAct.h"
44
45 #include "SalomeApp_Application.h"
46
47 #include "SUIT_MessageBox.h"
48 #include "SUIT_ResourceMgr.h"
49
50 #include <limits.h>
51 #include <qlayout.h>
52 #include <qvalidator.h>
53 #include <qcolordialog.h>
54
55 #include <vtkTextProperty.h>
56
57 using namespace std;
58
59
60 VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
61   QVBox(parent), myPreviewActor(0)
62 {
63   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
64   QString propertyName;
65   propertyName = QString("scalar_bar_vertical_");
66   myVerX = aResourceMgr->doubleValue("VISU", propertyName + "x", myVerX);
67   myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", myVerY);
68   myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", myVerW);
69   myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",myVerH);
70   
71   propertyName = QString("scalar_bar_horizontal_");
72   myHorX = aResourceMgr->doubleValue("VISU", propertyName + "x", myHorX);
73   myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", myHorY);
74   myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", myHorW);
75   myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",myHorH);
76   
77   Imin = 0.0; Imax = 0.0; /*Fmin = 0.0; Fmax = 0.0;*/ Rmin = 0.0; Rmax = 0.0;
78   myRangeMode = -1;
79
80   setSpacing(6);
81   //setMargin(11);
82
83   // Range ============================================================
84   RangeGroup = new QButtonGroup (tr("SCALAR_RANGE_GRP"), this, "RangeGroup");
85   RangeGroup->setColumnLayout(0, Qt::Vertical );
86   RangeGroup->layout()->setSpacing( 0 );
87   RangeGroup->layout()->setMargin( 0 );
88   QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() );
89   RangeGroupLayout->setAlignment( Qt::AlignTop );
90   RangeGroupLayout->setSpacing( 6 );
91   RangeGroupLayout->setMargin( 11 );
92
93   myModeLbl = new QLabel("Scalar Mode", RangeGroup);
94
95   myModeCombo = new QComboBox(RangeGroup);
96
97   CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), RangeGroup);
98   CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
99
100   RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), RangeGroup, "RBFrange");
101   RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), RangeGroup, "RBIrange");
102   RBFrange->setChecked( true );
103
104   MinEdit = new QLineEdit( RangeGroup, "MinEdit" );
105   MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
106   MinEdit->setMinimumWidth( 70 );
107   MinEdit->setValidator( new QDoubleValidator(this) );
108   MinEdit->setText( "0.0" );
109   QLabel* MinLabel = new QLabel (tr("LBL_MIN"), RangeGroup, "MinLabel");
110   MinLabel->setBuddy(MinEdit);
111
112   MaxEdit = new QLineEdit( RangeGroup, "MaxEdit" );
113   MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
114   MaxEdit->setMinimumWidth( 70 );
115   MaxEdit->setValidator( new QDoubleValidator(this) );
116   MaxEdit->setText( "0.0" );
117   QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), RangeGroup, "MaxLabel");
118   MaxLabel->setBuddy(MaxEdit);
119
120   RangeGroupLayout->addWidget( myModeLbl, 0, 0 );
121   RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3);
122   RangeGroupLayout->addMultiCellWidget( CBLog, 1, 1, 0, 3);
123   RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1);
124   RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3);
125   RangeGroupLayout->addWidget( MinLabel, 3, 0 );
126   RangeGroupLayout->addWidget( MinEdit,  3, 1 );
127   RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
128   RangeGroupLayout->addWidget( MaxEdit,  3, 3 );
129
130   //TopLayout->addWidget( RangeGroup );
131
132   // Colors and Labels ========================================================
133   QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this, "ColLabGroup");
134   ColLabGroup->setColumnLayout(0, Qt::Vertical );
135   ColLabGroup->layout()->setSpacing( 0 );
136   ColLabGroup->layout()->setMargin( 0 );
137   QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() );
138   ColLabGroupLayout->setAlignment( Qt::AlignTop );
139   ColLabGroupLayout->setSpacing( 6 );
140   ColLabGroupLayout->setMargin( 11 );
141
142   QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup, "ColorLabel");
143   ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup );
144   ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
145   ColorSpin->setMinimumWidth( 70 );
146   ColorSpin->setValue( 64 );
147
148   QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup, "LabelLabel");
149   LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup );
150   LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
151   LabelSpin->setMinimumWidth( 70 );
152   LabelSpin->setValue( 5 );
153
154   ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
155   ColLabGroupLayout->addWidget( ColorSpin,  0, 1);
156   ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
157   ColLabGroupLayout->addWidget( LabelSpin,  0, 3);
158
159   //TopLayout->addWidget( ColLabGroup );
160
161   // Orientation ==========================================================
162   QButtonGroup* OrientGroup = new QButtonGroup (tr("ORIENTATION_GRP"), this, "OrientGroup");
163   OrientGroup->setColumnLayout(0, Qt::Vertical );
164   OrientGroup->layout()->setSpacing( 0 );
165   OrientGroup->layout()->setMargin( 0 );
166   QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() );
167   OrientGroupLayout->setAlignment( Qt::AlignTop );
168   OrientGroupLayout->setSpacing( 6 );
169   OrientGroupLayout->setMargin( 11 );
170
171   RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGroup, "RBvert");
172   RBvert->setChecked( true );
173   RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGroup, "RBhori");
174   OrientGroupLayout->addWidget( RBvert, 0, 0 );
175   OrientGroupLayout->addWidget( RBhori, 0, 1 );
176
177   //  TopLayout->addWidget( OrientGroup );
178
179   // Origin ===============================================================
180   QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this, "OriginGroup");
181   OriginGroup->setColumnLayout(0, Qt::Vertical );
182   OriginGroup->layout()->setSpacing( 0 );
183   OriginGroup->layout()->setMargin( 0 );
184   QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() );
185   OriginGroupLayout->setAlignment( Qt::AlignTop );
186   OriginGroupLayout->setSpacing( 6 );
187   OriginGroupLayout->setMargin( 11 );
188
189   QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup, "XLabel");
190   XSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
191   XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
192   XSpin->setMinimumWidth( 70 );
193   XSpin->setValue( 0.01 );
194
195   QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup, "YLabel");
196   YSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
197   YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
198   YSpin->setMinimumWidth( 70 );
199   YSpin->setValue( 0.01 );
200
201   OriginGroupLayout->addWidget( XLabel, 0, 0);
202   OriginGroupLayout->addWidget( XSpin,  0, 1);
203   OriginGroupLayout->addWidget( YLabel, 0, 2);
204   OriginGroupLayout->addWidget( YSpin,  0, 3);
205
206   //TopLayout->addWidget( OriginGroup );
207
208   // Dimensions =========================================================
209   QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this, "DimGroup");
210   DimGroup->setColumnLayout(0, Qt::Vertical );
211   DimGroup->layout()->setSpacing( 0 );
212   DimGroup->layout()->setMargin( 0 );
213   QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() );
214   DimGroupLayout->setAlignment( Qt::AlignTop );
215   DimGroupLayout->setSpacing( 6 );
216   DimGroupLayout->setMargin( 11 );
217
218   QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup, "WidthLabel");
219   WidthSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
220   WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
221   WidthSpin->setMinimumWidth( 70 );
222   WidthSpin->setValue( 0.1 );
223
224   QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup, "HeightLabel");
225   HeightSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
226   HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
227   HeightSpin->setMinimumWidth( 70 );
228   HeightSpin->setValue( 0.8 );
229
230   DimGroupLayout->addWidget( WidthLabel, 0, 0);
231   DimGroupLayout->addWidget( WidthSpin,  0, 1);
232   DimGroupLayout->addWidget( HeightLabel, 0, 2);
233   DimGroupLayout->addWidget( HeightSpin,  0, 3);
234
235   //TopLayout->addWidget( DimGroup );
236
237   // Save check box ===========================================================
238   QHBox* aSaveBox = new QHBox(this);
239   if (!SetPref) {
240     CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), aSaveBox, "CBSave");
241     //TopLayout->addWidget(CBSave);
242   }
243   else {
244     CBSave = 0;
245   }
246   myTextBtn = new QPushButton("Text properties...", aSaveBox);
247   myTextDlg = new VisuGUI_TextPrefDlg(this);
248   myTextDlg->setTitleVisible(!SetPref);
249
250   QGroupBox* CheckGroup = new QGroupBox("", this, "CheckGroup");
251   CheckGroup->setColumnLayout(0, Qt::Vertical );
252   CheckGroup->layout()->setSpacing( 0 );
253   CheckGroup->layout()->setMargin( 0 );
254   QGridLayout* CheckGroupLayout = new QGridLayout( CheckGroup->layout() );
255   
256   myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), CheckGroup);
257   myPreviewCheck->setChecked(false);
258   CheckGroupLayout->addWidget(myPreviewCheck , 0, 0 );
259
260   // signals and slots connections ===========================================
261   connect( RangeGroup,   SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) );
262   connect( myModeCombo,   SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( int ) ) );
263   connect( OrientGroup,  SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) );
264   connect( XSpin,        SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
265   connect( YSpin,        SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
266   connect( myTextBtn,    SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
267   connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) );
268   connect( ColorSpin,    SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
269   connect( LabelSpin,    SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
270   connect( WidthSpin,    SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
271   connect( HeightSpin,   SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
272   connect( CBLog,        SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() ));
273   changeRange( 0 );
274   changeDefaults( 0 );
275   myIsStoreTextProp = false;
276   myBusy = false;
277 }
278
279 /**
280  * Initializes dialog box values from resources
281  */
282 void VisuGUI_ScalarBarPane::initFromResources() {
283   int sbCol=64,sbLab=5,orient=0;
284   float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8;
285   float sbVmin=0., sbVmax=0.;
286   bool sbRange=false;
287   QString aString;
288
289   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
290
291   bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0);
292   int aPlace = 1;
293   if (anIsArrangeBar){
294     aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0);
295   }
296
297   int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0);
298   myModeCombo->setCurrentItem(aScalarMode);
299
300   orient = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", orient);
301   if(orient != 0){
302     orient=1;
303     sbX1=0.2;
304     sbY1=0.01;
305     sbW=0.6;
306     sbH=0.12;
307   }
308   
309   QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
310
311   sbX1 = aResourceMgr->doubleValue("VISU", propertyName + "x", sbX1);
312   sbY1 = aResourceMgr->doubleValue("VISU", propertyName + "y", sbY1);
313
314   sbW = aResourceMgr->doubleValue("VISU", propertyName + "width", sbW);
315   sbH = aResourceMgr->doubleValue("VISU", propertyName + "height",sbH);
316   
317   if(orient){
318     sbY1 += sbH*(aPlace-1);
319   } else {
320     sbX1 += sbW*(aPlace-1);
321   }
322   sbCol = aResourceMgr->integerValue("VISU" ,"scalar_bar_num_colors", sbCol);
323   sbLab = aResourceMgr->integerValue("VISU", "scalar_bar_num_labels", sbLab);
324
325   int rangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0);
326   if (rangeType == 1) sbRange = true;
327   sbVmin = aResourceMgr->doubleValue("VISU", "scalar_range_min", sbVmin);
328   sbVmax = aResourceMgr->doubleValue("VISU", "scalar_range_max", sbVmax);
329
330   bool isLog = aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false);
331   setLogarithmic(isLog);
332   
333   if((sbX1 < 0.) || (sbY1 < 0.) ||
334      ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
335     if(orient == 0) {
336       sbX1=0.01;
337       sbY1=0.1;
338       sbW=0.1;
339       sbH=0.8;
340     } else {
341       sbX1=0.2;
342       sbY1=0.01;
343       sbW=0.6;
344       sbH=0.12;
345     }
346   }
347   if(sbCol < 2) sbCol=2;
348   if(sbCol > 64) sbCol=64;
349   if(sbLab < 2) sbLab=2;
350   if(sbLab > 65) sbLab=65;
351
352   if(sbVmin > sbVmax) {
353     sbVmin=0.;
354     sbVmax=0.;
355   }
356
357   setRange( sbVmin, sbVmax, /*0.0, 0.0,*/ sbRange );
358   setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 0);
359   setScalarBarData( sbCol, sbLab );
360
361   // "Title"
362   bool isBold = false, isItalic = false, isShadow = false;
363   int aFontFamily = VTK_ARIAL;
364
365   if ( aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" ) )
366     {
367       QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" );
368       
369       if ( f.family() == "Arial" )
370         aFontFamily = VTK_ARIAL;
371       else if ( f.family() == "Courier" )
372         aFontFamily = VTK_COURIER;
373       else if ( f.family() == "Times" )
374         aFontFamily = VTK_TIMES;
375       
376       isBold = f.bold();
377       isItalic = f.italic();
378       isShadow =  f.underline();
379     }
380   
381   QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
382   
383   myTextDlg->myTitleFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
384
385   // "Labels"
386   isBold = isItalic = isShadow = false;
387   aFontFamily = VTK_ARIAL;
388
389   if ( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" ) )
390     {
391       QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" );
392       
393       if ( f.family() == "Arial" )
394         aFontFamily = VTK_ARIAL;
395       else if ( f.family() == "Courier" )
396         aFontFamily = VTK_COURIER;
397       else if ( f.family() == "Times" )
398         aFontFamily = VTK_TIMES;
399       
400       isBold = f.bold();
401       isItalic = f.italic();
402       isShadow =  f.underline();
403     }
404   
405   aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
406   
407   myTextDlg->myLabelFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
408 }
409
410 /**
411  * Stores dialog values to resources
412  */
413 void VisuGUI_ScalarBarPane::storeToResources() {
414   int orient = (RBvert->isChecked())? 0 : 1;
415   float sbX1   = XSpin->value();
416   float sbY1   = YSpin->value();
417   float sbW    = WidthSpin->value();
418   float sbH    = HeightSpin->value();
419   int sbCol  = ColorSpin->value();
420   int sbLab  = LabelSpin->value();
421
422   if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
423     if(orient == 0) {
424       sbX1=0.01;
425       sbY1=0.1;
426       sbW=0.17;
427       sbH=0.8;
428     } else {
429       sbX1=0.2;
430       sbY1=0.01;
431       sbW=0.6;
432       sbH=0.12;
433     }
434   }
435
436   bool sbRange = RBIrange->isChecked();
437   float sbVmin = (float)(MinEdit->text().toDouble());
438   float sbVmax = (float)(MaxEdit->text().toDouble());
439
440   if(sbVmin > sbVmax) {
441     sbVmin=0.;
442     sbVmax=0.;
443   }
444
445   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
446
447   aResourceMgr->setValue("VISU", "scalar_bar_orientation", orient);
448
449   QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
450
451   aResourceMgr->setValue("VISU", propertyName + "x", sbX1);
452   aResourceMgr->setValue("VISU", propertyName + "y", sbY1);
453   aResourceMgr->setValue("VISU", propertyName + "width", sbW);
454   aResourceMgr->setValue("VISU", propertyName + "height", sbH);
455
456   aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol);
457   aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab);
458
459   if(sbRange)
460     {
461       aResourceMgr->setValue("VISU", "scalar_range_type", 1);
462       aResourceMgr->setValue("VISU", "scalar_range_min" ,sbVmin);
463       aResourceMgr->setValue("VISU", "scalar_range_max" ,sbVmax);
464     }
465   else
466     aResourceMgr->setValue("VISU", "scalar_range_type", 0);
467   
468   aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic());
469  
470   ////
471
472   if (myIsStoreTextProp) {
473     // "Title"
474     QColor aTitleColor (255, 255, 255);
475     int aTitleFontFamily = VTK_ARIAL;
476     bool isTitleBold = false;
477     bool isTitleItalic = false;
478     bool isTitleShadow = false;
479
480     myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily,
481                                     isTitleBold, isTitleItalic, isTitleShadow);
482
483     QFont aTitleFont;
484     
485     aTitleFont.setBold(isTitleBold);
486     aTitleFont.setItalic(isTitleItalic);
487     aTitleFont.setUnderline(isTitleShadow);
488     
489     QString titleFontFamily;
490     switch (aTitleFontFamily) {
491     case VTK_ARIAL:
492       titleFontFamily = "Arial";
493       break;
494     case VTK_COURIER:
495       titleFontFamily = "Courier";
496       break;
497     case VTK_TIMES:
498       titleFontFamily = "Times";
499       break;
500     }
501     aTitleFont.setFamily(titleFontFamily);
502     
503     aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont);
504     
505     aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor);
506     
507     // "Label"
508     QColor aLabelColor (255, 255, 255);
509     int aLabelFontFamily = VTK_ARIAL;
510     bool isLabelBold = false;
511     bool isLabelItalic = false;
512     bool isLabelShadow = false;
513
514     myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
515                                     isLabelBold, isLabelItalic, isLabelShadow);
516
517
518     QFont aLabelFont;
519     
520     aLabelFont.setBold(isLabelBold);
521     aLabelFont.setItalic(isLabelItalic);
522     aLabelFont.setUnderline(isLabelShadow);
523
524     QString labelFontFamily;
525     switch (aLabelFontFamily) {
526     case VTK_ARIAL:
527       labelFontFamily = "Arial";
528       break;
529     case VTK_COURIER:
530       labelFontFamily = "Courier";
531       break;
532     case VTK_TIMES:
533       labelFontFamily = "Times";
534       break;
535     }
536
537     aLabelFont.setFamily(labelFontFamily);
538     
539     aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont);
540
541     aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor);
542   }
543 }
544
545 /**
546  * Initialise dialog box from presentation object
547  */
548 void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
549   initFromResources();
550   myScalarMap = thePrs;
551   setPosAndSize( thePrs->GetPosX(),
552                  thePrs->GetPosY(),
553                  thePrs->GetWidth(),
554                  thePrs->GetHeight(),
555                  thePrs->GetBarOrientation());
556   switch(thePrs->GetScaling()){
557   case VISU::LOGARITHMIC :
558     setLogarithmic(true);
559     break;
560   default:
561     setLogarithmic(false);
562   }
563   float aRange[2];
564   thePrs->GetScalarMapPL()->GetSourceRange(aRange);
565   Rmin = aRange[0]; Rmax = aRange[1];
566   setRange( thePrs->GetMin(), thePrs->GetMax(),
567             /*0.0, 0.0,*/ thePrs->IsRangeFixed() );
568   setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
569
570   // Update myModeCombo
571   int aNbComp = thePrs->GetField()->myNbComp;
572   bool isScalarMode = (aNbComp > 1);
573   myModeCombo->clear();
574   myModeCombo->insertItem("<Modulus>");
575   const VISU::PField& aField = thePrs->GetField();
576   const VISU::TNames& aCompNames = aField->myCompNames;
577   const VISU::TNames& aUnitNames = aField->myUnitNames;
578   for(int i = 0; i < aNbComp; i++){
579     QString aComponent = QString(aCompNames[i]).simplifyWhiteSpace();
580     if(aComponent.isNull() || aComponent == "")
581       aComponent = "Component " + QString::number(i+1);
582     else
583       aComponent = "[" + QString::number(i+1) + "] " + aComponent;
584
585     QString anUnit = QString(aUnitNames[i]).simplifyWhiteSpace();
586     if(anUnit.isNull() || anUnit == "")
587       anUnit = "-";
588     
589     aComponent = aComponent + ", " + anUnit;
590
591     myModeCombo->insertItem(aComponent);
592   }
593   //
594   myModeCombo->setCurrentItem(thePrs->GetScalarMode());
595   if (aNbComp==1){
596     myModeCombo->setCurrentItem(1);
597   }
598   //
599   myModeLbl->setEnabled(isScalarMode);
600   myModeCombo->setEnabled(isScalarMode);
601
602   // "Title"
603   myTextDlg->setTitleText(QString(thePrs->GetTitle()));
604
605   float R, G, B;
606   thePrs->GetTitleColor(&R, &G, &B);
607
608   myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
609                                   thePrs->GetTitFontType(),
610                                   thePrs->IsBoldTitle(),
611                                   thePrs->IsItalicTitle(),
612                                   thePrs->IsShadowTitle());
613
614   // "Labels"
615   thePrs->GetLabelColor(&R, &G, &B);
616
617   myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
618                                   thePrs->GetLblFontType(),
619                                   thePrs->IsBoldLabel(),
620                                   thePrs->IsItalicLabel(),
621                                   thePrs->IsShadowLabel());
622
623   // Draw Preview
624   if (myPreviewCheck->isChecked()) {
625     createScalarBar();
626     updatePreview();
627   }
628
629 }
630 /*! Slot update preview of scalar bar, if preview is checked
631  */
632 void VisuGUI_ScalarBarPane::updatePreview()
633 {
634   if (myPreviewCheck->isChecked()) {
635     if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
636       deleteScalarBar();
637       createScalarBar();
638       vf->Repaint();
639     }
640   }
641 }
642
643 /*! Creating preview scalar bar
644  */
645 void VisuGUI_ScalarBarPane::createScalarBar()
646 {
647   if (VISU::GetActiveViewWindow<SVTK_ViewWindow>() == NULL) return;
648   if (myPreviewActor != 0) return;
649   if (myScalarMap == NULL) return;
650
651   if (!check()) return;
652
653   if ( myBusy ) return;
654
655   myBusy = true;
656
657   int sbCol,sbLab;
658   sbCol = getNbColors();
659   sbLab = getNbLabels();
660   if(sbCol < 2) sbCol=2;
661   if(sbCol > 64) sbCol=64;
662   if(sbLab < 2) sbLab=2;
663   if(sbLab > 65) sbLab=65;
664   myPreviewActor = VISU_ScalarMapAct::New();
665   VISU_ScalarBarActor* aScalarBarActor = myPreviewActor->GetScalarBar();
666   myPreviewActor->GetScalarBar()->VisibilityOn();
667   myPreviewActor->PickableOff();
668   
669   myScalarMap->SetScalarMode(myModeCombo->currentItem());
670   myScalarMap->SetPosition(getX(),getY());
671   myScalarMap->SetSize(getWidth(),getHeight());
672   myScalarMap->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
673   if(isLogarithmic())
674     myScalarMap->SetScaling(VISU::LOGARITHMIC);
675   else
676     myScalarMap->SetScaling(VISU::LINEAR);
677   if (RBFrange->isChecked()) {
678     myScalarMap->SetSourceRange();
679   } else {
680     myScalarMap->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
681   }
682   myScalarMap->SetNbColors(sbCol);
683   myScalarMap->SetLabels(sbLab); 
684   
685   myScalarMap->GetScalarMapPL()->SetNbColors(sbCol);
686   myScalarMap->GetScalarMapPL()->Update();
687     
688   aScalarBarActor->SetLookupTable(myScalarMap->GetScalarMapPL()->GetBarTable());
689   
690   if (myTextDlg->getTitleText().latin1() != "") 
691     aScalarBarActor->SetTitle(myTextDlg->getTitleText().latin1());
692   else
693     aScalarBarActor->SetTitle(myScalarMap->GetTitle());
694   aScalarBarActor->SetOrientation(getOrientation());
695   aScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
696   aScalarBarActor->GetPositionCoordinate()->SetValue(getX(),getY());
697   aScalarBarActor->SetWidth(getWidth());
698   aScalarBarActor->SetHeight(getHeight());
699   aScalarBarActor->SetNumberOfLabels(sbLab);
700   aScalarBarActor->SetMaximumNumberOfColors(sbCol);
701
702   // title text property
703   QColor aTitleColor;
704   int aTitleFontFamily;
705   bool isTitleBold;
706   bool isTitleItalic;
707   bool isTitleShadow;
708   myTextDlg->myTitleFont->GetData(aTitleColor,aTitleFontFamily,
709                                   isTitleBold,isTitleItalic,isTitleShadow);
710   vtkTextProperty* aTitleProp = aScalarBarActor->GetTitleTextProperty();
711   aTitleProp->SetFontFamily(aTitleFontFamily);
712   aTitleProp->SetColor(float(aTitleColor.red())/255.,
713                        float(aTitleColor.green())/255.,
714                        float(aTitleColor.blue())/255.);
715   (isTitleBold)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
716   (isTitleItalic)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
717   (isTitleShadow)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
718   
719   // label text property
720   QColor aLabelColor;
721   int aLabelFontFamily;
722   bool isLabelBold;
723   bool isLabelItalic;
724   bool isLabelShadow;
725   myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
726                                   isLabelBold, isLabelItalic, isLabelShadow);
727   vtkTextProperty* aLabelProp = aScalarBarActor->GetLabelTextProperty();
728   aLabelProp->SetFontFamily(aLabelFontFamily);
729   aLabelProp->SetColor(float(aLabelColor.red())/255.,
730                        float(aLabelColor.green())/255.,
731                        float(aLabelColor.blue())/255.);
732   (isLabelBold)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
733   (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
734   (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
735
736   aScalarBarActor->Modified();
737
738   VISU::GetActiveViewWindow<SVTK_ViewWindow>()->AddActor(myPreviewActor);
739
740   myBusy = false;
741 }
742 /*! Deleting preview scalar bar
743  */
744 void VisuGUI_ScalarBarPane::deleteScalarBar()
745 {
746   if ( myBusy ) return;
747   
748   if (myPreviewActor == 0) return;
749   if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()){
750     vf->RemoveActor(myPreviewActor);
751     myPreviewActor->GetScalarBar()->VisibilityOff();
752   }
753   myPreviewActor->Delete();
754   myPreviewActor = 0;
755 }
756 /*! public: Deleting preview scalar bar
757  */
758 void VisuGUI_ScalarBarPane::deletePreview()
759 {
760   deleteScalarBar();
761 }
762 /**
763  * Store values to presentation object
764  */
765 int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ScalarMap_i* thePrs) {
766   thePrs->SetScalarMode(myModeCombo->currentItem());
767   thePrs->SetPosition(XSpin->value(), YSpin->value());
768   thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
769   thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
770   if(isLogarithmic())
771     thePrs->SetScaling(VISU::LOGARITHMIC);
772   else
773     thePrs->SetScaling(VISU::LINEAR);
774
775   if (RBFrange->isChecked()) {
776     thePrs->SetSourceRange();
777   } else {
778     thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
779   }
780   thePrs->SetNbColors(ColorSpin->value());
781   thePrs->SetLabels(LabelSpin->value());
782
783   if (isToSave()) storeToResources();
784
785   if (myIsStoreTextProp) {
786     // "Title"
787     thePrs->SetTitle(myTextDlg->getTitleText().latin1());
788
789     QColor aTitColor (255, 255, 255);
790     int aTitleFontFamily = VTK_ARIAL;
791     bool isTitleBold = false;
792     bool isTitleItalic = false;
793     bool isTitleShadow = false;
794
795     myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
796                                     isTitleBold, isTitleItalic, isTitleShadow);
797
798     thePrs->SetBoldTitle(isTitleBold);
799     thePrs->SetItalicTitle(isTitleItalic);
800     thePrs->SetShadowTitle(isTitleShadow);
801     thePrs->SetTitFontType(aTitleFontFamily);
802     thePrs->SetTitleColor(aTitColor.red()/255.,
803                           aTitColor.green()/255.,
804                           aTitColor.blue()/255.);
805
806     // "Label"
807     QColor aLblColor (255, 255, 255);
808     int aLabelFontFamily = VTK_ARIAL;
809     bool isLabelBold = false;
810     bool isLabelItalic = false;
811     bool isLabelShadow = false;
812
813     myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
814                                     isLabelBold, isLabelItalic, isLabelShadow);
815
816     thePrs->SetBoldLabel(isLabelBold);
817     thePrs->SetItalicLabel(isLabelItalic);
818     thePrs->SetShadowLabel(isLabelShadow);
819     thePrs->SetLblFontType(aLabelFontFamily);
820     thePrs->SetLabelColor(aLblColor.red()/255.,
821                           aLblColor.green()/255.,
822                           aLblColor.blue()/255.);
823   }
824
825   return 1;
826 }
827
828 /*!
829   Called when orientation is changed
830 */
831 void VisuGUI_ScalarBarPane::changeDefaults( int )
832 {
833   if ( RBvert->isChecked() ) {
834     XSpin->setValue( myVerX );
835     YSpin->setValue( myVerY );
836     WidthSpin->setValue( myVerW );
837     HeightSpin->setValue( myVerH );
838   }
839   else {
840     XSpin->setValue( myHorX );
841     YSpin->setValue( myHorY );
842     WidthSpin->setValue( myHorW );
843     HeightSpin->setValue( myHorH );
844   }
845   updatePreview();
846 }
847
848 /*!
849   Called when Range mode is changed
850 */
851 void VisuGUI_ScalarBarPane::changeRange( int )
852 {
853   int mode = -1;
854   if ( RBFrange->isChecked() )
855     mode = 0;
856   if ( RBIrange->isChecked() )
857     mode = 1;
858   if ( myRangeMode == mode )
859     return;
860   //MinSpin->setMaxValue( Fmin );
861   //MaxSpin->setMinValue( Fmax );
862   if ( RBFrange->isChecked() ) {
863     //MinLabel->setEnabled( false );
864     MinEdit->setEnabled( false );
865     //MaxLabel->setEnabled( false );
866     MaxEdit->setEnabled( false );
867     if ( mode != -1 ) {
868       Imin = MinEdit->text().toDouble();
869       Imax = MaxEdit->text().toDouble();
870     }
871     MinEdit->setText( QString::number( Rmin ) );
872     MaxEdit->setText( QString::number( Rmax ) );
873   }
874   else {
875     //MinLabel->setEnabled( true );
876     MinEdit->setEnabled( true );
877     //MaxLabel->setEnabled( true );
878     MaxEdit->setEnabled( true );
879     MinEdit->setText( QString::number( Imin ) );
880     MaxEdit->setText( QString::number( Imax ) );
881   }
882   myRangeMode = mode;
883   updatePreview();
884 }
885
886 /*!
887   Called when X,Y position is changed
888 */
889 void VisuGUI_ScalarBarPane::XYChanged( double )
890 {
891   QtxDblSpinBox* snd = (QtxDblSpinBox*)sender();
892   if ( snd == XSpin ) {
893     WidthSpin->setMaxValue( 1.0 - XSpin->value() );
894   }
895   if ( snd == YSpin ) {
896     HeightSpin->setMaxValue( 1.0 - YSpin->value() );
897   }
898   updatePreview();
899 }
900
901 /*!
902   Called when scalar mode is changed
903 */
904 void VisuGUI_ScalarBarPane::changeScalarMode( int theMode )
905 {
906   if ( myScalarMap ) {
907     if ( RBFrange->isChecked() ) {
908       float aRange[2];
909       myScalarMap->SetScalarMode(theMode);
910       myScalarMap->GetScalarMapPL()->GetSourceRange(aRange);
911       MinEdit->setText( QString::number( aRange[0] ) );
912       MaxEdit->setText( QString::number( aRange[1] ) );
913     }
914   }
915 }
916
917 /*!
918   Sets default values and range mode
919 */
920 void VisuGUI_ScalarBarPane::setRange( double imin, double imax/*, double fmin, double fmax*/, bool sbRange )
921 {
922   Imin = imin; Imax = imax;// Fmin = fmin; Fmax = fmax;
923   if ( RBIrange->isChecked() ) {
924     MinEdit->setText( QString::number( Imin ) );
925     MaxEdit->setText( QString::number( Imax ) );
926   }
927   else {
928     MinEdit->setText( QString::number( Rmin ) );
929     MaxEdit->setText( QString::number( Rmax ) );
930   }
931   myRangeMode = -1;
932   if( sbRange )
933     RBIrange->setChecked( true );
934   else
935     RBFrange->setChecked( true );
936   changeRange( 0 );
937 }
938
939 /*!
940   Sets default values and range mode
941 */
942 void VisuGUI_ScalarBarPane::setDefaultRange(double imin, double imax){
943   Rmin = imin;
944   Rmax = imax;
945 }
946
947 /*!
948   Sets size and position
949 */
950 void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
951 {
952   if ( vert ) {
953     myVerX = x;
954     myVerY = y;
955     myVerW = w;
956     myVerH = h;
957     RBvert->setChecked( true );
958   }
959   else {
960     myHorX = x;
961     myHorY = y;
962     myHorW = w;
963     myHorH = h;
964     RBhori->setChecked( true );
965   }
966   changeDefaults( 0 );
967 }
968
969 /*!
970   Sets colors and labels number
971 */
972 void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
973 {
974   ColorSpin->setValue( colors );
975   LabelSpin->setValue( labels );
976 }
977
978 /*!
979   Gets orientation
980 */
981 int  VisuGUI_ScalarBarPane::getOrientation()
982 {
983   if (RBvert->isChecked() )
984     return  1;
985   else
986     return 0;
987 }
988
989 /*!
990   Called when <OK> button is clicked, validates data and closes dialog
991 */
992 bool VisuGUI_ScalarBarPane::check()
993 {
994   double minVal = MinEdit->text().toDouble();
995   double maxVal = MaxEdit->text().toDouble();
996   if ( RBIrange->isChecked() ) {
997     if (minVal >= maxVal) {
998       SUIT_MessageBox::warn1( this,tr("WRN_VISU"),
999                              tr("MSG_MINMAX_VALUES"),
1000                              tr("BUT_OK"));
1001       return false;
1002     }
1003   }
1004   // check if logarithmic mode is on and check imposed range to not contain negative values
1005   if ( CBLog->isChecked() ) {
1006     if ( RBIrange->isChecked() ) {
1007       if ( (minVal > 0) && (maxVal > 0) ) {
1008         // nothing to do
1009       }
1010       else {
1011         SUIT_MessageBox::warn1( this,
1012                                 tr("WRN_VISU"),
1013                                 tr("WRN_LOGARITHMIC_RANGE"),
1014                                 tr("BUT_OK"));
1015         return false;
1016       }
1017     }
1018     else {
1019       if ( Rmin > 0 && Rmax > 0 ) {
1020         // nothing to do
1021       }
1022       else {
1023         SUIT_MessageBox::warn1( this,
1024                                 tr("WRN_VISU"),
1025                                 tr("WRN_LOGARITHMIC_FIELD_RANGE"),
1026                                 tr("BUT_OK"));
1027         RBIrange->setChecked(1);
1028         changeRange(1);
1029         //MinEdit->setText( QString::number( Rmin ) );
1030         //MaxEdit->setText( QString::number( Rmax ) );
1031         return false;
1032       }
1033     }
1034   }
1035   return true;
1036 }
1037
1038 void VisuGUI_ScalarBarPane::onTextPref()
1039 {
1040   myIsStoreTextProp = myTextDlg->exec();
1041   updatePreview();
1042 }
1043
1044 void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview)
1045 {
1046   if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
1047     if (thePreview) {
1048       createScalarBar();
1049     } else {
1050       deleteScalarBar();
1051     }
1052     vf->Repaint();
1053   }
1054 }
1055
1056 //#######################################################################################
1057
1058 /*!
1059   Constructor
1060 */
1061 VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool SetPref)
1062     : QDialog(VISU::GetDesktop(theModule), 0, true,
1063               WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
1064 {
1065   setName("VisuGUI_ScalarBarDlg");
1066   setCaption(SetPref ? tr("DLG_PREF_TITLE") : tr("DLG_PROP_TITLE"));
1067   setSizeGripEnabled(TRUE);
1068
1069   QVBoxLayout* TopLayout = new QVBoxLayout(this);
1070   TopLayout->setSpacing(6);
1071   TopLayout->setMargin(11);
1072
1073   myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref);
1074   TopLayout->addWidget(myScalarPane);
1075
1076   // Common buttons ===========================================================
1077   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1078   GroupButtons->setColumnLayout(0, Qt::Vertical );
1079   GroupButtons->layout()->setSpacing( 0 );
1080   GroupButtons->layout()->setMargin( 0 );
1081   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1082   GroupButtonsLayout->setAlignment( Qt::AlignTop );
1083   GroupButtonsLayout->setSpacing( 6 );
1084   GroupButtonsLayout->setMargin( 11 );
1085
1086   QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
1087   buttonOk->setAutoDefault( TRUE );
1088   buttonOk->setDefault( TRUE );
1089   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
1090   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1091
1092   QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
1093   buttonCancel->setAutoDefault( TRUE );
1094   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
1095
1096   TopLayout->addWidget( GroupButtons );
1097
1098   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
1099   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
1100 }
1101
1102 /*!
1103   Called when <OK> button is clicked, validates data and closes dialog
1104 */
1105 void VisuGUI_ScalarBarDlg::accept()
1106 {
1107   if (myScalarPane->check()) 
1108     {
1109       myScalarPane->deletePreview(); 
1110       QDialog::accept();
1111     }
1112 }
1113
1114 /*!
1115   Called when <Cancel> button is clicked, remove preview and closes dialog
1116 */
1117 void VisuGUI_ScalarBarDlg::reject()
1118 {
1119   myScalarPane->deletePreview();
1120   QDialog::reject();
1121 }
1122
1123
1124 //#######################################################################################
1125 VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent)
1126   : QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
1127 {
1128   setName("VisuGUI_TextPrefDlg");
1129   setCaption(tr("TIT_TEXT_PREF"));
1130   setSizeGripEnabled(TRUE);
1131
1132   QVBoxLayout* TopLayout = new QVBoxLayout(this);
1133   TopLayout->setSpacing(6);
1134   TopLayout->setMargin(11);
1135
1136   // "Title" grp
1137   QGroupBox* aTitleGrp = new QGroupBox (2, Qt::Vertical, tr("LBL_TITLE"), this);
1138
1139   //   edit line
1140   myTitleEdt = new QLineEdit (aTitleGrp);
1141
1142   //   font
1143   QHBox* aHBox = new QHBox (aTitleGrp);
1144   aHBox->setSpacing(5);
1145   myTitleFont = new SVTK_FontWidget (aHBox);
1146
1147   TopLayout->addWidget(aTitleGrp);
1148
1149   // "Labels" grp
1150   QGroupBox* aLabelsGrp = new QGroupBox (1, Qt::Vertical, tr("LBL_LABELS"), this);
1151
1152   //   font
1153   aHBox = new QHBox (aLabelsGrp);
1154   aHBox->setSpacing(5);
1155   myLabelFont = new SVTK_FontWidget (aHBox);
1156
1157   TopLayout->addWidget(aLabelsGrp);
1158
1159   // Common buttons ===========================================================
1160   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1161   GroupButtons->setColumnLayout(0, Qt::Vertical );
1162   GroupButtons->layout()->setSpacing( 0 );
1163   GroupButtons->layout()->setMargin( 0 );
1164   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1165   GroupButtonsLayout->setAlignment( Qt::AlignTop );
1166   GroupButtonsLayout->setSpacing( 6 );
1167   GroupButtonsLayout->setMargin( 11 );
1168
1169   QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
1170   buttonOk->setAutoDefault( TRUE );
1171   buttonOk->setDefault( TRUE );
1172   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
1173   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1174
1175   QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
1176   buttonCancel->setAutoDefault( TRUE );
1177   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
1178
1179   TopLayout->addWidget( GroupButtons );
1180
1181   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(accept()));
1182   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
1183 }