Skip to content
Snippets Groups Projects
Verified Commit e63a8983 authored by Karsten Rink's avatar Karsten Rink Committed by Lars Bilke
Browse files

[gui] adding widget and access for ignoring nodata

parent 1e7bd1a0
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,20 @@ ...@@ -26,6 +26,20 @@
<string>2D Mesh Mapping</string> <string>2D Mesh Mapping</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="6" column="2">
<widget class="QLineEdit" name="newNameEdit">
<property name="text">
<string>MappedMesh</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QLabel" name="newNameLabel">
<property name="text">
<string>Name of new mesh:</string>
</property>
</widget>
</item>
<item row="1" column="3"> <item row="1" column="3">
<widget class="QPushButton" name="rasterSelectButton"> <widget class="QPushButton" name="rasterSelectButton">
<property name="maximumSize"> <property name="maximumSize">
...@@ -39,20 +53,6 @@ ...@@ -39,20 +53,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="noDataValueLabel">
<property name="text">
<string> Set NoData values to:</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QRadioButton" name="staticValueButton">
<property name="text">
<string>Map to static value:</string>
</property>
</widget>
</item>
<item row="1" column="2"> <item row="1" column="2">
<widget class="QLineEdit" name="rasterPathEdit"/> <widget class="QLineEdit" name="rasterPathEdit"/>
</item> </item>
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="2"> <item row="4" column="2">
<widget class="QLineEdit" name="noDataValueEdit"> <widget class="QLineEdit" name="noDataValueEdit">
<property name="text"> <property name="text">
<string>0.0</string> <string>0.0</string>
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="2"> <item row="5" column="2">
<widget class="QLineEdit" name="staticValueEdit"> <widget class="QLineEdit" name="staticValueEdit">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
...@@ -89,13 +89,10 @@ ...@@ -89,13 +89,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1" colspan="3"> <item row="5" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QRadioButton" name="staticValueButton">
<property name="orientation"> <property name="text">
<enum>Qt::Horizontal</enum> <string>Map to static value:</string>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -109,17 +106,27 @@ ...@@ -109,17 +106,27 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="2"> <item row="7" column="1" colspan="3">
<widget class="QLineEdit" name="newNameEdit"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="text"> <property name="orientation">
<string>MappedMesh</string> <enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="2"> <item row="4" column="0" colspan="2">
<widget class="QLabel" name="newNameLabel"> <widget class="QLabel" name="noDataValueLabel">
<property name="text"> <property name="text">
<string>Name of new mesh:</string> <string> Set NoData values to:</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QCheckBox" name="ignoreNoDataCheckbox">
<property name="text">
<string>Ignore</string>
</property> </property>
</widget> </widget>
</item> </item>
......
...@@ -25,10 +25,17 @@ MeshMapping2DDialog::MeshMapping2DDialog(QDialog* parent) ...@@ -25,10 +25,17 @@ MeshMapping2DDialog::MeshMapping2DDialog(QDialog* parent)
this->staticValueEdit->setValidator (static_value_validator); this->staticValueEdit->setValidator (static_value_validator);
} }
void MeshMapping2DDialog::on_ignoreNoDataCheckbox_toggled(bool isChecked)
{
this->noDataValueEdit->setEnabled(!isChecked);
}
void MeshMapping2DDialog::on_rasterValueButton_toggled(bool isChecked) void MeshMapping2DDialog::on_rasterValueButton_toggled(bool isChecked)
{ {
this->rasterPathEdit->setEnabled(isChecked); this->rasterPathEdit->setEnabled(isChecked);
this->noDataValueEdit->setEnabled(isChecked); this->ignoreNoDataCheckbox->setEnabled(isChecked);
this->noDataValueEdit->setEnabled(isChecked &&
!this->ignoreNoDataCheckbox->isChecked());
this->rasterSelectButton->setEnabled(isChecked); this->rasterSelectButton->setEnabled(isChecked);
this->staticValueEdit->setEnabled(!isChecked); this->staticValueEdit->setEnabled(!isChecked);
} }
...@@ -52,7 +59,9 @@ void MeshMapping2DDialog::accept() ...@@ -52,7 +59,9 @@ void MeshMapping2DDialog::accept()
OGSError::box("Please specify path to raster file."); OGSError::box("Please specify path to raster file.");
return; return;
} }
if (this->rasterValueButton->isChecked() && this->noDataValueEdit->text().isEmpty()) if (this->rasterValueButton->isChecked() &&
!this->ignoreNoDataCheckbox->isChecked() &&
this->noDataValueEdit->text().isEmpty())
{ {
OGSError::box("Please specify No Data value."); OGSError::box("Please specify No Data value.");
return; return;
...@@ -67,6 +76,10 @@ void MeshMapping2DDialog::accept() ...@@ -67,6 +76,10 @@ void MeshMapping2DDialog::accept()
OGSError::box("Please specify a name for the resulting mesh."); OGSError::box("Please specify a name for the resulting mesh.");
return; return;
} }
if (this->noDataValueEdit->text().isEmpty())
{
this->noDataValueEdit->setText("0.0");
}
this->done(QDialog::Accepted); this->done(QDialog::Accepted);
} }
......
...@@ -29,10 +29,12 @@ public: ...@@ -29,10 +29,12 @@ public:
bool useStaticMapping() const { return this->staticValueButton->isChecked(); } bool useStaticMapping() const { return this->staticValueButton->isChecked(); }
std::string getRasterPath() const { return this->rasterPathEdit->text().toStdString(); } std::string getRasterPath() const { return this->rasterPathEdit->text().toStdString(); }
double getNoDataReplacement() const { return this->noDataValueEdit->text().toDouble(); } double getNoDataReplacement() const { return this->noDataValueEdit->text().toDouble(); }
bool getIgnoreNoData() const { return this->ignoreNoDataCheckbox->isChecked(); }
double getStaticValue() const { return this->staticValueEdit->text().toDouble(); } double getStaticValue() const { return this->staticValueEdit->text().toDouble(); }
std::string getNewMeshName() const { return this->newNameEdit->text().toStdString(); } std::string getNewMeshName() const { return this->newNameEdit->text().toStdString(); }
private slots: private slots:
void on_ignoreNoDataCheckbox_toggled(bool isChecked);
void on_rasterValueButton_toggled(bool isChecked); void on_rasterValueButton_toggled(bool isChecked);
void on_rasterSelectButton_pressed(); void on_rasterSelectButton_pressed();
......
...@@ -189,7 +189,8 @@ void MeshView::openMap2dMeshDialog() ...@@ -189,7 +189,8 @@ void MeshView::openMap2dMeshDialog()
return; return;
} }
if (!MeshLib::MeshLayerMapper::layerMapping(*result, *raster, if (!MeshLib::MeshLayerMapper::layerMapping(*result, *raster,
dlg.getNoDataReplacement())) dlg.getNoDataReplacement(),
dlg.getIgnoreNoData()))
{ {
OGSError::box("Error mapping mesh."); OGSError::box("Error mapping mesh.");
return; return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment