fix: Navigate to contour should work (#5718)
* fix: Navigate to contour should work * Switched back to jump to segment center for hte unit tests
This commit is contained in:
1 parent
b2f6e1f237
commit
0fd517d6ab
3 files changed
+233
-1
No files matched your search
@@ -56,6 +56,7 @@ setActiveSegmentation(viewportId, segmentationId)
|
||||
getSegmentations()
|
||||
getSegmentation(segmentationId)
|
||||
jumpToSegmentCenter(segmentationId, segmentIndex, viewportId)
|
||||
jumpToSegmentNext(segmentationId, segmentIndex, forViewportId?, direction?, highlightAlpha?, highlightSegment?, animationLength?, highlightHideOthers?, animationFunctionType?)
|
||||
highlightSegment(segmentationId, segmentIndex, viewportId)
|
||||
```
|
||||
|
||||
@@ -174,3 +175,59 @@ segmentationService.setSegmentColor(
|
||||
[255, 0, 0, 255] // RGBA
|
||||
);
|
||||
```
|
||||
|
||||
### Navigation
|
||||
|
||||
#### jumpToSegmentNext
|
||||
|
||||
Jumps to the next or previous slice that contains the specified segment in the viewport. This method handles both labelmap and contour segmentations:
|
||||
- For **labelmaps**: Jumps to the segment center
|
||||
- For **contours**: Cycles through all slices that contain contour data for the segment in the specified direction
|
||||
|
||||
```typescript
|
||||
segmentationService.jumpToSegmentNext(
|
||||
segmentationId: string,
|
||||
segmentIndex: number,
|
||||
forViewportId?: string, // Optional viewport ID. If not provided, applies to all viewports with this segmentation
|
||||
direction?: number, // 1 for forward (default), -1 for backward
|
||||
highlightAlpha?: number, // Alpha value for highlighting (0-1), default: 0.9
|
||||
highlightSegment?: boolean, // Whether to highlight the segment after jumping, default: true
|
||||
animationLength?: number, // Length of highlight animation in milliseconds, default: 750
|
||||
highlightHideOthers?: boolean, // Whether to hide other segments during highlight, default: false
|
||||
animationFunctionType?: EasingFunctionEnum // The easing function to use for animation, default: EASE_IN_OUT
|
||||
)
|
||||
```
|
||||
|
||||
**Navigation Behavior:**
|
||||
- **Forward (direction = 1)**: Finds the next slice after the current one that contains the segment. If no slice is found after the current one, wraps around to the first slice with the segment.
|
||||
- **Backward (direction = -1)**: Finds the previous slice before the current one that contains the segment. If no slice is found before the current one, wraps around to the last slice with the segment.
|
||||
|
||||
**Example Usage:**
|
||||
|
||||
```typescript
|
||||
// Jump to next slice with segment 1
|
||||
segmentationService.jumpToSegmentNext(
|
||||
segmentationId,
|
||||
1, // segmentIndex
|
||||
'viewport-1'
|
||||
);
|
||||
|
||||
// Jump to previous slice with segment 2, with custom highlighting
|
||||
segmentationService.jumpToSegmentNext(
|
||||
segmentationId,
|
||||
2, // segmentIndex
|
||||
'viewport-1',
|
||||
-1, // backward direction
|
||||
0.95, // highlightAlpha
|
||||
true, // highlightSegment
|
||||
1000, // animationLength in ms
|
||||
true // highlightHideOthers
|
||||
);
|
||||
|
||||
// Apply to all viewports with this segmentation
|
||||
segmentationService.jumpToSegmentNext(
|
||||
segmentationId,
|
||||
1 // segmentIndex
|
||||
// forViewportId omitted - applies to all viewports
|
||||
);
|
||||
```
|
||||
Reference in new issue
Block a user