bigdataviewer / bigdataviewer-playground

BSD 2-Clause "Simplified" License
19 stars 5 forks source link

Add a ZSlider in bdv based on ray casting #240

Closed NicoKiaru closed 3 years ago

NicoKiaru commented 3 years ago

This PR adds an actions which adds a ZSlider in a Bdv window - and a demo of it (RayCastDemo)

Because the orientation in Bdv can be anything, the way the slider works is the following: a 'virtual' ray is cast at the center of the bdv window and each plane which intersects this ray corresponds to a position within the slider.

All positions from all sources are finally sorted along Z.

The slider works 'directionally' : if the user moves the bdv window, the slider is updated to its new z position, if the user moves the slider, the bdv window is shifted in z according to the new position.

The slider works only for 'standard' sources ( = 3D Rai with affine transforms ), and not for warped sources.

NicoKiaru commented 3 years ago

For tischi : only the last commit really matter

tischi commented 3 years ago

@NicoKiaru I tried it out but when moving the z-slider, nothing happens for me.

image
NicoKiaru commented 3 years ago

Hmm. The ray is cast at the center of the screen. If there's no image crossing it, then no movement happens. From the image it's unclear whether the cross actually 'touches' an image. But this could be something else...

tischi commented 3 years ago

Cool! Moving a source onto the cross works!

What's the extend of the range supposed to be?

I did Shift+X on a source and scrolled and it felt like I could go a bit too far, i.e. into neighboring sources.

NicoKiaru commented 3 years ago

The range is 'infinite'. A ray is cast at the center of the window, and all planes from any source intersecting this ray will have a 'plane index'. All plane index are sorted and put into the slider. This means that all spacings are not equal (unless the ray crosses only one source). Sometimes you will 'jump' from the end of one source to the beginning of the next one.

tischi commented 3 years ago

What do you mean by infinite?

image

I am at the end of the slider but still within our universe, even within the sources.

NicoKiaru commented 3 years ago

If there's no source further away, then you stop at the last intersecting plane. But it's 'potentaially infinite' in the sense that if there is an image further away, the slider would have extra positions. It's not a fixed range with a fixed step size.

Here's a small drawing showing what the positions would look like in the case of 3 randomly placed sources: image

Even if the positions in the slider are evenly spaced, these positions are not evenly spaced in the real physical coordinates. Also if there are intertwined planes, they are sorted along their coordinates along the z axis.

Is it clearer ?

tischi commented 3 years ago

Thanks! Yes, this is awesome, dude!

The only question I would have whether (a) it is only the central ray that is used to determine when a source ends or whether (b) it is the whole viewer window?

image

I think already (a) is awesome!

NicoKiaru commented 3 years ago

So far it's the central ray. There are a few things which could be tried - like casting rays on the 4 corners of the image and try to 'merge' them together, but I'm sure how to do that.

What we could also do is to add a button that rotates the view in order to make it perpendicular to the current nearest plane. Then maybe the slider feeling would be more natural.

NicoKiaru commented 3 years ago

It should not be too difficult to put all planes of a RAI as long as the ray intersects at least one plane.

tischi commented 3 years ago

I would merge it as is and then make issues about your suggestions. Should we merge?