Skip to content

Introduce PipelineBuilder microservice

This Merge Request continues building on the idea of "microservices" and introduces two such services.

vtkPTSPipelineBuilder

vtkPTSPipelineBuilder A class to create pipeline elements such as sources, filters, readers and representations.

vtkPTSPipelineBuilder uses internally vtkParaViewPipelineController /vtkParaViewPipelineControllerWithRendering and takes care of pre/post initialization of a proxy as well as registration with the proxymanager. Its API consists mainly of single-value observables returning the created proxy or an error where applicable.

parat.pipelineBuilder is a new Python class that acts as a thin-wrapper for vtkPTSPipelineBuilder. Its provides as more pythonic API, converts observable-based API to async functions and allows to extra keyword-based arguments to be used as property values:

from parat.pipelineBuilder import *

App = PythonApplication()
session = await App.initialize()
 
builder = PipelineBuilder(session)
 
sphere = await builder.CreateSource("sources", "SphereSource", ThetaResolution=80, Radius=2)

Properties are set using a new microservice vtkPTSPropertyManager.

vtkPTSPropertyManager

vtkPTSPropertyManager provides a minimal API for setting any property of a proxy:

 std::vector<vtkVariant> GetPropertyValue(vtkSMProxy* proxy, const std::string& name);
 void SetPropertyValue(vtkSMProxy* proxy, const std::string& name, const std::vector<vtkVariant>& value);
 void SetPropertyValue(vtkSMProxy* proxy, const std::string& name, const vtkVariant& value); // convenience method

It is mainly used as a base for parat.propertyManager that allows to set proxy properties using native Python objects or even change-sets in the form of a dictionary:

...
sphere = await builder.CreateSource("sources", "SphereSource", ThetaResolution=80, Radius=2)
pmanager = PropertyManager()
pmanager.SetPropertyValue(sphere, "Radius", 5) 
pmanager.SetPropertyValue(sphere, "Center", [1, 2, 3]) 
pmanager.SetPropertyValue(sphere, "Center", (3, 4, 5))      
pmanager.SetProperties(sphere, {"StartPhi":10, "EndPhi": 90, "PhiResolution": 80 }) 

assert pmanager.GetPropertyValue(sphere, "Center") == [3,4,5]
assert pmanager.GetPropertyValue(sphere, "StartPhi") == 10

parat.propertyManager includes also API for calling methods of proxies that return observables :

...
view = await builder.CreateView("views", "RenderView")
await pmanager.Update(view)  # C++ API: rxcpp::observable<bool> vtkSMViewProxy::Update()

as well as the ability to switch the visibility of a representation.

representation = await builder.CreateRepresentation(shrink, 0, view, "GeometryRepresentation")
pmanager.SetVisibility(representation, view, False)

this is merely to keep all "set"/"get" methods of a proxy to a single microservice.

I am not sure that the last two cases belong to propertyManager but I don't know where else they could live. So, we leave them here for now and they may be moved to a separate microservice later.

Edited by Christos Tsolakis

Merge request reports

Loading