Salome HOME
Update version to 3.2.0a1
[modules/visu.git] / src / VISUGUI / VisuGUI_SweepPrefDlg.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_SweepPrefDlg.cxx
25 //  Author : Laurent CORNABE & Hubert ROLLAND 
26 //  Module : VISU
27 //  $Header$
28
29 using namespace std;
30 #include "VisuGUI_SweepPrefDlg.h"
31 #include <qlayout.h>
32
33 /*!
34   Constructor
35 */
36 VisuGUI_SweepPrefDlg::VisuGUI_SweepPrefDlg( QWidget* parent,  const char* name, bool modal, WFlags fl )
37     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
38 {
39   if (!name)
40       setName("VisuGUI_SweepPrefDlg");
41   setCaption(tr("DLG_TITLE"));
42   setSizeGripEnabled(TRUE);
43
44   QVBoxLayout* TopLayout = new QVBoxLayout( this );
45   TopLayout->setSpacing( 6 );
46   TopLayout->setMargin( 11 );
47
48   TopGroup = new QGroupBox( this, "TopGroup" );
49   TopGroup->setColumnLayout(0, Qt::Vertical );
50   TopGroup->layout()->setSpacing( 0 );
51   TopGroup->layout()->setMargin( 0 );
52   QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
53   TopGroupLayout->setAlignment( Qt::AlignTop );
54   TopGroupLayout->setSpacing( 6 );
55   TopGroupLayout->setMargin( 11 );
56
57   TimeLabel = new QLabel (tr("LBL_TIME_STEP"), TopGroup, "TimeLabel");
58   TimeSpin = new QtxDblSpinBox( 0.1, 1000.0, 0.1, TopGroup );
59   TimeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
60   TimeSpin->setMinimumSize( 70, 0 );
61   TimeSpin->setValue( 0.2 );
62
63   CyclesLabel = new QLabel (tr("LBL_NB_CYCLES"), TopGroup, "CyclesLabel");
64   CyclesSpin = new QSpinBox( 1, 100, 1, TopGroup, "CyclesSpin" );
65   CyclesSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
66   CyclesSpin->setMinimumSize( 70, 0 );
67   CyclesSpin->setValue( 1 );
68
69   StepsLabel = new QLabel (tr("LBL_NB_STEPS"), TopGroup, "StepsLabel");
70   StepsSpin = new QSpinBox( 1, 200, 1, TopGroup, "StepsSpin" );
71   StepsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
72   StepsSpin->setMinimumSize( 70, 0 );
73   StepsSpin->setValue( 20 );
74
75   TopGroupLayout->addWidget( TimeLabel,   0, 0 );
76   TopGroupLayout->addWidget( TimeSpin,    0, 1 );
77   TopGroupLayout->addWidget( CyclesLabel, 1, 0 );
78   TopGroupLayout->addWidget( CyclesSpin,  1, 1 );
79   TopGroupLayout->addWidget( StepsLabel,  2, 0 );
80   TopGroupLayout->addWidget( StepsSpin,   2, 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_SweepPrefDlg::~VisuGUI_SweepPrefDlg()
112 {
113 }
114
115 /*!
116   Sets Time step
117 */ 
118 void VisuGUI_SweepPrefDlg::setTimeStep( double step )
119 {
120   TimeSpin->setValue( step );
121 }
122
123 /*!
124   Gets Time step
125 */
126 double VisuGUI_SweepPrefDlg::getTimeStep()
127 {
128   return TimeSpin->value();
129 }
130
131 /*!
132   Sets Nb of cycles
133 */
134 void VisuGUI_SweepPrefDlg::setNbCycles( int nbc )
135 {
136   CyclesSpin->setValue( nbc );
137 }
138
139 /*!
140   Gets Nb of cycles
141 */
142 int VisuGUI_SweepPrefDlg::getNbCycles()
143 {
144   return CyclesSpin->value();
145 }
146
147 /*!
148   Sets Nb of Steps
149 */
150 void VisuGUI_SweepPrefDlg::setNbSteps( int nbs )
151 {
152   StepsSpin->setValue( nbs );
153 }
154
155 /*!
156   Gets Nb of Steps
157 */
158 int VisuGUI_SweepPrefDlg::getNbSteps()
159 {
160   return StepsSpin->value();
161 }