Skip to content

Add Range capability#7

Merged
koldunovn merged 1 commit intomainfrom
add-range
Feb 7, 2026
Merged

Add Range capability#7
koldunovn merged 1 commit intomainfrom
add-range

Conversation

@koldunovn
Copy link
Collaborator

  • src/interface/range_popup.h - Header for the range popup dialog API
  • src/interface/range_popup.c - Modal popup implementation with:
    • Editable Minimum/Maximum text fields (using Xaw asciiTextWidgetClass)
    • "Symmetric about Zero" button - sets range to [-max(|min|,|max|), max(|min|,|max|)]
    • "Reset to Global Values" button - restores the variable's full data range
    • OK / Cancel buttons
    • Modal event loop (like ncview's XtGrabExclusive approach)

Modified files:

  • src/interface/x_interface.c - Added "Range" button in colorbar_form (same line as the colorbar, appearing to its right), initialized the popup during x_init, wired up the callback
  • src/interface/x_interface.h - Added x_set_range_button_callback() and x_range_popup_show() declarations
  • src/ushow.c - Added on_range_button() callback that opens the popup with the current variable's user_min/user_max and global_min/global_max, and updates the display on OK
  • Makefile - Added range_popup.c to USHOW_SRCS and its dependency rule

How it works:

  1. User clicks the "Range" button (positioned after the colorbar)
  2. A modal popup appears with the current min/max values pre-filled in editable text fields
  3. User can type new values, click "Symmetric about Zero", or click "Reset to Global Values"
  4. On "OK", the variable's display range is updated and the image redraws
  5. On "Cancel", nothing changes

Here's a summary of everything that was added:

Tests (tests/test_range_popup.c - 24 tests):
- 12 range_compute_symmetric tests: positive range, negative range, spanning zero, min larger abs, already symmetric, both zero, min zero, equal magnitude, small values, large values, result always symmetric, covers original range
- 11 range_parse_value tests: integer, float, negative, scientific notation, negative scientific, zero, whitespace, empty string, invalid string, NULL string, NULL value pointer
- 1 constants test: verifying RANGE_POPUP_OK/CANCEL values

Architecture refactoring for testability:
- Created src/interface/range_utils.h / range_utils.c - pure logic functions with no X11 dependency
- range_popup.c now includes and uses range_utils.h instead of inlining the logic
- Tests link only against range_utils.c (no X11 required)

Documentation (README.md):
- Added Range button, Min-/Min+/Max-/Max+ buttons to the Interface section with descriptions of the popup dialog features
- Added test_range_popup to the test suite list

  - src/interface/range_popup.h - Header for the range popup dialog API
  - src/interface/range_popup.c - Modal popup implementation with:
    - Editable Minimum/Maximum text fields (using Xaw asciiTextWidgetClass)
    - "Symmetric about Zero" button - sets range to [-max(|min|,|max|), max(|min|,|max|)]
    - "Reset to Global Values" button - restores the variable's full data range
    - OK / Cancel buttons
    - Modal event loop (like ncview's XtGrabExclusive approach)

  Modified files:
  - src/interface/x_interface.c - Added "Range" button in colorbar_form (same line as the colorbar, appearing to its right), initialized the popup during x_init, wired up the callback
  - src/interface/x_interface.h - Added x_set_range_button_callback() and x_range_popup_show() declarations
  - src/ushow.c - Added on_range_button() callback that opens the popup with the current variable's user_min/user_max and global_min/global_max, and updates the display on OK
  - Makefile - Added range_popup.c to USHOW_SRCS and its dependency rule

  How it works:
  1. User clicks the "Range" button (positioned after the colorbar)
  2. A modal popup appears with the current min/max values pre-filled in editable text fields
  3. User can type new values, click "Symmetric about Zero", or click "Reset to Global Values"
  4. On "OK", the variable's display range is updated and the image redraws
  5. On "Cancel", nothing changes

  Here's a summary of everything that was added:

    Tests (tests/test_range_popup.c - 24 tests):
    - 12 range_compute_symmetric tests: positive range, negative range, spanning zero, min larger abs, already symmetric, both zero, min zero, equal magnitude, small values, large values,
    result always symmetric, covers original range
    - 11 range_parse_value tests: integer, float, negative, scientific notation, negative scientific, zero, whitespace, empty string, invalid string, NULL string, NULL value pointer
    - 1 constants test: verifying RANGE_POPUP_OK/CANCEL values

    Architecture refactoring for testability:
    - Created src/interface/range_utils.h / range_utils.c - pure logic functions with no X11 dependency
    - range_popup.c now includes and uses range_utils.h instead of inlining the logic
    - Tests link only against range_utils.c (no X11 required)

    Documentation (README.md):
    - Added Range button, Min-/Min+/Max-/Max+ buttons to the Interface section with descriptions of the popup dialog features
    - Added test_range_popup to the test suite list
@koldunovn koldunovn merged commit d4b5f5e into main Feb 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant