Salome HOME
Merge from V5_1_main 14/05/2010
[modules/visu.git] / src / VISUGUI / VisuGUI_Table3dDlg.cxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // VISU VISUGUI : GUI of VISU component
21 // File   : VisuGUI_Table3dDlg.cxx
22 // Author : Laurent CORNABE & Hubert ROLLAND
23 //
24 #include "VisuGUI_Table3dDlg.h"
25
26 #include "VisuGUI.h"
27 #include "VisuGUI_Tools.h"
28 #include "VisuGUI_ViewTools.h"
29 #include "VisuGUI_InputPane.h"
30
31 #include "VISU_ColoredPrs3dFactory.hh"
32 #include "VISU_ViewManager_i.hh"
33 #include "VISU_Prs3dUtils.hh"
34
35 #include <SVTK_ViewWindow.h>
36 #include <SALOME_Actor.h>
37 #include <SUIT_Desktop.h>
38 #include <SUIT_Session.h>
39 #include <SUIT_MessageBox.h>
40 #include <SUIT_ResourceMgr.h>
41 #include <LightApp_Application.h>
42 #include <SalomeApp_IntSpinBox.h>
43 #include <SalomeApp_DoubleSpinBox.h>
44 #include <SVTK_FontWidget.h>
45
46 #include <QGridLayout>
47 #include <QHBoxLayout>
48 #include <QVBoxLayout>
49 #include <QTabWidget>
50 #include <QRadioButton>
51 #include <QCheckBox>
52 #include <QLabel>
53 #include <QPushButton>
54 #include <QButtonGroup>
55 #include <QGroupBox>
56 #include <QLineEdit>
57
58 #define SURFACE_PRS_ID 0
59 #define CONTOUR_PRS_ID 1
60
61 //=======================================================================
62 //function : VisuGUI_Table3DPane
63 //purpose  :
64 //=======================================================================
65 VisuGUI_Table3DPane::VisuGUI_Table3DPane( QWidget* parent )
66   : QWidget( parent ),
67     myViewWindow( VISU::GetActiveViewWindow<SVTK_ViewWindow>() ),
68     myPrs( 0 ),
69     myInitFromPrs( false )
70 {
71   QGridLayout* topLayout = new QGridLayout( this );
72   topLayout->setMargin( 11 );
73   topLayout->setSpacing( 6 );
74
75   // scale
76   QLabel* scaleLabel = new QLabel( tr( "SCALE" ), this );
77   ScaleSpn = new SalomeApp_DoubleSpinBox( this );
78   VISU::initSpinBox( ScaleSpn, -1.e6, 1.e6, 0.1, "parametric_precision" );
79   // Presentation type
80   GBPrsTypeBox = new QGroupBox( tr( "PRESENTATION_TYPE" ), this );
81   GBPrsType = new QButtonGroup( GBPrsTypeBox );
82   QRadioButton* rb1 = new QRadioButton( tr( "SURFACE" ), GBPrsTypeBox );
83   QRadioButton* rb2 = new QRadioButton( tr( "CONTOUR" ), GBPrsTypeBox );
84   GBPrsType->addButton( rb1, SURFACE_PRS_ID );
85   GBPrsType->addButton( rb2, CONTOUR_PRS_ID );
86   QHBoxLayout* GBPrsTypeBoxLayout = new QHBoxLayout( GBPrsTypeBox );
87   GBPrsTypeBoxLayout->setMargin( 11 );
88   GBPrsTypeBoxLayout->setSpacing( 6 );
89   GBPrsTypeBoxLayout->addWidget( rb1 );
90   GBPrsTypeBoxLayout->addWidget( rb2 );
91   
92   // nb Contours
93   QLabel* nbContLabel = new QLabel( tr( "NUMBER_CONTOURS" ), this );
94   NbContoursSpn = new SalomeApp_IntSpinBox( this );
95   NbContoursSpn->setMinimum( 1 );
96   NbContoursSpn->setMaximum( 999 );
97   NbContoursSpn->setSingleStep( 1 );
98
99   topLayout->addWidget( scaleLabel,    0, 0 );
100   topLayout->addWidget( ScaleSpn,      0, 1 );
101   topLayout->addWidget( GBPrsTypeBox,  1, 0, 1, 2 );
102   topLayout->addWidget( nbContLabel,   2, 0 );
103   topLayout->addWidget( NbContoursSpn, 2, 1 );
104   topLayout->setRowStretch( 3, 5 );
105
106   // signals and slots connections
107
108   connect( GBPrsType, SIGNAL( buttonClicked( int ) ), this, SLOT( onPrsType( int ) ) );
109 }
110
111 //=======================================================================
112 //function : destructor
113 //purpose  :
114 //=======================================================================
115 VisuGUI_Table3DPane::~VisuGUI_Table3DPane()
116 {
117 }
118
119 //=======================================================================
120 //function : onPrsType
121 //purpose  :
122 //=======================================================================
123 void VisuGUI_Table3DPane::onPrsType( int id )
124 {
125   NbContoursSpn->setEnabled( id == CONTOUR_PRS_ID );
126 }
127
128 //=======================================================================
129 //function : storeToPrsObject
130 //purpose  :
131 //=======================================================================
132 int VisuGUI_Table3DPane::storeToPrsObject( VISU::PointMap3d_i* thePrs )
133 {
134   // scale
135   thePrs->SetScaleFactor( ScaleSpn->value() );
136
137   // prs type
138   thePrs->SetContourPrs( GBPrsType->checkedId() == CONTOUR_PRS_ID );
139
140   // nb contours
141   thePrs->SetNbOfContours( NbContoursSpn->value() );
142
143   return 1;
144 }
145
146 //=======================================================================
147 //function : GetPrs
148 //purpose  :
149 //=======================================================================
150 VISU::PointMap3d_i* VisuGUI_Table3DPane::GetPrs()
151 {
152   return myPrs;
153 }
154
155 //=======================================================================
156 //function : initFromPrsObject
157 //purpose  :
158 //=======================================================================
159 void VisuGUI_Table3DPane::initFromPrsObject( VISU::PointMap3d_i* thePrs )
160 {
161   myInitFromPrs = true;
162   myPrs = thePrs;
163
164   // scale
165   double aScale = thePrs->GetScaleFactor();
166   if (aScale<0)
167     aScale = 0;
168   ScaleSpn->setValue( aScale );
169
170   // prs type
171   int id = thePrs->GetIsContourPrs() ? CONTOUR_PRS_ID : SURFACE_PRS_ID;
172   GBPrsType->button( id )->setChecked( true );
173   onPrsType( id );
174
175   // nb contours
176   NbContoursSpn->setValue( thePrs->GetNbOfContours() );
177 }
178
179 //=======================================================================
180 //function : Table Scalar Bar
181 //purpose  :
182 //=======================================================================
183
184 VisuGUI_TableScalarBarPane::VisuGUI_TableScalarBarPane( QWidget* parent )
185   : QWidget( parent ), 
186     myBarPrs( 0 )
187 {
188   QGridLayout* topLayout = new QGridLayout( this );
189   topLayout->setSpacing( 6 );
190   topLayout->setMargin( 11 );
191
192   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
193   QString propertyName;
194   propertyName = QString( "scalar_bar_vertical_" );
195   myVerX  = aResourceMgr->doubleValue(  "VISU", propertyName + "x", 0. );
196   myVerY  = aResourceMgr->doubleValue(  "VISU", propertyName + "y", 0. );
197   myVerW  = aResourceMgr->doubleValue(  "VISU", propertyName + "width",  0. );
198   myVerH  = aResourceMgr->doubleValue(  "VISU", propertyName + "height", 0. );
199   myVerTS = aResourceMgr->integerValue( "VISU", propertyName + "title_size",  0 );
200   myVerLS = aResourceMgr->integerValue( "VISU", propertyName + "label_size",  0 );
201   myVerBW = aResourceMgr->integerValue( "VISU", propertyName + "bar_width",  0 );
202   myVerBH = aResourceMgr->integerValue( "VISU", propertyName + "bar_height", 0 );
203
204   propertyName = QString( "scalar_bar_horizontal_" );
205   myHorX  = aResourceMgr->doubleValue(  "VISU", propertyName + "x", 0. );
206   myHorY  = aResourceMgr->doubleValue(  "VISU", propertyName + "y", 0. );
207   myHorW  = aResourceMgr->doubleValue(  "VISU", propertyName + "width",  0. );
208   myHorH  = aResourceMgr->doubleValue(  "VISU", propertyName + "height", 0. );
209   myHorTS = aResourceMgr->integerValue( "VISU", propertyName + "title_size",  0 );
210   myHorLS = aResourceMgr->integerValue( "VISU", propertyName + "label_size",  0 );
211   myHorBW = aResourceMgr->integerValue( "VISU", propertyName + "bar_width",  0 );
212   myHorBH = aResourceMgr->integerValue( "VISU", propertyName + "bar_height", 0 );
213
214   // Range ============================================================
215   RangeGroup = new QGroupBox( tr( "SCALAR_RANGE_GRP" ), this );
216   QButtonGroup* RangeRB = new QButtonGroup( RangeGroup );
217   QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup );
218   RangeGroupLayout->setSpacing( 6 );
219   RangeGroupLayout->setMargin( 11 );
220
221   CBLog = new QCheckBox( tr( "LOGARITHMIC_SCALING" ), RangeGroup );
222
223   RBFrange = new QRadioButton( tr( "FIELD_RANGE_BTN" ),   RangeGroup );
224   RBIrange = new QRadioButton( tr( "IMPOSED_RANGE_BTN" ), RangeGroup );
225   RangeRB->addButton( RBFrange, 0 );
226   RangeRB->addButton( RBIrange, 1 );
227   RBFrange->setChecked( true );
228
229   MinEdit = new QLineEdit( RangeGroup );
230   MinEdit->setMinimumWidth( 70 );
231   MinEdit->setValidator( new QDoubleValidator( this ) );
232   MinEdit->setText( "0.0" );
233   QLabel* MinLabel = new QLabel( tr( "LBL_MIN" ), RangeGroup );
234   MinLabel->setBuddy( MinEdit );
235
236   MaxEdit = new QLineEdit( RangeGroup );
237   MaxEdit->setMinimumWidth( 70 );
238   MaxEdit->setValidator( new QDoubleValidator( this ) );
239   MaxEdit->setText( "0.0" );
240   QLabel* MaxLabel = new QLabel( tr( "LBL_MAX" ), RangeGroup );
241   MaxLabel->setBuddy( MaxEdit );
242
243   RangeGroupLayout->addWidget( CBLog,    1, 0, 1, 4 );
244   RangeGroupLayout->addWidget( RBFrange, 2, 0, 1, 2 );
245   RangeGroupLayout->addWidget( RBIrange, 2, 2, 1, 2 );
246   RangeGroupLayout->addWidget( MinLabel, 3, 0 );
247   RangeGroupLayout->addWidget( MinEdit,  3, 1 );
248   RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
249   RangeGroupLayout->addWidget( MaxEdit,  3, 3 );
250
251   // Colors and Labels ========================================================
252   QGroupBox* ColLabGroup = new QGroupBox( tr( "COLORS_LABELS_GRP" ), this );
253   QHBoxLayout* ColLabGroupLayout = new QHBoxLayout( ColLabGroup );
254   ColLabGroupLayout->setSpacing( 6 );
255   ColLabGroupLayout->setMargin( 11 );
256
257   QLabel* ColorLabel = new QLabel( tr( "LBL_NB_COLORS" ), ColLabGroup );
258   ColorSpin = new SalomeApp_IntSpinBox( ColLabGroup );
259   ColorSpin->setMinimum( 2 );
260   ColorSpin->setMaximum( 256 );
261   ColorSpin->setSingleStep( 1 );
262   ColorSpin->setMinimumWidth( 70 );
263   ColorSpin->setValue( 64 );
264
265   QLabel* LabelLabel = new QLabel( tr( "LBL_NB_LABELS" ), ColLabGroup );
266   LabelSpin = new SalomeApp_IntSpinBox( ColLabGroup );
267   LabelSpin->setMinimum( 2 );
268   LabelSpin->setMaximum( 65 );
269   LabelSpin->setSingleStep( 1 );
270   LabelSpin->setMinimumWidth( 70 );
271   LabelSpin->setValue( 5 );
272
273   ColLabGroupLayout->addWidget( ColorLabel );
274   ColLabGroupLayout->addWidget( ColorSpin );
275   ColLabGroupLayout->addWidget( LabelLabel );
276   ColLabGroupLayout->addWidget( LabelSpin );
277
278   // Orientation ==========================================================
279   QGroupBox* OrientGroup = new QGroupBox( tr( "ORIENTATION_GRP" ), this );
280   QButtonGroup* OrientRB = new QButtonGroup( OrientGroup );
281   QHBoxLayout* OrientGroupLayout = new QHBoxLayout( OrientGroup );
282   OrientGroupLayout->setSpacing( 6 );
283   OrientGroupLayout->setMargin( 11 );
284
285   RBvert = new QRadioButton( tr( "VERTICAL_BTN" ), OrientGroup );
286   RBhori = new QRadioButton( tr( "HORIZONTAL_BTN" ), OrientGroup );
287   OrientRB->addButton( RBvert, 0 );
288   OrientRB->addButton( RBhori, 1 );
289   RBvert->setChecked( true );
290   OrientGroupLayout->addWidget( RBvert );
291   OrientGroupLayout->addWidget( RBhori );
292
293   // Origin ===============================================================
294   QGroupBox* OriginGroup = new QGroupBox( tr( "ORIGIN_GRP" ), this );
295   QHBoxLayout* OriginGroupLayout = new QHBoxLayout( OriginGroup );
296   OriginGroupLayout->setSpacing( 6 );
297   OriginGroupLayout->setMargin( 11 );
298
299   QLabel* XLabel = new QLabel( tr( "LBL_X" ), OriginGroup );
300   XSpin = new SalomeApp_DoubleSpinBox( OriginGroup );
301   VISU::initSpinBox( XSpin, 0.0, 1.0, 0.1, "parametric_precision" );
302   XSpin->setMinimumWidth( 70 );
303   XSpin->setValue( 0.01 );
304
305   QLabel* YLabel = new QLabel( tr( "LBL_Y" ), OriginGroup );
306   YSpin = new SalomeApp_DoubleSpinBox( OriginGroup );
307   VISU::initSpinBox( YSpin, 0.0, 1.0, 0.1, "parametric_precision" );
308   YSpin->setMinimumWidth( 70 );
309   YSpin->setValue( 0.1 );
310
311   OriginGroupLayout->addWidget( XLabel );
312   OriginGroupLayout->addWidget( XSpin );
313   OriginGroupLayout->addWidget( YLabel );
314   OriginGroupLayout->addWidget( YSpin );
315
316   // Dimensions =========================================================
317   QGroupBox* DimGroup = new QGroupBox( tr( "DIMENSIONS_GRP" ), this );
318   QHBoxLayout* DimGroupLayout = new QHBoxLayout( DimGroup );
319   DimGroupLayout->setSpacing( 6 );
320   DimGroupLayout->setMargin( 11 );
321
322   QLabel* WidthLabel = new QLabel( tr( "LBL_WIDTH" ), DimGroup );
323   WidthSpin = new SalomeApp_DoubleSpinBox( DimGroup );
324   VISU::initSpinBox( WidthSpin, 0.0, 1.0, 0.1, "parametric_precision" );
325   WidthSpin->setMinimumWidth( 70 );
326   WidthSpin->setValue( 0.1 );
327
328   QLabel* HeightLabel = new QLabel( tr( "LBL_HEIGHT" ), DimGroup );
329   HeightSpin = new SalomeApp_DoubleSpinBox( DimGroup );
330   VISU::initSpinBox( HeightSpin, 0.0, 1.0, 0.1, "parametric_precision" );
331   HeightSpin->setMinimumWidth( 70 );
332   HeightSpin->setValue( 0.8 );
333
334   DimGroupLayout->addWidget( WidthLabel );
335   DimGroupLayout->addWidget( WidthSpin );
336   DimGroupLayout->addWidget( HeightLabel );
337   DimGroupLayout->addWidget( HeightSpin );
338
339   myTextBtn = new QPushButton( tr( "Text properties..." ), this );
340   myBarBtn  = new QPushButton( tr( "Bar properties..." ), this );
341
342   // main layout =========================================================
343
344   topLayout->addWidget( RangeGroup,  0, 0, 1, 2 );
345   topLayout->addWidget( ColLabGroup, 1, 0, 1, 2 );
346   topLayout->addWidget( OrientGroup, 2, 0, 1, 2 );
347   topLayout->addWidget( OriginGroup, 3, 0, 1, 2 );
348   topLayout->addWidget( DimGroup,    4, 0, 1, 2 );
349   topLayout->addWidget( myTextBtn,   5, 0 );
350   topLayout->addWidget( myBarBtn,    5, 1 );
351
352   // init ================================================================
353
354   myTextDlg = new VisuGUI_TextPrefDlg( this );
355   myTextDlg->setTitleVisible( true );
356   myBarDlg = new VisuGUI_BarPrefDlg( this );
357
358   if ( RBvert->isChecked() ) {
359     myBarDlg->setRatios( myVerTS, myVerLS, myVerBW, myVerBH );
360   } else {
361     myBarDlg->setRatios( myHorTS, myHorLS, myHorBW, myHorBH );
362   }
363
364   int lp = aResourceMgr->integerValue( "VISU", propertyName + "scalar_bar_label_precision", 3 );
365   myBarDlg->setLabelsPrecision( lp );
366
367   myBarDlg->setUnitsVisible( aResourceMgr->booleanValue( "VISU", propertyName + "display_units", true ) );
368
369   // signals and slots connections ===========================================
370   connect( RangeRB,      SIGNAL( buttonClicked( int ) ),   this, SLOT( changeRange( int ) ) );
371   connect( OrientRB,     SIGNAL( buttonClicked( int ) ),   this, SLOT( changeDefaults( int ) ) );
372   connect( XSpin,        SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
373   connect( YSpin,        SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
374   connect( myTextBtn,    SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
375   connect( myBarBtn,     SIGNAL( clicked() ), this, SLOT( onBarPref() ) );
376   changeDefaults( 0 );
377   myIsStoreTextProp = true;
378   myBusy = false;
379 }
380
381 //----------------------------------------------------------------------------
382
383 void VisuGUI_TableScalarBarPane::onBarPref()
384 {
385   if ( RBvert->isChecked() )
386     myBarDlg->setRatios( myVerTS, myVerLS, myVerBW, myVerBH );
387   else
388     myBarDlg->setRatios( myHorTS, myHorLS, myHorBW, myHorBH );
389   if ( myBarDlg->exec() ) {
390     if ( RBvert->isChecked() )
391       myBarDlg->getRatios( myVerTS, myVerLS, myVerBW, myVerBH );
392     else
393       myBarDlg->getRatios( myHorTS, myHorLS, myHorBW, myHorBH );
394   }
395 }
396
397 //----------------------------------------------------------------------------
398 /**
399  * Initialise dialog box from presentation object
400  */
401 void VisuGUI_TableScalarBarPane::initFromPrsObject( VISU::PointMap3d_i* thePrs )
402 {
403   myBarPrs = dynamic_cast<VISU::PointMap3d_i*>( thePrs );
404   
405   if ( !myBarPrs )
406     return;
407
408   switch ( myBarPrs->GetScaling() ) {
409   case VISU::LOGARITHMIC:
410     CBLog->setChecked( true );
411     break;
412   default:
413     CBLog->setChecked( false );
414   }
415
416   setRange( myBarPrs->GetMin(), myBarPrs->GetMax(), myBarPrs->IsRangeFixed() );
417
418   setScalarBarData( myBarPrs->GetNbColors(), myBarPrs->GetLabels() );
419
420   // "Title"
421   CORBA::String_var aTitle = myBarPrs->GetTitle();
422   myTextDlg->setTitleText( aTitle.in() );
423   myTitle = aTitle.in();
424
425   vtkFloatingPointType R, G, B;
426   myBarPrs->GetTitleColor( R, G, B );
427
428   setPosAndSize( myBarPrs->GetPosX(),
429                  myBarPrs->GetPosY(),
430                  myBarPrs->GetWidth(),
431                  myBarPrs->GetHeight(),
432                  myBarPrs->GetBarOrientation() );
433   
434   myVerTS = myBarPrs->GetTitleSize();
435   myVerLS = myBarPrs->GetLabelSize();
436   myVerBW = myBarPrs->GetBarWidth();
437   myVerBH = myBarPrs->GetBarHeight();
438   myBarDlg->setRatios( myVerTS, myVerLS, myVerBW, myVerBH );
439
440   myBarDlg->setLabelsPrecision( VISU::ToPrecision( myBarPrs->GetLabelsFormat() ) );
441   myBarDlg->setUnitsVisible( myBarPrs->IsUnitsVisible() );
442
443   myTextDlg->myTitleFont->SetData( QColor( (int)(R*255.), (int)(G*255.), (int)(B*255.) ),
444                                    myBarPrs->GetTitFontType(),
445                                    myBarPrs->IsBoldTitle(),
446                                    myBarPrs->IsItalicTitle(),
447                                    myBarPrs->IsShadowTitle() );
448
449   // "Labels"
450   myBarPrs->GetLabelColor( R, G, B );
451
452   myTextDlg->myLabelFont->SetData( QColor( (int)(R*255.), (int)(G*255.), (int)(B*255.) ),
453                                    myBarPrs->GetLblFontType(),
454                                    myBarPrs->IsBoldLabel(),
455                                    myBarPrs->IsItalicLabel(),
456                                    myBarPrs->IsShadowLabel() );
457 }
458
459 //----------------------------------------------------------------------------
460 /**
461  * Store values to presentation object
462  */
463 int VisuGUI_TableScalarBarPane::storeToPrsObject( VISU::PointMap3d_i* thePrs ) {
464   if( !myBarPrs )
465     return 0;
466
467   myBarPrs->SetPosition( XSpin->value(), YSpin->value() );
468   myBarPrs->SetSize( WidthSpin->value(), HeightSpin->value() );
469
470   if(RBvert->isChecked()) {
471     myBarPrs->SetRatios(myVerTS, myVerLS, myVerBW, myVerBH);
472   } else {
473     myBarPrs->SetRatios(myHorTS, myHorLS, myHorBW, myHorBH);
474   }
475
476   std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() );
477   myBarPrs->SetLabelsFormat( f.c_str() );
478   myBarPrs->SetUnitsVisible( myBarDlg->isUnitsVisible() );
479
480   myBarPrs->SetBarOrientation( ( RBvert->isChecked() )? VISU::ColoredPrs3dBase::VERTICAL : VISU::ColoredPrs3dBase::HORIZONTAL );
481   if ( CBLog->isChecked() )
482     myBarPrs->SetScaling( VISU::LOGARITHMIC );
483   else
484     myBarPrs->SetScaling( VISU::LINEAR );
485
486   if ( RBFrange->isChecked() ) {
487     myBarPrs->SetSourceRange();
488   } else {
489     myBarPrs->SetRange( MinEdit->text().toDouble(), MaxEdit->text().toDouble() );
490   }
491   myBarPrs->SetNbColors( ColorSpin->value() );
492   myBarPrs->SetLabels( LabelSpin->value() );
493
494   if ( myIsStoreTextProp ) {
495     // "Title"
496     myBarPrs->SetTitle( myTextDlg->getTitleText().toLatin1().constData() );
497
498     QColor aTitColor( 255, 255, 255 );
499     int aTitleFontFamily = VTK_ARIAL;
500     bool isTitleBold = false;
501     bool isTitleItalic = false;
502     bool isTitleShadow = false;
503
504     myTextDlg->myTitleFont->GetData( aTitColor, aTitleFontFamily, isTitleBold, isTitleItalic, isTitleShadow );
505
506     myBarPrs->SetBoldTitle( isTitleBold );
507     myBarPrs->SetItalicTitle( isTitleItalic );
508     myBarPrs->SetShadowTitle( isTitleShadow );
509     myBarPrs->SetTitFontType( aTitleFontFamily );
510     myBarPrs->SetTitleColor( aTitColor.red()/255.,
511                              aTitColor.green()/255.,
512                              aTitColor.blue()/255. );
513
514     // "Label"
515     QColor aLblColor( 255, 255, 255 );
516     int aLabelFontFamily = VTK_ARIAL;
517     bool isLabelBold = false;
518     bool isLabelItalic = false;
519     bool isLabelShadow = false;
520
521     myTextDlg->myLabelFont->GetData( aLblColor, aLabelFontFamily, isLabelBold, isLabelItalic, isLabelShadow );
522
523     myBarPrs->SetBoldLabel( isLabelBold);
524     myBarPrs->SetItalicLabel( isLabelItalic );
525     myBarPrs->SetShadowLabel( isLabelShadow );
526     myBarPrs->SetLblFontType( aLabelFontFamily );
527     myBarPrs->SetLabelColor( aLblColor.red()/255.,
528                              aLblColor.green()/255.,
529                              aLblColor.blue()/255. );
530     //    myIsStoreTextProp = false;
531   }
532   return 1;
533 }
534
535 //----------------------------------------------------------------------------
536 /*!
537   Sets default values and range mode
538 */
539 void VisuGUI_TableScalarBarPane::setRange( double imin, double imax, bool sbRange )
540 {
541   MinEdit->setText( QString::number( imin ) );
542   MaxEdit->setText( QString::number( imax ) );
543
544   if ( sbRange )
545     RBIrange->setChecked( true );
546   else
547     RBFrange->setChecked( true );
548
549   changeRange( sbRange );
550 }
551
552 //----------------------------------------------------------------------------
553 /*!
554   Called when Range mode is changed
555 */
556 void VisuGUI_TableScalarBarPane::changeRange( int )
557 {
558   if ( RBFrange->isChecked() ) {
559     myBarPrs->SetSourceRange();
560     MinEdit->setEnabled( false );
561     MaxEdit->setEnabled( false );
562   } else {
563     myBarPrs->SetRange( myBarPrs->GetMin(), myBarPrs->GetMax() );
564     myBarPrs->SetRange( MinEdit->text().toDouble(), MaxEdit->text().toDouble() );
565     MinEdit->setEnabled( true );
566     MaxEdit->setEnabled( true );
567   }
568
569   MinEdit->setText( QString::number( myBarPrs->GetMin() ) );
570   MaxEdit->setText( QString::number( myBarPrs->GetMax() ) );
571 }
572
573 //----------------------------------------------------------------------------
574 /*!
575   Called when X,Y position is changed
576 */
577 void VisuGUI_TableScalarBarPane::XYChanged( double )
578 {
579   SalomeApp_DoubleSpinBox* snd = (SalomeApp_DoubleSpinBox*)sender();
580   if ( snd == XSpin ) {
581     WidthSpin->setMaximum( 1.0 - XSpin->value() );
582   }
583   if ( snd == YSpin ) {
584     HeightSpin->setMaximum( 1.0 - YSpin->value() );
585   }
586 }
587
588 //----------------------------------------------------------------------------
589 /*!
590   
591 */
592 void VisuGUI_TableScalarBarPane::changeScalarMode( int )
593 {
594 //do nothing
595 }
596
597 //----------------------------------------------------------------------------
598 /*!
599   Sets size and position
600 */
601 void VisuGUI_TableScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
602 {
603   if ( vert ) {
604     myVerX = x;
605     myVerY = y;
606     myVerW = w;
607     myVerH = h;
608     RBvert->setChecked( true );
609   }
610   else {
611     myHorX = x;
612     myHorY = y;
613     myHorW = w;
614     myHorH = h;
615     RBhori->setChecked( true );
616   }
617   changeDefaults( 0 );
618 }
619
620 //----------------------------------------------------------------------------
621 /*!
622   Sets colors and labels number
623 */
624 void VisuGUI_TableScalarBarPane::setScalarBarData( int colors, int labels )
625 {
626   ColorSpin->setValue( colors );
627   LabelSpin->setValue( labels );
628 }
629
630 //----------------------------------------------------------------------------
631 void VisuGUI_TableScalarBarPane::onTextPref()
632 {
633   myTextDlg->storeBeginValues();
634   myIsStoreTextProp = myTextDlg->exec() || myIsStoreTextProp;
635 }
636
637 //----------------------------------------------------------------------------
638 VisuGUI_TableScalarBarPane::~VisuGUI_TableScalarBarPane()
639 {
640 }
641
642 //----------------------------------------------------------------------------
643 /*!
644   Called when orientation is changed
645 */
646 void VisuGUI_TableScalarBarPane::changeDefaults( int )
647 {
648   if ( RBvert->isChecked() ) {
649     XSpin->setValue( myVerX );
650     YSpin->setValue( myVerY );
651     WidthSpin->setValue( myVerW );
652     HeightSpin->setValue( myVerH );
653   }
654   else {
655     XSpin->setValue( myHorX );
656     YSpin->setValue( myHorY );
657     WidthSpin->setValue( myHorW );
658     HeightSpin->setValue( myHorH );
659   }
660 }
661
662 //=======================================================================
663 //function : Check
664 //purpose  : Called when <OK> button is clicked, validates data and closes dialog
665 //=======================================================================
666 bool VisuGUI_TableScalarBarPane::check()
667 {
668   double minVal = MinEdit->text().toDouble();
669   double maxVal = MaxEdit->text().toDouble();
670   if ( RBIrange->isChecked() ) {
671     if (minVal >= maxVal) {
672       SUIT_MessageBox::warning( this,tr("WRN_VISU"),
673                                 tr("MSG_MINMAX_VALUES") );
674       return false;
675     }
676   }
677
678   // check if logarithmic mode is on and check imposed range to not contain negative values
679   if ( CBLog->isChecked() ) {
680     if ( minVal <= 0.0 || maxVal <= 0.0) {
681       if ( RBIrange->isChecked() ) {
682         SUIT_MessageBox::warning( this,
683                                   tr("WRN_VISU"),
684                                   tr("WRN_LOGARITHMIC_RANGE") );
685       } else {
686         if ( minVal == 0)
687           SUIT_MessageBox::warning( this,
688                                     tr("WRN_VISU"),
689                                     tr("WRN_LOGARITHMIC_RANGE") );
690         else
691           SUIT_MessageBox::warning( this,
692                                     tr("WRN_VISU"),
693                                     tr("WRN_LOGARITHMIC_FIELD_RANGE") );
694         RBIrange->setChecked(true);
695         changeRange(1);
696       }
697       return false;
698     }
699   }
700   return true;
701 }
702
703 //=======================================================================
704 //function : Constructor
705 //purpose  :
706 //=======================================================================
707 VisuGUI_Table3DDlg::VisuGUI_Table3DDlg ( SalomeApp_Module* theModule )
708   : QDialog ( VISU::GetDesktop( theModule ) )
709 {
710   setModal( false );
711   setWindowTitle( tr( "Point Map 3D Definition" ) );
712   setSizeGripEnabled( true );
713
714   QVBoxLayout* TopLayout = new QVBoxLayout( this );
715   TopLayout->setSpacing( 6 );
716   TopLayout->setMargin( 11 );
717
718   myTabBox = new QTabWidget( this );
719   myIsoPane = new VisuGUI_Table3DPane( this );
720   myScalarBarPane = new VisuGUI_TableScalarBarPane( this );
721
722   myTabBox->addTab( myIsoPane,       tr( "DLG_PREF_TITLE" ) );
723   myTabBox->addTab( myScalarBarPane, tr( "DLG_PROP_TITLE" ) );
724
725   QGroupBox* GroupButtons = new QGroupBox( this );
726   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
727   GroupButtonsLayout->setSpacing( 6 );
728   GroupButtonsLayout->setMargin( 11 );
729
730   QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons );
731   buttonOk->setAutoDefault( true );
732   buttonOk->setDefault( true );
733   QPushButton* buttonApply = new QPushButton( tr( "&Apply" ), GroupButtons );
734   buttonApply->setAutoDefault( true );
735   QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ), GroupButtons );
736   buttonCancel->setAutoDefault( true );
737   QPushButton* buttonHelp = new QPushButton( tr( "&Help" ), GroupButtons );
738   buttonHelp->setAutoDefault( true );
739
740   GroupButtonsLayout->addWidget( buttonOk );
741   GroupButtonsLayout->addWidget( buttonApply );
742   GroupButtonsLayout->addSpacing( 10 );
743   GroupButtonsLayout->addStretch();
744   GroupButtonsLayout->addWidget( buttonCancel );
745   GroupButtonsLayout->addWidget( buttonHelp );
746
747   TopLayout->addWidget( myTabBox );
748   TopLayout->addWidget( GroupButtons );
749
750   // signals and slots connections
751   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
752   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
753   connect( buttonHelp,   SIGNAL( clicked() ), this, SLOT( onHelp() ) );
754   connect( buttonApply,  SIGNAL( clicked() ), this, SLOT( onApply() ) );
755 }
756
757 //=======================================================================
758 //function : Destructor
759 //purpose  :
760 //=======================================================================
761 VisuGUI_Table3DDlg::~VisuGUI_Table3DDlg()
762 {
763 }
764
765 //=======================================================================
766 //function : accept
767 //purpose  :
768 //=======================================================================
769 void VisuGUI_Table3DDlg::accept()
770 {
771   if (myScalarBarPane->check())
772     QDialog::accept();
773 }
774
775 //=======================================================================
776 //function : onApply
777 //purpose  :
778 //=======================================================================
779 void VisuGUI_Table3DDlg::onApply()
780 {
781   if (myScalarBarPane->check()) {
782     storeToPrsObject( myPrsCopy );
783     myPrsCopy->UpdateActors();
784   }
785 }
786
787 //=======================================================================
788 //function : onHelp
789 //purpose  :
790 //=======================================================================
791 void VisuGUI_Table3DDlg::onHelp()
792 {
793   QString aHelpFileName = "table_3d_page.html";
794   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
795   if (app) {
796     VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
797     app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
798   }
799   else {
800     QString platform;
801 #ifdef WIN32
802     platform = "winapplication";
803 #else
804     platform = "application";
805 #endif
806     SUIT_MessageBox::warning( this, QObject::tr("WRN_WARNING"),
807                               tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
808                               arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName) );
809   }
810
811 }
812
813 //=======================================================================
814 //function : storeToPrsObject
815 //purpose  :
816 //=======================================================================
817 int VisuGUI_Table3DDlg::storeToPrsObject( VISU::PointMap3d_i* thePrs )
818 {
819   int anIsOk = myIsoPane->storeToPrsObject( thePrs );
820   anIsOk &= myScalarBarPane->storeToPrsObject( thePrs );
821
822   return anIsOk;
823 }
824
825 //=======================================================================
826 //function : initFromPrsObject
827 //purpose  :
828 //=======================================================================
829 void VisuGUI_Table3DDlg::initFromPrsObject( VISU::PointMap3d_i* thePrs )
830 {
831   myPrsCopy = thePrs;
832   myIsoPane->initFromPrsObject( thePrs );
833   myScalarBarPane->initFromPrsObject( thePrs );
834 }