VTK Examples - Changes to ViewportBorders

Changes mainly focusing on viewport borders and using text widgets:

  • The C++ snippet ViewportBorder has been renamed to DrawViewportBorder. It now returns a vtkActor2D. Additionally a struct ViewportBorderSpecifier is provided to specify what lines need to be drawn around the border. This is particularly useful for drawing borders around multiple viewports without duplicating adjacent borders.
  • The Python snippet DrawViewportBorder has also been refactored to return a vtkActor2D. It also uses a a dataclass called ViewportBorderSpecifier.
  • The C++ snippet ReadPolyData has been rewritten to use the C++ filesystem. Note the use of .generic_string() - really important for Windows! The thinking here is that the C++ filesystem is so natural and easy to use, much like Python’s pathlib so why not use it.

Of course, examples affected by these changes have been rewritten and … “improved”. Additionally, in the case of the C++ examples, where the viewports were labelled, these labels have been converted to vtkTextWidgets. The advantage of this is that the text widgets stay in the same relative position when the window is resized. To position multiple text widgets, a function is provided called GetTextPositions(...), in C++, and get_text_positions(...), in Python. There is a PythonicAPI snippet GetTextPositions for this.

To get an idea of how these functions are used, please see:

Here is what the old version looked like:

and this is the new version:

For a more complex example using all the above changes, see:

Here is what the old version looked like:

and this is the new version:

3 Likes