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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | import type {
ECGViewportProperties,
ViewPresentation,
ViewPresentationSelector,
} from '../../../types';
import { viewportProjection } from '../viewportProjection';
import type { ECGViewState } from './ECGViewportTypes';
import ECGViewport from './ECGViewport';
class ECGViewportLegacyAdapter extends ECGViewport {
async setEcg(imageId: string): Promise<void> {
await this.setDisplaySets({ displaySetId: imageId });
}
setChannelVisibility(index: number, visible: boolean): void {
const waveform = this.getWaveformData();
const dataId = this.getFirstBinding()?.data.id;
if (!waveform || !dataId) {
return;
}
const current = this.getDisplaySetPresentation(dataId) || {};
const nextVisibleChannels = new Set(
current.visibleChannels || waveform.channels.map((_channel, i) => i)
);
if (visible) {
nextVisibleChannels.add(index);
} else {
nextVisibleChannels.delete(index);
}
this.setDisplaySetPresentation(dataId, {
visibleChannels: Array.from(nextVisibleChannels).sort((a, b) => a - b),
});
}
setProperties(props: ECGViewportProperties): void {
const dataId = this.getFirstBinding()?.data.id;
if (!dataId) {
return;
}
this.setDisplaySetPresentation(dataId, {
visibleChannels: props.visibleChannels,
});
}
getProperties(): ECGViewportProperties {
const dataId = this.getFirstBinding()?.data.id;
return {
visibleChannels: dataId
? this.getDisplaySetPresentation(dataId)?.visibleChannels
: undefined,
};
}
resetProperties(): void {
const waveform = this.getWaveformData();
const dataId = this.getFirstBinding()?.data.id;
if (!waveform || !dataId) {
return;
}
this.setDisplaySetPresentation(dataId, {
visibleChannels: waveform.channels.map((_channel, index) => index),
});
}
/**
* Compatibility wrapper for legacy callers. Next viewports should read
* presentation through `viewportProjection.getPresentation`.
*/
getViewPresentation(
selector?: ViewPresentationSelector
): ViewPresentation | undefined {
return viewportProjection.getPresentation<ViewPresentation>(this, {
selector,
});
}
/**
* Compatibility wrapper for legacy callers. Next viewports should use
* viewport projection to derive view state, then call `setViewState`.
*/
setViewPresentation(viewPres?: ViewPresentation): void {
if (!viewPres) {
return;
}
const nextViewState = viewportProjection.withPresentation<
ECGViewState,
ViewPresentation
>(this, viewPres);
if (nextViewState) {
this.setViewState(nextViewState);
}
}
/**
* Compatibility wrapper for legacy callers. Direct Next viewports should use
* `resetViewState`.
*/
resetCamera(): boolean {
return this.resetViewState();
}
}
export default ECGViewportLegacyAdapter;
|