Class: ViewSynchronizer
Defined in: src/display/ViewSynchronizer.ts:54
Manages synchronization of coordinates across multiple SingleSliceViewer instances.
This class allows you to create custom layouts with arbitrary numbers of views and control how they synchronize. You can sync on hover or only on clicks, add/remove views dynamically, and temporarily disable synchronization.
Example
// Create a synchronizer that syncs on click only
const sync = new ViewSynchronizer({ syncOnHover: false });
// Add views
const axial = await SingleSliceViewer.createAxial(axialContainer, volStack);
const sagittal = await SingleSliceViewer.createSagittal(sagContainer, volStack);
sync.addView('axial', axial);
sync.addView('sagittal', sagittal);
// Now clicks in one view will update the other
// You can also programmatically sync a coordinate across all views:
sync.syncCoordinate([50, 60, 70]);Constructors
Constructor
new ViewSynchronizer(options?): ViewSynchronizer;Defined in: src/display/ViewSynchronizer.ts:85
Create a new ViewSynchronizer
Parameters
options?
Configuration options
Returns
ViewSynchronizer
Methods
addView()
addView(viewId, viewer): void;Defined in: src/display/ViewSynchronizer.ts:99
Add a view to the synchronization group
Parameters
viewId
string
Unique identifier for this view
viewer
The SingleSliceViewer instance to add
Returns
void
removeView()
removeView(viewId): SingleSliceViewer | undefined;Defined in: src/display/ViewSynchronizer.ts:154
Remove a view from the synchronization group
Parameters
viewId
string
ID of the view to remove
Returns
SingleSliceViewer | undefined
The removed viewer instance, or undefined if not found
getView()
getView(viewId): SingleSliceViewer | undefined;Defined in: src/display/ViewSynchronizer.ts:178
Get a view by ID
Parameters
viewId
string
ID of the view to get
Returns
SingleSliceViewer | undefined
The viewer instance, or undefined if not found
getViewIds()
getViewIds(): string[];Defined in: src/display/ViewSynchronizer.ts:187
Get all view IDs
Returns
string[]
Array of view IDs
hasView()
hasView(viewId): boolean;Defined in: src/display/ViewSynchronizer.ts:197
Check if a view exists
Parameters
viewId
string
ID to check
Returns
boolean
True if the view exists
getViewCount()
getViewCount(): number;Defined in: src/display/ViewSynchronizer.ts:206
Get the number of views in the synchronizer
Returns
number
Number of views
syncCoordinate()
syncCoordinate(coord): void;Defined in: src/display/ViewSynchronizer.ts:215
Programmatically sync a specific coordinate across all views
Parameters
coord
number[]
World coordinate [x, y, z] in mm
Returns
void
enable()
enable(): void;Defined in: src/display/ViewSynchronizer.ts:272
Enable synchronization
Returns
void
disable()
disable(): void;Defined in: src/display/ViewSynchronizer.ts:279
Disable synchronization (views will stop syncing)
Returns
void
isEnabled()
isEnabled(): boolean;Defined in: src/display/ViewSynchronizer.ts:286
Check if synchronization is enabled
Returns
boolean
toggle()
toggle(): boolean;Defined in: src/display/ViewSynchronizer.ts:295
Toggle synchronization on/off
Returns
boolean
The new enabled state
dispose()
dispose(): void;Defined in: src/display/ViewSynchronizer.ts:303
Remove all views and clean up resources
Returns
void
fromViews()
static fromViews(views, options?): ViewSynchronizer;Defined in: src/display/ViewSynchronizer.ts:318
Create a synchronizer with pre-configured views
Parameters
views
| Map<string, SingleSliceViewer> | Record<string, SingleSliceViewer>
Map of view IDs to viewer instances
options?
Configuration options
Returns
ViewSynchronizer
A new ViewSynchronizer with the views already added
createOrthogonal()
static createOrthogonal(
axial,
sagittal,
coronal,
options?): ViewSynchronizer;Defined in: src/display/ViewSynchronizer.ts:344
Create a synchronizer for a standard orthogonal view setup
Parameters
axial
Axial view
sagittal
Sagittal view
coronal
Coronal view
options?
Configuration options
Returns
ViewSynchronizer
A new ViewSynchronizer with the three views