Skip to content

Definitions manager

This MR adds adapter classes for vtkSMProxy vtkSMProperty vtkSMDomain and vtkSMPropertyGroup. These adapters are treated as immutable objects that provide information about the proxy/property/domain/propertygroup definition. The goal is provide enough information about building UIs without having to navigate the proxy definition XMLs or handle the SM classes directly.

In practice, (some) of the logic of pqProxyWidget has been abstracted and moved to these classes allowing in the future to reuse it in other UI frameworks. Where (some) refer to missing capabilities ragrding interfaces and +++.

A new microservice vtkPTSDefinitionManager is introduced that allows to construct a vtkProxyAdapter :

rxcpp::observable<vtkSmartPointer<vtkProxyAdapter>> GetDefinition(vtkSMProxy* smproxy) 
rxcpp::observable<vtkSmartPointer<vtkProxyAdapter>> GetDefinition(const std::string& group, const std::string& name);

The python wrapper can also return a dictionary with a structure similar( but not same) to the yaml files created by simput. Few examples:

contour.yaml

point2cell.yaml

sphere.yaml

wavelet.yaml

Why it returns an observable ? The current implementation does not take advantage of this but in the future loading a new session or a plugin might change the definition. Right now we don't monitor for either of these.

When it comes to Widget decorators pq*Decorator classes moved into a separate module in GUISupport/Decorators and converted to pure VTK (+ access to servermanager module) classes. Again this allows them to be reused outside of Qt without duplicating the logic. Moreover, they are python-wrapped and can be used in conjunction with trame in order to decorate web UI widgets.

example usage in python:

sphere = await builder.CreateSource("sources", "SphereSource")
point2cell = await builder.CreateFilter("filters", "PointDataToCellData", Input=sphere)
definition = await definitionManager.GetDefinition(point2cell)

yamlFile = yaml.dump(definition.as_dict()) # interoperability with simput

for prop in definition.GetProperties(): # prop is a vtkPropertyAdapter
    if len(prop.GetDecorators()) != 0:
        decorators = definitionManager.GetPropertyDecorators(point2cell, prop.GetName())

            for decorator in decorators:
                print(decorator.canShowWidget(False))  # should we show widget (show_advanced = False) ?
                print(decorator.enableWidget())  # should we enable the widget ?

Edited by Christos Tsolakis

Merge request reports