feat(hp callback): Add viewport ready callback (#3772)
Co-authored-by: Ouwen Huang <ouwen.huang@duke.edu>
This commit is contained in:
1 parent
1a68c06c3b
commit
bf252bcec2
10 files changed
+143
-44
No files matched your search
@@ -580,6 +580,23 @@ function commandsModule({
|
||||
storePresentation: ({ viewportId }) => {
|
||||
cornerstoneViewportService.storePresentation({ viewportId });
|
||||
},
|
||||
|
||||
attachProtocolViewportDataListener: ({ protocol, stageIndex }) => {
|
||||
const EVENT = cornerstoneViewportService.EVENTS.VIEWPORT_DATA_CHANGED;
|
||||
const command = protocol.callbacks.onViewportDataInitialized;
|
||||
const numPanes = protocol.stages?.[stageIndex]?.viewports.length ?? 1;
|
||||
let numPanesWithData = 0;
|
||||
const { unsubscribe } = cornerstoneViewportService.subscribe(EVENT, evt => {
|
||||
numPanesWithData++;
|
||||
|
||||
if (numPanesWithData === numPanes) {
|
||||
commandsManager.run(...command);
|
||||
|
||||
// Unsubscribe from the event
|
||||
unsubscribe(EVENT);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const definitions = {
|
||||
@@ -606,7 +623,6 @@ function commandsModule({
|
||||
storeContexts: [],
|
||||
options: {},
|
||||
},
|
||||
|
||||
deleteMeasurement: {
|
||||
commandFn: actions.deleteMeasurement,
|
||||
},
|
||||
@@ -714,6 +730,9 @@ function commandsModule({
|
||||
cleanUpCrosshairs: {
|
||||
commandFn: actions.cleanUpCrosshairs,
|
||||
},
|
||||
attachProtocolViewportDataListener: {
|
||||
commandFn: actions.attachProtocolViewportDataListener,
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user