Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
microscopyService.focusAnnotation(roiAnnotation, props.activeViewportId);
};

/**
* Handler for toggling visibility of an annotation item
* @param param0
*/
const onMeasurementItemToggleVisibilityHandler = ({ uid }: { uid: string }) => {
props.commandsManager.runCommand('toggleMeasurementVisibility', { uid }, 'MICROSCOPY');
};

/**
* Handler for "Edit" action of an annotation item
* @param param0
Expand All @@ -295,6 +303,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
const length = roiAnnotation.getLength();
const shortAxisLength = roiAnnotation.roiGraphic.properties.shortAxisLength;
const isSelected: boolean = selectedAnnotation === roiAnnotation;
const isVisible = roiAnnotation.isVisible;

// other events
const { uid } = roiAnnotation;
Expand All @@ -318,6 +327,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
index,
label,
isActive: isSelected,
isVisible,
displayText,
roiAnnotation,
};
Expand All @@ -341,8 +351,8 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
primary: item.displayText,
secondary: [],
}}
isVisible={true}
onToggleVisibility={() => {}}
isVisible={item.isVisible}
onToggleVisibility={() => onMeasurementItemToggleVisibilityHandler({ uid: item.uid })}
isLocked={false}
onToggleLocked={() => {}}
onRename={() =>
Expand Down
6 changes: 6 additions & 0 deletions extensions/dicom-microscopy/src/getCommandsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ export default function getCommandsModule({
toggleAnnotations: () => {
microscopyService.toggleROIsVisibility();
},
toggleMeasurementVisibility: ({ uid }) => {
microscopyService.toggleROIVisibility(uid);
},
};

const definitions = {
Expand All @@ -143,6 +146,9 @@ export default function getCommandsModule({
toggleAnnotations: {
commandFn: actions.toggleAnnotations,
},
toggleMeasurementVisibility: {
commandFn: actions.toggleMeasurementVisibility,
},
};

return {
Expand Down
19 changes: 19 additions & 0 deletions extensions/dicom-microscopy/src/services/MicroscopyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,25 @@ export default class MicroscopyService extends PubSubService {
this.managedViewers.forEach(mv => mv.showROIs());
}

/**
* Toggle visibility of a specific ROI
* @param uid The UID of the ROI to toggle
*/
toggleROIVisibility(uid) {
const roiAnnotation = this.getAnnotation(uid);
if (!roiAnnotation) {
return;
}
const isVisible = !roiAnnotation.isVisible;
roiAnnotation.setVisibility(isVisible);

this.managedViewers.forEach(mv => {
mv.toggleROIVisibility(uid, roiAnnotation.roiGraphic, isVisible);
});

this._broadcastEvent(EVENTS.ANNOTATION_UPDATED, roiAnnotation);
}

/**
* Returns a RoiAnnotation instance for the given ROI UID
*
Expand Down
15 changes: 15 additions & 0 deletions extensions/dicom-microscopy/src/tools/viewerManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,21 @@ class ViewerManager extends PubSubService {
}
}

/**
* Toggles the visibility of a specific ROI.
*
* @param {string} uid - Unique identifier of the ROI
* @param {Object} roiGraphic - ROI graphic object to re-add if making visible
* @param {boolean} isVisible - Whether the ROI should be visible or hidden
*/
toggleROIVisibility(uid, roiGraphic, isVisible) {
if (isVisible) {
this.runSilently(() => this.viewer.addROI(roiGraphic, styles.default));
} else {
this.runSilently(() => this.viewer.removeROI(uid));
}
}

_jumpToPoint(coord) {
const pyramid = this.viewer[this._pyramid].metadata;

Expand Down
10 changes: 10 additions & 0 deletions extensions/dicom-microscopy/src/utils/RoiAnnotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ class RoiAnnotation extends PubSubService {
this.label = label;
this.viewState = viewState;
this.setMeasurements(roiGraphic);
this.isVisible = true;
}

/**
* Sets the visibility state of the annotation.
*
* @param {boolean} isVisible
*/
setVisibility(isVisible) {
this.isVisible = isVisible;
}

getScoord3d() {
Expand Down
Loading