1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : VisuGUI_ScalarBarDlg.cxx
25 // Author : Laurent CORNABE & Hubert ROLLAND
29 #include "VisuGUI_ScalarBarDlg.h"
32 #include "VisuGUI_Tools.h"
33 #include "VisuGUI_ViewTools.h"
35 #include "SVTK_ViewWindow.h"
36 #include "SVTK_FontWidget.h"
38 #include "VISUConfig.hh"
39 #include "VISU_Convertor.hxx"
41 #include "VISU_ScalarMapPL.hxx"
42 #include "VISU_ScalarMap_i.hh"
43 #include "VISU_ScalarMapAct.h"
45 #include "LightApp_Application.h"
47 #include "SUIT_Session.h"
48 #include "SUIT_MessageBox.h"
49 #include "SUIT_ResourceMgr.h"
53 #include <qvalidator.h>
54 #include <qcolordialog.h>
56 #include <vtkTextProperty.h>
61 VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
62 QVBox(parent), myPreviewActor(0)
64 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
66 propertyName = QString("scalar_bar_vertical_");
67 myVerX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
68 myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
69 myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
70 myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
72 propertyName = QString("scalar_bar_horizontal_");
73 myHorX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
74 myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
75 myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
76 myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
78 Imin = 0.0; Imax = 0.0; /*Fmin = 0.0; Fmax = 0.0;*/ Rmin = 0.0; Rmax = 0.0;
84 // Range ============================================================
85 RangeGroup = new QButtonGroup (tr("SCALAR_RANGE_GRP"), this, "RangeGroup");
86 RangeGroup->setColumnLayout(0, Qt::Vertical );
87 RangeGroup->layout()->setSpacing( 0 );
88 RangeGroup->layout()->setMargin( 0 );
89 QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() );
90 RangeGroupLayout->setAlignment( Qt::AlignTop );
91 RangeGroupLayout->setSpacing( 6 );
92 RangeGroupLayout->setMargin( 11 );
94 myModeLbl = new QLabel("Scalar Mode", RangeGroup);
96 myModeCombo = new QComboBox(RangeGroup);
98 CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), RangeGroup);
99 CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
101 RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), RangeGroup, "RBFrange");
102 RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), RangeGroup, "RBIrange");
103 RBFrange->setChecked( true );
105 MinEdit = new QLineEdit( RangeGroup, "MinEdit" );
106 MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
107 MinEdit->setMinimumWidth( 70 );
108 MinEdit->setValidator( new QDoubleValidator(this) );
109 MinEdit->setText( "0.0" );
110 QLabel* MinLabel = new QLabel (tr("LBL_MIN"), RangeGroup, "MinLabel");
111 MinLabel->setBuddy(MinEdit);
113 MaxEdit = new QLineEdit( RangeGroup, "MaxEdit" );
114 MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
115 MaxEdit->setMinimumWidth( 70 );
116 MaxEdit->setValidator( new QDoubleValidator(this) );
117 MaxEdit->setText( "0.0" );
118 QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), RangeGroup, "MaxLabel");
119 MaxLabel->setBuddy(MaxEdit);
121 RangeGroupLayout->addWidget( myModeLbl, 0, 0 );
122 RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3);
123 RangeGroupLayout->addMultiCellWidget( CBLog, 1, 1, 0, 3);
124 RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1);
125 RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3);
126 RangeGroupLayout->addWidget( MinLabel, 3, 0 );
127 RangeGroupLayout->addWidget( MinEdit, 3, 1 );
128 RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
129 RangeGroupLayout->addWidget( MaxEdit, 3, 3 );
131 //TopLayout->addWidget( RangeGroup );
133 // Colors and Labels ========================================================
134 QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this, "ColLabGroup");
135 ColLabGroup->setColumnLayout(0, Qt::Vertical );
136 ColLabGroup->layout()->setSpacing( 0 );
137 ColLabGroup->layout()->setMargin( 0 );
138 QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() );
139 ColLabGroupLayout->setAlignment( Qt::AlignTop );
140 ColLabGroupLayout->setSpacing( 6 );
141 ColLabGroupLayout->setMargin( 11 );
143 QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup, "ColorLabel");
144 ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup );
145 ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
146 ColorSpin->setMinimumWidth( 70 );
147 ColorSpin->setValue( 64 );
149 QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup, "LabelLabel");
150 LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup );
151 LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
152 LabelSpin->setMinimumWidth( 70 );
153 LabelSpin->setValue( 5 );
155 ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
156 ColLabGroupLayout->addWidget( ColorSpin, 0, 1);
157 ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
158 ColLabGroupLayout->addWidget( LabelSpin, 0, 3);
160 //TopLayout->addWidget( ColLabGroup );
162 // Orientation ==========================================================
163 QButtonGroup* OrientGroup = new QButtonGroup (tr("ORIENTATION_GRP"), this, "OrientGroup");
164 OrientGroup->setColumnLayout(0, Qt::Vertical );
165 OrientGroup->layout()->setSpacing( 0 );
166 OrientGroup->layout()->setMargin( 0 );
167 QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() );
168 OrientGroupLayout->setAlignment( Qt::AlignTop );
169 OrientGroupLayout->setSpacing( 6 );
170 OrientGroupLayout->setMargin( 11 );
172 RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGroup, "RBvert");
173 RBvert->setChecked( true );
174 RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGroup, "RBhori");
175 OrientGroupLayout->addWidget( RBvert, 0, 0 );
176 OrientGroupLayout->addWidget( RBhori, 0, 1 );
178 // TopLayout->addWidget( OrientGroup );
180 // Origin ===============================================================
181 QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this, "OriginGroup");
182 OriginGroup->setColumnLayout(0, Qt::Vertical );
183 OriginGroup->layout()->setSpacing( 0 );
184 OriginGroup->layout()->setMargin( 0 );
185 QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() );
186 OriginGroupLayout->setAlignment( Qt::AlignTop );
187 OriginGroupLayout->setSpacing( 6 );
188 OriginGroupLayout->setMargin( 11 );
190 QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup, "XLabel");
191 XSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
192 XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
193 XSpin->setMinimumWidth( 70 );
194 XSpin->setValue( 0.01 );
196 QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup, "YLabel");
197 YSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
198 YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
199 YSpin->setMinimumWidth( 70 );
200 YSpin->setValue( 0.01 );
202 OriginGroupLayout->addWidget( XLabel, 0, 0);
203 OriginGroupLayout->addWidget( XSpin, 0, 1);
204 OriginGroupLayout->addWidget( YLabel, 0, 2);
205 OriginGroupLayout->addWidget( YSpin, 0, 3);
207 //TopLayout->addWidget( OriginGroup );
209 // Dimensions =========================================================
210 QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this, "DimGroup");
211 DimGroup->setColumnLayout(0, Qt::Vertical );
212 DimGroup->layout()->setSpacing( 0 );
213 DimGroup->layout()->setMargin( 0 );
214 QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() );
215 DimGroupLayout->setAlignment( Qt::AlignTop );
216 DimGroupLayout->setSpacing( 6 );
217 DimGroupLayout->setMargin( 11 );
219 QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup, "WidthLabel");
220 WidthSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
221 WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
222 WidthSpin->setMinimumWidth( 70 );
223 WidthSpin->setValue( 0.1 );
225 QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup, "HeightLabel");
226 HeightSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
227 HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
228 HeightSpin->setMinimumWidth( 70 );
229 HeightSpin->setValue( 0.8 );
231 DimGroupLayout->addWidget( WidthLabel, 0, 0);
232 DimGroupLayout->addWidget( WidthSpin, 0, 1);
233 DimGroupLayout->addWidget( HeightLabel, 0, 2);
234 DimGroupLayout->addWidget( HeightSpin, 0, 3);
236 //TopLayout->addWidget( DimGroup );
238 // Save check box ===========================================================
239 QHBox* aSaveBox = new QHBox(this);
241 CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), aSaveBox, "CBSave");
242 //TopLayout->addWidget(CBSave);
247 myTextBtn = new QPushButton("Text properties...", aSaveBox);
248 myTextDlg = new VisuGUI_TextPrefDlg(this);
249 myTextDlg->setTitleVisible(!SetPref);
251 QGroupBox* CheckGroup = new QGroupBox("", this, "CheckGroup");
252 CheckGroup->setColumnLayout(0, Qt::Vertical );
253 CheckGroup->layout()->setSpacing( 0 );
254 CheckGroup->layout()->setMargin( 0 );
255 QGridLayout* CheckGroupLayout = new QGridLayout( CheckGroup->layout() );
257 myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), CheckGroup);
258 myPreviewCheck->setChecked(false);
259 CheckGroupLayout->addWidget(myPreviewCheck , 0, 0 );
261 // signals and slots connections ===========================================
262 connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) );
263 connect( myModeCombo, SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( int ) ) );
264 connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) );
265 connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
266 connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
267 connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
268 connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) );
269 connect( ColorSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
270 connect( LabelSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
271 connect( WidthSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
272 connect( HeightSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
273 connect( CBLog, SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() ));
276 myIsStoreTextProp = false;
281 * Initializes dialog box values from resources
283 void VisuGUI_ScalarBarPane::initFromResources() {
284 int sbCol=64,sbLab=5,orient=0;
285 float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8;
286 float sbVmin=0., sbVmax=0.;
290 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
292 bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0);
295 aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0);
298 int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0);
299 myModeCombo->setCurrentItem(aScalarMode);
301 orient = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", orient);
310 QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
312 sbX1 = aResourceMgr->doubleValue("VISU", propertyName + "x", sbX1);
313 sbY1 = aResourceMgr->doubleValue("VISU", propertyName + "y", sbY1);
315 sbW = aResourceMgr->doubleValue("VISU", propertyName + "width", sbW);
316 sbH = aResourceMgr->doubleValue("VISU", propertyName + "height",sbH);
319 sbY1 += sbH*(aPlace-1);
321 sbX1 += sbW*(aPlace-1);
323 sbCol = aResourceMgr->integerValue("VISU" ,"scalar_bar_num_colors", sbCol);
324 sbLab = aResourceMgr->integerValue("VISU", "scalar_bar_num_labels", sbLab);
326 int rangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0);
327 if (rangeType == 1) sbRange = true;
328 sbVmin = aResourceMgr->doubleValue("VISU", "scalar_range_min", sbVmin);
329 sbVmax = aResourceMgr->doubleValue("VISU", "scalar_range_max", sbVmax);
331 bool isLog = aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false);
332 setLogarithmic(isLog);
334 if((sbX1 < 0.) || (sbY1 < 0.) ||
335 ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
348 if(sbCol < 2) sbCol=2;
349 if(sbCol > 64) sbCol=64;
350 if(sbLab < 2) sbLab=2;
351 if(sbLab > 65) sbLab=65;
353 if(sbVmin > sbVmax) {
358 setRange( sbVmin, sbVmax, /*0.0, 0.0,*/ sbRange );
359 setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 0);
360 setScalarBarData( sbCol, sbLab );
363 bool isBold = false, isItalic = false, isShadow = false;
364 int aFontFamily = VTK_ARIAL;
366 if ( aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" ) )
368 QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" );
370 if ( f.family() == "Arial" )
371 aFontFamily = VTK_ARIAL;
372 else if ( f.family() == "Courier" )
373 aFontFamily = VTK_COURIER;
374 else if ( f.family() == "Times" )
375 aFontFamily = VTK_TIMES;
378 isItalic = f.italic();
379 isShadow = f.underline();
382 QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
384 myTextDlg->myTitleFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
387 isBold = isItalic = isShadow = false;
388 aFontFamily = VTK_ARIAL;
390 if ( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" ) )
392 QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" );
394 if ( f.family() == "Arial" )
395 aFontFamily = VTK_ARIAL;
396 else if ( f.family() == "Courier" )
397 aFontFamily = VTK_COURIER;
398 else if ( f.family() == "Times" )
399 aFontFamily = VTK_TIMES;
402 isItalic = f.italic();
403 isShadow = f.underline();
406 aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
408 myTextDlg->myLabelFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
412 * Stores dialog values to resources
414 void VisuGUI_ScalarBarPane::storeToResources() {
415 int orient = (RBvert->isChecked())? 0 : 1;
416 float sbX1 = XSpin->value();
417 float sbY1 = YSpin->value();
418 float sbW = WidthSpin->value();
419 float sbH = HeightSpin->value();
420 int sbCol = ColorSpin->value();
421 int sbLab = LabelSpin->value();
423 if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
437 bool sbRange = RBIrange->isChecked();
438 float sbVmin = (float)(MinEdit->text().toDouble());
439 float sbVmax = (float)(MaxEdit->text().toDouble());
441 if(sbVmin > sbVmax) {
446 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
448 aResourceMgr->setValue("VISU", "scalar_bar_orientation", orient);
450 QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
452 aResourceMgr->setValue("VISU", propertyName + "x", sbX1);
453 aResourceMgr->setValue("VISU", propertyName + "y", sbY1);
454 aResourceMgr->setValue("VISU", propertyName + "width", sbW);
455 aResourceMgr->setValue("VISU", propertyName + "height", sbH);
457 aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol);
458 aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab);
462 aResourceMgr->setValue("VISU", "scalar_range_type", 1);
463 aResourceMgr->setValue("VISU", "scalar_range_min" ,sbVmin);
464 aResourceMgr->setValue("VISU", "scalar_range_max" ,sbVmax);
467 aResourceMgr->setValue("VISU", "scalar_range_type", 0);
469 aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic());
473 if (myIsStoreTextProp) {
475 QColor aTitleColor (255, 255, 255);
476 int aTitleFontFamily = VTK_ARIAL;
477 bool isTitleBold = false;
478 bool isTitleItalic = false;
479 bool isTitleShadow = false;
481 myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily,
482 isTitleBold, isTitleItalic, isTitleShadow);
486 aTitleFont.setBold(isTitleBold);
487 aTitleFont.setItalic(isTitleItalic);
488 aTitleFont.setUnderline(isTitleShadow);
490 QString titleFontFamily;
491 switch (aTitleFontFamily) {
493 titleFontFamily = "Arial";
496 titleFontFamily = "Courier";
499 titleFontFamily = "Times";
502 aTitleFont.setFamily(titleFontFamily);
504 aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont);
506 aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor);
509 QColor aLabelColor (255, 255, 255);
510 int aLabelFontFamily = VTK_ARIAL;
511 bool isLabelBold = false;
512 bool isLabelItalic = false;
513 bool isLabelShadow = false;
515 myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
516 isLabelBold, isLabelItalic, isLabelShadow);
521 aLabelFont.setBold(isLabelBold);
522 aLabelFont.setItalic(isLabelItalic);
523 aLabelFont.setUnderline(isLabelShadow);
525 QString labelFontFamily;
526 switch (aLabelFontFamily) {
528 labelFontFamily = "Arial";
531 labelFontFamily = "Courier";
534 labelFontFamily = "Times";
538 aLabelFont.setFamily(labelFontFamily);
540 aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont);
542 aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor);
547 * Initialise dialog box from presentation object
549 void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
551 myScalarMap = thePrs;
552 myTitle = thePrs->GetTitle();
553 setPosAndSize( thePrs->GetPosX(),
557 thePrs->GetBarOrientation());
558 switch(thePrs->GetScaling()){
559 case VISU::LOGARITHMIC :
560 setLogarithmic(true);
563 setLogarithmic(false);
565 vtkFloatingPointType aRange[2];
566 thePrs->GetScalarMapPL()->GetSourceRange(aRange);
567 Rmin = aRange[0]; Rmax = aRange[1];
568 setRange( thePrs->GetMin(), thePrs->GetMax(),
569 /*0.0, 0.0,*/ thePrs->IsRangeFixed() );
570 setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
572 // Update myModeCombo
573 int aNbComp = thePrs->GetField()->myNbComp;
574 bool isScalarMode = (aNbComp > 1);
575 myModeCombo->clear();
576 myModeCombo->insertItem("<Modulus>");
577 const VISU::PField& aField = thePrs->GetField();
578 const VISU::TNames& aCompNames = aField->myCompNames;
579 const VISU::TNames& aUnitNames = aField->myUnitNames;
580 for(int i = 0; i < aNbComp; i++){
581 QString aComponent = QString(aCompNames[i].c_str()).simplifyWhiteSpace();
582 if(aComponent.isNull() || aComponent == "")
583 aComponent = "Component " + QString::number(i+1);
585 aComponent = "[" + QString::number(i+1) + "] " + aComponent;
587 QString anUnit = QString(aUnitNames[i].c_str()).simplifyWhiteSpace();
588 if(anUnit.isNull() || anUnit == "")
591 aComponent = aComponent + ", " + anUnit;
593 myModeCombo->insertItem(aComponent);
596 myModeCombo->setCurrentItem(thePrs->GetScalarMode());
598 myModeCombo->setCurrentItem(1);
601 myModeLbl->setEnabled(isScalarMode);
602 myModeCombo->setEnabled(isScalarMode);
605 myTextDlg->setTitleText(QString(thePrs->GetTitle()));
607 vtkFloatingPointType R, G, B;
608 thePrs->GetTitleColor(&R, &G, &B);
610 myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
611 thePrs->GetTitFontType(),
612 thePrs->IsBoldTitle(),
613 thePrs->IsItalicTitle(),
614 thePrs->IsShadowTitle());
617 thePrs->GetLabelColor(&R, &G, &B);
619 myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
620 thePrs->GetLblFontType(),
621 thePrs->IsBoldLabel(),
622 thePrs->IsItalicLabel(),
623 thePrs->IsShadowLabel());
626 if (myPreviewCheck->isChecked()) {
632 /*! Slot update preview of scalar bar, if preview is checked
634 void VisuGUI_ScalarBarPane::updatePreview()
636 if (myPreviewCheck->isChecked()) {
637 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
645 /*! Creating preview scalar bar
647 void VisuGUI_ScalarBarPane::createScalarBar()
649 if (VISU::GetActiveViewWindow<SVTK_ViewWindow>() == NULL) return;
650 if (myPreviewActor != 0) return;
651 if (myScalarMap == NULL) return;
653 if (!check()) return;
654 myScalarMapPL = VISU_ScalarMapPL::New();
655 if(myScalarMap->GetScalarMapPL())
656 myScalarMapPL->ShallowCopy(myScalarMap->GetScalarMapPL());
658 if ( myBusy ) return;
663 sbCol = getNbColors();
664 sbLab = getNbLabels();
665 if(sbCol < 2) sbCol=2;
666 if(sbCol > 64) sbCol=64;
667 if(sbLab < 2) sbLab=2;
668 if(sbLab > 65) sbLab=65;
669 myPreviewActor = VISU_ScalarMapAct::New();
670 VISU_ScalarBarActor* aScalarBarActor = myPreviewActor->GetScalarBar();
671 myPreviewActor->GetScalarBar()->VisibilityOn();
672 myPreviewActor->PickableOff();
674 myScalarMapPL->SetScalarMode(myModeCombo->currentItem());
676 myScalarMapPL->SetScaling(VISU::LOGARITHMIC);
678 myScalarMapPL->SetScaling(VISU::LINEAR);
679 vtkFloatingPointType theRange[2];
680 theRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble();
681 theRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble();
682 myScalarMapPL->SetScalarRange(theRange);
683 myScalarMapPL->SetNbColors(sbCol);
685 myScalarMapPL->Update();
687 aScalarBarActor->SetLookupTable(myScalarMapPL->GetBarTable());
689 if (myTextDlg->getTitleText().latin1() != "")
690 aScalarBarActor->SetTitle(myTextDlg->getTitleText().latin1());
692 aScalarBarActor->SetTitle(myTitle.c_str());
693 aScalarBarActor->SetOrientation(getOrientation());
694 aScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
695 aScalarBarActor->GetPositionCoordinate()->SetValue(getX(),getY());
696 aScalarBarActor->SetWidth(getWidth());
697 aScalarBarActor->SetHeight(getHeight());
698 aScalarBarActor->SetNumberOfLabels(sbLab);
699 aScalarBarActor->SetMaximumNumberOfColors(sbCol);
701 // title text property
703 int aTitleFontFamily;
707 myTextDlg->myTitleFont->GetData(aTitleColor,aTitleFontFamily,
708 isTitleBold,isTitleItalic,isTitleShadow);
709 vtkTextProperty* aTitleProp = aScalarBarActor->GetTitleTextProperty();
710 aTitleProp->SetFontFamily(aTitleFontFamily);
711 aTitleProp->SetColor(vtkFloatingPointType(aTitleColor.red())/255.,
712 vtkFloatingPointType(aTitleColor.green())/255.,
713 vtkFloatingPointType(aTitleColor.blue())/255.);
714 (isTitleBold)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
715 (isTitleItalic)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
716 (isTitleShadow)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
718 // label text property
720 int aLabelFontFamily;
724 myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
725 isLabelBold, isLabelItalic, isLabelShadow);
726 vtkTextProperty* aLabelProp = aScalarBarActor->GetLabelTextProperty();
727 aLabelProp->SetFontFamily(aLabelFontFamily);
728 aLabelProp->SetColor(vtkFloatingPointType(aLabelColor.red())/255.,
729 vtkFloatingPointType(aLabelColor.green())/255.,
730 vtkFloatingPointType(aLabelColor.blue())/255.);
731 (isLabelBold)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
732 (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
733 (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
735 aScalarBarActor->Modified();
737 VISU::GetActiveViewWindow<SVTK_ViewWindow>()->AddActor(myPreviewActor);
741 /*! Deleting preview scalar bar
743 void VisuGUI_ScalarBarPane::deleteScalarBar()
745 if ( myBusy ) return;
747 if (myPreviewActor == 0) return;
748 vtkRenderer* aRend = myPreviewActor->GetRenderer();
750 myPreviewActor->RemoveFromRender(aRend);
751 myPreviewActor->GetScalarBar()->VisibilityOff();
752 myPreviewActor->Delete();
756 myScalarMapPL->Delete();
760 /*! public: Deleting preview scalar bar
762 void VisuGUI_ScalarBarPane::deletePreview()
765 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
769 * Store values to presentation object
771 int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ScalarMap_i* thePrs) {
772 thePrs->SetScalarMode(myModeCombo->currentItem());
773 thePrs->SetPosition(XSpin->value(), YSpin->value());
774 thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
775 thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
777 thePrs->SetScaling(VISU::LOGARITHMIC);
779 thePrs->SetScaling(VISU::LINEAR);
781 if (RBFrange->isChecked()) {
782 thePrs->SetSourceRange();
784 thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
786 thePrs->SetNbColors(ColorSpin->value());
787 thePrs->SetLabels(LabelSpin->value());
789 if (isToSave()) storeToResources();
791 if (myIsStoreTextProp) {
793 thePrs->SetTitle(myTextDlg->getTitleText().latin1());
795 QColor aTitColor (255, 255, 255);
796 int aTitleFontFamily = VTK_ARIAL;
797 bool isTitleBold = false;
798 bool isTitleItalic = false;
799 bool isTitleShadow = false;
801 myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
802 isTitleBold, isTitleItalic, isTitleShadow);
804 thePrs->SetBoldTitle(isTitleBold);
805 thePrs->SetItalicTitle(isTitleItalic);
806 thePrs->SetShadowTitle(isTitleShadow);
807 thePrs->SetTitFontType(aTitleFontFamily);
808 thePrs->SetTitleColor(aTitColor.red()/255.,
809 aTitColor.green()/255.,
810 aTitColor.blue()/255.);
813 QColor aLblColor (255, 255, 255);
814 int aLabelFontFamily = VTK_ARIAL;
815 bool isLabelBold = false;
816 bool isLabelItalic = false;
817 bool isLabelShadow = false;
819 myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
820 isLabelBold, isLabelItalic, isLabelShadow);
822 thePrs->SetBoldLabel(isLabelBold);
823 thePrs->SetItalicLabel(isLabelItalic);
824 thePrs->SetShadowLabel(isLabelShadow);
825 thePrs->SetLblFontType(aLabelFontFamily);
826 thePrs->SetLabelColor(aLblColor.red()/255.,
827 aLblColor.green()/255.,
828 aLblColor.blue()/255.);
829 myIsStoreTextProp = false;
836 Called when orientation is changed
838 void VisuGUI_ScalarBarPane::changeDefaults( int )
840 if ( RBvert->isChecked() ) {
841 XSpin->setValue( myVerX );
842 YSpin->setValue( myVerY );
843 WidthSpin->setValue( myVerW );
844 HeightSpin->setValue( myVerH );
847 XSpin->setValue( myHorX );
848 YSpin->setValue( myHorY );
849 WidthSpin->setValue( myHorW );
850 HeightSpin->setValue( myHorH );
856 Called when Range mode is changed
858 void VisuGUI_ScalarBarPane::changeRange( int )
861 if ( RBFrange->isChecked() )
863 if ( RBIrange->isChecked() )
865 if ( myRangeMode == mode )
867 //MinSpin->setMaxValue( Fmin );
868 //MaxSpin->setMinValue( Fmax );
869 if ( RBFrange->isChecked() ) {
870 //MinLabel->setEnabled( false );
871 MinEdit->setEnabled( false );
872 //MaxLabel->setEnabled( false );
873 MaxEdit->setEnabled( false );
875 Imin = MinEdit->text().toDouble();
876 Imax = MaxEdit->text().toDouble();
878 MinEdit->setText( QString::number( Rmin ) );
879 MaxEdit->setText( QString::number( Rmax ) );
882 //MinLabel->setEnabled( true );
883 MinEdit->setEnabled( true );
884 //MaxLabel->setEnabled( true );
885 MaxEdit->setEnabled( true );
886 MinEdit->setText( QString::number( Imin ) );
887 MaxEdit->setText( QString::number( Imax ) );
894 Called when X,Y position is changed
896 void VisuGUI_ScalarBarPane::XYChanged( double )
898 QtxDblSpinBox* snd = (QtxDblSpinBox*)sender();
899 if ( snd == XSpin ) {
900 WidthSpin->setMaxValue( 1.0 - XSpin->value() );
902 if ( snd == YSpin ) {
903 HeightSpin->setMaxValue( 1.0 - YSpin->value() );
909 Called when scalar mode is changed
911 void VisuGUI_ScalarBarPane::changeScalarMode( int theMode )
914 if ( RBFrange->isChecked() ) {
915 vtkFloatingPointType aRange[2];
916 int aMode = myScalarMap->GetScalarMode();
917 myScalarMap->SetScalarMode(theMode);
918 myScalarMap->GetScalarMapPL()->GetSourceRange(aRange);
919 MinEdit->setText( QString::number( aRange[0] ) );
920 MaxEdit->setText( QString::number( aRange[1] ) );
921 myScalarMap->SetScalarMode(aMode);
928 Sets default values and range mode
930 void VisuGUI_ScalarBarPane::setRange( double imin, double imax/*, double fmin, double fmax*/, bool sbRange )
932 Imin = imin; Imax = imax;// Fmin = fmin; Fmax = fmax;
933 if ( RBIrange->isChecked() ) {
934 MinEdit->setText( QString::number( Imin ) );
935 MaxEdit->setText( QString::number( Imax ) );
938 MinEdit->setText( QString::number( Rmin ) );
939 MaxEdit->setText( QString::number( Rmax ) );
943 RBIrange->setChecked( true );
945 RBFrange->setChecked( true );
950 Sets default values and range mode
952 void VisuGUI_ScalarBarPane::setDefaultRange(double imin, double imax){
958 Sets size and position
960 void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
967 RBvert->setChecked( true );
974 RBhori->setChecked( true );
980 Sets colors and labels number
982 void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
984 ColorSpin->setValue( colors );
985 LabelSpin->setValue( labels );
991 int VisuGUI_ScalarBarPane::getOrientation()
993 if (RBvert->isChecked() )
1000 Called when <OK> button is clicked, validates data and closes dialog
1002 bool VisuGUI_ScalarBarPane::check()
1004 double minVal = MinEdit->text().toDouble();
1005 double maxVal = MaxEdit->text().toDouble();
1006 if ( RBIrange->isChecked() ) {
1007 if (minVal >= maxVal) {
1008 SUIT_MessageBox::warn1( this,tr("WRN_VISU"),
1009 tr("MSG_MINMAX_VALUES"),
1014 // check if logarithmic mode is on and check imposed range to not contain negative values
1015 if ( CBLog->isChecked() ) {
1016 if ( RBIrange->isChecked() ) {
1017 if ( (minVal > 0) && (maxVal > 0) ) {
1021 SUIT_MessageBox::warn1( this,
1023 tr("WRN_LOGARITHMIC_RANGE"),
1029 if ( Rmin > 0 && Rmax > 0 ) {
1033 SUIT_MessageBox::warn1( this,
1035 tr("WRN_LOGARITHMIC_FIELD_RANGE"),
1037 RBIrange->setChecked(1);
1039 //MinEdit->setText( QString::number( Rmin ) );
1040 //MaxEdit->setText( QString::number( Rmax ) );
1048 void VisuGUI_ScalarBarPane::onTextPref()
1050 myTextDlg->storeBeginValues();
1051 myIsStoreTextProp = myTextDlg->exec() || myIsStoreTextProp;
1055 void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview)
1057 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
1067 //#######################################################################################
1072 VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool SetPref)
1073 : QDialog(VISU::GetDesktop(theModule), 0, true,
1074 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
1076 setName("VisuGUI_ScalarBarDlg");
1077 setCaption(SetPref ? tr("DLG_PREF_TITLE") : tr("DLG_PROP_TITLE"));
1078 setSizeGripEnabled(TRUE);
1080 QVBoxLayout* TopLayout = new QVBoxLayout(this);
1081 TopLayout->setSpacing(6);
1082 TopLayout->setMargin(11);
1084 myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref);
1085 TopLayout->addWidget(myScalarPane);
1087 // Common buttons ===========================================================
1088 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1089 GroupButtons->setColumnLayout(0, Qt::Vertical );
1090 GroupButtons->layout()->setSpacing( 0 );
1091 GroupButtons->layout()->setMargin( 0 );
1092 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1093 GroupButtonsLayout->setAlignment( Qt::AlignTop );
1094 GroupButtonsLayout->setSpacing( 6 );
1095 GroupButtonsLayout->setMargin( 11 );
1097 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
1098 buttonOk->setAutoDefault( TRUE );
1099 buttonOk->setDefault( TRUE );
1100 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
1101 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1103 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
1104 buttonCancel->setAutoDefault( TRUE );
1105 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
1107 QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" );
1108 buttonHelp->setAutoDefault( TRUE );
1109 GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
1111 TopLayout->addWidget( GroupButtons );
1113 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
1114 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
1115 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
1119 Called when <OK> button is clicked, validates data and closes dialog
1121 void VisuGUI_ScalarBarDlg::accept()
1123 if (myScalarPane->check())
1125 myScalarPane->deletePreview();
1131 Called when <Cancel> button is clicked, remove preview and closes dialog
1133 void VisuGUI_ScalarBarDlg::reject()
1135 myScalarPane->deletePreview();
1140 Called when <Help> button is clicked, shows the corresponding help page in defined browser
1142 void VisuGUI_ScalarBarDlg::onHelp()
1144 QString aHelpFileName = "/files/scalar_map_presentation.htm";
1145 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1147 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
1148 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
1151 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
1152 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
1153 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
1154 QObject::tr("BUT_OK"));
1159 //#######################################################################################
1160 VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent)
1161 : QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
1163 setName("VisuGUI_TextPrefDlg");
1164 setCaption(tr("TIT_TEXT_PREF"));
1165 setSizeGripEnabled(TRUE);
1167 QVBoxLayout* TopLayout = new QVBoxLayout(this);
1168 TopLayout->setSpacing(6);
1169 TopLayout->setMargin(11);
1172 QGroupBox* aTitleGrp = new QGroupBox (2, Qt::Vertical, tr("LBL_TITLE"), this);
1175 myTitleEdt = new QLineEdit (aTitleGrp);
1178 QHBox* aHBox = new QHBox (aTitleGrp);
1179 aHBox->setSpacing(5);
1180 myTitleFont = new SVTK_FontWidget (aHBox);
1182 TopLayout->addWidget(aTitleGrp);
1185 QGroupBox* aLabelsGrp = new QGroupBox (1, Qt::Vertical, tr("LBL_LABELS"), this);
1188 aHBox = new QHBox (aLabelsGrp);
1189 aHBox->setSpacing(5);
1190 myLabelFont = new SVTK_FontWidget (aHBox);
1192 TopLayout->addWidget(aLabelsGrp);
1194 // Common buttons ===========================================================
1195 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1196 GroupButtons->setColumnLayout(0, Qt::Vertical );
1197 GroupButtons->layout()->setSpacing( 0 );
1198 GroupButtons->layout()->setMargin( 0 );
1199 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1200 GroupButtonsLayout->setAlignment( Qt::AlignTop );
1201 GroupButtonsLayout->setSpacing( 6 );
1202 GroupButtonsLayout->setMargin( 11 );
1204 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
1205 buttonOk->setAutoDefault( TRUE );
1206 buttonOk->setDefault( TRUE );
1207 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
1208 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1210 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
1211 buttonCancel->setAutoDefault( TRUE );
1212 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
1214 QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" );
1215 buttonHelp->setAutoDefault( TRUE );
1216 GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
1218 TopLayout->addWidget( GroupButtons );
1220 connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
1221 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
1222 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp()));
1225 void VisuGUI_TextPrefDlg::onHelp()
1227 QString aHelpFileName = "/files/scalar_map_presentation.htm";
1228 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1230 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
1231 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
1234 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
1235 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
1236 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
1237 QObject::tr("BUT_OK"));
1241 void VisuGUI_TextPrefDlg::storeBeginValues()
1243 myTitle = myTitleEdt->text();
1244 myTitleFont->GetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
1245 myLabelFont->GetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
1249 Called when <Cancel> button is clicked, restore begin values
1251 void VisuGUI_TextPrefDlg::reject()
1253 myTitleEdt->setText(myTitle);
1254 myTitleFont->SetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
1255 myLabelFont->SetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
1260 Called when <Ok> button is clicked, store begin values
1262 void VisuGUI_TextPrefDlg::accept()