1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // VISU VISUGUI : GUI of VISU component
21 // File : VisuGUI_Table3dDlg.cxx
22 // Author : Laurent CORNABE & Hubert ROLLAND
24 #include "VisuGUI_Table3dDlg.h"
27 #include "VisuGUI_Tools.h"
28 #include "VisuGUI_ViewTools.h"
29 #include "VisuGUI_InputPane.h"
31 #include "VISU_ColoredPrs3dFactory.hh"
32 #include "VISU_ViewManager_i.hh"
33 #include "VISU_Prs3dUtils.hh"
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>
46 #include <QGridLayout>
47 #include <QHBoxLayout>
48 #include <QVBoxLayout>
50 #include <QRadioButton>
53 #include <QPushButton>
54 #include <QButtonGroup>
58 #define SURFACE_PRS_ID 0
59 #define CONTOUR_PRS_ID 1
61 //=======================================================================
62 //function : VisuGUI_Table3DPane
64 //=======================================================================
65 VisuGUI_Table3DPane::VisuGUI_Table3DPane( QWidget* parent )
67 myViewWindow( VISU::GetActiveViewWindow<SVTK_ViewWindow>() ),
69 myInitFromPrs( false )
71 QGridLayout* topLayout = new QGridLayout( this );
72 topLayout->setMargin( 11 );
73 topLayout->setSpacing( 6 );
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" );
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 );
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 );
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 );
106 // signals and slots connections
108 connect( GBPrsType, SIGNAL( buttonClicked( int ) ), this, SLOT( onPrsType( int ) ) );
111 //=======================================================================
112 //function : destructor
114 //=======================================================================
115 VisuGUI_Table3DPane::~VisuGUI_Table3DPane()
119 //=======================================================================
120 //function : onPrsType
122 //=======================================================================
123 void VisuGUI_Table3DPane::onPrsType( int id )
125 NbContoursSpn->setEnabled( id == CONTOUR_PRS_ID );
128 //=======================================================================
129 //function : storeToPrsObject
131 //=======================================================================
132 int VisuGUI_Table3DPane::storeToPrsObject( VISU::PointMap3d_i* thePrs )
135 thePrs->SetScaleFactor( ScaleSpn->value() );
138 thePrs->SetContourPrs( GBPrsType->checkedId() == CONTOUR_PRS_ID );
141 thePrs->SetNbOfContours( NbContoursSpn->value() );
146 //=======================================================================
149 //=======================================================================
150 VISU::PointMap3d_i* VisuGUI_Table3DPane::GetPrs()
155 //=======================================================================
156 //function : initFromPrsObject
158 //=======================================================================
159 void VisuGUI_Table3DPane::initFromPrsObject( VISU::PointMap3d_i* thePrs )
161 myInitFromPrs = true;
165 double aScale = thePrs->GetScaleFactor();
168 ScaleSpn->setValue( aScale );
171 int id = thePrs->GetIsContourPrs() ? CONTOUR_PRS_ID : SURFACE_PRS_ID;
172 GBPrsType->button( id )->setChecked( true );
176 NbContoursSpn->setValue( thePrs->GetNbOfContours() );
179 //=======================================================================
180 //function : Table Scalar Bar
182 //=======================================================================
184 VisuGUI_TableScalarBarPane::VisuGUI_TableScalarBarPane( QWidget* parent )
188 QGridLayout* topLayout = new QGridLayout( this );
189 topLayout->setSpacing( 6 );
190 topLayout->setMargin( 11 );
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 );
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 );
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 );
221 CBLog = new QCheckBox( tr( "LOGARITHMIC_SCALING" ), RangeGroup );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
273 ColLabGroupLayout->addWidget( ColorLabel );
274 ColLabGroupLayout->addWidget( ColorSpin );
275 ColLabGroupLayout->addWidget( LabelLabel );
276 ColLabGroupLayout->addWidget( LabelSpin );
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 );
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 );
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 );
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 );
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 );
311 OriginGroupLayout->addWidget( XLabel );
312 OriginGroupLayout->addWidget( XSpin );
313 OriginGroupLayout->addWidget( YLabel );
314 OriginGroupLayout->addWidget( YSpin );
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 );
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 );
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 );
334 DimGroupLayout->addWidget( WidthLabel );
335 DimGroupLayout->addWidget( WidthSpin );
336 DimGroupLayout->addWidget( HeightLabel );
337 DimGroupLayout->addWidget( HeightSpin );
339 myTextBtn = new QPushButton( tr( "Text properties..." ), this );
340 myBarBtn = new QPushButton( tr( "Bar properties..." ), this );
342 // main layout =========================================================
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 );
352 // init ================================================================
354 myTextDlg = new VisuGUI_TextPrefDlg( this );
355 myTextDlg->setTitleVisible( true );
356 myBarDlg = new VisuGUI_BarPrefDlg( this );
358 if ( RBvert->isChecked() ) {
359 myBarDlg->setRatios( myVerTS, myVerLS, myVerBW, myVerBH );
361 myBarDlg->setRatios( myHorTS, myHorLS, myHorBW, myHorBH );
364 int lp = aResourceMgr->integerValue( "VISU", propertyName + "scalar_bar_label_precision", 3 );
365 myBarDlg->setLabelsPrecision( lp );
367 myBarDlg->setUnitsVisible( aResourceMgr->booleanValue( "VISU", propertyName + "display_units", true ) );
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() ) );
377 myIsStoreTextProp = true;
381 //----------------------------------------------------------------------------
383 void VisuGUI_TableScalarBarPane::onBarPref()
385 if ( RBvert->isChecked() )
386 myBarDlg->setRatios( myVerTS, myVerLS, myVerBW, myVerBH );
388 myBarDlg->setRatios( myHorTS, myHorLS, myHorBW, myHorBH );
389 if ( myBarDlg->exec() ) {
390 if ( RBvert->isChecked() )
391 myBarDlg->getRatios( myVerTS, myVerLS, myVerBW, myVerBH );
393 myBarDlg->getRatios( myHorTS, myHorLS, myHorBW, myHorBH );
397 //----------------------------------------------------------------------------
399 * Initialise dialog box from presentation object
401 void VisuGUI_TableScalarBarPane::initFromPrsObject( VISU::PointMap3d_i* thePrs )
403 myBarPrs = dynamic_cast<VISU::PointMap3d_i*>( thePrs );
408 switch ( myBarPrs->GetScaling() ) {
409 case VISU::LOGARITHMIC:
410 CBLog->setChecked( true );
413 CBLog->setChecked( false );
416 setRange( myBarPrs->GetMin(), myBarPrs->GetMax(), myBarPrs->IsRangeFixed() );
418 setScalarBarData( myBarPrs->GetNbColors(), myBarPrs->GetLabels() );
421 CORBA::String_var aTitle = myBarPrs->GetTitle();
422 myTextDlg->setTitleText( aTitle.in() );
423 myTitle = aTitle.in();
425 vtkFloatingPointType R, G, B;
426 myBarPrs->GetTitleColor( R, G, B );
428 setPosAndSize( myBarPrs->GetPosX(),
430 myBarPrs->GetWidth(),
431 myBarPrs->GetHeight(),
432 myBarPrs->GetBarOrientation() );
434 myVerTS = myBarPrs->GetTitleSize();
435 myVerLS = myBarPrs->GetLabelSize();
436 myVerBW = myBarPrs->GetBarWidth();
437 myVerBH = myBarPrs->GetBarHeight();
438 myBarDlg->setRatios( myVerTS, myVerLS, myVerBW, myVerBH );
440 myBarDlg->setLabelsPrecision( VISU::ToPrecision( myBarPrs->GetLabelsFormat() ) );
441 myBarDlg->setUnitsVisible( myBarPrs->IsUnitsVisible() );
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() );
450 myBarPrs->GetLabelColor( R, G, B );
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() );
459 //----------------------------------------------------------------------------
461 * Store values to presentation object
463 int VisuGUI_TableScalarBarPane::storeToPrsObject( VISU::PointMap3d_i* thePrs ) {
467 myBarPrs->SetPosition( XSpin->value(), YSpin->value() );
468 myBarPrs->SetSize( WidthSpin->value(), HeightSpin->value() );
470 if(RBvert->isChecked()) {
471 myBarPrs->SetRatios(myVerTS, myVerLS, myVerBW, myVerBH);
473 myBarPrs->SetRatios(myHorTS, myHorLS, myHorBW, myHorBH);
476 std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() );
477 myBarPrs->SetLabelsFormat( f.c_str() );
478 myBarPrs->SetUnitsVisible( myBarDlg->isUnitsVisible() );
480 myBarPrs->SetBarOrientation( ( RBvert->isChecked() )? VISU::ColoredPrs3dBase::VERTICAL : VISU::ColoredPrs3dBase::HORIZONTAL );
481 if ( CBLog->isChecked() )
482 myBarPrs->SetScaling( VISU::LOGARITHMIC );
484 myBarPrs->SetScaling( VISU::LINEAR );
486 if ( RBFrange->isChecked() ) {
487 myBarPrs->SetSourceRange();
489 myBarPrs->SetRange( MinEdit->text().toDouble(), MaxEdit->text().toDouble() );
491 myBarPrs->SetNbColors( ColorSpin->value() );
492 myBarPrs->SetLabels( LabelSpin->value() );
494 if ( myIsStoreTextProp ) {
496 myBarPrs->SetTitle( myTextDlg->getTitleText().toLatin1().constData() );
498 QColor aTitColor( 255, 255, 255 );
499 int aTitleFontFamily = VTK_ARIAL;
500 bool isTitleBold = false;
501 bool isTitleItalic = false;
502 bool isTitleShadow = false;
504 myTextDlg->myTitleFont->GetData( aTitColor, aTitleFontFamily, isTitleBold, isTitleItalic, isTitleShadow );
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. );
515 QColor aLblColor( 255, 255, 255 );
516 int aLabelFontFamily = VTK_ARIAL;
517 bool isLabelBold = false;
518 bool isLabelItalic = false;
519 bool isLabelShadow = false;
521 myTextDlg->myLabelFont->GetData( aLblColor, aLabelFontFamily, isLabelBold, isLabelItalic, isLabelShadow );
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;
535 //----------------------------------------------------------------------------
537 Sets default values and range mode
539 void VisuGUI_TableScalarBarPane::setRange( double imin, double imax, bool sbRange )
541 MinEdit->setText( QString::number( imin ) );
542 MaxEdit->setText( QString::number( imax ) );
545 RBIrange->setChecked( true );
547 RBFrange->setChecked( true );
549 changeRange( sbRange );
552 //----------------------------------------------------------------------------
554 Called when Range mode is changed
556 void VisuGUI_TableScalarBarPane::changeRange( int )
558 if ( RBFrange->isChecked() ) {
559 myBarPrs->SetSourceRange();
560 MinEdit->setEnabled( false );
561 MaxEdit->setEnabled( false );
563 myBarPrs->SetRange( myBarPrs->GetMin(), myBarPrs->GetMax() );
564 myBarPrs->SetRange( MinEdit->text().toDouble(), MaxEdit->text().toDouble() );
565 MinEdit->setEnabled( true );
566 MaxEdit->setEnabled( true );
569 MinEdit->setText( QString::number( myBarPrs->GetMin() ) );
570 MaxEdit->setText( QString::number( myBarPrs->GetMax() ) );
573 //----------------------------------------------------------------------------
575 Called when X,Y position is changed
577 void VisuGUI_TableScalarBarPane::XYChanged( double )
579 SalomeApp_DoubleSpinBox* snd = (SalomeApp_DoubleSpinBox*)sender();
580 if ( snd == XSpin ) {
581 WidthSpin->setMaximum( 1.0 - XSpin->value() );
583 if ( snd == YSpin ) {
584 HeightSpin->setMaximum( 1.0 - YSpin->value() );
588 //----------------------------------------------------------------------------
592 void VisuGUI_TableScalarBarPane::changeScalarMode( int )
597 //----------------------------------------------------------------------------
599 Sets size and position
601 void VisuGUI_TableScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
608 RBvert->setChecked( true );
615 RBhori->setChecked( true );
620 //----------------------------------------------------------------------------
622 Sets colors and labels number
624 void VisuGUI_TableScalarBarPane::setScalarBarData( int colors, int labels )
626 ColorSpin->setValue( colors );
627 LabelSpin->setValue( labels );
630 //----------------------------------------------------------------------------
631 void VisuGUI_TableScalarBarPane::onTextPref()
633 myTextDlg->storeBeginValues();
634 myIsStoreTextProp = myTextDlg->exec() || myIsStoreTextProp;
637 //----------------------------------------------------------------------------
638 VisuGUI_TableScalarBarPane::~VisuGUI_TableScalarBarPane()
642 //----------------------------------------------------------------------------
644 Called when orientation is changed
646 void VisuGUI_TableScalarBarPane::changeDefaults( int )
648 if ( RBvert->isChecked() ) {
649 XSpin->setValue( myVerX );
650 YSpin->setValue( myVerY );
651 WidthSpin->setValue( myVerW );
652 HeightSpin->setValue( myVerH );
655 XSpin->setValue( myHorX );
656 YSpin->setValue( myHorY );
657 WidthSpin->setValue( myHorW );
658 HeightSpin->setValue( myHorH );
662 //=======================================================================
664 //purpose : Called when <OK> button is clicked, validates data and closes dialog
665 //=======================================================================
666 bool VisuGUI_TableScalarBarPane::check()
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") );
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,
684 tr("WRN_LOGARITHMIC_RANGE") );
687 SUIT_MessageBox::warning( this,
689 tr("WRN_LOGARITHMIC_RANGE") );
691 SUIT_MessageBox::warning( this,
693 tr("WRN_LOGARITHMIC_FIELD_RANGE") );
694 RBIrange->setChecked(true);
703 //=======================================================================
704 //function : Constructor
706 //=======================================================================
707 VisuGUI_Table3DDlg::VisuGUI_Table3DDlg ( SalomeApp_Module* theModule )
708 : QDialog ( VISU::GetDesktop( theModule ) )
711 setWindowTitle( tr( "Point Map 3D Definition" ) );
712 setSizeGripEnabled( true );
714 QVBoxLayout* TopLayout = new QVBoxLayout( this );
715 TopLayout->setSpacing( 6 );
716 TopLayout->setMargin( 11 );
718 myTabBox = new QTabWidget( this );
719 myIsoPane = new VisuGUI_Table3DPane( this );
720 myScalarBarPane = new VisuGUI_TableScalarBarPane( this );
722 myTabBox->addTab( myIsoPane, tr( "DLG_PREF_TITLE" ) );
723 myTabBox->addTab( myScalarBarPane, tr( "DLG_PROP_TITLE" ) );
725 QGroupBox* GroupButtons = new QGroupBox( this );
726 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
727 GroupButtonsLayout->setSpacing( 6 );
728 GroupButtonsLayout->setMargin( 11 );
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 );
740 GroupButtonsLayout->addWidget( buttonOk );
741 GroupButtonsLayout->addWidget( buttonApply );
742 GroupButtonsLayout->addSpacing( 10 );
743 GroupButtonsLayout->addStretch();
744 GroupButtonsLayout->addWidget( buttonCancel );
745 GroupButtonsLayout->addWidget( buttonHelp );
747 TopLayout->addWidget( myTabBox );
748 TopLayout->addWidget( GroupButtons );
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() ) );
757 //=======================================================================
758 //function : Destructor
760 //=======================================================================
761 VisuGUI_Table3DDlg::~VisuGUI_Table3DDlg()
765 //=======================================================================
768 //=======================================================================
769 void VisuGUI_Table3DDlg::accept()
771 if (myScalarBarPane->check())
775 //=======================================================================
778 //=======================================================================
779 void VisuGUI_Table3DDlg::onApply()
781 if (myScalarBarPane->check()) {
782 storeToPrsObject( myPrsCopy );
783 myPrsCopy->UpdateActors();
787 //=======================================================================
790 //=======================================================================
791 void VisuGUI_Table3DDlg::onHelp()
793 QString aHelpFileName = "table_3d_page.html";
794 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
796 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
797 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
802 platform = "winapplication";
804 platform = "application";
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) );
813 //=======================================================================
814 //function : storeToPrsObject
816 //=======================================================================
817 int VisuGUI_Table3DDlg::storeToPrsObject( VISU::PointMap3d_i* thePrs )
819 int anIsOk = myIsoPane->storeToPrsObject( thePrs );
820 anIsOk &= myScalarBarPane->storeToPrsObject( thePrs );
825 //=======================================================================
826 //function : initFromPrsObject
828 //=======================================================================
829 void VisuGUI_Table3DDlg::initFromPrsObject( VISU::PointMap3d_i* thePrs )
832 myIsoPane->initFromPrsObject( thePrs );
833 myScalarBarPane->initFromPrsObject( thePrs );