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
31 #include <qvalidator.h>
32 #include <qcolordialog.h>
34 #include "SUIT_MessageBox.h"
35 #include "SUIT_ResourceMgr.h"
37 #include "SalomeApp_Application.h"
40 #include "VISUConfig.hh"
41 #include "VISU_Convertor.hxx"
43 #include "VISU_ScalarMapPL.hxx"
44 #include "VISU_ScalarMap_i.hh"
46 #include "VisuGUI_ScalarBarDlg.h"
52 VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane(QWidget * parent, bool SetPref):
55 myVerX = 0.01; myVerY = 0.10; myVerW = 0.10; myVerH = 0.80;
56 myHorX = 0.20; myHorY = 0.01; myHorW = 0.60; myHorH = 0.12;
57 Imin = 0.0; Imax = 0.0; /*Fmin = 0.0; Fmax = 0.0;*/ Rmin = 0.0; Rmax = 0.0;
63 // Range ============================================================
64 RangeGroup = new QButtonGroup( tr( "Scalar range" ), this, "RangeGroup" );
65 RangeGroup->setColumnLayout(0, Qt::Vertical );
66 RangeGroup->layout()->setSpacing( 0 );
67 RangeGroup->layout()->setMargin( 0 );
68 QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() );
69 RangeGroupLayout->setAlignment( Qt::AlignTop );
70 RangeGroupLayout->setSpacing( 6 );
71 RangeGroupLayout->setMargin( 11 );
73 myModeLbl = new QLabel("Scalar Mode", RangeGroup);
75 myModeCombo = new QComboBox(RangeGroup);
76 myModeCombo->insertItem("Modulus");
77 myModeCombo->insertItem("Component 1");
78 myModeCombo->insertItem("Component 2");
79 myModeCombo->insertItem("Component 3");
81 CBLog = new QCheckBox( tr( "Logarithmic scaling" ), RangeGroup );
82 CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
84 RBFrange = new QRadioButton( tr( "Use field range" ), RangeGroup, "RBFrange" );
85 RBIrange = new QRadioButton( tr( "Use imposed range" ), RangeGroup, "RBIrange" );
86 RBFrange->setChecked( true );
88 MinEdit = new QLineEdit( RangeGroup, "MinEdit" );
89 MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
90 MinEdit->setMinimumWidth( 70 );
91 MinEdit->setValidator( new QDoubleValidator(this) );
92 MinEdit->setText( "0.0" );
93 QLabel* MinLabel = new QLabel( tr( "Min:" ), RangeGroup, "MinLabel" );
94 MinLabel->setBuddy(MinEdit);
96 MaxEdit = new QLineEdit( RangeGroup, "MaxEdit" );
97 MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
98 MaxEdit->setMinimumWidth( 70 );
99 MaxEdit->setValidator( new QDoubleValidator(this) );
100 MaxEdit->setText( "0.0" );
101 QLabel* MaxLabel = new QLabel( tr( "Max:" ), RangeGroup, "MaxLabel" );
102 MaxLabel->setBuddy(MaxEdit);
104 RangeGroupLayout->addWidget( myModeLbl, 0, 0 );
105 RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3);
106 RangeGroupLayout->addMultiCellWidget( CBLog, 1, 1, 0, 3);
107 RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1);
108 RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3);
109 RangeGroupLayout->addWidget( MinLabel, 3, 0 );
110 RangeGroupLayout->addWidget( MinEdit, 3, 1 );
111 RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
112 RangeGroupLayout->addWidget( MaxEdit, 3, 3 );
114 //TopLayout->addWidget( RangeGroup );
116 // Colors and Labels ========================================================
117 QGroupBox* ColLabGroup = new QGroupBox( tr( "Colors and labels" ), this, "ColLabGroup" );
118 ColLabGroup->setColumnLayout(0, Qt::Vertical );
119 ColLabGroup->layout()->setSpacing( 0 );
120 ColLabGroup->layout()->setMargin( 0 );
121 QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() );
122 ColLabGroupLayout->setAlignment( Qt::AlignTop );
123 ColLabGroupLayout->setSpacing( 6 );
124 ColLabGroupLayout->setMargin( 11 );
126 QLabel* ColorLabel = new QLabel( tr( "Nb. of colors:" ), ColLabGroup, "ColorLabel" );
127 ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup );
128 ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
129 ColorSpin->setMinimumWidth( 70 );
130 ColorSpin->setValue( 64 );
132 QLabel* LabelLabel = new QLabel( tr( "Nb. of labels:" ), ColLabGroup, "LabelLabel" );
133 LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup );
134 LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
135 LabelSpin->setMinimumWidth( 70 );
136 LabelSpin->setValue( 5 );
138 ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
139 ColLabGroupLayout->addWidget( ColorSpin, 0, 1);
140 ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
141 ColLabGroupLayout->addWidget( LabelSpin, 0, 3);
143 //TopLayout->addWidget( ColLabGroup );
145 // Orientation ==========================================================
146 QButtonGroup* OrientGroup = new QButtonGroup( tr( "Orientation" ), this, "OrientGroup" );
147 OrientGroup->setColumnLayout(0, Qt::Vertical );
148 OrientGroup->layout()->setSpacing( 0 );
149 OrientGroup->layout()->setMargin( 0 );
150 QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() );
151 OrientGroupLayout->setAlignment( Qt::AlignTop );
152 OrientGroupLayout->setSpacing( 6 );
153 OrientGroupLayout->setMargin( 11 );
155 RBvert = new QRadioButton( tr( "Vertical" ), OrientGroup, "RBvert" );
156 RBvert->setChecked( true );
157 RBhori = new QRadioButton( tr( "Horizontal" ), OrientGroup, "RBhori" );
158 OrientGroupLayout->addWidget( RBvert, 0, 0 );
159 OrientGroupLayout->addWidget( RBhori, 0, 1 );
161 // TopLayout->addWidget( OrientGroup );
163 // Origin ===============================================================
164 QGroupBox* OriginGroup = new QGroupBox( tr( "Origin" ), this, "OriginGroup" );
165 OriginGroup->setColumnLayout(0, Qt::Vertical );
166 OriginGroup->layout()->setSpacing( 0 );
167 OriginGroup->layout()->setMargin( 0 );
168 QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() );
169 OriginGroupLayout->setAlignment( Qt::AlignTop );
170 OriginGroupLayout->setSpacing( 6 );
171 OriginGroupLayout->setMargin( 11 );
173 QLabel* XLabel = new QLabel( tr( "X:" ), OriginGroup, "XLabel" );
174 XSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
175 XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
176 XSpin->setMinimumWidth( 70 );
177 XSpin->setValue( 0.01 );
179 QLabel* YLabel = new QLabel( tr( "Y:" ), OriginGroup, "YLabel" );
180 YSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
181 YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
182 YSpin->setMinimumWidth( 70 );
183 YSpin->setValue( 0.01 );
185 OriginGroupLayout->addWidget( XLabel, 0, 0);
186 OriginGroupLayout->addWidget( XSpin, 0, 1);
187 OriginGroupLayout->addWidget( YLabel, 0, 2);
188 OriginGroupLayout->addWidget( YSpin, 0, 3);
190 //TopLayout->addWidget( OriginGroup );
192 // Dimensions =========================================================
193 QGroupBox* DimGroup = new QGroupBox( tr( "Dimensions" ), this, "DimGroup" );
194 DimGroup->setColumnLayout(0, Qt::Vertical );
195 DimGroup->layout()->setSpacing( 0 );
196 DimGroup->layout()->setMargin( 0 );
197 QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() );
198 DimGroupLayout->setAlignment( Qt::AlignTop );
199 DimGroupLayout->setSpacing( 6 );
200 DimGroupLayout->setMargin( 11 );
202 QLabel* WidthLabel = new QLabel( tr( "Width:" ), DimGroup, "WidthLabel" );
203 WidthSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
204 WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
205 WidthSpin->setMinimumWidth( 70 );
206 WidthSpin->setValue( 0.1 );
208 QLabel* HeightLabel = new QLabel( tr( "Height:" ), DimGroup, "HeightLabel" );
209 HeightSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
210 HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
211 HeightSpin->setMinimumWidth( 70 );
212 HeightSpin->setValue( 0.8 );
214 DimGroupLayout->addWidget( WidthLabel, 0, 0);
215 DimGroupLayout->addWidget( WidthSpin, 0, 1);
216 DimGroupLayout->addWidget( HeightLabel, 0, 2);
217 DimGroupLayout->addWidget( HeightSpin, 0, 3);
219 //TopLayout->addWidget( DimGroup );
221 // Save check box ===========================================================
222 QHBox* aSaveBox = new QHBox(this);
224 CBSave = new QCheckBox( tr( "Save as default values" ), aSaveBox, "CBSave" );
225 //TopLayout->addWidget( CBSave );
230 myTextBtn = new QPushButton("Text properties...", aSaveBox);
231 myTextDlg = new VisuGUI_TextPrefDlg(this);
232 myTextDlg->setTitleVisible(!SetPref);
234 // signals and slots connections ===========================================
235 connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) );
236 connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) );
237 connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
238 connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
239 connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
243 myIsStoreTextProp = false;
248 * Initializes dialog box values from resources
250 void VisuGUI_ScalarBarPane::initFromResources() {
251 int sbCol=64,sbLab=5,orient=1;
252 float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8;
253 float sbVmin=0., sbVmax=0.;
257 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
259 orient = aResourceMgr->integerValue("Visu:SBOrientation",orient);
268 sbX1 = aResourceMgr->doubleValue("Visu:SBXorigin",sbX1);
269 sbY1 = aResourceMgr->doubleValue("Visu:SBYorigin",sbY1);
271 sbW = aResourceMgr->doubleValue("Visu:SBWidth",sbW);
272 sbH = aResourceMgr->doubleValue("Visu:SBHeight",sbH);
274 sbCol = aResourceMgr->integerValue("Visu:SBNumberOfColors",sbCol);
275 sbLab = aResourceMgr->integerValue("Visu:SBNumberOfLabels",sbLab);
276 sbRange = aResourceMgr->booleanValue("Visu:SBImposeRange",sbRange);
277 sbVmin = aResourceMgr->doubleValue("Visu:SBMinimumValue",sbVmin);
278 sbVmax = aResourceMgr->doubleValue("Visu:SBMaximumValue",sbVmax);
280 QString aScaling = aResourceMgr->stringValue("Visu:SBMaximumValue","LINEAR");
281 if(aScaling.compare("LOGARITHMIC") == 0)
282 setLogarithmic(true);
284 setLogarithmic(false);
286 if((sbX1 < 0.) || (sbY1 < 0.) ||
287 ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
300 if(sbCol < 2) sbCol=2;
301 if(sbCol > 64) sbCol=64;
302 if(sbLab < 2) sbLab=2;
303 if(sbLab > 65) sbLab=65;
305 if(sbVmin > sbVmax) {
310 setRange( sbVmin, sbVmax, /*0.0, 0.0,*/ sbRange );
311 setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 1);
312 setScalarBarData( sbCol, sbLab );
314 aString = aResourceMgr->stringValue("Visu:IsBoldTitle","true");
315 myTextDlg->setBoldTitle(aString.compare("true") == 0);
317 aString = aResourceMgr->stringValue("Visu:IsItalicTitle","true");
318 myTextDlg->setItalicTitle(aString.compare("true") == 0);
320 aString = aResourceMgr->stringValue("Visu:IsShadowTitle","true");
321 myTextDlg->setShadowTitle(aString.compare("true") == 0);
323 myTextDlg->setTitleFont(VTK_ARIAL);
324 switch(aResourceMgr->integerValue("Visu:TitFontType",0)){
326 myTextDlg->setTitleFont(VTK_ARIAL);
329 myTextDlg->setTitleFont(VTK_COURIER);
332 myTextDlg->setTitleFont(VTK_TIMES);
337 float R = aResourceMgr->doubleValue("Visu:TitleColorR",1.0);
341 float G = aResourceMgr->doubleValue("Visu:TitleColorG",1.0);
345 float B = aResourceMgr->doubleValue("Visu:TitleColorB",1.0);
349 myTextDlg->setTitleColor(QColor((int)(R*255.),
354 aString = aResourceMgr->stringValue("Visu:IsBoldLabel","true");
355 myTextDlg->setBoldLabel(aString.compare("true") == 0);
357 aString = aResourceMgr->stringValue("Visu:IsItalicLabel","true");
358 myTextDlg->setItalicLabel(aString.compare("true") == 0);
360 aString = aResourceMgr->stringValue("Visu:IsShadowLabel","true");
361 myTextDlg->setShadowLabel(aString.compare("true") == 0);
363 switch(aResourceMgr->integerValue("Visu:LblFontType",0)){
365 myTextDlg->setLabelFont(VTK_ARIAL);
368 myTextDlg->setLabelFont(VTK_COURIER);
371 myTextDlg->setLabelFont(VTK_TIMES);
376 float R = aResourceMgr->doubleValue("Visu:LabelColorR",1.0);
380 float G = aResourceMgr->doubleValue("Visu:LabelColorG",1.0);
384 float B = aResourceMgr->doubleValue("Visu:LabelColorB",1.0);
388 myTextDlg->setLabelColor(QColor((int)(R*255.),
398 * Stores dialog values to resources
400 void VisuGUI_ScalarBarPane::storeToResources() {
401 int orient = (RBvert->isChecked())? 1 : 0;
402 float sbX1 = XSpin->value();
403 float sbY1 = YSpin->value();
404 float sbW = WidthSpin->value();
405 float sbH = HeightSpin->value();
406 int sbCol = ColorSpin->value();
407 int sbLab = LabelSpin->value();
409 if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
423 bool sbRange = RBIrange->isChecked();
424 float sbVmin = (float)(MinEdit->text().toDouble());
425 float sbVmax = (float)(MaxEdit->text().toDouble());
427 if(sbVmin > sbVmax) {
432 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
434 aResourceMgr->setValue("Visu:SBOrientation",orient);
435 aResourceMgr->setValue("Visu:SBXorigin",sbX1);
436 aResourceMgr->setValue("Visu:SBYorigin",sbY1);
437 aResourceMgr->setValue("Visu:SBWidth",sbW);
438 aResourceMgr->setValue("Visu:SBHeight",sbH);
439 aResourceMgr->setValue("Visu:SBNumberOfColors",sbCol);
440 aResourceMgr->setValue("Visu:SBNumberOfLabels",sbLab);
442 aResourceMgr->setValue("Visu:SBImposeRange", "true");
444 aResourceMgr->setValue("Visu:SBImposeRange", "false");
445 aResourceMgr->setValue("Visu:SBMinimumValue",sbVmin);
446 aResourceMgr->setValue("Visu:SBMaximumValue",sbVmax);
448 aResourceMgr->setValue("Visu:SBScaling", "LOGARITHMIC");
450 aResourceMgr->setValue("Visu:SBScaling", "LINEAR");
454 if (myIsStoreTextProp) {
455 if (myTextDlg->isBoldTitle())
456 aResourceMgr->setValue("Visu:IsBoldTitle","true");
458 aResourceMgr->setValue("Visu:IsBoldTitle","false");
460 if (myTextDlg->isItalicTitle())
461 aResourceMgr->setValue("Visu:IsItalicTitle","true");
463 aResourceMgr->setValue("Visu:IsItalicTitle","false");
465 if (myTextDlg->isShadowTitle())
466 aResourceMgr->setValue("Visu:IsShadowTitle","true");
468 aResourceMgr->setValue("Visu:IsShadowTitle","false");
470 switch (myTextDlg->getTitleFont()) {
472 aResourceMgr->setValue("Visu:TitFontType",0);
475 aResourceMgr->setValue("Visu:TitFontType",1);
478 aResourceMgr->setValue("Visu:TitFontType",2);
481 QColor aColor = myTextDlg->getTitleColor();
482 aResourceMgr->setValue("Visu:TitleColorR", aColor.red()/255.);
483 aResourceMgr->setValue("Visu:TitleColorG", aColor.green()/255.);
484 aResourceMgr->setValue("Visu:TitleColorB", aColor.blue()/255.);
486 if (myTextDlg->isBoldLabel())
487 aResourceMgr->setValue("Visu:IsBoldLabel","true");
489 aResourceMgr->setValue("Visu:IsBoldLabel","false");
491 if (myTextDlg->isItalicLabel())
492 aResourceMgr->setValue("Visu:IsItalicLabel","true");
494 aResourceMgr->setValue("Visu:IsItalicLabel","false");
496 if (myTextDlg->isShadowLabel())
497 aResourceMgr->setValue("Visu:IsShadowLabel","true");
499 aResourceMgr->setValue("Visu:IsShadowLabel","false");
501 switch (myTextDlg->getLabelFont()) {
503 aResourceMgr->setValue("Visu:LblFontType",0);
506 aResourceMgr->setValue("Visu:LblFontType",1);
509 aResourceMgr->setValue("Visu:LblFontType",2);
512 aColor = myTextDlg->getLabelColor();
513 aResourceMgr->setValue("Visu:LabelColorR", aColor.red()/255.);
514 aResourceMgr->setValue("Visu:LabelColorG", aColor.green()/255.);
515 aResourceMgr->setValue("Visu:LabelColorB", aColor.blue()/255.);
521 * Initialise dialog box from presentation object
523 void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
525 myModeCombo->setCurrentItem(thePrs->GetScalarMode());
526 setPosAndSize( thePrs->GetPosX(),
530 thePrs->GetBarOrientation());
531 switch(thePrs->GetScaling()){
532 case VISU::LOGARITHMIC :
533 setLogarithmic(true);
536 setLogarithmic(false);
539 thePrs->GetScalarMapPL()->GetSourceRange(aRange);
540 Rmin = aRange[0]; Rmax = aRange[1];
541 setRange( thePrs->GetMin(), thePrs->GetMax(),
542 /*0.0, 0.0,*/ thePrs->IsRangeFixed() );
543 setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
544 bool isScalarMode = (thePrs->GetField()->myNbComp > 1);
545 myModeLbl->setEnabled(isScalarMode);
546 myModeCombo->setEnabled(isScalarMode);
548 myTextDlg->setTitleText(QString(thePrs->GetTitle()));
550 myTextDlg->setBoldTitle(thePrs->IsBoldTitle());
551 myTextDlg->setItalicTitle(thePrs->IsItalicTitle());
552 myTextDlg->setShadowTitle(thePrs->IsShadowTitle());
553 myTextDlg->setTitleFont(thePrs->GetTitFontType());
555 thePrs->GetTitleColor(&R, &G, &B);
556 myTextDlg->setTitleColor(QColor((int)(R*255.),
560 myTextDlg->setBoldLabel(thePrs->IsBoldLabel());
561 myTextDlg->setItalicLabel(thePrs->IsItalicLabel());
562 myTextDlg->setShadowLabel(thePrs->IsShadowLabel());
563 myTextDlg->setLabelFont(thePrs->GetLblFontType());
564 thePrs->GetLabelColor(&R, &G, &B);
565 myTextDlg->setLabelColor(QColor((int)(R*255.),
572 * Store values to presentation object
574 int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ScalarMap_i* thePrs) {
575 thePrs->SetScalarMode(myModeCombo->currentItem());
576 thePrs->SetPosition(XSpin->value(), YSpin->value());
577 thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
578 thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
580 thePrs->SetScaling(VISU::LOGARITHMIC);
582 thePrs->SetScaling(VISU::LINEAR);
584 if (RBFrange->isChecked()) {
585 thePrs->SetSourceRange();
587 thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
589 thePrs->SetNbColors(ColorSpin->value());
590 thePrs->SetLabels(LabelSpin->value());
592 if (isToSave()) storeToResources();
594 if (myIsStoreTextProp) {
595 thePrs->SetTitle(myTextDlg->getTitleText().latin1());
597 thePrs->SetBoldTitle(myTextDlg->isBoldTitle());
598 thePrs->SetItalicTitle(myTextDlg->isItalicTitle());
599 thePrs->SetShadowTitle(myTextDlg->isShadowTitle());
600 thePrs->SetTitFontType(myTextDlg->getTitleFont());
601 QColor aTitColor = myTextDlg->getTitleColor();
602 thePrs->SetTitleColor(aTitColor.red()/255.,
603 aTitColor.green()/255.,
604 aTitColor.blue()/255.);
606 thePrs->SetBoldLabel(myTextDlg->isBoldLabel());
607 thePrs->SetItalicLabel(myTextDlg->isItalicLabel());
608 thePrs->SetShadowLabel(myTextDlg->isShadowLabel());
609 thePrs->SetLblFontType(myTextDlg->getLabelFont());
610 QColor aLblColor = myTextDlg->getLabelColor();
611 thePrs->SetLabelColor(aLblColor.red()/255.,
612 aLblColor.green()/255.,
613 aLblColor.blue()/255.);
622 Called when orientation is changed
624 void VisuGUI_ScalarBarPane::changeDefaults( int )
626 if ( RBvert->isChecked() ) {
627 XSpin->setValue( myVerX );
628 YSpin->setValue( myVerY );
629 WidthSpin->setValue( myVerW );
630 HeightSpin->setValue( myVerH );
633 XSpin->setValue( myHorX );
634 YSpin->setValue( myHorY );
635 WidthSpin->setValue( myHorW );
636 HeightSpin->setValue( myHorH );
641 Called when Range mode is changed
643 void VisuGUI_ScalarBarPane::changeRange( int )
646 if ( RBFrange->isChecked() )
648 if ( RBIrange->isChecked() )
650 if ( myRangeMode == mode )
652 //MinSpin->setMaxValue( Fmin );
653 //MaxSpin->setMinValue( Fmax );
654 if ( RBFrange->isChecked() ) {
655 //MinLabel->setEnabled( false );
656 MinEdit->setEnabled( false );
657 //MaxLabel->setEnabled( false );
658 MaxEdit->setEnabled( false );
660 Imin = MinEdit->text().toDouble();
661 Imax = MaxEdit->text().toDouble();
663 MinEdit->setText( QString::number( Rmin ) );
664 MaxEdit->setText( QString::number( Rmax ) );
667 //MinLabel->setEnabled( true );
668 MinEdit->setEnabled( true );
669 //MaxLabel->setEnabled( true );
670 MaxEdit->setEnabled( true );
671 MinEdit->setText( QString::number( Imin ) );
672 MaxEdit->setText( QString::number( Imax ) );
678 Called when X,Y position is changed
680 void VisuGUI_ScalarBarPane::XYChanged( double )
682 QtxDblSpinBox* snd = (QtxDblSpinBox*)sender();
683 if ( snd == XSpin ) {
684 WidthSpin->setMaxValue( 1.0 - XSpin->value() );
686 if ( snd == YSpin ) {
687 HeightSpin->setMaxValue( 1.0 - YSpin->value() );
692 Sets default values and range mode
694 void VisuGUI_ScalarBarPane::setRange( double imin, double imax/*, double fmin, double fmax*/, bool sbRange )
696 Imin = imin; Imax = imax;// Fmin = fmin; Fmax = fmax;
697 if ( RBIrange->isChecked() ) {
698 MinEdit->setText( QString::number( Imin ) );
699 MaxEdit->setText( QString::number( Imax ) );
702 MinEdit->setText( QString::number( Rmin ) );
703 MaxEdit->setText( QString::number( Rmax ) );
707 RBIrange->setChecked( true );
709 RBFrange->setChecked( true );
714 Sets size and position
716 void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
723 RBvert->setChecked( true );
730 RBhori->setChecked( true );
736 Sets colors and labels number
738 void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
740 ColorSpin->setValue( colors );
741 LabelSpin->setValue( labels );
747 int VisuGUI_ScalarBarPane::getOrientation()
749 if (RBvert->isChecked() )
758 Called when <OK> button is clicked, validates data and closes dialog
760 bool VisuGUI_ScalarBarPane::check()
762 double minVal = MinEdit->text().toDouble();
763 double maxVal = MaxEdit->text().toDouble();
764 if ( RBIrange->isChecked() ) {
765 if (minVal >= maxVal) {
766 SUIT_MessageBox::warn1( this,tr("VISU_WARNING"),
767 tr("MSG_MINMAX_VALUES"),
772 // check if logarithmic mode is on and check imposed range to not contain negative values
773 if ( CBLog->isChecked() ) {
774 if ( RBIrange->isChecked() ) {
775 if ( (minVal > 0) && (maxVal > 0) ) {
779 SUIT_MessageBox::warn1( this,
781 tr("WRN_LOGARITHMIC_RANGE"),
787 if ( Rmin > 0 && Rmax > 0 ) {
791 SUIT_MessageBox::warn1( this,
793 tr("WRN_LOGARITHMIC_FIELD_RANGE"),
795 RBIrange->setChecked(1);
797 //MinEdit->setText( QString::number( Rmin ) );
798 //MaxEdit->setText( QString::number( Rmax ) );
807 void VisuGUI_ScalarBarPane::onTextPref() {
808 myIsStoreTextProp = myTextDlg->exec();
815 //#######################################################################################
821 VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg(QWidget* parent, bool SetPref)
822 : QDialog( parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
824 setName( "VisuGUI_ScalarBarDlg" );
825 setCaption( SetPref ? tr( "Scalar Bar Preferences" ) : tr( "Scalar Bar Properties" ) );
826 setSizeGripEnabled( TRUE );
828 QVBoxLayout* TopLayout = new QVBoxLayout(this);
829 TopLayout->setSpacing(6);
830 TopLayout->setMargin(11);
832 myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref);
833 TopLayout->addWidget(myScalarPane);
835 // Common buttons ===========================================================
836 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
837 GroupButtons->setColumnLayout(0, Qt::Vertical );
838 GroupButtons->layout()->setSpacing( 0 );
839 GroupButtons->layout()->setMargin( 0 );
840 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
841 GroupButtonsLayout->setAlignment( Qt::AlignTop );
842 GroupButtonsLayout->setSpacing( 6 );
843 GroupButtonsLayout->setMargin( 11 );
845 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
846 buttonOk->setAutoDefault( TRUE );
847 buttonOk->setDefault( TRUE );
848 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
849 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
851 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
852 buttonCancel->setAutoDefault( TRUE );
853 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
855 TopLayout->addWidget( GroupButtons );
857 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
858 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
865 Called when <OK> button is clicked, validates data and closes dialog
867 void VisuGUI_ScalarBarDlg::accept()
869 if (myScalarPane->check()) QDialog::accept();
876 //#######################################################################################
882 VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg(QWidget* parent) :
883 QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
885 setName( "VisuGUI_TextPrefDlg" );
886 setCaption( tr("TIT_TEXT_PREF") );
887 setSizeGripEnabled( TRUE );
889 QVBoxLayout* TopLayout = new QVBoxLayout(this);
890 TopLayout->setSpacing(6);
891 TopLayout->setMargin(11);
893 QGroupBox* aTitleGrp = new QGroupBox( this );
894 aTitleGrp->setTitle(tr("LBL_TITLE"));
895 aTitleGrp->setColumnLayout(0, Qt::Vertical );
896 QGridLayout* aTitleLayout = new QGridLayout( aTitleGrp->layout() );
897 aTitleLayout->setSpacing( 6 );
898 aTitleLayout->setMargin( 3 );
900 myTitleEdt = new QLineEdit(aTitleGrp);
901 aTitleLayout->addMultiCellWidget(myTitleEdt, 0, 0, 0, 4);
904 aFontsLst.append("Arial");
905 aFontsLst.append("Courier");
906 aFontsLst.append("Times");
908 myTitColor = new QToolButton(aTitleGrp);
909 connect( myTitColor, SIGNAL(clicked()), this, SLOT(setTitleColor()) );
910 aTitleLayout->addWidget(myTitColor, 1, 0);
912 myTitFontCombo = new QComboBox(aTitleGrp);
913 myTitFontCombo->insertStrList(aFontsLst);
914 aTitleLayout->addWidget(myTitFontCombo, 1, 1);
916 myTitBoldChk = new QCheckBox(tr("LBL_BOLD"), aTitleGrp);
917 aTitleLayout->addWidget(myTitBoldChk, 1, 2);
919 myTitItalicChk = new QCheckBox(tr("LBL_ITALIC"), aTitleGrp);
920 aTitleLayout->addWidget(myTitItalicChk, 1, 3);
922 myTitShadowChk = new QCheckBox(tr("LBL_SHADOW"), aTitleGrp);
923 aTitleLayout->addWidget(myTitShadowChk, 1, 4);
925 TopLayout->addWidget( aTitleGrp );
927 QGroupBox* aLabelsGrp = new QGroupBox( this );
928 aLabelsGrp->setTitle(tr("LBL_LABELS"));
929 aLabelsGrp->setColumnLayout(0, Qt::Vertical );
930 QGridLayout* aLabelLayout = new QGridLayout( aLabelsGrp->layout() );
931 aLabelLayout->setSpacing( 6 );
932 aLabelLayout->setMargin( 3 );
934 myLblColor = new QToolButton(aLabelsGrp);
935 connect( myLblColor, SIGNAL(clicked()), this, SLOT(setLabelColor()) );
936 aLabelLayout->addWidget(myLblColor, 0, 0);
938 myLblFontCombo = new QComboBox(aLabelsGrp);
939 myLblFontCombo->insertStrList(aFontsLst);
940 aLabelLayout->addWidget(myLblFontCombo, 0, 1);
942 myLblBoldChk = new QCheckBox(tr("LBL_BOLD"), aLabelsGrp);
943 aLabelLayout->addWidget(myLblBoldChk, 0, 2);
945 myLblItalicChk = new QCheckBox(tr("LBL_ITALIC"), aLabelsGrp);
946 aLabelLayout->addWidget(myLblItalicChk, 0, 3);
948 myLblShadowChk = new QCheckBox(tr("LBL_SHADOW"), aLabelsGrp);
949 aLabelLayout->addWidget(myLblShadowChk, 0, 4);
951 TopLayout->addWidget( aLabelsGrp );
953 // Common buttons ===========================================================
954 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
955 GroupButtons->setColumnLayout(0, Qt::Vertical );
956 GroupButtons->layout()->setSpacing( 0 );
957 GroupButtons->layout()->setMargin( 0 );
958 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
959 GroupButtonsLayout->setAlignment( Qt::AlignTop );
960 GroupButtonsLayout->setSpacing( 6 );
961 GroupButtonsLayout->setMargin( 11 );
963 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
964 buttonOk->setAutoDefault( TRUE );
965 buttonOk->setDefault( TRUE );
966 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
967 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
969 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
970 buttonCancel->setAutoDefault( TRUE );
971 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
973 TopLayout->addWidget( GroupButtons );
975 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
976 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
980 void VisuGUI_TextPrefDlg::setTitleColor() {
981 QColor aColor = QColorDialog::getColor( getTitleColor(), this );
982 if (aColor.isValid()) setTitleColor(aColor);
985 void VisuGUI_TextPrefDlg::setLabelColor() {
986 QColor aColor = QColorDialog::getColor( getLabelColor(), this );
987 if (aColor.isValid()) setLabelColor(aColor);
992 #define GETFONT(FuncName, Control) \
993 int VisuGUI_TextPrefDlg::FuncName() \
995 switch (Control->currentItem()) { \
996 case 0: return VTK_ARIAL; \
997 case 1: return VTK_COURIER; \
998 case 2: return VTK_TIMES; \
1003 #define SETFONT(FuncName, Control) \
1004 void VisuGUI_TextPrefDlg::FuncName(int theFont) \
1006 switch (theFont) { \
1007 case VTK_ARIAL: Control->setCurrentItem(0); break; \
1008 case VTK_COURIER: Control->setCurrentItem(1); break; \
1009 case VTK_TIMES: Control->setCurrentItem(2); break; \
1013 GETFONT(getTitleFont, myTitFontCombo);
1014 SETFONT(setTitleFont, myTitFontCombo);
1016 GETFONT(getLabelFont, myLblFontCombo);
1017 SETFONT(setLabelFont, myLblFontCombo);