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

Richard Whitehead richard.whitehead at vivosight.com
Wed Jun 11 18:02:30 EDT 2014


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!


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.


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


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.

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

More information about the vtkusers mailing list