Skip to content

Commit

Permalink
Show just the layer number behind layer spinbox
Browse files Browse the repository at this point in the history
  • Loading branch information
mooiman committed Nov 23, 2024
1 parent bea0ad6 commit 488b42e
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 24 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ packages/Release/
packages/x64/
bin/x64/Release/qgis_umesh.lib
packages/qgis_umesh.vcxproj.user
*.bak
*.obj
packages/generated/moc_create_vector_layers.cpp
packages/generated/moc_handle_vector_layers.cpp
8 changes: 4 additions & 4 deletions dispatch_release_dll_to_qgis.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ copy .\doc\qgis_umesh_installation.pdf "c:\Program Files\Deltares\qgis_umesh\do
copy .\icons\*.* "c:\Program Files\Deltares\qgis_umesh\icons\*.*"

rem copy to Bulletin
copy "c:\OSGeo4W\apps\qgis\plugins\qgis_umesh.dll" n:\Deltabox\Bulletin\mooiman\programs\QGIS_3.38.03_qgis_umesh\*.*
copy .\doc\qgis_umesh_um.pdf n:\Deltabox\Bulletin\mooiman\programs\QGIS_3.38.03_qgis_umesh\doc\*.*
copy .\doc\qgis_umesh_installation.pdf n:\Deltabox\Bulletin\mooiman\programs\QGIS_3.38.03_qgis_umesh\doc\*.*
copy .\icons\*.* n:\Deltabox\Bulletin\mooiman\programs\QGIS_3.38.03_qgis_umesh\icons\*.*
copy "c:\OSGeo4W\apps\qgis\plugins\qgis_umesh.dll" n:\Deltabox\Bulletin\mooiman\programs\QGIS_3.34.00_qgis_umesh\*.*
copy .\doc\qgis_umesh_um.pdf n:\Deltabox\Bulletin\mooiman\programs\QGIS_3.34.00_qgis_umesh\doc\*.*
copy .\doc\qgis_umesh_installation.pdf n:\Deltabox\Bulletin\mooiman\programs\QGIS_3.34.00_qgis_umesh\doc\*.*
copy .\icons\*.* n:\Deltabox\Bulletin\mooiman\programs\QGIS_3.34.00_qgis_umesh\icons\*.*
rem pause
Binary file added packages/Debug/vc142.pdb
Binary file not shown.
23 changes: 13 additions & 10 deletions packages/src/map_time_manager_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ void MapTimeManagerWindow::create_window()
QFrame* line = new QFrame();
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
vl->addWidget(line);
vl->addWidget(m_slider);
vl->addWidget(line);

// Selection of parameter and/or vector

Expand Down Expand Up @@ -687,7 +687,7 @@ QVBoxLayout * MapTimeManagerWindow::create_scalar_selection_1d_2d_3d()
{
m_layerLabelPrefix = new QLabel(tr("Layer"));
m_layerLabelSuffix = new QLabel(tr("[0,0]"));
m_layerLabelSuffix->setText(tr("z/sigma: %1").arg(var->layer_center[var->nr_hydro_layers - 1]));
m_layerLabelSuffix->setText(tr("[1,%1]").arg(var->layer_center[var->nr_hydro_layers - 1]));
m_sb_hydro_layer = spinbox_layer(var->nr_hydro_layers);
connect(m_sb_hydro_layer, SIGNAL(valueChanged(int)), this, SLOT(spinbox_value_changed(int)));

Expand Down Expand Up @@ -768,7 +768,7 @@ QVBoxLayout * MapTimeManagerWindow::create_vector_selection_2d_3d()
struct _variable * var = m_vars->variable[strings[3].toInt()];
m_layerLabelPrefix_vec = new QLabel(tr("Layer"));
m_layerLabelSuffix_vec = new QLabel(tr("[0,0]"));
m_layerLabelSuffix_vec->setText(tr("z/sigma: %1").arg(var->layer_center[var->nr_hydro_layers - 1]));
m_layerLabelSuffix_vec->setText(tr("[1,%1]").arg(var->layer_center[var->nr_hydro_layers - 1]));
m_sb_hydro_layer_vec = spinbox_layer(var->nr_hydro_layers);
connect(m_sb_hydro_layer_vec, SIGNAL(valueChanged(int)), this, SLOT(spinbox_vec_value_changed(int)));

Expand Down Expand Up @@ -1220,7 +1220,7 @@ void MapTimeManagerWindow::cb_clicked_3d(int item)
m_sb_hydro_layer->setValue(var->nr_hydro_layers);
}
int i_lay = m_sb_hydro_layer->value();
m_layerLabelSuffix->setText(tr("z/sigma: %1").arg(var->layer_center[i_lay - 1]));
m_layerLabelSuffix->setText(tr("[1,%1]").arg(var->layer_center[i_lay - 1]));
}

if (var->nr_bed_layers > 0)
Expand Down Expand Up @@ -1311,7 +1311,7 @@ void MapTimeManagerWindow::cb_clicked_vec_3d(int item)
m_sb_hydro_layer_vec->setValue(var->nr_hydro_layers);
}
int i_lay = m_sb_hydro_layer_vec->value();
m_layerLabelSuffix_vec->setText(tr("z/sigma: %1").arg(var->layer_center[i_lay - 1]));
m_layerLabelSuffix_vec->setText(tr("[1,%1]").arg(var->layer_center[i_lay - 1]));

