wolfhece.wolf_array._clipping
Clipping zones for WolfArray OpenGL rendering.
Provides WolfArrayClipZone (extends header_wolf) to
restrict rendering to predefined or dynamically-defined world-coordinate
regions using the OpenGL scissor test.
A typical use case is a “curtain” comparison: two overlapping arrays are
stacked, and a draggable ClipSlider lets the user reveal one
array vs. the other by sliding a horizontal or vertical bar.
Author: HECE - University of Liege, Pierre Archambeau Date: 2024
Copyright (c) 2024 University of Liege. All rights reserved.
Module Contents
- class wolfhece.wolf_array._clipping.ClipSliderEdge(*args, **kwds)[source]
Bases:
enum.Enum
Which edge of the clip zone the slider controls.
- class wolfhece.wolf_array._clipping.WolfArrayClipZone(xmin: float = 0.0, ymin: float = 0.0, xmax: float = 1.0, ymax: float = 1.0, active: bool = True, owner_name: str = '', invert: bool = False)[source]
Bases:
wolfhece.wolf_array._header_wolf.header_wolf
Rectangular clipping zone in world coordinates.
Extends
header_wolfso that existing spatial tools (find_intersection(),get_bounds(), …) work seamlessly.The zone is defined by world-coordinate bounds
[xmin, xmax] × [ymin, ymax]. When active, the zone is applied as an OpenGL scissor rectangle during rendering: only the pixels that fall inside the zone are drawn.Usage:
clip = WolfArrayClipZone(xmin=160000, ymin=130000, xmax=170000, ymax=140000) my_array.add_clip_zone(clip)
Or from an existing header (another WolfArray for instance):
clip = WolfArrayClipZone.from_header(other_array)
- _sliders: list[ClipSlider] = [][source]
- set_bounds_clip(xmin: float, ymin: float, xmax: float, ymax: float)[source]
Set the clipping zone from world-coordinate bounds.
- world_to_scissor(view_xmin: float, view_ymin: float, view_xmax: float, view_ymax: float, vp_width: int, vp_height: int) tuple[int, int, int, int][source]
Convert world-coordinate bounds to a
glScissorrectangle.The returned
(sx, sy, sw, sh)tuple is in window-pixel coordinates, clamped to the current viewport.- Parameters:
view_xmin – Current viewport left (world coords).
view_ymin – Current viewport bottom (world coords).
view_xmax – Current viewport right (world coords).
view_ymax – Current viewport top (world coords).
vp_width – Viewport width in pixels.
vp_height – Viewport height in pixels.
- enable_scissor(view_xmin: float, view_ymin: float, view_xmax: float, view_ymax: float, vp_width: int, vp_height: int)[source]
Enable
GL_SCISSOR_TESTrestricted to this clip zone.
- draw_border(color: tuple = DEFAULT_COLOR, width: float = 2.0)[source]
Draw the clip-zone border as a world-coordinate rectangle.
- property sliders: list[ClipSlider][source]
All
ClipSliderobjects attached to this zone.
- property slider: ClipSlider | None[source]
First attached slider, or
None.
- attach_slider(edge: ClipSliderEdge = ClipSliderEdge.RIGHT, **kwargs) ClipSlider[source]
Create and attach a
ClipSlidercontrolling edge.Extra kwargs are forwarded to the
ClipSliderconstructor.- Returns:
The newly created slider.
- classmethod deserialize(data: dict) WolfArrayClipZone[source]
Reconstruct a clip zone from a serialized dict.
- classmethod from_header(h: wolfhece.wolf_array._header_wolf.header_wolf, active: bool = True, owner_name: str = '') WolfArrayClipZone[source]
Create a clip zone matching a
header_wolfextent.
- classmethod from_extent(xmin: float, ymin: float, xmax: float, ymax: float, active: bool = True, owner_name: str = '') WolfArrayClipZone[source]
Alias for the regular constructor (explicit factory).
- class wolfhece.wolf_array._clipping.ClipSlider(clip_zone: WolfArrayClipZone, edge: ClipSliderEdge = ClipSliderEdge.RIGHT, color: tuple = DEFAULT_COLOR, line_width: float = 3.0, grab_tolerance_px: int = 8, owner_name: str = '')[source]
Draggable horizontal or vertical bar controlling a clip-zone edge.
Provides the visual bar, hit testing, and drag logic. Mouse-event dispatch must be wired from the host viewer (e.g.
WolfMapViewer).- draw(view_xmin: float, view_ymin: float, view_xmax: float, view_ymax: float)[source]
Draw the slider bar across the full viewport extent.
Must be called outside any active scissor test so the bar is always fully visible.
- hit_test(world_x: float, world_y: float, sx: float, sy: float) bool[source]
Check whether a world-coordinate point is close enough to grab.
- Parameters:
world_x – Pointer X in world coordinates.
world_y – Pointer Y in world coordinates.
sx – Pixels per world-unit (horizontal scale).
sy – Pixels per world-unit (vertical scale).
- Returns:
Trueif withingrab_tolerance_pxpixels.
- class wolfhece.wolf_array._clipping.ClipConfig(name: str, owner_name: str, zones: list[WolfArrayClipZone])[source]
Named snapshot of clip zones for one array.
- classmethod deserialize(data: dict) ClipConfig[source]
- class wolfhece.wolf_array._clipping.ClipConfigs[source]
Collection of named
ClipConfigsnapshots.Follows the same pattern as
Memory_Views.- configs: dict[str, ClipConfig][source]
- add(cfg: ClipConfig)[source]