1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // VISU VISUGUI : GUI of VISU component
23 // File : VisuGUI_Table3dDlg.cxx
24 // Author : Laurent CORNABE & Hubert ROLLAND
26 #include "VisuGUI_Table3dDlg.h"
29 #include "VisuGUI_Tools.h"
30 #include "VisuGUI_ViewTools.h"
31 #include "VisuGUI_InputPane.h"
33 #include "VISU_ColoredPrs3dFactory.hh"
34 #include "VISU_ViewManager_i.hh"
35 #include "VISU_Prs3dUtils.hh"
37 #include <SVTK_ViewWindow.h>
38 #include <SALOME_Actor.h>
39 #include <SUIT_Desktop.h>
40 #include <SUIT_Session.h>
41 #include <SUIT_MessageBox.h>
42 #include <SUIT_ResourceMgr.h>
43 #include <LightApp_Application.h>
44 #include <SVTK_FontWidget.h>
45 #include <QtxDoubleSpinBox.h>
47 #include <QGridLayout>
48 #include <QHBoxLayout>
49 #include <QVBoxLayout>
51 #include <QRadioButton>
55 #include <QPushButton>
56 #include <QButtonGroup>
60 #define SURFACE_PRS_ID 0
61 #define CONTOUR_PRS_ID 1
63 //=======================================================================
64 //function : VisuGUI_Table3DPane
66 //=======================================================================
67 VisuGUI_Table3DPane::VisuGUI_Table3DPane( QWidget* parent )
69 myViewWindow( VISU::GetActiveViewWindow<SVTK_ViewWindow>() ),
71 myInitFromPrs( false )
73 QGridLayout* topLayout = new QGridLayout( this );
74 topLayout->setMargin( 11 );
75 topLayout->setSpacing( 6 );
78 QLabel* scaleLabel = new QLabel( tr( "SCALE" ), this );
79 ScaleSpn = new QtxDoubleSpinBox( -1.e6, 1.e6, 0.1, this );
81 GBPrsTypeBox = new QGroupBox( tr( "PRESENTATION_TYPE" ), this );
82 GBPrsType = new QButtonGroup( GBPrsTypeBox );
83 QRadioButton* rb1 = new QRadioButton( tr( "SURFACE" ), GBPrsTypeBox );
84 QRadioButton* rb2 = new QRadioButton( tr( "CONTOUR" ), GBPrsTypeBox );
85 GBPrsType->addButton( rb1, SURFACE_PRS_ID );
86 GBPrsType->addButton( rb2, CONTOUR_PRS_ID );
87 QHBoxLayout* GBPrsTypeBoxLayout = new QHBoxLayout( GBPrsTypeBox );
88 GBPrsTypeBoxLayout->setMargin( 11 );
89 GBPrsTypeBoxLayout->setSpacing( 6 );
90 GBPrsTypeBoxLayout->addWidget( rb1 );
91 GBPrsTypeBoxLayout->addWidget( rb2 );
94 QLabel* nbContLabel = new QLabel( tr( "NUMBER_CONTOURS" ), this );
95 NbContoursSpn = new QSpinBox( this );
96 NbContoursSpn->setMinimum( 1 );
97 NbContoursSpn->setMaximum( 999 );
98 NbContoursSpn->setSingleStep( 1 );
100 topLayout->addWidget( scaleLabel, 0, 0 );
101 topLayout->addWidget( ScaleSpn, 0, 1 );
102 topLayout->addWidget( GBPrsTypeBox, 1, 0, 1, 2 );
103 topLayout->addWidget( nbContLabel, 2, 0 );
104 topLayout->addWidget( NbContoursSpn, 2, 1 );
105 topLayout->setRowStretch( 3, 5 );
107 // signals and slots connections
109 connect( GBPrsType, SIGNAL( buttonClicked( int ) ), this, SLOT( onPrsType( int ) ) );
112 //=======================================================================
113 //function : destructor
115 //=======================================================================
116 VisuGUI_Table3DPane::~VisuGUI_Table3DPane()
120 //=======================================================================
121 //function : onPrsType
123 //=======================================================================
124 void VisuGUI_Table3DPane::onPrsType( int id )
126 NbContoursSpn->setEnabled( id == CONTOUR_PRS_ID );
129 //=======================================================================
130 //function : storeToPrsObject
132 //=======================================================================
133 int VisuGUI_Table3DPane::storeToPrsObject( VISU::PointMap3d_i* thePrs )
136 thePrs->SetScaleFactor( ScaleSpn->value() );
139 thePrs->SetContourPrs( GBPrsType->checkedId() == CONTOUR_PRS_ID );
142 thePrs->SetNbOfContours( NbContoursSpn->value() );
147 //=======================================================================
150 //=======================================================================
151 VISU::PointMap3d_i* VisuGUI_Table3DPane::GetPrs()
156 //=======================================================================
157 //function : initFromPrsObject
159 //=======================================================================
160 void VisuGUI_Table3DPane::initFromPrsObject( VISU::PointMap3d_i* thePrs )
162 myInitFromPrs = true;
166 double aScale = thePrs->GetScaleFactor();
169 ScaleSpn->setValue( aScale );
172 int id = thePrs->GetIsContourPrs() ? CONTOUR_PRS_ID : SURFACE_PRS_ID;
173 GBPrsType->button( id )->setChecked( true );
177 NbContoursSpn->setValue( thePrs->GetNbOfContours() );
180 //=======================================================================
181 //function : Table Scalar Bar
183 //=======================================================================
185 VisuGUI_TableScalarBarPane::VisuGUI_TableScalarBarPane( QWidget* parent )
189 QGridLayout* topLayout = new QGridLayout( this );
190 topLayout->setSpacing( 6 );
191 topLayout->setMargin( 11 );
193 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
194 QString propertyName;
195 propertyName = QString( "scalar_bar_vertical_" );
196 myVerX = aResourceMgr->doubleValue( "VISU", propertyName + "x", 0. );
197 myVerY = aResourceMgr->doubleValue( "VISU", propertyName + "y", 0. );
198 myVerW = aResourceMgr->doubleValue( "VISU", propertyName + "width", 0. );
199 myVerH = aResourceMgr->doubleValue( "VISU", propertyName + "height", 0. );
200 myVerTS = aResourceMgr->integerValue( "VISU", propertyName + "title_size", 0 );
201 myVerLS = aResourceMgr->integerValue( "VISU", propertyName + "label_size", 0 );
202 myVerBW = aResourceMgr->integerValue( "VISU", propertyName + "bar_width", 0 );
203 myVerBH = aResourceMgr->integerValue( "VISU", propertyName + "bar_height", 0 );
205 propertyName = QString( "scalar_bar_horizontal_" );
206 myHorX = aResourceMgr->doubleValue( "VISU", propertyName + "x", 0. );
207 myHorY = aResourceMgr->doubleValue( "VISU", propertyName + "y", 0. );
208 myHorW = aResourceMgr->doubleValue( "VISU", propertyName + "width", 0. );
209 myHorH = aResourceMgr->doubleValue( "VISU", propertyName + "height", 0. );
210 myHorTS = aResourceMgr->integerValue( "VISU", propertyName + "title_size", 0 );
211 myHorLS = aResourceMgr->integerValue( "VISU", propertyName + "label_size", 0 );
212 myHorBW = aResourceMgr->integerValue( "VISU", propertyName + "bar_width", 0 );
213 myHorBH = aResourceMgr->integerValue( "VISU", propertyName + "bar_height", 0 );
215 // Range ============================================================
216 RangeGroup = new QGroupBox( tr( "SCALAR_RANGE_GRP" ), this );
217 QButtonGroup* RangeRB = new QButtonGroup( RangeGroup );
218 QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup );
219 RangeGroupLayout->setSpacing( 6 );
220 RangeGroupLayout->setMargin( 11 );
222 CBLog = new QCheckBox( tr( "LOGARITHMIC_SCALING" ), RangeGroup );
224 RBFrange = new QRadioButton( tr( "FIELD_RANGE_BTN" ), RangeGroup );
225 RBIrange = new QRadioButton( tr( "IMPOSED_RANGE_BTN" ), RangeGroup );
226 RangeRB->addButton( RBFrange, 0 );
227 RangeRB->addButton( RBIrange, 1 );
228 RBFrange->setChecked( true );
230 MinEdit = new QLineEdit( RangeGroup );
231 MinEdit->setMinimumWidth( 70 );
232 MinEdit->setValidator( new QDoubleValidator( this ) );
233 MinEdit->setText( "0.0" );
234 QLabel* MinLabel = new QLabel( tr( "LBL_MIN" ), RangeGroup );
235 MinLabel->setBuddy( MinEdit );
237 MaxEdit = new QLineEdit( RangeGroup );
238 MaxEdit->setMinimumWidth( 70 );
239 MaxEdit->setValidator( new QDoubleValidator( this ) );
240 MaxEdit->setText( "0.0" );
241 QLabel* MaxLabel = new QLabel( tr( "LBL_MAX" ), RangeGroup );
242 MaxLabel->setBuddy( MaxEdit );
244 RangeGroupLayout->addWidget( CBLog, 1, 0, 1, 4 );
245 RangeGroupLayout->addWidget( RBFrange, 2, 0, 1, 2 );
246 RangeGroupLayout->addWidget( RBIrange, 2, 2, 1, 2 );
247 RangeGroupLayout->addWidget( MinLabel, 3, 0 );
248 RangeGroupLayout->addWidget( MinEdit, 3, 1 );
249 RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
250 RangeGroupLayout->addWidget( MaxEdit, 3, 3 );
252 // Colors and Labels ========================================================
253 QGroupBox* ColLabGroup = new QGroupBox( tr( "COLORS_LABELS_GRP" ), this );
254 QHBoxLayout* ColLabGroupLayout = new QHBoxLayout( ColLabGroup );
255 ColLabGroupLayout->setSpacing( 6 );
256 ColLabGroupLayout->setMargin( 11 );
258 QLabel* ColorLabel = new QLabel( tr( "LBL_NB_COLORS" ), ColLabGroup );
259 ColorSpin = new QSpinBox( ColLabGroup );
260 ColorSpin->setMinimum( 2 );
261 ColorSpin->setMaximum( 256 );
262 ColorSpin->setSingleStep( 1 );
263 ColorSpin->setMinimumWidth( 70 );
264 ColorSpin->setValue( 64 );
266 QLabel* LabelLabel = new QLabel( tr( "LBL_NB_LABELS" ), ColLabGroup );
267 LabelSpin = new QSpinBox( ColLabGroup );
268 LabelSpin->setMinimum( 2 );
269 LabelSpin->setMaximum( 65 );
270 LabelSpin->setSingleStep( 1 );
271 LabelSpin->setMinimumWidth( 70 );
272 LabelSpin->setValue( 5 );
274 ColLabGroupLayout->addWidget( ColorLabel );
275 ColLabGroupLayout->addWidget( ColorSpin );
276 ColLabGroupLayout->addWidget( LabelLabel );
277 ColLabGroupLayout->addWidget( LabelSpin );
279 // Orientation ==========================================================
280 QGroupBox* OrientGroup = new QGroupBox( tr( "ORIENTATION_GRP" ), this );
281 QButtonGroup* OrientRB = new QButtonGroup( OrientGroup );
282 QHBoxLayout* OrientGroupLayout = new QHBoxLayout( OrientGroup );
283 OrientGroupLayout->setSpacing( 6 );
284 OrientGroupLayout->setMargin( 11 );
286 RBvert = new QRadioButton( tr( "VERTICAL_BTN" ), OrientGroup );
287 RBhori = new QRadioButton( tr( "HORIZONTAL_BTN" ), OrientGroup );
288 OrientRB->addButton( RBvert, 0 );
289 OrientRB->addButton( RBhori, 1 );
290 RBvert->setChecked( true );
291 OrientGroupLayout->addWidget( RBvert );
292 OrientGroupLayout->addWidget( RBhori );
294 // Origin ===============================================================
295 QGroupBox* OriginGroup = new QGroupBox( tr( "ORIGIN_GRP" ), this );
296 QHBoxLayout* OriginGroupLayout = new QHBoxLayout( OriginGroup );
297 OriginGroupLayout->setSpacing( 6 );
298 OriginGroupLayout->setMargin( 11 );
300 QLabel* XLabel = new QLabel( tr( "LBL_X" ), OriginGroup );
301 XSpin = new QtxDoubleSpinBox( 0.0, 1.0, 0.1, OriginGroup );
302 XSpin->setMinimumWidth( 70 );
303 XSpin->setValue( 0.01 );
305 QLabel* YLabel = new QLabel( tr( "LBL_Y" ), OriginGroup );
306 YSpin = new QtxDoubleSpinBox( 0.0, 1.0, 0.1, OriginGroup );
307 YSpin->setMinimumWidth( 70 );
308 YSpin->setValue( 0.1 );
310 OriginGroupLayout->addWidget( XLabel );
311 OriginGroupLayout->addWidget( XSpin );
312 OriginGroupLayout->addWidget( YLabel );
313 OriginGroupLayout->addWidget( YSpin );
315 // Dimensions =========================================================
316 QGroupBox* DimGroup = new QGroupBox( tr( "DIMENSIONS_GRP" ), this );
317 QHBoxLayout* DimGroupLayout = new QHBoxLayout( DimGroup );
318 DimGroupLayout->setSpacing( 6 );
319 DimGroupLayout->setMargin( 11 );
321 QLabel* WidthLabel = new QLabel( tr( "LBL_WIDTH" ), DimGroup );
322 WidthSpin = new QtxDoubleSpinBox( 0.0, 1.0, 0.1, DimGroup );
323 WidthSpin->setMinimumWidth( 70 );
324 WidthSpin->setValue( 0.1 );
326 QLabel* HeightLabel = new QLabel( tr( "LBL_HEIGHT" ), DimGroup );
327 HeightSpin = new QtxDoubleSpinBox( 0.0, 1.0, 0.1, DimGroup );
328 HeightSpin->setMinimumWidth( 70 );
329 HeightSpin->setValue( 0.8 );
331 DimGroupLayout->addWidget( WidthLabel );
332 DimGroupLayout->addWidget( WidthSpin );
333 DimGroupLayout->addWidget( HeightLabel );
334 DimGroupLayout->addWidget( HeightSpin );
336 myTextBtn = new QPushButton( tr( "Text properties..." ), this );
337 myBarBtn = new QPushButton( tr( "Bar properties..." ), this );
339 // main layout =========================================================
341 topLayout->addWidget( RangeGroup, 0, 0, 1, 2 );
342 topLayout->addWidget( ColLabGroup, 1, 0, 1, 2 );
343 topLayout->addWidget( OrientGroup, 2, 0, 1, 2 );
344 topLayout->addWidget( OriginGroup, 3, 0, 1, 2 );
345 topLayout->addWidget( DimGroup, 4, 0, 1, 2 );
346 topLayout->addWidget( myTextBtn, 5, 0 );
347 topLayout->addWidget( myBarBtn, 5, 1 );
349 // init ================================================================
351 myTextDlg = new VisuGUI_TextPrefDlg( this );
352 myTextDlg->setTitleVisible( true );
353 myBarDlg = new VisuGUI_BarPrefDlg( this );
355 if ( RBvert->isChecked() ) {
356 myBarDlg->setRatios( myVerTS, myVerLS, myVerBW, myVerBH );
358 myBarDlg->setRatios( myHorTS, myHorLS, myHorBW, myHorBH );
361 int lp = aResourceMgr->integerValue( "VISU", propertyName + "scalar_bar_label_precision", 3 );
362 myBarDlg->setLabelsPrecision( lp );
364 myBarDlg->setUnitsVisible( aResourceMgr->booleanValue( "VISU", propertyName + "display_units", true ) );
366 // signals and slots connections ===========================================
367 connect( RangeRB, SIGNAL( buttonClicked( int ) ), this, SLOT( changeRange( int ) ) );
368 connect( OrientRB, SIGNAL( buttonClicked( int ) ), this, SLOT( changeDefaults( int ) ) );
369 connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
370 connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
371 connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
372 connect( myBarBtn, SIGNAL( clicked() ), this, SLOT( onBarPref() ) );
374 myIsStoreTextProp = true;
378 //----------------------------------------------------------------------------
380 void VisuGUI_TableScalarBarPane::onBarPref()
382 if ( RBvert->isChecked() )
383 myBarDlg->setRatios( myVerTS, myVerLS, myVerBW, myVerBH );
385 myBarDlg->setRatios( myHorTS, myHorLS, myHorBW, myHorBH );
386 if ( myBarDlg->exec() ) {
387 if ( RBvert->isChecked() )
388 myBarDlg->getRatios( myVerTS, myVerLS, myVerBW, myVerBH );
390 myBarDlg->getRatios( myHorTS, myHorLS, myHorBW, myHorBH );
394 //----------------------------------------------------------------------------
396 * Initialise dialog box from presentation object
398 void VisuGUI_TableScalarBarPane::initFromPrsObject( VISU::PointMap3d_i* thePrs )
400 myBarPrs = dynamic_cast<VISU::PointMap3d_i*>( thePrs );
405 switch ( myBarPrs->GetScaling() ) {
406 case VISU::LOGARITHMIC:
407 CBLog->setChecked( true );
410 CBLog->setChecked( false );
413 setRange( myBarPrs->GetMin(), myBarPrs->GetMax(), myBarPrs->IsRangeFixed() );
415 setScalarBarData( myBarPrs->GetNbColors(), myBarPrs->GetLabels() );
418 CORBA::String_var aTitle = myBarPrs->GetTitle();
419 myTextDlg->setTitleText( aTitle.in() );
420 myTitle = aTitle.in();
422 vtkFloatingPointType R, G, B;
423 myBarPrs->GetTitleColor( R, G, B );
425 setPosAndSize( myBarPrs->GetPosX(),
427 myBarPrs->GetWidth(),
428 myBarPrs->GetHeight(),
429 myBarPrs->GetBarOrientation() );
431 myVerTS = myBarPrs->GetTitleSize();
432 myVerLS = myBarPrs->GetLabelSize();
433 myVerBW = myBarPrs->GetBarWidth();
434 myVerBH = myBarPrs->GetBarHeight();
435 myBarDlg->setRatios( myVerTS, myVerLS, myVerBW, myVerBH );
437 myBarDlg->setLabelsPrecision( VISU::ToPrecision( myBarPrs->GetLabelsFormat() ) );
438 myBarDlg->setUnitsVisible( myBarPrs->IsUnitsVisible() );
440 myTextDlg->myTitleFont->SetData( QColor( (int)(R*255.), (int)(G*255.), (int)(B*255.) ),
441 myBarPrs->GetTitFontType(),
442 myBarPrs->IsBoldTitle(),
443 myBarPrs->IsItalicTitle(),
444 myBarPrs->IsShadowTitle() );
447 myBarPrs->GetLabelColor( R, G, B );
449 myTextDlg->myLabelFont->SetData( QColor( (int)(R*255.), (int)(G*255.), (int)(B*255.) ),
450 myBarPrs->GetLblFontType(),
451 myBarPrs->IsBoldLabel(),
452 myBarPrs->IsItalicLabel(),
453 myBarPrs->IsShadowLabel() );
456 //----------------------------------------------------------------------------
458 * Store values to presentation object
460 int VisuGUI_TableScalarBarPane::storeToPrsObject( VISU::PointMap3d_i* thePrs ) {
464 myBarPrs->SetPosition( XSpin->value(), YSpin->value() );
465 myBarPrs->SetSize( WidthSpin->value(), HeightSpin->value() );
467 if(RBvert->isChecked()) {
468 myBarPrs->SetRatios(myVerTS, myVerLS, myVerBW, myVerBH);
470 myBarPrs->SetRatios(myHorTS, myHorLS, myHorBW, myHorBH);
473 std::string f = VISU::ToFormat( myBarDlg->getLabelsPrecision() );
474 myBarPrs->SetLabelsFormat( f.c_str() );
475 myBarPrs->SetUnitsVisible( myBarDlg->isUnitsVisible() );
477 myBarPrs->SetBarOrientation( ( RBvert->isChecked() )? VISU::ColoredPrs3dBase::VERTICAL : VISU::ColoredPrs3dBase::HORIZONTAL );
478 if ( CBLog->isChecked() )
479 myBarPrs->SetScaling( VISU::LOGARITHMIC );
481 myBarPrs->SetScaling( VISU::LINEAR );
483 if ( RBFrange->isChecked() ) {
484 myBarPrs->SetSourceRange();
486 myBarPrs->SetRange( MinEdit->text().toDouble(), MaxEdit->text().toDouble() );
488 myBarPrs->SetNbColors( ColorSpin->value() );
489 myBarPrs->SetLabels( LabelSpin->value() );
491 if ( myIsStoreTextProp ) {
493 myBarPrs->SetTitle( myTextDlg->getTitleText().toLatin1().constData() );
495 QColor aTitColor( 255, 255, 255 );
496 int aTitleFontFamily = VTK_ARIAL;
497 bool isTitleBold = false;
498 bool isTitleItalic = false;
499 bool isTitleShadow = false;
501 myTextDlg->myTitleFont->GetData( aTitColor, aTitleFontFamily, isTitleBold, isTitleItalic, isTitleShadow );
503 myBarPrs->SetBoldTitle( isTitleBold );
504 myBarPrs->SetItalicTitle( isTitleItalic );
505 myBarPrs->SetShadowTitle( isTitleShadow );
506 myBarPrs->SetTitFontType( aTitleFontFamily );
507 myBarPrs->SetTitleColor( aTitColor.red()/255.,
508 aTitColor.green()/255.,
509 aTitColor.blue()/255. );
512 QColor aLblColor( 255, 255, 255 );
513 int aLabelFontFamily = VTK_ARIAL;
514 bool isLabelBold = false;
515 bool isLabelItalic = false;
516 bool isLabelShadow = false;
518 myTextDlg->myLabelFont->GetData( aLblColor, aLabelFontFamily, isLabelBold, isLabelItalic, isLabelShadow );
520 myBarPrs->SetBoldLabel( isLabelBold);
521 myBarPrs->SetItalicLabel( isLabelItalic );
522 myBarPrs->SetShadowLabel( isLabelShadow );
523 myBarPrs->SetLblFontType( aLabelFontFamily );
524 myBarPrs->SetLabelColor( aLblColor.red()/255.,
525 aLblColor.green()/255.,
526 aLblColor.blue()/255. );
527 // myIsStoreTextProp = false;
532 //----------------------------------------------------------------------------
534 Sets default values and range mode
536 void VisuGUI_TableScalarBarPane::setRange( double imin, double imax, bool sbRange )
538 MinEdit->setText( QString::number( imin ) );
539 MaxEdit->setText( QString::number( imax ) );
542 RBIrange->setChecked( true );
544 RBFrange->setChecked( true );
546 changeRange( sbRange );
549 //----------------------------------------------------------------------------
551 Called when Range mode is changed
553 void VisuGUI_TableScalarBarPane::changeRange( int )
555 if ( RBFrange->isChecked() ) {
556 myBarPrs->SetSourceRange();
557 MinEdit->setEnabled( false );
558 MaxEdit->setEnabled( false );
560 myBarPrs->SetRange( myBarPrs->GetMin(), myBarPrs->GetMax() );
561 myBarPrs->SetRange( MinEdit->text().toDouble(), MaxEdit->text().toDouble() );
562 MinEdit->setEnabled( true );
563 MaxEdit->setEnabled( true );
566 MinEdit->setText( QString::number( myBarPrs->GetMin() ) );
567 MaxEdit->setText( QString::number( myBarPrs->GetMax() ) );
570 //----------------------------------------------------------------------------
572 Called when X,Y position is changed
574 void VisuGUI_TableScalarBarPane::XYChanged( double )
576 QtxDoubleSpinBox* snd = (QtxDoubleSpinBox*)sender();
577 if ( snd == XSpin ) {
578 WidthSpin->setMaximum( 1.0 - XSpin->value() );
580 if ( snd == YSpin ) {
581 HeightSpin->setMaximum( 1.0 - YSpin->value() );
585 //----------------------------------------------------------------------------
589 void VisuGUI_TableScalarBarPane::changeScalarMode( int )
594 //----------------------------------------------------------------------------
596 Sets size and position
598 void VisuGUI_TableScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
605 RBvert->setChecked( true );
612 RBhori->setChecked( true );
617 //----------------------------------------------------------------------------
619 Sets colors and labels number
621 void VisuGUI_TableScalarBarPane::setScalarBarData( int colors, int labels )
623 ColorSpin->setValue( colors );
624 LabelSpin->setValue( labels );
627 //----------------------------------------------------------------------------
628 void VisuGUI_TableScalarBarPane::onTextPref()
630 myTextDlg->storeBeginValues();
631 myIsStoreTextProp = myTextDlg->exec() || myIsStoreTextProp;
634 //----------------------------------------------------------------------------
635 VisuGUI_TableScalarBarPane::~VisuGUI_TableScalarBarPane()
639 //----------------------------------------------------------------------------
641 Called when orientation is changed
643 void VisuGUI_TableScalarBarPane::changeDefaults( int )
645 if ( RBvert->isChecked() ) {
646 XSpin->setValue( myVerX );
647 YSpin->setValue( myVerY );
648 WidthSpin->setValue( myVerW );
649 HeightSpin->setValue( myVerH );
652 XSpin->setValue( myHorX );
653 YSpin->setValue( myHorY );
654 WidthSpin->setValue( myHorW );
655 HeightSpin->setValue( myHorH );
659 //=======================================================================
661 //purpose : Called when <OK> button is clicked, validates data and closes dialog
662 //=======================================================================
663 bool VisuGUI_TableScalarBarPane::check()
665 double minVal = MinEdit->text().toDouble();
666 double maxVal = MaxEdit->text().toDouble();
667 if ( RBIrange->isChecked() ) {
668 if (minVal >= maxVal) {
669 SUIT_MessageBox::warning( this,tr("WRN_VISU"),
670 tr("MSG_MINMAX_VALUES") );
675 // check if logarithmic mode is on and check imposed range to not contain negative values
676 if ( CBLog->isChecked() ) {
677 if ( minVal <= 0.0 || maxVal <= 0.0) {
678 if ( RBIrange->isChecked() ) {
679 SUIT_MessageBox::warning( this,
681 tr("WRN_LOGARITHMIC_RANGE") );
684 SUIT_MessageBox::warning( this,
686 tr("WRN_LOGARITHMIC_RANGE") );
688 SUIT_MessageBox::warning( this,
690 tr("WRN_LOGARITHMIC_FIELD_RANGE") );
691 RBIrange->setChecked(true);
700 //=======================================================================
701 //function : Constructor
703 //=======================================================================
704 VisuGUI_Table3DDlg::VisuGUI_Table3DDlg ( SalomeApp_Module* theModule )
705 : QDialog ( VISU::GetDesktop( theModule ) )
708 setWindowTitle( tr( "Point Map 3D Definition" ) );
709 setSizeGripEnabled( true );
711 QVBoxLayout* TopLayout = new QVBoxLayout( this );
712 TopLayout->setSpacing( 6 );
713 TopLayout->setMargin( 11 );
715 myTabBox = new QTabWidget( this );
716 myIsoPane = new VisuGUI_Table3DPane( this );
717 myScalarBarPane = new VisuGUI_TableScalarBarPane( this );
719 myTabBox->addTab( myIsoPane, tr( "DLG_PREF_TITLE" ) );
720 myTabBox->addTab( myScalarBarPane, tr( "DLG_PROP_TITLE" ) );
722 QGroupBox* GroupButtons = new QGroupBox( this );
723 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
724 GroupButtonsLayout->setSpacing( 6 );
725 GroupButtonsLayout->setMargin( 11 );
727 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons );
728 buttonOk->setAutoDefault( true );
729 buttonOk->setDefault( true );
730 QPushButton* buttonApply = new QPushButton( tr( "&Apply" ), GroupButtons );
731 buttonApply->setAutoDefault( true );
732 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ), GroupButtons );
733 buttonCancel->setAutoDefault( true );
734 QPushButton* buttonHelp = new QPushButton( tr( "&Help" ), GroupButtons );
735 buttonHelp->setAutoDefault( true );
737 GroupButtonsLayout->addWidget( buttonOk );
738 GroupButtonsLayout->addWidget( buttonApply );
739 GroupButtonsLayout->addSpacing( 10 );
740 GroupButtonsLayout->addStretch();
741 GroupButtonsLayout->addWidget( buttonCancel );
742 GroupButtonsLayout->addWidget( buttonHelp );
744 TopLayout->addWidget( myTabBox );
745 TopLayout->addWidget( GroupButtons );
747 // signals and slots connections
748 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
749 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
750 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
751 connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onApply() ) );
754 //=======================================================================
755 //function : Destructor
757 //=======================================================================
758 VisuGUI_Table3DDlg::~VisuGUI_Table3DDlg()
762 //=======================================================================
765 //=======================================================================
766 void VisuGUI_Table3DDlg::accept()
768 if (myScalarBarPane->check())
772 //=======================================================================
775 //=======================================================================
776 void VisuGUI_Table3DDlg::onApply()
778 if (myScalarBarPane->check()) {
779 storeToPrsObject( myPrsCopy );
780 myPrsCopy->UpdateActors();
784 //=======================================================================
787 //=======================================================================
788 void VisuGUI_Table3DDlg::onHelp()
790 QString aHelpFileName = "table_3d_page.html";
791 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
793 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
794 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
799 platform = "winapplication";
801 platform = "application";
803 SUIT_MessageBox::warning( this, QObject::tr("WRN_WARNING"),
804 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
805 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName) );
810 //=======================================================================
811 //function : storeToPrsObject
813 //=======================================================================
814 int VisuGUI_Table3DDlg::storeToPrsObject( VISU::PointMap3d_i* thePrs )
816 int anIsOk = myIsoPane->storeToPrsObject( thePrs );
817 anIsOk &= myScalarBarPane->storeToPrsObject( thePrs );
822 //=======================================================================
823 //function : initFromPrsObject
825 //=======================================================================
826 void VisuGUI_Table3DDlg::initFromPrsObject( VISU::PointMap3d_i* thePrs )
829 myIsoPane->initFromPrsObject( thePrs );
830 myScalarBarPane->initFromPrsObject( thePrs );