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_ExportLandCoverMapDlg.h"
21 #include <SUIT_MessageBox.h>
24 #include <QVBoxLayout>
27 #include <QDoubleSpinBox>
28 #include <QVBoxLayout>
30 HYDROGUI_ExportLandCoverMapDlg::HYDROGUI_ExportLandCoverMapDlg( QWidget* theParent, bool IsLinear, const QStringList& theAttrItems )
31 : QtxDialog( theParent, false, true, QtxDialog::OKCancel )
33 setWindowTitle( tr( "EXPORT_LANDCOVERMAP" ) );
34 setButtonPosition( Left, OK );
35 setButtonPosition( Right, Cancel );
37 myAttrCheckBox = new QCheckBox( tr( "WRITE_ST_AS_ATTRS_TO_DBF" ), mainFrame() );
38 myAttrCheckBox->setChecked(false);
39 myAvFields = new QComboBox( mainFrame() );
40 myAvFields->setEnabled(false);
41 myAvFields->addItems( theAttrItems );
43 QVBoxLayout* aSketchLayout = new QVBoxLayout( mainFrame() );
44 aSketchLayout->setMargin( 0 );
45 aSketchLayout->setSpacing( 5 );
47 QGridLayout* aLayout = new QGridLayout();
48 aLayout->setMargin( 5 );
49 aLayout->setSpacing( 5 );
50 aLayout->addWidget( myAttrCheckBox, 0, 0 );
51 aLayout->addWidget( myAvFields, 1, 0, 1, 2 );
55 myDiscrLabel = new QLabel( tr( "LCM_DISCR_LABEL" ), mainFrame() );
56 myDeflSpinBox = new QDoubleSpinBox( mainFrame() );
57 myDeflSpinBox->setRange(0.001, 2);
58 myDeflSpinBox->setDecimals(3);
59 myDeflSpinBox->setSingleStep(0.001);
60 myDeflLabel = new QLabel ( tr( "LCM_DEFL_LABEL" ), mainFrame() );
61 aLayout->addWidget( myDiscrLabel, 2, 0 );
62 aLayout->addWidget( myDeflLabel, 3, 0, 1, 1 );
63 aLayout->addWidget( myDeflSpinBox, 3, 1, 2, 2 );
72 myWarningLabel = new QLabel( tr( "ATTRS_NOT_WRITTEN_TO_DBF" ), mainFrame() );
73 myWarningLabel->setStyleSheet("QLabel { font: italic; color : blue; }");
75 aSketchLayout->addLayout( aLayout );
76 aSketchLayout->addWidget( myWarningLabel, 1, Qt::AlignHCenter );
77 aSketchLayout->addStretch(1);
79 setMinimumSize( 300, 100 );
81 connect( myAttrCheckBox, SIGNAL(clicked(bool)), this, SLOT(onAttrCBChecked(bool)));
82 connect( myAvFields, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(onAvFieldsChanged(const QString&)));
86 HYDROGUI_ExportLandCoverMapDlg::~HYDROGUI_ExportLandCoverMapDlg()
90 void HYDROGUI_ExportLandCoverMapDlg::onAttrCBChecked( bool theState )
93 myAvFields->setEnabled(true);
95 myAvFields->setEnabled(false);
97 myWarningLabel->setVisible( !theState || getCurrentItem().isEmpty() );
100 void HYDROGUI_ExportLandCoverMapDlg::onAvFieldsChanged(const QString& theText)
102 myWarningLabel->setVisible( theText.isEmpty() );
105 QString HYDROGUI_ExportLandCoverMapDlg::getCurrentItem() const
107 return myAvFields->currentText();
110 bool HYDROGUI_ExportLandCoverMapDlg::getAttrCheckBoxState()
112 return myAttrCheckBox->isChecked();
115 double HYDROGUI_ExportLandCoverMapDlg::getDeflValue() const
118 return myDeflSpinBox->value();
120 return -1; //value is not needed