Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
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_Session.h>
35 #include <SUIT_Tools.h>
36
37 #include <qlabel.h>
38 #include <qpushbutton.h>
39 #include <qgroupbox.h>
40 #include <qlayout.h>
41 #include <qspinbox.h>
42 //using namespace std;
43
44 //=================================================================================
45 // class    : GEOMToolsGUI_NbIsosDlg()
46 // purpose  : Constructs a GEOMToolsGUI_NbIsosDlg which is a child of 'parent', with the 
47 //            name 'name' and widget flags set to 'f'.
48 //            The dialog will by default be modeless, unless you set 'modal' to
49 //            TRUE to construct a modal dialog.
50 //=================================================================================
51 GEOMToolsGUI_NbIsosDlg::GEOMToolsGUI_NbIsosDlg(QWidget* parent )
52   :QDialog( parent, "GEOMToolsGUI_NbIsosDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
53 {
54   setCaption( tr( "GEOM_MEN_ISOS" ) );
55   setSizeGripEnabled(TRUE);
56   QGridLayout* MyDialogLayout = new QGridLayout(this); 
57   MyDialogLayout->setSpacing(6);
58   MyDialogLayout->setMargin(11);
59   
60   /***************************************************************/
61   QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" );
62   GroupC1->setColumnLayout(0, Qt::Vertical );
63   GroupC1->layout()->setSpacing( 0 );
64   GroupC1->layout()->setMargin( 0 );
65   QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
66   GroupC1Layout->setAlignment( Qt::AlignTop );
67   GroupC1Layout->setSpacing( 6 );
68   GroupC1Layout->setMargin( 11 );
69   
70   QLabel* TextLabel1 = new QLabel( GroupC1, "TextLabel1" );
71   TextLabel1->setText( tr( "GEOM_MEN_ISOU") );
72   GroupC1Layout->addWidget( TextLabel1, 0, 0 );
73   
74   SpinBoxU = new QSpinBox( GroupC1, "SpinBoxU" );
75   SpinBoxU->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
76   SpinBoxU->setMinValue( 0 );
77   SpinBoxU->setValue( 1 );
78   GroupC1Layout->addWidget( SpinBoxU, 0, 1 );
79
80   QLabel* TextLabel2 = new QLabel( GroupC1, "TextLabel2" );
81   TextLabel2->setText( tr( "GEOM_MEN_ISOV") ) ;
82   GroupC1Layout->addWidget( TextLabel2, 0, 2 );
83
84   SpinBoxV = new QSpinBox( GroupC1, "SpinBoxV");
85   SpinBoxV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
86   SpinBoxV->setValue( 1 );
87   SpinBoxV->setMinValue( 0 );
88   GroupC1Layout->addWidget( SpinBoxV, 0, 3 );
89   
90   /***************************************************************/
91   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
92   GroupButtons->setColumnLayout(0, Qt::Vertical );
93   GroupButtons->layout()->setSpacing( 0 );
94   GroupButtons->layout()->setMargin( 0 );
95   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
96   GroupButtonsLayout->setAlignment( Qt::AlignTop );
97   GroupButtonsLayout->setSpacing( 6 );
98   GroupButtonsLayout->setMargin( 11 );
99   
100   QPushButton* buttonOk = new QPushButton( GroupButtons, "buttonOk" );
101   buttonOk->setText( tr( "GEOM_BUT_OK" ) ) ;
102   buttonOk->setAutoDefault( TRUE );
103   buttonOk->setDefault( TRUE );
104   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
105   
106   GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
107   
108   QPushButton* buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
109   buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) ) ;
110   buttonCancel->setAutoDefault( TRUE );
111   GroupButtonsLayout->addWidget( buttonCancel, 0, 1 );
112
113   QPushButton* buttonHelp = new QPushButton( GroupButtons, "buttonHelp" );
114   buttonHelp->setText( tr( "GEOM_BUT_HELP" ) ) ;
115   buttonHelp->setAutoDefault( TRUE );
116   GroupButtonsLayout->addWidget( buttonHelp, 0, 2 );
117   /***************************************************************/
118   
119   MyDialogLayout->addWidget(GroupC1, 0, 0);
120   MyDialogLayout->addWidget(GroupButtons, 1, 0);
121
122   myHelpFileName = "isos.htm";
123   
124   // signals and slots connections
125   connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
126   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
127   connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
128   
129   /* Move widget on the botton right corner of main widget */
130   SUIT_Tools::centerWidget(this, parent);
131 }
132
133 //=================================================================================
134 // function : ~GEOMToolsGUI_NbIsosDlg()
135 // purpose  : Destroys the object and frees any allocated resources
136 //=================================================================================
137 GEOMToolsGUI_NbIsosDlg::~GEOMToolsGUI_NbIsosDlg()
138 {
139     // no need to delete child widgets, Qt does it all for us
140 }
141
142 int GEOMToolsGUI_NbIsosDlg::getU() const
143 {
144   return SpinBoxU->text().toInt();
145 }
146
147 int GEOMToolsGUI_NbIsosDlg::getV() const
148 {
149   return SpinBoxV->text().toInt();
150 }
151
152 void GEOMToolsGUI_NbIsosDlg::setU( const int v )
153 {
154   SpinBoxU->setValue( v );
155 }
156
157 void GEOMToolsGUI_NbIsosDlg::setV( const int v )
158 {
159   SpinBoxV->setValue( v );
160 }
161
162 //=================================================================================
163 // function : ClickOnHelp()
164 // purpose  :
165 //=================================================================================
166 void GEOMToolsGUI_NbIsosDlg::ClickOnHelp()
167 {
168   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
169   if (app) {
170     GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
171     app->onHelpContextModule(aGeomGUI ? app->moduleName(aGeomGUI->moduleName()) : QString(""), myHelpFileName);
172   }
173   else {
174     SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
175                            QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
176                            arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
177                            QObject::tr("BUT_OK"));
178   }
179 }