Main Page | Data Structures | Directories | File List | Data Fields | Globals

tclSadie_app.c File Reference

Some tclSadie-specific application callbacks for the SADIE library. More...

#include <tcl.h>
#include <tk.h>
#include <sadie.h>
#include "tclsadie.h"

Go to the source code of this file.

Enumerations

enum  err_template_index {
  ERR_TKDIALOG, ERR_WINDOW, ERR_TITLE, ERR_TEXT,
  ERR_BITMAP, ERR_DEFAULT, ERR_STRING, max_err_index
}
 Define slots in the command template for an error-reporting Tk popup. More...

Functions

int tclsadie_plotter (PIXEL *line, uint32_t nbnd, uint32_t npix, const char *minxlbl, const char *maxxlbl, int option, PIXEL gmin, PIXEL gmax, void *data)
 Declare the plotting callback (defined elsewhere) so we can register it.
int dispose_private_data (void *rawdata)
 Clean up the private data used by the SADIE library callbacks.
void tclsadie_demolish_private_data (ClientData clientData)
 Register the SADIE application data cleanup with the Tcl interpreter.
int tclsadie_private_data_init (Tcl_Interp *interp)
 Set up the tclSadie-specific private data structure for the SADIE library.
void tclsadie_warning_messenger (char option, char *msg, void *data)
 The callback allowing the SADIE library to generate log messages.
void tclsadie_error_messenger (char option, char *msg, void *data)
 The callback allowing the SADIE library to generate error messages.
int tclsadie_app_init (void)
 Register all the necessary callbacks with the SADIE library.


Detailed Description

Some tclSadie-specific application callbacks for the SADIE library.

The SADIE library allows an application to provide its own callbacks for certain utility operations, such as displaying error messages and updating the session log. If we expect it to manipulate parts of a user interface defined in Tcl/Tk (as in the case of tclSadie), we need to provide callbacks that not only conform to the requirements for SADIE's callbacks, but also are properly Tcl/Tk aware. For convenience, we also maintain an application-wide data structure for details required by the callbacks, such as the Tk canvas that represents the session log and pre-parsed Tcl/Tk command templates for generating popup error messages.

Author:
University of Arizona Digital Image Analysis Lab
Date:
1999, 2004
Version:
Id
tclSadie_app.c,v 1.1 2005/03/22 20:40:53 mmunro Exp

Definition in file tclSadie_app.c.


Enumeration Type Documentation

enum err_template_index
 

Define slots in the command template for an error-reporting Tk popup.

Enumeration values:
ERR_TKDIALOG  modal dialog tk_dialog Tcl/Tk command.
ERR_WINDOW  the top-level window to use for dialog.
ERR_TITLE  text to appear in the window manager's title bar.
ERR_TEXT  message to appear in the top portion of the dialog box.
ERR_BITMAP  a bitmap to display in the top portion of the dialog.
ERR_DEFAULT  the index of the dialog's default button.
ERR_STRING  text displayed to the right of the button.
max_err_index  the command template length

Definition at line 53 of file tclSadie_app.c.


Function Documentation

int dispose_private_data void *  rawdata  ) 
 

Clean up the private data used by the SADIE library callbacks.

This conforms to the app_data_destructor_t prototype defined within the SADIE library for something that disposes of application-specific data.

Parameters:
[out] rawdata really the tclSadie application-specific data.

Definition at line 102 of file tclSadie_app.c.

References Tclsadie_app_data::err_popup, Tclsadie_app_data::log_refresh, Tclsadie_app_data::sadievar, and Tclsadie_app_data::sessionlog_canvas.

Referenced by tclsadie_private_data_init().

int tclsadie_app_init void   ) 
 

Register all the necessary callbacks with the SADIE library.

Note that this registers all the SADIE callbacks (including the plotter and progress meter callbacks), not just the ones defined in tclSadie_app.c. The SADIE library provides the various sad_register functions (see sadie.h for the interfaces).

Returns:
TCL_OK on success, TCL_ERROR on errors.

Definition at line 454 of file tclSadie_app.c.

References ProgMeter_Create(), ProgMeter_Destroy(), ProgMeter_Update(), tclsadie_error_messenger(), tclsadie_plotter(), and tclsadie_warning_messenger().

Referenced by Tcl_AppInit().

void tclsadie_demolish_private_data ClientData  clientData  ) 
 

Register the SADIE application data cleanup with the Tcl interpreter.

In addition to registering Tcl-aware callbacks with the SADIE library, we also register SADIE's generic application data cleanup operation with the Tcl interpreter. This wrapper conforms to the Tcl_ExitProc prototype for a Tcl/Tk exit handler (registered by Tcl_CreateExitHandler).

Parameters:
[in] clientData required by the prototype, but not used.

Definition at line 128 of file tclSadie_app.c.

