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

work state with zlib linking error

parent 0ee373e9
No related branches found
No related tags found
No related merge requests found
...@@ -4,15 +4,16 @@ if(BUILD_SHARED_LIBS) ...@@ -4,15 +4,16 @@ if(BUILD_SHARED_LIBS)
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif() endif()
target_link_libraries(NetCdfDialogLib target_link_libraries(NetCdfDialogLib
PUBLIC Qt5::Widgets PUBLIC Qt5::Widgets ${ZLIB_LIBRARIES}
PRIVATE MathLib vtknetcdfcpp) PRIVATE MathLib ${NETCDF_LIBRARIES_C}
${NETCDF_LIBRARIES_CXX} ${HDF5_LIBRARIES})
set_property(TARGET NetCdfDialogLib PROPERTY FOLDER "DataExplorer") set_property(TARGET NetCdfDialogLib PROPERTY FOLDER "DataExplorer")
# Workaround for system installed VTK (tested on arch) # Workaround for system installed VTK (tested on arch)
if(NOT OGS_USE_CONAN) if(NOT OGS_USE_CONAN)
target_include_directories( target_include_directories(NetCdfDialogLib SYSTEM
NetCdfDialogLib SYSTEM PUBLIC ${NETCDF_INCLUDES_C}
PUBLIC ${VTK_INSTALL_PREFIX}/include/vtk/vtknetcdfcpp) PUBLIC ${NETCDF_INCLUDES_CXX})
endif() endif()
add_autogen_include(NetCdfDialogLib) add_autogen_include(NetCdfDialogLib)
...@@ -21,16 +21,18 @@ ...@@ -21,16 +21,18 @@
#include <vtkImageImport.h> #include <vtkImageImport.h>
using namespace netCDF;
// Constructor // Constructor
NetCdfConfigureDialog::NetCdfConfigureDialog(std::string const& fileName, QDialog* parent) NetCdfConfigureDialog::NetCdfConfigureDialog(std::string const& fileName, QDialog* parent)
: QDialog(parent), _currentFile(new NcFile(fileName.c_str(), NcFile::ReadOnly)), : QDialog(parent), _currentFile(fileName.c_str(), NcFile::read),
_currentInitialDateTime(QDateTime()), _currentMesh(nullptr), _currentRaster(nullptr), _currentPath(fileName) _currentInitialDateTime(QDateTime()), _currentMesh(nullptr), _currentRaster(nullptr), _currentPath(fileName)
{ {
setupUi(this); setupUi(this);
int const idx = setVariableSelect(); // set up variables of the file in the combobox int const idx = setVariableSelect(); // set up variables of the file in the combobox
comboBoxVariable->setCurrentIndex(idx); //pre-select the variable with the biggest number of dimensions...valueWithMaxDim() comboBoxVariable->setCurrentIndex(idx); //pre-select the variable with the biggest number of dimensions...valueWithMaxDim()
_currentVar = _currentFile->get_var(idx); _currentVar = _currentFile.getVar(comboBoxVariable->itemText(idx).toStdString());
setDimensionSelect(); setDimensionSelect();
...@@ -45,7 +47,7 @@ NetCdfConfigureDialog::~NetCdfConfigureDialog() = default; ...@@ -45,7 +47,7 @@ NetCdfConfigureDialog::~NetCdfConfigureDialog() = default;
void NetCdfConfigureDialog::accept() void NetCdfConfigureDialog::accept()
{ {
QMessageBox valueErrorBox; QMessageBox valueErrorBox;
if (_currentVar->num_dims() < 2){ if (_currentVar.getDimCount() < 2){
valueErrorBox.setText("Selected Variable has not enough dimensions."); valueErrorBox.setText("Selected Variable has not enough dimensions.");
valueErrorBox.exec(); valueErrorBox.exec();
}else if (doubleSpinBoxDim2Start->value() == doubleSpinBoxDim2Start->maximum()){ }else if (doubleSpinBoxDim2Start->value() == doubleSpinBoxDim2Start->maximum()){
...@@ -56,7 +58,6 @@ void NetCdfConfigureDialog::accept() ...@@ -56,7 +58,6 @@ void NetCdfConfigureDialog::accept()
valueErrorBox.exec(); valueErrorBox.exec();
}else{ }else{
createDataObject(); createDataObject();
delete _currentFile;
this->done(QDialog::Accepted); this->done(QDialog::Accepted);
} }
} }
...@@ -64,13 +65,13 @@ void NetCdfConfigureDialog::accept() ...@@ -64,13 +65,13 @@ void NetCdfConfigureDialog::accept()
// Instructions if the Cancel-Button has been pressed. // Instructions if the Cancel-Button has been pressed.
void NetCdfConfigureDialog::reject() void NetCdfConfigureDialog::reject()
{ {
delete _currentFile;
this->done(QDialog::Rejected); this->done(QDialog::Rejected);
} }
void NetCdfConfigureDialog::on_comboBoxVariable_currentIndexChanged(int id) void NetCdfConfigureDialog::on_comboBoxVariable_currentIndexChanged(int id)
{ {
_currentVar = _currentFile->get_var(_id_map[id]); std::string const var_name = comboBoxVariable->itemText(_id_map[id]).toStdString();
_currentVar = _currentFile.getVar(var_name);
setDimensionSelect(); setDimensionSelect();
} }
...@@ -89,7 +90,7 @@ void NetCdfConfigureDialog::on_comboBoxDim1_currentIndexChanged(int id) ...@@ -89,7 +90,7 @@ void NetCdfConfigureDialog::on_comboBoxDim1_currentIndexChanged(int id)
//set up y-axis/lon //set up y-axis/lon
void NetCdfConfigureDialog::on_comboBoxDim2_currentIndexChanged(int id) void NetCdfConfigureDialog::on_comboBoxDim2_currentIndexChanged(int id)
{ {
if (_currentVar->num_dims() > 1) if (_currentVar.getDimCount() > 1)
{ {
if (id == -1) id = 0; if (id == -1) id = 0;
double firstValue=0, lastValue=0; double firstValue=0, lastValue=0;
...@@ -103,7 +104,7 @@ void NetCdfConfigureDialog::on_comboBoxDim2_currentIndexChanged(int id) ...@@ -103,7 +104,7 @@ void NetCdfConfigureDialog::on_comboBoxDim2_currentIndexChanged(int id)
//set up time //set up time
void NetCdfConfigureDialog::on_comboBoxDim3_currentIndexChanged(int id) void NetCdfConfigureDialog::on_comboBoxDim3_currentIndexChanged(int id)
{ {
if (_currentVar->num_dims() > 2) if (_currentVar.getDimCount() > 2)
{ {
if (id == -1) id = 0; if (id == -1) id = 0;
double firstValue=0, lastValue=0; double firstValue=0, lastValue=0;
...@@ -141,7 +142,7 @@ void NetCdfConfigureDialog::on_comboBoxDim3_currentIndexChanged(int id) ...@@ -141,7 +142,7 @@ void NetCdfConfigureDialog::on_comboBoxDim3_currentIndexChanged(int id)
//set up additional dimension //set up additional dimension
void NetCdfConfigureDialog::on_comboBoxDim4_currentIndexChanged(int id) void NetCdfConfigureDialog::on_comboBoxDim4_currentIndexChanged(int id)
{ {
if (_currentVar->num_dims() > 3) if (_currentVar.getDimCount() > 3)
{ {
if (id == -1) id = 0; if (id == -1) id = 0;
double firstValue=0, lastValue=0; double firstValue=0, lastValue=0;
...@@ -158,17 +159,20 @@ int NetCdfConfigureDialog::setVariableSelect() ...@@ -158,17 +159,20 @@ int NetCdfConfigureDialog::setVariableSelect()
{ {
int max_dim = 0; int max_dim = 0;
int max_dim_idx = 0; int max_dim_idx = 0;
auto const n_vars = _currentFile->num_vars(); auto const& names =_currentFile.getVars();
for (int i = 0; i < n_vars; i++) //auto const n_vars = _currentFile.getVarCount();
//for (int i = 0; i < n_vars; i++)
for (auto it = names.cbegin(); it != names.cend(); ++it)
{ {
NcVar const& focusedVar = *_currentFile->get_var(i); //NcVar const& focusedVar = _currentFile.getVar(i);
if (focusedVar.num_dims() > 1) int const var_dim_count = it->second.getDimCount();
if (var_dim_count > 1)
{ {
_id_map.push_back(i); //_id_map.push_back(i);
comboBoxVariable->addItem(focusedVar.name()); comboBoxVariable->addItem(QString::fromStdString(it->first));
if (focusedVar.num_dims() > max_dim) if (var_dim_count > max_dim)
{ {
max_dim = focusedVar.num_dims(); max_dim = var_dim_count;
max_dim_idx = comboBoxVariable->count() - 1; max_dim_idx = comboBoxVariable->count() - 1;
} }
} }
...@@ -178,7 +182,7 @@ int NetCdfConfigureDialog::setVariableSelect() ...@@ -178,7 +182,7 @@ int NetCdfConfigureDialog::setVariableSelect()
void NetCdfConfigureDialog::setDimensionSelect() void NetCdfConfigureDialog::setDimensionSelect()
{ {
int const dim = _currentVar->num_dims(); int const dim = _currentVar.getDimCount();
std::array<QComboBox*,4> dim_box = {{ comboBoxDim1, comboBoxDim2, comboBoxDim3, comboBoxDim4 }}; std::array<QComboBox*,4> dim_box = {{ comboBoxDim1, comboBoxDim2, comboBoxDim3, comboBoxDim4 }};
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
...@@ -190,7 +194,7 @@ void NetCdfConfigureDialog::setDimensionSelect() ...@@ -190,7 +194,7 @@ void NetCdfConfigureDialog::setDimensionSelect()
for (int i=0; i < dim; ++i) //write dimension-names into selection-boxes for (int i=0; i < dim; ++i) //write dimension-names into selection-boxes
{ {
for (int j = 0; j < dim; ++j) for (int j = 0; j < dim; ++j)
dim_box[j]->addItem(_currentVar->get_dim(i)->name()); dim_box[j]->addItem(QString::fromStdString(_currentVar.getDim(i).getName()));
} }
comboBoxDim1->setCurrentIndex(dim-2); comboBoxDim1->setCurrentIndex(dim-2);
on_comboBoxDim1_currentIndexChanged(dim-2); on_comboBoxDim1_currentIndexChanged(dim-2);
...@@ -218,29 +222,36 @@ void NetCdfConfigureDialog::setDimensionSelect() ...@@ -218,29 +222,36 @@ void NetCdfConfigureDialog::setDimensionSelect()
void NetCdfConfigureDialog::getDimEdges(int dimId, unsigned &size, double &firstValue, double &lastValue) void NetCdfConfigureDialog::getDimEdges(int dimId, unsigned &size, double &firstValue, double &lastValue)
{ {
if ((_currentFile->get_var(_currentVar->get_dim(dimId)->name())) != nullptr) size = 0;
firstValue = 0;
lastValue = 0;
if (_currentFile.getVar(_currentVar.getDim(dimId).getName()).isNull())
return;
NcVar const& tmpVarOfDim = _currentFile.getVar(_currentVar.getDim(dimId).getName());
if ((tmpVarOfDim.getDimCount()) == 1)
{ {
NcVar *tmpVarOfDim = _currentFile->get_var(_currentVar->get_dim(dimId)->name()); /*
if ((tmpVarOfDim->num_dims()) == 1) int sizeOfDim = tmpVarOfDim.getDim(0).getSize();
{ size = sizeOfDim;
int sizeOfDim = tmpVarOfDim->get_dim(0)->size(); double *arrayOfDimStart = new double[1]; //[1] = {0};
size = sizeOfDim; long edgeOfArray = 1; //[1] = {1};
double *arrayOfDimStart = new double[1]; //[1] = {0}; long edgeOrigin[1] = {0};
long edgeOfArray = 1; //[1] = {1}; tmpVarOfDim.set_cur(edgeOrigin);
long edgeOrigin[1] = {0}; tmpVarOfDim->get(arrayOfDimStart,edgeOfArray);
tmpVarOfDim->set_cur(edgeOrigin); firstValue = arrayOfDimStart[0];
tmpVarOfDim->get(arrayOfDimStart,edgeOfArray); double arrayOfDimEnd[1] = {0};
firstValue = arrayOfDimStart[0]; edgeOrigin[0] = sizeOfDim - 1;
double arrayOfDimEnd[1] = {0}; tmpVarOfDim->set_cur(edgeOrigin);
edgeOrigin[0] = sizeOfDim - 1; tmpVarOfDim->get(arrayOfDimEnd,edgeOfArray);
tmpVarOfDim->set_cur(edgeOrigin); lastValue = arrayOfDimEnd[0];
tmpVarOfDim->get(arrayOfDimEnd,edgeOfArray); */
lastValue = arrayOfDimEnd[0]; size = tmpVarOfDim.getDim(0).getSize();
} std::vector<std::size_t> start_val{{0}};
}else{ std::vector<std::size_t> length{{1}};
size = 0; tmpVarOfDim.getVar(start_val, length, &firstValue);
firstValue = 0; start_val[0] = size-1;
lastValue = 0; tmpVarOfDim.getVar(start_val, length, &lastValue);
} }
} }
...@@ -264,33 +275,45 @@ long NetCdfConfigureDialog::convertDateToMinutes(QDateTime initialDateTime, QDat ...@@ -264,33 +275,45 @@ long NetCdfConfigureDialog::convertDateToMinutes(QDateTime initialDateTime, QDat
int NetCdfConfigureDialog::getTimeStep() int NetCdfConfigureDialog::getTimeStep()
{ {
NcVar* timeVar = _currentFile->get_var(comboBoxDim2->currentIndex()); NcVar const& timeVar =
_currentFile.getVar(comboBoxDim2->currentText().toStdString());
double const datesToMinutes = convertDateToMinutes(_currentInitialDateTime,dateTimeEditDim3->date(),dateTimeEditDim3->time()); double const datesToMinutes = convertDateToMinutes(_currentInitialDateTime,dateTimeEditDim3->date(),dateTimeEditDim3->time());
double timeArray[1] = {datesToMinutes}; double timeArray[1] = {datesToMinutes};
double currentTime = timeVar->get_index(timeArray); /*
double currentTime = timeVar.get_index(timeArray);
if (currentTime < 0) currentTime=0; //if the value isn't found in the array, set it to 0 as default... if (currentTime < 0) currentTime=0; //if the value isn't found in the array, set it to 0 as default...
return static_cast<int>(currentTime); return static_cast<int>(currentTime);
*/
/** TODO **/
return 0;
} }
int NetCdfConfigureDialog::getDim4() const int NetCdfConfigureDialog::getDim4() const
{ {
NcVar* dim3Var = _currentFile->get_var(comboBoxDim4->currentIndex()); /** TODO **/
/*
NcVar const& dim3Var =
_currentFile.getVar(comboBoxDim4->currentText().toStdString());
int timeArray[1] = {spinBoxDim4->value()}; int timeArray[1] = {spinBoxDim4->value()};
int currentValueDim3 = dim3Var->get_index(timeArray); int currentValueDim3 = dim3Var.get_index(timeArray);
if (currentValueDim3 < 0) currentValueDim3=0; //if the value isn't found in the array, set it to 0 as default... if (currentValueDim3 < 0)
currentValueDim3=0; //if the value isn't found in the array, set it to 0 as default...
return currentValueDim3; return currentValueDim3;
*/
return 0;
} }
double NetCdfConfigureDialog::getResolution() double NetCdfConfigureDialog::getResolution()
{ {
if (comboBoxDim1->currentIndex() > -1) if (comboBoxDim1->currentIndex() > -1)
{ {
NcVar* latVar = _currentFile->get_var(comboBoxDim1->currentIndex()); NcVar const& latVar =
_currentFile.getVar(comboBoxDim1->currentText().toStdString());
double firstValue = 0, lastValue = 0; double firstValue = 0, lastValue = 0;
unsigned size = 0; unsigned size = 0;
getDimEdges(latVar->id(), size, firstValue, lastValue); getDimEdges(latVar.getId(), size, firstValue, lastValue);
if (size < 2) if (size < 2)
{ {
return 1; return 1;
...@@ -306,7 +329,7 @@ double NetCdfConfigureDialog::getResolution() ...@@ -306,7 +329,7 @@ double NetCdfConfigureDialog::getResolution()
void NetCdfConfigureDialog::createDataObject() void NetCdfConfigureDialog::createDataObject()
{ {
auto* length = new std::size_t[_currentVar->num_dims()]; auto* length = new std::size_t[_currentVar.getDimCount()];
double originLon = 0, originLat = 0; double originLon = 0, originLat = 0;
double lastLon = 0, lastLat = 0; double lastLon = 0, lastLat = 0;
unsigned sizeLon = 0, sizeLat = 0; unsigned sizeLon = 0, sizeLat = 0;
...@@ -314,7 +337,7 @@ void NetCdfConfigureDialog::createDataObject() ...@@ -314,7 +337,7 @@ void NetCdfConfigureDialog::createDataObject()
getDimEdges(comboBoxDim2->currentIndex(), sizeLon, originLon, lastLon); getDimEdges(comboBoxDim2->currentIndex(), sizeLon, originLon, lastLon);
for(int i=0; i < _currentVar->num_dims(); i++) length[i]=1; for(int i=0; i < _currentVar.getDimCount(); i++) length[i]=1;
// set array edges: lat x lon // set array edges: lat x lon
length[comboBoxDim1->currentIndex()]=sizeLat; length[comboBoxDim1->currentIndex()]=sizeLat;
...@@ -325,18 +348,21 @@ void NetCdfConfigureDialog::createDataObject() ...@@ -325,18 +348,21 @@ void NetCdfConfigureDialog::createDataObject()
for(std::size_t i=0; i < (sizeLat*sizeLon); i++) data_array[i]=0; for(std::size_t i=0; i < (sizeLat*sizeLon); i++) data_array[i]=0;
//Time-Dimension: //Time-Dimension:
if (_currentVar->num_dims() > 2) /*
if (_currentVar.getDimCount() > 2)
{ {
auto* newOrigin = new long[_currentVar->num_dims()]; auto* newOrigin = new long[_currentVar.getDimCount()];
for (int i=0; i < _currentVar->num_dims(); i++) newOrigin[i]=0; for (int i=0; i < _currentVar.getDimCount(); i++) newOrigin[i]=0;
newOrigin[comboBoxDim3->currentIndex()] = getTimeStep(); //set origin to selected time newOrigin[comboBoxDim3->currentIndex()] = getTimeStep(); //set origin to selected time
_currentVar->set_cur(newOrigin); _currentVar.set_cur(newOrigin);
//Dimension 4: //Dimension 4:
if (_currentVar->num_dims() > 3) newOrigin[comboBoxDim4->currentIndex()] = getDim4(); //if there are is a 4th dimension if (_currentVar.getDimCount() > 3) newOrigin[comboBoxDim4->currentIndex()] = getDim4(); //if there are is a 4th dimension
delete [] newOrigin; delete [] newOrigin;
} }
*/
_currentVar->get(data_array,length); //create Array of Values std::vector<std::size_t> data_origin {{0, 0}};
std::vector<std::size_t> data_length {{sizeLat, sizeLon}};
_currentVar.getVar(data_origin, data_length, data_array); // create Array of Values
for (std::size_t i=0; i < (sizeLat*sizeLon); i++) for (std::size_t i=0; i < (sizeLat*sizeLon); i++)
{ {
...@@ -371,7 +397,7 @@ void NetCdfConfigureDialog::createDataObject() ...@@ -371,7 +397,7 @@ void NetCdfConfigureDialog::createDataObject()
useIntensity = MeshLib::UseIntensityAs::DATAVECTOR; useIntensity = MeshLib::UseIntensityAs::DATAVECTOR;
} }
_currentMesh = MeshLib::RasterToMesh::convert( _currentMesh = MeshLib::RasterToMesh::convert(
data_array, header, meshElemType, useIntensity, _currentVar->name()); data_array, header, meshElemType, useIntensity, _currentVar.getName());
} }
else else
{ {
...@@ -439,5 +465,3 @@ void NetCdfConfigureDialog::on_radioMesh_toggled(bool isTrue) ...@@ -439,5 +465,3 @@ void NetCdfConfigureDialog::on_radioMesh_toggled(bool isTrue)
this->comboBoxUseIntensity->setEnabled(true); this->comboBoxUseIntensity->setEnabled(true);
} }
} }
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#pragma once #pragma once
#include <netcdfcpp.h> #include <netcdf>
#include <QDialog> #include <QDialog>
#include "ui_NetCdfConfigure.h" #include "ui_NetCdfConfigure.h"
...@@ -65,8 +65,8 @@ private: ...@@ -65,8 +65,8 @@ private:
QString setName(); QString setName();
void reverseNorthSouth(double* data, std::size_t width, std::size_t height); void reverseNorthSouth(double* data, std::size_t width, std::size_t height);
NcFile *_currentFile; netCDF::NcFile _currentFile;
NcVar *_currentVar; netCDF::NcVar _currentVar;
QDateTime _currentInitialDateTime; QDateTime _currentInitialDateTime;
MeshLib::Mesh* _currentMesh; MeshLib::Mesh* _currentMesh;
VtkGeoImageSource* _currentRaster; VtkGeoImageSource* _currentRaster;
......
...@@ -106,6 +106,8 @@ if(OGS_USE_NETCDF) ...@@ -106,6 +106,8 @@ if(OGS_USE_NETCDF)
set(NETCDF_ROOT ${CONAN_NETCDF-C_ROOT}) set(NETCDF_ROOT ${CONAN_NETCDF-C_ROOT})
set(NETCDF_CXX_ROOT ${CONAN_NETCDF-CXX_ROOT}) set(NETCDF_CXX_ROOT ${CONAN_NETCDF-CXX_ROOT})
find_package(NetCDF REQUIRED) find_package(NetCDF REQUIRED)
find_package(HDF5 REQUIRED)
find_package(ZLIB REQUIRED)
endif() endif()
# lapack # lapack
......
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