Salome HOME
NRI : merge from 1.2c
[modules/visu.git] / src / VISUGUI / VisuGUI_PartialScaDlg.cxx
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2003  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. 
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : VisuGUI_PartialScaDlg.cxx
25 //  Author : Laurent CORNABE & Hubert ROLLAND 
26 //  Module : VISU
27 //  $Header$
28
29 using namespace std;
30 #include "VisuGUI_PartialScaDlg.h"
31
32 #include <qgroupbox.h>
33 #include <qlabel.h>
34 #include <qlineedit.h>
35 #include <qpushbutton.h>
36 #include <qlayout.h>
37 #include <qvariant.h>
38 #include <qtooltip.h>
39 #include <qwhatsthis.h>
40
41 /*!
42   Constructor
43 */
44 VisuGUI_PartialScaDlg::VisuGUI_PartialScaDlg( QWidget* parent,  const char* name, bool modal, WFlags fl )
45     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
46 {
47   if ( !name )
48     setName( "VisuGUI_PartialScaDlg" );
49   setCaption( tr( "Partial Scale" ) );
50   setSizeGripEnabled( TRUE );
51
52   QGridLayout* TopLayout = new QGridLayout( this ); 
53   TopLayout->setSpacing( 6 );
54   TopLayout->setMargin( 11 );
55   
56   TopGroup = new QGroupBox( this, "TopGroup" );
57   TopGroup->setColumnLayout(0, Qt::Vertical );
58   TopGroup->layout()->setSpacing( 0 );
59   TopGroup->layout()->setMargin( 0 );
60   QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
61   TopGroupLayout->setAlignment( Qt::AlignTop );
62   TopGroupLayout->setSpacing( 6 );
63   TopGroupLayout->setMargin( 11 );
64   
65   MinLabel = new QLabel( tr( "Min:" ), TopGroup, "MinLabel" );
66   MinSpin = new QAD_SpinBoxDbl( TopGroup, -999.99, 999.99, 0.1 );
67   MinSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
68   MinSpin->setMinimumSize( 70, 0 );
69   MinSpin->setValue( 0.0 );
70
71   MaxLabel = new QLabel( tr( "Max:" ), TopGroup, "MaxLabel" );
72   MaxSpin = new QAD_SpinBoxDbl( TopGroup, -999.99, 999.99, 0.1 );
73   MaxSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
74   MaxSpin->setMinimumSize( 70, 0 );
75   MaxSpin->setValue( 0.0 );
76   
77   TopGroupLayout->addWidget( MinLabel, 0, 0 );
78   TopGroupLayout->addWidget( MinSpin,  0, 1 );
79   TopGroupLayout->addWidget( MaxLabel, 1, 0 );
80   TopGroupLayout->addWidget( MaxSpin,  1, 1 );
81
82   GroupButtons = new QGroupBox( this, "GroupButtons" );
83   GroupButtons->setColumnLayout(0, Qt::Vertical );
84   GroupButtons->layout()->setSpacing( 0 );
85   GroupButtons->layout()->setMargin( 0 );
86   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
87   GroupButtonsLayout->setAlignment( Qt::AlignTop );
88   GroupButtonsLayout->setSpacing( 6 );
89   GroupButtonsLayout->setMargin( 11 );
90
91   buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
92   buttonOk->setAutoDefault( TRUE );
93   buttonOk->setDefault( TRUE );
94   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
95   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
96   buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
97   buttonCancel->setAutoDefault( TRUE );
98   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
99   
100   TopLayout->addWidget( TopGroup,     0, 0 );
101   TopLayout->addWidget( GroupButtons, 1, 0 );
102
103   // signals and slots connections
104   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
105   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
106 }
107
108 /*!
109   Destructor
110 */
111 VisuGUI_PartialScaDlg::~VisuGUI_PartialScaDlg()
112 {
113 }
114
115 /*!
116   Sets min, max values
117 */
118 void VisuGUI_PartialScaDlg::setMinMax( const double min, const double max )
119 {
120   MinSpin->setValue( min );
121   MaxSpin->setValue( max );
122 }
123
124 /*!
125   Gets min value
126 */
127 double VisuGUI_PartialScaDlg::getMin()
128 {
129   return MinSpin->value();
130 }
131
132 /*!
133   Gets max value
134 */
135 double VisuGUI_PartialScaDlg::getMax()
136 {
137   return MaxSpin->value();
138 }
139