Files
DP44/enriched-qwen3-coder-next/Common/DTS.Common/Events/RegionOfInterest/RegionOfInterestChannels.md

55 lines
4.9 KiB
Markdown
Raw Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- Common/DTS.Common/Events/RegionOfInterest/RegionOfInterestChannels/RegionOfInterestChannelsSelectedEvent.cs
generated_at: "2026-04-16T03:25:26.350849+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "708a3abe68702000"
---
# RegionOfInterestChannels
## 1. Purpose
This module defines a Prism-based event for propagating region-of-interest (ROI) channel selection changes across the application. Specifically, `RegionOfInterestChannelsSelectedEvent` is a `PubSubEvent` used to broadcast when a user or system component selects a set of channels (by name and ID) for a given ROI—identified by its suffix—along with the consumer responsible for the selection. It enables decoupled communication between ROI management UI components (e.g., channel selectors) and downstream consumers (e.g., visualization or processing modules) without tight coupling.
## 2. Public Interface
- **`RegionOfInterestChannelsSelectedEvent`**
*Type:* `class` (inherits from `Prism.Events.PubSubEvent<RegionOfInterestChannelsSelectedEventArgs>`)
*Behavior:* A Prism event used to publish and subscribe to ROI channel selection changes. Subscribers receive an instance of `RegionOfInterestChannelsSelectedEventArgs` containing the selection details.
- **`RegionOfInterestChannelsSelectedEventArgs`**
*Type:* `class`
*Behavior:* Encapsulates the payload of a channel selection event.
- **Constructor:**
`RegionOfInterestChannelsSelectedEventArgs(string roiSuffix, string[] selectedChannelNames, long[] selectedChannelIds, object o)`
Initializes the event args with the ROI suffix, selected channel names, selected channel IDs, and the consumer object. All properties are set once and immutable after construction.
- **Properties:**
- `string RegionOfInterestSuffix { get; }` — The suffix identifying the ROI (e.g., `"Brain"`, `"Tumor"`), used to correlate the selection with a specific ROI context.
- `string[] ChannelNames { get; }` — Ordered array of selected channel *names* (e.g., `["Red", "Green"]`). May be empty.
- `long[] ChannelIds { get; }` — Ordered array of corresponding selected channel *IDs* (e.g., `[101L, 102L]`). Must be same length as `ChannelNames`.
- `object Consumer { get; }` — The object (typically a view model or service) that triggered or is responsible for the selection. Used to avoid re-processing events originating from the same consumer.
## 3. Invariants
- `ChannelNames.Length == ChannelIds.Length` must hold for all valid instances (enforced by caller; no runtime validation is present in the class).
- `RegionOfInterestSuffix` is non-null and non-empty (implied by usage context; not validated in the constructor).
- `ChannelNames` and `ChannelIds` arrays are never `null` (constructor assigns them directly; caller must provide non-null arrays).
- `Consumer` may be `null`, but typically represents a unique consumer instance to prevent echo loops.
- The order of elements in `ChannelNames` and `ChannelIds` is semantically meaningful (i.e., index `i` in `ChannelNames` corresponds to index `i` in `ChannelIds`).
## 4. Dependencies
- **Dependencies *on* this module:**
- `Prism.Events` (via `PubSubEvent<T>`) — Required for event publication/subscription.
- `Prism.Regions` — Imported but *not used* in this file (likely a remnant or for future extension).
- **Dependencies *of* this module:**
- Consumers of `RegionOfInterestChannelsSelectedEvent` (e.g., view models, services) must subscribe to it using Prisms event aggregator.
- Publishers must provide valid `RegionOfInterestChannelsSelectedEventArgs` instances.
- **Inferred consumers:**
- Any module handling ROI-specific channel logic (e.g., rendering, analysis pipelines) likely subscribes to this event.
## 5. Gotchas
- **No validation of array lengths or nulls in the constructor** — Callers must ensure `selectedChannelNames` and `selectedChannelIds` are non-null and of equal length; otherwise, downstream consumers may encounter `IndexOutOfRangeException` or inconsistent state.
- **`Consumer` is an `object`** — No type safety or interface contract is enforced. Subscribers must cast or check the type themselves (e.g., `is IRegionOfInterestConsumer`), risking runtime errors if misused.
- **`Prism.Regions` is imported but unused** — Suggests possible historical or future use (e.g., region-scoped events), but currently adds no value and may confuse readers.
- **No documentation of expected ROI suffix format** — The meaning of `RegionOfInterestSuffix` (e.g., casing, allowed characters) is application-specific and not defined here.
- **No mechanism to distinguish initial selection vs. subsequent updates** — Subscribers must track state themselves to avoid redundant processing.
- **No cancellation or error handling support** — The event is fire-and-forget; subscribers cannot signal failure or abort propagation.