Salome HOME
Updated copyright comment
[modules/gui.git] / src / Plot2d / Plot2d_SetupCurveScaleDlg.cxx
1 // Copyright (C) 2007-2024  CEA, EDF, 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, or (at your option) any later version.
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
23 // File   : Plot2d_SetupCurveScaleDlg.cxx
24 //
25 #include "Plot2d_SetupCurveScaleDlg.h"
26
27 #include <SUIT_Tools.h>
28
29 #include <QGroupBox>
30 #include <QHBoxLayout>
31 #include <QVBoxLayout>
32 #include <QLabel>
33 #include <QPushButton>
34
35 #include <QtxDoubleSpinBox.h>
36
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;
41
42 /*!
43   \class Plot2d_SetupCurveScaleDlg
44   \brief Dialog box for modifying 2d curve scale factor.
45 */
46
47 /*!
48   \brief Constructor.
49   \param parent parent widget
50 */
51 Plot2d_SetupCurveScaleDlg::Plot2d_SetupCurveScaleDlg( /*curveList lst, */QWidget* parent )
52 : QDialog( parent )
53 {
54   setModal( true );
55   setWindowTitle( tr("TLT_SETUP_CURVE_SCALE") );
56   setSizeGripEnabled( true );
57
58   /************************************************************************/
59   QGroupBox* GroupC1 = new QGroupBox( this );
60   QHBoxLayout* GroupC1Layout = new QHBoxLayout( GroupC1 );
61   GroupC1Layout->setSpacing( SPACING_SIZE );
62   GroupC1Layout->setMargin( MARGIN_SIZE );
63
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 );
69
70   GroupC1Layout->addWidget( aScaleLab );
71   GroupC1Layout->addWidget( myValueSpin );
72
73   /************************************************************************/
74   QGroupBox* GroupButtons = new QGroupBox( this );
75   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
76   GroupButtonsLayout->setSpacing( SPACING_SIZE );
77   GroupButtonsLayout->setMargin( MARGIN_SIZE );
78
79   myOkBtn     = new QPushButton( tr( "BUT_OK" ),     this );
80   myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this );
81
82   GroupButtonsLayout->addWidget( myOkBtn );
83   GroupButtonsLayout->addSpacing( 10 );
84   GroupButtonsLayout->addWidget( myCancelBtn );
85
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 );
92  
93   // default settings
94   setScale( 1.0 );   // no scale
95
96   // connections
97   connect( myOkBtn,       SIGNAL( clicked() ),           this, SLOT( accept() ) );
98   connect( myCancelBtn,   SIGNAL( clicked() ),           this, SLOT( reject() ) );
99
100   SUIT_Tools::centerWidget( this, parent );
101 }
102
103 /*!
104   \brief Destructor.
105 */
106 Plot2d_SetupCurveScaleDlg::~Plot2d_SetupCurveScaleDlg()
107 {
108 }
109
110 /*!
111   \brief Set scale factor.
112   \param coef scale factor
113   \sa getScale()
114 */
115 void Plot2d_SetupCurveScaleDlg::setScale( const double coef )
116 {
117   if ( coef > myValueSpin->maximum() ){
118     myValueSpin->setMaximum( coef );
119   }
120   myValueSpin->setValue( coef );
121 }
122
123 /*!
124   \brief Get scale factor.
125   \return chosen scale factor
126   \sa setScale()
127 */
128 double Plot2d_SetupCurveScaleDlg::getScale() const
129 {
130   return myValueSpin->value();
131 }
132 /*!
133   \brief Clear value in the "Scale factor" spinbox.
134 */
135 void Plot2d_SetupCurveScaleDlg::setUndefinedValue() {
136   myValueSpin->setCleared(true);
137   myValueSpin->setSpecialValueText("");
138 }