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>
38 HYDROGUI_ImportBathymetryDlg::HYDROGUI_ImportBathymetryDlg( HYDROGUI_Module* theModule, const QString& theTitle )
39 : HYDROGUI_InputPanel( theModule, theTitle )
41 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
43 // Import bathymetry from file
44 myFileNameGroup = new QGroupBox( tr( "IMPORT_BATHYMETRY_FROM_FILE" ) );
46 QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup );
48 myFileName = new QLineEdit( myFileNameGroup );
49 myFileName->setReadOnly( true );
51 QToolButton* aBrowseBtn = new QToolButton( myFileNameGroup );
52 aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
54 QBoxLayout* aFileNameLayout = new QHBoxLayout( myFileNameGroup );
55 aFileNameLayout->setMargin( 5 );
56 aFileNameLayout->setSpacing( 5 );
57 aFileNameLayout->addWidget( aFileNameLabel );
58 aFileNameLayout->addWidget( myFileName );
59 aFileNameLayout->addWidget( aBrowseBtn );
62 myObjectNameGroup = new QGroupBox( tr( "BATHYMETRY_NAME" ) );
64 QLabel* aBathymetryNameLabel = new QLabel( tr( "NAME" ), myObjectNameGroup );
65 myObjectName = new QLineEdit( myObjectNameGroup );
67 QBoxLayout* aBathymetryNameLayout = new QHBoxLayout( myObjectNameGroup );
68 aBathymetryNameLayout->setMargin( 5 );
69 aBathymetryNameLayout->setSpacing( 5 );
70 aBathymetryNameLayout->addWidget( aBathymetryNameLabel );
71 aBathymetryNameLayout->addWidget( myObjectName );
74 addWidget( myFileNameGroup );
75 addWidget( myObjectNameGroup );
78 connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
81 HYDROGUI_ImportBathymetryDlg::~HYDROGUI_ImportBathymetryDlg()
85 void HYDROGUI_ImportBathymetryDlg::reset()
88 myObjectName->clear();
89 myObjectNameGroup->setEnabled( false );
92 void HYDROGUI_ImportBathymetryDlg::setObjectName( const QString& theName )
94 myObjectName->setText( theName );
95 myObjectNameGroup->setEnabled( !theName.isEmpty() || !myFileName->text().isEmpty() );
98 QString HYDROGUI_ImportBathymetryDlg::getObjectName() const
100 return myObjectName->text();
103 void HYDROGUI_ImportBathymetryDlg::setFileName( const QString& theFileName )
105 myFileName->setText( theFileName );
107 if ( !myObjectNameGroup->isEnabled() )
108 myObjectNameGroup->setEnabled( !theFileName.isEmpty() );
111 QString HYDROGUI_ImportBathymetryDlg::getFileName() const
113 return myFileName->text();
116 void HYDROGUI_ImportBathymetryDlg::onBrowse()
118 QString aFilter( tr( "BATHYMETRY_FILTER" ) );
119 QString aFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_BATHYMETRY_FROM_FILE" ), true );
121 if( !aFileName.isEmpty() )
123 setFileName( aFileName );
124 emit FileSelected( aFileName );