Referenced by tclsadie_private_data_init().

void tclsadie_error_messenger char  option,
char *  msg,
void *  data
 

The callback allowing the SADIE library to generate error messages.

In this context an error is an alert that pops up a modal Tk dialog widget, in addition to resetting the message text element of the array holding Tcl settings. The message type code is the character supplied as the option parameter of the SADIE library function MESSAGE, with the following significance:

  • E error,
  • W warning,
  • I informational message, and
  • P picture (not used by tclSadie).

Parameters:
[in] option the message type code.
[in] msg the error text.
[in] data points to the tclSadie application private data.

Definition at line 411 of file tclSadie_app.c.

References Tclsadie_cmd_skel::cmd, Tclsadie_app_data::err_popup, ERR_TEXT, Tclsadie_cmd_skel::len, Tclsadie_app_data::main_interp, and Tclsadie_app_data::sadievar.

Referenced by tclsadie_app_init().

int tclsadie_plotter PIXEL *  line,
uint32_t  nbnd,
uint32_t  npix,
const char *  minxlbl,
const char *  maxxlbl,
int  option,
PIXEL  gmin,
PIXEL  gmax,
void *  data
 

Declare the plotting callback (defined elsewhere) so we can register it.

Because SADIE knows nothing of the Tcl/Tk specifics of tclSadie's session log (notably the Tk canvas it uses and the current vertical position within this), we first recover the relevant details from the private application-specific data. Then for each band in the image we plot a bar graph, arranging them horizontally within the session log (for large hyperspectral images this may be unwieldy). The first three bands of a multi-band image get plotted in red, green and blue respectively: everything else in black. The bar lengths are scaled according to the option code, one of the values defined in sadie.h :

  • UNIT values truncated at the unit interval (broken?),
  • NORM linear scaling, and
  • LOG logarithmic scaling.

Parameters:
[in] line a band-sequential array of pixel values to plot.
[in] nbnd the number of bands (number of bar graphs).
[in] npix the number of bars to draw for each graph.
[in] minxlbl the label for the x axis minimum.
[in] maxxlbl the label for the x axis maximum.
[in] option the scaling option code.
[in] gmin the low end of the range of pixel values.
[in] gmax the high end of the range of pixel values.
[in] data the tclSadie application private data structure.
Returns:
TCL_OK on success, TCL_ERROR on failure.

Definition at line 702 of file tclSadie_plot.c.

References BAR_COLOR, DEFAULT_SESSION_LOG_POS_INDEX, GetSadieUintFromObj2(), Tclsadie_app_data::log_refresh, Tclsadie_app_data::main_interp, Line_value_range::max, max_axl_index, max_bar_index, max_label_index, max_text_index, max_x_preset_index, max_y_preset_index, Line_value_range::min, RIGHT_MARGIN, Tclsadie_app_data::sadievar, Tclsadie_app_data::sessionlog_canvas, and TOP_MARGIN.

Referenced by tclsadie_app_init().

int tclsadie_private_data_init Tcl_Interp *  interp  ) 
 

Set up the tclSadie-specific private data structure for the SADIE library.

The tclSadie callbacks need access to information such as the particular Tk canvas used for the SADIE session log, the name of the top-level window to use for pop-up dialog boxes, and the pre-parsed Tcl/Tk command templates, but cannot obtain it from SADIE, so here we initialize the relevant global data structure for their benefit.

Parameters:
[in] interp the main Tcl interpreter.
Returns:
TCL_ERROR on errors, otherwise TCL_OK.

Definition at line 258 of file tclSadie_app.c.

References DEFAULT_SESSION_LOG_CANVAS, dispose_private_data(), Tclsadie_app_data::err_popup, Tclsadie_app_data::log_refresh, Tclsadie_app_data::main_interp, Tclsadie_app_data::sadievar, SADIEVAR_ARRAYNAME, Tclsadie_app_data::sessionlog_canvas, and tclsadie_demolish_private_data().

Referenced by Tcl_AppInit().

void tclsadie_warning_messenger char  option,
char *  msg,
void *  data
 

The callback allowing the SADIE library to generate log messages.

We write an informational or low-key warning message (as opposed to an alert) to the session log without popping up a modal dialog box. The message type code is the character supplied as the option parameter of the SADIE library function MESSAGE, with the following significance:

  • E error,
  • W warning,
  • I informational message, and
  • P picture (not used by tclSadie).

Parameters:
[in] option the message type code.
[in] msg the error text.
[in] data points to the tclSadie application private data.

Definition at line 379 of file tclSadie_app.c.

References Tclsadie_app_data::main_interp, and Tclsadie_app_data::sadievar.

Referenced by tclsadie_app_init().


Generated on Fri Jul 8 14:55:03 2005 for tclSadie by  doxygen 1.4.2