Salome HOME
83e5bfe9e65036b06431c1c92b2f3232c7986db9
[modules/visu.git] / src / VISUGUI / VisuGUI_GaussPointsDlg.cxx
1 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  VISU VISUGUI : GUI of VISU component
24 //  File   : VisuGUI_GaussPointsDlg.cxx
25 //  Author : Oleg UVAROV
26 //  Module : VISU
27 //
28 #include "VisuGUI_GaussPointsDlg.h"
29
30 #include "VISUConfig.hh"
31
32 #include "VisuGUI_Tools.h"
33 #include "VisuGUI_InputPane.h"
34 #include "VisuGUI_PrimitiveBox.h"
35 #include "VisuGUI_SizeBox.h"
36
37 #include "VISU_ColoredPrs3dFactory.hh"
38 #include "VISU_GaussPoints_i.hh"
39 #include "VISU_Prs3dUtils.hh"
40 #include "VISU_GaussPointsPL.hxx"
41 #include "VISU_OpenGLPointSpriteMapper.hxx"
42 #include "VISU_Convertor.hxx"
43
44 #include "LightApp_Application.h"
45 #include "SalomeApp_Module.h"
46 #include "SalomeApp_IntSpinBox.h"
47 #include <SalomeApp_DoubleSpinBox.h>
48 #include "LightApp_SelectionMgr.h"
49 #include "SUIT_Desktop.h"
50 #include "SUIT_ResourceMgr.h"
51 #include "SUIT_Session.h"
52 #include "SUIT_MessageBox.h"
53 #include "SVTK_FontWidget.h"
54
55 #include <QLayout>
56 #include <QTabWidget>
57 #include <QButtonGroup>
58 #include <QRadioButton>
59 #include <QFileDialog>
60 #include <QValidator>
61 #include <QColorDialog>
62 #include <QGroupBox>
63 #include <QCheckBox>
64 #include <QLabel>
65 #include <QPushButton>
66 #include <QLineEdit>
67 #include <QComboBox>
68 #include <QToolButton>
69 #include <QTabWidget>
70 #include <QKeyEvent>
71
72 #include <vtkPolyData.h>
73 #include <vtkDataSet.h>
74 #include <vtkSphereSource.h>
75
76 using namespace std;
77
78 VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent):
79   QWidget(parent)
80 {
81   myVerX = 0.01;  myVerY = 0.10;  myVerW = 0.08;  myVerH = 0.80;
82   myHorX = 0.10;  myHorY = 0.01;  myHorW = 0.80;  myHorH = 0.08;
83   myVerTS = myVerLS = myVerBW = myVerBH = 0;
84   myHorTS = myHorLS = myHorBW = myHorBH = 0;
85   Imin = 0.0; Imax = 0.0;
86   myRangeMode = -1;
87
88   QVBoxLayout* aMainLayout = new QVBoxLayout( this );
89   aMainLayout->setSpacing(6);
90   //setMargin(11);
91
92   // Active bar ========================================================
93   QGroupBox* ActiveBarGroup = new QGroupBox (tr("ACTIVE_BAR_GRP"), this );
94   aMainLayout->addWidget(ActiveBarGroup);
95   //ActiveBarGroup->setColumnLayout(0, Qt::Vertical );
96   //ActiveBarGroup->layout()->setSpacing( 0 );
97   //ActiveBarGroup->layout()->setMargin( 0 );
98   QGridLayout* ActiveBarGroupLayout = new QGridLayout( ActiveBarGroup );
99   ActiveBarGroupLayout->setAlignment( Qt::AlignTop );
100   ActiveBarGroupLayout->setSpacing( 6 );
101   ActiveBarGroupLayout->setMargin( 11 );
102
103   QButtonGroup* BarTypeGroup = new QButtonGroup( ActiveBarGroup );
104   QGroupBox* aGB = new QGroupBox( ActiveBarGroup );
105   QVBoxLayout* aVBLay = new QVBoxLayout( aGB );
106
107   BarTypeGroup->setExclusive( true );
108   //aGB->setFrameStyle( QFrame::NoFrame );
109   aVBLay->setMargin( 0 );
110
111   myRBLocal = new QRadioButton( tr( "LOCAL" ), aGB );
112   myRBGlobal = new QRadioButton( tr( "GLOBAL" ), aGB );
113   aVBLay->addWidget( myRBLocal );
114   aVBLay->addWidget( myRBGlobal );
115
116   BarTypeGroup->addButton( myRBLocal );
117   BarTypeGroup->addButton( myRBGlobal );
118
119   myCBDisplayed = new QCheckBox( tr( "DISPLAYED" ), ActiveBarGroup );
120
121   ActiveBarGroupLayout->addWidget( aGB, 0, 0, 2, 1 );
122   ActiveBarGroupLayout->addWidget( myCBDisplayed, 1, 1 );
123
124   // Range ============================================================
125   RangeGroup = new QButtonGroup ( this );
126   aGB = new QGroupBox( tr("SCALAR_RANGE_GRP"), this );
127   aMainLayout->addWidget(aGB);
128
129   QGridLayout* RangeGroupLayout = new QGridLayout( aGB );
130   RangeGroupLayout->setAlignment( Qt::AlignTop );
131   RangeGroupLayout->setSpacing( 6 );
132   RangeGroupLayout->setMargin( 11 );
133
134   myModeLbl = new QLabel("Scalar Mode", aGB);
135
136   myModeCombo = new QComboBox(aGB);
137
138   RBFieldRange = new QRadioButton (tr("FIELD_RANGE_BTN"), aGB);
139   RBImposedRange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), aGB);
140   RBFieldRange->setChecked( true );
141   RangeGroup->addButton( RBFieldRange );
142   RangeGroup->addButton( RBImposedRange );
143
144   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
145   int aPrecision = qAbs(aResourceMgr->integerValue( "VISU", "visual_data_precision", 0 ));
146
147   QDoubleValidator* dv = new QDoubleValidator(this);
148   dv->setDecimals(aPrecision);
149
150   MinEdit = new QLineEdit( aGB );
151   MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
152   MinEdit->setMinimumWidth( 70 );
153   MinEdit->setValidator( dv );
154   MinEdit->setText( "0.0" );
155   QLabel* MinLabel = new QLabel (tr("LBL_MIN"), aGB);
156   MinLabel->setBuddy(MinEdit);
157
158   MaxEdit = new QLineEdit( aGB );
159   MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
160   MaxEdit->setMinimumWidth( 70 );
161   MaxEdit->setValidator( dv );
162   MaxEdit->setText( "0.0" );
163   QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), aGB);
164   MaxLabel->setBuddy(MaxEdit);
165
166   RangeGroupLayout->addWidget( myModeLbl,      0, 0 );
167   RangeGroupLayout->addWidget( myModeCombo,    0, 1, 1, 3);
168   RangeGroupLayout->addWidget( RBFieldRange,   1, 0, 1, 2);
169   RangeGroupLayout->addWidget( RBImposedRange, 1, 2, 1, 2);
170   RangeGroupLayout->addWidget( MinLabel,       2, 0 );
171   RangeGroupLayout->addWidget( MinEdit,        2, 1 );
172   RangeGroupLayout->addWidget( MaxLabel,       2, 2 );
173   RangeGroupLayout->addWidget( MaxEdit,        2, 3 );
174
175   // Colors and Labels ========================================================
176   QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this );
177   aMainLayout->addWidget(ColLabGroup);
178   //ColLabGroup->setColumnLayout(0, Qt::Vertical );
179   //ColLabGroup->layout()->setSpacing( 0 );
180   //ColLabGroup->layout()->setMargin( 0 );
181   QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup );
182   ColLabGroupLayout->setAlignment( Qt::AlignTop );
183   ColLabGroupLayout->setSpacing( 6 );
184   ColLabGroupLayout->setMargin( 11 );
185
186   QButtonGroup* TypeGroup = new QButtonGroup( ColLabGroup );
187   aGB = new QGroupBox ( ColLabGroup );
188   aVBLay = new QVBoxLayout( aGB );
189   TypeGroup->setExclusive( true );
190   //aGB->setFrameStyle( QFrame::NoFrame );
191   aVBLay->setMargin( 0 );
192
193   BicolorButton = new QRadioButton( tr( "BICOLOR" ), aGB );
194   aVBLay->addWidget( BicolorButton );
195   TypeGroup->addButton( BicolorButton );
196   RainbowButton = new QRadioButton( tr( "RAINBOW" ), aGB );
197   aVBLay->addWidget( RainbowButton );
198   TypeGroup->addButton( RainbowButton );
199
200   ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup );
201   ColorSpin = new SalomeApp_IntSpinBox( ColLabGroup );
202   ColorSpin->setAcceptNames( false );
203   ColorSpin->setMinimum( 2 );
204   ColorSpin->setMaximum( 256 );
205   ColorSpin->setSingleStep( 1 );
206   ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
207   ColorSpin->setMinimumWidth( 70 );
208   ColorSpin->setValue( 64 );
209
210   LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup);
211   LabelSpin = new SalomeApp_IntSpinBox( ColLabGroup );
212   LabelSpin->setAcceptNames( false );  
213   LabelSpin->setMinimum( 2 );
214   LabelSpin->setMaximum( 65 );
215   LabelSpin->setSingleStep( 1 );
216   LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
217   LabelSpin->setMinimumWidth( 70 );
218   LabelSpin->setValue( 5 );
219
220   ColLabGroupLayout->addWidget( aGB, 0, 0, 2, 1);
221   ColLabGroupLayout->addWidget( ColorLabel, 1, 1);
222   ColLabGroupLayout->addWidget( ColorSpin,  1, 2);
223   ColLabGroupLayout->addWidget( LabelLabel, 1, 3);
224   ColLabGroupLayout->addWidget( LabelSpin,  1, 4);
225
226   //TopLayout->addWidget( ColLabGroup );
227
228   // Orientation ==========================================================
229   QButtonGroup* OrientGroup = new QButtonGroup ( this );
230   aGB = new QGroupBox( tr("ORIENTATION_GRP"), this  );
231   aMainLayout->addWidget(aGB);
232   //OrientGroup->setColumnLayout(0, Qt::Vertical );
233   //OrientGroup->layout()->setSpacing( 0 );
234   //OrientGroup->layout()->setMargin( 0 );
235   QGridLayout* OrientGroupLayout = new QGridLayout( aGB );
236   OrientGroupLayout->setAlignment( Qt::AlignTop );
237   OrientGroupLayout->setSpacing( 6 );
238   OrientGroupLayout->setMargin( 11 );
239
240   RBvert = new QRadioButton (tr("VERTICAL_BTN"), aGB );
241   RBvert->setChecked( true );
242   OrientGroup->addButton( RBvert );
243   RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), aGB);
244   OrientGroup->addButton( RBhori
245                           );
246   OrientGroupLayout->addWidget( RBvert, 0, 0 );
247   OrientGroupLayout->addWidget( RBhori, 0, 1 );
248
249   //  TopLayout->addWidget( OrientGroup );
250
251   // Origin ===============================================================
252   QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this );
253   aMainLayout->addWidget( OriginGroup );
254   //OriginGroup->setColumnLayout(0, Qt::Vertical );
255   //OriginGroup->layout()->setSpacing( 0 );
256   //OriginGroup->layout()->setMargin( 0 );
257   QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup );
258   OriginGroupLayout->setAlignment( Qt::AlignTop );
259   OriginGroupLayout->setSpacing( 6 );
260   OriginGroupLayout->setMargin( 11 );
261
262   QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup );
263   XSpin = new SalomeApp_DoubleSpinBox( OriginGroup );
264   VISU::initSpinBox( XSpin, 0.0, 1.0, 0.1, "parametric_precision" );
265   XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
266   XSpin->setMinimumWidth( 70 );
267   XSpin->setValue( 0.01 );
268
269   QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup );
270   YSpin = new SalomeApp_DoubleSpinBox( OriginGroup );
271   VISU::initSpinBox( YSpin, 0.0, 1.0, 0.1, "parametric_precision" );
272   YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
273   YSpin->setMinimumWidth( 70 );
274   YSpin->setValue( 0.01 );
275
276   OriginGroupLayout->addWidget( XLabel, 0, 0);
277   OriginGroupLayout->addWidget( XSpin,  0, 1);
278   OriginGroupLayout->addWidget( YLabel, 0, 2);
279   OriginGroupLayout->addWidget( YSpin,  0, 3);
280
281   //TopLayout->addWidget( OriginGroup );
282
283   // Dimensions =========================================================
284   QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this );
285   aMainLayout->addWidget( DimGroup );
286   //DimGroup->setColumnLayout(0, Qt::Vertical );
287   //DimGroup->layout()->setSpacing( 0 );
288   //DimGroup->layout()->setMargin( 0 );
289   QGridLayout* DimGroupLayout = new QGridLayout( DimGroup );
290   DimGroupLayout->setAlignment( Qt::AlignTop );
291   DimGroupLayout->setSpacing( 6 );
292   DimGroupLayout->setMargin( 11 );
293
294   QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup );
295   WidthSpin = new SalomeApp_DoubleSpinBox( DimGroup );
296   VISU::initSpinBox( WidthSpin, 0.0, 1.0, 0.1, "parametric_precision" );
297   WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
298   WidthSpin->setMinimumWidth( 70 );
299   WidthSpin->setValue( 0.1 );
300
301   QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup );
302   HeightSpin = new SalomeApp_DoubleSpinBox( DimGroup );
303   VISU::initSpinBox( HeightSpin, 0.0, 1.0, 0.1, "parametric_precision" );
304   HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
305   HeightSpin->setMinimumWidth( 70 );
306   HeightSpin->setValue( 0.8 );
307
308   QLabel* SpacingLabel = new QLabel (tr("LBL_SPACING"), DimGroup );
309   SpacingSpin = new SalomeApp_DoubleSpinBox( DimGroup );
310   VISU::initSpinBox( SpacingSpin, 0.0, 1.0, 0.01, "parametric_precision" );  
311   SpacingSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
312   SpacingSpin->setMinimumWidth( 70 );
313   SpacingSpin->setValue( 0.01 );
314
315   DimGroupLayout->addWidget( WidthLabel, 0, 0);
316   DimGroupLayout->addWidget( WidthSpin,  0, 1);
317   DimGroupLayout->addWidget( HeightLabel, 0, 2);
318   DimGroupLayout->addWidget( HeightSpin,  0, 3);
319   DimGroupLayout->addWidget( SpacingLabel, 0, 4);
320   DimGroupLayout->addWidget( SpacingSpin,  0, 5);
321
322   //TopLayout->addWidget( DimGroup );
323
324   QWidget* aSaveBox = new QWidget(this);
325   aMainLayout->addWidget( aSaveBox );
326
327   QHBoxLayout* aHBoxLay = new QHBoxLayout( aSaveBox );
328
329   myTextBtn = new QPushButton("Text properties...", aSaveBox);
330   aHBoxLay->addWidget( myTextBtn );
331
332   myBarBtn = new QPushButton("Bar properties...", aSaveBox);
333   aHBoxLay->addWidget( myBarBtn );
334
335   myTextDlg = new VisuGUI_TextPrefDlg(this);
336   aMainLayout->addWidget( myTextDlg );
337   myTextDlg->setTitleVisible(true);
338
339   myBarDlg = new VisuGUI_BarPrefDlg(this);
340   aMainLayout->addWidget( myBarDlg );
341
342   QGroupBox* CheckGroup = new QGroupBox("", this );
343   aMainLayout->addWidget( CheckGroup );
344   QGridLayout* CheckGroupLayout = new QGridLayout( CheckGroup );
345
346   myHideBar = new QCheckBox(tr("HIDE_SCALAR_BAR"), CheckGroup);
347   myHideBar->setChecked(false);
348   CheckGroupLayout->addWidget(myHideBar, 0, 0);
349
350   // signals and slots connections ===========================================
351   connect( RBFieldRange,  SIGNAL( clicked() ), this, SLOT( fieldRangeClicked() ) );
352   connect( RBImposedRange,SIGNAL( clicked() ), this, SLOT( imposedRangeClicked() ) );
353
354   connect( myModeCombo,   SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( int ) ) );
355
356   connect( myRBLocal,     SIGNAL( clicked() ), this, SLOT( onLocalScalarBar() ) );
357   connect( myRBGlobal,    SIGNAL( clicked() ), this, SLOT( onGlobalScalarBar() ) );
358
359   connect( RainbowButton, SIGNAL( toggled( bool ) ), ColorLabel, SLOT( setEnabled( bool ) ) );
360   connect( RainbowButton, SIGNAL( toggled( bool ) ), ColorSpin, SLOT( setEnabled( bool ) ) );
361   connect( RainbowButton, SIGNAL( toggled( bool ) ), LabelLabel, SLOT( setEnabled( bool ) ) );
362   connect( RainbowButton, SIGNAL( toggled( bool ) ), LabelSpin, SLOT( setEnabled( bool ) ) );
363   connect( OrientGroup,   SIGNAL( buttonClicked( int ) ), this, SLOT( changeDefaults( int ) ) );
364   connect( XSpin,         SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
365   connect( YSpin,         SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
366   connect( myTextBtn,     SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
367   connect( myBarBtn,      SIGNAL( clicked() ), this, SLOT( onBarPref() ) );
368
369   changeDefaults( 0 );
370   myIsStoreTextProp = false;
371 }
372
373 bool VisuGUI_GaussScalarBarPane::UseFieldRange(bool theInit)
374 {
375   if ( theInit )
376     return !myPrsCopy->IsRangeFixed();
377
378   return RBFieldRange->isChecked() || !myPrsCopy->GetIsActiveLocalScalarBar();
379 }
380
381
382 void VisuGUI_GaussScalarBarPane::onGlobalScalarBar()
383 {
384   myPrsCopy->SetIsActiveLocalScalarBar(false);
385   myPrsCopy->SetSourceRange();
386
387   myCBDisplayed->setEnabled( false );
388
389   RBImposedRange->setEnabled( false );
390   RBFieldRange->setEnabled( false );
391
392   MinEdit->setEnabled( false );
393   MaxEdit->setEnabled( false );
394
395   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
396   int aPrecision = qAbs(aResourceMgr->integerValue("VISU", "visual_data_precision", 0));
397
398   MinEdit->setText(QString::number(myPrsCopy->GetMin(), 'g', aPrecision));
399   MaxEdit->setText(QString::number(myPrsCopy->GetMax(), 'g', aPrecision));
400 }
401
402
403 void VisuGUI_GaussScalarBarPane::onLocalScalarBar()
404 {
405   myPrsCopy->SetIsActiveLocalScalarBar(true);
406   if ( RBFieldRange->isChecked() )
407     myPrsCopy->SetSourceRange();
408   else
409     myPrsCopy->SetRange(myPrsCopy->GetMin(), myPrsCopy->GetMax());
410
411   myCBDisplayed->setEnabled( true );
412
413   RBImposedRange->setEnabled( true );
414   RBFieldRange->setEnabled( true );
415
416   MinEdit->setEnabled( RBImposedRange->isChecked() );
417   MaxEdit->setEnabled( RBImposedRange->isChecked() );
418
419   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
420   int aPrecision = qAbs(aResourceMgr->integerValue("VISU", "visual_data_precision", 0));
421
422   MinEdit->setText(QString::number(myPrsCopy->GetMin(), 'g', aPrecision));
423   MaxEdit->setText(QString::number(myPrsCopy->GetMax(), 'g', aPrecision));
424 }
425
426
427 /*!
428   Called when Range mode is changed to FieldRange
429 */
430 void VisuGUI_GaussScalarBarPane::fieldRangeClicked()
431 {
432   myPrsCopy->SetSourceRange();
433
434   RBFieldRange->setChecked( true );
435   RBImposedRange->setChecked( false );
436
437   MinEdit->setEnabled( false );
438   MaxEdit->setEnabled( false );
439
440   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
441   int aPrecision = qAbs(aResourceMgr->integerValue("VISU", "visual_data_precision", 0));
442
443   MinEdit->setText(QString::number(myPrsCopy->GetMin(), 'g', aPrecision));
444   MaxEdit->setText(QString::number(myPrsCopy->GetMax(), 'g', aPrecision));
445 }
446
447
448 /*!
449   Called when Range mode is changed to FieldRange
450 */
451 void VisuGUI_GaussScalarBarPane::imposedRangeClicked()
452 {
453   myPrsCopy->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
454
455   RBImposedRange->setChecked( true );
456   RBFieldRange->setChecked( false );
457
458   MinEdit->setEnabled( true );
459   MaxEdit->setEnabled( true );
460 }
461
462
463 /*!
464   Called when scalar mode is changed
465 */
466 void VisuGUI_GaussScalarBarPane::changeScalarMode( int theMode )
467 {
468   myPrsCopy->SetScalarMode( theMode );
469   if ( UseFieldRange() ) {
470     SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
471     int aPrecision = qAbs(aResourceMgr->integerValue("VISU", "visual_data_precision", 0));
472
473     MinEdit->setText(QString::number(myPrsCopy->GetSourceMin(), 'g', aPrecision));
474     MaxEdit->setText(QString::number(myPrsCopy->GetSourceMax(), 'g', aPrecision));
475   }
476 }
477
478 /**
479  * Initialise dialog box from presentation object
480  */
481 void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs,
482                                                    bool theInit )
483 {
484   myPrsCopy = thePrs;
485
486   myModeCombo->setCurrentIndex(thePrs->GetScalarMode());
487
488   bool activeLocal = thePrs->GetIsActiveLocalScalarBar();
489   if ( activeLocal ) {
490     RBImposedRange->setChecked( !UseFieldRange(theInit) );
491     RBFieldRange->setChecked( UseFieldRange(theInit) );
492     MinEdit->setEnabled( !UseFieldRange(theInit) );
493     MaxEdit->setEnabled( !UseFieldRange(theInit) );
494   } else {
495     RBImposedRange->setEnabled( false );
496     RBFieldRange->setEnabled( false );
497     MinEdit->setEnabled( false );
498     MaxEdit->setEnabled( false );
499   }
500
501   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
502   int aPrecision = qAbs(aResourceMgr->integerValue("VISU", "visual_data_precision", 0));
503
504   MinEdit->setText(QString::number(thePrs->GetMin(), 'g', aPrecision));
505   MaxEdit->setText(QString::number(thePrs->GetMax(), 'g', aPrecision));
506
507   setPosAndSize( thePrs->GetPosX(),
508                  thePrs->GetPosY(),
509                  thePrs->GetWidth(),
510                  thePrs->GetHeight(),
511                  thePrs->GetBarOrientation());
512
513   if (RBvert->isChecked()) {
514     myVerTS = thePrs->GetTitleSize();
515     myVerLS = thePrs->GetLabelSize();
516     myVerBW = thePrs->GetBarWidth();
517     myVerBH = thePrs->GetBarHeight();
518   } else {
519     myHorTS = thePrs->GetTitleSize();
520     myHorLS = thePrs->GetLabelSize();
521     myHorBW = thePrs->GetBarWidth();
522     myHorBH = thePrs->GetBarHeight();
523   }
524
525   myBarDlg->setLabelsPrecision( VISU::ToPrecision( thePrs->GetLabelsFormat() ) );
526   myBarDlg->setUnitsVisible(thePrs->IsUnitsVisible());
527
528   SpacingSpin->setValue(thePrs->GetSpacing());
529
530   myRBLocal->setChecked( activeLocal );
531
532   myRBGlobal->setChecked( !activeLocal );
533   myRBGlobal->setEnabled( thePrs->IsGlobalRangeDefined() );
534   if( !thePrs->IsGlobalRangeDefined() )
535     myRBLocal->setChecked( true );
536
537   myCBDisplayed->setEnabled( activeLocal );
538   myCBDisplayed->setChecked( thePrs->GetIsDispGlobalScalarBar() );
539
540   bool bicolor = thePrs->GetSpecificPL()->GetBicolor();
541   BicolorButton->setChecked( bicolor );
542   RainbowButton->setChecked( !bicolor );
543   ColorLabel->setEnabled( !bicolor );
544   ColorSpin->setEnabled( !bicolor );
545   LabelLabel->setEnabled( !bicolor );
546   LabelSpin->setEnabled( !bicolor );
547
548   setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
549
550   // Update myModeCombo
551   int aNbComp = thePrs->GetField()->myNbComp;
552   bool isScalarMode = (aNbComp > 1);
553   myModeCombo->clear();
554   myModeCombo->addItem("<Modulus>");
555   VISU::PField aField = thePrs->GetField();
556   const VISU::TNames& aCompNames = aField->myCompNames;
557   const VISU::TNames& aUnitNames = aField->myUnitNames;
558   for(int i = 0; i < aNbComp; i++){
559     QString aComponent = QString(aCompNames[i].c_str()).simplified();
560     if(aComponent.isNull() || aComponent == "")
561       aComponent = "Component " + QString::number(i+1);
562     else
563       aComponent = "[" + QString::number(i+1) + "] " + aComponent;
564
565     QString anUnit = QString(aUnitNames[i].c_str()).simplified();
566     if(anUnit.isNull() || anUnit == "")
567       anUnit = "-";
568
569     aComponent = aComponent + ", " + anUnit;
570
571     myModeCombo->addItem(aComponent);
572   }
573   //
574   myModeCombo->setCurrentIndex(thePrs->GetScalarMode());
575   if (aNbComp==1){
576     myModeCombo->setCurrentIndex(1);
577   }
578   //
579   myModeLbl->setEnabled(isScalarMode);
580   myModeCombo->setEnabled(isScalarMode);
581
582   // "Title"
583   myTextDlg->setTitleText(QString(thePrs->GetTitle()));
584
585   vtkFloatingPointType R, G, B;
586   thePrs->GetTitleColor(R, G, B);
587
588   int lp = VISU::ToPrecision( thePrs->GetLabelsFormat() );
589   myBarDlg->setLabelsPrecision( lp );
590   myBarDlg->setUnitsVisible(thePrs->IsUnitsVisible());
591
592   myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
593                                   thePrs->GetTitFontType(),
594                                   thePrs->IsBoldTitle(),
595                                   thePrs->IsItalicTitle(),
596                                   thePrs->IsShadowTitle());
597
598   // "Labels"
599   thePrs->GetLabelColor(R, G, B);
600
601   myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
602                                   thePrs->GetLblFontType(),
603                                   thePrs->IsBoldLabel(),
604                                   thePrs->IsItalicLabel(),
605                                   thePrs->IsShadowLabel());
606
607   myHideBar->setChecked(!thePrs->IsBarVisible());
608 }
609
610 /**
611  * Store values to presentation object
612  */
613 int VisuGUI_GaussScalarBarPane::storeToPrsObject(VISU::GaussPoints_i* thePrs) {
614   thePrs->SetScalarMode(myModeCombo->currentIndex());
615
616   if (RBFieldRange->isChecked()) {
617     thePrs->SetSourceRange();
618   } else {
619     thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
620   }
621
622   thePrs->SetSpacing(SpacingSpin->value());
623   thePrs->SetIsActiveLocalScalarBar(myRBLocal->isChecked());
624   thePrs->SetIsDispGlobalScalarBar(myCBDisplayed->isChecked());
625   thePrs->SetBiColor(BicolorButton->isChecked());
626
627   thePrs->SetPosition(XSpin->value(), YSpin->value());
628   thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
629   thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ColoredPrs3dBase::VERTICAL : VISU::ColoredPrs3dBase::HORIZONTAL);
630   thePrs->SetNbColors(ColorSpin->value());
631   thePrs->SetLabels(LabelSpin->value());
632
633   if(RBvert->isChecked()) {
634     thePrs->SetRatios(myVerTS, myVerLS, myVerBW, myVerBH);
635   } else {
636     thePrs->SetRatios(myHorTS, myHorLS, myHorBW, myHorBH);
637   }
638
639   std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() );
640   thePrs->SetLabelsFormat( f.c_str() );
641   thePrs->SetUnitsVisible(myBarDlg->isUnitsVisible());
642
643   thePrs->SetBarVisible(!myHideBar->isChecked());
644
645   if (myIsStoreTextProp) {
646     // "Title"
647     thePrs->SetTitle(myTextDlg->getTitleText().toLatin1().data());
648
649     QColor aTitColor (255, 255, 255);
650     int aTitleFontFamily = VTK_ARIAL;
651     bool isTitleBold = false;
652     bool isTitleItalic = false;
653     bool isTitleShadow = false;
654
655     myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
656                                     isTitleBold, isTitleItalic, isTitleShadow);
657
658     thePrs->SetBoldTitle(isTitleBold);
659     thePrs->SetItalicTitle(isTitleItalic);
660     thePrs->SetShadowTitle(isTitleShadow);
661     thePrs->SetTitFontType(aTitleFontFamily);
662     thePrs->SetTitleColor(aTitColor.red()/255.,
663                           aTitColor.green()/255.,
664                           aTitColor.blue()/255.);
665
666     // "Label"
667     QColor aLblColor (255, 255, 255);
668     int aLabelFontFamily = VTK_ARIAL;
669     bool isLabelBold = false;
670     bool isLabelItalic = false;
671     bool isLabelShadow = false;
672
673     myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
674                                     isLabelBold, isLabelItalic, isLabelShadow);
675
676     thePrs->SetBoldLabel(isLabelBold);
677     thePrs->SetItalicLabel(isLabelItalic);
678     thePrs->SetShadowLabel(isLabelShadow);
679     thePrs->SetLblFontType(aLabelFontFamily);
680     thePrs->SetLabelColor(aLblColor.red()/255.,
681                           aLblColor.green()/255.,
682                           aLblColor.blue()/255.);
683   }
684
685   return 1;
686 }
687
688 /*!
689   Called when orientation is changed
690 */
691 void VisuGUI_GaussScalarBarPane::changeDefaults( int )
692 {
693   if ( RBvert->isChecked() ) {
694     XSpin->setValue( myVerX );
695     YSpin->setValue( myVerY );
696     WidthSpin->setValue( myVerW );
697     HeightSpin->setValue( myVerH );
698   }
699   else {
700     XSpin->setValue( myHorX );
701     YSpin->setValue( myHorY );
702     WidthSpin->setValue( myHorW );
703     HeightSpin->setValue( myHorH );
704   }
705 }
706
707 /*!
708   Called when X,Y position is changed
709 */
710 void VisuGUI_GaussScalarBarPane::XYChanged( double )
711 {
712   SalomeApp_DoubleSpinBox* snd = (SalomeApp_DoubleSpinBox*)sender();
713   if ( snd == XSpin ) {
714     WidthSpin->setMaximum( 1.0 - XSpin->value() );
715   }
716   if ( snd == YSpin ) {
717     HeightSpin->setMaximum( 1.0 - YSpin->value() );
718   }
719 }
720
721 /*!
722   Sets size and position
723 */
724 void VisuGUI_GaussScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
725 {
726   if ( vert ) {
727     myVerX = x;
728     myVerY = y;
729     myVerW = w;
730     myVerH = h;
731     RBvert->setChecked( true );
732   }
733   else {
734     myHorX = x;
735     myHorY = y;
736     myHorW = w;
737     myHorH = h;
738     RBhori->setChecked( true );
739   }
740   changeDefaults( 0 );
741 }
742
743 /*!
744   Sets colors and labels number
745 */
746 void VisuGUI_GaussScalarBarPane::setScalarBarData( int colors, int labels )
747 {
748   ColorSpin->setValue( colors );
749   LabelSpin->setValue( labels );
750 }
751
752 /*!
753   Gets orientation
754 */
755 int VisuGUI_GaussScalarBarPane::getOrientation()
756 {
757   if (RBvert->isChecked() )
758     return  1;
759   else
760     return 0;
761 }
762
763 /*!
764   Sets and gets parameters
765 */
766 double VisuGUI_GaussScalarBarPane::getX() {
767   return XSpin->value();
768 }
769
770 double VisuGUI_GaussScalarBarPane::getY() {
771   return YSpin->value();
772 }
773
774 double VisuGUI_GaussScalarBarPane::getWidth() {
775   return WidthSpin->value();
776 }
777
778 double VisuGUI_GaussScalarBarPane::getHeight() {
779   return HeightSpin->value();
780 }
781
782 int VisuGUI_GaussScalarBarPane::getNbColors() {
783   return ColorSpin->value();
784 }
785
786 int VisuGUI_GaussScalarBarPane::getNbLabels() {
787   return LabelSpin->value();
788 }
789
790 void VisuGUI_GaussScalarBarPane::onTextPref()
791 {
792   myIsStoreTextProp = myTextDlg->exec();
793 }
794
795 void VisuGUI_GaussScalarBarPane::onBarPref()
796 {
797   if(RBvert->isChecked())
798     myBarDlg->setRatios(myVerTS, myVerLS, myVerBW, myVerBH);
799   else
800     myBarDlg->setRatios(myHorTS, myHorLS, myHorBW, myHorBH);
801   if(myBarDlg->exec()) {
802     if(RBvert->isChecked())
803       myBarDlg->getRatios(myVerTS, myVerLS, myVerBW, myVerBH);
804     else
805       myBarDlg->getRatios(myHorTS, myHorLS, myHorBW, myHorBH);
806   }
807 }
808
809 /*!
810  * Constructor
811  */
812 VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule):
813   myModule(theModule),
814   VisuGUI_Prs3dDlg(theModule)
815 {
816   //setName("VisuGUI_GaussPointsDlg");
817   setWindowTitle(tr("DLG_PROP_TITLE"));
818   setSizeGripEnabled(TRUE);
819
820   QVBoxLayout* TopLayout = new QVBoxLayout(this);
821   TopLayout->setSpacing(6);
822   TopLayout->setMargin(11);
823
824
825   // Presentation
826   QButtonGroup* PrsGroup = new QButtonGroup( this );
827   QGroupBox* aGB = new QGroupBox( tr( "PRS_TITLE" ), this );
828   QHBoxLayout* aHBLay = new QHBoxLayout( aGB );
829   PrsGroup->setExclusive( true );
830   aHBLay->setMargin( 11 );
831   aHBLay->setSpacing(6);
832
833   myResultsButton = new QRadioButton( tr( "RESULTS" ), aGB );
834   myGeometryButton = new QRadioButton( tr( "GEOMETRY" ), aGB );
835   myDefShapeButton = new QRadioButton( tr( "DEFORMED_SHAPE" ), aGB );
836   aHBLay->addWidget( myResultsButton );
837   aHBLay->addWidget( myGeometryButton );
838   aHBLay->addWidget( myDefShapeButton );
839
840   PrsGroup->addButton( myResultsButton );
841   PrsGroup->addButton( myGeometryButton );
842   PrsGroup->addButton( myDefShapeButton );
843
844
845   myTabBox = new QTabWidget (this);
846
847   // Gauss points pane
848   QWidget* aBox = new QWidget (this);
849   QVBoxLayout* aVBLay = new QVBoxLayout( aBox );
850   aVBLay->setMargin(11);
851   aVBLay->setSpacing(6);
852
853   // Primitive
854   myPrimitiveBox = new VisuGUI_PrimitiveBox( aBox );
855   aVBLay->addWidget( myPrimitiveBox );
856
857   // Size
858   mySizeBox = new VisuGUI_SizeBox( aBox );
859   aVBLay->addWidget( mySizeBox );
860
861   // Deformed Shape
862   myDefShapeBox = new QGroupBox( tr( "DEFORMED_SHAPE_TITLE" ), aBox );
863   aVBLay->addWidget( myDefShapeBox );
864   //myDefShapeBox->setColumnLayout(0, Qt::Vertical );
865   //myDefShapeBox->layout()->setSpacing( 0 );
866   //myDefShapeBox->layout()->setMargin( 0 );
867
868   QGridLayout* aDefShapeLayout = new QGridLayout( myDefShapeBox );
869   aDefShapeLayout->setAlignment(Qt::AlignTop);
870   aDefShapeLayout->setSpacing(6);
871   aDefShapeLayout->setMargin(11);
872
873   QLabel* aScaleLabel = new QLabel( tr( "SCALE_FACTOR" ), myDefShapeBox );
874   myScaleSpinBox = new SalomeApp_DoubleSpinBox( myDefShapeBox );
875   VISU::initSpinBox( myScaleSpinBox, 0.0, 10.0, 0.1, "visual_data_precision" );
876
877   aDefShapeLayout->addWidget( aScaleLabel, 0, 0 );
878   aDefShapeLayout->addWidget( myScaleSpinBox, 0, 1 );
879
880   // Scalar Bar pane
881   myScalarPane = new VisuGUI_GaussScalarBarPane(this);
882   if ( myScalarPane->layout() )
883     myScalarPane->layout()->setMargin(5);
884
885   // Input pane
886   myInputPane = new VisuGUI_InputPane(VISU::TGAUSSPOINTS, theModule, this);
887   myInputPane->SetRestoreInitialSelection(false);
888
889   connect( myResultsButton,  SIGNAL( clicked() ),       mySizeBox,    SLOT( onToggleResults() ) );
890   connect( myResultsButton,  SIGNAL( toggled( bool ) ), myScalarPane, SLOT( setEnabled( bool ) ) );
891   connect( myGeometryButton, SIGNAL( clicked() ),       mySizeBox,    SLOT( onToggleGeometry() ) );
892   connect( myDefShapeButton, SIGNAL( toggled( bool ) ), this,         SLOT( onToggleDefShape( bool ) ) );
893   connect( myDefShapeButton, SIGNAL( toggled( bool ) ), myScalarPane, SLOT( setEnabled( bool ) ) );
894
895   myTabBox->addTab(aBox, tr("GAUSS_POINTS_TAB"));
896   myTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB"));
897   myTabBox->addTab(myInputPane, tr("INPUT_TAB"));
898
899   // Common buttons ===========================================================
900   QGroupBox* GroupButtons = new QGroupBox( this );
901   //GroupButtons->setColumnLayout(0, Qt::Vertical );
902   //GroupButtons->layout()->setSpacing( 0 );
903   //GroupButtons->layout()->setMargin( 0 );
904   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons );
905   GroupButtonsLayout->setAlignment( Qt::AlignTop );
906   GroupButtonsLayout->setSpacing( 6 );
907   GroupButtonsLayout->setMargin( 11 );
908
909   QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons );
910   buttonOk->setAutoDefault( TRUE );
911   buttonOk->setDefault( TRUE );
912   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
913   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
914
915   QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons );
916   buttonCancel->setAutoDefault( TRUE );
917   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
918
919   QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons );
920   buttonHelp->setAutoDefault( TRUE );
921   GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
922
923   TopLayout->addWidget( aGB );
924   TopLayout->addWidget( myTabBox );
925   TopLayout->addWidget( GroupButtons );
926
927   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
928   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
929   connect( buttonHelp,   SIGNAL( clicked() ), this, SLOT( onHelp() ) );
930 }
931
932 VisuGUI_GaussPointsDlg::~VisuGUI_GaussPointsDlg()
933 {}
934
935 void VisuGUI_GaussPointsDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
936                                                 bool theInit )
937 {
938   if( theInit )
939     myPrsCopy = VISU::TSameAsFactory<VISU::TGAUSSPOINTS>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
940
941   myScalarPane->initFromPrsObject( myPrsCopy, theInit );
942
943   bool isDeformed = myPrsCopy->GetIsDeformed();
944   myScaleSpinBox->setValue( myPrsCopy->GetScaleFactor() );
945   myDefShapeButton->setChecked( isDeformed );
946   myDefShapeButton->setEnabled( myPrsCopy->GetField()->myNbComp > 1 );
947   onToggleDefShape( isDeformed );
948
949   bool isResults = myPrsCopy->GetIsColored();
950   myResultsButton->setChecked( isResults && !isDeformed );
951   myGeometryButton->setChecked( !isResults && !isDeformed );
952
953   myPrimitiveBox->setPrimitiveType( myPrsCopy->GetPrimitiveType() );
954   myPrimitiveBox->setClampMaximum( myPrsCopy->GetMaximumSupportedSize() );
955   myPrimitiveBox->setClamp( myPrsCopy->GetClamp() );
956   myPrimitiveBox->setMainTexture( myPrsCopy->GetQMainTexture() );
957   myPrimitiveBox->setAlphaTexture( myPrsCopy->GetQAlphaTexture() );
958   myPrimitiveBox->setAlphaThreshold( myPrsCopy->GetAlphaThreshold() );
959   myPrimitiveBox->setResolution( myPrsCopy->GetResolution() );
960   myPrimitiveBox->setFaceLimit( myPrsCopy->GetFaceLimit() );
961
962   mySizeBox->setType( isResults || isDeformed ? VisuGUI_SizeBox::Results : VisuGUI_SizeBox::Geometry );
963   mySizeBox->setGeomSize( myPrsCopy->GetGeomSize() );
964   mySizeBox->setMinSize( myPrsCopy->GetMinSize() );
965   mySizeBox->setMaxSize( myPrsCopy->GetMaxSize() );
966   mySizeBox->setMagnification( myPrsCopy->GetMagnification() );
967   mySizeBox->setIncrement( myPrsCopy->GetMagnificationIncrement() );
968   mySizeBox->setColor( myPrsCopy->GetQColor() );
969
970   //Disable Size controls if there are no OpenGL extensions
971   char* ext = (char*)glGetString( GL_EXTENSIONS );
972   if( strstr( ext, "GL_ARB_point_sprite" ) == NULL ||
973       strstr( ext, "GL_ARB_shader_objects" ) == NULL ||
974       strstr( ext, "GL_ARB_vertex_buffer_object" ) == NULL )
975       mySizeBox->enableSizeControls(false);
976
977   if( !theInit )
978     return;
979
980   myInputPane->initFromPrsObject( myPrsCopy );
981   myTabBox->setCurrentIndex( 0 );
982 }
983
984 int VisuGUI_GaussPointsDlg::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs )
985 {
986   if(!myInputPane->check())
987     return 0;
988
989   int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
990   anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy );
991
992   myPrsCopy->SetIsDeformed( myDefShapeButton->isChecked() );
993   myPrsCopy->SetScaleFactor( myScaleSpinBox->value() );
994
995   int aPrimitiveType = myPrimitiveBox->getPrimitiveType();
996   myPrsCopy->SetPrimitiveType( VISU::GaussPoints::PrimitiveType( aPrimitiveType )  );
997
998   myPrsCopy->SetClamp( myPrimitiveBox->getClamp() );
999
1000   QString aMainTexture = myPrimitiveBox->getMainTexture();
1001   QString anAlphaTexture = myPrimitiveBox->getAlphaTexture();
1002
1003   aMainTexture = aMainTexture.isNull() ? myPrsCopy->GetQMainTexture() : aMainTexture;
1004   anAlphaTexture = anAlphaTexture.isNull() ? myPrsCopy->GetQAlphaTexture() : anAlphaTexture;
1005
1006   myPrsCopy->SetTextures( aMainTexture.toLatin1().data(), anAlphaTexture.toLatin1().data() );
1007
1008   myPrsCopy->SetAlphaThreshold( myPrimitiveBox->getAlphaThreshold() );
1009
1010   myPrsCopy->SetResolution( myPrimitiveBox->getResolution() );
1011   myPrsCopy->SetFaceLimit( myPrimitiveBox->getFaceLimit() );
1012
1013   bool isColored = !myGeometryButton->isChecked();
1014   if( isColored )
1015   {
1016     myPrsCopy->SetIsColored( true );
1017     myPrsCopy->SetMinSize( mySizeBox->getMinSize() );
1018     myPrsCopy->SetMaxSize( mySizeBox->getMaxSize() );
1019   }
1020   else
1021   {
1022     myPrsCopy->SetIsColored( false );
1023     myPrsCopy->SetQColor( mySizeBox->getColor() );
1024     myPrsCopy->SetGeomSize( mySizeBox->getGeomSize() );
1025   }
1026
1027   myPrsCopy->SetMagnification( mySizeBox->getMagnification() );
1028   myPrsCopy->SetMagnificationIncrement( mySizeBox->getIncrement() );
1029
1030   VISU::TSameAsFactory<VISU::TGAUSSPOINTS>().Copy(myPrsCopy, thePrs);
1031
1032   //Set created Gauss points presentation selected,
1033   //Issue 0019874(EDF 746 VISU: Picking alphanumeric Gauss)
1034   if(thePrs){
1035     SALOME_ListIO aListIO;
1036     //LightApp_SelectionMgr* aSelectionMgr = VISU::GetSelectionMgr(myModule);
1037     Handle(SALOME_InteractiveObject) anIO = thePrs->GetIO();
1038     if(anIO && anIO->hasEntry()) {
1039       aListIO.Append(anIO);
1040       VISU::UpdateObjBrowser(myModule,true);
1041       //IPAL20836 aSelectionMgr->setSelectedObjects(aListIO);
1042     }
1043     else
1044       myInputPane->SetRestoreInitialSelection(true);
1045   }
1046   return anIsOk;
1047 }
1048
1049 void VisuGUI_GaussPointsDlg::onToggleDefShape( bool on )
1050 {
1051   if( on )//myDefShapeButton->isChecked() )
1052   {
1053     myDefShapeBox->show();
1054     mySizeBox->setType( VisuGUI_SizeBox::Results );
1055   }
1056   else
1057     myDefShapeBox->hide();
1058 }
1059
1060 void VisuGUI_GaussPointsDlg::accept()
1061 {
1062   if( (bool)myPrsCopy && myPrimitiveBox->getPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere )
1063   {
1064     int aNumberOfFaces = myPrimitiveBox->getFaceNumber();
1065     int aNumberOfPoints = myPrsCopy->GetSpecificPL()->GetInput()->GetNumberOfCells();
1066
1067     if( aNumberOfFaces * aNumberOfPoints > myPrimitiveBox->getFaceLimit() )
1068     {
1069       QString aWarning = "The number of faces needed to perform the 'Geometrical Sphere' primitive\n";
1070       aWarning.append( "presentation might be too important to ensure an acceptable frame rate.\n\n" );
1071       aWarning.append( "Can you please confirm that you want to continue anyway?" );
1072       if( SUIT_MessageBox::warning( this, tr( "Warning" ), aWarning, tr( "&OK" ), tr( "&Cancel" ) ) == 1 )
1073         return;
1074     }
1075
1076     /*
1077     float aMemory = 50.0 * 1024.0 * (float)aNumberOfFaces * (float)aNumberOfPoints;
1078
1079     cout << aNumberOfFaces << endl;
1080     cout << aNumberOfPoints << endl;
1081     cout << aMemory << endl;
1082
1083     vtkSphereSource* aSphere = vtkSphereSource::New();
1084     aSphere->SetThetaResolution( myPrimitiveBox->getResolution() );
1085     aSphere->SetPhiResolution( myPrimitiveBox->getResolution() );
1086     aSphere->GetOutput()->Update();
1087     aSphere->GetOutput()->GetActualMemorySize();
1088
1089     aMemory = aSphere->GetOutput()->GetActualMemorySize() * 1024.0 * (float)aNumberOfPoints;
1090
1091     if( VISU_PipeLine::CheckAvailableMemory( aMemory ) == 0 )
1092     {
1093       SUIT_MessageBox::error1( this, "caption", "text", "ok" );
1094       return 0;
1095     }
1096     */
1097   }
1098
1099   //if( myScalarPane->check() )
1100   VisuGUI_Prs3dDlg::accept();
1101 }
1102
1103 QString VisuGUI_GaussPointsDlg::GetContextHelpFilePath()
1104 {
1105   return "types_of_gauss_points_presentations_page.html";
1106 }