UI widget generation (automation) for VTK

I am interested to write a new UI (using QT) for VTK

I will probably start prototyping via Python to evaluate it’s longer feasibility and maintainability.

Instead of hand writing individual UI node for each corresponding VTK class (using vtkArrowSource as an example), I am hoping to automate the process, however I am unsure if vtk parameter get/set methods are all following a specific naming convention for which I can use a regex to extract them, I also need the parameter name and type to be able to generate corresponding UI widget for each of them e.g. TipLength parameter are double while TipResolution are integer, it would also be useful to know the value range as envisage by the author of the node.

How would other tackle this problem within what VTK C++/Python provides ?

Are there some upcoming features in VTK e.g. version 10, which can make the above a breeze, maybe some reflection technique to retrieve all user adjustable parameters with name, type, range and hints [e.g. string can be use for folder]

I can use something like the following but I get methods that I believe would not make sense in a UI

def getMethods(classname: str) -> list:
    method_list = [attribute for attribute in dir(str2Class(classname)) if
                   callable(getattr(str2Class(classname), attribute))
                   and attribute.startswith('__') is False
                   (attribute.startswith('Set') is True or
                    attribute.startswith('Get') is True
    return method_list

You may want to check the new marshalling hints. This could probably be adapted to your needs.

@jaswantp WDYT?

If you plan to use PySide/Qt, I’d wager Python’s object introspection capabilities are sufficient. Moreover, VTK will soon have the properties exposed as pythonic properties, so you wouldn’t need to parse function names at all.

If you prefer C++, runtime introspection of VTK objects is doable but it needs work. vtkParseProperties.h runs at compile time on the class headers to catalog different properties and their set/get functions. We’ll need to store that information and present it at runtime using a map of vtkVariant?

Instead, what if you used json as the means to push(pull) state from(to) the Qt UI to(from) VTK objects? In that case, you will benefit from autogenerated C++ code which can capture the properties of an object in json and also apply the property values on an object from json. Does that make sense?

1 Like

Several GUI pipeline editors has been developed for VTK over the past 30 years (VTK Designer, MayaVi/tvtk, BVTKNodes, SimVTK, etc.) and these projects are mostly dead or unhealthy (software package developed by a single person, user community not growing).

Therefore, before jumping in, I would recommend to think about what your end goal is, what you want to achieve on what time horizon, who would be your users, and how would you sustain the project in the long term.

You may also reconsider using Qt. Now that VTK runs natively in the web browser (not just VTK.js but real VTK, using webassembly) using Qt for GUI would be extremely limiting. Especially because a VTK pipeline editor would be most useful for education purposes and novices would not necessarily know how to (or would not want to) set up Python environments or install desktop applications. Implementation using web GUI could be easier, too, because there are tons of full-featured pipeline editors for web frameworks, such as reactflow . There are pipeline editors for Qt, too (for example QSchematic) but how well they are supported, is Python wrapping provided, …? Or just compare how easy to give reactflow a try (you can drag and drop boxes on the frontpage of their website - takes seconds) compared to QSchematic (you need to download Qt, download the source, build some demo project - takes hours). If you compare number of stars, number of closed pull requests, etc. - everything is about 100x more for the web framework, so probably there are 100x more developers and users. I’m a C++ developer (with significant time spent in Python nowadays), but for any new projects I would not lock myself into using Qt desktop GUI.

1 Like

@lassoan Thank you for the insights. I will invest time to learn the web technology aspect, starting with VTK.js

Kind regards

UI (using QT) for VTK

Sounds like ParaView to me