Back to index

salome-geom  6.5.0
GEOMToolsGUI_NbIsosDlg.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // GEOM GEOMGUI : GUI for Geometry component
00024 // File   : GEOMToolsGUI_NbIsosDlg.cxx
00025 // Author : OCC Team
00026 //
00027 #include "GEOMToolsGUI_NbIsosDlg.h"
00028 #include <GeometryGUI.h>
00029 #include <LightApp_Application.h>
00030 #include <SUIT_MessageBox.h>
00031 #include <SUIT_ResourceMgr.h>
00032 #include <SUIT_Session.h>
00033 #include <SUIT_Tools.h>
00034 
00035 #include <QLabel>
00036 #include <QPushButton>
00037 #include <QGroupBox>
00038 #include <QGridLayout>
00039 #include <QSpinBox>
00040 #include <QKeyEvent>
00041 
00042 //=================================================================================
00043 // class    : GEOMToolsGUI_NbIsosDlg()
00044 // purpose  : Constructs a GEOMToolsGUI_NbIsosDlg which is a child of 'parent', with the 
00045 //            name 'name' and widget flags set to 'f'.
00046 //            The dialog will by default be modeless, unless you set 'modal' to
00047 //            TRUE to construct a modal dialog.
00048 //=================================================================================
00049 GEOMToolsGUI_NbIsosDlg::GEOMToolsGUI_NbIsosDlg(QWidget* parent )
00050   :QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
00051 {
00052   setObjectName( "GEOMToolsGUI_NbIsosDlg" );
00053   setModal( true );
00054 
00055   setWindowTitle( tr( "GEOM_MEN_ISOS" ) );
00056   setSizeGripEnabled(TRUE);
00057   QGridLayout* MyDialogLayout = new QGridLayout(this); 
00058   MyDialogLayout->setSpacing(6);
00059   MyDialogLayout->setMargin(11);
00060   
00061   /***************************************************************/
00062   QGroupBox* GroupC1 = new QGroupBox( this );
00063   GroupC1->setObjectName( "GroupC1" );
00064   QGridLayout* GroupC1Layout = new QGridLayout( GroupC1 );
00065   GroupC1Layout->setAlignment( Qt::AlignTop );
00066   GroupC1Layout->setSpacing( 6 );
00067   GroupC1Layout->setMargin( 11 );
00068   
00069   QLabel* TextLabel1 = new QLabel( GroupC1 );
00070   TextLabel1->setObjectName( "TextLabel1" );
00071   TextLabel1->setText( tr( "GEOM_MEN_ISOU") );
00072   GroupC1Layout->addWidget( TextLabel1, 0, 0 );
00073   
00074   SpinBoxU = new QSpinBox( GroupC1 );
00075   SpinBoxU->setObjectName( "SpinBoxU" );
00076   SpinBoxU->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
00077   SpinBoxU->setMinimum( 0 );
00078   SpinBoxU->setValue( 1 );
00079   GroupC1Layout->addWidget( SpinBoxU, 0, 1 );
00080 
00081   QLabel* TextLabel2 = new QLabel( GroupC1 );
00082   TextLabel2->setObjectName( "TextLabel2" );
00083   TextLabel2->setText( tr( "GEOM_MEN_ISOV") ) ;
00084   GroupC1Layout->addWidget( TextLabel2, 0, 2 );
00085 
00086   SpinBoxV = new QSpinBox( GroupC1 );
00087   SpinBoxV->setObjectName( "SpinBoxV");
00088   SpinBoxV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
00089   SpinBoxV->setValue( 1 );
00090   SpinBoxV->setMinimum( 0 );
00091   GroupC1Layout->addWidget( SpinBoxV, 0, 3 );
00092   
00093   /***************************************************************/
00094   QGroupBox* GroupButtons = new QGroupBox( this );
00095   GroupButtons->setObjectName( "GroupButtons" );
00096   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons );
00097   GroupButtonsLayout->setAlignment( Qt::AlignTop );
00098   GroupButtonsLayout->setSpacing( 6 );
00099   GroupButtonsLayout->setMargin( 11 );
00100   
00101   QPushButton* buttonOk = new QPushButton( GroupButtons );
00102   buttonOk->setObjectName( "buttonOk" );
00103   buttonOk->setText( tr( "GEOM_BUT_OK" ) ) ;
00104   buttonOk->setAutoDefault( TRUE );
00105   buttonOk->setDefault( TRUE );
00106   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
00107   
00108   GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
00109   
00110   QPushButton* buttonCancel = new QPushButton( GroupButtons );
00111   buttonCancel->setObjectName( "buttonCancel" );
00112   buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) ) ;
00113   buttonCancel->setAutoDefault( TRUE );
00114   GroupButtonsLayout->addWidget( buttonCancel, 0, 1 );
00115 
00116   QPushButton* buttonHelp = new QPushButton( GroupButtons );
00117   buttonHelp->setObjectName( "buttonHelp" );
00118   buttonHelp->setText( tr( "GEOM_BUT_HELP" ) ) ;
00119   buttonHelp->setAutoDefault( TRUE );
00120   GroupButtonsLayout->addWidget( buttonHelp, 0, 2 );
00121   /***************************************************************/
00122   
00123   MyDialogLayout->addWidget(GroupC1, 0, 0);
00124   MyDialogLayout->addWidget(GroupButtons, 1, 0);
00125 
00126   myHelpFileName = "isolines_page.html";
00127   
00128   // signals and slots connections
00129   connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
00130   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
00131   connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
00132   
00133   /* Move widget on the botton right corner of main widget */
00134   SUIT_Tools::centerWidget(this, parent);
00135 }
00136 
00137 //=================================================================================
00138 // function : ~GEOMToolsGUI_NbIsosDlg()
00139 // purpose  : Destroys the object and frees any allocated resources
00140 //=================================================================================
00141 GEOMToolsGUI_NbIsosDlg::~GEOMToolsGUI_NbIsosDlg()
00142 {
00143     // no need to delete child widgets, Qt does it all for us
00144 }
00145 
00146 int GEOMToolsGUI_NbIsosDlg::getU() const
00147 {
00148   return SpinBoxU->text().toInt();
00149 }
00150 
00151 int GEOMToolsGUI_NbIsosDlg::getV() const
00152 {
00153   return SpinBoxV->text().toInt();
00154 }
00155 
00156 void GEOMToolsGUI_NbIsosDlg::setU( const int v )
00157 {
00158   SpinBoxU->setValue( v );
00159 }
00160 
00161 void GEOMToolsGUI_NbIsosDlg::setV( const int v )
00162 {
00163   SpinBoxV->setValue( v );
00164 }
00165 
00166 //=================================================================================
00167 // function : ClickOnHelp()
00168 // purpose  :
00169 //=================================================================================
00170 void GEOMToolsGUI_NbIsosDlg::ClickOnHelp()
00171 {
00172   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
00173   if (app) {
00174     GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
00175     app->onHelpContextModule(aGeomGUI ? app->moduleName(aGeomGUI->moduleName()) : QString(""), myHelpFileName);
00176   }
00177   else {
00178                 QString platform;
00179 #ifdef WIN32
00180                 platform = "winapplication";
00181 #else
00182                 platform = "application";
00183 #endif
00184     SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
00185                              QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
00186                              arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
00187                              QObject::tr("BUT_OK"));
00188   }
00189 }
00190 
00191 //=================================================================================
00192 // function : keyPressEvent()
00193 // purpose  :
00194 //=================================================================================
00195 void GEOMToolsGUI_NbIsosDlg::keyPressEvent( QKeyEvent* e )
00196 {
00197   QDialog::keyPressEvent( e );
00198   if ( e->isAccepted() )
00199     return;
00200 
00201   if ( e->key() == Qt::Key_F1 )
00202     {
00203       e->accept();
00204       ClickOnHelp();
00205     }
00206 }