]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROGUI/HYDROGUI_ExportLandCoverMapDlg.cxx
Salome HOME
Merge branch 'BR_LAND_COVER_MAP' into BR_quadtree
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ExportLandCoverMapDlg.cxx
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.
6 //
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.
11 //
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
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include "HYDROGUI_ExportLandCoverMapDlg.h"
20
21 #include <SUIT_MessageBox.h>
22
23 #include <QCheckBox>
24 #include <QVBoxLayout>
25 #include <QComboBox>
26 #include <QLabel>
27 #include <QDoubleSpinBox>
28
29 HYDROGUI_ExportLandCoverMapDlg::HYDROGUI_ExportLandCoverMapDlg( QWidget* theParent, bool IsLinear, const QStringList& theAttrItems )
30   : QtxDialog( theParent, false, true, QtxDialog::OKCancel )
31 {
32   setWindowTitle( tr( "EXPORT_LANDCOVERMAP" ) );
33   setButtonPosition( Left, OK );
34   setButtonPosition( Right, Cancel );
35
36   myAttrCheckBox = new QCheckBox( tr( "WRITE_ST_AS_ATTRS_TO_DBF" ), mainFrame() );
37   myAttrCheckBox->setChecked(false);
38   myAvFields = new QComboBox( mainFrame() );
39   myAvFields->setEnabled(false);
40   myAvFields->addItems( theAttrItems );
41
42   QGridLayout* aLayout = new QGridLayout( mainFrame() );
43   aLayout->setMargin( 5 );
44   aLayout->setSpacing( 5 );
45   aLayout->addWidget( myAttrCheckBox, 0, 0 );
46   aLayout->addWidget( myAvFields, 1, 0, 1, 2 );
47
48   if(!IsLinear)
49   {
50     myDiscrLabel = new QLabel( tr( "LCM_DISCR_LABEL" ), mainFrame() );
51     myDeflSpinBox = new QDoubleSpinBox( mainFrame() );
52     myDeflSpinBox->setRange(0.001, 2); 
53     myDeflSpinBox->setDecimals(3);
54     myDeflSpinBox->setSingleStep(0.001);
55     myDeflLabel = new QLabel ( tr( "LCM_DEFL_LABEL" ), mainFrame() );
56     aLayout->addWidget( myDiscrLabel, 2, 0 );
57     aLayout->addWidget( myDeflLabel, 3, 0, 1, 1 );
58     aLayout->addWidget( myDeflSpinBox, 3, 1, 2, 2 );
59   }
60   else
61   {
62     myDeflSpinBox = NULL;
63     myDeflLabel = NULL;
64     myDiscrLabel = NULL;
65   }
66
67   setMinimumSize( 300, 100 );
68
69   connect( myAttrCheckBox, SIGNAL(clicked(bool)), this, SLOT(onAttrCBChecked(bool)));
70
71 }
72
73 HYDROGUI_ExportLandCoverMapDlg::~HYDROGUI_ExportLandCoverMapDlg()
74 {
75 }
76
77 void HYDROGUI_ExportLandCoverMapDlg::onAttrCBChecked( bool theState )
78 {
79   if (theState)
80     myAvFields->setEnabled(true);
81   else
82     myAvFields->setEnabled(false);
83 }
84
85 QString HYDROGUI_ExportLandCoverMapDlg::getCurrentItem() const
86 {
87   return myAvFields->currentText();
88 }
89
90 bool HYDROGUI_ExportLandCoverMapDlg::getAttrCheckBoxState()
91 {
92   return myAttrCheckBox->isChecked();
93 }
94
95 double HYDROGUI_ExportLandCoverMapDlg::getDeflValue() const
96 {
97   if (myDeflSpinBox)
98     return myDeflSpinBox->value();
99   else 
100     return -1; //value is not needed
101 }