Salome HOME
copyrights in HYDRO files are updated
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportBathymetryDlg.cxx
1 // Copyright (C) 2007-2015  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, or (at your option) any later version.
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
23 #include "HYDROGUI_ImportBathymetryDlg.h"
24
25 #include "HYDROGUI_Tool.h"
26
27 #include <SUIT_FileDlg.h>
28 #include <SUIT_ResourceMgr.h>
29 #include <SUIT_Session.h>
30
31 #include <QGroupBox>
32 #include <QLabel>
33 #include <QLayout>
34 #include <QLineEdit>
35 #include <QPicture>
36 #include <QToolButton>
37 #include <QCheckBox>
38
39 HYDROGUI_ImportBathymetryDlg::HYDROGUI_ImportBathymetryDlg( HYDROGUI_Module* theModule, const QString& theTitle )
40 : HYDROGUI_InputPanel( theModule, theTitle )
41 {
42   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
43
44   // Import bathymetry from file
45   myFileNameGroup = new QGroupBox( tr( "IMPORT_BATHYMETRY_FROM_FILE" ) );
46
47   QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup );
48
49   myFileName = new QLineEdit( myFileNameGroup );
50   myFileName->setReadOnly( true );
51
52   QToolButton* aBrowseBtn = new QToolButton( myFileNameGroup );
53   aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
54
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 );
61
62   // Bathymetry name
63   myObjectNameGroup = new QGroupBox( tr( "BATHYMETRY_NAME" ) );
64
65   QLabel* aBathymetryNameLabel = new QLabel( tr( "NAME" ), myObjectNameGroup );
66   myObjectName = new QLineEdit( myObjectNameGroup );
67
68   QBoxLayout* aBathymetryNameLayout = new QHBoxLayout( myObjectNameGroup );
69   aBathymetryNameLayout->setMargin( 5 );
70   aBathymetryNameLayout->setSpacing( 5 );
71   aBathymetryNameLayout->addWidget( aBathymetryNameLabel );
72   aBathymetryNameLayout->addWidget( myObjectName );
73
74   myInvertAltitudes = new QCheckBox( tr( "INVERT_BATHYMETRY_ALTITUDES" ), this );
75
76   // Common
77   addWidget( myFileNameGroup );
78   addWidget( myObjectNameGroup );
79   addWidget( myInvertAltitudes );
80
81   addStretch();
82
83   connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
84 }
85
86 HYDROGUI_ImportBathymetryDlg::~HYDROGUI_ImportBathymetryDlg()
87 {
88 }
89
90 void HYDROGUI_ImportBathymetryDlg::reset()
91 {
92   myFileName->clear();
93   myObjectName->clear();
94   myObjectNameGroup->setEnabled( false );
95 }
96
97 void HYDROGUI_ImportBathymetryDlg::setObjectName( const QString& theName )
98 {
99   myObjectName->setText( theName );
100   myObjectNameGroup->setEnabled( !theName.isEmpty() || !myFileName->text().isEmpty() );
101 }
102
103 QString HYDROGUI_ImportBathymetryDlg::getObjectName() const
104 {
105   return myObjectName->text();
106 }
107
108 void HYDROGUI_ImportBathymetryDlg::setFileName( const QString& theFileName )
109 {
110   myFileName->setText( theFileName );
111
112   if ( !myObjectNameGroup->isEnabled() )
113     myObjectNameGroup->setEnabled( !theFileName.isEmpty() );
114 }
115
116 QString HYDROGUI_ImportBathymetryDlg::getFileName() const
117 {
118   return myFileName->text();
119 }
120
121 void HYDROGUI_ImportBathymetryDlg::setInvertAltitudes( const bool theIsInvert )
122 {
123   myInvertAltitudes->setChecked( theIsInvert );
124 }
125
126 bool HYDROGUI_ImportBathymetryDlg::isInvertAltitudes() const
127 {
128   return myInvertAltitudes->isChecked();
129 }
130
131 void HYDROGUI_ImportBathymetryDlg::onBrowse()
132 {
133   QString aFilter( tr( "BATHYMETRY_FILTER" ) );
134   QString aFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_BATHYMETRY_FROM_FILE" ), true );
135
136   if( !aFileName.isEmpty() )
137   {
138     setFileName( aFileName );
139     emit FileSelected( aFileName );
140   }
141 }
142
143
144
145