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