Skip to content

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

typescript
// 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

ts
new ViewSynchronizer(options?): ViewSynchronizer;

Defined in: src/display/ViewSynchronizer.ts:85

Create a new ViewSynchronizer

Parameters

options?

ViewSynchronizerOptions

Configuration options

Returns

ViewSynchronizer

Methods

addView()

ts
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

SingleSliceViewer

The SingleSliceViewer instance to add

Returns

void


removeView()

ts
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()

ts
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()

ts
getViewIds(): string[];

Defined in: src/display/ViewSynchronizer.ts:187

Get all view IDs

Returns

string[]

Array of view IDs


hasView()

ts
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()

ts
getViewCount(): number;

Defined in: src/display/ViewSynchronizer.ts:206

Get the number of views in the synchronizer

Returns

number

Number of views


syncCoordinate()

ts
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()

ts
enable(): void;

Defined in: src/display/ViewSynchronizer.ts:272

Enable synchronization

Returns

void


disable()

ts
disable(): void;

Defined in: src/display/ViewSynchronizer.ts:279

Disable synchronization (views will stop syncing)

Returns

void


isEnabled()

ts
isEnabled(): boolean;

Defined in: src/display/ViewSynchronizer.ts:286

Check if synchronization is enabled

Returns

boolean


toggle()

ts
toggle(): boolean;

Defined in: src/display/ViewSynchronizer.ts:295

Toggle synchronization on/off

Returns

boolean

The new enabled state


dispose()

ts
dispose(): void;

Defined in: src/display/ViewSynchronizer.ts:303

Remove all views and clean up resources

Returns

void


fromViews()

ts
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?

ViewSynchronizerOptions

Configuration options

Returns

ViewSynchronizer

A new ViewSynchronizer with the views already added


createOrthogonal()

ts
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

SingleSliceViewer

Axial view

sagittal

SingleSliceViewer

Sagittal view

coronal

SingleSliceViewer

Coronal view

options?

ViewSynchronizerOptions

Configuration options

Returns

ViewSynchronizer

A new ViewSynchronizer with the three views

Released under the MIT License.