[vtkusers] VTK + Gtk

Vincent Nicolas vincent.nicolas at tele.ucl.ac.be
Tue Apr 27 16:22:43 EDT 2004


Hi Luca,

> I am planning the development of an application using VTK and GTk on 
> Linux.

I think Gtkmm is a better way than using directly Gtk. Gtkmm is a C++ wrapper on top of Gtk ( pure C ). As VTK is in c++, it's really easier to stay in the same language.

> I think I must use two separate threads as both VTK and Gtk own
> specific main loops.
> I wonder which communication method between VTK  and  Gtk  is  better,
> as I  suppose  it is not possible  to exchange  data directly between 
> them via global variables.

With Gtk(mm), you can create two separate threads, one for GUI and the second for every VTK pipeline you want. 
Gtkmm uses signals (from libsigc++ library) which allows communication between Gtkmm events/methods synchroneously ... so this could run into problems when dealing with threads ... the solution come from Gtk(mm) which add a Dispatcher method, it's an asynchronous signal. Gtk(mm) also add some method for creating thread and managing them. 

Gtkmm doc on threads:
http://www.gtkmm.org/gtkmm2/docs/reference/html/group__Threads.html

Gtkmm doc on dispatcher: 
http://www.gtkmm.org/gtkmm2/docs/reference/html/classGlib_1_1Dispatcher.html

> I think this is a crucial issue, as the Gtk GUI should be able to modify 
> several visualization aspects controlled by VTK.

You are right, it's a crucial issue, except if you don't need smooth GUI and real time interraction between GUI and visualisation windows.

> Can somebody help me understand which would be the most efficient way to 
> do that? Is the multi-threaded approach right?

I'm writing such an application, and use the main loop for GUI, and create new threads when needed by VTK pipelines. Gtk::Dispatcher allow me to manage progress bar, "real time" modification of actors on scenes (color, opacity, add new actors, ...), loading multiple datas concurently, ...

> 
> Thanks in advance
> 
>   Luca P. Lavorante


Vincent Nicolas
-----------------------------------------
Communications and Remote Sensing Lab.
Universite catholique de Louvain
vincent.nicolas at tele.ucl.ac.be
+32 (0)10 478555
http://www.tele.ucl.ac.be





More information about the vtkusers mailing list