-
Notifications
You must be signed in to change notification settings - Fork 29
Store position in layer space when double-clicking segment #9017
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
Conversation
📝 WalkthroughWalkthroughSelection and context-menu flows now compute and store cell/segment positions in a visible segmentation layer's local coordinate space when available, falling back to global coordinates otherwise. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
frontend/javascripts/viewer/controller/combinations/volume_handlers.ts (1)
141-154: LGTM! Correctly stores position in layer space.The implementation correctly transforms the global position to layer space when a visible segmentation layer exists, falling back to the global position otherwise. This ensures segment positions remain correct across coordinate system changes, addressing the issue described in #9012.
Optional: Consider extracting common logic to reduce duplication.
Similar position transformation logic appears in both this file (lines 141-150) and
context_menu.tsx(lines 1059-1067). Consider extracting a helper function:function getPositionForSegmentActivation( globalPos: Vector3, visibleSegmentationLayer: APIDataLayer | null | undefined, state: WebknossosState, ): Vector3 { if (visibleSegmentationLayer != null) { return globalToLayerTransformedPosition( globalPos, visibleSegmentationLayer.name, "segmentation", state, ); } return globalPos; }Then use it in both locations:
- const positionInLayerSpace = - visibleSegmentationLayer != null - ? globalToLayerTransformedPosition( - globalPos, - visibleSegmentationLayer.name, - "segmentation", - Store.getState(), - ) - : null; - - Store.dispatch( - setActiveCellAction(segmentId, positionInLayerSpace || globalPos, additionalCoordinates), - ); + const positionForActivation = getPositionForSegmentActivation( + globalPos, + visibleSegmentationLayer, + Store.getState(), + ); + Store.dispatch( + setActiveCellAction(segmentId, positionForActivation, additionalCoordinates), + );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
frontend/javascripts/viewer/controller/combinations/volume_handlers.ts(1 hunks)frontend/javascripts/viewer/view/context_menu.tsx(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
frontend/javascripts/viewer/view/context_menu.tsx (1)
frontend/javascripts/viewer/model/actions/volumetracing_actions.ts (1)
setActiveCellAction(206-218)
frontend/javascripts/viewer/controller/combinations/volume_handlers.ts (2)
frontend/javascripts/viewer/model/accessors/dataset_layer_transformation_accessor.ts (1)
globalToLayerTransformedPosition(487-506)frontend/javascripts/viewer/model/actions/volumetracing_actions.ts (1)
setActiveCellAction(206-218)
🔇 Additional comments (2)
frontend/javascripts/viewer/view/context_menu.tsx (2)
1059-1067: LGTM! Consistent layer space transformation.The position transformation logic correctly mirrors the implementation in
volume_handlers.ts, ensuring consistent behavior across different code paths for segment activation.
1433-1437: LGTM! Correctly applies layer space position.The context menu action properly uses the transformed position with appropriate fallback, ensuring segment positions are stored in layer space across all activation paths.
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
unreleased_changes/9017.md(1 hunks)
🧰 Additional context used
🪛 LanguageTool
unreleased_changes/9017.md
[grammar] ~2-~2: Ensure spelling is correct
Context: ...r coordinate system, preserving correct behvaiour when layer transforms are in use.
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build-smoketest-push
- GitHub Check: frontend-tests
- GitHub Check: backend-tests
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.
very nice, looks fixed to me 🎉
Thanks for fixing this so fast 🏎️
The comment below is only regarding a potential follow up
| ? globalToLayerTransformedPosition( | ||
| globalPos, | ||
| visibleSegmentationLayer.name, | ||
| "segmentation", |
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.
I was a little confused by the plain string "segmentation" here at first. @philippotto Do we maybe want to refactor this into an enum, so we can write something like LayerType.Segmentation or so? This would have made this upon first read easier to understand / not stumble upon.
=> But this refacoring shouldn't be done here.
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.
sorry, this comment slipped through in my mail box. yes, sounds like a good idea. we should be careful about the naming though. I think, it's often called "category".
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.
ok I opened a short issue fore this: #9035
URL of deployed dev instance (used for testing):
Steps to test:
Issues:
(Please delete unneeded items, merge only when none are left open)
$PR_NUMBER.mdfile inunreleased_changesor use./tools/create-changelog-entry.py)