14 KiB
14 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-16T04:32:32.660920+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | cd00dc5bfe396de9 |
RegionsAndZones
Documentation: Regions and Zones Module
1. Purpose
This module provides data structures and UI adorning capabilities for defining and managing spatial regions and zones within test object templates, primarily for ISO-compliant test configuration. It enables users to define named zones (e.g., anatomical or functional areas) containing one or more rectangular regions, each associated with metadata (e.g., direction, filter class, transducer location) used to generate ISO codes and filter available channels. The module bridges raw template data (TemplateZone, TemplateRegion) with WPF-based UI interaction (via RegionAdorner) and supports bidirectional conversion between in-memory objects and ISO database representations.
2. Public Interface
Zone class
Zone(Zone copy, TestObjectTemplate template)
Copy constructor. Initializes a newZoneby copying properties (Description,Image,Regions) from an existingZone, preservingISODllZone, and preloading picture filenames.Zone(TemplateZone z, TestObjectTemplate template)
Constructor from ISOTemplateZone. LoadsDescription,Image, andRegions(converted toRegionobjects). Attempts to load and cache the zone picture as aBitmapImageif the file exists.string Name { get; set; }
Zone name, sourced fromISODllZone.ZoneName.string Description { get; set; }
Zone description, sourced fromISODllZone.Description(defaults to"").string Image { get; set; }
Filename of the zone picture, sourced fromISODllZone.Picture.TemplateZone ISODllZone { get; }
Read-only reference to the underlying ISOTemplateZoneobject.string[] AllPictures { get; }
Thread-safe array of filenames (not full paths) in theZonePicturessubdirectory of the app base directory. Populates on first access.void PopulateFilenamesIfNeeded()
Ensures_fileNamesis populated (only if empty), using a lock to prevent concurrent population.int PictureIndex { get; set; }
Index intoAllPicturesfor the currently selected picture. Setting triggers loading of the corresponding image intoPictureSource. Index-1setsPictureSourcetonull.string GetPictureName()
Returns the filename of the currently selected picture (empty string ifPictureIndex < 0).System.Windows.Media.ImageSource PictureSource { get; set; }
The WPFImageSourcefor the currently selected picture.Region[] Regions { get; set; }
Array ofRegionobjects in this zone.getreturns a copy;setreplaces the internal list.
RegionAdorner class
RegionAdorner(UIElement adornedElement, TestObjectTemplate template, Contexts context)
Constructor. Creates a new adorner for anImage(or otherUIElement). Initializes_region, sets up mouse event handlers, and configures visual path (AliceBlue stroke, 60% opacity, initially hidden).Point GetUpperLeft()
Returns the upper-left corner ofSelectRect, adjusted for scaling between the adorned element’sRenderSizeand itsSourcedimensions.Point GetLowerRight()
Returns the lower-right corner ofSelectRect, similarly scaled.bool IsNew { get; set; }
Controls visibility of region add/delete UI:true→RegionAddVisibility=Visible,RegionDeleteVisibility=Hidden;false→ vice versa.Rect SelectRect { get; set; }
Bounding rectangle of the region in adorner coordinates. Setting it updatesMyRegion.RegionUpperLeft/RegionBottomRightviaGetUpperLeft()/GetLowerRight().Region MyRegion { get; set; }
Reference to the associatedRegionobject.Contexts Context { get; set; }
Context enum (EditTestObjectorEditTestObjectTemplate) indicating usage mode.event RegionSelectedHandler OnRegionSelected
Raised onMouseLeftButtonDown.event EndSelectionHandler OnEndSelection
Raised onMouseLeftButtonUp(viaEndSelection()).void DrawSelection(...)
UpdatesSelectRectto a rectangle defined byAnchorPointand current mouse position (used during region creation).void MoveSelection(...)
UpdatesSelectRectby translating it by the mouse delta (used during region movement).
Region class
Region(RegionAdorner adorner, TestObjectTemplate template)
Constructor for a new region. Sets default name/description, assignsTemplate, initializesRegionChannels/RegionUIChannelsfrom template, and callsDetermineAvailableISOSettings().Region(TestObjectTemplate template, TemplateRegion r)
Constructor from ISOTemplateRegion. Populates all properties fromr(e.g.,RegionUpperLeft,RegionDirection,ISOCode) and callsFilterRegionChannels()andSetISOCode().string RegionName { get; set; }
User-facing region name.string RegionDescription { get; set; }
User-facing region description.Point RegionUpperLeft { get; set; }
Upper-left coordinate (WPFPoint) of the region.Point RegionBottomRight { get; set; }
Lower-right coordinate (WPFPoint) of the region.MMEDirections RegionDirection { get; set; }
Direction metadata (e.g., "Anterior", "Posterior"). Setting updates_directionIndexand callsSetISOCode().MMEFilterClasses RegionFilterClass { get; set; }
Filter class metadata. Setting updates_filterClassIndexand callsSetISOCode().MMEFineLocations1 RegionFineLocation1 { get; set; }
Fine location 1 metadata. Setting updates_fineLocation1Indexand callsSetISOCode().MMEFineLocations2 RegionFineLocation2 { get; set; }
Fine location 2 metadata. Setting updates_fineLocation2Indexand callsSetISOCode().MMEFineLocations3 RegionFineLocation3 { get; set; }
Fine location 3 metadata. Setting callsSetISOCode().MMETransducerMainLocation RegionMainLocation { get; set; }
Main transducer location metadata. Setting updates_mainLocationIndexand callsSetISOCode().MMEPhysicalDimensions RegionPhysicalDimension { get; set; }
Physical dimension metadata. Setting updates_physicalDimensionIndexand callsSetISOCode().MMEPositions RegionPosition { get; set; }
Position metadata. Setting updates_positionIndexand callsSetISOCode().MMETestObjects RegionTestObject { get; set; }
Test object type (e.g., "Breast", "Brain").TestObjectTemplate Template { get; set; }
Reference to the parent template. Setting triggersDetermineAvailableISOSettings().string[] AllDirections { get; set; }
Available direction options (from template).setalso populatesAllDirectionsStrings.string[] AllDirectionsStrings { get; }
Human-readable direction names (e.g.,"Anterior").MMEFilterClasses[] AllFilterClasses { get; set; }
Available filter classes.setpopulatesAllFilterClassStrings.string[] AllFilterClassStrings { get; }
Human-readable filter class names.MMEFineLocations1[] AllFineLocations1 { get; set; }
Available fine location 1 options.setpopulatesAllFineLocations1Strings.string[] AllFineLocations1Strings { get; }
Human-readable fine location 1 names ("??"for null).MMEFineLocations2[] AllFineLocations2 { get; set; }
Available fine location 2 options.setpopulatesAllFineLocations2Strings.string[] AllFineLocations2Strings { get; }
Human-readable fine location 2 names.int FineLocation2Index { get; set; }
Index intoAllFineLocations2. Setting updatesRegionFineLocation2and callsFilterRegionChannels().MMEFineLocations3[] AllFineLocations3 { get; set; }
Available fine location 3 options.setpopulatesAllFineLocations3Strings.string[] AllFineLocations3Strings { get; }
Human-readable fine location 3 names.MMETransducerMainLocation[] AllMainLocations { get; set; }
Available main location options.setpopulatesAllMainLocationsStrings.string[] AllMainLocationsStrings { get; }
Human-readable main location names ("????"for null).MMEPhysicalDimensions[] AllPhysicalDimensions { get; set; }
Available physical dimension options.setpopulatesAllPhysicalDimensionStrings.string[] AllPhysicalDimensionStrings { get; }
Human-readable physical dimension names ("??"for null).MMEPositions[] AllPositions { get; set; }
Available position options.setpopulatesAllPositionStrings.string[] AllPositionStrings { get; }
Human-readable position names.string ISOCode { get; set; }
16-character ISO code string (e.g.,"BREAST?ANTERIOR???????"). Generated bySetISOCode()from metadata fields.TestObjectTemplateChannel[] RegionChannels { get; set; }
List of channels available for this region (filtered byRegionMainLocation,RegionDirection, etc.).settriggersDetermineAvailableISOSettings().TemplateChannelUI[] RegionUIChannels { get; set; }
UI-friendly channel list (mirrorsRegionChannels).Visibility RegionAddVisibility { get; set; }
UI visibility flag for "add region" controls.Visibility RegionDeleteVisibility { get; set; }
UI visibility flag for "delete region" controls.TemplateRegion ToISORegion(TestObjectTemplate template, Zone zone, int number)
Converts thisRegionto aTemplateRegionfor ISO export. UsesRegionUpperLeft/RegionBottomRight(converted toSystem.Drawing.Point), and maps null metadata to ISO defaults ("?","??","????").
3. Invariants
- Picture filename consistency:
PictureIndexmust be in[0, AllPictures.Length-1]or-1. SettingPictureIndexto-1setsPictureSourcetonull. - ISO code format:
ISOCodeis always 16 characters, with"?","??", or"????"used for missing metadata fields. - Channel filtering:
RegionChannelsis always a subset ofTemplate.TemplateAllChannels, filtered byRegionMainLocation,RegionDirection,RegionFilterClass,RegionFineLocation1/2/3,RegionPhysicalDimension, andRegionPosition. - Metadata consistency:
RegionDirection,RegionFilterClass, etc., are alwaysnullor a valid object from their respectiveAll*arrays. - Thread safety:
_fileNamespopulation is guarded by a static lock (MyLock), andAllPicturesalways accesses_fileNamesunder this lock. - Region bounds:
RegionUpperLeftandRegionBottomRightare WPFPointcoordinates relative to the adorned image.
4. Dependencies
- Imports/References:
System,System.Collections.Generic,System.Linq(core .NET)System.Windows,System.Windows.Controls,System.Windows.Documents,System.Windows.Input,System.Windows.Media,System.Windows.Shapes(WPF)System.ComponentModel(INotifyPropertyChanged)App(fromApplication.Current),IsoDb,TestObjectTemplate,TemplateZone,TemplateRegion,MMEDirections,MMEFilterClasses,MMEFineLocations1/2/3,MMETransducerMainLocation,MMEPhysicalDimensions,MMEPositions,MMETestObjects,TestObjectTemplateChannel,TemplateChannelUI(all inferred from usage).
- External resources:
ZonePicturessubdirectory inAppDomain.CurrentDomain.BaseDirectory(for zone images).
- Depended on by:
- UI layers (e.g., WPF adorner layers using
RegionAdorner). - Database import/export logic (via
ToISORegionandZoneconstructors).
- UI layers (e.g., WPF adorner layers using
5. Gotchas
- Picture loading failure: If
Imageis set but the file does not exist atZonePictures/<Image>,PictureIndexis set to-1silently (no exception thrown). - Scaling assumptions:
GetUpperLeft()/GetLowerRight()assume the adorned element is anImagewith aBitmapImagesource. Scaling logic may be incorrect ifSourcedimensions are unavailable or non-integer. FineLocation2Indexsetter: Only updatesRegionFineLocation2and callsFilterRegionChannels(); does not update_fineLocation2Indexdirectly (relies onRegionFineLocation2setter).RegionFineLocation3setter: Does not update_fineLocation3Index(emptyelseblock), unlike other fine location properties.AllPicturesthread safety: While_fileNamespopulation is thread-safe,AllPicturesreturns a snapshot array. Concurrent modifications to_fileNames(e.g., viaPopulateFilenames()) during enumeration could causeIndexOutOfRangeExceptionif not for the lock (butAllPicturesitself is safe).Regionconstructor fromTemplateRegion: Uses((App)Application.Current).IsoDbfor lookups. IfIsoDbis not initialized, this will throw aNullReferenceException.RegionChannels/RegionUIChannels: Thesetaccessor forRegionChannelscallsDetermineAvailableISOSettings(), which may overwrite previously set values (e.g.,RegionDirection,RegionFilterClass).- ISO code generation:
SetISOCode()uses"?"for nullRegionTestObject, but"???"for nullRegionMainLocation(inconsistent padding).