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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : VisuGUI_ScalarBarDlg.cxx
25 // Author : Laurent CORNABE & Hubert ROLLAND
29 #include "VisuGUI_ScalarBarDlg.h"
32 #include "VisuGUI_Tools.h"
33 #include "VisuGUI_FontWg.h"
35 #include "VISUConfig.hh"
36 #include "VISU_Convertor.hxx"
38 #include "VISU_ScalarMapPL.hxx"
39 #include "VISU_ScalarMap_i.hh"
41 #include "SalomeApp_Application.h"
43 #include "SUIT_MessageBox.h"
44 #include "SUIT_ResourceMgr.h"
48 #include <qvalidator.h>
49 #include <qcolordialog.h>
54 VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
57 myVerX = 0.01; myVerY = 0.10; myVerW = 0.10; myVerH = 0.80;
58 myHorX = 0.20; myHorY = 0.01; myHorW = 0.60; myHorH = 0.12;
59 Imin = 0.0; Imax = 0.0; /*Fmin = 0.0; Fmax = 0.0;*/ Rmin = 0.0; Rmax = 0.0;
65 // Range ============================================================
66 RangeGroup = new QButtonGroup (tr("SCALAR_RANGE_GRP"), this, "RangeGroup");
67 RangeGroup->setColumnLayout(0, Qt::Vertical );
68 RangeGroup->layout()->setSpacing( 0 );
69 RangeGroup->layout()->setMargin( 0 );
70 QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() );
71 RangeGroupLayout->setAlignment( Qt::AlignTop );
72 RangeGroupLayout->setSpacing( 6 );
73 RangeGroupLayout->setMargin( 11 );
75 myModeLbl = new QLabel("Scalar Mode", RangeGroup);
77 myModeCombo = new QComboBox(RangeGroup);
78 myModeCombo->insertItem("Modulus");
79 myModeCombo->insertItem("Component 1");
80 myModeCombo->insertItem("Component 2");
81 myModeCombo->insertItem("Component 3");
83 CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), RangeGroup);
84 CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
86 RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), RangeGroup, "RBFrange");
87 RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), RangeGroup, "RBIrange");
88 RBFrange->setChecked( true );
90 MinEdit = new QLineEdit( RangeGroup, "MinEdit" );
91 MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
92 MinEdit->setMinimumWidth( 70 );
93 MinEdit->setValidator( new QDoubleValidator(this) );
94 MinEdit->setText( "0.0" );
95 QLabel* MinLabel = new QLabel (tr("LBL_MIN"), RangeGroup, "MinLabel");
96 MinLabel->setBuddy(MinEdit);
98 MaxEdit = new QLineEdit( RangeGroup, "MaxEdit" );
99 MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
100 MaxEdit->setMinimumWidth( 70 );
101 MaxEdit->setValidator( new QDoubleValidator(this) );
102 MaxEdit->setText( "0.0" );
103 QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), RangeGroup, "MaxLabel");
104 MaxLabel->setBuddy(MaxEdit);
106 RangeGroupLayout->addWidget( myModeLbl, 0, 0 );
107 RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3);
108 RangeGroupLayout->addMultiCellWidget( CBLog, 1, 1, 0, 3);
109 RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1);
110 RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3);
111 RangeGroupLayout->addWidget( MinLabel, 3, 0 );
112 RangeGroupLayout->addWidget( MinEdit, 3, 1 );
113 RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
114 RangeGroupLayout->addWidget( MaxEdit, 3, 3 );
116 //TopLayout->addWidget( RangeGroup );
118 // Colors and Labels ========================================================
119 QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this, "ColLabGroup");
120 ColLabGroup->setColumnLayout(0, Qt::Vertical );
121 ColLabGroup->layout()->setSpacing( 0 );
122 ColLabGroup->layout()->setMargin( 0 );
123 QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() );
124 ColLabGroupLayout->setAlignment( Qt::AlignTop );
125 ColLabGroupLayout->setSpacing( 6 );
126 ColLabGroupLayout->setMargin( 11 );
128 QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup, "ColorLabel");
129 ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup );
130 ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
131 ColorSpin->setMinimumWidth( 70 );
132 ColorSpin->setValue( 64 );
134 QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup, "LabelLabel");
135 LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup );
136 LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
137 LabelSpin->setMinimumWidth( 70 );
138 LabelSpin->setValue( 5 );
140 ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
141 ColLabGroupLayout->addWidget( ColorSpin, 0, 1);
142 ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
143 ColLabGroupLayout->addWidget( LabelSpin, 0, 3);
145 //TopLayout->addWidget( ColLabGroup );
147 // Orientation ==========================================================
148 QButtonGroup* OrientGroup = new QButtonGroup (tr("ORIENTATION_GRP"), this, "OrientGroup");
149 OrientGroup->setColumnLayout(0, Qt::Vertical );
150 OrientGroup->layout()->setSpacing( 0 );
151 OrientGroup->layout()->setMargin( 0 );
152 QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() );
153 OrientGroupLayout->setAlignment( Qt::AlignTop );
154 OrientGroupLayout->setSpacing( 6 );
155 OrientGroupLayout->setMargin( 11 );
157 RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGroup, "RBvert");
158 RBvert->setChecked( true );
159 RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGroup, "RBhori");
160 OrientGroupLayout->addWidget( RBvert, 0, 0 );
161 OrientGroupLayout->addWidget( RBhori, 0, 1 );
163 // TopLayout->addWidget( OrientGroup );
165 // Origin ===============================================================
166 QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this, "OriginGroup");
167 OriginGroup->setColumnLayout(0, Qt::Vertical );
168 OriginGroup->layout()->setSpacing( 0 );
169 OriginGroup->layout()->setMargin( 0 );
170 QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() );
171 OriginGroupLayout->setAlignment( Qt::AlignTop );
172 OriginGroupLayout->setSpacing( 6 );
173 OriginGroupLayout->setMargin( 11 );
175 QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup, "XLabel");
176 XSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
177 XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
178 XSpin->setMinimumWidth( 70 );
179 XSpin->setValue( 0.01 );
181 QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup, "YLabel");
182 YSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
183 YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
184 YSpin->setMinimumWidth( 70 );
185 YSpin->setValue( 0.01 );
187 OriginGroupLayout->addWidget( XLabel, 0, 0);
188 OriginGroupLayout->addWidget( XSpin, 0, 1);
189 OriginGroupLayout->addWidget( YLabel, 0, 2);
190 OriginGroupLayout->addWidget( YSpin, 0, 3);
192 //TopLayout->addWidget( OriginGroup );
194 // Dimensions =========================================================
195 QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this, "DimGroup");
196 DimGroup->setColumnLayout(0, Qt::Vertical );
197 DimGroup->layout()->setSpacing( 0 );
198 DimGroup->layout()->setMargin( 0 );
199 QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() );
200 DimGroupLayout->setAlignment( Qt::AlignTop );
201 DimGroupLayout->setSpacing( 6 );
202 DimGroupLayout->setMargin( 11 );
204 QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup, "WidthLabel");
205 WidthSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
206 WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
207 WidthSpin->setMinimumWidth( 70 );
208 WidthSpin->setValue( 0.1 );
210 QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup, "HeightLabel");
211 HeightSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
212 HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
213 HeightSpin->setMinimumWidth( 70 );
214 HeightSpin->setValue( 0.8 );
216 DimGroupLayout->addWidget( WidthLabel, 0, 0);
217 DimGroupLayout->addWidget( WidthSpin, 0, 1);
218 DimGroupLayout->addWidget( HeightLabel, 0, 2);
219 DimGroupLayout->addWidget( HeightSpin, 0, 3);
221 //TopLayout->addWidget( DimGroup );
223 // Save check box ===========================================================
224 QHBox* aSaveBox = new QHBox(this);
226 CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), aSaveBox, "CBSave");
227 //TopLayout->addWidget(CBSave);
232 myTextBtn = new QPushButton("Text properties...", aSaveBox);
233 myTextDlg = new VisuGUI_TextPrefDlg(this);
234 myTextDlg->setTitleVisible(!SetPref);
236 // signals and slots connections ===========================================
237 connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) );
238 connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) );
239 connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
240 connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
241 connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
245 myIsStoreTextProp = false;
250 * Initializes dialog box values from resources
252 void VisuGUI_ScalarBarPane::initFromResources() {
253 int sbCol=64,sbLab=5,orient=0;
254 float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8;
255 float sbVmin=0., sbVmax=0.;
259 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
261 int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0);
262 myModeCombo->setCurrentItem(aScalarMode);
264 orient = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", orient);
273 QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
275 sbX1 = aResourceMgr->doubleValue("VISU", propertyName + "x", sbX1);
276 sbY1 = aResourceMgr->doubleValue("VISU", propertyName + "y", sbY1);
278 sbW = aResourceMgr->doubleValue("VISU", propertyName + "width", sbW);
279 sbH = aResourceMgr->doubleValue("VISU", propertyName + "height",sbH);
281 sbCol = aResourceMgr->integerValue("VISU" ,"scalar_bar_num_colors", sbCol);
282 sbLab = aResourceMgr->integerValue("VISU", "scalar_bar_num_labels", sbLab);
284 int rangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0);
285 if (rangeType == 1) sbRange = true;
286 sbVmin = aResourceMgr->doubleValue("VISU", "scalar_range_min", sbVmin);
287 sbVmax = aResourceMgr->doubleValue("VISU", "scalar_range_max", sbVmax);
289 bool isLog = aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false);
290 setLogarithmic(isLog);
292 if((sbX1 < 0.) || (sbY1 < 0.) ||
293 ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
306 if(sbCol < 2) sbCol=2;
307 if(sbCol > 64) sbCol=64;
308 if(sbLab < 2) sbLab=2;
309 if(sbLab > 65) sbLab=65;
311 if(sbVmin > sbVmax) {
316 setRange( sbVmin, sbVmax, /*0.0, 0.0,*/ sbRange );
317 setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 0);
318 setScalarBarData( sbCol, sbLab );
321 bool isBold = false, isItalic = false, isShadow = false;
322 int aFontFamily = VTK_ARIAL;
324 if ( aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" ) )
326 QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" );
328 if ( f.family() == "Arial" )
329 aFontFamily = VTK_ARIAL;
330 else if ( f.family() == "Courier" )
331 aFontFamily = VTK_COURIER;
332 else if ( f.family() == "Times" )
333 aFontFamily = VTK_TIMES;
336 isItalic = f.italic();
337 isShadow = f.underline();
340 QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
342 myTextDlg->myTitleFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
345 isBold = isItalic = isShadow = false;
346 aFontFamily = VTK_ARIAL;
348 if ( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" ) )
350 QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" );
352 if ( f.family() == "Arial" )
353 aFontFamily = VTK_ARIAL;
354 else if ( f.family() == "Courier" )
355 aFontFamily = VTK_COURIER;
356 else if ( f.family() == "Times" )
357 aFontFamily = VTK_TIMES;
360 isItalic = f.italic();
361 isShadow = f.underline();
364 aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
366 myTextDlg->myLabelFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
370 * Stores dialog values to resources
372 void VisuGUI_ScalarBarPane::storeToResources() {
373 int orient = (RBvert->isChecked())? 0 : 1;
374 float sbX1 = XSpin->value();
375 float sbY1 = YSpin->value();
376 float sbW = WidthSpin->value();
377 float sbH = HeightSpin->value();
378 int sbCol = ColorSpin->value();
379 int sbLab = LabelSpin->value();
381 if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
395 bool sbRange = RBIrange->isChecked();
396 float sbVmin = (float)(MinEdit->text().toDouble());
397 float sbVmax = (float)(MaxEdit->text().toDouble());
399 if(sbVmin > sbVmax) {
404 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
406 aResourceMgr->setValue("VISU", "scalar_bar_orientation", orient);
408 QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
410 aResourceMgr->setValue("VISU", propertyName + "x", sbX1);
411 aResourceMgr->setValue("VISU", propertyName + "y", sbY1);
412 aResourceMgr->setValue("VISU", propertyName + "width", sbW);
413 aResourceMgr->setValue("VISU", propertyName + "height", sbH);
415 aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol);
416 aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab);
420 aResourceMgr->setValue("VISU", "scalar_range_type", 1);
421 aResourceMgr->setValue("VISU", "scalar_range_min" ,sbVmin);
422 aResourceMgr->setValue("VISU", "scalar_range_max" ,sbVmax);
425 aResourceMgr->setValue("VISU", "scalar_range_type", 0);
427 aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic());
431 if (myIsStoreTextProp) {
433 QColor aTitleColor (255, 255, 255);
434 int aTitleFontFamily = VTK_ARIAL;
435 bool isTitleBold = false;
436 bool isTitleItalic = false;
437 bool isTitleShadow = false;
439 myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily,
440 isTitleBold, isTitleItalic, isTitleShadow);
444 aTitleFont.setBold(isTitleBold);
445 aTitleFont.setItalic(isTitleItalic);
446 aTitleFont.setUnderline(isTitleShadow);
448 QString titleFontFamily;
449 switch (aTitleFontFamily) {
451 titleFontFamily = "Arial";
454 titleFontFamily = "Courier";
457 titleFontFamily = "Times";
460 aTitleFont.setFamily(titleFontFamily);
462 aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont);
464 aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor);
467 QColor aLabelColor (255, 255, 255);
468 int aLabelFontFamily = VTK_ARIAL;
469 bool isLabelBold = false;
470 bool isLabelItalic = false;
471 bool isLabelShadow = false;
473 myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
474 isLabelBold, isLabelItalic, isLabelShadow);
479 aLabelFont.setBold(isLabelBold);
480 aLabelFont.setItalic(isLabelItalic);
481 aLabelFont.setUnderline(isLabelShadow);
483 QString labelFontFamily;
484 switch (aLabelFontFamily) {
486 labelFontFamily = "Arial";
489 labelFontFamily = "Courier";
492 labelFontFamily = "Times";
496 aLabelFont.setFamily(labelFontFamily);
498 aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont);
500 aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor);
505 * Initialise dialog box from presentation object
507 void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
509 myModeCombo->setCurrentItem(thePrs->GetScalarMode());
510 setPosAndSize( thePrs->GetPosX(),
514 thePrs->GetBarOrientation());
515 switch(thePrs->GetScaling()){
516 case VISU::LOGARITHMIC :
517 setLogarithmic(true);
520 setLogarithmic(false);
523 thePrs->GetScalarMapPL()->GetSourceRange(aRange);
524 Rmin = aRange[0]; Rmax = aRange[1];
525 setRange( thePrs->GetMin(), thePrs->GetMax(),
526 /*0.0, 0.0,*/ thePrs->IsRangeFixed() );
527 setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
528 bool isScalarMode = (thePrs->GetField()->myNbComp > 1);
529 myModeLbl->setEnabled(isScalarMode);
530 myModeCombo->setEnabled(isScalarMode);
533 myTextDlg->setTitleText(QString(thePrs->GetTitle()));
536 thePrs->GetTitleColor(&R, &G, &B);
538 myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
539 thePrs->GetTitFontType(),
540 thePrs->IsBoldTitle(),
541 thePrs->IsItalicTitle(),
542 thePrs->IsShadowTitle());
545 thePrs->GetLabelColor(&R, &G, &B);
547 myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
548 thePrs->GetLblFontType(),
549 thePrs->IsBoldLabel(),
550 thePrs->IsItalicLabel(),
551 thePrs->IsShadowLabel());
555 * Store values to presentation object
557 int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ScalarMap_i* thePrs) {
558 thePrs->SetScalarMode(myModeCombo->currentItem());
559 thePrs->SetPosition(XSpin->value(), YSpin->value());
560 thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
561 thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
563 thePrs->SetScaling(VISU::LOGARITHMIC);
565 thePrs->SetScaling(VISU::LINEAR);
567 if (RBFrange->isChecked()) {
568 thePrs->SetSourceRange();
570 thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
572 thePrs->SetNbColors(ColorSpin->value());
573 thePrs->SetLabels(LabelSpin->value());
575 if (isToSave()) storeToResources();
577 if (myIsStoreTextProp) {
579 thePrs->SetTitle(myTextDlg->getTitleText().latin1());
581 QColor aTitColor (255, 255, 255);
582 int aTitleFontFamily = VTK_ARIAL;
583 bool isTitleBold = false;
584 bool isTitleItalic = false;
585 bool isTitleShadow = false;
587 myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
588 isTitleBold, isTitleItalic, isTitleShadow);
590 thePrs->SetBoldTitle(isTitleBold);
591 thePrs->SetItalicTitle(isTitleItalic);
592 thePrs->SetShadowTitle(isTitleShadow);
593 thePrs->SetTitFontType(aTitleFontFamily);
594 thePrs->SetTitleColor(aTitColor.red()/255.,
595 aTitColor.green()/255.,
596 aTitColor.blue()/255.);
599 QColor aLblColor (255, 255, 255);
600 int aLabelFontFamily = VTK_ARIAL;
601 bool isLabelBold = false;
602 bool isLabelItalic = false;
603 bool isLabelShadow = false;
605 myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
606 isLabelBold, isLabelItalic, isLabelShadow);
608 thePrs->SetBoldLabel(isLabelBold);
609 thePrs->SetItalicLabel(isLabelItalic);
610 thePrs->SetShadowLabel(isLabelShadow);
611 thePrs->SetLblFontType(aLabelFontFamily);
612 thePrs->SetLabelColor(aLblColor.red()/255.,
613 aLblColor.green()/255.,
614 aLblColor.blue()/255.);
621 Called when orientation is changed
623 void VisuGUI_ScalarBarPane::changeDefaults( int )
625 if ( RBvert->isChecked() ) {
626 XSpin->setValue( myVerX );
627 YSpin->setValue( myVerY );
628 WidthSpin->setValue( myVerW );
629 HeightSpin->setValue( myVerH );
632 XSpin->setValue( myHorX );
633 YSpin->setValue( myHorY );
634 WidthSpin->setValue( myHorW );
635 HeightSpin->setValue( myHorH );
640 Called when Range mode is changed
642 void VisuGUI_ScalarBarPane::changeRange( int )
645 if ( RBFrange->isChecked() )
647 if ( RBIrange->isChecked() )
649 if ( myRangeMode == mode )
651 //MinSpin->setMaxValue( Fmin );
652 //MaxSpin->setMinValue( Fmax );
653 if ( RBFrange->isChecked() ) {
654 //MinLabel->setEnabled( false );
655 MinEdit->setEnabled( false );
656 //MaxLabel->setEnabled( false );
657 MaxEdit->setEnabled( false );
659 Imin = MinEdit->text().toDouble();
660 Imax = MaxEdit->text().toDouble();
662 MinEdit->setText( QString::number( Rmin ) );
663 MaxEdit->setText( QString::number( Rmax ) );
666 //MinLabel->setEnabled( true );
667 MinEdit->setEnabled( true );
668 //MaxLabel->setEnabled( true );
669 MaxEdit->setEnabled( true );
670 MinEdit->setText( QString::number( Imin ) );
671 MaxEdit->setText( QString::number( Imax ) );
677 Called when X,Y position is changed
679 void VisuGUI_ScalarBarPane::XYChanged( double )
681 QtxDblSpinBox* snd = (QtxDblSpinBox*)sender();
682 if ( snd == XSpin ) {
683 WidthSpin->setMaxValue( 1.0 - XSpin->value() );
685 if ( snd == YSpin ) {
686 HeightSpin->setMaxValue( 1.0 - YSpin->value() );
691 Sets default values and range mode
693 void VisuGUI_ScalarBarPane::setRange( double imin, double imax/*, double fmin, double fmax*/, bool sbRange )
695 Imin = imin; Imax = imax;// Fmin = fmin; Fmax = fmax;
696 if ( RBIrange->isChecked() ) {
697 MinEdit->setText( QString::number( Imin ) );
698 MaxEdit->setText( QString::number( Imax ) );
701 MinEdit->setText( QString::number( Rmin ) );
702 MaxEdit->setText( QString::number( Rmax ) );
706 RBIrange->setChecked( true );
708 RBFrange->setChecked( true );
713 Sets size and position
715 void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
722 RBvert->setChecked( true );
729 RBhori->setChecked( true );
735 Sets colors and labels number
737 void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
739 ColorSpin->setValue( colors );
740 LabelSpin->setValue( labels );
746 int VisuGUI_ScalarBarPane::getOrientation()
748 if (RBvert->isChecked() )
755 Called when <OK> button is clicked, validates data and closes dialog
757 bool VisuGUI_ScalarBarPane::check()
759 double minVal = MinEdit->text().toDouble();
760 double maxVal = MaxEdit->text().toDouble();
761 if ( RBIrange->isChecked() ) {
762 if (minVal >= maxVal) {
763 SUIT_MessageBox::warn1( this,tr("WRN_VISU"),
764 tr("MSG_MINMAX_VALUES"),
769 // check if logarithmic mode is on and check imposed range to not contain negative values
770 if ( CBLog->isChecked() ) {
771 if ( RBIrange->isChecked() ) {
772 if ( (minVal > 0) && (maxVal > 0) ) {
776 SUIT_MessageBox::warn1( this,
778 tr("WRN_LOGARITHMIC_RANGE"),
784 if ( Rmin > 0 && Rmax > 0 ) {
788 SUIT_MessageBox::warn1( this,
790 tr("WRN_LOGARITHMIC_FIELD_RANGE"),
792 RBIrange->setChecked(1);
794 //MinEdit->setText( QString::number( Rmin ) );
795 //MaxEdit->setText( QString::number( Rmax ) );
803 void VisuGUI_ScalarBarPane::onTextPref()
805 myIsStoreTextProp = myTextDlg->exec();
809 //#######################################################################################
814 VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool SetPref)
815 : QDialog(VISU::GetDesktop(theModule), 0, true,
816 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
818 setName("VisuGUI_ScalarBarDlg");
819 setCaption(SetPref ? tr("DLG_PREF_TITLE") : tr("DLG_PROP_TITLE"));
820 setSizeGripEnabled(TRUE);
822 QVBoxLayout* TopLayout = new QVBoxLayout(this);
823 TopLayout->setSpacing(6);
824 TopLayout->setMargin(11);
826 myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref);
827 TopLayout->addWidget(myScalarPane);
829 // Common buttons ===========================================================
830 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
831 GroupButtons->setColumnLayout(0, Qt::Vertical );
832 GroupButtons->layout()->setSpacing( 0 );
833 GroupButtons->layout()->setMargin( 0 );
834 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
835 GroupButtonsLayout->setAlignment( Qt::AlignTop );
836 GroupButtonsLayout->setSpacing( 6 );
837 GroupButtonsLayout->setMargin( 11 );
839 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
840 buttonOk->setAutoDefault( TRUE );
841 buttonOk->setDefault( TRUE );
842 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
843 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
845 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
846 buttonCancel->setAutoDefault( TRUE );
847 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
849 TopLayout->addWidget( GroupButtons );
851 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
852 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
856 Called when <OK> button is clicked, validates data and closes dialog
858 void VisuGUI_ScalarBarDlg::accept()
860 if (myScalarPane->check()) QDialog::accept();
864 //#######################################################################################
865 VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent)
866 : QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
868 setName("VisuGUI_TextPrefDlg");
869 setCaption(tr("TIT_TEXT_PREF"));
870 setSizeGripEnabled(TRUE);
872 QVBoxLayout* TopLayout = new QVBoxLayout(this);
873 TopLayout->setSpacing(6);
874 TopLayout->setMargin(11);
877 QGroupBox* aTitleGrp = new QGroupBox (2, Qt::Vertical, tr("LBL_TITLE"), this);
880 myTitleEdt = new QLineEdit (aTitleGrp);
883 QHBox* aHBox = new QHBox (aTitleGrp);
884 aHBox->setSpacing(5);
885 myTitleFont = new VisuGUI_FontWg (aHBox);
887 TopLayout->addWidget(aTitleGrp);
890 QGroupBox* aLabelsGrp = new QGroupBox (1, Qt::Vertical, tr("LBL_LABELS"), this);
893 aHBox = new QHBox (aLabelsGrp);
894 aHBox->setSpacing(5);
895 myLabelFont = new VisuGUI_FontWg (aHBox);
897 TopLayout->addWidget(aLabelsGrp);
899 // Common buttons ===========================================================
900 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
901 GroupButtons->setColumnLayout(0, Qt::Vertical );
902 GroupButtons->layout()->setSpacing( 0 );
903 GroupButtons->layout()->setMargin( 0 );
904 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
905 GroupButtonsLayout->setAlignment( Qt::AlignTop );
906 GroupButtonsLayout->setSpacing( 6 );
907 GroupButtonsLayout->setMargin( 11 );
909 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
910 buttonOk->setAutoDefault( TRUE );
911 buttonOk->setDefault( TRUE );
912 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
913 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
915 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
916 buttonCancel->setAutoDefault( TRUE );
917 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
919 TopLayout->addWidget( GroupButtons );
921 connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
922 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));