Hi Matthew, Thanks a lot for your answer !
So if I understand correctly (as I'm still a beginner in the Python binding world / Shiboken). If I have a C++ class based on both Qt and VTK (like this one : http://camitk.imag.fr/apidocumentation/3.2/classcamitk_1_1RendererWidget.html), I would be able to expose the VTK part using VTK's Python binder OR Qt part using Shiboken, but not both (or I send $$ to VTK to convert them to Shiboken ;-) And then the solution seems to be to still use Shiboken, and inject code in the wrapped classes (containing CPython code) in order to tell it how to convert the Python object (PyObject) into a VTKObject when necessary. Which seems difficult, from the C++ side, regarding how VTK handles its VTKObjects. Please let me know if I've misunderstood some points ! And, by the way, would this problem still occur if we decide not to expose to Python the VTK part ? I mean, we still consider C++ classes based on both Qt and VTK, but only describe in the typesystem.xml files for Shiboken, the C++ and Qt objects we want to expose (thus no rules for VTK objects). This way, the CPython extension generated would still be able to run the VTK methods trought the C++ library, but forbid to directly handle the VTK objects from the Python world (or crashes). But I don't know if it would be possible to render the 3D of VTK in some Qt widget ... Feel free to react, as I said I'm not an expert, any advice is welcome (except sending too much $$ to kitware ;-) ) Thanks, Nicolas. On 12/12/2013 06:07 PM, Matthew Woehlke wrote: > On 2013-12-12 11:09, Nicolas SAUBAT wrote: >> I'm trying to bind to Python a C++ framework, called CamiTK >> (http://camitk.imag.fr) which is based on Qt and VTK (http://www.vtk.org/). >> For binding Qt C++ classes, no problem, we can tell Shiboken how to use >> Qt in Python, thanks to the provided typesystem.xml files. >> But I was wondering, how we can do the same stuff using VTK ? > Well. That's a good question. > > If you just want to generate bindings for VTK-based objects, VTK has its > own wrapping system that will allow you to do that. (IME it's rather > limited compared to Shiboken; no support for enums, STL containers, > etc.) However, getting the two to talk to each other is likely to be an > issue. > > What you would ultimately need to do, I think, is to be able to teach > Shiboken how to get a vtkObject* from a PyObject. As far as the Shiboken > architecture, I think you should be able to write custom converters for > this. > > The problem comes with how VTK implements its conversions, which depends > on having a pointer to the call arguments, which is not available in > Shiboken. As such, I'm not sure that (at the C++ level) it is possible > to get the vtkObject* from *just* a PyObject. > > TBH, I have the same problem and haven't solved it, except that I > decided the best thing to do would be to rewrite VTK's wrapping to just > use Shiboken and be done with it ;-). If you find a solution, please let > me know. (If you can throw $$ at making VTK use Shiboken, please also > let me know ;-).) > > Note that it's probably impossible to wrap a VTK-derived object with > Shiboken in any useful way. > -- Nicolas SAUBAT Ingénieur Recherche et Développement Equipe GMCAO - Laboratoire TIMC-IMAG Pavillon Taillefer Allée des Alpes - Domaine de la Merci 38706 La Tronche Tel : (33)04 56 52 00 10 _______________________________________________ PySide mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/pyside
