-
Notifications
You must be signed in to change notification settings - Fork 336
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: segmentSelect issue + segmentation modified event #1065
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/tools/src/eventListeners/annotations/annotationRemovedListener.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { AnnotationRemovedEventType } from '../../types/EventTypes'; | ||
import * as contourSegUtils from '../../utilities/contourSegmentation'; | ||
import { contourSegmentationRemoved } from './contourSegmentation'; | ||
|
||
export default function annotationRemovedListener( | ||
evt: AnnotationRemovedEventType | ||
) { | ||
const annotation = evt.detail.annotation; | ||
|
||
if (contourSegUtils.isContourSegmentationAnnotation(annotation)) { | ||
contourSegmentationRemoved(evt); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...es/tools/src/eventListeners/annotations/contourSegmentation/contourSegmentationRemoved.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { AnnotationRemovedEventType } from '../../../types/EventTypes'; | ||
import type { ContourSegmentationAnnotation } from '../../../types/ContourSegmentationAnnotation'; | ||
import { removeContourSegmentationAnnotation } from '../../../utilities/contourSegmentation'; | ||
|
||
export default function contourSegmentationRemovedListener( | ||
evt: AnnotationRemovedEventType | ||
) { | ||
const annotation = evt.detail.annotation as ContourSegmentationAnnotation; | ||
|
||
removeContourSegmentationAnnotation(annotation); | ||
} |
1 change: 1 addition & 0 deletions
1
packages/tools/src/eventListeners/annotations/contourSegmentation/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default as contourSegmentationCompleted } from './contourSegmentationCompleted'; | ||
export { default as contourSegmentationRemoved } from './contourSegmentationRemoved'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import annotationCompletedListener from './annotationCompletedListener'; | ||
import annotationSelectionListener from './annotationSelectionListener'; | ||
import annotationModifiedListener from './annotationModifiedListener'; | ||
import annotationRemovedListener from './annotationRemovedListener'; | ||
|
||
export { | ||
annotationCompletedListener, | ||
annotationSelectionListener, | ||
annotationModifiedListener, | ||
annotationRemovedListener, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { getEnabledElements, utilities as csUtils } from '@cornerstonejs/core'; | ||
import type { Annotation } from '../types'; | ||
|
||
const { isEqual } = csUtils; | ||
|
||
/** | ||
* Finds a all matching viewports in terms of the orientation of the annotation data | ||
* and the frame of reference. This doesn't mean the annotation IS being displayed | ||
* on these viewports, just that it could be by navigating the slice, and/or pan/zoom, | ||
* without changing the orientation. | ||
* | ||
* @param annotation - Annotation to find the viewports that it could display in | ||
* @returns All viewports to display in | ||
*/ | ||
export default function getViewportsForAnnotation(annotation: Annotation) { | ||
const { metadata } = annotation; | ||
|
||
return getEnabledElements() | ||
.filter((enabledElement) => { | ||
if (enabledElement.FrameOfReferenceUID === metadata.FrameOfReferenceUID) { | ||
const viewport = enabledElement.viewport; | ||
const { viewPlaneNormal, viewUp } = viewport.getCamera(); | ||
return ( | ||
isEqual(viewPlaneNormal, metadata.viewPlaneNormal) && | ||
(!metadata.viewUp || isEqual(viewUp, metadata.viewUp)) | ||
); | ||
} | ||
return; | ||
}) | ||
.map((enabledElement) => enabledElement.viewport); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have this already
packages/tools/src/utilities/getViewportForAnnotation.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ViewportS (plural)
Later it looks for the viewport that is in a toolGroup with freehand tool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed a change to make
getViewportForAnnotation
callgetViewportsForAnnotation
removing duplicated code