-
Notifications
You must be signed in to change notification settings - Fork 8
Center button to center color scale range #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -38,6 +38,7 @@ enum { | |||||||||||||||||||||||||||||||||||||||
| ID_SAMPLER = 12, | ||||||||||||||||||||||||||||||||||||||||
| ID_EXPORT = 13, | ||||||||||||||||||||||||||||||||||||||||
| ID_COLORMAPINVERT = 14, | ||||||||||||||||||||||||||||||||||||||||
| ID_RANGECENTERMINMAX = 15, | ||||||||||||||||||||||||||||||||||||||||
| ID_VARSELECTOR = 100, | ||||||||||||||||||||||||||||||||||||||||
| ID_DIMEDIT = 200, | ||||||||||||||||||||||||||||||||||||||||
| ID_DIMDOWN = 300, | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -64,6 +65,7 @@ wxBEGIN_EVENT_TABLE(wxNcVisFrame, wxFrame) | |||||||||||||||||||||||||||||||||||||||
| EVT_TEXT_ENTER(ID_RANGEMIN, wxNcVisFrame::OnRangeChanged) | ||||||||||||||||||||||||||||||||||||||||
| EVT_TEXT_ENTER(ID_RANGEMAX, wxNcVisFrame::OnRangeChanged) | ||||||||||||||||||||||||||||||||||||||||
| EVT_BUTTON(ID_RANGERESETMINMAX, wxNcVisFrame::OnRangeResetMinMax) | ||||||||||||||||||||||||||||||||||||||||
| EVT_BUTTON(ID_RANGECENTERMINMAX, wxNcVisFrame::OnRangeCenterMinMax) | ||||||||||||||||||||||||||||||||||||||||
| EVT_BUTTON(ID_COLORMAPINVERT, wxNcVisFrame::OnColorMapInvertClicked) | ||||||||||||||||||||||||||||||||||||||||
| EVT_COMBOBOX(ID_COLORMAP, wxNcVisFrame::OnColorMapCombo) | ||||||||||||||||||||||||||||||||||||||||
| EVT_COMBOBOX(ID_GRIDLINES, wxNcVisFrame::OnGridLinesCombo) | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1441,6 +1443,70 @@ void wxNcVisFrame::SetDataRangeByMinMax( | |||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| //////////////////////////////////////////////////////////////////////////////// | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| void wxNcVisFrame::SetDataRangeCenteredOnZero(bool fRedraw) { | ||||||||||||||||||||||||||||||||||||||||
| if (m_data.size() == 0) { | ||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| float dDataMin = 0.0f; | ||||||||||||||||||||||||||||||||||||||||
| float dDataMax = 0.0f; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| int i; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if ((!m_fDataHasMissingValue) || (std::isnan(m_dMissingValueFloat))) { | ||||||||||||||||||||||||||||||||||||||||
| for (i = 0; i < (int)m_data.size(); i++) { | ||||||||||||||||||||||||||||||||||||||||
| if (!std::isnan(m_data[i])) { | ||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| if (i == (int)m_data.size()) { | ||||||||||||||||||||||||||||||||||||||||
| return; // no valid data | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| dDataMin = m_data[i]; | ||||||||||||||||||||||||||||||||||||||||
| dDataMax = m_data[i]; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| for (i++; i < (int)m_data.size(); i++) { | ||||||||||||||||||||||||||||||||||||||||
| if (std::isnan(m_data[i])) { | ||||||||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| if (m_data[i] < dDataMin) dDataMin = m_data[i]; | ||||||||||||||||||||||||||||||||||||||||
| if (m_data[i] > dDataMax) dDataMax = m_data[i]; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||
| for (i = 0; i < (int)m_data.size(); i++) { | ||||||||||||||||||||||||||||||||||||||||
| if ((m_data[i] != m_dMissingValueFloat) && (!std::isnan(m_data[i]))) { | ||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| if (i == (int)m_data.size()) { | ||||||||||||||||||||||||||||||||||||||||
| return; // no valid data | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| dDataMin = m_data[i]; | ||||||||||||||||||||||||||||||||||||||||
| dDataMax = m_data[i]; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| for (i++; i < (int)m_data.size(); i++) { | ||||||||||||||||||||||||||||||||||||||||
| if ((m_data[i] == m_dMissingValueFloat) || (std::isnan(m_data[i]))) { | ||||||||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| if (m_data[i] < dDataMin) dDataMin = m_data[i]; | ||||||||||||||||||||||||||||||||||||||||
| if (m_data[i] > dDataMax) dDataMax = m_data[i]; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // Center on 0: make range symmetric around zero | ||||||||||||||||||||||||||||||||||||||||
| const float M = std::max(std::fabs(dDataMin), std::fabs(dDataMax)); | ||||||||||||||||||||||||||||||||||||||||
| if (!(M > 0.0f) || std::isnan(M)) { | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1499
to
+1501
|
||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| m_imagepanel->SetDataRange(-M, M, fRedraw); | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1501
to
+1505
|
||||||||||||||||||||||||||||||||||||||||
| if (!(M > 0.0f) || std::isnan(M)) { | |
| return; | |
| } | |
| m_imagepanel->SetDataRange(-M, M, fRedraw); | |
| // If M is NaN, there is no valid magnitude to use. | |
| if (std::isnan(M)) { | |
| return; | |
| } | |
| // For valid data with zero magnitude (e.g., all-zero field), use a small | |
| // symmetric fallback range around zero instead of doing nothing. | |
| float rangeMax = M; | |
| if (!(M > 0.0f)) { | |
| rangeMax = 1.0f; // fallback half-range for degenerate all-zero fields | |
| } | |
| m_imagepanel->SetDataRange(-rangeMax, rangeMax, fRedraw); |
Copilot
AI
Feb 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GenerateDimensionControls() calls SetDataRangeCenteredOnZero(false) and then immediately calls SetDataRangeByMinMax(false), which overwrites the centered range and scans the dataset twice. Since centering is triggered by the new "Center" button, the first call appears redundant; consider removing it (or, if centering is meant to be the default, remove/adjust the subsequent SetDataRangeByMinMax(false) so the centered range is preserved).
| SetDataRangeCenteredOnZero(false); |
Copilot
AI
Feb 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new OnRangeCenterMinMax block has inconsistent indentation and duplicate separator lines (two consecutive "////////////////////////////////////////////////////////////////////////////////" plus trailing whitespace). Please match the existing formatting style in this file (tabs/indentation and a single separator) to keep diffs clean and consistent.
| //////////////////////////////////////////////////////////////////////////////// | |
| void wxNcVisFrame::OnRangeCenterMinMax( | |
| wxCommandEvent & event | |
| ) { | |
| SetDataRangeCenteredOnZero(true); | |
| } | |
| void wxNcVisFrame::OnRangeCenterMinMax( | |
| wxCommandEvent & event | |
| ) { | |
| SetDataRangeCenteredOnZero(true); | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -273,6 +273,13 @@ class wxNcVisFrame : public wxFrame { | |||||||||||||
| bool fRedraw = false | ||||||||||||||
| ); | ||||||||||||||
|
|
||||||||||||||
| /// <summary> | ||||||||||||||
| /// Set the data range centered on zero. | ||||||||||||||
| /// </summary> | ||||||||||||||
|
Comment on lines
+276
to
+278
|
||||||||||||||
| /// <summary> | |
| /// Set the data range centered on zero. | |
| /// </summary> | |
| /// <summary> | |
| /// Set the data range centered on zero. | |
| /// </summary> |
Copilot
AI
Feb 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The newly added XML doc comments for OnRangeCenterMinMax use different indentation/alignment than the surrounding header comment blocks. Please align them with the existing tab-indented comment style used throughout this header for consistency.
| /// <summary> | |
| /// Callback triggered when the range center min/max button is pressed. | |
| /// </summary> | |
| /// <summary> | |
| /// Callback triggered when the range center min/max button is pressed. | |
| /// </summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SetDataRangeCenteredOnZero() largely duplicates the min/max scan logic from SetDataRangeByMinMax(), but with slightly different edge-case handling. To reduce maintenance burden (and avoid the two implementations drifting), consider extracting a shared helper that computes (min,max) over valid data and reusing it from both functions.