[vtkusers] Using vtk with GTK
Vincent Nicolas
vincent.nicolas at tele.ucl.ac.be
Thu Dec 4 14:21:31 EST 2003
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
>
More information about the vtkusers
mailing list