Salome HOME
lot 12 GUI p.1
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ExportLandCoverMapDlg.cxx
index 9da8db3674602c94459d2b946aef82c704690fec..30fcc0c2b38f2869d07b75dff1e1b05c101ed617 100644 (file)
 #include <QCheckBox>
 #include <QVBoxLayout>
 #include <QComboBox>
+#include <QLabel>
+#include <QDoubleSpinBox>
+#include <QVBoxLayout>
 
-HYDROGUI_ExportLandCoverMapDlg::HYDROGUI_ExportLandCoverMapDlg( QWidget* theParent, const QStringList& theAttrItems )
+HYDROGUI_ExportLandCoverMapDlg::HYDROGUI_ExportLandCoverMapDlg( QWidget* theParent, bool IsLinear, const QStringList& theAttrItems )
   : QtxDialog( theParent, false, true, QtxDialog::OKCancel )
 {
   setWindowTitle( tr( "EXPORT_LANDCOVERMAP" ) );
@@ -37,15 +40,46 @@ HYDROGUI_ExportLandCoverMapDlg::HYDROGUI_ExportLandCoverMapDlg( QWidget* thePare
   myAvFields->setEnabled(false);
   myAvFields->addItems( theAttrItems );
 
-  QGridLayout* aLayout = new QGridLayout( mainFrame() );
+  QVBoxLayout* aSketchLayout = new QVBoxLayout( mainFrame() );
+  aSketchLayout->setMargin( 0 );
+  aSketchLayout->setSpacing( 5 );
+
+  QGridLayout* aLayout = new QGridLayout();
   aLayout->setMargin( 5 );
   aLayout->setSpacing( 5 );
   aLayout->addWidget( myAttrCheckBox, 0, 0 );
   aLayout->addWidget( myAvFields, 1, 0, 1, 2 );
 
+  if(!IsLinear)
+  {
+    myDiscrLabel = new QLabel( tr( "LCM_DISCR_LABEL" ), mainFrame() );
+    myDeflSpinBox = new QDoubleSpinBox( mainFrame() );
+    myDeflSpinBox->setRange(0.001, 2); 
+    myDeflSpinBox->setDecimals(3);
+    myDeflSpinBox->setSingleStep(0.001);
+    myDeflLabel = new QLabel ( tr( "LCM_DEFL_LABEL" ), mainFrame() );
+    aLayout->addWidget( myDiscrLabel, 2, 0 );
+    aLayout->addWidget( myDeflLabel, 3, 0, 1, 1 );
+    aLayout->addWidget( myDeflSpinBox, 3, 1, 2, 2 );
+  }
+  else
+  {
+    myDeflSpinBox = NULL;
+    myDeflLabel = NULL;
+    myDiscrLabel = NULL;
+  }
+
+  myWarningLabel = new QLabel( tr( "ATTRS_NOT_WRITTEN_TO_DBF" ), mainFrame() );
+  myWarningLabel->setStyleSheet("QLabel { font: italic; color : blue; }");
+  
+  aSketchLayout->addLayout( aLayout );
+  aSketchLayout->addWidget( myWarningLabel, 1, Qt::AlignHCenter );
+  aSketchLayout->addStretch(1);
+
   setMinimumSize( 300, 100 );
 
   connect( myAttrCheckBox, SIGNAL(clicked(bool)), this, SLOT(onAttrCBChecked(bool)));
+  connect( myAvFields, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(onAvFieldsChanged(const QString&)));
 
 }
 
@@ -59,6 +93,13 @@ void HYDROGUI_ExportLandCoverMapDlg::onAttrCBChecked( bool theState )
     myAvFields->setEnabled(true);
   else
     myAvFields->setEnabled(false);
+
+  myWarningLabel->setVisible( !theState || getCurrentItem().isEmpty() );
+}
+
+void HYDROGUI_ExportLandCoverMapDlg::onAvFieldsChanged(const QString& theText)
+{
+  myWarningLabel->setVisible( theText.isEmpty() );
 }
 
 QString HYDROGUI_ExportLandCoverMapDlg::getCurrentItem() const
@@ -70,3 +111,11 @@ bool HYDROGUI_ExportLandCoverMapDlg::getAttrCheckBoxState()
 {
   return myAttrCheckBox->isChecked();
 }
+
+double HYDROGUI_ExportLandCoverMapDlg::getDeflValue() const
+{
+  if (myDeflSpinBox)
+    return myDeflSpinBox->value();
+  else 
+    return -1; //value is not needed
+}