Interactive text widget. Search box.

I’d like to have a search box in my scene, where the user enters a point id, and that point is highlighted for example.

Is there any widget that handles the input of text from the user? I am guessing that a TextWidget could be hacked for this purpose, but I am not sure how to handle the interactivity of data from the user.

Any hint is appreciated, thanks!

It would be a lot of work to implement such a widget using OpenGL. If you want to go beyond small demos or “lightweight” applications then you need to use a GUI toolkit, such as Qt.

Thanks @lassoan for your insight. It is indeed a lightweight visualization for research purposes and fast iteration.
I was thinking on hacking the Window Interactor (that is able to listen to the keyboard) to accept numbers [0-9, “,”, “-”, backspace and intro] to populate the text widget as a search box.
But yes, I realize that this is stretching the original purpose of the code base.
Do you know of any modern integration of the GUI toolkit imgui with VTK? Qt is a dependency too big for my purposes.

A huge advantage of Qt that it is known by many developers and used by many people on many different platforms. It is true that it is big (it is not a GUI toolkit but a platform abstraction layer) and its desktop widgets are in maintenance mode (we don’t see much feature development, and bugs are fixed at about the same rate as they are introduced).

Unfortunately, recent aggressive revenue-focused behavior of Qt Company makes its future somewhat uncertain. It would be nice to find an alternative, but I don’t think any of the other GUI toolkits come even close.

1 Like

I’d say +1 for Qt if you want to create an actual GUI, since VTK is fully compatible with it and provide the interface for it, QVTKRenderWidget, QVTKRenderWindowInteractor.

That being said, recent improvement to VTK have recently been made so it can be used directly to create an application (eg: system logo, drag&drop, …), see F3D for an example. Creating actual menu and GUI in this context would be complex, especially cross-platform.

1 Like

I have created a bridge vtkImguiAdapter between VTK and Imgui.

vtkImguiAdapter links both frameworks using SDL2. SDL2 compatibility in VTK was recently added in vtkSDL2OpenGLRenderWindow and vtkSDL2RenderWindowInteractor, so VTK9.0 is needed.

If VTK wasn’t compiled with VTK_USE_SDL2, those VTK files will be compiled in the vtkImguiAdapter project.

Imgui is not suited for controlling full desktop applications, but it’s a pretty useful addon for single window visualizations in VTK. The biggest selling point of Imgui is that it lives closer to the rendered data, so modifications of the data are easy. Imgui is used heavily in the game industry, as a level editor, and as a scene debugger.

For the search box, I am still figuring out how to easily FindData in VTK for a toy example. I am sure the functionality is there, but the API is not that clear to me.

Also, I haven’t tested it with a lot of rendered data, so, not sure yet about frame rates in complex scenes.

Please have a look at the code example. I am sure there is room for improvement.

3 Likes