m_MyCanvas->reset_min_max();
if (!m_show_map_vector_3d)
Expand Down Expand Up @@ -1424,20 +1424,20 @@ void MapTimeManagerWindow::draw_time_dependent_data_1d(QComboBox * cb, int item)
// begin HACK edge vs contact
if (location == "edge" || location == "contact")
{
var->draw = true;;
var->draw = true;
int i = m_q_times.indexOf(curr_date_time->dateTime());
m_MyCanvas->set_current_step(i);
m_MyCanvas->draw_all();
}
else if (location == "face")
{
var->draw = true;;
var->draw = true;
//int i = m_q_times.indexOf(curr_date_time->dateTime());
m_MyCanvas->draw_all();
}
else if (location == "node")
{
var->draw = true;;
var->draw = true;
int i = m_q_times.indexOf(curr_date_time->dateTime());
m_MyCanvas->set_current_step(i);
m_MyCanvas->draw_all();
Expand Down Expand Up @@ -1567,13 +1567,14 @@ void MapTimeManagerWindow::spinbox_value_changed(int i_lay)
struct _variable * var = m_vars->variable[jj];
if (var->nr_hydro_layers > 0)
{
m_layerLabelSuffix->setText(tr("z/sigma: %1").arg(var->layer_center[i_lay - 1]));
m_layerLabelSuffix->setText(tr("[1,%1]").arg(var->layer_center[i_lay - 1]));
}
if (var->nr_bed_layers > 0)
{
m_layerLabelSuffix->setText(tr("Bed layer: %1").arg(var->layer_center[i_lay - 1]));
}
m_show_check_3d->setChecked(false);
m_show_check_3d->setChecked(true);

return;
}
Expand All @@ -1585,7 +1586,9 @@ void MapTimeManagerWindow::spinbox_vec_value_changed(int i_lay)
int jj = slist[3].toInt();

struct _variable * var = m_vars->variable[jj];
m_layerLabelSuffix_vec->setText(tr("z/sigma: %1").arg(var->layer_center[i_lay - 1]));
m_layerLabelSuffix_vec->setText(tr("[1,%1]").arg(var->layer_center[i_lay - 1]));
m_show_check_vec_3d->setChecked(false);
m_show_check_vec_3d->setChecked(true);
return;
}
void MapTimeManagerWindow::clicked_current_view()
Expand Down
65 changes: 55 additions & 10 deletions packages/src/ugrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,17 +806,41 @@ long UGRID::read_variables()
m_mesh_vars->variable[m_nr_mesh_var - 1]->nr_hydro_layers = nr_layers;

std::string name = m_map_dim_name["zs_name_layer"];
int ii;
status = nc_inq_varid(m_ncid, name.c_str(), &ii);
int var_id;
status = nc_inq_varid(m_ncid, name.c_str(), &var_id);
if (status == NC_NOERR)
{
double * values_c = (double *)malloc(sizeof(double) * nr_layers);
status = nc_get_var_double(this->m_ncid, ii, values_c);
std::vector<double> values;
values.reserve(nr_layers);
int dim_of_var;
status = nc_inq_varndims(this->m_ncid, var_id, &dim_of_var);
for (int j = 0; j < nr_layers; j++)
{
values.push_back(*(values_c + j));
values.push_back(j + 1);
}
if (dim_of_var != 1)
{
}
if (false) // janm
{
if (nc_type == NC_DOUBLE)
{
double* values_c = (double*)malloc(sizeof(double) * nr_layers);
status = nc_get_var_double(this->m_ncid, var_id, values_c);
for (int j = 0; j < nr_layers; j++)
{
values.push_back(*(values_c + j));
}
}
else if (nc_type == NC_FLOAT)
{
float* values_c = (float*)malloc(sizeof(float) * nr_layers);
status = nc_get_var_float(this->m_ncid, var_id, values_c);
for (int j = 0; j < nr_layers; j++)
{
values.push_back(*(values_c + j));
}
}
}
m_mesh_vars->variable[m_nr_mesh_var - 1]->layer_center = values;
}
Expand All @@ -831,17 +855,38 @@ long UGRID::read_variables()
m_mesh_vars->variable[m_nr_mesh_var - 1]->nr_hydro_layers = nr_layers;

std::string name = m_map_dim_name["zs_name_interface"];
int ii;
status = nc_inq_varid(m_ncid, name.c_str(), &ii);
int var_id;
status = nc_inq_varid(m_ncid, name.c_str(), &var_id);
if (status == NC_NOERR)
{
double* values_c = (double*)malloc(sizeof(double) * nr_layers);
status = nc_get_var_double(this->m_ncid, ii, values_c);
std::vector<double> values;
values.reserve(nr_layers);
int dim_of_var;
status = nc_inq_varndims(this->m_ncid, var_id, &dim_of_var);
for (int j = 0; j < nr_layers; j++)
{
values.push_back(*(values_c + j));
values.push_back(j + 1);
}
if (false) // janm
{
if (nc_type == NC_DOUBLE)
{
double* values_c = (double*)malloc(sizeof(double) * nr_layers);
status = nc_get_var_double(this->m_ncid, var_id, values_c);
for (int j = 0; j < nr_layers; j++)
{
values.push_back(*(values_c + j));
}
}
else if (nc_type == NC_FLOAT)
{
float* values_c = (float*)malloc(sizeof(float) * nr_layers);
status = nc_get_var_float(this->m_ncid, var_id, values_c);
for (int j = 0; j < nr_layers; j++)
{
values.push_back(*(values_c + j));
}
}
}
m_mesh_vars->variable[m_nr_mesh_var - 1]->layer_center = values;
}
Expand Down

0 comments on commit 488b42e

Please sign in to comment.