Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ROI): Avoid removing highlighting of ROI after closing ROI info dialog and use double click to open it #197

Merged
merged 8 commits into from
May 8, 2024
30 changes: 24 additions & 6 deletions src/components/SlideViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,19 @@ class SlideViewer extends React.Component<SlideViewerProps, SlideViewerState> {
}
}

onRoiDoubleClicked = (event: CustomEventInit): void => {
const selectedRoi = event.detail.payload as dmv.roi.ROI
if (selectedRoi != null) {
this.setState({
isSelectedRoiModalVisible: true
})
} else {
this.setState({
isSelectedRoiModalVisible: false
})
}
}

onRoiSelected = (event: CustomEventInit): void => {
const selectedRoi = event.detail.payload as dmv.roi.ROI
if (selectedRoi != null) {
Expand All @@ -1430,22 +1443,19 @@ class SlideViewer extends React.Component<SlideViewerProps, SlideViewerState> {
})
this.setState({
selectedRoiUIDs: new Set([selectedRoi.uid]),
selectedRoi: selectedRoi,
isSelectedRoiModalVisible: true
selectedRoi: selectedRoi
})
} else {
this.setState({
selectedRoiUIDs: new Set(),
selectedRoi: undefined,
isSelectedRoiModalVisible: false
selectedRoi: undefined
})
}
}

handleRoiSelectionCancellation (): void {
this.setState({
isSelectedRoiModalVisible: false,
selectedRoiUIDs: new Set()
isSelectedRoiModalVisible: false
})
}

Expand Down Expand Up @@ -1566,6 +1576,10 @@ class SlideViewer extends React.Component<SlideViewerProps, SlideViewerState> {
'dicommicroscopyviewer_roi_selected',
this.onRoiSelected
)
document.body.removeEventListener(
'dicommicroscopyviewer_roi_double_clicked',
this.onRoiDoubleClicked
)
document.body.removeEventListener(
'dicommicroscopyviewer_roi_removed',
this.onRoiRemoved
Expand Down Expand Up @@ -1665,6 +1679,10 @@ class SlideViewer extends React.Component<SlideViewerProps, SlideViewerState> {
'dicommicroscopyviewer_roi_selected',
this.onRoiSelected
)
document.body.addEventListener(
'dicommicroscopyviewer_roi_double_clicked',
this.onRoiDoubleClicked
)
document.body.addEventListener(
'dicommicroscopyviewer_roi_removed',
this.onRoiRemoved
Expand Down
Loading