1 // Copyright (C) 2007-2013 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
23 // File : Plot2d_SetupCurveScaleDlg.cxx
25 #include "Plot2d_SetupCurveScaleDlg.h"
27 #include <SUIT_Tools.h>
30 #include <QHBoxLayout>
31 #include <QVBoxLayout>
33 #include <QPushButton>
35 #include <QtxDoubleSpinBox.h>
37 const int MARGIN_SIZE = 11;
38 const int SPACING_SIZE = 6;
39 const int MIN_COMBO_WIDTH = 100;
40 const int MIN_SPIN_WIDTH = 50;
43 \class Plot2d_SetupCurveScaleDlg
44 \brief Dialog box for modifying 2d curve scale factor.
49 \param parent parent widget
51 Plot2d_SetupCurveScaleDlg::Plot2d_SetupCurveScaleDlg( /*curveList lst, */QWidget* parent )
55 setWindowTitle( tr("TLT_SETUP_CURVE_SCALE") );
56 setSizeGripEnabled( true );
58 /************************************************************************/
59 QGroupBox* GroupC1 = new QGroupBox( this );
60 QHBoxLayout* GroupC1Layout = new QHBoxLayout( GroupC1 );
61 GroupC1Layout->setSpacing( SPACING_SIZE );
62 GroupC1Layout->setMargin( MARGIN_SIZE );
64 QLabel* aScaleLab = new QLabel( tr( "CURVE_SCALE_FACTOR" ), GroupC1 );
65 myValueSpin = new QtxDoubleSpinBox( GroupC1 );
66 myValueSpin->setMinimum( 0.01 );
67 myValueSpin->setSingleStep( 0.1 );
68 myValueSpin->setMinimumWidth( MIN_SPIN_WIDTH );
70 GroupC1Layout->addWidget( aScaleLab );
71 GroupC1Layout->addWidget( myValueSpin );
73 /************************************************************************/
74 QGroupBox* GroupButtons = new QGroupBox( this );
75 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
76 GroupButtonsLayout->setSpacing( SPACING_SIZE );
77 GroupButtonsLayout->setMargin( MARGIN_SIZE );
79 myOkBtn = new QPushButton( tr( "BUT_OK" ), this );
80 myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this );
82 GroupButtonsLayout->addWidget( myOkBtn );
83 GroupButtonsLayout->addSpacing( 10 );
84 GroupButtonsLayout->addWidget( myCancelBtn );
86 /************************************************************************/
87 QVBoxLayout* topLayout = new QVBoxLayout( this );
88 topLayout->setSpacing( SPACING_SIZE );
89 topLayout->setMargin( MARGIN_SIZE );
90 topLayout->addWidget( GroupC1 );
91 topLayout->addWidget( GroupButtons );
94 setScale( 1.0 ); // no scale
97 connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
98 connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
100 SUIT_Tools::centerWidget( this, parent );
106 Plot2d_SetupCurveScaleDlg::~Plot2d_SetupCurveScaleDlg()
111 \brief Set scale factor.
112 \param coef scale factor
115 void Plot2d_SetupCurveScaleDlg::setScale( const double coef )
117 if ( coef > myValueSpin->maximum() ){
118 myValueSpin->setMaximum( coef );
120 myValueSpin->setValue( coef );
124 \brief Get scale factor.
125 \return chosen scale factor
128 double Plot2d_SetupCurveScaleDlg::getScale() const
130 return myValueSpin->value();
133 \brief Clear value in the "Scale factor" spinbox.
135 void Plot2d_SetupCurveScaleDlg::setUndefinedValue() {
136 myValueSpin->setCleared(true);
137 myValueSpin->setSpecialValueText("");