[vtkusers] How to embed VTK rendering context into Windows Form

Sonya Blade sonyablade2010 at hotmail.com
Fri Jun 13 03:10:25 EDT 2014


Thank You Richard your comments helped me a lot.I managed to get it working on VC++2012, having set the Parent Id to a controls handle worked for me,while I was expecting flickering on the control canvas, also not expecting the mouse inputs to be handled properly between control and VTK window (how VTK renderwindow message queue system is hooking itself into controls is still vague for  me),but everything worked fine. 
Commenting on Python usage has really brought new dimension to my thought, since I was trying to achive the GUI with VC++2012 features and where the VTK library will remain intact. It seems that  the Python is exactly what I need. I think the hardest part will be integrating the python created interface and VTK in VC++2012. 
I googled a bit to get familiar with usage/programming of Python for GUI but what I found was quite discouraging with command-like interface poping out windows, probably I didn't find the right tutorial on net but I'll still continue to look for them,I was expecting more like an IDE. 
I'll appreciate your entry points,
Regards,

From: richard.whitehead at vivosight.com
To: sonyablade2010 at hotmail.com; vtkusers at vtk.org
Subject: Re: [vtkusers] How to embed VTK rendering context into Windows Form
Date: Wed, 11 Jun 2014 23:02:30 +0100







Sonya,
 
It sounds like you are mixing C++ with C++ .NET (CLR), which are different 
languages.  In principle they should work together (C++ CLR is often used 
as a “bridge” between pure C++ and other .NET languages such as C#).  If 
you are struggling to get started then I think this is going to give you a lot 
of trouble, C++ CLR I would consider to be an “expert’s” language, and writing 
in multiple languages is always asking for trouble.
I would advise you to stick purely to C++ if at all possible.  I have 
not used Qt, but it seems that VTK integrates well with Qt.  Qt is a 
framework for making user interfaces – the same job that MFC does – but is 
cross-platform (i.e. it will work on Apple as well as Windows), and it is more 
oriented towards visual and imaging programs. 
 
Another off-the-wall suggestion for you to think about:  have you 
considered writing in python rather than C++?  VTK ships with python 
wrappers – in other words, python versions of all the classes.  These are 
produced automatically so they should all be up-to-date.  A lot of the 
examples are in python.  You can make user interfaces in python.  
Python is considered a much easier language to learn than C++ and you won’t have 
all the mess with templates and smart pointers.  It may be slightly less 
efficient but this is probably not important at all.  Just an idea.
 
Hope this helps.  I’m away tomorrow (Thursday) so I won’t reply again 
until Friday!
 
Richard
 
 
 


 

From: Sonya Blade 
Sent: Wednesday, June 11, 2014 10:02 PM
To: Richard Whitehead 
Subject: RE: [vtkusers] How to embed VTK rendering context into 
Windows Form
 

Hi Richard, 


I'll be grateful if you can do 
that,
I do absolutely nothing other than adding new 
MyForm item (which is visual control) to the existing 

AreaPicking.cxx example which originally ships with VTK examples. 
Furthermore I do have to turn on the CLR support 
under the Solution properties-> C/C++ -> Code Generation, where whole 
mess begins.
 
Probably I shouldn't create the form that way at all?
 
#include <vtkVersion.h>
#include <vtkSmartPointer.h>
#include <vtkPoints.h>
#include <vtkXMLPolyDataWriter.h>
#include <vtkPolyData.h>
#include <vtkCellArray.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkInteractorStyleRubberBandPick.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkInteractorStyleTrackball.h>
#include <vtkAreaPicker.h>
#include <vtkCallbackCommand.h>
#include <vtkProp3DCollection.h>
#include <MyForm.h>   // If comment out that line 
everything works normally in VTK way, spawns the console window and everything 
is fine.
 
Regards,
 


From: richard.whitehead at vivosight.com
To: 
sonyablade2010 at hotmail.com
Subject: Re: [vtkusers] How to embed VTK rendering 
context into Windows Form
Date: Wed, 11 Jun 2014 21:36:55 +0100






Sonya,
 
It sounds like you have not #included all the header files it needs to 
understand you code, but I don’t really have enough information to help beyond 
that.  You could send some code...  but I probably won’t get to look 
at it until Friday.
 
Richard

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140613/f37acc60/attachment.html>


More information about the vtkusers mailing list