Add a button to make value based selection in 3d clipping tool#479
Add a button to make value based selection in 3d clipping tool#479
Conversation
|
This would be one way to implement scipp/essdiffraction#102 |
There was a problem hiding this comment.
Playing around with it and it works nicely 👍
- Can you update the docs page about plots with value threshold? It seems like we no longer need to show a manual implementation?
- Please update the tooltip of the button that opens the cutting tool. Currently it says 'Hide/show spatial cutting tool'. But it is no longer only spatial.
There was a problem hiding this comment.
Can you update the docs page about plots with value threshold? It seems like we no longer need to show a manual implementation?
I think I still want to keep the example in the gallery. Doing it that way is still a valid use case I feel, as it doesn't require interaction from the user to actually get the desired plot.
What I could do though, is a page explaining in more detail how to use the clipping tools though... I opened #523 for this.
src/plopp/widgets/clip3d.py
Outdated
| A tool that provides a slider to extract a points in a three-dimensional | ||
| scatter plot based on a value selection criterion, and add it to the scene as an | ||
| opaque cut. The slider controls the range of the selection. | ||
|
|
||
| .. versionadded:: 25.08.0 |
There was a problem hiding this comment.
| A tool that provides a slider to extract a points in a three-dimensional | |
| scatter plot based on a value selection criterion, and add it to the scene as an | |
| opaque cut. The slider controls the range of the selection. | |
| .. versionadded:: 25.08.0 | |
| A tool that provides a slider to extract points in a three-dimensional | |
| scatter plot based on a value selection criterion, and adds it to the scene as an | |
| opaque cut. The slider controls the range of the selection. | |
| .. versionadded:: 25.02.0 |
How do you handle setting a future version in this?
There was a problem hiding this comment.
How do you handle setting a future version in this?
As far as I know, you can't. You have to guess in advance what the version will be 😞
src/plopp/widgets/clip3d.py
Outdated
| self._update() | ||
|
|
||
|
|
||
| class ClippingPlanes(ipw.HBox): |
There was a problem hiding this comment.
Is there a better name? It's not really just planes anymore.
src/plopp/widgets/clip3d.py
Outdated
| disabled=True, | ||
| tooltip='Operation to combine multiple cuts', | ||
| layout={'width': '60px', 'padding': '0px 0px 0px 0px'}, | ||
| layout={'width': '78px', 'padding': '0px 0px 0px 0px'}, |
There was a problem hiding this comment.
I think these should be specified in a relative unit to deal with different font sizes.
src/plopp/widgets/clip3d.py
Outdated
| self.layout.display = 'none' | ||
|
|
||
| def _add_cut(self, direction: Literal['x', 'y', 'z']): | ||
| def _add_cut(self, direction: Literal['x', 'y', 'z', 'v']): |
There was a problem hiding this comment.
| def _add_cut(self, direction: Literal['x', 'y', 'z', 'v']): | |
| def _add_cut(self, tool_kind: Literal['x', 'y', 'z', 'v']): |
or something similar.
There was a problem hiding this comment.
Maybe I can change direction to kind everywhere.
src/plopp/widgets/clip3d.py
Outdated
| else: | ||
| selections.append( | ||
| (da.coords[cut.dim] >= xmin) & (da.coords[cut.dim] < xmax) | ||
| ) |
There was a problem hiding this comment.
Can this and the branch in _remove_cut above be handled by the tools themselves? I.e., use a common interface and avoid branches here to keep this class simpler.
(In particular since the _remove_cut looks at a private attribute.)
There was a problem hiding this comment.
Good suggestion to move this part inside the tool 👍
For the _remove_cut, I kept it as is because:
- the tool would then have to have knowledge about the canvas so it can remove itself from it (pythreejs objects have no knowledge of which Scene they are being displayed on, the Scene has to remove them via
scene.remove(outline), which is what thecanvasis doing internally. - it is actually useful to have a
directionattribute to identify the type of clip, and I would be making use of that in Updates to Dream instrument view essdiffraction#242
src/plopp/widgets/clip3d.py
Outdated
| self._unit = self._limits.unit | ||
| self.visible = True | ||
| self._update = update | ||
| self._direction = 'v' |
There was a problem hiding this comment.
This can be removed if you implement my suggestion for avoiding branches in ClippingPlanes.
Click on the V button to add a value selection.

This is basically like the threshold gallery example made easier.
Draft because I am not sure we need the added complexity if this can be done quite simply like in the gallery example.