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