[vtkusers] How Vtk's tcl/tk examples are implemented?
Roman Putanowicz
putanowr at twins.pk.edu.pl
Wed Jun 25 01:59:03 EDT 2003
> Seeing more vtk examples implemented in tcl/tk than in
> C++, I wanted to take a brief look at tcl/tk. For now
> I have read only a little about the script language. I
> noticed the syntax of those tcl examples coming with
> vtk is somewhat not quite the same as what I have read
> about (for example, tcl/tk introdued in the first few
> chapters of "Practical Programming in tcl and tk" by
> Welsh).
Hi,
The syntax is exactly the same as in the book you have
mentioned. The only confusing thing can be that those
examples use wrappers around VTK library.
Maybe the best way is to explain it on an example:
vtkUnstructuredGridReader reader ## 1
reader SetFileName "mesh.vtk" ## 2
In line 1 you call vtkUnstructuredGridReader Tcl procedure
which does the following:
1) creates an instance of the class vtkUnstructuredGridReader
2) creates a new Tcl command "reader". The new command is
associated with the created object (to put it simple :).
In line 2 you call Tcl command "reader". The arguments to this command
are: name of the method, arguments required by the method.
Then the command calls the method (in this line SetFileName) for
the object associated with it and passes to the method all remaining
arguments.
> I wonder in what tcl/tk or what extentions(?)
> are those examples implemented. Before my getting
> further into tcl/tk learning, can any experienced
> tcl/tk user(s) in this mailing list help give some
> introductory knowledge about that?
You can take a look at chapter 44 of the Welsh book you mentioned.
This chapter explains a mechanism of adding new commands to Tcl.
Maybe this can help you to see why VTK examples in Tcl look as they look.
Regards
Romek
More information about the vtkusers
mailing list