1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROGUI_ImportBathymetryDlg.h"
25 #include "HYDROGUI_Tool.h"
27 #include <SUIT_FileDlg.h>
28 #include <SUIT_ResourceMgr.h>
29 #include <SUIT_Session.h>
36 #include <QToolButton>
39 HYDROGUI_ImportBathymetryDlg::HYDROGUI_ImportBathymetryDlg( HYDROGUI_Module* theModule, const QString& theTitle )
40 : HYDROGUI_InputPanel( theModule, theTitle )
42 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
44 // Import bathymetry from file
45 myFileNameGroup = new QGroupBox( tr( "IMPORT_BATHYMETRY_FROM_FILE" ) );
47 QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup );
49 myFileName = new QLineEdit( myFileNameGroup );
50 myFileName->setReadOnly( true );
52 QToolButton* aBrowseBtn = new QToolButton( myFileNameGroup );
53 aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
55 QBoxLayout* aFileNameLayout = new QHBoxLayout( myFileNameGroup );
56 aFileNameLayout->setMargin( 5 );
57 aFileNameLayout->setSpacing( 5 );
58 aFileNameLayout->addWidget( aFileNameLabel );
59 aFileNameLayout->addWidget( myFileName );
60 aFileNameLayout->addWidget( aBrowseBtn );
63 myObjectNameGroup = new QGroupBox( tr( "BATHYMETRY_NAME" ) );
65 QLabel* aBathymetryNameLabel = new QLabel( tr( "NAME" ), myObjectNameGroup );
66 myObjectName = new QLineEdit( myObjectNameGroup );
68 QBoxLayout* aBathymetryNameLayout = new QHBoxLayout( myObjectNameGroup );
69 aBathymetryNameLayout->setMargin( 5 );
70 aBathymetryNameLayout->setSpacing( 5 );
71 aBathymetryNameLayout->addWidget( aBathymetryNameLabel );
72 aBathymetryNameLayout->addWidget( myObjectName );
74 myInvertAltitudes = new QCheckBox( tr( "INVERT_BATHYMETRY_ALTITUDES" ), this );
77 addWidget( myFileNameGroup );
78 addWidget( myObjectNameGroup );
79 addWidget( myInvertAltitudes );
83 connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
86 HYDROGUI_ImportBathymetryDlg::~HYDROGUI_ImportBathymetryDlg()
90 void HYDROGUI_ImportBathymetryDlg::reset()
93 myObjectName->clear();
94 myObjectNameGroup->setEnabled( false );
97 void HYDROGUI_ImportBathymetryDlg::setObjectName( const QString& theName )
99 myObjectName->setText( theName );
100 myObjectNameGroup->setEnabled( !theName.isEmpty() || !myFileName->text().isEmpty() );
103 QString HYDROGUI_ImportBathymetryDlg::getObjectName() const
105 return myObjectName->text();
108 void HYDROGUI_ImportBathymetryDlg::setFileName( const QString& theFileName )
110 myFileName->setText( theFileName );
112 if ( !myObjectNameGroup->isEnabled() )
113 myObjectNameGroup->setEnabled( !theFileName.isEmpty() );
116 QString HYDROGUI_ImportBathymetryDlg::getFileName() const
118 return myFileName->text();
121 void HYDROGUI_ImportBathymetryDlg::setInvertAltitudes( const bool theIsInvert )
123 myInvertAltitudes->setChecked( theIsInvert );
126 bool HYDROGUI_ImportBathymetryDlg::isInvertAltitudes() const
128 return myInvertAltitudes->isChecked();
131 void HYDROGUI_ImportBathymetryDlg::onBrowse()
133 QString aFilter( tr( "BATHYMETRY_FILTER" ) );
134 QString aFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_BATHYMETRY_FROM_FILE" ), true );
136 if( !aFileName.isEmpty() )
138 setFileName( aFileName );
139 emit FileSelected( aFileName );