Cornerstone viewport and tools
The Cornerstone viewport and tools layer turns OHIF display sets into interactive image views. It coordinates viewport creation, image and volume presentation, user tools, commands, measurements, overlays, and related services so a study becomes a usable viewing surface rather than raw image data.
Viewport system
The viewport system is the main runtime surface for imaging content. It receives display sets and view options from OHIF, asks the Cornerstone viewport service to mount them, and exposes a consistent place for rendering and interaction.
Extension boundary
The primary extension is registered as @ohif/extension-cornerstone through extensions/…/index.tsx. It supplies the cornerstone viewport module and registers the services that make the viewport useful: viewport, tool group, synchronizer, segmentation, cache, colorbar, and viewed-data services.
Cornerstone initialization runs before the extension connects these services. It prepares image loading, metadata, rendering choices, prefetch, cine playback, measurement links, and error reporting. Other OHIF modules then use extension contracts instead of reaching into Cornerstone directly.
The extension also publishes the default customization set for viewport overlays, tools, rendering controls, toolbar sections, segmentation panels, and GPU settings. Mode customization can compose these capabilities without replacing the extension boundary.
The package boundary in extensions/…/package.json defines the extension entry points and its Cornerstone and OHIF compatibility contract. The package exposes its source module and shared types while keeping the rendering layer aligned with the host application's shared services and imaging libraries.
References: extensions/…/package.json• L1-14 extensions/…/package.json• L36-70 extensions/…/index.tsx• L112-169 extensions/…/index.tsx• L210-285 extensions/…/init.tsx• L58-80 extensions/…/init.tsx• L147-267 extensions/…/getCustomizationModule.tsx• L21-49
Viewport contract
ViewportInfo is the OHIF-side record for one viewport. It keeps the viewport ID, display-set choices, tool group, orientation, background, synchronization groups, initial image choice, and saved presentation IDs together so the service can rebuild a view without losing its place.
The Cornerstone viewport itself is the rendering object. The service keeps this rendering object separate from ViewportInfo, which lets OHIF replace the displayed data while preserving the user-facing state. Public options are normalized into a common form before the viewport is mounted.
References: extensions/…/Viewport.ts• L21-59 extensions/…/Viewport.ts• L130-143 extensions/…/Viewport.ts• L256-315
Viewport adapter
The viewport adapter is the common behavior boundary between the established Cornerstone viewport path and the native generic viewport path. It gives commands and controls one way to classify content, read or change view state, address display-set appearance, find volume data, and copy a displayed view.
The native path keeps presentation per display set and addresses volume data by its source identity. The adapter preserves those rules while mapping the same user-facing operations to the established path, so a toolbar action does not need to know which rendering path owns the viewport.
References: extensions/…/NextViewportAdapter.ts• L39-91 extensions/…/NextViewportAdapter.ts• L112-210 extensions/…/NextViewportAdapter.ts• L213-240 extensions/…/IViewportAdapter.contract.test.ts• L83-143 extensions/…/IViewportAdapter.contract.test.ts• L234-383 extensions/…/IViewportAdapter.contract.test.ts• L423-466
Viewport rendering
Viewport rendering covers the path from display-set data to a visible stack, volume, waveform, video, or whole-slide view. The same service coordinates these content types while keeping their view controls separate from the source study data.
Viewport lifecycle
OHIFCornerstoneViewport owns the link between a React viewport tile and its Cornerstone element. On mount it enables the viewport, registers the element for OHIF use, joins the configured tool and synchronizer groups, and loads display-set data through the cache and viewport services. It watches real element size changes so a hidden or zero-sized tile does not trigger a broken render.
When the tile leaves the layout, it stores presentation state before it removes group membership, clears segmentation representations, disables the element, and unregisters the element reference. A display-set metadata change can rebuild the viewport data while keeping the camera position. The component also treats dynamic reconstructable data as volume content and refreshes the viewport when its source metadata is invalidated. A viewport tile can include overlays, cine controls, and active-viewport behavior without changing the rendering contract.
Viewport data changes report success only after the mount completes. A failed mount is logged instead of broadcasting a ready-state change, so listeners do not treat an incomplete viewport as usable.
This diagram shows the normal lifecycle from a viewport tile to a cleaned-up rendering surface.
flowchart LR
A[Viewport tile] --> B[Enable Cornerstone element]
B --> C[Create viewport data]
C --> D[Mount stack or volume]
D --> E[Join tools and synchronizers]
E --> F[Render and interact]
F --> G[Store presentation]
G --> H[Remove groups and disable element]
References: extensions/…/OHIFCornerstoneViewport.tsx• L72-150 extensions/…/OHIFCornerstoneViewport.tsx• L152-234 extensions/…/OHIFCornerstoneViewport.tsx• L236-320 extensions/…/CornerstoneViewportService.ts• L186-212 extensions/…/CornerstoneViewportService.ts• L514-619 extensions/…/CornerstoneViewportService.ts• L1520-1560
Viewport families
The service maps display-set data to the view that can present it. Stack views browse ordered images. Volume views support reformatted slices, fusion, projections, or 3D display. Other families support ECG waveforms, video, and whole-slide images. ECG views present waveform channels from DICOM waveform data rather than image slices.
The built-in MPR protocol presents one reconstructable display set in a 1x3 group of axial, sagittal, and coronal volume views. Its reformat stage uses the same group and keeps VOI and colormap state aligned while derived segmentation data follows matching frame-of-reference rules.
The extension supports the established Cornerstone viewport path and an optional native generic viewport path. The viewport service selects one path for its lifetime, while the viewport adapter and service contract hide differences in view state, appearance, data addressing, and content checks. This keeps commands and UI controls focused on user intent instead of on the active rendering path.
| View family | Main viewing purpose |
|---|---|
| Stack | Browse an ordered acquisition or image series |
| Volume or MPR | Reformat a reconstructable study and compare volume layers |
| 3D volume | Render a volume with a 3D appearance preset |
| ECG | Show waveform content |
| Video | Play DICOM video content |
| Whole slide | Browse large microscopy content |
References: extensions/…/CornerstoneViewportService.ts• L146-171 extensions/…/CornerstoneViewportService.ts• L905-927 extensions/…/CornerstoneViewportService.ts• L1015-1155 extensions/…/LegacyViewportBackend.ts• L38-75 extensions/…/NextViewportBackend.ts• L126-184 extensions/…/IViewportAdapter.ts• L42-69 extensions/…/mpr.ts• L3-20 extensions/…/mpr.ts• L51-195
Presentation state
Presentation state describes how a display set looks and where the user is viewing it. It includes the current slice or view reference, pan and zoom, rotation, flips, window and level, inversion, colormap, and segmentation appearance.
The viewport service stores this state when content changes or a tile closes. It restores the state when the display set returns. A hanging protocol can therefore set the first view without preventing later user changes from surviving layout changes.
References: extensions/…/CornerstoneViewportService.ts• L316-404 extensions/…/CornerstoneViewportService.ts• L485-587 extensions/…/IViewportAdapter.ts• L94-123
Rendering controls
The rendering controls change the visible presentation without changing the source study. Window and level adjust image brightness and contrast. Colormaps, opacity, thresholds, volume presets, lighting, orientation, rotation, flips, scale, slice position, and reset provide the main ways to inspect image content.
Controls address the active display set in a viewport. In a fusion view, the first base layer remains the source image and the topmost foreground layer receives display controls when one exists. Segmentation and other derived overlays use their own representation path so they do not replace the source layer.
The useViewportRendering hook gives React controls a viewport-focused API. It reads the selected layer's current presentation and turns UI changes into commands or adapter calls. When a layer has no saved window and level, it uses that layer's default values instead of showing the prior layer's state. The same API exposes colorbars, colormaps, opacity, thresholds, and 3D volume settings across viewport types.
The ViewportWindowLevel panel presents per-volume histograms, window and level values, and opacity controls for the active viewport. It checks volume load state from the cache when it opens, refreshes histogram data as volumes load or change, and applies opacity to other compatible viewports that show the same volume set. This keeps the control useful for volume-capable generic viewports as well as dedicated volume viewports.
The WindowLevelTool keeps the standard Cornerstone tool name while guarding the window-level drag action. It ignores drags when no viewport is enabled or when the viewport has no VOI range, such as ECG viewports. This lets the shared tool remain safe across viewport families while normal image viewports still use the base Cornerstone behavior.
References: extensions/…/useViewportRendering.tsx• L91-176 extensions/…/useViewportRendering.tsx• L219-242 extensions/…/useViewportRendering.tsx• L268-368 extensions/…/useViewportRendering.tsx• L469-681 extensions/…/useViewportRendering.tsx• L698-821 extensions/…/ViewportWindowLevel.tsx• L15-38 extensions/…/ViewportWindowLevel.tsx• L69-95 extensions/…/ViewportWindowLevel.tsx• L132-224 extensions/…/CornerstoneViewportService.ts• L1128-1298 extensions/…/WindowLevelTool.ts• L5-22 extensions/…/index.ts• L7-13
GPU rendering presets
GPU rendering presets control how volume data fits into GPU texture limits. A selected cornerstone.gpuSettingsPreset also enables final lossy downsampling; the null value restores the Cornerstone default preset and the application's configured downsampling choice.
The preset is applied during initialization and again when global or mode customization changes. Volume viewports read it when they add their actors, so the setting must be available before a volume view opens.
References: extensions/…/gpuSettingsPresetCustomization.ts• L1-8 extensions/…/initGpuSettingsPreset.ts• L1-18 extensions/…/initGpuSettingsPreset.ts• L20-51 extensions/…/init.tsx• L121-167 extensions/…/getCustomizationModule.tsx• L41-49
Tool interaction
Cornerstone tools turn a rendered viewport into an interactive work surface. Tool groups attach sets of tools to viewports and control which tool responds to pointer, touch, keyboard, or wheel input.
Tool groups
The tool group service creates groups, adds tools, assigns viewports, and tracks each tool's active, passive, enabled, or disabled state. A viewport joins its configured group when its Cornerstone element becomes ready.
The default customization provides separate capability blocks for common navigation, annotation, and segmentation tools. Modes can add these blocks to a group, while toolbar evaluators hide or disable a control when its tool or viewport type is not available in the current viewport. Toolbar definitions and toolbar sections are published as reusable capabilities that a mode can compose.
Tool bindings can be persisted as user preferences. This lets a returning user keep a preferred mouse or touch action without changing the tool's meaning for other viewports.
References: extensions/…/ToolGroupService.ts• L82-125 extensions/…/ToolGroupService.ts• L137-225 extensions/…/ToolGroupService.ts• L282-341 extensions/…/viewportToolsCustomization.ts• L4-32 extensions/…/toolGroupToolsCustomization.ts• L140-201 extensions/…/toolbarButtonsCustomization.ts• L714-802 extensions/…/getCustomizationModule.tsx• L21-49
Imaging tools
The extension registers tools in broad groups that match the work a viewer performs. Navigation tools move through images or change the view. Measurement tools draw lengths, angles, regions, probes, and annotations. Segmentation tools create or edit labelmap and contour data. Reference and overlay tools add context without changing the source image.
The registered set also includes tools for crosshairs, fusion and projection navigation, magnification, calibration, ultrasound findings, and volume interaction. A tool becomes usable only after a mode places it in a relevant tool group.
| Tool group | User goal |
|---|---|
| Navigation and view | Pan, zoom, scroll, rotate, orient, reset, or follow crosshairs |
| Measurement and annotation | Mark geometry or describe a finding |
| Segmentation editing | Paint, erase, select, interpolate, or edit segments |
| Context and display | Show reference lines, image overlays, labels, or magnified views |
References: extensions/…/initCornerstoneTools.js• L56-121 extensions/…/initCornerstoneTools.js• L137-185 extensions/…/viewportToolsCustomization.ts• L4-32 extensions/…/toolGroupToolsCustomization.ts• L140-199
Command surface
Commands provide the application-facing actions for viewport and tool behavior. They resolve a requested viewport or the active viewport, check the available tool group or display set, apply the action through the viewport service or adapter, and render when needed. This keeps toolbar buttons, panels, and keyboard actions aligned across both viewport paths.
The command surface covers six main areas:
- View navigation: slice jumps, scrolling, orientation, rotation, flips, scale, reset, and measurement navigation.
- Image appearance: window and level, presets, inversion, colormaps, thresholds, opacity, and 3D rendering controls.
- Tool state: activate, enable, disable, toggle, bind, and cancel tools.
- Study interaction: toggle cine, synchronize viewports, show context menus, and capture a viewport.
- Derived data: load or hydrate display sets, manage segmentations, update measurements, and export measurement or segmentation reports.
- Assisted editing: control segmentation previews, brush settings, interpolation, and optional labelmap assistance.
Commands are the main contract between toolbar buttons, panels, keyboard actions, and Cornerstone. They use one resolution rule for most viewport actions: an explicit viewport takes priority, then the active viewport is used. Missing viewports and tools stop the action instead of producing a partial update. Shared viewport operations keep the command behavior aligned across the established and native rendering paths.
Commands also coordinate actions that cross service boundaries. Display-set data can be loaded without choosing a viewport, which lets derived data become available before a later display decision. Measurement navigation can select a compatible viewport or update a viewport configuration. Derived-display-set hydration records the intended overlay and position before it loads the referenced image, and it applies a requested viewport type only to the hydration target. Other compatible panes keep their existing render mode. The generic Escape action clears either a segmentation preview or an annotation in progress, and orientation changes require both volume capability and reconstructable source data.
This makes commands the place where user intent becomes a safe service operation. A UI control should call a command instead of reimplementing viewport-specific behavior.
References: extensions/…/commandsModule.ts• L122-159 extensions/…/commandsModule.ts• L236-441 extensions/…/commandsModule.ts• L1016-1181 extensions/…/commandsModule.ts• L1273-1435 extensions/…/commandsModule.ts• L1978-2139 extensions/…/commandsModule.ts• L2163-2311 extensions/…/commandsModule.ts• L2613-2942 extensions/…/NextViewportAdapter.ts• L112-240
Measurement bridge
The measurement bridge keeps Cornerstone annotations and OHIF measurements aligned. Supported annotation tools map to measurement records when annotations are added or completed. Later edits, selections, labels, lock state, visibility, and removals flow back to the matching Cornerstone annotation.
This shared identity lets the measurement service support panels, jump-to-measurement navigation, undo and redo, and export while Cornerstone remains responsible for drawing the annotation in the viewport. Calibration uses the same tool family but applies a physical spacing change after the user enters the known length.
References: extensions/…/initMeasurementService.ts• L22-199 extensions/…/initMeasurementService.ts• L202-346 extensions/…/initMeasurementService.ts• L349-551 extensions/…/CalibrationLineTool.ts• L51-97
Segmentation panel
The segmentation panel is exposed through extensions/…/getPanelModule.tsx as reusable UI capabilities for selecting, editing, styling, viewing, and exporting segmentation data in the active viewport. It provides general and no-header variants, plus representation-specific panels that pair segmentation controls with the matching labelmap or contour toolbox.
The panel maps each representation to its toolbar section and uses commands for selection, editing, visibility, style, centering, and export actions. A representation-specific panel selects the active segmentation for that representation in the current viewport. It also shows utility settings in a popover and reads mode customizations through change-aware subscriptions, so a mode can change the table layout or editing behavior after the panel mounts.
Export availability follows the data that a segmentation exposes. Segmentations with usable labelmap or contour data are exportable; a segmentation with neither representation loaded remains available as an export option for downstream handling rather than being hidden by the panel.
References: extensions/…/getPanelModule.tsx• L10-29 extensions/…/getPanelModule.tsx• L46-67 extensions/…/getPanelModule.tsx• L70-123 extensions/…/PanelSegmentation.tsx• L21-71 extensions/…/PanelSegmentation.tsx• L92-108 extensions/…/PanelSegmentation.tsx• L110-226 extensions/…/PanelSegmentation.tsx• L244-337
Service integration
Viewport behavior depends on services that hold state outside the canvas. These services let several tiles share view state, display derived data, show load progress, and clean up resources when a mode ends.
Synchronizers and cine
The synchronizer service coordinates related viewports. It can keep camera position, window and level, zoom and pan, or image slice position aligned. Source and target roles support one-way links, while a shared group supports common changes across several tiles. The viewport component restores prior synchronizer membership when a tile is rebuilt outside a hanging protocol layout.
The extension also registers a frame-view synchronizer for frame-based content. Cine support adds time playback for dynamic volumes and stops playback before a viewport's display sets change. When the active viewport changes or its data changes, the active-viewport behavior can enable cine for configured dynamic modalities or dynamic volumes. Manual slice scrolling stops active cine before it changes the image. These rules prevent playback from holding stale content while a viewport is being repurposed.
References: extensions/…/SyncGroupService.ts• L36-167 extensions/…/SyncGroupService.ts• L170-243 extensions/…/OHIFCornerstoneViewport.tsx• L152-234 extensions/…/ActiveViewportBehavior.tsx• L15-73 extensions/…/ViewportImageScrollbar.tsx• L24-41 extensions/…/index.tsx• L210-223 extensions/…/commandsModule.ts• L1009-1014 extensions/…/commandsModule.ts• L1919-1934
Overlays and status
Viewport overlays present context around the image without becoming part of the image data. The overlay system can show metadata, window and level, zoom, instance and slice position, orientation markers, loading state, and a slice scrollbar. Orientation markers follow the current camera and wait for world-coordinate points when a whole-slide viewport has not loaded its slide metadata. A viewport option can hide the complete overlay layer when a mode needs an unobstructed image surface.
The progress scrollbar combines slice navigation with loaded and viewed progress. A legacy scrollbar remains available through customization and tracks the current image index from viewport slice events. Selecting a new image through that scrollbar stops cine first. The viewed-data service records which data identifiers the user has seen, while the colorbar service exposes active colormaps for data layers that support them. Customization controls which overlay and status elements appear.
Pixel overlays use ImageOverlayViewerTool to turn DICOM overlay data into a displayable layer. The tool is not a drawing tool; it provides a toggleable visual layer tied to the current image. SEG and RTSTRUCT layers follow a separate representation path, so the source image remains available while derived data is added or removed.
References: extensions/…/CornerstoneOverlays.tsx• L15-99 extensions/…/ViewportOrientationMarkers.tsx• L19-109 extensions/…/ViewportImageScrollbar.tsx• L24-101 extensions/…/CustomizableViewportOverlay.tsx• L54-75 extensions/…/ViewportSliceProgressScrollbar.tsx• L21-121 extensions/…/ViewedDataService.ts• L8-55 extensions/…/ColorbarService.ts• L42-131 extensions/…/ImageOverlayViewerTool.tsx• L19-30 extensions/…/CornerstoneViewportService.ts• L1342-1505
Data loading and cleanup
Cornerstone loading uses the active OHIF data source and shared metadata. SOP class handlers first turn supported whole-slide microscopy and ECG series into display sets with the metadata needed by their viewport families. The extension then registers image and volume loaders, applies authentication and transfer-syntax settings, and separates request work for interaction, thumbnails, prefetch, and computation. ECG metadata uses the same data-source boundary for waveform bulk data, so authentication and bulk-data URI handling remain outside the viewport code. Cached waveform bytes are reused on later reads, while a failed read can be retried.
Cleanup is part of the viewport contract. Mode exit clears request queues, metadata cache entries, enabled elements, presentation stores, viewed data, and segmentation state. Viewport disable also releases native data registrations before the viewport record is removed. When a SEG layer is still loading, representation setup waits for the data to exist but is bounded so a failed load cannot block viewport readiness forever. ECG mount failures follow the same readiness rule: the service shows an error and rejects the mount instead of reporting a successful viewport update.
References: extensions/…/init.tsx• L214-257 extensions/…/init.tsx• L239-245 extensions/…/index.tsx• L171-203 extensions/…/CornerstoneViewportService.ts• L263-301 extensions/…/CornerstoneViewportService.ts• L905-927 extensions/…/CornerstoneViewportService.ts• L1377-1505 extensions/…/NextViewportBackend.ts• L660-671 extensions/…/ecgMetadata.ts• L40-108 extensions/…/getSopClassHandlerModule.js• L18-150 extensions/…/getSopClassHandlerModule.js• L165-251
Related pages
This page is a child of Cornerstone imaging integration. Read DICOM segmentation and RT for derived segmentation and RT structure lifecycles, and structured reports and measurements for report-driven findings and measurement workflows.
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to viewport data shape or viewport type must preserve stack-versus-volume selection on both established and native viewport paths.
- New tools must be registered, named, added to the right tool-group customization, and connected to toolbar evaluation when a button exposes them.
- New annotation tools must keep their measurement mapping and annotation event identity aligned with the measurement service.
- Changes to command names or options must be reflected in toolbar controls, panels, hooks, keyboard actions, and any extension that calls the command.
- Changes to viewport operation behavior must preserve both explicit-viewport and active-viewport command paths, including stack, MPR, and native generic viewports.
- Changes to presentation capture or restore must preserve view position, image appearance, and derived representations during viewport reuse.
- Changes to overlay display sets must preserve their reference to source image data and their separate representation path.
- Changes to derived-data hydration must preserve the distinction between the target pane's requested viewport type and the render mode of other compatible panes.
- Changes to service events must preserve the subscribers that refresh toolbars, overlays, measurements, and segmentation state.
- Changes to viewport disable order must release tool groups, synchronizers, segmentation representations, request work, and native data registrations.
- Changes to viewport size handling must keep zero-size tiles from resizing and must keep the scrollbar height aligned with the visible tile.
- Changes to active-layer selection must keep window and level, colormap, opacity, threshold, and colorbar controls on the intended foreground display set.
- Changes to segmentation panel modules or representation-specific toolbox mappings must keep panel names, labels, and toolbar sections aligned with the representation type.
- Changes to segmentation panel customizations must keep mode-enter registrations visible after the panel has mounted.
- Changes to segmentation export checks must preserve the distinction between missing representations and representations that lack usable export data.
- Changes to automatic cine rules must preserve both active-viewport changes and manual slice navigation as playback boundaries.
- Changes to window-level tool support must keep the shared tool name and must guard viewport types that do not expose a VOI range.
- Changes to the window-level panel must keep cache state, volume-load events, and volume-change events aligned so completed volumes do not start a permanent refresh loop.
- Changes to volume opacity handling must preserve updates across all compatible viewports that show the same volume set.
- Changes to orientation markers must preserve camera-change refreshes and the no-marker state while world points are unavailable.
- Changes to ECG metadata must keep waveform bulk-data loading inside the data-source contract, including auth headers, cached bytes, and retry after failure.
- Changes to mount errors must keep readiness events limited to successful mounts and must preserve the user-facing ECG error notice.
- Changes to GPU preset customization must preserve the link between the selected preset, final downsampling, and volume actor creation.
- Changes to toolbar capability packs must preserve the mode composition contract for button definitions and toolbar sections.
- Changes to the command used for Escape must keep preview rejection and annotation cancellation in the same safe, no-op-compatible operation.
- Changes to viewport-independent display-set loading must keep data availability separate from the later choice of where to render it.
- Changes to volume lookup must retain capability-based handling for native generic viewports rather than relying on viewport class checks.
- Changes to the extension package exports or runtime contract must keep the host able to resolve the public entry point and shared types with the supported Cornerstone and OHIF versions.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A viewport is resized while its tile has zero width and height | The render surface can become permanently black after the tile becomes visible | Ignore zero-size resize events and resize again when the element has real dimensions |
| Native viewport data loses its independent stack-versus-volume shape | The service can select the wrong mount path because native planar types do not identify their content alone | Preserve the data shape and route live viewport actions through the adapter |
| A command targets a tool that is not in the viewport's tool group | The toolbar action appears to do nothing | Add the tool to the mode's tool-group capability block and let the evaluator check availability |
| A window-level drag reaches an ECG or missing viewport | Cornerstone can reject the action because the viewport has no usable VOI range | Keep the replacement tool name and return before the base drag handler for unsupported or absent viewports |
| An annotation tool has no measurement mapping | The drawing can appear in Cornerstone but is absent or stale in OHIF measurement state | Register matching annotation-to-measurement conversions and event handlers |
| A derived overlay is signaled as loaded before its segmentation state exists | The source image renders but the SEG or RT representation is not attached | Add derived data to Cornerstone state before signaling completion and reapply the representation during hydration |
| A SEG load fails or never reports completion | Viewport setup can wait forever and dependent readiness callbacks do not run | Resolve failed or timed-out representation setup without blocking the viewport |
| A hydration command applies a stack type to every compatible pane | An MPR pane can change into a stack view even though only the target pane needed the pinned mode | Apply the requested type only to the hydration target and keep existing modes on matched panes |
| CPU rendering is used for a feature that needs GPU support | MPR, volume rendering, or some segmentation overlays are unavailable | Keep unsupported controls disabled and show the CPU fallback message |
| A selected GPU preset is invalid | The requested volume texture policy is not applied and the session keeps its prior GPU state | Apply presets through the initialization helper and warn without claiming the invalid preset was applied |
| A rendering control reads the background layer when a fusion viewport has a foreground layer | Window and level or colormap changes affect the wrong study | Resolve controls against the topmost foreground display set and validate that it belongs to the viewport |
| A completed volume was loaded before the window-level panel mounted | The panel can remain in loading state and refresh histograms for the life of the panel | Seed loading from cached volume status and stop the interval when all viewport volumes are loaded |
| A generic planar viewport carrying volume data is omitted from opacity updates | Matching viewports show different opacity for the same volume | Find viewports through the generic volume-compatibility guard and apply the change to every matching volume set |
| A user scrolls a stack while cine is playing | Cine can continue changing the image after the user selected a slice | Stop cine before applying the manual slice change |
| A mode registers segmentation panel settings after the panel first renders | The panel keeps default layout or editing behavior | Read customization through the change-aware hook so mode changes refresh the panel |
| A whole-slide viewport has no world-coordinate points when orientation markers render | Marker calculation can use invalid coordinates and show incorrect orientation | Render no markers until the viewport supplies all required world points |
| ECG waveform bulk data is fetched outside the active data source | Relative URIs or protected waveform data can fail even when image loading works | Let the data source provide bytes and auth headers to the Cornerstone metadata builder |
| ECG mounting fails but the viewport service broadcasts a data-change event | Dependent UI can treat the waveform viewport as ready | Show the ECG error and reject the mount so success events are not sent |
| Escape is bound to only one of preview rejection or annotation cancellation | One kind of in-progress edit remains active after the user presses Escape | Route Escape through the combined cancellation command and keep each underlying action safe when idle |
| A caller uses viewport-independent loading as if it also displays the display set | Data is ready but no viewport shows it, which can look like a failed load | Treat loading as preparation and use a separate hydration or viewport update action for display |
| Volume lookup depends on a concrete viewport class | Native generic volume viewports are treated as stacks and receive no volume-specific appearance change | Use the volume capability check and resolve the source volume through the command |
Key files
| File | Why to read it |
|---|---|
| extensions/…/index.tsx | Extension registration, public modules, service setup, and mode cleanup |
| extensions/…/package.json | Extension entry points and compatibility contract for OHIF and Cornerstone services |
| extensions/…/init.tsx | Cornerstone startup, loaders, metadata, rendering choices, GPU presets, and service connections |
| extensions/…/getCustomizationModule.tsx | Default customization assembly for viewport, tool, toolbar, segmentation, and rendering behavior |
| extensions/…/toolbarButtonsCustomization.ts | Shared toolbar capabilities, viewport guards, and mode-composable toolbar sections |
| extensions/…/OHIFCornerstoneViewport.tsx | React viewport lifecycle and the handoff from a tile to the viewport service |
| extensions/…/CornerstoneViewportService.ts | Central coordination for viewport data, presentations, navigation, volumes, overlays, and mount readiness |
| extensions/…/Viewport.ts | OHIF's viewport options, display-set options, and persisted viewport record |
| extensions/…/IViewportAdapter.ts | Common contract across established and native viewport APIs |
| extensions/…/NextViewportAdapter.ts | Native viewport state, per-display-set presentation, data addressing, and capture behavior |
| extensions/…/IViewportAdapter.contract.test.ts | Guarantees that both viewport paths expose aligned user-facing behavior |
| extensions/…/NextViewportBackend.ts | Native viewport lifecycle and data binding model |
| extensions/…/mpr.ts | MPR layout, orientations, and synchronization rules |
| extensions/…/initCornerstoneTools.js | Registered navigation, measurement, annotation, overlay, and segmentation tools |
| extensions/…/WindowLevelTool.ts | Safe window-level interaction across viewport types without changing the shared tool contract |
| extensions/…/ViewportWindowLevel.tsx | Volume window-level histograms and opacity controls with loading and generic viewport coordination |
| extensions/…/index.ts | Viewport types that do not support window-level interaction |
| extensions/…/ToolGroupService.ts | Tool-group membership, modes, bindings, and user preferences |
| extensions/…/commandsModule.ts | Application actions for viewport control, tools, navigation, derived data, and combined edit cancellation |
| extensions/…/initMeasurementService.ts | Two-way annotation and measurement state bridge |
| extensions/…/SyncGroupService.ts | Viewport synchronization and custom synchronizer registration |
| extensions/…/useViewportRendering.tsx | UI-facing rendering controls for windowing, colormaps, opacity, thresholds, and 3D views |
| extensions/…/CornerstoneOverlays.tsx | Viewport metadata, slice, loading, orientation, and progress overlays |
| extensions/…/PanelSegmentation.tsx | Segmentation selection, editing, styling, utility settings, and export actions in the active viewport |
| extensions/…/getPanelModule.tsx | Public segmentation and measurement panel variants and representation-specific toolbox composition |
| extensions/…/ActiveViewportBehavior.tsx | Active-viewport tracking and automatic cine activation rules |
| extensions/…/initGpuSettingsPreset.ts | GPU preset application and customization-change handling |
| extensions/…/getSopClassHandlerModule.js | Display-set creation for whole-slide microscopy and ECG viewport families |
| extensions/…/ecgMetadata.ts | DICOM ECG metadata and data-source-backed waveform loading |