From 5c9ccf34f778466b81d76bafb0f550f977d5252c Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 9 May 2026 23:09:11 +0200 Subject: [PATCH] Fixing a glitch in the data mapping widget (when editing the value, the node got deselected, but the colors boxes were still enabled) --- src/img/img/imgPropertiesPage.cc | 77 +++++++++++++++++--------------- src/img/img/imgPropertiesPage.h | 1 + 2 files changed, 41 insertions(+), 37 deletions(-) diff --git a/src/img/img/imgPropertiesPage.cc b/src/img/img/imgPropertiesPage.cc index cdb14e1d1..83938a4d8 100644 --- a/src/img/img/imgPropertiesPage.cc +++ b/src/img/img/imgPropertiesPage.cc @@ -314,46 +314,48 @@ PropertiesPage::min_max_value_changed () emit edited (); } +bool +PropertiesPage::update_controls () +{ + bool has_error = false; + + value_le->setText (QString ()); + value_le->setEnabled (false); + + colors->setEnabled (false_color_control->has_selection ()); + colors->set_single_mode (false); + + if (false_color_control->has_selection () && false_color_control->selected_node () > 0 && false_color_control->selected_node () < int (false_color_control->nodes ().size ()) - 1) { + + double xmin, xmax; + get_xmin_xmax (xmin, xmax, has_error); + + if (! has_error) { + + double x = false_color_control->nodes () [false_color_control->selected_node ()].first; + double xx = x * (xmax - xmin) + xmin; + + value_le->setText (tl::to_qstring (tl::sprintf ("%.4g", xx))); + value_le->setEnabled (true); + + } + + } else if (false_color_control->has_selection ()) { + + colors->set_single_mode (true); + + } + + return has_error; +} + void PropertiesPage::color_mapping_changed () { - if (! m_no_signals) { - - bool has_error = false; - - value_le->setText (QString ()); - value_le->setEnabled (false); - - colors->setEnabled (false_color_control->has_selection ()); - colors->set_single_mode (false); - - if (false_color_control->has_selection () && false_color_control->selected_node () > 0 && false_color_control->selected_node () < int (false_color_control->nodes ().size ()) - 1) { - - double xmin, xmax; - get_xmin_xmax (xmin, xmax, has_error); - - if (! has_error) { - - double x = false_color_control->nodes () [false_color_control->selected_node ()].first; - double xx = x * (xmax - xmin) + xmin; - - value_le->setText (tl::to_qstring (tl::sprintf ("%.4g", xx))); - value_le->setEnabled (true); - - } - - } else if (false_color_control->has_selection ()) { - - colors->set_single_mode (true); - - } - - if (! has_error) { - m_in_color_mapping_signal = true; - emit edited (); - m_in_color_mapping_signal = false; - } - + if (! m_no_signals && ! update_controls ()) { + m_in_color_mapping_signal = true; + emit edited (); + m_in_color_mapping_signal = false; } } @@ -509,6 +511,7 @@ PropertiesPage::update () m_no_signals = false; + update_controls (); recompute_histogram (); } diff --git a/src/img/img/imgPropertiesPage.h b/src/img/img/imgPropertiesPage.h index c799775b0..06d73b173 100644 --- a/src/img/img/imgPropertiesPage.h +++ b/src/img/img/imgPropertiesPage.h @@ -101,6 +101,7 @@ private: void invalidate (); void init (); void get_xmin_xmax (double &xmin, double &xmax, bool &has_error_out); + bool update_controls (); }; }