I have just built VTK from source with Qt support. One of the things I'm interested is the PBR (physically based rendering), which was introduced in v9.0.
I would like to interact with various parameters such as metallic, color, roughness etc. components using QScrollBar
and other Qt widgets.
There are multiple VTK examples available here. However none show the behaviour I'm looking for but instead concentrate on just rendering things on the screen without any interaction outside of what the widget offers out of the box.
Give an instance of vtkActor
(for example a sphere) I would like to access SetMetallic(double)
, SetRoughness(double)
etc. (through vtkActor::GetProperty()
) and connect those to let's say QScrollBar::valueChanged(int)
(yes, I'm aware that it emits int
) to allow changing the properties of the surface of the object.
My issue is mostly on how to access the actors through the VTK Qt widget. Of course due to my lack of knowledge in VTK it is also possible that this question is a more general in nature namely how to access the actors in any type of GUI environment, where VTK is integrated into.
UPDATE:
Here is what I have so far:
vtkWidget->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActors()->GetNextActor()->GetProperty()->SetColor(0.7, 0.1, 0.4);
For a given instance of QVTKOpenGLNativeWidget
called vtkWidget
I retrieve the render window, then for example retrieve the first renderer (in case there are more a slightly different approach is required). From there a renderer provides me with all the actors. If I iterate (using GetNextActor()
in a loop that checks if there are any actors left in the collection) I can access an actor. Here the problem is that I am not sure how to distinguish between several actors but this is a purely VTK-related question. Once I have the actor I can get the property and set it accordingly (in the example above I have manually set the Color
property of the actor).
Looking at this I am seeing 5-6 function calls, which sounds like a lot of work so the interesting question is if there is a more direct approach.