Skip to content

Commit

Permalink
fix add segmentation button
Browse files Browse the repository at this point in the history
  • Loading branch information
IbrahimCSAE committed Apr 25, 2024
1 parent fda8f29 commit 8ad0ffa
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions extensions/cornerstone-dicom-seg/src/panels/PanelSegmentation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ export default function PanelSegmentation({
extensionManager,
configuration,
}) {
const { segmentationService, viewportGridService, uiDialogService, displaySetService } =
servicesManager.services;
const {
segmentationService,
viewportGridService,
uiDialogService,
displaySetService,
cornerstoneViewportService,
} = servicesManager.services;

const { t } = useTranslation('PanelSegmentation');

Expand Down Expand Up @@ -82,21 +87,33 @@ export default function PanelSegmentation({
// Handle initial state
handleActiveViewportChange();

const changed = viewportGridService.EVENTS.ACTIVE_VIEWPORT_ID_CHANGED;
const changedGrid = viewportGridService.EVENTS.ACTIVE_VIEWPORT_ID_CHANGED;
const ready = viewportGridService.EVENTS.VIEWPORTS_READY;

const subs = [];
[ready, changed].forEach(evt => {
const subsGrid = [];
[ready, changedGrid].forEach(evt => {
const { unsubscribe } = viewportGridService.subscribe(evt, ({ viewportId }) => {
handleActiveViewportChange(viewportId);
});

subs.push(unsubscribe);
subsGrid.push(unsubscribe);
});

const changedData = cornerstoneViewportService.EVENTS.VIEWPORT_DATA_CHANGED;

const subsData = [];
[changedData].forEach(evt => {
const { unsubscribe } = cornerstoneViewportService.subscribe(evt, () => {
handleActiveViewportChange();
});

subsData.push(unsubscribe);
});

// Clean up
return () => {
subs.forEach(unsub => unsub());
subsGrid.forEach(unsub => unsub());
subsData.forEach(unsub => unsub());
};
}, []);

Expand Down

0 comments on commit 8ad0ffa

Please sign in to comment.