TCL railroad generator

2011-09-06

Was looking around for something to generate railroad diagrams. Found something on Stack Overflow but the description for how to get it to run was rather slim (albeit still pretty useful). Here's the more extended version... This tutorial is for Ubuntu (11.04).

Source url. This gives you the url to the source of bubble-generator.tcl. Download it, put it somewhere, make sure it has executable rights (chmod u+x bubble-generator.tcl). You will also need this data script to get started. It's the SQLite syntax, but it serves as a basis from which you can work.

Even though the name says tcl, this script is actually something called wish. I don't know the details, but it's a scripting language for creating window stuff or whatever, presumably running in some kind of tcl. Regardless, you need to install wish if you don't already have it. Chances are you don't. Wish is actually provided by version specific packages (it will tell you so when you actually try to get wish). At the time of writing, 8.5 was the latest version and it worked with that.

Code:
sudo apt-get install tk8.5

Install Image Magick if you don't already (not in Ubuntu by default)...

Code:
sudo apt-get install imagemagick

Now the next step would be to install xv, because you won't have it. Unfortunately, xv dates from 1994 and has not been maintained since (except for some third party patches).

To install xv you need a script because there's no package for it. Some blind trust is in order here though. Below's the build script (derived from this one). I haven't changed it so whatever... Save it in some file, run chmod u+x file on it and run it with sudo ./file.

Code:
#!/bin/bash

cd /tmp
wget ftp://ftp.cis.upenn.edu/pub/xv/xv-3.10a.tar.gz
wget http://prdownloads.sourceforge.net/png-mng/xv-3.10a-jumbo-patches-20050501.tar.gz
tar xvzf xv-3.10a.tar.gz
tar xvzf xv-3.10a-jumbo-patches-20050501.tar.gz
cd xv-3.10a
patch -p1 < ../xv-3.10a-jumbo-fix-patch-20050410.txt
patch -p1 < ../xv-3.10a-jumbo-enh-patch-20050501.txt
sudo apt-get install libc6-dev
sudo apt-get install libx11-dev
sudo apt-get install libxt-dev
sudo apt-get install libjpeg62-dev
sudo apt-get install libtiff4-dev
sudo apt-get install libpng12-dev
make
sudo cp xv /usr/bin

That'll do some stuff (probably install a few packages, just hit y) and when it's done, at least on my system, allows me to run and open xv. Yay.

Now we're ready-ish.

Run the script with wish bubble-generator.tcl. If you have the default data file in the same dir, this should open a popup window with some choices. Clicking one of those choices will open a railroad diagram for that option and a (at least for me) black window for xv. Closing xv does nothing, closing the diagram effectively closes the app.

Now, it seems like it's idle (and maybe it is at that point ;) but it has generated a gif with same name as the option you clicked. It just doesn't close the editor or the app (which confused me into thinking it b0rked). It will actually generate it as black text/lines on transparent background. Awesome work...

You can edit the data file easily to suit your own needs. Probably the rest of the tcl file as well to do some proper cleanup or whatever.

Good luck!