SpecTk
a displayer for SpecTcl
by D. Bazin
current release: version 1.3 (March 2010)
This program displays and manupulates spectra accumulated in SpecTcl. It is written mostly in Tcl/Tk using the BLT and Incr Tcl libraries. SpecTk uses SpecTcl as a server for the spectrum data, therefore SpecTcl has to be configured as a server. The C++ and Tcl code necessary are provided on this page. I have presented this program at the 2005 Tcl conference which took place in October 2005 in Portland, Oregon. The paper describes in detail most of the features, and the talk illustrates the usefulness of such a tool (for wide audience).
SpecTk offers the following features:
- Remotely view spectra from any SpecTcl program on the same local network
- Spectra are displayed according to their defined units
- Many pages containing graphs of spectra can be defined and selected easily using tabs
- A toolbar allows the user to quickly switch between manipulation tools
- Functionalities are contained in a retractable drawer
- Spectrum selection is chosen from a configurable tree (alphabetically ordered)
- Gates and/or regions of interest (ROI) can be defined and manipulated
- Calculation results can be embedded in graph displays
- Data can be fitted to various functions
- Configuration files can be written and loaded
- Encapsulated PostScript files of pages or graphs can be either saved or sent to a printer
- Many other features can be and will be implemented in the future…

Here are the instructions to configure SpecTcl as a server:
- Download the tar file Server.tar
- Untar the file in the folder of your choice (could be your SpecTcl folder)
- This will create a folder called Server containing two files: server31.h and Server.tcl
- Add the following lines to your main SpecTcl.cpp file (called MySpecTclApp.cpp in the skeleton directory):
- in the include directives: #include "YourServerFolder/server31.h"
- in the AddCommands method: AddServerCommands(this, rInterp);
- Recompile SpecTcl
- Add the following line in your SpecTclRC.tcl startup file: source YourServerPath/Server.tcl
- Start SpecTcl. You should see a small frame on the bottom of your toplevel window indicating that the SpecTcl server is up and listening on a given port number. This port number should be used when connecting SpecTk to SpecTcl.
Here are the instructions to install SpecTk:
- Download the file MacOSX.tar (Intel processor only) for the Mac OS X version, Windows.zip for the Windows version, or Linux.tar for the Linux version. This Linux version works with a Debian installation but not with the new Ubuntu installation now being phased in at the NSCL. I have recompiled SpecTk for this new system and the two architectures available: the i686 architecture (32 bits element machines), and the x86_64 architecture (64 bits fishtank machines).
- Untar in the folder of your choice
- Define the environment variable SpecTkHome to point to the installation folder
- From the created folder, simply type: ./SpecTk , or from any other folder type the path to the SpecTk executable
- This should open the SpecTk window. Now connect to the SpecTcl of your choice and enjoy!
Prerequisites:
In addition to having Tcl/Tk installed on your system, you also need the BLT24 and Itcl (also called Incr Tcl) packages installed. Here are some guidelines to get this done on the various supported platforms:
- Mac OS X: the easiest way to install Tcl/Tk and other ported Unix programs is to use Fink which can be found at http://fink.sourceforge.net. Once Fink is installed on your system, there is a GUI which makes installation even easier at http://finkcommander.sourceforge.net. Both Tcl/Tk version 8.4 and the BLT package can be directly installed from Fink. For the Itcl library, the project repositories can be found at http://sourceforge.net/projects/incrtcl/. I have used version 3.2.1 to develop SpecTk. A tarball containing the compiled libraries is located here. It installs in the Fink domain (/sw).
- Linux: Binaries for Linux can be found in the ActiveTcl distribution at http://www.activestate.com/Products/ActiveTcl/. This installation contains many packages including Itcl, but not BLT. The BLT repositories can be found at http://sourceforge.net/projects/blt/. You will need to run the configuration script and compile the libraries to install the package.
- Windows: Binaries for Windows can be found in the ActiveTcl distribution at http://www.activestate.com/Products/ActiveTcl/. This installation contains many packages including Itcl, but not BLT. The BLT repositories can be found at http://sourceforge.net/projects/blt/. Fortunately, they contain binaries for Windows (select "View ALL Project Files") to access them. Select the binary for tcl84. Alternatively, you can directly download the installation files for Active Tcl (here) and the BLT library (here).
The present release of SpecTk is version 1.3. Please report bugs, shortcomings and suggestions at bazin@nscl.msu.edu.
Bug fixes for version 1.3:
- 12/13/09: Added two buttons to directly print a single graph or an entire page without having to go through the dialogs. The printer specified from the dialog box will be used.
- 12/13/09: Changed the binding behavior of individual graphs. Each graph can now have a separate binding. The tool in the left toolbar switches automatically depending on the current binding of the selected graph. Any graph can be selected by clicking outside the active spectrum area.
- 12/13/09: Fixed bug which would occur when a ROI would be defined starting with a numeral.
- 12/13/09: Server.tcl - The Load procedure has been redirected to prevent SpecTk from getting confused whenever a new definition file is being loaded. The communication with SpecTk is interrupted while the definition file is being loaded, and reestablished after the loading is done.
Bug fixes for version 1.2:
- 03/23/09: SpecTkAppInit.c - fixed memset bug which caused the 2D displays to mysteriously dissapear when the frames were resized to a smaller size. This bug was more apparent on Linux systems than OS X for some reason.
- 03/23/09: Client.tcl - fixed server(buffer) not set bug which would cause the connecting script to fail.
- 03/25/09: Display2D.tcl - changed call to SetDisplay.
- 03/25/09: Palette.tcl - added hiding of scale display ticks when the width of the frame containing the spectrum becomes too small. Also added support for log color scale of z dimension.
- 03/25/09: Page.tcl - removed call to unset Display($id) in Page::Modify, which is not needed and would cause the script to halt.
Bug fixes for version beta 1.1:
- 12/23/05: SpecTkAppInit.c - added check of environment variable SpecTkHome to determine the location of startup Tcl file (Main.tcl). Provided that this environment variable is set correctly, SpecTk can now be started from any folder.
- 12/23/05: server.h - mode 0 in Get2DData reactivated after fixing bug in which always the same bins were transmitted to the client. This fix requires a SpecTcl recompile (make clean then make).
- 12/23/05: Wave2D.tcl - mode 0 (uncompressed data) was leading to an infinite loop in some cases. Speed of non-zero sorting by Tcl needs to be assessed.
- 12/24/05: FitDialog.tcl - fixed bug which prevented deletion of fits.
- 12/24/05: Client.tcl - spectrum tree gate info now updated whenever an apply command is generated by the server.
- 12/26/05: Client.tcl - gate list now updated whenever an apply command is generated by the server, so that newly defined composite gates appear in the spectrum title.
Bug fixes for version beta 1.0:
- 2/25/05: server.h - mode 0 in Get2DData wasn't properly feeding the spectrum data. After discovering that sorting the non-zero bins in Tcl is too slow, this transfer mode has been removed and only mode 1 is implemented (compressed or non-zero data transfer). This bug fix needs SpecTcl recompile. No change for SpecTk.
- 2/25/05: ExpandDialog.tcl - fixed storage of expansion in display object so that it is not reset to full scale when updates are issued.
- 2/25/05: Display1D.tcl - added safeguard for spectrum expansion to reject it when limits are equal or xmax < xmin.