]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI_ScalarBarDlg.cxx
Salome HOME
Fix for bug PAL10966.
[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 }
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   int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0);
282   myModeCombo->setCurrentItem(aScalarMode);
283
284   orient = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", orient);
285   if(orient != 0){
286     orient=1;
287     sbX1=0.2;
288     sbY1=0.01;
289     sbW=0.6;
290     sbH=0.12;
291   }
292   
293   QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
294
295   sbX1 = aResourceMgr->doubleValue("VISU", propertyName + "x", sbX1);
296   sbY1 = aResourceMgr->doubleValue("VISU", propertyName + "y", sbY1);
297
298   sbW = aResourceMgr->doubleValue("VISU", propertyName + "width", sbW);
299   sbH = aResourceMgr->doubleValue("VISU", propertyName + "height",sbH);
300   
301   sbCol = aResourceMgr->integerValue("VISU" ,"scalar_bar_num_colors", sbCol);
302   sbLab = aResourceMgr->integerValue("VISU", "scalar_bar_num_labels", sbLab);
303
304   int rangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0);
305   if (rangeType == 1) sbRange = true;
306   sbVmin = aResourceMgr->doubleValue("VISU", "scalar_range_min", sbVmin);
307   sbVmax = aResourceMgr->doubleValue("VISU", "scalar_range_max", sbVmax);
308
309   bool isLog = aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false);
310   setLogarithmic(isLog);
311   
312   if((sbX1 < 0.) || (sbY1 < 0.) ||
313      ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
314     if(orient == 0) {
315       sbX1=0.01;
316       sbY1=0.1;
317       sbW=0.1;
318       sbH=0.8;
319     } else {
320       sbX1=0.2;
321       sbY1=0.01;
322       sbW=0.6;
323       sbH=0.12;
324     }
325   }
326   if(sbCol < 2) sbCol=2;
327   if(sbCol > 64) sbCol=64;
328   if(sbLab < 2) sbLab=2;
329   if(sbLab > 65) sbLab=65;
330
331   if(sbVmin > sbVmax) {
332     sbVmin=0.;
333     sbVmax=0.;
334   }
335
336   setRange( sbVmin, sbVmax, /*0.0, 0.0,*/ sbRange );
337   setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 0);
338   setScalarBarData( sbCol, sbLab );
339
340   // "Title"
341   bool isBold = false, isItalic = false, isShadow = false;
342   int aFontFamily = VTK_ARIAL;
343
344   if ( aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" ) )
345     {
346       QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" );
347       
348       if ( f.family() == "Arial" )
349         aFontFamily = VTK_ARIAL;
350       else if ( f.family() == "Courier" )
351         aFontFamily = VTK_COURIER;
352       else if ( f.family() == "Times" )
353         aFontFamily = VTK_TIMES;
354       
355       isBold = f.bold();
356       isItalic = f.italic();
357       isShadow =  f.underline();
358     }
359   
360   QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
361   
362   myTextDlg->myTitleFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
363
364   // "Labels"
365   isBold = isItalic = isShadow = false;
366   aFontFamily = VTK_ARIAL;
367
368   if ( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" ) )
369     {
370       QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" );
371       
372       if ( f.family() == "Arial" )
373         aFontFamily = VTK_ARIAL;
374       else if ( f.family() == "Courier" )
375         aFontFamily = VTK_COURIER;
376       else if ( f.family() == "Times" )
377         aFontFamily = VTK_TIMES;
378       
379       isBold = f.bold();
380       isItalic = f.italic();
381       isShadow =  f.underline();
382     }
383   
384   aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
385   
386   myTextDlg->myLabelFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
387 }
388
389 /**
390  * Stores dialog values to resources
391  */
392 void VisuGUI_ScalarBarPane::storeToResources() {
393   int orient = (RBvert->isChecked())? 0 : 1;
394   float sbX1   = XSpin->value();
395   float sbY1   = YSpin->value();
396   float sbW    = WidthSpin->value();
397   float sbH    = HeightSpin->value();
398   int sbCol  = ColorSpin->value();
399   int sbLab  = LabelSpin->value();
400
401   if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
402     if(orient == 0) {
403       sbX1=0.01;
404       sbY1=0.1;
405       sbW=0.17;
406       sbH=0.8;
407     } else {
408       sbX1=0.2;
409       sbY1=0.01;
410       sbW=0.6;
411       sbH=0.12;
412     }
413   }
414
415   bool sbRange = RBIrange->isChecked();
416   float sbVmin = (float)(MinEdit->text().toDouble());
417   float sbVmax = (float)(MaxEdit->text().toDouble());
418
419   if(sbVmin > sbVmax) {
420     sbVmin=0.;
421     sbVmax=0.;
422   }
423
424   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
425
426   aResourceMgr->setValue("VISU", "scalar_bar_orientation", orient);
427
428   QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
429
430   aResourceMgr->setValue("VISU", propertyName + "x", sbX1);
431   aResourceMgr->setValue("VISU", propertyName + "y", sbY1);
432   aResourceMgr->setValue("VISU", propertyName + "width", sbW);
433   aResourceMgr->setValue("VISU", propertyName + "height", sbH);
434
435   aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol);
436   aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab);
437
438   if(sbRange)
439     {
440       aResourceMgr->setValue("VISU", "scalar_range_type", 1);
441       aResourceMgr->setValue("VISU", "scalar_range_min" ,sbVmin);
442       aResourceMgr->setValue("VISU", "scalar_range_max" ,sbVmax);
443     }
444   else
445     aResourceMgr->setValue("VISU", "scalar_range_type", 0);
446   
447   aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic());
448  
449   ////
450
451   if (myIsStoreTextProp) {
452     // "Title"
453     QColor aTitleColor (255, 255, 255);
454     int aTitleFontFamily = VTK_ARIAL;
455     bool isTitleBold = false;
456     bool isTitleItalic = false;
457     bool isTitleShadow = false;
458
459     myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily,
460                                     isTitleBold, isTitleItalic, isTitleShadow);
461
462     QFont aTitleFont;
463     
464     aTitleFont.setBold(isTitleBold);
465     aTitleFont.setItalic(isTitleItalic);
466     aTitleFont.setUnderline(isTitleShadow);
467     
468     QString titleFontFamily;
469     switch (aTitleFontFamily) {
470     case VTK_ARIAL:
471       titleFontFamily = "Arial";
472       break;
473     case VTK_COURIER:
474       titleFontFamily = "Courier";
475       break;
476     case VTK_TIMES:
477       titleFontFamily = "Times";
478       break;
479     }
480     aTitleFont.setFamily(titleFontFamily);
481     
482     aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont);
483     
484     aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor);
485     
486     // "Label"
487     QColor aLabelColor (255, 255, 255);
488     int aLabelFontFamily = VTK_ARIAL;
489     bool isLabelBold = false;
490     bool isLabelItalic = false;
491     bool isLabelShadow = false;
492
493     myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
494                                     isLabelBold, isLabelItalic, isLabelShadow);
495
496
497     QFont aLabelFont;
498     
499     aLabelFont.setBold(isLabelBold);
500     aLabelFont.setItalic(isLabelItalic);
501     aLabelFont.setUnderline(isLabelShadow);
502
503     QString labelFontFamily;
504     switch (aLabelFontFamily) {
505     case VTK_ARIAL:
506       labelFontFamily = "Arial";
507       break;
508     case VTK_COURIER:
509       labelFontFamily = "Courier";
510       break;
511     case VTK_TIMES:
512       labelFontFamily = "Times";
513       break;
514     }
515
516     aLabelFont.setFamily(labelFontFamily);
517     
518     aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont);
519
520     aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor);
521   }
522 }
523
524 /**
525  * Initialise dialog box from presentation object
526  */
527 void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
528   initFromResources();
529   myScalarMap = thePrs;
530   myModeCombo->setCurrentItem(thePrs->GetScalarMode());
531   setPosAndSize( thePrs->GetPosX(),
532                  thePrs->GetPosY(),
533                  thePrs->GetWidth(),
534                  thePrs->GetHeight(),
535                  thePrs->GetBarOrientation());
536   switch(thePrs->GetScaling()){
537   case VISU::LOGARITHMIC :
538     setLogarithmic(true);
539     break;
540   default:
541     setLogarithmic(false);
542   }
543   float aRange[2];
544   thePrs->GetScalarMapPL()->GetSourceRange(aRange);
545   Rmin = aRange[0]; Rmax = aRange[1];
546   setRange( thePrs->GetMin(), thePrs->GetMax(),
547             /*0.0, 0.0,*/ thePrs->IsRangeFixed() );
548   setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
549   bool isScalarMode = (thePrs->GetField()->myNbComp > 1);
550   myModeLbl->setEnabled(isScalarMode);
551   myModeCombo->setEnabled(isScalarMode);
552
553   // "Title"
554   myTextDlg->setTitleText(QString(thePrs->GetTitle()));
555
556   float R, G, B;
557   thePrs->GetTitleColor(&R, &G, &B);
558
559   myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
560                                   thePrs->GetTitFontType(),
561                                   thePrs->IsBoldTitle(),
562                                   thePrs->IsItalicTitle(),
563                                   thePrs->IsShadowTitle());
564
565   // "Labels"
566   thePrs->GetLabelColor(&R, &G, &B);
567
568   myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
569                                   thePrs->GetLblFontType(),
570                                   thePrs->IsBoldLabel(),
571                                   thePrs->IsItalicLabel(),
572                                   thePrs->IsShadowLabel());
573
574   // Draw Preview
575   if (myPreviewCheck->isChecked()) {
576     createScalarBar();
577     updatePreview();
578   }
579
580 }
581 /*! Slot update preview of scalar bar, if preview is checked
582  */
583 void VisuGUI_ScalarBarPane::updatePreview()
584 {
585   if (myPreviewCheck->isChecked()) {
586     if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) {
587       deleteScalarBar();
588       createScalarBar();
589       vf->Repaint();
590     }
591   }
592 }
593
594 /*! Creating preview scalar bar
595  */
596 void VisuGUI_ScalarBarPane::createScalarBar()
597 {
598   if (VISU::GetViewWindow() == NULL) return;
599   if (myPreviewActor != 0) return;
600   if (myScalarMap == NULL) return;
601
602   if(!check()) return;
603
604   if ( myBusy ) return;
605
606   myBusy = true;
607
608   int sbCol,sbLab;
609   sbCol = getNbColors();
610   sbLab = getNbLabels();
611   if(sbCol < 2) sbCol=2;
612   if(sbCol > 64) sbCol=64;
613   if(sbLab < 2) sbLab=2;
614   if(sbLab > 65) sbLab=65;
615   myPreviewActor = VISU_ScalarMapAct::New();
616   VISU_ScalarBarActor* aScalarBarActor = myPreviewActor->GetScalarBar();
617   myPreviewActor->GetScalarBar()->VisibilityOn();
618   myPreviewActor->PickableOff();
619   
620   myScalarMap->SetScalarMode(myModeCombo->currentItem());
621   myScalarMap->SetPosition(getX(),getY());
622   myScalarMap->SetSize(getWidth(),getHeight());
623   myScalarMap->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
624   if(isLogarithmic())
625     myScalarMap->SetScaling(VISU::LOGARITHMIC);
626   else
627     myScalarMap->SetScaling(VISU::LINEAR);
628   if (RBFrange->isChecked()) {
629     myScalarMap->SetSourceRange();
630   } else {
631     myScalarMap->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
632   }
633   myScalarMap->SetNbColors(sbCol);
634   myScalarMap->SetLabels(sbLab); 
635   
636   myScalarMap->GetScalarMapPL()->SetNbColors(sbCol);
637   myScalarMap->GetScalarMapPL()->Update();
638     
639   aScalarBarActor->SetLookupTable(myScalarMap->GetScalarMapPL()->GetBarTable());
640   
641   if (myTextDlg->getTitleText().latin1() != "") 
642     aScalarBarActor->SetTitle(myTextDlg->getTitleText().latin1());
643   else
644     aScalarBarActor->SetTitle(myScalarMap->GetTitle());
645   aScalarBarActor->SetOrientation(getOrientation());
646   aScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
647   aScalarBarActor->GetPositionCoordinate()->SetValue(getX(),getY());
648   aScalarBarActor->SetWidth(getWidth());
649   aScalarBarActor->SetHeight(getHeight());
650   aScalarBarActor->SetNumberOfLabels(sbLab);
651   aScalarBarActor->SetMaximumNumberOfColors(sbCol);
652
653   // title text property
654   QColor aTitleColor;
655   int aTitleFontFamily;
656   bool isTitleBold;
657   bool isTitleItalic;
658   bool isTitleShadow;
659   myTextDlg->myTitleFont->GetData(aTitleColor,aTitleFontFamily,
660                                   isTitleBold,isTitleItalic,isTitleShadow);
661   vtkTextProperty* aTitleProp = aScalarBarActor->GetTitleTextProperty();
662   aTitleProp->SetFontFamily(aTitleFontFamily);
663   aTitleProp->SetColor(float(aTitleColor.red())/255.,
664                        float(aTitleColor.green())/255.,
665                        float(aTitleColor.blue())/255.);
666   (isTitleBold)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
667   (isTitleItalic)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
668   (isTitleShadow)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
669   
670   // label text property
671   QColor aLabelColor;
672   int aLabelFontFamily;
673   bool isLabelBold;
674   bool isLabelItalic;
675   bool isLabelShadow;
676   myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
677                                   isLabelBold, isLabelItalic, isLabelShadow);
678   vtkTextProperty* aLabelProp = aScalarBarActor->GetLabelTextProperty();
679   aLabelProp->SetFontFamily(aLabelFontFamily);
680   aLabelProp->SetColor(float(aLabelColor.red())/255.,
681                        float(aLabelColor.green())/255.,
682                        float(aLabelColor.blue())/255.);
683   (isLabelBold)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
684   (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
685   (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
686
687   aScalarBarActor->Modified();
688
689   VISU::GetViewWindow()->AddActor(myPreviewActor);
690
691   myBusy = false;
692 }
693 /*! Deleting preview scalar bar
694  */
695 void VisuGUI_ScalarBarPane::deleteScalarBar()
696 {
697   if ( myBusy ) return;
698   
699   if (myPreviewActor == 0) return;
700   if (SVTK_ViewWindow* vf = VISU::GetViewWindow()){
701     vf->RemoveActor(myPreviewActor);
702     myPreviewActor->GetScalarBar()->VisibilityOff();
703   }
704   myPreviewActor->Delete();
705   myPreviewActor = 0;
706 }
707 /*! public: Deleting preview scalar bar
708  */
709 void VisuGUI_ScalarBarPane::deletePreview()
710 {
711   deleteScalarBar();
712 }
713 /**
714  * Store values to presentation object
715  */
716 int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ScalarMap_i* thePrs) {
717   thePrs->SetScalarMode(myModeCombo->currentItem());
718   thePrs->SetPosition(XSpin->value(), YSpin->value());
719   thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
720   thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
721   if(isLogarithmic())
722     thePrs->SetScaling(VISU::LOGARITHMIC);
723   else
724     thePrs->SetScaling(VISU::LINEAR);
725
726   if (RBFrange->isChecked()) {
727     thePrs->SetSourceRange();
728   } else {
729     thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
730   }
731   thePrs->SetNbColors(ColorSpin->value());
732   thePrs->SetLabels(LabelSpin->value());
733
734   if (isToSave()) storeToResources();
735
736   if (myIsStoreTextProp) {
737     // "Title"
738     thePrs->SetTitle(myTextDlg->getTitleText().latin1());
739
740     QColor aTitColor (255, 255, 255);
741     int aTitleFontFamily = VTK_ARIAL;
742     bool isTitleBold = false;
743     bool isTitleItalic = false;
744     bool isTitleShadow = false;
745
746     myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
747                                     isTitleBold, isTitleItalic, isTitleShadow);
748
749     thePrs->SetBoldTitle(isTitleBold);
750     thePrs->SetItalicTitle(isTitleItalic);
751     thePrs->SetShadowTitle(isTitleShadow);
752     thePrs->SetTitFontType(aTitleFontFamily);
753     thePrs->SetTitleColor(aTitColor.red()/255.,
754                           aTitColor.green()/255.,
755                           aTitColor.blue()/255.);
756
757     // "Label"
758     QColor aLblColor (255, 255, 255);
759     int aLabelFontFamily = VTK_ARIAL;
760     bool isLabelBold = false;
761     bool isLabelItalic = false;
762     bool isLabelShadow = false;
763
764     myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
765                                     isLabelBold, isLabelItalic, isLabelShadow);
766
767     thePrs->SetBoldLabel(isLabelBold);
768     thePrs->SetItalicLabel(isLabelItalic);
769     thePrs->SetShadowLabel(isLabelShadow);
770     thePrs->SetLblFontType(aLabelFontFamily);
771     thePrs->SetLabelColor(aLblColor.red()/255.,
772                           aLblColor.green()/255.,
773                           aLblColor.blue()/255.);
774   }
775
776   return 1;
777 }
778
779 /*!
780   Called when orientation is changed
781 */
782 void VisuGUI_ScalarBarPane::changeDefaults( int )
783 {
784   if ( RBvert->isChecked() ) {
785     XSpin->setValue( myVerX );
786     YSpin->setValue( myVerY );
787     WidthSpin->setValue( myVerW );
788     HeightSpin->setValue( myVerH );
789   }
790   else {
791     XSpin->setValue( myHorX );
792     YSpin->setValue( myHorY );
793     WidthSpin->setValue( myHorW );
794     HeightSpin->setValue( myHorH );
795   }
796   updatePreview();
797 }
798
799 /*!
800   Called when Range mode is changed
801 */
802 void VisuGUI_ScalarBarPane::changeRange( int )
803 {
804   int mode = -1;
805   if ( RBFrange->isChecked() )
806     mode = 0;
807   if ( RBIrange->isChecked() )
808     mode = 1;
809   if ( myRangeMode == mode )
810     return;
811   //MinSpin->setMaxValue( Fmin );
812   //MaxSpin->setMinValue( Fmax );
813   if ( RBFrange->isChecked() ) {
814     //MinLabel->setEnabled( false );
815     MinEdit->setEnabled( false );
816     //MaxLabel->setEnabled( false );
817     MaxEdit->setEnabled( false );
818     if ( mode != -1 ) {
819       Imin = MinEdit->text().toDouble();
820       Imax = MaxEdit->text().toDouble();
821     }
822     MinEdit->setText( QString::number( Rmin ) );
823     MaxEdit->setText( QString::number( Rmax ) );
824   }
825   else {
826     //MinLabel->setEnabled( true );
827     MinEdit->setEnabled( true );
828     //MaxLabel->setEnabled( true );
829     MaxEdit->setEnabled( true );
830     MinEdit->setText( QString::number( Imin ) );
831     MaxEdit->setText( QString::number( Imax ) );
832   }
833   myRangeMode = mode;
834   updatePreview();
835 }
836
837 /*!
838   Called when X,Y position is changed
839 */
840 void VisuGUI_ScalarBarPane::XYChanged( double )
841 {
842   QtxDblSpinBox* snd = (QtxDblSpinBox*)sender();
843   if ( snd == XSpin ) {
844     WidthSpin->setMaxValue( 1.0 - XSpin->value() );
845   }
846   if ( snd == YSpin ) {
847     HeightSpin->setMaxValue( 1.0 - YSpin->value() );
848   }
849   updatePreview();
850 }
851
852 /*!
853   Sets default values and range mode
854 */
855 void VisuGUI_ScalarBarPane::setRange( double imin, double imax/*, double fmin, double fmax*/, bool sbRange )
856 {
857   Imin = imin; Imax = imax;// Fmin = fmin; Fmax = fmax;
858   if ( RBIrange->isChecked() ) {
859     MinEdit->setText( QString::number( Imin ) );
860     MaxEdit->setText( QString::number( Imax ) );
861   }
862   else {
863     MinEdit->setText( QString::number( Rmin ) );
864     MaxEdit->setText( QString::number( Rmax ) );
865   }
866   myRangeMode = -1;
867   if( sbRange )
868     RBIrange->setChecked( true );
869   else
870     RBFrange->setChecked( true );
871   changeRange( 0 );
872 }
873
874 /*!
875   Sets size and position
876 */
877 void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
878 {
879   if ( vert ) {
880     myVerX = x;
881     myVerY = y;
882     myVerW = w;
883     myVerH = h;
884     RBvert->setChecked( true );
885   }
886   else {
887     myHorX = x;
888     myHorY = y;
889     myHorW = w;
890     myHorH = h;
891     RBhori->setChecked( true );
892   }
893   changeDefaults( 0 );
894 }
895
896 /*!
897   Sets colors and labels number
898 */
899 void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
900 {
901   ColorSpin->setValue( colors );
902   LabelSpin->setValue( labels );
903 }
904
905 /*!
906   Gets orientation
907 */
908 int  VisuGUI_ScalarBarPane::getOrientation()
909 {
910   if (RBvert->isChecked() )
911     return  1;
912   else
913     return 0;
914 }
915
916 /*!
917   Called when <OK> button is clicked, validates data and closes dialog
918 */
919 bool VisuGUI_ScalarBarPane::check()
920 {
921   double minVal = MinEdit->text().toDouble();
922   double maxVal = MaxEdit->text().toDouble();
923   if ( RBIrange->isChecked() ) {
924     if (minVal >= maxVal) {
925       SUIT_MessageBox::warn1( this,tr("WRN_VISU"),
926                              tr("MSG_MINMAX_VALUES"),
927                              tr("BUT_OK"));
928       return false;
929     }
930   }
931   // check if logarithmic mode is on and check imposed range to not contain negative values
932   if ( CBLog->isChecked() ) {
933     if ( RBIrange->isChecked() ) {
934       if ( (minVal > 0) && (maxVal > 0) ) {
935         // nothing to do
936       }
937       else {
938         SUIT_MessageBox::warn1( this,
939                                 tr("WRN_VISU"),
940                                 tr("WRN_LOGARITHMIC_RANGE"),
941                                 tr("BUT_OK"));
942         return false;
943       }
944     }
945     else {
946       if ( Rmin > 0 && Rmax > 0 ) {
947         // nothing to do
948       }
949       else {
950         SUIT_MessageBox::warn1( this,
951                                 tr("WRN_VISU"),
952                                 tr("WRN_LOGARITHMIC_FIELD_RANGE"),
953                                 tr("BUT_OK"));
954         RBIrange->setChecked(1);
955         changeRange(1);
956         //MinEdit->setText( QString::number( Rmin ) );
957         //MaxEdit->setText( QString::number( Rmax ) );
958         return false;
959       }
960     }
961   }
962   return true;
963 }
964
965 void VisuGUI_ScalarBarPane::onTextPref()
966 {
967   myIsStoreTextProp = myTextDlg->exec();
968   updatePreview();
969 }
970
971 void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview)
972 {
973   if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) {
974     if (thePreview) {
975       createScalarBar();
976     } else {
977       deleteScalarBar();
978     }
979     vf->Repaint();
980   }
981 }
982
983 //#######################################################################################
984
985 /*!
986   Constructor
987 */
988 VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool SetPref)
989     : QDialog(VISU::GetDesktop(theModule), 0, true,
990               WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
991 {
992   setName("VisuGUI_ScalarBarDlg");
993   setCaption(SetPref ? tr("DLG_PREF_TITLE") : tr("DLG_PROP_TITLE"));
994   setSizeGripEnabled(TRUE);
995
996   QVBoxLayout* TopLayout = new QVBoxLayout(this);
997   TopLayout->setSpacing(6);
998   TopLayout->setMargin(11);
999
1000   myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref);
1001   TopLayout->addWidget(myScalarPane);
1002
1003   // Common buttons ===========================================================
1004   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1005   GroupButtons->setColumnLayout(0, Qt::Vertical );
1006   GroupButtons->layout()->setSpacing( 0 );
1007   GroupButtons->layout()->setMargin( 0 );
1008   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1009   GroupButtonsLayout->setAlignment( Qt::AlignTop );
1010   GroupButtonsLayout->setSpacing( 6 );
1011   GroupButtonsLayout->setMargin( 11 );
1012
1013   QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
1014   buttonOk->setAutoDefault( TRUE );
1015   buttonOk->setDefault( TRUE );
1016   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
1017   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1018
1019   QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
1020   buttonCancel->setAutoDefault( TRUE );
1021   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
1022
1023   TopLayout->addWidget( GroupButtons );
1024
1025   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
1026   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
1027 }
1028
1029 /*!
1030   Called when <OK> button is clicked, validates data and closes dialog
1031 */
1032 void VisuGUI_ScalarBarDlg::accept()
1033 {
1034   myScalarPane->deletePreview();
1035   if (myScalarPane->check()) QDialog::accept();
1036 }
1037
1038 /*!
1039   Called when <Cancel> button is clicked, remove preview and closes dialog
1040 */
1041 void VisuGUI_ScalarBarDlg::reject()
1042 {
1043   myScalarPane->deletePreview();
1044   QDialog::reject();
1045 }
1046
1047
1048 //#######################################################################################
1049 VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent)
1050   : QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
1051 {
1052   setName("VisuGUI_TextPrefDlg");
1053   setCaption(tr("TIT_TEXT_PREF"));
1054   setSizeGripEnabled(TRUE);
1055
1056   QVBoxLayout* TopLayout = new QVBoxLayout(this);
1057   TopLayout->setSpacing(6);
1058   TopLayout->setMargin(11);
1059
1060   // "Title" grp
1061   QGroupBox* aTitleGrp = new QGroupBox (2, Qt::Vertical, tr("LBL_TITLE"), this);
1062
1063   //   edit line
1064   myTitleEdt = new QLineEdit (aTitleGrp);
1065
1066   //   font
1067   QHBox* aHBox = new QHBox (aTitleGrp);
1068   aHBox->setSpacing(5);
1069   myTitleFont = new VisuGUI_FontWg (aHBox);
1070
1071   TopLayout->addWidget(aTitleGrp);
1072
1073   // "Labels" grp
1074   QGroupBox* aLabelsGrp = new QGroupBox (1, Qt::Vertical, tr("LBL_LABELS"), this);
1075
1076   //   font
1077   aHBox = new QHBox (aLabelsGrp);
1078   aHBox->setSpacing(5);
1079   myLabelFont = new VisuGUI_FontWg (aHBox);
1080
1081   TopLayout->addWidget(aLabelsGrp);
1082
1083   // Common buttons ===========================================================
1084   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1085   GroupButtons->setColumnLayout(0, Qt::Vertical );
1086   GroupButtons->layout()->setSpacing( 0 );
1087   GroupButtons->layout()->setMargin( 0 );
1088   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1089   GroupButtonsLayout->setAlignment( Qt::AlignTop );
1090   GroupButtonsLayout->setSpacing( 6 );
1091   GroupButtonsLayout->setMargin( 11 );
1092
1093   QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
1094   buttonOk->setAutoDefault( TRUE );
1095   buttonOk->setDefault( TRUE );
1096   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
1097   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1098
1099   QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
1100   buttonCancel->setAutoDefault( TRUE );
1101   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
1102
1103   TopLayout->addWidget( GroupButtons );
1104
1105   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(accept()));
1106   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
1107 }