Skip to content

Commit

Permalink
Ui-QT: fixed an issue, where resizing of the geometry could lead to c…
Browse files Browse the repository at this point in the history
…rashes (Part 2).

Updates of the cell filter slider ui-elements would emit events that could reset the m_cell_min/max_xxx values the old numbers. The SpinWidget::setCellFilter function now makes sure to only accept viable values.
  • Loading branch information
M. Sallermann authored and M. Sallermann committed Jun 25, 2021
1 parent e545385 commit 11fe938
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
10 changes: 1 addition & 9 deletions ui-cpp/include/SpinWidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,7 @@ class SpinWidget : public QOpenGLWidget
glm::vec2 yRangePosition() const;
glm::vec2 zRangePosition() const;

void setCellFilter( int cell_a_min, int cell_a_max, int cell_b_min, int cell_b_max, int cell_c_min, int cell_c_max )
{
m_cell_a_min = cell_a_min;
m_cell_a_max = cell_a_max;
m_cell_b_min = cell_b_min;
m_cell_b_max = cell_b_max;
m_cell_c_min = cell_c_min;
m_cell_c_max = cell_c_max;
}
void setCellFilter( int cell_a_min, int cell_a_max, int cell_b_min, int cell_b_max, int cell_c_min, int cell_c_max );

std::array<int, 6> getCellFilter()
{
Expand Down
12 changes: 12 additions & 0 deletions ui-cpp/src/SpinWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,18 @@ SpinWidget::Colormap SpinWidget::colormap_arrows() const
return m_colormap_arrows;
}

void SpinWidget::setCellFilter(int cell_a_min, int cell_a_max, int cell_b_min, int cell_b_max, int cell_c_min, int cell_c_max)
{
int n_cells[3];
Geometry_Get_N_Cells( this->state.get(), n_cells );
m_cell_a_min = std::max(0, std::min( n_cells[0]-1, cell_a_min) );
m_cell_a_max = std::max(0, std::min( n_cells[0]-1, cell_a_max) );
m_cell_b_min = std::max(0, std::min( n_cells[1]-1, cell_b_min) );
m_cell_b_max = std::max(0, std::min( n_cells[1]-1, cell_b_max) );
m_cell_c_min = std::max(0, std::min( n_cells[2]-1, cell_c_min) );
m_cell_c_max = std::max(0, std::min( n_cells[2]-1, cell_c_max) );
}

void SpinWidget::setColormapGeneral( Colormap colormap )
{
m_colormap_general = colormap;
Expand Down

0 comments on commit 11fe938

Please sign in to comment.