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