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=1;
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 orient = aResourceMgr->integerValue("Visu:SBOrientation",orient);
270 sbX1 = aResourceMgr->doubleValue("Visu:SBXorigin",sbX1);
271 sbY1 = aResourceMgr->doubleValue("Visu:SBYorigin",sbY1);
273 sbW = aResourceMgr->doubleValue("Visu:SBWidth",sbW);
274 sbH = aResourceMgr->doubleValue("Visu:SBHeight",sbH);
276 sbCol = aResourceMgr->integerValue("Visu:SBNumberOfColors",sbCol);
277 sbLab = aResourceMgr->integerValue("Visu:SBNumberOfLabels",sbLab);
278 sbRange = aResourceMgr->booleanValue("Visu:SBImposeRange",sbRange);
279 sbVmin = aResourceMgr->doubleValue("Visu:SBMinimumValue",sbVmin);
280 sbVmax = aResourceMgr->doubleValue("Visu:SBMaximumValue",sbVmax);
282 QString aScaling = aResourceMgr->stringValue("Visu:SBMaximumValue","LINEAR");
283 if(aScaling.compare("LOGARITHMIC") == 0)
284 setLogarithmic(true);
286 setLogarithmic(false);
288 if((sbX1 < 0.) || (sbY1 < 0.) ||
289 ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
302 if(sbCol < 2) sbCol=2;
303 if(sbCol > 64) sbCol=64;
304 if(sbLab < 2) sbLab=2;
305 if(sbLab > 65) sbLab=65;
307 if(sbVmin > sbVmax) {
312 setRange( sbVmin, sbVmax, /*0.0, 0.0,*/ sbRange );
313 setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 1);
314 setScalarBarData( sbCol, sbLab );
317 aString = aResourceMgr->stringValue("Visu:IsBoldTitle","true");
318 bool isBold = (aString.compare("true") == 0);
319 aString = aResourceMgr->stringValue("Visu:IsItalicTitle","true");
320 bool isItalic = (aString.compare("true") == 0);
321 aString = aResourceMgr->stringValue("Visu:IsShadowTitle","true");
322 bool isShadow = (aString.compare("true") == 0);
324 int aFontType = aResourceMgr->integerValue("Visu:TitFontType",0);
325 int aFontFamily = VTK_ARIAL;
328 aFontFamily = VTK_ARIAL; break;
330 aFontFamily = VTK_COURIER; break;
332 aFontFamily = VTK_TIMES; break;
335 float R = aResourceMgr->doubleValue("Visu:TitleColorR",1.0);
339 float G = aResourceMgr->doubleValue("Visu:TitleColorG",1.0);
343 float B = aResourceMgr->doubleValue("Visu:TitleColorB",1.0);
347 myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
349 isBold, isItalic, isShadow);
352 aString = aResourceMgr->stringValue("Visu:IsBoldLabel","true");
353 isBold = (aString.compare("true") == 0);
354 aString = aResourceMgr->stringValue("Visu:IsItalicLabel","true");
355 isItalic = (aString.compare("true") == 0);
356 aString = aResourceMgr->stringValue("Visu:IsShadowLabel","true");
357 isShadow = (aString.compare("true") == 0);
359 aFontType = aResourceMgr->integerValue("Visu:LblFontType",0);
360 aFontFamily = VTK_ARIAL;
363 aFontFamily = VTK_ARIAL; break;
365 aFontFamily = VTK_COURIER; break;
367 aFontFamily = VTK_TIMES; break;
370 R = aResourceMgr->doubleValue("Visu:LabelColorR",1.0);
374 G = aResourceMgr->doubleValue("Visu:LabelColorG",1.0);
378 B = aResourceMgr->doubleValue("Visu:LabelColorB",1.0);
382 myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
384 isBold, isItalic, isShadow);
388 * Stores dialog values to resources
390 void VisuGUI_ScalarBarPane::storeToResources() {
391 int orient = (RBvert->isChecked())? 1 : 0;
392 float sbX1 = XSpin->value();
393 float sbY1 = YSpin->value();
394 float sbW = WidthSpin->value();
395 float sbH = HeightSpin->value();
396 int sbCol = ColorSpin->value();
397 int sbLab = LabelSpin->value();
399 if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
413 bool sbRange = RBIrange->isChecked();
414 float sbVmin = (float)(MinEdit->text().toDouble());
415 float sbVmax = (float)(MaxEdit->text().toDouble());
417 if(sbVmin > sbVmax) {
422 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
424 aResourceMgr->setValue("Visu:SBOrientation",orient);
425 aResourceMgr->setValue("Visu:SBXorigin",sbX1);
426 aResourceMgr->setValue("Visu:SBYorigin",sbY1);
427 aResourceMgr->setValue("Visu:SBWidth",sbW);
428 aResourceMgr->setValue("Visu:SBHeight",sbH);
429 aResourceMgr->setValue("Visu:SBNumberOfColors",sbCol);
430 aResourceMgr->setValue("Visu:SBNumberOfLabels",sbLab);
432 aResourceMgr->setValue("Visu:SBImposeRange", "true");
434 aResourceMgr->setValue("Visu:SBImposeRange", "false");
435 aResourceMgr->setValue("Visu:SBMinimumValue",sbVmin);
436 aResourceMgr->setValue("Visu:SBMaximumValue",sbVmax);
438 aResourceMgr->setValue("Visu:SBScaling", "LOGARITHMIC");
440 aResourceMgr->setValue("Visu:SBScaling", "LINEAR");
444 if (myIsStoreTextProp) {
446 QColor aTitleColor (255, 255, 255);
447 int aTitleFontFamily = VTK_ARIAL;
448 bool isTitleBold = false;
449 bool isTitleItalic = false;
450 bool isTitleShadow = false;
452 myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily,
453 isTitleBold, isTitleItalic, isTitleShadow);
456 aResourceMgr->setValue("Visu:IsBoldTitle","true");
458 aResourceMgr->setValue("Visu:IsBoldTitle","false");
461 aResourceMgr->setValue("Visu:IsItalicTitle","true");
463 aResourceMgr->setValue("Visu:IsItalicTitle","false");
466 aResourceMgr->setValue("Visu:IsShadowTitle","true");
468 aResourceMgr->setValue("Visu:IsShadowTitle","false");
470 switch (aTitleFontFamily) {
472 aResourceMgr->setValue("Visu:TitFontType",0);
475 aResourceMgr->setValue("Visu:TitFontType",1);
478 aResourceMgr->setValue("Visu:TitFontType",2);
481 aResourceMgr->setValue("Visu:TitleColorR", aTitleColor.red()/255.);
482 aResourceMgr->setValue("Visu:TitleColorG", aTitleColor.green()/255.);
483 aResourceMgr->setValue("Visu:TitleColorB", aTitleColor.blue()/255.);
486 QColor aLabelColor (255, 255, 255);
487 int aLabelFontFamily = VTK_ARIAL;
488 bool isLabelBold = false;
489 bool isLabelItalic = false;
490 bool isLabelShadow = false;
492 myTextDlg->myTitleFont->GetData(aLabelColor, aLabelFontFamily,
493 isLabelBold, isLabelItalic, isLabelShadow);
496 aResourceMgr->setValue("Visu:IsBoldLabel","true");
498 aResourceMgr->setValue("Visu:IsBoldLabel","false");
501 aResourceMgr->setValue("Visu:IsItalicLabel","true");
503 aResourceMgr->setValue("Visu:IsItalicLabel","false");
506 aResourceMgr->setValue("Visu:IsShadowLabel","true");
508 aResourceMgr->setValue("Visu:IsShadowLabel","false");
510 switch (aLabelFontFamily) {
512 aResourceMgr->setValue("Visu:LblFontType",0);
515 aResourceMgr->setValue("Visu:LblFontType",1);
518 aResourceMgr->setValue("Visu:LblFontType",2);
521 aResourceMgr->setValue("Visu:LabelColorR", aLabelColor.red()/255.);
522 aResourceMgr->setValue("Visu:LabelColorG", aLabelColor.green()/255.);
523 aResourceMgr->setValue("Visu:LabelColorB", aLabelColor.blue()/255.);
528 * Initialise dialog box from presentation object
530 void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
532 myModeCombo->setCurrentItem(thePrs->GetScalarMode());
533 setPosAndSize( thePrs->GetPosX(),
537 thePrs->GetBarOrientation());
538 switch(thePrs->GetScaling()){
539 case VISU::LOGARITHMIC :
540 setLogarithmic(true);
543 setLogarithmic(false);
546 thePrs->GetScalarMapPL()->GetSourceRange(aRange);
547 Rmin = aRange[0]; Rmax = aRange[1];
548 setRange( thePrs->GetMin(), thePrs->GetMax(),
549 /*0.0, 0.0,*/ thePrs->IsRangeFixed() );
550 setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
551 bool isScalarMode = (thePrs->GetField()->myNbComp > 1);
552 myModeLbl->setEnabled(isScalarMode);
553 myModeCombo->setEnabled(isScalarMode);
556 myTextDlg->setTitleText(QString(thePrs->GetTitle()));
559 thePrs->GetTitleColor(&R, &G, &B);
561 myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
562 thePrs->GetTitFontType(),
563 thePrs->IsBoldTitle(),
564 thePrs->IsItalicTitle(),
565 thePrs->IsShadowTitle());
568 thePrs->GetLabelColor(&R, &G, &B);
570 myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
571 thePrs->GetLblFontType(),
572 thePrs->IsBoldLabel(),
573 thePrs->IsItalicLabel(),
574 thePrs->IsShadowLabel());
578 * Store values to presentation object
580 int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ScalarMap_i* thePrs) {
581 thePrs->SetScalarMode(myModeCombo->currentItem());
582 thePrs->SetPosition(XSpin->value(), YSpin->value());
583 thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
584 thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
586 thePrs->SetScaling(VISU::LOGARITHMIC);
588 thePrs->SetScaling(VISU::LINEAR);
590 if (RBFrange->isChecked()) {
591 thePrs->SetSourceRange();
593 thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
595 thePrs->SetNbColors(ColorSpin->value());
596 thePrs->SetLabels(LabelSpin->value());
598 if (isToSave()) storeToResources();
600 if (myIsStoreTextProp) {
602 thePrs->SetTitle(myTextDlg->getTitleText().latin1());
604 QColor aTitColor (255, 255, 255);
605 int aTitleFontFamily = VTK_ARIAL;
606 bool isTitleBold = false;
607 bool isTitleItalic = false;
608 bool isTitleShadow = false;
610 myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
611 isTitleBold, isTitleItalic, isTitleShadow);
613 thePrs->SetBoldTitle(isTitleBold);
614 thePrs->SetItalicTitle(isTitleItalic);
615 thePrs->SetShadowTitle(isTitleShadow);
616 thePrs->SetTitFontType(aTitleFontFamily);
617 thePrs->SetTitleColor(aTitColor.red()/255.,
618 aTitColor.green()/255.,
619 aTitColor.blue()/255.);
622 QColor aLblColor (255, 255, 255);
623 int aLabelFontFamily = VTK_ARIAL;
624 bool isLabelBold = false;
625 bool isLabelItalic = false;
626 bool isLabelShadow = false;
628 myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
629 isLabelBold, isLabelItalic, isLabelShadow);
631 thePrs->SetBoldLabel(isLabelBold);
632 thePrs->SetItalicLabel(isLabelItalic);
633 thePrs->SetShadowLabel(isLabelShadow);
634 thePrs->SetLblFontType(aLabelFontFamily);
635 thePrs->SetLabelColor(aLblColor.red()/255.,
636 aLblColor.green()/255.,
637 aLblColor.blue()/255.);
644 Called when orientation is changed
646 void VisuGUI_ScalarBarPane::changeDefaults( int )
648 if ( RBvert->isChecked() ) {
649 XSpin->setValue( myVerX );
650 YSpin->setValue( myVerY );
651 WidthSpin->setValue( myVerW );
652 HeightSpin->setValue( myVerH );
655 XSpin->setValue( myHorX );
656 YSpin->setValue( myHorY );
657 WidthSpin->setValue( myHorW );
658 HeightSpin->setValue( myHorH );
663 Called when Range mode is changed
665 void VisuGUI_ScalarBarPane::changeRange( int )
668 if ( RBFrange->isChecked() )
670 if ( RBIrange->isChecked() )
672 if ( myRangeMode == mode )
674 //MinSpin->setMaxValue( Fmin );
675 //MaxSpin->setMinValue( Fmax );
676 if ( RBFrange->isChecked() ) {
677 //MinLabel->setEnabled( false );
678 MinEdit->setEnabled( false );
679 //MaxLabel->setEnabled( false );
680 MaxEdit->setEnabled( false );
682 Imin = MinEdit->text().toDouble();
683 Imax = MaxEdit->text().toDouble();
685 MinEdit->setText( QString::number( Rmin ) );
686 MaxEdit->setText( QString::number( Rmax ) );
689 //MinLabel->setEnabled( true );
690 MinEdit->setEnabled( true );
691 //MaxLabel->setEnabled( true );
692 MaxEdit->setEnabled( true );
693 MinEdit->setText( QString::number( Imin ) );
694 MaxEdit->setText( QString::number( Imax ) );
700 Called when X,Y position is changed
702 void VisuGUI_ScalarBarPane::XYChanged( double )
704 QtxDblSpinBox* snd = (QtxDblSpinBox*)sender();
705 if ( snd == XSpin ) {
706 WidthSpin->setMaxValue( 1.0 - XSpin->value() );
708 if ( snd == YSpin ) {
709 HeightSpin->setMaxValue( 1.0 - YSpin->value() );
714 Sets default values and range mode
716 void VisuGUI_ScalarBarPane::setRange( double imin, double imax/*, double fmin, double fmax*/, bool sbRange )
718 Imin = imin; Imax = imax;// Fmin = fmin; Fmax = fmax;
719 if ( RBIrange->isChecked() ) {
720 MinEdit->setText( QString::number( Imin ) );
721 MaxEdit->setText( QString::number( Imax ) );
724 MinEdit->setText( QString::number( Rmin ) );
725 MaxEdit->setText( QString::number( Rmax ) );
729 RBIrange->setChecked( true );
731 RBFrange->setChecked( true );
736 Sets size and position
738 void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
745 RBvert->setChecked( true );
752 RBhori->setChecked( true );
758 Sets colors and labels number
760 void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
762 ColorSpin->setValue( colors );
763 LabelSpin->setValue( labels );
769 int VisuGUI_ScalarBarPane::getOrientation()
771 if (RBvert->isChecked() )
778 Called when <OK> button is clicked, validates data and closes dialog
780 bool VisuGUI_ScalarBarPane::check()
782 double minVal = MinEdit->text().toDouble();
783 double maxVal = MaxEdit->text().toDouble();
784 if ( RBIrange->isChecked() ) {
785 if (minVal >= maxVal) {
786 SUIT_MessageBox::warn1( this,tr("WRN_VISU"),
787 tr("MSG_MINMAX_VALUES"),
792 // check if logarithmic mode is on and check imposed range to not contain negative values
793 if ( CBLog->isChecked() ) {
794 if ( RBIrange->isChecked() ) {
795 if ( (minVal > 0) && (maxVal > 0) ) {
799 SUIT_MessageBox::warn1( this,
801 tr("WRN_LOGARITHMIC_RANGE"),
807 if ( Rmin > 0 && Rmax > 0 ) {
811 SUIT_MessageBox::warn1( this,
813 tr("WRN_LOGARITHMIC_FIELD_RANGE"),
815 RBIrange->setChecked(1);
817 //MinEdit->setText( QString::number( Rmin ) );
818 //MaxEdit->setText( QString::number( Rmax ) );
826 void VisuGUI_ScalarBarPane::onTextPref()
828 myIsStoreTextProp = myTextDlg->exec();
832 //#######################################################################################
837 VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool SetPref)
838 : QDialog(VISU::GetDesktop(theModule), 0, true,
839 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
841 setName("VisuGUI_ScalarBarDlg");
842 setCaption(SetPref ? tr("DLG_PREF_TITLE") : tr("DLG_PROP_TITLE"));
843 setSizeGripEnabled(TRUE);
845 QVBoxLayout* TopLayout = new QVBoxLayout(this);
846 TopLayout->setSpacing(6);
847 TopLayout->setMargin(11);
849 myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref);
850 TopLayout->addWidget(myScalarPane);
852 // Common buttons ===========================================================
853 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
854 GroupButtons->setColumnLayout(0, Qt::Vertical );
855 GroupButtons->layout()->setSpacing( 0 );
856 GroupButtons->layout()->setMargin( 0 );
857 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
858 GroupButtonsLayout->setAlignment( Qt::AlignTop );
859 GroupButtonsLayout->setSpacing( 6 );
860 GroupButtonsLayout->setMargin( 11 );
862 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
863 buttonOk->setAutoDefault( TRUE );
864 buttonOk->setDefault( TRUE );
865 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
866 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
868 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
869 buttonCancel->setAutoDefault( TRUE );
870 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
872 TopLayout->addWidget( GroupButtons );
874 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
875 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
879 Called when <OK> button is clicked, validates data and closes dialog
881 void VisuGUI_ScalarBarDlg::accept()
883 if (myScalarPane->check()) QDialog::accept();
887 //#######################################################################################
888 VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent)
889 : QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
891 setName("VisuGUI_TextPrefDlg");
892 setCaption(tr("TIT_TEXT_PREF"));
893 setSizeGripEnabled(TRUE);
895 QVBoxLayout* TopLayout = new QVBoxLayout(this);
896 TopLayout->setSpacing(6);
897 TopLayout->setMargin(11);
900 QGroupBox* aTitleGrp = new QGroupBox (2, Qt::Vertical, tr("LBL_TITLE"), this);
903 myTitleEdt = new QLineEdit (aTitleGrp);
906 QHBox* aHBox = new QHBox (aTitleGrp);
907 aHBox->setSpacing(5);
908 myTitleFont = new VisuGUI_FontWg (aHBox);
910 TopLayout->addWidget(aTitleGrp);
913 QGroupBox* aLabelsGrp = new QGroupBox (1, Qt::Vertical, tr("LBL_LABELS"), this);
916 aHBox = new QHBox (aLabelsGrp);
917 aHBox->setSpacing(5);
918 myLabelFont = new VisuGUI_FontWg (aHBox);
920 TopLayout->addWidget(aLabelsGrp);
922 // Common buttons ===========================================================
923 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
924 GroupButtons->setColumnLayout(0, Qt::Vertical );
925 GroupButtons->layout()->setSpacing( 0 );
926 GroupButtons->layout()->setMargin( 0 );
927 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
928 GroupButtonsLayout->setAlignment( Qt::AlignTop );
929 GroupButtonsLayout->setSpacing( 6 );
930 GroupButtonsLayout->setMargin( 11 );
932 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
933 buttonOk->setAutoDefault( TRUE );
934 buttonOk->setDefault( TRUE );
935 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
936 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
938 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
939 buttonCancel->setAutoDefault( TRUE );
940 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
942 TopLayout->addWidget( GroupButtons );
944 connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
945 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));