Skip to content

Conversation

JamesAPetts
Copy link
Member

This PR makes scroll/pan/zoom update the crosshairs correctly when using either vtkInteractorStyleMPRSlice or vtkInteractorStyleMPRCrosshairs.

Updates for vtkInteractorStyleMPRRotate will come in the future or during a large refactor of the iStyle framework we have in place.


renderWindow.render();

// Its up to the layout manager of an app to know how many viewports are being created.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheeky

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member

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);
Copy link
Member

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

Copy link
Member Author

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']);
Copy link
Member

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"

Copy link
Member Author

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') {
Copy link
Member

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?

Copy link
Member Author

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);
Copy link
Member

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();
Copy link
Member

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?

Copy link
Member Author

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,
Copy link
Member

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?

Copy link
Member Author

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 = `
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This SVG is odd

Copy link
Member Author

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! :)

Copy link
Member

@dannyrb dannyrb left a 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

@ohif-bot
Copy link
Member

🎉 This PR is included in version 0.7.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants