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_FontWg.h"
34 #include "VISUConfig.hh"
35 #include "VISU_Convertor.hxx"
37 #include "VISU_ScalarMapPL.hxx"
38 #include "VISU_ScalarMap_i.hh"
40 #include "SalomeApp_Application.h"
42 #include "SUIT_MessageBox.h"
43 #include "SUIT_ResourceMgr.h"
47 #include <qvalidator.h>
48 #include <qcolordialog.h>
53 VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
56 myVerX = 0.01; myVerY = 0.10; myVerW = 0.10; myVerH = 0.80;
57 myHorX = 0.20; myHorY = 0.01; myHorW = 0.60; myHorH = 0.12;
58 Imin = 0.0; Imax = 0.0; /*Fmin = 0.0; Fmax = 0.0;*/ Rmin = 0.0; Rmax = 0.0;
64 // Range ============================================================
65 RangeGroup = new QButtonGroup (tr("SCALAR_RANGE_GRP"), this, "RangeGroup");
66 RangeGroup->setColumnLayout(0, Qt::Vertical );
67 RangeGroup->layout()->setSpacing( 0 );
68 RangeGroup->layout()->setMargin( 0 );
69 QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() );
70 RangeGroupLayout->setAlignment( Qt::AlignTop );
71 RangeGroupLayout->setSpacing( 6 );
72 RangeGroupLayout->setMargin( 11 );
74 myModeLbl = new QLabel("Scalar Mode", RangeGroup);
76 myModeCombo = new QComboBox(RangeGroup);
77 myModeCombo->insertItem("Modulus");
78 myModeCombo->insertItem("Component 1");
79 myModeCombo->insertItem("Component 2");
80 myModeCombo->insertItem("Component 3");
82 CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), RangeGroup);
83 CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
85 RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), RangeGroup, "RBFrange");
86 RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), RangeGroup, "RBIrange");
87 RBFrange->setChecked( true );
89 MinEdit = new QLineEdit( RangeGroup, "MinEdit" );
90 MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
91 MinEdit->setMinimumWidth( 70 );
92 MinEdit->setValidator( new QDoubleValidator(this) );
93 MinEdit->setText( "0.0" );
94 QLabel* MinLabel = new QLabel (tr("LBL_MIN"), RangeGroup, "MinLabel");
95 MinLabel->setBuddy(MinEdit);
97 MaxEdit = new QLineEdit( RangeGroup, "MaxEdit" );
98 MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
99 MaxEdit->setMinimumWidth( 70 );
100 MaxEdit->setValidator( new QDoubleValidator(this) );
101 MaxEdit->setText( "0.0" );
102 QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), RangeGroup, "MaxLabel");
103 MaxLabel->setBuddy(MaxEdit);
105 RangeGroupLayout->addWidget( myModeLbl, 0, 0 );
106 RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3);
107 RangeGroupLayout->addMultiCellWidget( CBLog, 1, 1, 0, 3);
108 RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1);
109 RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3);
110 RangeGroupLayout->addWidget( MinLabel, 3, 0 );
111 RangeGroupLayout->addWidget( MinEdit, 3, 1 );
112 RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
113 RangeGroupLayout->addWidget( MaxEdit, 3, 3 );
115 //TopLayout->addWidget( RangeGroup );
117 // Colors and Labels ========================================================
118 QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this, "ColLabGroup");
119 ColLabGroup->setColumnLayout(0, Qt::Vertical );
120 ColLabGroup->layout()->setSpacing( 0 );
121 ColLabGroup->layout()->setMargin( 0 );
122 QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() );
123 ColLabGroupLayout->setAlignment( Qt::AlignTop );
124 ColLabGroupLayout->setSpacing( 6 );
125 ColLabGroupLayout->setMargin( 11 );
127 QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup, "ColorLabel");
128 ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup );
129 ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
130 ColorSpin->setMinimumWidth( 70 );
131 ColorSpin->setValue( 64 );
133 QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup, "LabelLabel");
134 LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup );
135 LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
136 LabelSpin->setMinimumWidth( 70 );
137 LabelSpin->setValue( 5 );
139 ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
140 ColLabGroupLayout->addWidget( ColorSpin, 0, 1);
141 ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
142 ColLabGroupLayout->addWidget( LabelSpin, 0, 3);
144 //TopLayout->addWidget( ColLabGroup );
146 // Orientation ==========================================================
147 QButtonGroup* OrientGroup = new QButtonGroup (tr("ORIENTATION_GRP"), this, "OrientGroup");
148 OrientGroup->setColumnLayout(0, Qt::Vertical );
149 OrientGroup->layout()->setSpacing( 0 );
150 OrientGroup->layout()->setMargin( 0 );
151 QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() );
152 OrientGroupLayout->setAlignment( Qt::AlignTop );
153 OrientGroupLayout->setSpacing( 6 );
154 OrientGroupLayout->setMargin( 11 );
156 RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGroup, "RBvert");
157 RBvert->setChecked( true );
158 RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGroup, "RBhori");
159 OrientGroupLayout->addWidget( RBvert, 0, 0 );
160 OrientGroupLayout->addWidget( RBhori, 0, 1 );
162 // TopLayout->addWidget( OrientGroup );
164 // Origin ===============================================================
165 QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this, "OriginGroup");
166 OriginGroup->setColumnLayout(0, Qt::Vertical );
167 OriginGroup->layout()->setSpacing( 0 );
168 OriginGroup->layout()->setMargin( 0 );
169 QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() );
170 OriginGroupLayout->setAlignment( Qt::AlignTop );
171 OriginGroupLayout->setSpacing( 6 );
172 OriginGroupLayout->setMargin( 11 );
174 QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup, "XLabel");
175 XSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
176 XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
177 XSpin->setMinimumWidth( 70 );
178 XSpin->setValue( 0.01 );
180 QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup, "YLabel");
181 YSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
182 YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
183 YSpin->setMinimumWidth( 70 );
184 YSpin->setValue( 0.01 );
186 OriginGroupLayout->addWidget( XLabel, 0, 0);
187 OriginGroupLayout->addWidget( XSpin, 0, 1);
188 OriginGroupLayout->addWidget( YLabel, 0, 2);
189 OriginGroupLayout->addWidget( YSpin, 0, 3);
191 //TopLayout->addWidget( OriginGroup );
193 // Dimensions =========================================================
194 QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this, "DimGroup");
195 DimGroup->setColumnLayout(0, Qt::Vertical );
196 DimGroup->layout()->setSpacing( 0 );
197 DimGroup->layout()->setMargin( 0 );
198 QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() );
199 DimGroupLayout->setAlignment( Qt::AlignTop );
200 DimGroupLayout->setSpacing( 6 );
201 DimGroupLayout->setMargin( 11 );
203 QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup, "WidthLabel");
204 WidthSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
205 WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
206 WidthSpin->setMinimumWidth( 70 );
207 WidthSpin->setValue( 0.1 );
209 QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup, "HeightLabel");
210 HeightSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
211 HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
212 HeightSpin->setMinimumWidth( 70 );
213 HeightSpin->setValue( 0.8 );
215 DimGroupLayout->addWidget( WidthLabel, 0, 0);
216 DimGroupLayout->addWidget( WidthSpin, 0, 1);
217 DimGroupLayout->addWidget( HeightLabel, 0, 2);
218 DimGroupLayout->addWidget( HeightSpin, 0, 3);
220 //TopLayout->addWidget( DimGroup );
222 // Save check box ===========================================================
223 QHBox* aSaveBox = new QHBox(this);
225 CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), aSaveBox, "CBSave");
226 //TopLayout->addWidget(CBSave);
231 myTextBtn = new QPushButton("Text properties...", aSaveBox);
232 myTextDlg = new VisuGUI_TextPrefDlg(this);
233 myTextDlg->setTitleVisible(!SetPref);
235 // signals and slots connections ===========================================
236 connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) );
237 connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) );
238 connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
239 connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
240 connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
244 myIsStoreTextProp = false;
249 * Initializes dialog box values from resources
251 void VisuGUI_ScalarBarPane::initFromResources() {
252 int sbCol=64,sbLab=5,orient=1;
253 float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8;
254 float sbVmin=0., sbVmax=0.;
258 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
260 orient = aResourceMgr->integerValue("Visu:SBOrientation",orient);
269 sbX1 = aResourceMgr->doubleValue("Visu:SBXorigin",sbX1);
270 sbY1 = aResourceMgr->doubleValue("Visu:SBYorigin",sbY1);
272 sbW = aResourceMgr->doubleValue("Visu:SBWidth",sbW);
273 sbH = aResourceMgr->doubleValue("Visu:SBHeight",sbH);
275 sbCol = aResourceMgr->integerValue("Visu:SBNumberOfColors",sbCol);
276 sbLab = aResourceMgr->integerValue("Visu:SBNumberOfLabels",sbLab);
277 sbRange = aResourceMgr->booleanValue("Visu:SBImposeRange",sbRange);
278 sbVmin = aResourceMgr->doubleValue("Visu:SBMinimumValue",sbVmin);
279 sbVmax = aResourceMgr->doubleValue("Visu:SBMaximumValue",sbVmax);
281 QString aScaling = aResourceMgr->stringValue("Visu:SBMaximumValue","LINEAR");
282 if(aScaling.compare("LOGARITHMIC") == 0)
283 setLogarithmic(true);
285 setLogarithmic(false);
287 if((sbX1 < 0.) || (sbY1 < 0.) ||
288 ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
301 if(sbCol < 2) sbCol=2;
302 if(sbCol > 64) sbCol=64;
303 if(sbLab < 2) sbLab=2;
304 if(sbLab > 65) sbLab=65;
306 if(sbVmin > sbVmax) {
311 setRange( sbVmin, sbVmax, /*0.0, 0.0,*/ sbRange );
312 setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 1);
313 setScalarBarData( sbCol, sbLab );
316 aString = aResourceMgr->stringValue("Visu:IsBoldTitle","true");
317 bool isBold = (aString.compare("true") == 0);
318 aString = aResourceMgr->stringValue("Visu:IsItalicTitle","true");
319 bool isItalic = (aString.compare("true") == 0);
320 aString = aResourceMgr->stringValue("Visu:IsShadowTitle","true");
321 bool isShadow = (aString.compare("true") == 0);
323 int aFontType = aResourceMgr->integerValue("Visu:TitFontType",0);
324 int aFontFamily = VTK_ARIAL;
327 aFontFamily = VTK_ARIAL; break;
329 aFontFamily = VTK_COURIER; break;
331 aFontFamily = VTK_TIMES; break;
334 float R = aResourceMgr->doubleValue("Visu:TitleColorR",1.0);
338 float G = aResourceMgr->doubleValue("Visu:TitleColorG",1.0);
342 float B = aResourceMgr->doubleValue("Visu:TitleColorB",1.0);
346 myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
348 isBold, isItalic, isShadow);
351 aString = aResourceMgr->stringValue("Visu:IsBoldLabel","true");
352 isBold = (aString.compare("true") == 0);
353 aString = aResourceMgr->stringValue("Visu:IsItalicLabel","true");
354 isItalic = (aString.compare("true") == 0);
355 aString = aResourceMgr->stringValue("Visu:IsShadowLabel","true");
356 isShadow = (aString.compare("true") == 0);
358 aFontType = aResourceMgr->integerValue("Visu:LblFontType",0);
359 aFontFamily = VTK_ARIAL;
362 aFontFamily = VTK_ARIAL; break;
364 aFontFamily = VTK_COURIER; break;
366 aFontFamily = VTK_TIMES; break;
369 R = aResourceMgr->doubleValue("Visu:LabelColorR",1.0);
373 G = aResourceMgr->doubleValue("Visu:LabelColorG",1.0);
377 B = aResourceMgr->doubleValue("Visu:LabelColorB",1.0);
381 myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
383 isBold, isItalic, isShadow);
387 * Stores dialog values to resources
389 void VisuGUI_ScalarBarPane::storeToResources() {
390 int orient = (RBvert->isChecked())? 1 : 0;
391 float sbX1 = XSpin->value();
392 float sbY1 = YSpin->value();
393 float sbW = WidthSpin->value();
394 float sbH = HeightSpin->value();
395 int sbCol = ColorSpin->value();
396 int sbLab = LabelSpin->value();
398 if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
412 bool sbRange = RBIrange->isChecked();
413 float sbVmin = (float)(MinEdit->text().toDouble());
414 float sbVmax = (float)(MaxEdit->text().toDouble());
416 if(sbVmin > sbVmax) {
421 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
423 aResourceMgr->setValue("Visu:SBOrientation",orient);
424 aResourceMgr->setValue("Visu:SBXorigin",sbX1);
425 aResourceMgr->setValue("Visu:SBYorigin",sbY1);
426 aResourceMgr->setValue("Visu:SBWidth",sbW);
427 aResourceMgr->setValue("Visu:SBHeight",sbH);
428 aResourceMgr->setValue("Visu:SBNumberOfColors",sbCol);
429 aResourceMgr->setValue("Visu:SBNumberOfLabels",sbLab);
431 aResourceMgr->setValue("Visu:SBImposeRange", "true");
433 aResourceMgr->setValue("Visu:SBImposeRange", "false");
434 aResourceMgr->setValue("Visu:SBMinimumValue",sbVmin);
435 aResourceMgr->setValue("Visu:SBMaximumValue",sbVmax);
437 aResourceMgr->setValue("Visu:SBScaling", "LOGARITHMIC");
439 aResourceMgr->setValue("Visu:SBScaling", "LINEAR");
443 if (myIsStoreTextProp) {
445 QColor aTitleColor (255, 255, 255);
446 int aTitleFontFamily = VTK_ARIAL;
447 bool isTitleBold = false;
448 bool isTitleItalic = false;
449 bool isTitleShadow = false;
451 myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily,
452 isTitleBold, isTitleItalic, isTitleShadow);
455 aResourceMgr->setValue("Visu:IsBoldTitle","true");
457 aResourceMgr->setValue("Visu:IsBoldTitle","false");
460 aResourceMgr->setValue("Visu:IsItalicTitle","true");
462 aResourceMgr->setValue("Visu:IsItalicTitle","false");
465 aResourceMgr->setValue("Visu:IsShadowTitle","true");
467 aResourceMgr->setValue("Visu:IsShadowTitle","false");
469 switch (aTitleFontFamily) {
471 aResourceMgr->setValue("Visu:TitFontType",0);
474 aResourceMgr->setValue("Visu:TitFontType",1);
477 aResourceMgr->setValue("Visu:TitFontType",2);
480 aResourceMgr->setValue("Visu:TitleColorR", aTitleColor.red()/255.);
481 aResourceMgr->setValue("Visu:TitleColorG", aTitleColor.green()/255.);
482 aResourceMgr->setValue("Visu:TitleColorB", aTitleColor.blue()/255.);
485 QColor aLabelColor (255, 255, 255);
486 int aLabelFontFamily = VTK_ARIAL;
487 bool isLabelBold = false;
488 bool isLabelItalic = false;
489 bool isLabelShadow = false;
491 myTextDlg->myTitleFont->GetData(aLabelColor, aLabelFontFamily,
492 isLabelBold, isLabelItalic, isLabelShadow);
495 aResourceMgr->setValue("Visu:IsBoldLabel","true");
497 aResourceMgr->setValue("Visu:IsBoldLabel","false");
500 aResourceMgr->setValue("Visu:IsItalicLabel","true");
502 aResourceMgr->setValue("Visu:IsItalicLabel","false");
505 aResourceMgr->setValue("Visu:IsShadowLabel","true");
507 aResourceMgr->setValue("Visu:IsShadowLabel","false");
509 switch (aLabelFontFamily) {
511 aResourceMgr->setValue("Visu:LblFontType",0);
514 aResourceMgr->setValue("Visu:LblFontType",1);
517 aResourceMgr->setValue("Visu:LblFontType",2);
520 aResourceMgr->setValue("Visu:LabelColorR", aLabelColor.red()/255.);
521 aResourceMgr->setValue("Visu:LabelColorG", aLabelColor.green()/255.);
522 aResourceMgr->setValue("Visu:LabelColorB", aLabelColor.blue()/255.);
527 * Initialise dialog box from presentation object
529 void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
531 myModeCombo->setCurrentItem(thePrs->GetScalarMode());
532 setPosAndSize( thePrs->GetPosX(),
536 thePrs->GetBarOrientation());
537 switch(thePrs->GetScaling()){
538 case VISU::LOGARITHMIC :
539 setLogarithmic(true);
542 setLogarithmic(false);
545 thePrs->GetScalarMapPL()->GetSourceRange(aRange);
546 Rmin = aRange[0]; Rmax = aRange[1];
547 setRange( thePrs->GetMin(), thePrs->GetMax(),
548 /*0.0, 0.0,*/ thePrs->IsRangeFixed() );
549 setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
550 bool isScalarMode = (thePrs->GetField()->myNbComp > 1);
551 myModeLbl->setEnabled(isScalarMode);
552 myModeCombo->setEnabled(isScalarMode);
555 myTextDlg->setTitleText(QString(thePrs->GetTitle()));
558 thePrs->GetTitleColor(&R, &G, &B);
560 myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
561 thePrs->GetTitFontType(),
562 thePrs->IsBoldTitle(),
563 thePrs->IsItalicTitle(),
564 thePrs->IsShadowTitle());
567 thePrs->GetLabelColor(&R, &G, &B);
569 myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
570 thePrs->GetLblFontType(),
571 thePrs->IsBoldLabel(),
572 thePrs->IsItalicLabel(),
573 thePrs->IsShadowLabel());
577 * Store values to presentation object
579 int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ScalarMap_i* thePrs) {
580 thePrs->SetScalarMode(myModeCombo->currentItem());
581 thePrs->SetPosition(XSpin->value(), YSpin->value());
582 thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
583 thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
585 thePrs->SetScaling(VISU::LOGARITHMIC);
587 thePrs->SetScaling(VISU::LINEAR);
589 if (RBFrange->isChecked()) {
590 thePrs->SetSourceRange();
592 thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
594 thePrs->SetNbColors(ColorSpin->value());
595 thePrs->SetLabels(LabelSpin->value());
597 if (isToSave()) storeToResources();
599 if (myIsStoreTextProp) {
601 thePrs->SetTitle(myTextDlg->getTitleText().latin1());
603 QColor aTitColor (255, 255, 255);
604 int aTitleFontFamily = VTK_ARIAL;
605 bool isTitleBold = false;
606 bool isTitleItalic = false;
607 bool isTitleShadow = false;
609 myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
610 isTitleBold, isTitleItalic, isTitleShadow);
612 thePrs->SetBoldTitle(isTitleBold);
613 thePrs->SetItalicTitle(isTitleItalic);
614 thePrs->SetShadowTitle(isTitleShadow);
615 thePrs->SetTitFontType(aTitleFontFamily);
616 thePrs->SetTitleColor(aTitColor.red()/255.,
617 aTitColor.green()/255.,
618 aTitColor.blue()/255.);
621 QColor aLblColor (255, 255, 255);
622 int aLabelFontFamily = VTK_ARIAL;
623 bool isLabelBold = false;
624 bool isLabelItalic = false;
625 bool isLabelShadow = false;
627 myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
628 isLabelBold, isLabelItalic, isLabelShadow);
630 thePrs->SetBoldLabel(isLabelBold);
631 thePrs->SetItalicLabel(isLabelItalic);
632 thePrs->SetShadowLabel(isLabelShadow);
633 thePrs->SetLblFontType(aLabelFontFamily);
634 thePrs->SetLabelColor(aLblColor.red()/255.,
635 aLblColor.green()/255.,
636 aLblColor.blue()/255.);
643 Called when orientation is changed
645 void VisuGUI_ScalarBarPane::changeDefaults( int )
647 if ( RBvert->isChecked() ) {
648 XSpin->setValue( myVerX );
649 YSpin->setValue( myVerY );
650 WidthSpin->setValue( myVerW );
651 HeightSpin->setValue( myVerH );
654 XSpin->setValue( myHorX );
655 YSpin->setValue( myHorY );
656 WidthSpin->setValue( myHorW );
657 HeightSpin->setValue( myHorH );
662 Called when Range mode is changed
664 void VisuGUI_ScalarBarPane::changeRange( int )
667 if ( RBFrange->isChecked() )
669 if ( RBIrange->isChecked() )
671 if ( myRangeMode == mode )
673 //MinSpin->setMaxValue( Fmin );
674 //MaxSpin->setMinValue( Fmax );
675 if ( RBFrange->isChecked() ) {
676 //MinLabel->setEnabled( false );
677 MinEdit->setEnabled( false );
678 //MaxLabel->setEnabled( false );
679 MaxEdit->setEnabled( false );
681 Imin = MinEdit->text().toDouble();
682 Imax = MaxEdit->text().toDouble();
684 MinEdit->setText( QString::number( Rmin ) );
685 MaxEdit->setText( QString::number( Rmax ) );
688 //MinLabel->setEnabled( true );
689 MinEdit->setEnabled( true );
690 //MaxLabel->setEnabled( true );
691 MaxEdit->setEnabled( true );
692 MinEdit->setText( QString::number( Imin ) );
693 MaxEdit->setText( QString::number( Imax ) );
699 Called when X,Y position is changed
701 void VisuGUI_ScalarBarPane::XYChanged( double )
703 QtxDblSpinBox* snd = (QtxDblSpinBox*)sender();
704 if ( snd == XSpin ) {
705 WidthSpin->setMaxValue( 1.0 - XSpin->value() );
707 if ( snd == YSpin ) {
708 HeightSpin->setMaxValue( 1.0 - YSpin->value() );
713 Sets default values and range mode
715 void VisuGUI_ScalarBarPane::setRange( double imin, double imax/*, double fmin, double fmax*/, bool sbRange )
717 Imin = imin; Imax = imax;// Fmin = fmin; Fmax = fmax;
718 if ( RBIrange->isChecked() ) {
719 MinEdit->setText( QString::number( Imin ) );
720 MaxEdit->setText( QString::number( Imax ) );
723 MinEdit->setText( QString::number( Rmin ) );
724 MaxEdit->setText( QString::number( Rmax ) );
728 RBIrange->setChecked( true );
730 RBFrange->setChecked( true );
735 Sets size and position
737 void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
744 RBvert->setChecked( true );
751 RBhori->setChecked( true );
757 Sets colors and labels number
759 void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
761 ColorSpin->setValue( colors );
762 LabelSpin->setValue( labels );
768 int VisuGUI_ScalarBarPane::getOrientation()
770 if (RBvert->isChecked() )
777 Called when <OK> button is clicked, validates data and closes dialog
779 bool VisuGUI_ScalarBarPane::check()
781 double minVal = MinEdit->text().toDouble();
782 double maxVal = MaxEdit->text().toDouble();
783 if ( RBIrange->isChecked() ) {
784 if (minVal >= maxVal) {
785 SUIT_MessageBox::warn1( this,tr("WRN_VISU"),
786 tr("MSG_MINMAX_VALUES"),
791 // check if logarithmic mode is on and check imposed range to not contain negative values
792 if ( CBLog->isChecked() ) {
793 if ( RBIrange->isChecked() ) {
794 if ( (minVal > 0) && (maxVal > 0) ) {
798 SUIT_MessageBox::warn1( this,
800 tr("WRN_LOGARITHMIC_RANGE"),
806 if ( Rmin > 0 && Rmax > 0 ) {
810 SUIT_MessageBox::warn1( this,
812 tr("WRN_LOGARITHMIC_FIELD_RANGE"),
814 RBIrange->setChecked(1);
816 //MinEdit->setText( QString::number( Rmin ) );
817 //MaxEdit->setText( QString::number( Rmax ) );
825 void VisuGUI_ScalarBarPane::onTextPref()
827 myIsStoreTextProp = myTextDlg->exec();
831 //#######################################################################################
836 VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (QWidget* parent, bool SetPref)
837 : QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
839 setName("VisuGUI_ScalarBarDlg");
840 setCaption(SetPref ? tr("DLG_PREF_TITLE") : tr("DLG_PROP_TITLE"));
841 setSizeGripEnabled(TRUE);
843 QVBoxLayout* TopLayout = new QVBoxLayout(this);
844 TopLayout->setSpacing(6);
845 TopLayout->setMargin(11);
847 myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref);
848 TopLayout->addWidget(myScalarPane);
850 // Common buttons ===========================================================
851 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
852 GroupButtons->setColumnLayout(0, Qt::Vertical );
853 GroupButtons->layout()->setSpacing( 0 );
854 GroupButtons->layout()->setMargin( 0 );
855 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
856 GroupButtonsLayout->setAlignment( Qt::AlignTop );
857 GroupButtonsLayout->setSpacing( 6 );
858 GroupButtonsLayout->setMargin( 11 );
860 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
861 buttonOk->setAutoDefault( TRUE );
862 buttonOk->setDefault( TRUE );
863 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
864 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
866 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
867 buttonCancel->setAutoDefault( TRUE );
868 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
870 TopLayout->addWidget( GroupButtons );
872 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
873 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
877 Called when <OK> button is clicked, validates data and closes dialog
879 void VisuGUI_ScalarBarDlg::accept()
881 if (myScalarPane->check()) QDialog::accept();
885 //#######################################################################################
886 VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent)
887 : QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
889 setName("VisuGUI_TextPrefDlg");
890 setCaption(tr("TIT_TEXT_PREF"));
891 setSizeGripEnabled(TRUE);
893 QVBoxLayout* TopLayout = new QVBoxLayout(this);
894 TopLayout->setSpacing(6);
895 TopLayout->setMargin(11);
898 QGroupBox* aTitleGrp = new QGroupBox (2, Qt::Vertical, tr("LBL_TITLE"), this);
901 myTitleEdt = new QLineEdit (aTitleGrp);
904 QHBox* aHBox = new QHBox (aTitleGrp);
905 aHBox->setSpacing(5);
906 myTitleFont = new VisuGUI_FontWg (aHBox);
908 TopLayout->addWidget(aTitleGrp);
911 QGroupBox* aLabelsGrp = new QGroupBox (1, Qt::Vertical, tr("LBL_LABELS"), this);
914 aHBox = new QHBox (aLabelsGrp);
915 aHBox->setSpacing(5);
916 myLabelFont = new VisuGUI_FontWg (aHBox);
918 TopLayout->addWidget(aLabelsGrp);
920 // Common buttons ===========================================================
921 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
922 GroupButtons->setColumnLayout(0, Qt::Vertical );
923 GroupButtons->layout()->setSpacing( 0 );
924 GroupButtons->layout()->setMargin( 0 );
925 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
926 GroupButtonsLayout->setAlignment( Qt::AlignTop );
927 GroupButtonsLayout->setSpacing( 6 );
928 GroupButtonsLayout->setMargin( 11 );
930 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
931 buttonOk->setAutoDefault( TRUE );
932 buttonOk->setDefault( TRUE );
933 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
934 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
936 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
937 buttonCancel->setAutoDefault( TRUE );
938 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
940 TopLayout->addWidget( GroupButtons );
942 connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
943 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));