feat: make hanging protocol work on displaySets instead of series (#2837)
* feat(HP): Apply HP to display sets, fix race condition * fix: displaySetService no event not needed (#2912) * fix various styles and renamings * feat: refactored hp service * fix: use HP service event for viewport grid * remove unnecessary doc * fix test * apply review comment * fix: segmentation creation Co-authored-by: Alireza <ar.sedghi@gmail.com>
This commit is contained in:
1 parent
7c0756824e
commit
e1d366e1e1
26 files changed
+893
-979
No files matched your search
@@ -26,12 +26,12 @@ function ViewerViewportGrid(props) {
|
||||
return;
|
||||
}
|
||||
|
||||
const [
|
||||
matchDetails,
|
||||
const {
|
||||
viewportMatchDetails,
|
||||
hpAlreadyApplied,
|
||||
] = HangingProtocolService.getState();
|
||||
} = HangingProtocolService.getMatchDetails();
|
||||
|
||||
if (!matchDetails.length) {
|
||||
if (!viewportMatchDetails.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,24 +43,24 @@ function ViewerViewportGrid(props) {
|
||||
}
|
||||
|
||||
// if current viewport doesn't have a match
|
||||
if (matchDetails[i] === undefined) return;
|
||||
if (viewportMatchDetails[i] === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { displaySetsInfo, viewportOptions } = matchDetails[i];
|
||||
const { displaySetsInfo, viewportOptions } = viewportMatchDetails[i];
|
||||
|
||||
const displaySetUIDsToHang = [];
|
||||
const displaySetUIDsToHangOptions = [];
|
||||
displaySetsInfo.forEach(({ SeriesInstanceUID, displaySetOptions }) => {
|
||||
const matchingDisplaySet = availableDisplaySets.find(ds => {
|
||||
return ds.SeriesInstanceUID === SeriesInstanceUID;
|
||||
});
|
||||
displaySetsInfo.forEach(
|
||||
({ displaySetInstanceUID, displaySetOptions }) => {
|
||||
if (!displaySetInstanceUID) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!matchingDisplaySet) {
|
||||
return;
|
||||
displaySetUIDsToHang.push(displaySetInstanceUID);
|
||||
displaySetUIDsToHangOptions.push(displaySetOptions);
|
||||
}
|
||||
|
||||
displaySetUIDsToHang.push(matchingDisplaySet.displaySetInstanceUID);
|
||||
displaySetUIDsToHangOptions.push(displaySetOptions);
|
||||
});
|
||||
);
|
||||
|
||||
if (!displaySetUIDsToHang.length) {
|
||||
continue;
|
||||
@@ -113,10 +113,11 @@ function ViewerViewportGrid(props) {
|
||||
|
||||
// Using Hanging protocol engine to match the displaySets
|
||||
useEffect(() => {
|
||||
const { unsubscribe } = DisplaySetService.subscribe(
|
||||
DisplaySetService.EVENTS.DISPLAY_SETS_CHANGED,
|
||||
activeDisplaySets => {
|
||||
updateDisplaySetsForViewports(activeDisplaySets);
|
||||
const { unsubscribe } = HangingProtocolService.subscribe(
|
||||
HangingProtocolService.EVENTS.PROTOCOL_CHANGED,
|
||||
() => {
|
||||
const displaySets = DisplaySetService.getActiveDisplaySets();
|
||||
updateDisplaySetsForViewports(displaySets);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -369,6 +370,11 @@ function _getViewportComponent(displaySets, viewportComponents) {
|
||||
const SOPClassHandlerId = displaySets[0].SOPClassHandlerId;
|
||||
|
||||
for (let i = 0; i < viewportComponents.length; i++) {
|
||||
if (!viewportComponents[i])
|
||||
throw new Error('viewport components not defined');
|
||||
if (!viewportComponents[i].displaySetsToDisplay) {
|
||||
throw new Error('displaySetsToDisplay is null');
|
||||
}
|
||||
if (
|
||||
viewportComponents[i].displaySetsToDisplay.includes(SOPClassHandlerId)
|
||||
) {
|
||||
@@ -376,6 +382,7 @@ function _getViewportComponent(displaySets, viewportComponents) {
|
||||
return component;
|
||||
}
|
||||
}
|
||||
throw new Error(`No display set handler for ${SOPClassHandlerId}`);
|
||||
}
|
||||
|
||||
export default ViewerViewportGrid;
|
||||
Reference in new issue
Block a user