Salome HOME
Improvement Bug PAL10652
[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_FontWg.h"
34
35 #include "SVTK_ViewWindow.h"
36
37 #include "VISUConfig.hh"
38 #include "VISU_Convertor.hxx"
39
40 #include "VISU_ScalarMapPL.hxx"
41 #include "VISU_ScalarMap_i.hh"
42 #include "VISU_ScalarMapAct.h"
43
44 #include "SalomeApp_Application.h"
45
46 #include "SUIT_MessageBox.h"
47 #include "SUIT_ResourceMgr.h"
48
49 #include <limits.h>
50 #include <qlayout.h>
51 #include <qvalidator.h>
52 #include <qcolordialog.h>
53
54 #include <vtkTextProperty.h>
55
56 using namespace std;
57
58
59 VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
60   QVBox(parent), myPreviewActor(0)
61 {
62   myVerX = 0.01;  myVerY = 0.10;  myVerW = 0.10;  myVerH = 0.80;
63   myHorX = 0.20;  myHorY = 0.01;  myHorW = 0.60;  myHorH = 0.12;
64   Imin = 0.0; Imax = 0.0; /*Fmin = 0.0; Fmax = 0.0;*/ Rmin = 0.0; Rmax = 0.0;
65   myRangeMode = -1;
66
67   setSpacing(6);
68   //setMargin(11);
69
70   // Range ============================================================
71   RangeGroup = new QButtonGroup (tr("SCALAR_RANGE_GRP"), this, "RangeGroup");
72   RangeGroup->setColumnLayout(0, Qt::Vertical );
73   RangeGroup->layout()->setSpacing( 0 );
74   RangeGroup->layout()->setMargin( 0 );
75   QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() );
76   RangeGroupLayout->setAlignment( Qt::AlignTop );
77   RangeGroupLayout->setSpacing( 6 );
78   RangeGroupLayout->setMargin( 11 );
79
80   myModeLbl = new QLabel("Scalar Mode", RangeGroup);
81
82   myModeCombo = new QComboBox(RangeGroup);
83   myModeCombo->insertItem("Modulus");
84   myModeCombo->insertItem("Component 1");
85   myModeCombo->insertItem("Component 2");
86   myModeCombo->insertItem("Component 3");
87
88   CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), RangeGroup);
89   CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
90
91   RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), RangeGroup, "RBFrange");
92   RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), RangeGroup, "RBIrange");
93   RBFrange->setChecked( true );
94
95   MinEdit = new QLineEdit( RangeGroup, "MinEdit" );
96   MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
97   MinEdit->setMinimumWidth( 70 );
98   MinEdit->setValidator( new QDoubleValidator(this) );
99   MinEdit->setText( "0.0" );
100   QLabel* MinLabel = new QLabel (tr("LBL_MIN"), RangeGroup, "MinLabel");
101   MinLabel->setBuddy(MinEdit);
102
103   MaxEdit = new QLineEdit( RangeGroup, "MaxEdit" );
104   MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
105   MaxEdit->setMinimumWidth( 70 );
106   MaxEdit->setValidator( new QDoubleValidator(this) );
107   MaxEdit->setText( "0.0" );
108   QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), RangeGroup, "MaxLabel");
109   MaxLabel->setBuddy(MaxEdit);
110
111   RangeGroupLayout->addWidget( myModeLbl, 0, 0 );
112   RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3);
113   RangeGroupLayout->addMultiCellWidget( CBLog, 1, 1, 0, 3);
114   RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1);
115   RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3);
116   RangeGroupLayout->addWidget( MinLabel, 3, 0 );
117   RangeGroupLayout->addWidget( MinEdit,  3, 1 );
118   RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
119   RangeGroupLayout->addWidget( MaxEdit,  3, 3 );
120
121   //TopLayout->addWidget( RangeGroup );
122
123   // Colors and Labels ========================================================
124   QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this, "ColLabGroup");
125   ColLabGroup->setColumnLayout(0, Qt::Vertical );
126   ColLabGroup->layout()->setSpacing( 0 );
127   ColLabGroup->layout()->setMargin( 0 );
128   QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() );
129   ColLabGroupLayout->setAlignment( Qt::AlignTop );
130   ColLabGroupLayout->setSpacing( 6 );
131   ColLabGroupLayout->setMargin( 11 );
132
133   QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup, "ColorLabel");
134   ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup );
135   ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
136   ColorSpin->setMinimumWidth( 70 );
137   ColorSpin->setValue( 64 );
138
139   QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup, "LabelLabel");
140   LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup );
141   LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
142   LabelSpin->setMinimumWidth( 70 );
143   LabelSpin->setValue( 5 );
144
145   ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
146   ColLabGroupLayout->addWidget( ColorSpin,  0, 1);
147   ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
148   ColLabGroupLayout->addWidget( LabelSpin,  0, 3);
149
150   //TopLayout->addWidget( ColLabGroup );
151
152   // Orientation ==========================================================
153   QButtonGroup* OrientGroup = new QButtonGroup (tr("ORIENTATION_GRP"), this, "OrientGroup");
154   OrientGroup->setColumnLayout(0, Qt::Vertical );
155   OrientGroup->layout()->setSpacing( 0 );
156   OrientGroup->layout()->setMargin( 0 );
157   QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() );
158   OrientGroupLayout->setAlignment( Qt::AlignTop );
159   OrientGroupLayout->setSpacing( 6 );
160   OrientGroupLayout->setMargin( 11 );
161
162   RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGroup, "RBvert");
163   RBvert->setChecked( true );
164   RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGroup, "RBhori");
165   OrientGroupLayout->addWidget( RBvert, 0, 0 );
166   OrientGroupLayout->addWidget( RBhori, 0, 1 );
167
168   //  TopLayout->addWidget( OrientGroup );
169
170   // Origin ===============================================================
171   QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this, "OriginGroup");
172   OriginGroup->setColumnLayout(0, Qt::Vertical );
173   OriginGroup->layout()->setSpacing( 0 );
174   OriginGroup->layout()->setMargin( 0 );
175   QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() );
176   OriginGroupLayout->setAlignment( Qt::AlignTop );
177   OriginGroupLayout->setSpacing( 6 );
178   OriginGroupLayout->setMargin( 11 );
179
180   QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup, "XLabel");
181   XSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
182   XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
183   XSpin->setMinimumWidth( 70 );
184   XSpin->setValue( 0.01 );
185
186   QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup, "YLabel");
187   YSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
188   YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
189   YSpin->setMinimumWidth( 70 );
190   YSpin->setValue( 0.01 );
191
192   OriginGroupLayout->addWidget( XLabel, 0, 0);
193   OriginGroupLayout->addWidget( XSpin,  0, 1);
194   OriginGroupLayout->addWidget( YLabel, 0, 2);
195   OriginGroupLayout->addWidget( YSpin,  0, 3);
196
197   //TopLayout->addWidget( OriginGroup );
198
199   // Dimensions =========================================================
200   QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this, "DimGroup");
201   DimGroup->setColumnLayout(0, Qt::Vertical );
202   DimGroup->layout()->setSpacing( 0 );
203   DimGroup->layout()->setMargin( 0 );
204   QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() );
205   DimGroupLayout->setAlignment( Qt::AlignTop );
206   DimGroupLayout->setSpacing( 6 );
207   DimGroupLayout->setMargin( 11 );
208
209   QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup, "WidthLabel");
210   WidthSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
211   WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
212   WidthSpin->setMinimumWidth( 70 );
213   WidthSpin->setValue( 0.1 );
214
215   QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup, "HeightLabel");
216   HeightSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
217   HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
218   HeightSpin->setMinimumWidth( 70 );
219   HeightSpin->setValue( 0.8 );
220
221   DimGroupLayout->addWidget( WidthLabel, 0, 0);
222   DimGroupLayout->addWidget( WidthSpin,  0, 1);
223   DimGroupLayout->addWidget( HeightLabel, 0, 2);
224   DimGroupLayout->addWidget( HeightSpin,  0, 3);
225
226   //TopLayout->addWidget( DimGroup );
227
228   // Save check box ===========================================================
229   QHBox* aSaveBox = new QHBox(this);
230   if (!SetPref) {
231     CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), aSaveBox, "CBSave");
232     //TopLayout->addWidget(CBSave);
233   }
234   else {
235     CBSave = 0;
236   }
237   myTextBtn = new QPushButton("Text properties...", aSaveBox);
238   myTextDlg = new VisuGUI_TextPrefDlg(this);
239   myTextDlg->setTitleVisible(!SetPref);
240
241   QGroupBox* CheckGroup = new QGroupBox("", this, "CheckGroup");
242   CheckGroup->setColumnLayout(0, Qt::Vertical );
243   CheckGroup->layout()->setSpacing( 0 );
244   CheckGroup->layout()->setMargin( 0 );
245   QGridLayout* CheckGroupLayout = new QGridLayout( CheckGroup->layout() );
246   
247   myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), CheckGroup);
248   myPreviewCheck->setChecked(false);
249   CheckGroupLayout->addWidget(myPreviewCheck , 0, 0 );
250
251   // signals and slots connections ===========================================
252   connect( RangeGroup,   SIGNAL( clicked( int ) ), this, SLOT( changeRange( 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   myModeCombo->setCurrentItem(thePrs->GetScalarMode());
542   setPosAndSize( thePrs->GetPosX(),
543                  thePrs->GetPosY(),
544                  thePrs->GetWidth(),
545                  thePrs->GetHeight(),
546                  thePrs->GetBarOrientation());
547   switch(thePrs->GetScaling()){
548   case VISU::LOGARITHMIC :
549     setLogarithmic(true);
550     break;
551   default:
552     setLogarithmic(false);
553   }
554   float aRange[2];
555   thePrs->GetScalarMapPL()->GetSourceRange(aRange);
556   Rmin = aRange[0]; Rmax = aRange[1];
557   setRange( thePrs->GetMin(), thePrs->GetMax(),
558             /*0.0, 0.0,*/ thePrs->IsRangeFixed() );
559   setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
560   bool isScalarMode = (thePrs->GetField()->myNbComp > 1);
561   myModeLbl->setEnabled(isScalarMode);
562   myModeCombo->setEnabled(isScalarMode);
563
564   // "Title"
565   myTextDlg->setTitleText(QString(thePrs->GetTitle()));
566
567   float R, G, B;
568   thePrs->GetTitleColor(&R, &G, &B);
569
570   myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
571                                   thePrs->GetTitFontType(),
572                                   thePrs->IsBoldTitle(),
573                                   thePrs->IsItalicTitle(),
574                                   thePrs->IsShadowTitle());
575
576   // "Labels"
577   thePrs->GetLabelColor(&R, &G, &B);
578
579   myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
580                                   thePrs->GetLblFontType(),
581                                   thePrs->IsBoldLabel(),
582                                   thePrs->IsItalicLabel(),
583                                   thePrs->IsShadowLabel());
584
585   // Draw Preview
586   if (myPreviewCheck->isChecked()) {
587     createScalarBar();
588     updatePreview();
589   }
590
591 }
592 /*! Slot update preview of scalar bar, if preview is checked
593  */
594 void VisuGUI_ScalarBarPane::updatePreview()
595 {
596   if (myPreviewCheck->isChecked()) {
597     if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) {
598       deleteScalarBar();
599       createScalarBar();
600       vf->Repaint();
601     }
602   }
603 }
604
605 /*! Creating preview scalar bar
606  */
607 void VisuGUI_ScalarBarPane::createScalarBar()
608 {
609   if (VISU::GetViewWindow() == NULL) return;
610   if (myPreviewActor != 0) return;
611   if (myScalarMap == NULL) return;
612
613   if(!check()) return;
614
615   if ( myBusy ) return;
616
617   myBusy = true;
618
619   int sbCol,sbLab;
620   sbCol = getNbColors();
621   sbLab = getNbLabels();
622   if(sbCol < 2) sbCol=2;
623   if(sbCol > 64) sbCol=64;
624   if(sbLab < 2) sbLab=2;
625   if(sbLab > 65) sbLab=65;
626   myPreviewActor = VISU_ScalarMapAct::New();
627   VISU_ScalarBarActor* aScalarBarActor = myPreviewActor->GetScalarBar();
628   myPreviewActor->GetScalarBar()->VisibilityOn();
629   myPreviewActor->PickableOff();
630   
631   myScalarMap->SetScalarMode(myModeCombo->currentItem());
632   myScalarMap->SetPosition(getX(),getY());
633   myScalarMap->SetSize(getWidth(),getHeight());
634   myScalarMap->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
635   if(isLogarithmic())
636     myScalarMap->SetScaling(VISU::LOGARITHMIC);
637   else
638     myScalarMap->SetScaling(VISU::LINEAR);
639   if (RBFrange->isChecked()) {
640     myScalarMap->SetSourceRange();
641   } else {
642     myScalarMap->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
643   }
644   myScalarMap->SetNbColors(sbCol);
645   myScalarMap->SetLabels(sbLab); 
646   
647   myScalarMap->GetScalarMapPL()->SetNbColors(sbCol);
648   myScalarMap->GetScalarMapPL()->Update();
649     
650   aScalarBarActor->SetLookupTable(myScalarMap->GetScalarMapPL()->GetBarTable());
651   
652   if (myTextDlg->getTitleText().latin1() != "") 
653     aScalarBarActor->SetTitle(myTextDlg->getTitleText().latin1());
654   else
655     aScalarBarActor->SetTitle(myScalarMap->GetTitle());
656   aScalarBarActor->SetOrientation(getOrientation());
657   aScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
658   aScalarBarActor->GetPositionCoordinate()->SetValue(getX(),getY());
659   aScalarBarActor->SetWidth(getWidth());
660   aScalarBarActor->SetHeight(getHeight());
661   aScalarBarActor->SetNumberOfLabels(sbLab);
662   aScalarBarActor->SetMaximumNumberOfColors(sbCol);
663
664   // title text property
665   QColor aTitleColor;
666   int aTitleFontFamily;
667   bool isTitleBold;
668   bool isTitleItalic;
669   bool isTitleShadow;
670   myTextDlg->myTitleFont->GetData(aTitleColor,aTitleFontFamily,
671                                   isTitleBold,isTitleItalic,isTitleShadow);
672   vtkTextProperty* aTitleProp = aScalarBarActor->GetTitleTextProperty();
673   aTitleProp->SetFontFamily(aTitleFontFamily);
674   aTitleProp->SetColor(float(aTitleColor.red())/255.,
675                        float(aTitleColor.green())/255.,
676                        float(aTitleColor.blue())/255.);
677   (isTitleBold)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
678   (isTitleItalic)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
679   (isTitleShadow)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
680   
681   // label text property
682   QColor aLabelColor;
683   int aLabelFontFamily;
684   bool isLabelBold;
685   bool isLabelItalic;
686   bool isLabelShadow;
687   myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
688                                   isLabelBold, isLabelItalic, isLabelShadow);
689   vtkTextProperty* aLabelProp = aScalarBarActor->GetLabelTextProperty();
690   aLabelProp->SetFontFamily(aLabelFontFamily);
691   aLabelProp->SetColor(float(aLabelColor.red())/255.,
692                        float(aLabelColor.green())/255.,
693                        float(aLabelColor.blue())/255.);
694   (isLabelBold)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
695   (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
696   (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
697
698   aScalarBarActor->Modified();
699
700   VISU::GetViewWindow()->AddActor(myPreviewActor);
701
702   myBusy = false;
703 }
704 /*! Deleting preview scalar bar
705  */
706 void VisuGUI_ScalarBarPane::deleteScalarBar()
707 {
708   if ( myBusy ) return;
709   
710   if (myPreviewActor == 0) return;
711   if (SVTK_ViewWindow* vf = VISU::GetViewWindow()){
712     vf->RemoveActor(myPreviewActor);
713     myPreviewActor->GetScalarBar()->VisibilityOff();
714   }
715   myPreviewActor->Delete();
716   myPreviewActor = 0;
717 }
718 /*! public: Deleting preview scalar bar
719  */
720 void VisuGUI_ScalarBarPane::deletePreview()
721 {
722   deleteScalarBar();
723 }
724 /**
725  * Store values to presentation object
726  */
727 int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ScalarMap_i* thePrs) {
728   thePrs->SetScalarMode(myModeCombo->currentItem());
729   thePrs->SetPosition(XSpin->value(), YSpin->value());
730   thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
731   thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
732   if(isLogarithmic())
733     thePrs->SetScaling(VISU::LOGARITHMIC);
734   else
735     thePrs->SetScaling(VISU::LINEAR);
736
737   if (RBFrange->isChecked()) {
738     thePrs->SetSourceRange();
739   } else {
740     thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
741   }
742   thePrs->SetNbColors(ColorSpin->value());
743   thePrs->SetLabels(LabelSpin->value());
744
745   if (isToSave()) storeToResources();
746
747   if (myIsStoreTextProp) {
748     // "Title"
749     thePrs->SetTitle(myTextDlg->getTitleText().latin1());
750
751     QColor aTitColor (255, 255, 255);
752     int aTitleFontFamily = VTK_ARIAL;
753     bool isTitleBold = false;
754     bool isTitleItalic = false;
755     bool isTitleShadow = false;
756
757     myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
758                                     isTitleBold, isTitleItalic, isTitleShadow);
759
760     thePrs->SetBoldTitle(isTitleBold);
761     thePrs->SetItalicTitle(isTitleItalic);
762     thePrs->SetShadowTitle(isTitleShadow);
763     thePrs->SetTitFontType(aTitleFontFamily);
764     thePrs->SetTitleColor(aTitColor.red()/255.,
765                           aTitColor.green()/255.,
766                           aTitColor.blue()/255.);
767
768     // "Label"
769     QColor aLblColor (255, 255, 255);
770     int aLabelFontFamily = VTK_ARIAL;
771     bool isLabelBold = false;
772     bool isLabelItalic = false;
773     bool isLabelShadow = false;
774
775     myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
776                                     isLabelBold, isLabelItalic, isLabelShadow);
777
778     thePrs->SetBoldLabel(isLabelBold);
779     thePrs->SetItalicLabel(isLabelItalic);
780     thePrs->SetShadowLabel(isLabelShadow);
781     thePrs->SetLblFontType(aLabelFontFamily);
782     thePrs->SetLabelColor(aLblColor.red()/255.,
783                           aLblColor.green()/255.,
784                           aLblColor.blue()/255.);
785   }
786
787   return 1;
788 }
789
790 /*!
791   Called when orientation is changed
792 */
793 void VisuGUI_ScalarBarPane::changeDefaults( int )
794 {
795   if ( RBvert->isChecked() ) {
796     XSpin->setValue( myVerX );
797     YSpin->setValue( myVerY );
798     WidthSpin->setValue( myVerW );
799     HeightSpin->setValue( myVerH );
800   }
801   else {
802     XSpin->setValue( myHorX );
803     YSpin->setValue( myHorY );
804     WidthSpin->setValue( myHorW );
805     HeightSpin->setValue( myHorH );
806   }
807   updatePreview();
808 }
809
810 /*!
811   Called when Range mode is changed
812 */
813 void VisuGUI_ScalarBarPane::changeRange( int )
814 {
815   int mode = -1;
816   if ( RBFrange->isChecked() )
817     mode = 0;
818   if ( RBIrange->isChecked() )
819     mode = 1;
820   if ( myRangeMode == mode )
821     return;
822   //MinSpin->setMaxValue( Fmin );
823   //MaxSpin->setMinValue( Fmax );
824   if ( RBFrange->isChecked() ) {
825     //MinLabel->setEnabled( false );
826     MinEdit->setEnabled( false );
827     //MaxLabel->setEnabled( false );
828     MaxEdit->setEnabled( false );
829     if ( mode != -1 ) {
830       Imin = MinEdit->text().toDouble();
831       Imax = MaxEdit->text().toDouble();
832     }
833     MinEdit->setText( QString::number( Rmin ) );
834     MaxEdit->setText( QString::number( Rmax ) );
835   }
836   else {
837     //MinLabel->setEnabled( true );
838     MinEdit->setEnabled( true );
839     //MaxLabel->setEnabled( true );
840     MaxEdit->setEnabled( true );
841     MinEdit->setText( QString::number( Imin ) );
842     MaxEdit->setText( QString::number( Imax ) );
843   }
844   myRangeMode = mode;
845   updatePreview();
846 }
847
848 /*!
849   Called when X,Y position is changed
850 */
851 void VisuGUI_ScalarBarPane::XYChanged( double )
852 {
853   QtxDblSpinBox* snd = (QtxDblSpinBox*)sender();
854   if ( snd == XSpin ) {
855     WidthSpin->setMaxValue( 1.0 - XSpin->value() );
856   }
857   if ( snd == YSpin ) {
858     HeightSpin->setMaxValue( 1.0 - YSpin->value() );
859   }
860   updatePreview();
861 }
862
863 /*!
864   Sets default values and range mode
865 */
866 void VisuGUI_ScalarBarPane::setRange( double imin, double imax/*, double fmin, double fmax*/, bool sbRange )
867 {
868   Imin = imin; Imax = imax;// Fmin = fmin; Fmax = fmax;
869   if ( RBIrange->isChecked() ) {
870     MinEdit->setText( QString::number( Imin ) );
871     MaxEdit->setText( QString::number( Imax ) );
872   }
873   else {
874     MinEdit->setText( QString::number( Rmin ) );
875     MaxEdit->setText( QString::number( Rmax ) );
876   }
877   myRangeMode = -1;
878   if( sbRange )
879     RBIrange->setChecked( true );
880   else
881     RBFrange->setChecked( true );
882   changeRange( 0 );
883 }
884
885 /*!
886   Sets size and position
887 */
888 void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
889 {
890   if ( vert ) {
891     myVerX = x;
892     myVerY = y;
893     myVerW = w;
894     myVerH = h;
895     RBvert->setChecked( true );
896   }
897   else {
898     myHorX = x;
899     myHorY = y;
900     myHorW = w;
901     myHorH = h;
902     RBhori->setChecked( true );
903   }
904   changeDefaults( 0 );
905 }
906
907 /*!
908   Sets colors and labels number
909 */
910 void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
911 {
912   ColorSpin->setValue( colors );
913   LabelSpin->setValue( labels );
914 }
915
916 /*!
917   Gets orientation
918 */
919 int  VisuGUI_ScalarBarPane::getOrientation()
920 {
921   if (RBvert->isChecked() )
922     return  1;
923   else
924     return 0;
925 }
926
927 /*!
928   Called when <OK> button is clicked, validates data and closes dialog
929 */
930 bool VisuGUI_ScalarBarPane::check()
931 {
932   double minVal = MinEdit->text().toDouble();
933   double maxVal = MaxEdit->text().toDouble();
934   if ( RBIrange->isChecked() ) {
935     if (minVal >= maxVal) {
936       SUIT_MessageBox::warn1( this,tr("WRN_VISU"),
937                              tr("MSG_MINMAX_VALUES"),
938                              tr("BUT_OK"));
939       return false;
940     }
941   }
942   // check if logarithmic mode is on and check imposed range to not contain negative values
943   if ( CBLog->isChecked() ) {
944     if ( RBIrange->isChecked() ) {
945       if ( (minVal > 0) && (maxVal > 0) ) {
946         // nothing to do
947       }
948       else {
949         SUIT_MessageBox::warn1( this,
950                                 tr("WRN_VISU"),
951                                 tr("WRN_LOGARITHMIC_RANGE"),
952                                 tr("BUT_OK"));
953         return false;
954       }
955     }
956     else {
957       if ( Rmin > 0 && Rmax > 0 ) {
958         // nothing to do
959       }
960       else {
961         SUIT_MessageBox::warn1( this,
962                                 tr("WRN_VISU"),
963                                 tr("WRN_LOGARITHMIC_FIELD_RANGE"),
964                                 tr("BUT_OK"));
965         RBIrange->setChecked(1);
966         changeRange(1);
967         //MinEdit->setText( QString::number( Rmin ) );
968         //MaxEdit->setText( QString::number( Rmax ) );
969         return false;
970       }
971     }
972   }
973   return true;
974 }
975
976 void VisuGUI_ScalarBarPane::onTextPref()
977 {
978   myIsStoreTextProp = myTextDlg->exec();
979   updatePreview();
980 }
981
982 void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview)
983 {
984   if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) {
985     if (thePreview) {
986       createScalarBar();
987     } else {
988       deleteScalarBar();
989     }
990     vf->Repaint();
991   }
992 }
993
994 //#######################################################################################
995
996 /*!
997   Constructor
998 */
999 VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool SetPref)
1000     : QDialog(VISU::GetDesktop(theModule), 0, true,
1001               WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
1002 {
1003   setName("VisuGUI_ScalarBarDlg");
1004   setCaption(SetPref ? tr("DLG_PREF_TITLE") : tr("DLG_PROP_TITLE"));
1005   setSizeGripEnabled(TRUE);
1006
1007   QVBoxLayout* TopLayout = new QVBoxLayout(this);
1008   TopLayout->setSpacing(6);
1009   TopLayout->setMargin(11);
1010
1011   myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref);
1012   TopLayout->addWidget(myScalarPane);
1013
1014   // Common buttons ===========================================================
1015   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1016   GroupButtons->setColumnLayout(0, Qt::Vertical );
1017   GroupButtons->layout()->setSpacing( 0 );
1018   GroupButtons->layout()->setMargin( 0 );
1019   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1020   GroupButtonsLayout->setAlignment( Qt::AlignTop );
1021   GroupButtonsLayout->setSpacing( 6 );
1022   GroupButtonsLayout->setMargin( 11 );
1023
1024   QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
1025   buttonOk->setAutoDefault( TRUE );
1026   buttonOk->setDefault( TRUE );
1027   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
1028   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1029
1030   QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
1031   buttonCancel->setAutoDefault( TRUE );
1032   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
1033
1034   TopLayout->addWidget( GroupButtons );
1035
1036   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
1037   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
1038 }
1039
1040 /*!
1041   Called when <OK> button is clicked, validates data and closes dialog
1042 */
1043 void VisuGUI_ScalarBarDlg::accept()
1044 {
1045   if (myScalarPane->check()) 
1046     {
1047       myScalarPane->deletePreview(); 
1048       QDialog::accept();
1049     }
1050 }
1051
1052 /*!
1053   Called when <Cancel> button is clicked, remove preview and closes dialog
1054 */
1055 void VisuGUI_ScalarBarDlg::reject()
1056 {
1057   myScalarPane->deletePreview();
1058   QDialog::reject();
1059 }
1060
1061
1062 //#######################################################################################
1063 VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent)
1064   : QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
1065 {
1066   setName("VisuGUI_TextPrefDlg");
1067   setCaption(tr("TIT_TEXT_PREF"));
1068   setSizeGripEnabled(TRUE);
1069
1070   QVBoxLayout* TopLayout = new QVBoxLayout(this);
1071   TopLayout->setSpacing(6);
1072   TopLayout->setMargin(11);
1073
1074   // "Title" grp
1075   QGroupBox* aTitleGrp = new QGroupBox (2, Qt::Vertical, tr("LBL_TITLE"), this);
1076
1077   //   edit line
1078   myTitleEdt = new QLineEdit (aTitleGrp);
1079
1080   //   font
1081   QHBox* aHBox = new QHBox (aTitleGrp);
1082   aHBox->setSpacing(5);
1083   myTitleFont = new VisuGUI_FontWg (aHBox);
1084
1085   TopLayout->addWidget(aTitleGrp);
1086
1087   // "Labels" grp
1088   QGroupBox* aLabelsGrp = new QGroupBox (1, Qt::Vertical, tr("LBL_LABELS"), this);
1089
1090   //   font
1091   aHBox = new QHBox (aLabelsGrp);
1092   aHBox->setSpacing(5);
1093   myLabelFont = new VisuGUI_FontWg (aHBox);
1094
1095   TopLayout->addWidget(aLabelsGrp);
1096
1097   // Common buttons ===========================================================
1098   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1099   GroupButtons->setColumnLayout(0, Qt::Vertical );
1100   GroupButtons->layout()->setSpacing( 0 );
1101   GroupButtons->layout()->setMargin( 0 );
1102   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1103   GroupButtonsLayout->setAlignment( Qt::AlignTop );
1104   GroupButtonsLayout->setSpacing( 6 );
1105   GroupButtonsLayout->setMargin( 11 );
1106
1107   QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
1108   buttonOk->setAutoDefault( TRUE );
1109   buttonOk->setDefault( TRUE );
1110   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
1111   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1112
1113   QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
1114   buttonCancel->setAutoDefault( TRUE );
1115   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
1116
1117   TopLayout->addWidget( GroupButtons );
1118
1119   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(accept()));
1120   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
1121 }