[vtkusers] Question about conversion of winId in QVTKRenderWindowInteractor.__init__

Elvis Stansvik elvis.stansvik at orexplore.com
Wed Jun 15 09:15:41 EDT 2016


2016-06-15 14:44 GMT+02:00 Elvis Stansvik <elvis.stansvik at orexplore.com>:

> Hi all,
>
> I have a question about this chunk of code in
> QVTKRenderWindowInteractor.__init__:
>
>         WId = self.winId()
>
>         # Python2
>         if type(WId).__name__ == 'PyCObject':
>             from ctypes import pythonapi, c_void_p, py_object
>
>             pythonapi.PyCObject_AsVoidPtr.restype  = c_void_p
>             pythonapi.PyCObject_AsVoidPtr.argtypes = [py_object]
>
>             WId = pythonapi.PyCObject_AsVoidPtr(WId)
>
>         # Python3
>         elif type(WId).__name__ == 'PyCapsule':
>             from ctypes import pythonapi, c_void_p, py_object, c_char_p
>
>             pythonapi.PyCapsule_GetName.restype = c_char_p
>             pythonapi.PyCapsule_GetName.argtypes = [py_object]
>
>             name = pythonapi.PyCapsule_GetName(WId)
>
>             pythonapi.PyCapsule_GetPointer.restype  = c_void_p
>             pythonapi.PyCapsule_GetPointer.argtypes = [py_object, c_char_p]
>
>             WId = pythonapi.PyCapsule_GetPointer(WId, name)
>
>         self._RenderWindow.SetWindowInfo(str(int(WId)))
>
> On which platforms will these two code blocks kick in? (i.e., when is
> winId() a PyCObject or PyCapsule?). It seems on Linux/X11 they do not,
> since winId() returns a sip.voidptr which can be used directly in the
> SetWindowInfo call.
>

I also have a related question: On the C++ side of things, looking at
QVTKWidget2::SetRenderWindow, it seems that QVTKWidget2 doesn't use the
SetWindowInfo(...) approach that QVTKRenderWindowInteractor uses. Instead
it seems to simply do this->mRenWin->SetMapped(1) and then resize the
renderwindow to cover the widget (and keep it covering when the widget
geometry changes). Anyone know the reasons for choosing one approach over
the other, or at least why this approach was chosen for QVTKWidget2?

Elvis


> Thanks in advance,
> Elvis
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160615/2f6d33fa/attachment.html>


More information about the vtkusers mailing list