Salome HOME
NRI : First integration.
[modules/visu.git] / src / VISUGUI / VisuGUI_SweepPrefDlg.cxx
1 using namespace std;
2 //  File      : VisuGUI_SweepPrefDlg.cxx
3 //  Created   : Wed Aug 01 10:23:06 2001
4 //  Author    : Laurent CORNABE & Hubert ROLLAND 
5 //  Project   : SALOME
6 //  Module    : VISUGUI
7 //  Copyright : PRINCIPIA
8 //  $Header$
9
10 #include "VisuGUI_SweepPrefDlg.h"
11 #include <qlayout.h>
12
13 /*!
14   Constructor
15 */
16 VisuGUI_SweepPrefDlg::VisuGUI_SweepPrefDlg( QWidget* parent,  const char* name, bool modal, WFlags fl )
17     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
18 {
19   if ( !name )
20       setName( "VisuGUI_SweepPrefDlg" );
21   setCaption( tr( "Sweeping Preferences" ) );
22   setSizeGripEnabled( TRUE );
23   
24   QVBoxLayout* TopLayout = new QVBoxLayout( this ); 
25   TopLayout->setSpacing( 6 );
26   TopLayout->setMargin( 11 );
27   
28   TopGroup = new QGroupBox( this, "TopGroup" );
29   TopGroup->setColumnLayout(0, Qt::Vertical );
30   TopGroup->layout()->setSpacing( 0 );
31   TopGroup->layout()->setMargin( 0 );
32   QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
33   TopGroupLayout->setAlignment( Qt::AlignTop );
34   TopGroupLayout->setSpacing( 6 );
35   TopGroupLayout->setMargin( 11 );
36
37   TimeLabel = new QLabel( tr( "Time step (second):" ), TopGroup, "TimeLabel" );
38   TimeSpin = new QAD_SpinBoxDbl( TopGroup, 0.1, 1000.0, 0.1 );
39   TimeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
40   TimeSpin->setMinimumSize( 70, 0 );
41   TimeSpin->setValue( 0.2 );
42
43   CyclesLabel = new QLabel( tr( "Number of cycles:" ), TopGroup, "CyclesLabel" );
44   CyclesSpin = new QSpinBox( 1, 100, 1, TopGroup, "CyclesSpin" );
45   CyclesSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
46   CyclesSpin->setMinimumSize( 70, 0 );
47   CyclesSpin->setValue( 1 );
48
49   StepsLabel = new QLabel( tr( "Number of steps:" ), TopGroup, "StepsLabel" );
50   StepsSpin = new QSpinBox( 1, 200, 1, TopGroup, "StepsSpin" );
51   StepsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
52   StepsSpin->setMinimumSize( 70, 0 );
53   StepsSpin->setValue( 20 );
54
55   TopGroupLayout->addWidget( TimeLabel,   0, 0 );
56   TopGroupLayout->addWidget( TimeSpin,    0, 1 );
57   TopGroupLayout->addWidget( CyclesLabel, 1, 0 );
58   TopGroupLayout->addWidget( CyclesSpin,  1, 1 );
59   TopGroupLayout->addWidget( StepsLabel,  2, 0 );
60   TopGroupLayout->addWidget( StepsSpin,   2, 1 );
61
62   GroupButtons = new QGroupBox( this, "GroupButtons" );
63   GroupButtons->setColumnLayout(0, Qt::Vertical );
64   GroupButtons->layout()->setSpacing( 0 );
65   GroupButtons->layout()->setMargin( 0 );
66   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
67   GroupButtonsLayout->setAlignment( Qt::AlignTop );
68   GroupButtonsLayout->setSpacing( 6 );
69   GroupButtonsLayout->setMargin( 11 );
70
71   buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
72   buttonOk->setAutoDefault( TRUE );
73   buttonOk->setDefault( TRUE );
74   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
75   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
76   buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
77   buttonCancel->setAutoDefault( TRUE );
78   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
79
80   TopLayout->addWidget( TopGroup,     0, 0);
81   TopLayout->addWidget( GroupButtons, 1, 0 );
82
83   // signals and slots connections ===========================================
84   connect( buttonOk,     SIGNAL( clicked() ),      this, SLOT( accept() ) );
85   connect( buttonCancel, SIGNAL( clicked() ),      this, SLOT( reject() ) );
86 }
87
88 /*!
89   Destructor
90 */
91 VisuGUI_SweepPrefDlg::~VisuGUI_SweepPrefDlg()
92 {
93 }
94
95 /*!
96   Sets Time step
97 */ 
98 void VisuGUI_SweepPrefDlg::setTimeStep( double step )
99 {
100   TimeSpin->setValue( step );
101 }
102
103 /*!
104   Gets Time step
105 */
106 double VisuGUI_SweepPrefDlg::getTimeStep()
107 {
108   return TimeSpin->value();
109 }
110
111 /*!
112   Sets Nb of cycles
113 */
114 void VisuGUI_SweepPrefDlg::setNbCycles( int nbc )
115 {
116   CyclesSpin->setValue( nbc );
117 }
118
119 /*!
120   Gets Nb of cycles
121 */
122 int VisuGUI_SweepPrefDlg::getNbCycles()
123 {
124   return CyclesSpin->value();
125 }
126
127 /*!
128   Sets Nb of Steps
129 */
130 void VisuGUI_SweepPrefDlg::setNbSteps( int nbs )
131 {
132   StepsSpin->setValue( nbs );
133 }
134
135 /*!
136   Gets Nb of Steps
137 */
138 int VisuGUI_SweepPrefDlg::getNbSteps()
139 {
140   return StepsSpin->value();
141 }