-
Notifications
You must be signed in to change notification settings - Fork 83
Fix Crosshair Update on scroll/pan/zoom. #84
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
|
||
renderWindow.render(); | ||
|
||
// Its up to the layout manager of an app to know how many viewports are being created. |
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.
Cheeky
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 think its the only reasonable way to do it. They all have no knowledge of each other. You need a management layer for synrchronised viewports which is out of the scope of the viewport component itself. We could eventually formalise this layer in react-vtkjs-viewport itself, but I'm wondering if it'd be too app-specific.
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 cheat in cornerstone-tools by tracking enabledElements and exposing a configuration option for them to sync, or through methods that apply to "all" tracked enabledElements when used. This layer of abstraction doesn't exist 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.
That's my round-about way of saying I agree with you.
|
||
const api = apis[0]; | ||
|
||
api.svgWidgets.crosshairsWidget.resetCrosshairs(apis, 0); |
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 wonder what 0
is for 🤔
continues reading
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.
Which viewport to as source of truth for the reset.
vtkInteractorStyleMPRSlice.extend(publicAPI, model, initialValues); | ||
|
||
macro.setGet(publicAPI, model, ['callback']); | ||
macro.setGet(publicAPI, model, ['callback', 'apis', 'apiIndex', 'onScroll']); |
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.
It feels weird to use apis
in the interactorStyle
. It feels like we're creating a synchronizer with apis
as "viewport properties"
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.
Yeah, its difficult, because we have to do a different thing depending on each API index. We have to have add some layer like this to the iStyle so it has any knowledge other viewports exist. We could try and normalise this approach in the future though.
function handleButtonPress() { | ||
const { apis, apiIndex } = model; | ||
|
||
if (apis && apis[apiIndex] && apis[apiIndex].type === 'VIEW2D') { |
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.
This makes sense, but I hadn't thought of it. We'll need some way to change interaction based on this. Likely creating tools that only support one or the other?
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 hadn't thought of it either, pretty sure putting crosshairs on a View3D would just go kaput currently, View3D has recieved little love from the community as of yet anyway.
|
||
const api = apis[apiIndex]; | ||
|
||
api.svgWidgets.crosshairsWidget.updateCrosshairForApi(api); |
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.
Could use events or obersavables and have crosshairs monitor apis so it can self-update? Not pushing for that now, just adding ideas to the idea pile.
api.svgWidgets.crosshairsWidget.updateCrosshairForApi(api); | ||
} | ||
|
||
superButtonRelease(); |
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.
super
if calling an inherited constructor, but callback
if passed as an arg and called 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.
Yeah super is internal to the way the vtkjs classes are constructed. Callbacks we pass in when we set the interactor style allow us to hook into vtkjs from the app level but I don't like it haha.
if (onScroll) onScroll(slicePoint); | ||
if (onScroll) { | ||
onScroll({ | ||
slicePoint, |
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.
This isn't used by the model.onScroll
below. Do we expect it to be passed for other onScroll implementations?
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 left it as it already existed, I'm not sure of the original intention, we can review its existance later.
`; | ||
|
||
if (model.display) { | ||
node.innerHTML = ` |
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.
This SVG is odd
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.
This PR didn't touch it, feel free to clean it up! :)
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.
Fine to merge, but raises some interesting questions
🎉 This PR is included in version 0.7.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This PR makes scroll/pan/zoom update the crosshairs correctly when using either
vtkInteractorStyleMPRSlice
orvtkInteractorStyleMPRCrosshairs
.Updates for
vtkInteractorStyleMPRRotate
will come in the future or during a large refactor of the iStyle framework we have in place.