[vtkusers] vtkRenderWindow inside a tk frame

Kevin Wright krw at viz-solutions.com
Mon Dec 3 12:44:29 EST 2001


> -----Original Message-----
> From: vtkusers-admin at public.kitware.com
> [mailto:vtkusers-admin at public.kitware.com]On Behalf Of Pratheek Arora
> Sent: Sunday, December 02, 2001 8:05 AM
> To: Kevin Wright
> Cc: vtkusers at public.kitware.com
> Subject: RE: [vtkusers] vtkRenderWindow inside a tk frame
>
>
> Hi Kavin
>    The Same Problem I also faced, I am doing all my processing in C++ and
> for display purpose I am using TCL TK , I want to transfer my vtkImageData
> (which is in c++)to vtkTkImageViewerWidget , I have made one TCL Command
> for that, But still I am not getting the vtkImageData in tcltk, Can you
> please explain in more detail , How I can transfer my vtkImageData from
> c++ to TcL Tk


If you want to take an object created in Tcl/Tk and manipulate it in C++,
create a Tcl command which takes as an argument the object name.  I.e. if
you wanted to pass a vtkRenderWindow down to C++...

vtkTkRenderWindow rw
PassRWToC rw

You must create the "PassRWToC" command (if you're unsure of how to make new
Tcl commands in C/C++, check out a good Tcl/Tk book.  I recommend Practical
Programming in Tcl and Tk by Brent Welch).  That command takes a string
argument which is the "object name" (in this case the name is rw).  Then in
the PassRWToC command, get the actual pointer from that string as follows:

int PassRWToCCmd(ClientData, Tcl_Interp *interp, int argc, char **argv) {
  char *objectName = argv[1];
  int error = 0;
  void *ptr =
vtkTclGetPointerFromObject(objectName,"vtkRenderWindow",interp,error);
  vtkRenderWindow *rw = (vtkRenderWindow *) ptr;
  ...
}

Then you're all ready to go.  The vtkTclGetPointerFromObject function is
defined in the vtkTcl library.





More information about the vtkusers mailing list