pyvista / pyvista-support

[moved] Please head over to the Discussions tab of the PyVista repository
https://github.com/pyvista/pyvista/discussions
59 stars 4 forks source link

Boolean widget and export to vtkjs #69

Closed dennissergeev closed 4 years ago

dennissergeev commented 5 years ago

Is it possible to add a boolean-type widget to pyvista plotter, i.e. a tick box to show/hide a mesh?

And secondly, if this is possible, can a scene be saved to .vtkjs with this sort of tick box (and a corresponding hidden mesh?)

Thank you.

banesullivan commented 5 years ago

Is it possible to add a boolean-type widget to pyvista plotter, i.e. a tick box to show/hide a mesh?

There's no boolean style widget in VTK (to my knowledge) but we could easily implement a tick box widget in the BackgroundPlotter as part of the Qt interface... I'm not sure of a way to embed a Qt widget in the standard Plotter off the top of my head.

And secondly, if this is possible, can a scene be saved to .vtkjs with this sort of tick box (and a corresponding hidden mesh?)

Given the current state of VTKjs and how we export to VTKjs, this isn't possible.

However... itkwidgets might be able to handle implementing something like this if we can push for more development towards a PyVista style plotter in itkwidgets (see also https://github.com/InsightSoftwareConsortium/itkwidgets/issues/166)

banesullivan commented 5 years ago

Actually, there is a button widget! I will add this now

banesullivan commented 5 years ago

A work in progress is in the more-widgets branch... the button widget is a bit more complicated and difficult to implement than the rest of the widgets oddly enough

dennissergeev commented 5 years ago

Thanks @banesullivan !

And regarding VTKjs export, this still won't be possible, will it? On a related note, I noticed that things like colorbars and text are not being saved to VTKjs. Is this an expected behaviour?

banesullivan commented 5 years ago

And regarding VTKjs export, this still won't be possible, will it?

Nope, not possible.... Maybe one day, but not anytime soon.

On a related note, I noticed that things like colorbars and text are not being saved to VTKjs. Is this an expected behaviour?

Yep, this is expected... the current VTKjs exporter in PyVista only exports meshes with their mappings and textures so that the scene can be recreated in VTKjs. There is no equivalent of a scalar bar, axes widgets, or text actors in VTKjs at this time, so it isn't possible to export those.

However... some really exciting things are happening over in itkwidgets and I think we could have a mostly full-fledged itkwidgets plotter by early 2020 (see gif below from https://github.com/pyvista/pyvista/pull/389 for a rough prototype). VTKjs does support widgets similar to what we have in PyVista, so maybe itkwidgets would be the place to properly develop and use those kinds of features.

66076781-c85e1f00-e51b-11e9-9ba0-30aa60a1ab57

Also, the folks over at panel recently added some awesome features where the scalar bars are preserved in the panel alongside the VTKjs rendering (see https://github.com/pyviz/panel/pull/606 and image below). @xavArtley has been working hard to implement all of those awesome features in panel and might be able to provide further insight into what is possible using panel

64979761-abd5ac00-d8b8-11e9-992b-5dfa47a9f778

banesullivan commented 5 years ago

Actually the itkwidgets viewer already has a way to turn the visibility of a specific mesh off, so maybe try that out for an immediate hack of a solution!

dennissergeev commented 5 years ago

That's great! Looking forward to 2020! :)

I was asking this because I'm trying to embed VTKjs-exported scenes into an HTML page. Will a scene exported from PlotterITK as a standalone file contain labels and colorbars (and widgets)?

banesullivan commented 5 years ago

Will a scene exported from PlotterITK as a standalone file contain labels and colorbars (and widgets)?

I haven't tried this, so I am not sure. If you can save the widget, then I would imagine all of the interactive features (colorbars, buttons, etc.) would be there