1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_ImportBathymetryDlg.h"
21 #include "HYDROGUI_Tool.h"
23 #include <SUIT_FileDlg.h>
24 #include <SUIT_ResourceMgr.h>
25 #include <SUIT_Session.h>
32 #include <QToolButton>
35 HYDROGUI_ImportBathymetryDlg::HYDROGUI_ImportBathymetryDlg( HYDROGUI_Module* theModule, const QString& theTitle )
36 : HYDROGUI_InputPanel( theModule, theTitle )
38 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
40 // Import bathymetry from file
41 myFileNameGroup = new QGroupBox( tr( "IMPORT_BATHYMETRY_FROM_FILE" ) );
43 QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup );
45 myFileName = new QLineEdit( myFileNameGroup );
46 myFileName->setReadOnly( true );
48 QToolButton* aBrowseBtn = new QToolButton( myFileNameGroup );
49 aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
51 QBoxLayout* aFileNameLayout = new QHBoxLayout( myFileNameGroup );
52 aFileNameLayout->setMargin( 5 );
53 aFileNameLayout->setSpacing( 5 );
54 aFileNameLayout->addWidget( aFileNameLabel );
55 aFileNameLayout->addWidget( myFileName );
56 aFileNameLayout->addWidget( aBrowseBtn );
59 myObjectNameGroup = new QGroupBox( tr( "BATHYMETRY_NAME" ) );
61 QLabel* aBathymetryNameLabel = new QLabel( tr( "NAME" ), myObjectNameGroup );
62 myObjectName = new QLineEdit( myObjectNameGroup );
64 QBoxLayout* aBathymetryNameLayout = new QHBoxLayout( myObjectNameGroup );
65 aBathymetryNameLayout->setMargin( 5 );
66 aBathymetryNameLayout->setSpacing( 5 );
67 aBathymetryNameLayout->addWidget( aBathymetryNameLabel );
68 aBathymetryNameLayout->addWidget( myObjectName );
70 myInvertAltitudes = new QCheckBox( tr( "INVERT_BATHYMETRY_ALTITUDES" ), this );
73 addWidget( myFileNameGroup );
74 addWidget( myObjectNameGroup );
75 addWidget( myInvertAltitudes );
79 connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
82 HYDROGUI_ImportBathymetryDlg::~HYDROGUI_ImportBathymetryDlg()
86 void HYDROGUI_ImportBathymetryDlg::reset()
89 myObjectName->clear();
90 myObjectNameGroup->setEnabled( false );
93 void HYDROGUI_ImportBathymetryDlg::setObjectName( const QString& theName )
95 myObjectName->setText( theName );
96 myObjectNameGroup->setEnabled( !theName.isEmpty() || !myFileName->text().isEmpty() );
99 QString HYDROGUI_ImportBathymetryDlg::getObjectName() const
101 return myObjectName->text();
104 void HYDROGUI_ImportBathymetryDlg::setFileName( const QString& theFileName )
106 myFileName->setText( theFileName );
108 if ( !myObjectNameGroup->isEnabled() )
109 myObjectNameGroup->setEnabled( !theFileName.isEmpty() );
112 QString HYDROGUI_ImportBathymetryDlg::getFileName() const
114 return myFileName->text();
117 void HYDROGUI_ImportBathymetryDlg::setInvertAltitudes( const bool theIsInvert )
119 myInvertAltitudes->setChecked( theIsInvert );
122 bool HYDROGUI_ImportBathymetryDlg::isInvertAltitudes() const
124 return myInvertAltitudes->isChecked();
127 void HYDROGUI_ImportBathymetryDlg::onBrowse()
129 QString aFilter( tr( "BATHYMETRY_FILTER" ) );
130 QString aFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_BATHYMETRY_FROM_FILE" ), true );
132 if( !aFileName.isEmpty() )
134 setFileName( aFileName );
135 emit FileSelected( aFileName );