All files / packages/tools/src/synchronizers/synchronizers createVOISynchronizer.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41                                                    1x   1x                   1x    
import { createSynchronizer } from '../../store/SynchronizerManager';
import { Enums } from '@cornerstonejs/core';
import voiSyncCallback from '../callbacks/voiSyncCallback';
import Synchronizer from '../../store/SynchronizerManager/Synchronizer';
 
type VOISynchronizerOptions = {
  syncInvertState: boolean;
  syncColormap :boolean;
};
 
/**
 * A helper that creates a new `Synchronizer`
 * which listens to the `VOI_MODIFIED` rendering event and calls the `voiSyncCallback`.
 *
 * @param synchronizerName - The name of the synchronizer.
 * @param options - The options for the synchronizer. By default the voi
 * synchronizer will also sync the invert state of the volume, but this can be
 * disabled by setting `syncInvertState` to false.
 *
 * @returns A new `Synchronizer` instance.
 */
export default function createVOISynchronizer(
  synchronizerName: string,
  options: VOISynchronizerOptions
): Synchronizer {
  //  = { syncInvertState: true } if options is not provided or undefined or {}
  options = Object.assign({ syncInvertState: true, syncColormap:true }, options);
 
  const VOISynchronizer = createSynchronizer(
    synchronizerName,
    Enums.Events.VOI_MODIFIED,
    voiSyncCallback,
    {
      auxiliaryEventNames: [Enums.Events.COLORMAP_MODIFIED],
      ...options,
    }
  );
 
  return VOISynchronizer;
}