VTK Examples

There has been a rewrite/upgrade of the CameraOrientationWidget example.

There is a new C++ version and a new PythonicAPI version. WASM now works with the C++ version.

These two new versions take into account all the recent changes to the vtkCameraOrientationWidget, namely, axes labels and colors along with the positioning of the widget can now be easily changed.

The code demonstrates how to to automatically change axes labels and colors depending upon the object being viewed. You can also reposition the widget, the option -r repositions the widget to the upper right corner.

The code for setting up labels, colors and making the widget has been moved into functions to make it easier to implement in your own code. Note that, where colors are used, we pass the original vtkNamedColors object from main() to these functions. This is to ensure that if you define your own colors then these can be easily passed into these functions.

Look at the history section at the end of the description to see the relevant MRs corresponding to when these improvements were introduced.

Thanks to Jaswant Panchumarti and Shelly Belsky for making this a really useful widget.

Enjoy

3 Likes

That’s awesome, thank you, Andrew!

Hello, how does it work the -r option in Python?

I noticed where you say “You can also reposition the widget, the option -r repositions the widget to the upper right corner.”, and this could provide a workaround for a problem we have with PySide and PyVista in our PZero application, with the widget being huge and in the middle of the view.

You may have to wait for the next release of VTK,
However have a look at vtkCameraOrientationRepresentation for what can be done.
Also doing a reset camera before the render may help:

ren.ResetCamera() ren_win.Render() iren.Initialize() iren.Start()

Finally, remember that the interactor must be set prior to enabling the Camera Orientation Widget.

Hi, I’ve done some testing but found no solution.

Actually, some of the methods you cite are not exposed, since I’m using the Plotter of PyVista in Qt, with pyvistaqt.

Maybe @banesullivan could provide some suggestion?

Thanks!