Back to index

salome-gui  6.5.0
Plot2d_SetupCurveScaleDlg.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // File   : Plot2d_SetupCurveScaleDlg.cxx
00024 //
00025 #include "Plot2d_SetupCurveScaleDlg.h"
00026 
00027 #include <SUIT_Tools.h>
00028 
00029 #include <QGroupBox>
00030 #include <QHBoxLayout>
00031 #include <QVBoxLayout>
00032 #include <QLabel>
00033 #include <QPushButton>
00034 
00035 #include <QtxDoubleSpinBox.h>
00036 
00037 const int MARGIN_SIZE     = 11;
00038 const int SPACING_SIZE    = 6;
00039 const int MIN_COMBO_WIDTH = 100;
00040 const int MIN_SPIN_WIDTH  = 50;
00041 
00051 Plot2d_SetupCurveScaleDlg::Plot2d_SetupCurveScaleDlg( /*curveList lst, */QWidget* parent )
00052 : QDialog( parent )
00053 {
00054   setModal( true );
00055   setWindowTitle( tr("TLT_SETUP_CURVE_SCALE") );
00056   setSizeGripEnabled( true );
00057 
00058   /************************************************************************/
00059   QGroupBox* GroupC1 = new QGroupBox( this );
00060   QHBoxLayout* GroupC1Layout = new QHBoxLayout( GroupC1 );
00061   GroupC1Layout->setSpacing( SPACING_SIZE );
00062   GroupC1Layout->setMargin( MARGIN_SIZE );
00063 
00064   QLabel* aScaleLab = new QLabel( tr( "CURVE_SCALE_FACTOR" ), GroupC1 );
00065   myValueSpin = new QtxDoubleSpinBox( GroupC1 );
00066   myValueSpin->setMinimum( 0.01 );
00067   myValueSpin->setSingleStep( 0.1 );
00068   myValueSpin->setMinimumWidth( MIN_SPIN_WIDTH );
00069 
00070   GroupC1Layout->addWidget( aScaleLab );
00071   GroupC1Layout->addWidget( myValueSpin );
00072 
00073   /************************************************************************/
00074   QGroupBox* GroupButtons = new QGroupBox( this );
00075   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
00076   GroupButtonsLayout->setSpacing( SPACING_SIZE );
00077   GroupButtonsLayout->setMargin( MARGIN_SIZE );
00078 
00079   myOkBtn     = new QPushButton( tr( "BUT_OK" ),     this );
00080   myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this );
00081 
00082   GroupButtonsLayout->addWidget( myOkBtn );
00083   GroupButtonsLayout->addSpacing( 10 );
00084   GroupButtonsLayout->addWidget( myCancelBtn );
00085 
00086   /************************************************************************/
00087   QVBoxLayout* topLayout = new QVBoxLayout( this );
00088   topLayout->setSpacing( SPACING_SIZE );
00089   topLayout->setMargin( MARGIN_SIZE );
00090   topLayout->addWidget( GroupC1 );
00091   topLayout->addWidget( GroupButtons );
00092  
00093   // default settings
00094   setScale( 1.0 );   // no scale
00095 
00096   // connections
00097   connect( myOkBtn,       SIGNAL( clicked() ),           this, SLOT( accept() ) );
00098   connect( myCancelBtn,   SIGNAL( clicked() ),           this, SLOT( reject() ) );
00099 
00100   SUIT_Tools::centerWidget( this, parent );
00101 }
00102 
00106 Plot2d_SetupCurveScaleDlg::~Plot2d_SetupCurveScaleDlg()
00107 {
00108 }
00109 
00115 void Plot2d_SetupCurveScaleDlg::setScale( const double coef )
00116 {
00117   if ( coef > myValueSpin->maximum() ){
00118     myValueSpin->setMaximum( coef );
00119   }
00120   myValueSpin->setValue( coef );
00121 }
00122 
00128 double Plot2d_SetupCurveScaleDlg::getScale() const
00129 {
00130   return myValueSpin->value();
00131 }
00135 void Plot2d_SetupCurveScaleDlg::setUndefinedValue() {
00136   myValueSpin->setCleared(true);
00137   myValueSpin->setSpecialValueText("");
00138 }