[vtkusers] Using vtk with GTK

Day, Michael A AMRDEC/UAH mike.a.day at us.army.mil
Thu Aug 11 14:17:58 EDT 2005


Following my message is an old message from the vtkusers mailing list, describing how to use gtkmm to get the VTK RenderWindow to live inside a GTK window AND be able to put other GTK Widgets in the same window.

I would like to port this to straight C (instead of C++) and GTK+ (instead of gtkmm) and am quite lost as to how do do it for the current stable version of GTK+ (2.6.9).  Since my platform is Windows, I can't use GtkPlug and GtkSocket because those are only available in the 2.7.x (development) release of GTK+.  This is further complicated by the fact that I can't find where GDK_WINDOW_HWND is defined.

Has anyone done this before?  I would like to do this in C, not in Python or Tcl/Tk -- I've already read about PyGTK but I don't want to learn Python or Tcl/Tk or make end users of my shiny new application install them.

Thanks,

Mike Day
Virtual Targets Center

https://modelexchange.army.mil/



--------------------------------------------------------------------------------

Hi,

I'm using using VTK and GTK for a long time now and it works very well.
To be able to display a VTK window in a Gtk widget, you need to use an OpenGL widget. There are two OpenGL libraries for Gtk : GtkGLArea and GtkGLExt. I recommend the second since itis actively maintenained and seems to be superior as it allows any GtkWidget to contains an OpenGL window.

To render a VTK window in a GLWidget, you only need to specify the Gtk window Id to the VTK RenderWindow before calling Render().
Here is the C++ code to do that, it should be easy to change it to pure C. Suppose that "this" is the Gtk GL Widget and pay attention to the "WINDOW_HWND" (Win32) or "WINDOW_XWINDOW" (Linux, ...).

#ifdef	WIN32
	this->RenderWindow->SetWindowId((void*)GDK_WINDOW_HWND(this->get_window()->gobj()));
#else
	//Attach VTK Renderer to current OpenGL Window
	this->RenderWindow->SetWindowId((void*)GDK_WINDOW_XWINDOW(this->get_window()->gobj()));
#endif	
	this->RenderWindow->SetSize(this->get_width(), this->get_height());

Once you have linked you VTK render Windows, you can pack you Gtk GL Widget like any other Gtk object. Don't forget to call RenderWindow->Render() only after you have packed and showed your Gtk widget, else another window will be created !

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

On Thu, 04 Dec 2003 21:35:22 +0530
"shrinivas kulkarni" <kshrinivas at hotmail.com> wrote:

> Hi all,
> 
> I need to draw a VTK window inside a GTK window( I can do this easily), but 
> apart from this, the in same GTK window I want to place few buttons. I think 
> GTK does not allow to do this, because VTK needs a window ID/HANDLE to 
> decide, in which window it needs to be displayed and in GTK we can get such 
> handle only for top level window.
> 
> Has anybody created UI like this( VTK in GTK with buttons in it)? Note that 
> I am working on Windows platform. So if anybody have idea/suggestion how to 
> do this would be really helpful.
> 
> Thanks
> Shrinivas
> 
> _________________________________________________________________
> It is Ms World time! Send in your wishes to Ami Vashi. 
> http://server1.msn.co.in/sp03/Missworld2003/ Help her bring home the crown!
> 
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 




--------------------------------------------------------------------------------


Previous message: [vtkusers] Using vtk with GTK 
Next message: [vtkusers] Using vtk with GTK 
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] 

--------------------------------------------------------------------------------
More information about the vtkusers mailing list



More information about the vtkusers mailing list