]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMToolsGUI/GEOMToolsGUI_NbIsosDlg.cxx
Salome HOME
Porting to Qt4.
[modules/geom.git] / src / GEOMToolsGUI / GEOMToolsGUI_NbIsosDlg.cxx
1 //  GEOM GEOMGUI : GUI for Geometry 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : GEOMBase_NbIsosDlg.cxx
25 //  Author : 
26 //  Module : GEOM
27 //  $Header: 
28
29
30 #include "GEOMToolsGUI_NbIsosDlg.h"
31 #include "GeometryGUI.h"
32 #include <LightApp_Application.h>
33 #include <SUIT_MessageBox.h>
34 #include <SUIT_ResourceMgr.h>
35 #include <SUIT_Session.h>
36 #include <SUIT_Tools.h>
37
38 #include <QLabel>
39 #include <QPushButton>
40 #include <QGroupBox>
41 #include <QGridLayout>
42 #include <QSpinBox>
43 #include <QKeyEvent>
44 //using namespace std;
45
46 //=================================================================================
47 // class    : GEOMToolsGUI_NbIsosDlg()
48 // purpose  : Constructs a GEOMToolsGUI_NbIsosDlg which is a child of 'parent', with the 
49 //            name 'name' and widget flags set to 'f'.
50 //            The dialog will by default be modeless, unless you set 'modal' to
51 //            TRUE to construct a modal dialog.
52 //=================================================================================
53 GEOMToolsGUI_NbIsosDlg::GEOMToolsGUI_NbIsosDlg(QWidget* parent )
54   :QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
55 {
56   setObjectName( "GEOMToolsGUI_NbIsosDlg" );
57   setModal( true );
58
59   setWindowTitle( tr( "GEOM_MEN_ISOS" ) );
60   setSizeGripEnabled(TRUE);
61   QGridLayout* MyDialogLayout = new QGridLayout(this); 
62   MyDialogLayout->setSpacing(6);
63   MyDialogLayout->setMargin(11);
64   
65   /***************************************************************/
66   QGroupBox* GroupC1 = new QGroupBox( this );
67   GroupC1->setObjectName( "GroupC1" );
68   QGridLayout* GroupC1Layout = new QGridLayout( GroupC1 );
69   GroupC1Layout->setAlignment( Qt::AlignTop );
70   GroupC1Layout->setSpacing( 6 );
71   GroupC1Layout->setMargin( 11 );
72   
73   QLabel* TextLabel1 = new QLabel( GroupC1 );
74   TextLabel1->setObjectName( "TextLabel1" );
75   TextLabel1->setText( tr( "GEOM_MEN_ISOU") );
76   GroupC1Layout->addWidget( TextLabel1, 0, 0 );
77   
78   SpinBoxU = new QSpinBox( GroupC1 );
79   SpinBoxU->setObjectName( "SpinBoxU" );
80   SpinBoxU->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
81   SpinBoxU->setMinimum( 0 );
82   SpinBoxU->setValue( 1 );
83   GroupC1Layout->addWidget( SpinBoxU, 0, 1 );
84
85   QLabel* TextLabel2 = new QLabel( GroupC1 );
86   TextLabel2->setObjectName( "TextLabel2" );
87   TextLabel2->setText( tr( "GEOM_MEN_ISOV") ) ;
88   GroupC1Layout->addWidget( TextLabel2, 0, 2 );
89
90   SpinBoxV = new QSpinBox( GroupC1 );
91   SpinBoxV->setObjectName( "SpinBoxV");
92   SpinBoxV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
93   SpinBoxV->setValue( 1 );
94   SpinBoxV->setMinimum( 0 );
95   GroupC1Layout->addWidget( SpinBoxV, 0, 3 );
96   
97   /***************************************************************/
98   QGroupBox* GroupButtons = new QGroupBox( this );
99   GroupButtons->setObjectName( "GroupButtons" );
100   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons );
101   GroupButtonsLayout->setAlignment( Qt::AlignTop );
102   GroupButtonsLayout->setSpacing( 6 );
103   GroupButtonsLayout->setMargin( 11 );
104   
105   QPushButton* buttonOk = new QPushButton( GroupButtons );
106   buttonOk->setObjectName( "buttonOk" );
107   buttonOk->setText( tr( "GEOM_BUT_OK" ) ) ;
108   buttonOk->setAutoDefault( TRUE );
109   buttonOk->setDefault( TRUE );
110   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
111   
112   GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
113   
114   QPushButton* buttonCancel = new QPushButton( GroupButtons );
115   buttonCancel->setObjectName( "buttonCancel" );
116   buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) ) ;
117   buttonCancel->setAutoDefault( TRUE );
118   GroupButtonsLayout->addWidget( buttonCancel, 0, 1 );
119
120   QPushButton* buttonHelp = new QPushButton( GroupButtons );
121   buttonHelp->setObjectName( "buttonHelp" );
122   buttonHelp->setText( tr( "GEOM_BUT_HELP" ) ) ;
123   buttonHelp->setAutoDefault( TRUE );
124   GroupButtonsLayout->addWidget( buttonHelp, 0, 2 );
125   /***************************************************************/
126   
127   MyDialogLayout->addWidget(GroupC1, 0, 0);
128   MyDialogLayout->addWidget(GroupButtons, 1, 0);
129
130   myHelpFileName = "isos.htm";
131   
132   // signals and slots connections
133   connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
134   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
135   connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
136   
137   /* Move widget on the botton right corner of main widget */
138   SUIT_Tools::centerWidget(this, parent);
139 }
140
141 //=================================================================================
142 // function : ~GEOMToolsGUI_NbIsosDlg()
143 // purpose  : Destroys the object and frees any allocated resources
144 //=================================================================================
145 GEOMToolsGUI_NbIsosDlg::~GEOMToolsGUI_NbIsosDlg()
146 {
147     // no need to delete child widgets, Qt does it all for us
148 }
149
150 int GEOMToolsGUI_NbIsosDlg::getU() const
151 {
152   return SpinBoxU->text().toInt();
153 }
154
155 int GEOMToolsGUI_NbIsosDlg::getV() const
156 {
157   return SpinBoxV->text().toInt();
158 }
159
160 void GEOMToolsGUI_NbIsosDlg::setU( const int v )
161 {
162   SpinBoxU->setValue( v );
163 }
164
165 void GEOMToolsGUI_NbIsosDlg::setV( const int v )
166 {
167   SpinBoxV->setValue( v );
168 }
169
170 //=================================================================================
171 // function : ClickOnHelp()
172 // purpose  :
173 //=================================================================================
174 void GEOMToolsGUI_NbIsosDlg::ClickOnHelp()
175 {
176   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
177   if (app) {
178     GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
179     app->onHelpContextModule(aGeomGUI ? app->moduleName(aGeomGUI->moduleName()) : QString(""), myHelpFileName);
180   }
181   else {
182                 QString platform;
183 #ifdef WIN32
184                 platform = "winapplication";
185 #else
186                 platform = "application";
187 #endif
188     SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
189                              QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
190                              arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
191                              QObject::tr("BUT_OK"));
192   }
193 }
194
195 //=================================================================================
196 // function : keyPressEvent()
197 // purpose  :
198 //=================================================================================
199 void GEOMToolsGUI_NbIsosDlg::keyPressEvent( QKeyEvent* e )
200 {
201   QDialog::keyPressEvent( e );
202   if ( e->isAccepted() )
203     return;
204
205   if ( e->key() == Qt::Key_F1 )
206     {
207       e->accept();
208       ClickOnHelp();
209     }
210 }