1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : VisuGUI_GaussPointsDlg.cxx
25 // Author : Oleg UVAROV
28 #include "VisuGUI_GaussPointsDlg.h"
30 #include "VISUConfig.hh"
32 #include "VisuGUI_Tools.h"
33 #include "VisuGUI_InputPane.h"
35 #include "VISU_ColoredPrs3dFactory.hh"
36 #include "VISU_GaussPoints_i.hh"
37 #include "VISU_GaussPointsPL.hxx"
38 #include "VISU_OpenGLPointSpriteMapper.hxx"
39 #include "VISU_Convertor.hxx"
41 #include "VVTK_PrimitiveBox.h"
42 #include "VVTK_SizeBox.h"
44 #include "LightApp_Application.h"
45 #include "SalomeApp_Module.h"
46 #include "SUIT_Desktop.h"
47 #include "SUIT_ResourceMgr.h"
48 #include "SUIT_Session.h"
49 #include "SUIT_MessageBox.h"
50 #include "SVTK_FontWidget.h"
52 #include "QtxDblSpinBox.h"
55 #include <qtabwidget.h>
56 #include <qbuttongroup.h>
57 #include <qradiobutton.h>
58 #include <qfiledialog.h>
59 #include <qvalidator.h>
60 #include <qcolordialog.h>
61 #include <qgroupbox.h>
62 #include <qcheckbox.h>
64 #include <qpushbutton.h>
65 #include <qlineedit.h>
67 #include <qcombobox.h>
68 #include <qtoolbutton.h>
69 #include <qtabwidget.h>
71 #include <vtkPolyData.h>
72 #include <vtkDataSet.h>
73 #include <vtkSphereSource.h>
77 VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent):
80 myVerX = 0.01; myVerY = 0.10; myVerW = 0.10; myVerH = 0.80;
81 myHorX = 0.20; myHorY = 0.01; myHorW = 0.60; myHorH = 0.12;
82 myVerTW = myVerTH = myVerLW = myVerLH = myVerBW = myVerBH = 0;
83 myHorTW = myHorTH = myHorLW = myHorLH = myHorBW = myHorBH = 0;
84 Imin = 0.0; Imax = 0.0;
90 // Active bar ========================================================
91 QGroupBox* ActiveBarGroup = new QGroupBox (tr("ACTIVE_BAR_GRP"), this, "ActiveBarGroup");
92 ActiveBarGroup->setColumnLayout(0, Qt::Vertical );
93 ActiveBarGroup->layout()->setSpacing( 0 );
94 ActiveBarGroup->layout()->setMargin( 0 );
95 QGridLayout* ActiveBarGroupLayout = new QGridLayout( ActiveBarGroup->layout() );
96 ActiveBarGroupLayout->setAlignment( Qt::AlignTop );
97 ActiveBarGroupLayout->setSpacing( 6 );
98 ActiveBarGroupLayout->setMargin( 11 );
100 QButtonGroup* BarTypeGroup = new QButtonGroup( 2, Qt::Vertical, ActiveBarGroup, "BarTypeGroup" );
101 BarTypeGroup->setRadioButtonExclusive( true );
102 BarTypeGroup->setFrameStyle( QFrame::NoFrame );
103 BarTypeGroup->layout()->setMargin( 0 );
105 myRBLocal = new QRadioButton( tr( "LOCAL" ), BarTypeGroup );
106 myRBGlobal = new QRadioButton( tr( "GLOBAL" ), BarTypeGroup );
108 myCBDisplayed = new QCheckBox( tr( "DISPLAYED" ), ActiveBarGroup );
110 ActiveBarGroupLayout->addMultiCellWidget( BarTypeGroup, 0, 1, 0, 0 );
111 ActiveBarGroupLayout->addWidget( myCBDisplayed, 1, 1 );
113 // Range ============================================================
114 RangeGroup = new QButtonGroup (tr("SCALAR_RANGE_GRP"), this, "RangeGroup");
115 RangeGroup->setColumnLayout(0, Qt::Vertical );
116 RangeGroup->layout()->setSpacing( 0 );
117 RangeGroup->layout()->setMargin( 0 );
118 QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() );
119 RangeGroupLayout->setAlignment( Qt::AlignTop );
120 RangeGroupLayout->setSpacing( 6 );
121 RangeGroupLayout->setMargin( 11 );
123 myModeLbl = new QLabel("Scalar Mode", RangeGroup);
125 myModeCombo = new QComboBox(RangeGroup);
127 RangeGroupLayout->addWidget( myModeLbl, 0, 0 );
128 RangeGroupLayout->addWidget( myModeCombo, 0, 1 );
130 RBFieldRange = new QRadioButton (tr("FIELD_RANGE_BTN"), RangeGroup, "RBFieldRange");
131 RBImposedRange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), RangeGroup, "RBImposedRange");
132 RBFieldRange->setChecked( true );
134 MinEdit = new QLineEdit( RangeGroup, "MinEdit" );
135 MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
136 MinEdit->setMinimumWidth( 70 );
137 MinEdit->setValidator( new QDoubleValidator(this) );
138 MinEdit->setText( "0.0" );
139 QLabel* MinLabel = new QLabel (tr("LBL_MIN"), RangeGroup, "MinLabel");
140 MinLabel->setBuddy(MinEdit);
142 MaxEdit = new QLineEdit( RangeGroup, "MaxEdit" );
143 MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
144 MaxEdit->setMinimumWidth( 70 );
145 MaxEdit->setValidator( new QDoubleValidator(this) );
146 MaxEdit->setText( "0.0" );
147 QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), RangeGroup, "MaxLabel");
148 MaxLabel->setBuddy(MaxEdit);
150 RangeGroupLayout->addWidget( myModeLbl, 0, 0 );
151 RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3);
152 RangeGroupLayout->addMultiCellWidget( RBFieldRange, 1, 1, 0, 1);
153 RangeGroupLayout->addMultiCellWidget( RBImposedRange, 1, 1, 2, 3);
154 RangeGroupLayout->addWidget( MinLabel, 2, 0 );
155 RangeGroupLayout->addWidget( MinEdit, 2, 1 );
156 RangeGroupLayout->addWidget( MaxLabel, 2, 2 );
157 RangeGroupLayout->addWidget( MaxEdit, 2, 3 );
159 // Colors and Labels ========================================================
160 QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this, "ColLabGroup");
161 ColLabGroup->setColumnLayout(0, Qt::Vertical );
162 ColLabGroup->layout()->setSpacing( 0 );
163 ColLabGroup->layout()->setMargin( 0 );
164 QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() );
165 ColLabGroupLayout->setAlignment( Qt::AlignTop );
166 ColLabGroupLayout->setSpacing( 6 );
167 ColLabGroupLayout->setMargin( 11 );
169 QButtonGroup* TypeGroup = new QButtonGroup( 2, Qt::Vertical, ColLabGroup, "TypeGroup" );
170 TypeGroup->setRadioButtonExclusive( true );
171 TypeGroup->setFrameStyle( QFrame::NoFrame );
172 TypeGroup->layout()->setMargin( 0 );
174 BicolorButton = new QRadioButton( tr( "BICOLOR" ), TypeGroup );
175 RainbowButton = new QRadioButton( tr( "RAINBOW" ), TypeGroup );
177 ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup, "ColorLabel");
178 ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup );
179 ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
180 ColorSpin->setMinimumWidth( 70 );
181 ColorSpin->setValue( 64 );
183 LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup, "LabelLabel");
184 LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup );
185 LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
186 LabelSpin->setMinimumWidth( 70 );
187 LabelSpin->setValue( 5 );
189 ColLabGroupLayout->addMultiCellWidget( TypeGroup, 0, 1, 0, 0);
190 ColLabGroupLayout->addWidget( ColorLabel, 1, 1);
191 ColLabGroupLayout->addWidget( ColorSpin, 1, 2);
192 ColLabGroupLayout->addWidget( LabelLabel, 1, 3);
193 ColLabGroupLayout->addWidget( LabelSpin, 1, 4);
195 //TopLayout->addWidget( ColLabGroup );
197 // Orientation ==========================================================
198 QButtonGroup* OrientGroup = new QButtonGroup (tr("ORIENTATION_GRP"), this, "OrientGroup");
199 OrientGroup->setColumnLayout(0, Qt::Vertical );
200 OrientGroup->layout()->setSpacing( 0 );
201 OrientGroup->layout()->setMargin( 0 );
202 QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() );
203 OrientGroupLayout->setAlignment( Qt::AlignTop );
204 OrientGroupLayout->setSpacing( 6 );
205 OrientGroupLayout->setMargin( 11 );
207 RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGroup, "RBvert");
208 RBvert->setChecked( true );
209 RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGroup, "RBhori");
210 OrientGroupLayout->addWidget( RBvert, 0, 0 );
211 OrientGroupLayout->addWidget( RBhori, 0, 1 );
213 // TopLayout->addWidget( OrientGroup );
215 // Origin ===============================================================
216 QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this, "OriginGroup");
217 OriginGroup->setColumnLayout(0, Qt::Vertical );
218 OriginGroup->layout()->setSpacing( 0 );
219 OriginGroup->layout()->setMargin( 0 );
220 QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() );
221 OriginGroupLayout->setAlignment( Qt::AlignTop );
222 OriginGroupLayout->setSpacing( 6 );
223 OriginGroupLayout->setMargin( 11 );
225 QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup, "XLabel");
226 XSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
227 XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
228 XSpin->setMinimumWidth( 70 );
229 XSpin->setValue( 0.01 );
231 QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup, "YLabel");
232 YSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
233 YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
234 YSpin->setMinimumWidth( 70 );
235 YSpin->setValue( 0.01 );
237 OriginGroupLayout->addWidget( XLabel, 0, 0);
238 OriginGroupLayout->addWidget( XSpin, 0, 1);
239 OriginGroupLayout->addWidget( YLabel, 0, 2);
240 OriginGroupLayout->addWidget( YSpin, 0, 3);
242 //TopLayout->addWidget( OriginGroup );
244 // Dimensions =========================================================
245 QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this, "DimGroup");
246 DimGroup->setColumnLayout(0, Qt::Vertical );
247 DimGroup->layout()->setSpacing( 0 );
248 DimGroup->layout()->setMargin( 0 );
249 QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() );
250 DimGroupLayout->setAlignment( Qt::AlignTop );
251 DimGroupLayout->setSpacing( 6 );
252 DimGroupLayout->setMargin( 11 );
254 QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup, "WidthLabel");
255 WidthSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
256 WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
257 WidthSpin->setMinimumWidth( 70 );
258 WidthSpin->setValue( 0.1 );
260 QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup, "HeightLabel");
261 HeightSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
262 HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
263 HeightSpin->setMinimumWidth( 70 );
264 HeightSpin->setValue( 0.8 );
266 QLabel* SpacingLabel = new QLabel (tr("LBL_SPACING"), DimGroup, "SpacingLabel");
267 SpacingSpin = new QtxDblSpinBox( 0.0, 1.0, 0.01, DimGroup );
268 SpacingSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
269 SpacingSpin->setMinimumWidth( 70 );
270 SpacingSpin->setValue( 0.01 );
272 DimGroupLayout->addWidget( WidthLabel, 0, 0);
273 DimGroupLayout->addWidget( WidthSpin, 0, 1);
274 DimGroupLayout->addWidget( HeightLabel, 0, 2);
275 DimGroupLayout->addWidget( HeightSpin, 0, 3);
276 DimGroupLayout->addWidget( SpacingLabel, 0, 4);
277 DimGroupLayout->addWidget( SpacingSpin, 0, 5);
279 //TopLayout->addWidget( DimGroup );
281 QHBox* aSaveBox = new QHBox(this);
282 myTextBtn = new QPushButton("Text properties...", aSaveBox);
283 myBarBtn = new QPushButton("Bar properties...", aSaveBox);
284 myTextDlg = new VisuGUI_TextPrefDlg(this);
285 myTextDlg->setTitleVisible(true);
286 myBarDlg = new VisuGUI_BarPrefDlg(this);
288 // signals and slots connections ===========================================
289 connect( RBFieldRange, SIGNAL( clicked() ), this, SLOT( fieldRangeClicked() ) );
290 connect( RBImposedRange, SIGNAL( clicked() ), this, SLOT( imposedRangeClicked() ) );
292 connect( myModeCombo, SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( int ) ) );
294 connect( myRBLocal, SIGNAL( clicked() ), this, SLOT( onLocalScalarBar() ) );
295 connect( myRBGlobal, SIGNAL( clicked() ), this, SLOT( onGlobalScalarBar() ) );
297 connect( RainbowButton, SIGNAL( toggled( bool ) ), ColorLabel, SLOT( setEnabled( bool ) ) );
298 connect( RainbowButton, SIGNAL( toggled( bool ) ), ColorSpin, SLOT( setEnabled( bool ) ) );
299 connect( RainbowButton, SIGNAL( toggled( bool ) ), LabelLabel, SLOT( setEnabled( bool ) ) );
300 connect( RainbowButton, SIGNAL( toggled( bool ) ), LabelSpin, SLOT( setEnabled( bool ) ) );
301 connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) );
302 connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
303 connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
304 connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
305 connect( myBarBtn, SIGNAL( clicked() ), this, SLOT( onBarPref() ) );
308 myIsStoreTextProp = false;
311 bool VisuGUI_GaussScalarBarPane::UseFieldRange(bool theInit)
314 return !myPrsCopy->IsRangeFixed();
316 return RBFieldRange->isChecked() || !myPrsCopy->GetIsActiveLocalScalarBar();
320 void VisuGUI_GaussScalarBarPane::onGlobalScalarBar()
322 myPrsCopy->SetIsActiveLocalScalarBar(false);
323 myPrsCopy->SetSourceRange();
325 myCBDisplayed->setEnabled( false );
327 RBImposedRange->setEnabled( false );
328 RBFieldRange->setEnabled( false );
330 MinEdit->setEnabled( false );
331 MaxEdit->setEnabled( false );
333 MinEdit->setText( QString::number( myPrsCopy->GetMin() ) );
334 MaxEdit->setText( QString::number( myPrsCopy->GetMax() ) );
338 void VisuGUI_GaussScalarBarPane::onLocalScalarBar()
340 myPrsCopy->SetIsActiveLocalScalarBar(true);
341 if ( RBFieldRange->isChecked() )
342 myPrsCopy->SetSourceRange();
344 myPrsCopy->SetRange(myPrsCopy->GetMin(), myPrsCopy->GetMax());
346 myCBDisplayed->setEnabled( true );
348 RBImposedRange->setEnabled( true );
349 RBFieldRange->setEnabled( true );
351 MinEdit->setEnabled( RBImposedRange->isChecked() );
352 MaxEdit->setEnabled( RBImposedRange->isChecked() );
354 MinEdit->setText( QString::number( myPrsCopy->GetMin() ) );
355 MaxEdit->setText( QString::number( myPrsCopy->GetMax() ) );
360 Called when Range mode is changed to FieldRange
362 void VisuGUI_GaussScalarBarPane::fieldRangeClicked()
364 myPrsCopy->SetSourceRange();
366 RBFieldRange->setChecked( true );
367 RBImposedRange->setChecked( false );
369 MinEdit->setEnabled( false );
370 MaxEdit->setEnabled( false );
372 MinEdit->setText( QString::number( myPrsCopy->GetMin() ) );
373 MaxEdit->setText( QString::number( myPrsCopy->GetMax() ) );
378 Called when Range mode is changed to FieldRange
380 void VisuGUI_GaussScalarBarPane::imposedRangeClicked()
382 myPrsCopy->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
384 RBImposedRange->setChecked( true );
385 RBFieldRange->setChecked( false );
387 MinEdit->setEnabled( true );
388 MaxEdit->setEnabled( true );
393 Called when scalar mode is changed
395 void VisuGUI_GaussScalarBarPane::changeScalarMode( int theMode )
397 myPrsCopy->SetScalarMode( theMode );
398 if ( UseFieldRange() ) {
399 MinEdit->setText( QString::number( myPrsCopy->GetSourceMin() ) );
400 MaxEdit->setText( QString::number( myPrsCopy->GetSourceMax() ) );
405 * Initialise dialog box from presentation object
407 void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs,
412 myModeCombo->setCurrentItem(thePrs->GetScalarMode());
414 bool activeLocal = thePrs->GetIsActiveLocalScalarBar();
416 RBImposedRange->setChecked( !UseFieldRange(theInit) );
417 RBFieldRange->setChecked( UseFieldRange(theInit) );
418 MinEdit->setEnabled( !UseFieldRange(theInit) );
419 MaxEdit->setEnabled( !UseFieldRange(theInit) );
421 RBImposedRange->setEnabled( false );
422 RBFieldRange->setEnabled( false );
423 MinEdit->setEnabled( false );
424 MaxEdit->setEnabled( false );
427 MinEdit->setText( QString::number( thePrs->GetMin() ) );
428 MaxEdit->setText( QString::number( thePrs->GetMax() ) );
430 setPosAndSize( thePrs->GetPosX(),
434 thePrs->GetBarOrientation());
436 if(RBvert->isChecked()) {
437 myVerTW = thePrs->GetTitleWidth();
438 myVerTH = thePrs->GetTitleHeight();
439 myVerLW = thePrs->GetLabelWidth();
440 myVerLH = thePrs->GetLabelHeight();
441 myVerBW = thePrs->GetBarWidth();
442 myVerBH = thePrs->GetBarHeight();
444 myHorTW = thePrs->GetTitleWidth();
445 myHorTH = thePrs->GetTitleHeight();
446 myHorLW = thePrs->GetLabelWidth();
447 myHorLH = thePrs->GetLabelHeight();
448 myHorBW = thePrs->GetBarWidth();
449 myHorBH = thePrs->GetBarHeight();
452 myBarDlg->setLabelsFormat(thePrs->GetLabelsFormat());
453 myBarDlg->setUnitsVisible(thePrs->IsUnitsVisible());
455 SpacingSpin->setValue(thePrs->GetSpacing());
457 myRBLocal->setChecked( activeLocal );
459 myRBGlobal->setChecked( !activeLocal );
460 myRBGlobal->setEnabled( thePrs->IsGlobalRangeDefined() );
461 if( !thePrs->IsGlobalRangeDefined() )
462 myRBLocal->setChecked( true );
464 myCBDisplayed->setEnabled( activeLocal );
465 myCBDisplayed->setChecked( thePrs->GetIsDispGlobalScalarBar() );
467 bool bicolor = thePrs->GetSpecificPL()->GetBicolor();
468 BicolorButton->setChecked( bicolor );
469 RainbowButton->setChecked( !bicolor );
470 ColorLabel->setEnabled( !bicolor );
471 ColorSpin->setEnabled( !bicolor );
472 LabelLabel->setEnabled( !bicolor );
473 LabelSpin->setEnabled( !bicolor );
475 setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
477 // Update myModeCombo
478 int aNbComp = thePrs->GetField()->myNbComp;
479 bool isScalarMode = (aNbComp > 1);
480 myModeCombo->clear();
481 myModeCombo->insertItem("<Modulus>");
482 VISU::PField aField = thePrs->GetField();
483 const VISU::TNames& aCompNames = aField->myCompNames;
484 const VISU::TNames& aUnitNames = aField->myUnitNames;
485 for(int i = 0; i < aNbComp; i++){
486 QString aComponent = QString(aCompNames[i].c_str()).simplifyWhiteSpace();
487 if(aComponent.isNull() || aComponent == "")
488 aComponent = "Component " + QString::number(i+1);
490 aComponent = "[" + QString::number(i+1) + "] " + aComponent;
492 QString anUnit = QString(aUnitNames[i].c_str()).simplifyWhiteSpace();
493 if(anUnit.isNull() || anUnit == "")
496 aComponent = aComponent + ", " + anUnit;
498 myModeCombo->insertItem(aComponent);
501 myModeCombo->setCurrentItem(thePrs->GetScalarMode());
503 myModeCombo->setCurrentItem(1);
506 myModeLbl->setEnabled(isScalarMode);
507 myModeCombo->setEnabled(isScalarMode);
510 myTextDlg->setTitleText(QString(thePrs->GetTitle()));
512 vtkFloatingPointType R, G, B;
513 thePrs->GetTitleColor(&R, &G, &B);
515 myBarDlg->setLabelsFormat(thePrs->GetLabelsFormat());
516 myBarDlg->setUnitsVisible(thePrs->IsUnitsVisible());
518 myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
519 thePrs->GetTitFontType(),
520 thePrs->IsBoldTitle(),
521 thePrs->IsItalicTitle(),
522 thePrs->IsShadowTitle());
525 thePrs->GetLabelColor(&R, &G, &B);
527 myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
528 thePrs->GetLblFontType(),
529 thePrs->IsBoldLabel(),
530 thePrs->IsItalicLabel(),
531 thePrs->IsShadowLabel());
535 * Store values to presentation object
537 int VisuGUI_GaussScalarBarPane::storeToPrsObject(VISU::GaussPoints_i* thePrs) {
538 thePrs->SetScalarMode(myModeCombo->currentItem());
540 if (RBFieldRange->isChecked()) {
541 thePrs->SetSourceRange();
543 thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
546 thePrs->SetSpacing(SpacingSpin->value());
547 thePrs->SetIsActiveLocalScalarBar(myRBLocal->isChecked());
548 thePrs->SetIsDispGlobalScalarBar(myCBDisplayed->isChecked());
549 thePrs->SetBiColor(BicolorButton->isChecked());
551 thePrs->SetPosition(XSpin->value(), YSpin->value());
552 thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
553 thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3d::VERTICAL : VISU::ColoredPrs3d::HORIZONTAL);
554 thePrs->SetNbColors(ColorSpin->value());
555 thePrs->SetLabels(LabelSpin->value());
557 if(RBvert->isChecked()) {
558 thePrs->SetRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH);
560 thePrs->SetRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH);
563 thePrs->SetLabelsFormat(myBarDlg->getLabelsFormat());
564 thePrs->SetUnitsVisible(myBarDlg->isUnitsVisible());
566 if (myIsStoreTextProp) {
568 thePrs->SetTitle(myTextDlg->getTitleText().latin1());
570 QColor aTitColor (255, 255, 255);
571 int aTitleFontFamily = VTK_ARIAL;
572 bool isTitleBold = false;
573 bool isTitleItalic = false;
574 bool isTitleShadow = false;
576 myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
577 isTitleBold, isTitleItalic, isTitleShadow);
579 thePrs->SetBoldTitle(isTitleBold);
580 thePrs->SetItalicTitle(isTitleItalic);
581 thePrs->SetShadowTitle(isTitleShadow);
582 thePrs->SetTitFontType(aTitleFontFamily);
583 thePrs->SetTitleColor(aTitColor.red()/255.,
584 aTitColor.green()/255.,
585 aTitColor.blue()/255.);
588 QColor aLblColor (255, 255, 255);
589 int aLabelFontFamily = VTK_ARIAL;
590 bool isLabelBold = false;
591 bool isLabelItalic = false;
592 bool isLabelShadow = false;
594 myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
595 isLabelBold, isLabelItalic, isLabelShadow);
597 thePrs->SetBoldLabel(isLabelBold);
598 thePrs->SetItalicLabel(isLabelItalic);
599 thePrs->SetShadowLabel(isLabelShadow);
600 thePrs->SetLblFontType(aLabelFontFamily);
601 thePrs->SetLabelColor(aLblColor.red()/255.,
602 aLblColor.green()/255.,
603 aLblColor.blue()/255.);
610 Called when orientation is changed
612 void VisuGUI_GaussScalarBarPane::changeDefaults( int )
614 if ( RBvert->isChecked() ) {
615 XSpin->setValue( myVerX );
616 YSpin->setValue( myVerY );
617 WidthSpin->setValue( myVerW );
618 HeightSpin->setValue( myVerH );
621 XSpin->setValue( myHorX );
622 YSpin->setValue( myHorY );
623 WidthSpin->setValue( myHorW );
624 HeightSpin->setValue( myHorH );
629 Called when X,Y position is changed
631 void VisuGUI_GaussScalarBarPane::XYChanged( double )
633 QtxDblSpinBox* snd = (QtxDblSpinBox*)sender();
634 if ( snd == XSpin ) {
635 WidthSpin->setMaxValue( 1.0 - XSpin->value() );
637 if ( snd == YSpin ) {
638 HeightSpin->setMaxValue( 1.0 - YSpin->value() );
643 Sets size and position
645 void VisuGUI_GaussScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
652 RBvert->setChecked( true );
659 RBhori->setChecked( true );
665 Sets colors and labels number
667 void VisuGUI_GaussScalarBarPane::setScalarBarData( int colors, int labels )
669 ColorSpin->setValue( colors );
670 LabelSpin->setValue( labels );
676 int VisuGUI_GaussScalarBarPane::getOrientation()
678 if (RBvert->isChecked() )
685 Sets and gets parameters
687 double VisuGUI_GaussScalarBarPane::getX() {
688 return XSpin->value();
691 double VisuGUI_GaussScalarBarPane::getY() {
692 return YSpin->value();
695 double VisuGUI_GaussScalarBarPane::getWidth() {
696 return WidthSpin->value();
699 double VisuGUI_GaussScalarBarPane::getHeight() {
700 return HeightSpin->value();
703 int VisuGUI_GaussScalarBarPane::getNbColors() {
704 return ColorSpin->value();
707 int VisuGUI_GaussScalarBarPane::getNbLabels() {
708 return LabelSpin->value();
711 void VisuGUI_GaussScalarBarPane::onTextPref()
713 myIsStoreTextProp = myTextDlg->exec();
716 void VisuGUI_GaussScalarBarPane::onBarPref()
718 if(RBvert->isChecked())
719 myBarDlg->setRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH);
721 myBarDlg->setRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH);
722 if(myBarDlg->exec()) {
723 if(RBvert->isChecked())
724 myBarDlg->getRatios(myVerTW, myVerTH, myVerLW, myVerLH, myVerBW, myVerBH);
726 myBarDlg->getRatios(myHorTW, myHorTH, myHorLW, myHorLH, myHorBW, myHorBH);
733 VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule):
734 VisuGUI_Prs3dDlg(theModule)
736 setName("VisuGUI_GaussPointsDlg");
737 setCaption(tr("DLG_PROP_TITLE"));
738 setSizeGripEnabled(TRUE);
740 QVBoxLayout* TopLayout = new QVBoxLayout(this);
741 TopLayout->setSpacing(6);
742 TopLayout->setMargin(11);
746 QButtonGroup* PrsGroup = new QButtonGroup( 3, Qt::Horizontal, tr( "PRS_TITLE" ), this, "PrimitiveTypeGroup" );
747 PrsGroup->setRadioButtonExclusive( true );
748 PrsGroup->layout()->setMargin( 11 );
749 PrsGroup->layout()->setSpacing(6);
751 myResultsButton = new QRadioButton( tr( "RESULTS" ), PrsGroup );
752 myGeometryButton = new QRadioButton( tr( "GEOMETRY" ), PrsGroup );
753 myDefShapeButton = new QRadioButton( tr( "DEFORMED_SHAPE" ), PrsGroup );
755 myTabBox = new QTabWidget (this);
758 QVBox* aBox = new QVBox (this);
763 myPrimitiveBox = new VVTK_PrimitiveBox( aBox );
766 mySizeBox = new VVTK_SizeBox( aBox );
769 myDefShapeBox = new QGroupBox( tr( "DEFORMED_SHAPE_TITLE" ), aBox );
770 myDefShapeBox->setColumnLayout(0, Qt::Vertical );
771 myDefShapeBox->layout()->setSpacing( 0 );
772 myDefShapeBox->layout()->setMargin( 0 );
774 QGridLayout* aDefShapeLayout = new QGridLayout( myDefShapeBox->layout() );
775 aDefShapeLayout->setAlignment(Qt::AlignTop);
776 aDefShapeLayout->setSpacing(6);
777 aDefShapeLayout->setMargin(11);
779 QLabel* aScaleLabel = new QLabel( tr( "SCALE_FACTOR" ), myDefShapeBox );
780 myScaleSpinBox = new QtxDblSpinBox( 0.0, 10.0, 0.1, myDefShapeBox );
782 aDefShapeLayout->addWidget( aScaleLabel, 0, 0 );
783 aDefShapeLayout->addWidget( myScaleSpinBox, 0, 1 );
786 myScalarPane = new VisuGUI_GaussScalarBarPane(this);
787 myScalarPane->setMargin(5);
790 myInputPane = new VisuGUI_InputPane(VISU::TGAUSSPOINTS, theModule, this);
792 connect( myResultsButton, SIGNAL( clicked() ), mySizeBox, SLOT( onToggleResults() ) );
793 connect( myResultsButton, SIGNAL( toggled( bool ) ), myScalarPane, SLOT( setEnabled( bool ) ) );
794 connect( myGeometryButton, SIGNAL( clicked() ), mySizeBox, SLOT( onToggleGeometry() ) );
795 connect( myDefShapeButton, SIGNAL( toggled( bool ) ), this, SLOT( onToggleDefShape( bool ) ) );
796 connect( myDefShapeButton, SIGNAL( toggled( bool ) ), myScalarPane, SLOT( setEnabled( bool ) ) );
798 myTabBox->addTab(aBox, tr("GAUSS_POINTS_TAB"));
799 myTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB"));
800 myTabBox->addTab(myInputPane, tr("INPUT_TAB"));
802 // Common buttons ===========================================================
803 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
804 GroupButtons->setColumnLayout(0, Qt::Vertical );
805 GroupButtons->layout()->setSpacing( 0 );
806 GroupButtons->layout()->setMargin( 0 );
807 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
808 GroupButtonsLayout->setAlignment( Qt::AlignTop );
809 GroupButtonsLayout->setSpacing( 6 );
810 GroupButtonsLayout->setMargin( 11 );
812 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
813 buttonOk->setAutoDefault( TRUE );
814 buttonOk->setDefault( TRUE );
815 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
816 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
818 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
819 buttonCancel->setAutoDefault( TRUE );
820 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
822 QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" );
823 buttonHelp->setAutoDefault( TRUE );
824 GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
826 TopLayout->addWidget( PrsGroup );
827 TopLayout->addWidget( myTabBox );
828 TopLayout->addWidget( GroupButtons );
830 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
831 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
832 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
835 VisuGUI_GaussPointsDlg::~VisuGUI_GaussPointsDlg()
838 void VisuGUI_GaussPointsDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
842 myPrsCopy = VISU::TSameAsFactory<VISU::TGAUSSPOINTS>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
844 myScalarPane->initFromPrsObject( myPrsCopy, theInit );
846 bool isDeformed = myPrsCopy->GetIsDeformed();
847 myScaleSpinBox->setValue( myPrsCopy->GetScaleFactor() );
848 myDefShapeButton->setChecked( isDeformed );
849 myDefShapeButton->setEnabled( myPrsCopy->GetField()->myNbComp > 1 );
850 onToggleDefShape( isDeformed );
852 bool isResults = myPrsCopy->GetIsColored();
853 myResultsButton->setChecked( isResults && !isDeformed );
854 myGeometryButton->setChecked( !isResults && !isDeformed );
856 myPrimitiveBox->setPrimitiveType( myPrsCopy->GetPrimitiveType() );
857 myPrimitiveBox->setClampMaximum( myPrsCopy->GetMaximumSupportedSize() );
858 myPrimitiveBox->setClamp( myPrsCopy->GetClamp() );
859 myPrimitiveBox->setMainTexture( myPrsCopy->GetQMainTexture() );
860 myPrimitiveBox->setAlphaTexture( myPrsCopy->GetQAlphaTexture() );
861 myPrimitiveBox->setAlphaThreshold( myPrsCopy->GetAlphaThreshold() );
862 myPrimitiveBox->setResolution( myPrsCopy->GetResolution() );
863 myPrimitiveBox->setFaceLimit( myPrsCopy->GetFaceLimit() );
865 mySizeBox->setType( isResults || isDeformed ? VVTK_SizeBox::Results : VVTK_SizeBox::Geometry );
866 mySizeBox->setGeomSize( myPrsCopy->GetGeomSize() );
867 mySizeBox->setMinSize( myPrsCopy->GetMinSize() );
868 mySizeBox->setMaxSize( myPrsCopy->GetMaxSize() );
869 mySizeBox->setMagnification( myPrsCopy->GetMagnification() );
870 mySizeBox->setIncrement( myPrsCopy->GetMagnificationIncrement() );
871 mySizeBox->setColor( myPrsCopy->GetQColor() );
876 myInputPane->initFromPrsObject( myPrsCopy );
877 myTabBox->setCurrentPage( 0 );
880 int VisuGUI_GaussPointsDlg::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs )
882 if(!myInputPane->check())
885 int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
886 anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy );
888 myPrsCopy->SetIsDeformed( myDefShapeButton->isChecked() );
889 myPrsCopy->SetScaleFactor( myScaleSpinBox->value() );
891 int aPrimitiveType = myPrimitiveBox->getPrimitiveType();
892 myPrsCopy->SetPrimitiveType( VISU::GaussPoints::PrimitiveType( aPrimitiveType ) );
894 myPrsCopy->SetClamp( myPrimitiveBox->getClamp() );
896 QString aMainTexture = myPrimitiveBox->getMainTexture();
897 QString anAlphaTexture = myPrimitiveBox->getAlphaTexture();
899 aMainTexture = aMainTexture.isNull() ? myPrsCopy->GetQMainTexture() : aMainTexture;
900 anAlphaTexture = anAlphaTexture.isNull() ? myPrsCopy->GetQAlphaTexture() : anAlphaTexture;
902 myPrsCopy->SetTextures( aMainTexture, anAlphaTexture );
904 myPrsCopy->SetAlphaThreshold( myPrimitiveBox->getAlphaThreshold() );
906 myPrsCopy->SetResolution( myPrimitiveBox->getResolution() );
907 myPrsCopy->SetFaceLimit( myPrimitiveBox->getFaceLimit() );
909 bool isColored = !myGeometryButton->isChecked();
912 myPrsCopy->SetIsColored( true );
913 myPrsCopy->SetMinSize( mySizeBox->getMinSize() );
914 myPrsCopy->SetMaxSize( mySizeBox->getMaxSize() );
918 myPrsCopy->SetIsColored( false );
919 myPrsCopy->SetQColor( mySizeBox->getColor() );
920 myPrsCopy->SetGeomSize( mySizeBox->getGeomSize() );
923 myPrsCopy->SetMagnification( mySizeBox->getMagnification() );
924 myPrsCopy->SetMagnificationIncrement( mySizeBox->getIncrement() );
926 VISU::TSameAsFactory<VISU::TGAUSSPOINTS>().Copy(myPrsCopy, thePrs);
931 void VisuGUI_GaussPointsDlg::onToggleDefShape( bool on )
933 if( on )//myDefShapeButton->isChecked() )
935 myDefShapeBox->show();
936 mySizeBox->setType( VVTK_SizeBox::Results );
939 myDefShapeBox->hide();
942 void VisuGUI_GaussPointsDlg::accept()
944 if( (bool)myPrsCopy && myPrimitiveBox->getPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere )
946 int aNumberOfFaces = myPrimitiveBox->getFaceNumber();
947 int aNumberOfPoints = myPrsCopy->GetSpecificPL()->GetInput()->GetNumberOfCells();
949 if( aNumberOfFaces * aNumberOfPoints > myPrimitiveBox->getFaceLimit() )
951 QString aWarning = "The number of faces needed to perform the 'Geometrical Sphere' primitive\n";
952 aWarning.append( "presentation might be too important to ensure an acceptable frame rate.\n\n" );
953 aWarning.append( "Can you please confirm that you want to continue anyway?" );
954 if( SUIT_MessageBox::warn2( this, tr( "Warning" ), aWarning, tr( "&OK" ), tr( "&Cancel" ), 0, 1, 1 ) == 1 )
959 float aMemory = 50.0 * 1024.0 * (float)aNumberOfFaces * (float)aNumberOfPoints;
961 cout << aNumberOfFaces << endl;
962 cout << aNumberOfPoints << endl;
963 cout << aMemory << endl;
965 vtkSphereSource* aSphere = vtkSphereSource::New();
966 aSphere->SetThetaResolution( myPrimitiveBox->getResolution() );
967 aSphere->SetPhiResolution( myPrimitiveBox->getResolution() );
968 aSphere->GetOutput()->Update();
969 aSphere->GetOutput()->GetActualMemorySize();
971 aMemory = aSphere->GetOutput()->GetActualMemorySize() * 1024.0 * (float)aNumberOfPoints;
973 if( VISU_PipeLine::CheckAvailableMemory( aMemory ) == 0 )
975 SUIT_MessageBox::error1( this, "caption", "text", "ok" );
981 //if( myScalarPane->check() )
982 VisuGUI_Prs3dDlg::accept();
985 QString VisuGUI_GaussPointsDlg::GetContextHelpFilePath()
987 return "types_of_gauss_points_presentations_page.html";