[vtkusers] Get a VTKRender to draw inside an external QWidget (ver5) (or QOpenGLWidget)

Andras Lasso lasso at queensu.ca
Sat Sep 15 10:16:34 EDT 2018


The Qt OpenGL widget is Python-wrapped in CTK using PythonQt. The view widget has several improvements over the plain VTK widget, such as scheduleRender infrastructure to optimize calling of render() after changes in the VTK pipeline.

http://www.commontk.org

It is used in 3D Slicer, MITK, etc.

Andras
________________________________
From: David Gobbi <david.gobbi at gmail.com>
Sent: Saturday, September 15, 2018 9:58 AM
To: Elvis Stansvik
Cc: VTK Users
Subject: Re: [vtkusers] Get a VTKRender to draw inside an external QWidget (ver5) (or QOpenGLWidget)

Hi Elvis,

QVTKOpenGLWidget is not available in Python, it would have to be
wrapped with sip (or shiboken) rather than with the stock VTK wrappers.

The old QVTKWidget was, at one point, wrapped in Python as shown here:
https://gitlab.kitware.com/vtk/vtk/commit/d487197<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.kitware.com%2Fvtk%2Fvtk%2Fcommit%2Fd487197&data=02%7C01%7Classo%40queensu.ca%7Ca811ce9266714ebcb9a808d61b136097%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636726167389018144&sdata=UIeDsSTCw0YQ168bpV11UR8YcGbbrwmxMZBjeeSlx1A%3D&reserved=0>

It's totally feasible to do something similar with QVTKOpenGLWidget, if
someone wants to dedicate the time.

 - David


On Sat, Sep 15, 2018 at 6:06 AM Elvis Stansvik <elvis.stansvik at orexplore.com<mailto:elvis.stansvik at orexplore.com>> wrote:

I came across this thread while trying to find a QOpenGLWidget based
VTK/PyQt5 widget.

Just want to ask: The QVTKOpenGLWidget suggested here is not available
from Python right? (since it's not a vtkObject).

The OP asked about Python, and I'm sort of in the same boat.

Elvis

>
> Regards,
> Martijn
>
>
>
>
>
> Op 22 feb. 2018 21:10 schreef "Steve Petruzza" <spetruzza at sci.utah.edu<mailto:spetruzza at sci.utah.edu>>:
>>
>> Hi,
>>
>> I have a QOpenGLWidget that draws using gl calls. I would like to use a VTK render to draw inside the same canvas.
>>
>> I tried to use a QVTKRenderWindowInteractor passing the canvas as parent, but the canvas starts flickering and I cannot see any rendering.
>> The same VTK render (using the same QVTKRenderWindowInteractor) works correctly in a separate vtkrenderwindow.
>>
>> Is there any simple way to just get the VTKRender to draw directly into the glRender loop of the canvas using the existing rendering window?
>> Or any other suggestions.
>>
>> I am using VTK 8.1.0 and Qt 5.10 and this QVTKRenderWindowInteractor: https://gitlab.kitware.com/alextsui05/vtk/blob/e9e9ffcfbbad68343a0782a1d9024735b7649a46/Wrapping/Python/vtk/qt5/QVTKRenderWindowInteractor.py<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.kitware.com%2Falextsui05%2Fvtk%2Fblob%2Fe9e9ffcfbbad68343a0782a1d9024735b7649a46%2FWrapping%2FPython%2Fvtk%2Fqt5%2FQVTKRenderWindowInteractor.py&data=02%7C01%7Classo%40queensu.ca%7Ca811ce9266714ebcb9a808d61b136097%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636726167389018144&sdata=q62tMP%2ButZOYi13u%2FJ0Uv3GEWpLaZKRG%2FJpgk1BmjYk%3D&reserved=0>
>>
>> Thank you,
>> Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180915/3635f991/attachment.html>


More information about the vtkusers mailing list