Upgrading VTK widgets framework

As part of our future roadmap for VTK, we are planning to upgrade the VTK widgets framework to better support applications in managing and synchronizing widgets and their properties. This mainly includes synchronization of widgets and their corresponding representations across multiple viewports (vtkRenderer) and render windows (vtkRenderWindow). This is a very common use case for multi-view / multi-window applications that display widgets and annotations across multiple views. Current VTK widget classes are not designed to explicitly support this use case. As an extension of this effort, we also plan to introduce a higher level widget management structure to simplify the construction and management of widgets in an application.

State synchronization for representing widgets across multiple views

We plan to introduce a set of widget state classes (e.g. vtkLineWidgetState) that can be used to synchronize widget states across multiple views. Multiple widgets that wish to share state with each other will essentially point to the same state object as their model.

Simplifying widget instantiation and management

Instantiating and adding specific widgets to a renderer often requires understanding multiple classes and how they interconnect, for example, knowing about the multiple 2D / 3D representations and corresponding widget classes. There are multiple widgets serving similar functionality such as vtkLineWidget, vtkLineWidget2, and vtkMultilineWidget. We plan to introduce a vtkWidgetManager class (similar to what is implemented in vtk-js: https://kitware.github.io/vtk-js/docs/develop_widget.html) that will manage the life cycle of a widget and support synchronization of properties. The vtkWidgetManager will support pre-built recipes for the common use cases for widgets to simplify this process of choosing which classes to instantiate and which representations to use for common use cases. The utility of the widget manager could be extended further to features such as setting the current “in-focus” widget that will grab all interaction events (similar to vtk-js).

We would like to receive ideas and suggestions from the community within the scope of the above mentioned task.

References

  1. vtk-js widget concept: https://kitware.github.io/vtk-js/docs/concepts_widgets.html

  2. vtk-js develop widgets: https://kitware.github.io/vtk-js/docs/develop_widget.html

  3. Widget Manager Trame: https://github.com/Kitware/trame-vtk/blob/master/examples/widgets/clip.py

What matters as a maintainer:

  1. Current design/classes keep working (even if deprecated)
  2. New designed/classes are simpler to use, implement and maintain

The current design make the widget classes a bit hard to use and very hard to add new widgets and such, with tons of boilerplate.
If the new design account for that, i’d be happy!

Do look at the vtk Examples, in particular the C++ and PythonicAPI versions. The widgets are particularly useful in the sense that they can be rescaled, resized and moved. However as Mathieu said, thay are a bit hard to use, often requiring the setting of very many parameters for positioning etc.. To overcome this I have been implementing classes like ScalarBarProperties and functions like make_scalar_bar_widget and specific functions like position_sbw_h and position_sbw_v that resize horizontal and vertical scalar bars, dependent upon the number of entries in categorical color series. Additionally there are functions like get_text_positions to simplify placing text widgets in a viewport. You can see all these in !464 - not finished yet! Also look at FroggieView where slider callbacks are used. The C++ interactive example now works.

Please also consider nice examples showcasing any new classes. They can be based on the VTK tests.