TCL/TK and GRASS

Tom Moore tmoore at pnfi.forestry.ca
Fri Mar 4 21:24:01 EST 1994


In mailgate.grass.user you write:

>What moves are there to develop a tcl/tk interface?

I was also interested in developing a tcl/tk interface to
Grass, but didn't have the time or talent to do the work.
Fortunately,about the same time as I was scoping out the
problem I met up with Gilles Clement of LIS Inc (Montreal).
Gilles and his company had already developed an enhanced
Grass display driver, and were interested in using to
build decision support system types of applications.  
A couple of months ago I let a contract to Gilles to turn 
his display driver into a tcl/tk widget, and to write a bit
of sample tcl code to show how to use it.

Last week I got my first peek at the results, and it is
truly fantastic!  The display widget (called 'view') interfaces
seamlessly into the tcl/tk environment as does any other widget.  
I haven't had a chance to do much with it, but here is what I
know of it.  You can create one view, or as many views as you want,
in any place in the tk widget tree.  A view can take up a whole top
level window, or it can be part of a window along with buttons,
scroll bars, input fields, bar charts, lists, etc.  Views accept 
messages that tell them how to behave.  You tell the view what
images to display, how they should be overlayed, and what region should
should be shown.  Once image(s) are displayed in a view, you can
issue messages to zoom and pan.  Since this is tcl/tk, these 
messages can be bound to buttons or scroll bars.  Using tk, you can
build as fancy a display device as you like.  Place your own icons,
display a field showing scale factors, coordinators, legend classes,
make a special field in any font/color to show the title, etc.  The
possibilities are endless.  Depending on how you want your application to
behave, you can set up a tcl script to have multiple views zoom and pan 
independently or synchronously.

A few other aspects of the display widget:
The display widget avoids the named pipe issue that apparently
slows down the standard disply system.  All actions are
asynchrounous and interuptable.  So for example, if you click
on the zoom in button, and then click again in quick succession, 
the widget will stop drawing the first level of zoom, and immediately
begin drawing the second level.  I saw this in action, and it is a 
pretty neat feature.  The view widget also takes correct action to
update itself when it has been resized, so if you grab a resize corner
with the mouse and make the window bigger, the set of images in the
view will repaint as you expect (want).  This works in concert with
the tk pack/place geometry managers (geometry managers are one of the
more appealing features of tcl/tk.  Forgive me for not going into
details about them here, but don't think I could do it justice.)

So much for the display widget.

Gilles was also going to put together a couple of sample tcl
scripts to show how to interface tcl/tk with the standard
grass command lines.  Well, he thought about it, and decided
to put together something even better.  Gilles is developing a
translator that reads in the XGRASS definition files, and automatically
on-the-fly builds tcl/tk control panels.  When completed, this
will mean that all of the XGRASS menus will be available and
can be called up from within tcl/tk.  There are some really powerful
implications here.  Since tcl is an interpreted language, and
the tk widgets are objects that can be interogated and manipulated,
it is easy to extend/modify/customize these menus during run-time.

Sorry for raving on about this stuff like a fanatic.  I know
this sounds like a lot of hype, but I am really impressed with
what Gilles and crew were able to put togeher for us.  If you
want to know more about this Gilles will be presenting a couple
of papers at the Grass User conference next week.  I think he
is planning to have the software on hand to give a demonstration.
I will check to see if he is going to have a written paper.  If
so I'll get a copy and put it on our ftp server for everyone.

Right now this softare is in an alpha-test status.  As soon
as I have had a chance to test it out and it seems stable we
will be contributing it (to cecer.army.mil?).  This will definitely
have to wait until after Gilles gets back from the conference.

I'll post more details as I get them.

Tom
--
Tom Moore                                       tmoore at pnfi.forestry.ca
Petawawa National Forestry Institute            
Canadian Forest Service, Box 2000, Chalk River  +1 (613) 589-3048
ONT K0J 1J0  CANADA                             +1 (613) 589-2275 telefax



More information about the grass-user mailing list