Logo Search packages:      
Sourcecode: ygraph version File versions  Download package

ygraph.h File Reference


Detailed Description

Main header file.

Defines useful global macros.

Author:
Denis Pollney
Date:
1 Oct 2001
Copyright (C) 2001-2002 Denis Pollney
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

Definition in file ygraph.h.

#include <glib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk_imlib.h>
#include <stdio.h>

Go to the source code of this file.

Classes

struct  _Axis
 Describes the x and y axes of a plot. More...
struct  _ControlPanel
 Describes the widgets contained in the control panel. More...
struct  _DataSet
 Describes a collection of frame as a single set of data. More...
struct  _Frame
 Describes an individual frame of xy-data. More...
struct  _Legend
 Describes the contents of the plot legend. More...
struct  _Plot
 Describes all of the data contained in a single plot window. More...
struct  _PlotLine
 Describes a frame (line) in terms of window dependent ij to be plotted. More...
struct  _Point_Double
struct  _Tick
 Describes an individual tick-mark on an axis. More...

Defines

#define ABOUT_TITLE   "about"
#define ALPHABET   "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYX0123456789"
#define APPEND_DATA   1
#define APPLY_BUTTON_LABEL   "Apply"
#define array_index_set_val(a, t, i, v)   (((t*) (a)->data) [(i)]) = v
#define AXIS_EPSILON   1e-6
#define AXIS_LINEAR_TYPE_LABEL   "linear"
#define AXIS_LOG_TYPE_LABEL   "log"
#define BIG_FONT   FONT_LARGE
#define CANCEL_BUTTON_LABEL   "Cancel"
#define CMD_LINE_RANGE_DELIMETER   ","
#define COMMENT_DELIMETERS   "\"#"
#define CONTROL_PANEL_NAME   "ygraph-control"
#define CONVERGENCE_DIALOG_TITLE   "convergence test"
#define CONVERGENCE_LABEL   "convergence"
#define CONVERGENCE_MESSAGE   "Convergence test"
#define COPYRIGHT_MSG   "(c) 2002-2003 Denis Pollney <denis.pollney@aei.mpg.de>"
#define CROSS_SIZE   2
#define DEFAULT_ANIMATE_DELAY   100
#define DEFAULT_AXIS_FONT   FONT_NORMALSIZE
#define DEFAULT_DATA_SCALE_FACTOR   1.0
#define DEFAULT_FONT   FONT_NORMALSIZE
#define DEFAULT_I_SIZE   400
#define DEFAULT_J_SIZE   400
#define DEFAULT_LEGEND_FONT   FONT_NORMALSIZE
#define DEFAULT_LEGEND_WIDTH   80
#define DEFAULT_LINE_WIDTH   1
#define DEFAULT_PLOT_FONT   FONT_NORMALSIZE
#define DEFAULT_SKIP_STEP   1
#define DELAY_LABEL   "Delay"
#define DELAY_STR_SIZE   6
#define DOT_SIZE   4
#define END_BUTTON_LABEL   "End>>"
#define EQUAL_SIGN   '='
#define EXPORT_DIR_LABEL   "Directory:"
#define EXPORT_DIR_SELECT_MESSAGE   "Export multiple frames to directory"
#define EXPORT_FILE_LABEL   "File:"
#define EXPORT_FILE_SELECT_MESSAGE   "Export current frame to file"
#define EXPORT_TO_DIR_TITLE   "export directory"
#define EXPORT_TO_FILE_TITLE   "export file"
#define FAIL   -1
#define FILE_1_LABEL   "File 1 (1xres):"
#define FILE_2_LABEL   "File 2 (2xres):"
#define FILE_4_LABEL   "File 3 (4xres):"
#define FILE_A_LABEL   "File A:"
#define FILE_B_LABEL   "File B:"
#define FILE_ENTRY_LENGTH   120
#define FILE_SELECTION_TITLE   "read file"
#define FILE_STR_SIZE   255
#define FILENAME_SIZE   255
#define FIRST_FRAME   0
#define FONT_FONT   "-adobe-helvetica-bold-r-normal-*-*-%d-*-*-*-*-*-*"
#define FONT_HUGE   get_font(FONT_FONT, 200)
#define FONT_Huge   get_font(FONT_FONT, 170)
#define FONT_LARGE   get_font(FONT_FONT, 140)
#define FONT_Large   get_font(FONT_FONT, 120)
#define FONT_NORMALSIZE   get_font(FONT_FONT, 100)
#define GRID_INTENSITY   40000
#define HELP_MSG   "Type 'ygraph --help' for help"
#define INIT_DATA   0
#define INTERNAL_STDIN_STR   "ygraph#internal#stdin#string"
#define INTERP_ORDER   1
#define KEYBINDING_TITLE   "ygraph keybindings"
#define LABEL_INDICATOR_STRING   "label"
#define LEGEND_HEIGHT_PADDING   2
#define LEGEND_LINE_DIVISIONS   20
#define LEGEND_LINE_THICKNESS   4
#define LEGEND_OFF   0
#define LEGEND_OVER   3
#define LEGEND_RIGHT   1
#define LEGEND_TOP   2
#define LEGEND_WIDTH_PADDING   5
#define LONG_TICK_LENGTH   8
#define MAX_AXIS_LABEL_LENGTH   40
#define MAX_INTERP_ORDER   1
#define MAX_LINE_LENGTH   255
#define MAX_PIXELS   10000
#define MESSAGE_TITLE   "message ..."
#define MESSAGE_X_PADDING   20
#define MESSAGE_Y_PADDING   20
#define NAN_STRING   "nan nanq inf"
#define NCOLORS   7
#define NEW_BUTTON_LABEL   "New plot"
#define NEW_DATA_SET   -1
#define NEW_WINDOW_LABEL   "plot in new window"
#define NO_ZOOM   -1
#define NULLC   '\0'
#define OKAY_BUTTON_LABEL   "Okay"
#define OPTIMUM_TICK_MARK_NUMBER   6
#define PAUSE_BUTTON_LABEL   "Pause"
#define PLAY_BUTTON_LABEL   "Play"
#define QUIT_BUTTON_LABEL   "Quit"
#define RANGE_DIALOG_TITLE   "xy range"
#define RANGE_STR_MAX_SIZE   80
#define RANGE_VAL_SIZE   12
#define READ_COMMENT   0
#define READ_DATA   1
#define RELOAD_BUTTON_LABEL   "Reload"
#define RESCALE_DATA   2
#define SAVE_FILE_BASE_NAME   "frame"
#define SCALE_ENTRY_SIZE   8
#define SCALE_PANEL_NAME   "ygraph function rescale"
#define SCALE_TITLE_STRING   "re-scale factor"
#define SELECT_LABEL   "Select ..."
#define SHORT_TICK_LENGTH   5
#define SHOW_ALL_BUTTON_LABEL   "Show All"
#define START_BUTTON_LABEL   "<<Start"
#define STEP_BACK_BUTTON_LABEL   "<Step"
#define STEP_FWD_BUTTON_LABEL   "Step>"
#define SUBTRACT_DIALOG_TITLE   "subtract: A - B"
#define SUBTRACT_MESSAGE   "Subtract files: A - B"
#define SUCCESS   0
#define TEXT_X_HEIGHT_PADDING   2
#define TEXT_X_WIDTH_PADDING   2
#define TEXT_Y_HEIGHT_PADDING   2
#define TEXT_Y_WIDTH_PADDING   2
#define TIME_EPSILON   1e-10
#define TIME_INDICATOR_STRING   "time"
#define TIME_LABEL   "Time"
#define TIME_STR_MAX_SIZE   20
#define TIME_STR_SIZE   10
#define UNINITIALISED_TIME   -G_MAXDOUBLE
#define UNUSED(x)   x=x
#define X_AXIS_TYPE_LABEL   "x-axis"
#define X_PADDING   20
#define XMAX_LABEL   "x max"
#define XMIN_LABEL   "x min"
#define Y_AXIS_TYPE_LABEL   "y-axis"
#define Y_PADDING   20
#define YDEB(x)
#define YG_DATAFILE   0
#define YG_DERIVATIVE   3
#define YG_FRAME_INT   4
#define YG_INT   6
#define YG_SUBTRACT   1
#define YG_TIME_INT   5
#define YMAX_LABEL   "y max"
#define YMIN_LABEL   "y min"

Typedefs

typedef struct _Axis Axis
typedef struct _ControlPanel ControlPanel
typedef struct _DataSet DataSet
typedef struct _Frame Frame
typedef struct _Legend Legend
typedef struct _Plot Plot
typedef struct _PlotLine PlotLine
typedef struct _Point_Double Point_Double
typedef struct _Tick Tick

Enumerations

enum  AXIS_ORIENTATION { X_AXIS, Y_AXIS }
enum  AXIS_TYPE { AXIS_LINEAR, AXIS_LOG }
enum  DISPLAY_MODE { SHOW_ALL_MODE, ANIMATE_MODE, PAUSE_MODE }

Functions

gboolean about_expose (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
 Expose the "About" dialog box.
void about_window_create (void)
 Create the about box window.
void all_windows_draw (void)
 Redraw the contents of all plot windows.
gint axis_calc_height (Axis *axis)
 Calculate the amount of space needed by an axis according to the text in its labels.
gint axis_calc_tick_sep (Plot *plot, Axis *axis, guint i)
 Determine a measure of inter-tick spacing.
GArray * axis_calc_ticks (gdouble min, gdouble max, Axis *axis)
 Determine the location of tickmarks along an axis, given its range.
gint axis_calc_width (Axis *axis)
 Calculate the amount of space needed by an axis according to the text in its labels.
Axisaxis_create (Plot *plot, gint orientation, AXIS_TYPE type)
 Create an axis, including labels and locations of tick-marks.
void axis_draw (Plot *plot)
 Draw the plot axes, including tick-marks and labels.
void axis_draw_lines (Plot *plot)
 Render lines for the x and y axes.
void axis_draw_log_indicator (Plot *plot, Axis *axis)
 Write "log" at the end of a log axis.
void axis_draw_log_indicator_xy (Plot *plot)
 Write "log" at the end of log each axis.
void axis_draw_x_text (Plot *plot)
 Draw the labels on the x-axis.
void axis_draw_y_text (Plot *plot)
 Draw the y-axis labels.
void axis_free (Axis *axis)
 Free the space allocated to an Axis structure.
gint axis_get_text_height (GdkFont *font, gchar *label, gboolean axis_type)
 Return the height of an axis label entry, including padding.
gint axis_get_text_width (GdkFont *font, gchar *label, gboolean axis_type)
 Return the width of an axis label entry, including padding.
gboolean axis_set_from_dialog (GtkObject *button, Plot *plot)
 Sets the plot range based on values returned from the plot dialog.
GArray * axis_tick_append (GArray *ticks, gdouble val, Axis *axis, gboolean exp_notation)
 Add a Tick to an array.
void axis_toggle_log_state (Plot *plot)
 Switch between axis states log<->linear.
gdouble axis_transformation (const gdouble value, const Axis *axis)
gboolean axis_type_reset (Plot *plot)
 Sets the plot range based on values returned from the plot dialog.
void axis_type_set_toggle (Axis *axis, GtkToggleButton *toggle_linear, GtkToggleButton *toggle_log)
 Set the state of an axis-type toggle button (linear or log axis).
int check_for_nan (gchar *str)
 Checks for NaN values in a string.
GdkColor * color_set_rgb (GdkColormap *colormap, gulong red, gulong green, gulong blue)
 Set a GdkColor given RGB values.
void control_panel_raise (void)
 Create a new control panel, or raise it if it already exists.
gint current_frame_calc (DataSet *data_set)
 Determine the frame of a data set which corresponds to a given time.
void current_frame_increment (gint incr)
 Add a value to the current_frame value.
void current_frame_set (gint val)
 Set the current frame, ie. the global_current_frame.
void current_time_display_value (void)
 Display the value of the current_frame in the control panel.
gboolean current_time_set (GtkEditable *time_entry, gpointer data)
 Set the frame time.
gboolean data_reload_all (GtkWidget *reload_button, GdkEvent *event)
 Reload all of the currently loaded data.
void data_reload_plot (Plot *plot, gint action, GtkItem *reload_button)
 Reload all of the data in a given plot.
DataSetdata_set_init (gchar *fname)
void dataset_append_frame (DataSet *data_set, Frame *frame)
 Append a frame to a dataset.
void dataset_calc_rescale (DataSet *data_set, gdouble scale)
 Carry out the pointwise rescaling of a pair of DataSets.
DataSetdataset_derivative (gint idx)
 Take the derivative of each frame in a DataSet.
gint dataset_read_frame_integrate_file (gchar *file, gint option_read_skip_step, gint option_t_int)
gint dataset_read_from_file (gchar *fname, gint skip)
 Open a file and read in a set of data.
gint dataset_read_integrate_file (gchar *file, gint option_read_skip_step)
gint dataset_read_subtract_files (gchar *file0, gchar *file1)
 Read a pair of files and subtract individual data values.
void dataset_recalc (DataSet *data_set)
 Call a calculation operation on a specified data set.
gboolean delay_set (GtkEditable *delay_entry, gpointer data)
 Set the animation delay based on updated contents of the "delay" input field.
gchar * double_to_str (gdouble val, gboolean exp_notation)
 Convert a double to a string.
gboolean end_button_click (GtkWidget *end_button, GdkEventExpose *event, gpointer *data)
 Go to the last frame of an animation due to a "end" button click, and toggle the display mode to PAUSE_MODE.
gboolean export_dir_set (GtkEditable *file_entry, Plot *plot)
 Export a plot to a specified directory as a series of frames.
gboolean export_file_set (GtkEditable *file_entry, Plot *plot)
 Export a plot to a specified file.
void export_to_dir (Plot *plot, gchar *dirname)
 Export a sequence of frames to a directory.
void export_to_file (Plot *plot, gchar *filename)
 Export the current frame to an image file.
void file_select (Plot *plot, gint action, GtkItem *file_select_button)
 Creates a file selection dialog box for reading data into the existing window.
void file_select_A (GtkWidget *select_button, GdkEvent *event, Plot *plot)
 Creates a file selector for the first subtract file.
void file_select_B (GtkWidget *select_button, GdkEvent *event, Plot *plot)
 Creates a file selector for the first subtract file.
gboolean file_select_export (GtkObject *ok_button, GtkFileSelection *fs)
 Read the contents of an export file selection dialog.
void file_select_new_window (Plot *plot, gint action, GtkItem *file_select_button)
 Creates a file selection dialog box for reading data into the new window.
gboolean file_select_read (GtkObject *ok_button, GtkFileSelection *fs)
 Act on the result of a file selection.
gboolean file_subtract (GtkObject *ok_button, Plot *plot)
 Prompts the user for a pair of files to subtract, then performs and plots the subtraction.
void frame_append_data_point (Frame *frame, gdouble x_val, gdouble y_val)
 Append a data point to a frame, resetting the max and mins.
gint frame_draw_next (GtkObject *play_button)
 Move the animation to the next frame.
void frame_free (Frame *frame)
 De-allocate a frame and its contents.
Frameframe_init (void)
 Set default values for a single frame of a data set.
gchar * get_font (const char *font, gint font_size)
 Return a font spec string corresponding to a chosen font and size.
gint global_data_set_list_append (DataSet *data_set)
gboolean help_expose (GtkWidget *text_area, GdkEventExpose *event, gpointer data)
 Expose the "Help" text box.
void help_window_create (void)
 Create the help box window.
gdouble i_to_x (Plot *plot, gint i)
 Convert a plot window i-coordinate to a real x-coordinate value.
void image_dir_export_dialog (Plot *plot, gint action, GtkItem *export_button)
 Create a dialog box for exporting a series of images to a directory.
void image_export_dialog (Plot *plot, gint action, GtkItem *export_button)
 Create a dialog box for exporting an image to a file.
void image_export_file_select (GtkWidget *select_button, GdkEvent *event, Plot *plot)
 Create a file selection dialog for exporting plots.
gdouble interp (GArray *xy_data, gdouble x_val, gint order)
 Performs an 1D interpolation of the requested order, up to a hard-coded limit of MAX_INTERP_ORDER.
gdouble j_to_y (Plot *plot, gint j)
 Convert a plot window j-coordinate to a real y-coordinate value.
void keybinding_window_create (void)
 Create the help box window.
void legend_create (Plot *plot)
 Create a new legend structure given a plot window and its corresponding data content.
void legend_draw (Plot *plot)
 Put the legend data onto the window.
void legend_free (Legend *legend)
 Free up the space that has been allocated to a legend.
GdkGC * line_set_gc (Plot *plot, PlotLine *plot_data, gint frame_nbr, gint nframes)
 Set the line colour for SHOW_ALL display mode.
gdouble linear2log (const gdouble value)
void message_dialog (gchar *msg)
 Create a pop-up message dialog.
gboolean pause_play_button_click (GtkWidget *play_button, GdkEventExpose *event, gpointer *data)
 Switch the display mode based on "play" button clicks.
gboolean plot_area_button_press_event (GtkWidget *plot_area, GdkEventButton *event, Plot *plot)
 Handle a button press in the plot area.
gboolean plot_area_button_release_event (GtkWidget *plot_area, GdkEventButton *event, Plot *plot)
 Handle a button release in the plot area.
void plot_area_draw (Plot *plot)
 Draw the contents of the plot area, between the axes.
gboolean plot_area_motion_notify_event (GtkWidget *plot_area, GdkEventMotion *event, Plot *plot)
 Determine the location of the pointer.
void plot_area_write_location (Plot *plot, gint i, gint j)
 Create a popup containing the pointer location.
void plot_area_zoom_finish (Plot *plot, gint x, gint y)
 When the left-button is released, perform the zoom by resetting the ranges on the axes and redrawing the window.
void plot_area_zoom_rectangle_draw (Plot *plot, gint x, gint y)
 On motion events, draw a rectangle between the zoom starting point and the current cursor location in order to delimit the zoom region.
void plot_area_zoom_start (Plot *plot, gint x, gint y)
 Record the point at which the left-button was clicked on the plot window so that we can start a zoom process.
void plot_axes_create (Plot *plot)
 Create both x and y axes for a plot window.
void plot_data_append (Plot *plot, gint data_set_idx)
 Append a dataset to the data already contained in a plot (eg. after loading a new data set from a file).
Plotplot_data_init (GArray *data)
 Initialise a new plot window given a collection of data (eg. at startup or when a new plot window is created).
void plot_free (Plot *plot)
 Free the space that has been allocated to a plot structure.
DataSetplot_get_data_index (Plot *plot, gint idx)
 Get a DataSet by index from the global_data_set_list.
void plot_range_set (Plot *plot, gint mode)
 Calculate the maximum and minimum values of a collection of datasets to be displayed in a single window.
void plot_window_build (Plot *plot)
void plot_window_close (Plot *plot, gint action, GtkItem *file_select_button)
gboolean plot_window_configure (GtkWidget *plot_area, GdkEventConfigure *event, Plot *plot)
 Configure the plot window.
void plot_window_derivative (Plot *plot, gint action, GtkItem *button)
 Create a new plot containing the derivative of the current plot.
gboolean plot_window_destroy (GtkWidget *plot_area, GdkEventConfigure *event, Plot *plot)
 Destroy the plot window.
void plot_window_display_all (Plot *plot)
 Redraw the entire plot window, including axes.
void plot_window_display_data (Plot *plot)
 Draw the plot.
void plot_window_draw_grid_toggle (Plot *plot, gint action, GtkItem *draw_grid_toggle)
 Turn on/off the drawing of grid lines on the plot.
void plot_window_draw_points_toggle (Plot *plot, gint action, GtkItem *draw_points_toggle)
 Turn on/off the drawing of dots at each data point.
void plot_window_draw_range_toggle (Plot *plot, gint action, GtkItem *draw_range_toggle)
 Turn on/off the drawing of range values at corners of the plot.
void plot_window_draw_time (Plot *plot)
 Draw a time indicator in the upper left-hand corner of the plot.
void plot_window_empty_new (void)
 Open a blank new plot window.
gboolean plot_window_expose (GtkWidget *plot_area, GdkEventExpose *event, Plot *plot)
 Expose the plot window.
void plot_window_expunge (Plot *plot)
 Erase the entire window, including axes.
gboolean plot_window_key_press_event (GtkWidget *plot_area, GdkEventKey *event, Plot *plot)
 Close the plot window.
void plot_window_reconfigure (Plot *plot)
 Recalculate the ij data when the window size changes or the plot is zoomed.
void plot_window_show (void)
 Go through the list of plot windows an show each.
void plot_window_unzoom (Plot *plot)
 Handle an unzoom event.
void plotline_set_colors (Plot *plot, PlotLine *plotline, gint i)
 Set the start and end colours of a data set.
void range_dialog_create (Plot *plot, gint action, GtkItem *range_set_button)
 Create a dialog which prompts the user to enter (x,y) range values.
void range_entry_value_set (Plot *plot)
 Put values in the range dialog entry boxes.
gboolean range_reset (Plot *plot)
 Sets the plot range based on values returned from the plot dialog.
void scale_panel_create (Plot *plot, gint action, GtkItem *range_set_button)
 Draw the scale panel window.
gdouble set_fac (const gdouble x, const gdouble y, const gint window_size)
 Set the factor by which you need to multiply in order to convert xy to ij coordinates.
gboolean show_all_button_click (GtkWidget *showall_button, GdkEventExpose *event, gpointer *data)
 Toggle between SHOW_ALL and single frame display modes.
gboolean start_button_click (GtkWidget *start_button, GdkEventExpose *event, gpointer *data)
 Go to the first frame of an animation due to a "start" button click, and toggle the display mode to PAUSE_MODE.
gboolean step_back_button_click (GtkWidget *back_button, GdkEventExpose *event, gpointer *data)
 Move an animation one frame backward due to a "back" button click. Toggle to PAUSE_MODE and increment the frame number.
gboolean step_fwd_button_click (GtkWidget *fwd_button, GdkEventExpose *event, gpointer *data)
 Move an animation one frame forward due to a "fwd" button click. Toggle to PAUSE_MODE and increment the frame number.
gdouble str_to_double (gchar *s)
 Convert a string to a double, noting that fortran output often will use 'd' or 'D' rather than 'e' to denote the exponent.
void string_to_columns (gchar *range_string)
 Convert a string to two columns.
gdouble * string_to_range (gchar *range_string)
 Convert a string to a range.
void subtract_select_dialog_create (Plot *plot, gint action, GtkItem *button)
 Creates a dialog box for loading a pair of files to be subtracted.
void time_list_build (void)
 Build a new global time list from scratch.
void time_list_merge (DataSet *data_set)
 Merge time values with the global_time_list.
gint x_to_i (Plot *plot, gdouble x)
 Convert x-axis coordinate values to i values.
gint y_to_j (Plot *plot, gdouble y)
 Convert y-axis coordinate values to j values.
void zoom_x_range_set (Plot *plot, gint i1, gint i2)
 Set the new x-axis ranges after a zoom.
void zoom_y_range_set (Plot *plot, gint i1, gint i2)
 Set the new y-axis ranges after a zoom.

Variables

gchar * actual_font
gdouble font_size_factor
GdkPixmap * global_about_pixmap
gulong global_base_color [NCOLORS][3]
gchar * global_column_format_string
ControlPanelglobal_control_panel
gint global_current_frame
GArray * global_data_set_list
DISPLAY_MODE global_display_mode
gulong global_grid_intensity
gint global_last_frame
gint global_plot_nbr
GArray * global_plot_window
GtkWidget * global_scale_panel
GArray * global_time_list
gchar * global_working_directory
gint global_x_column
gdouble * global_x_range
gint global_y_column
gdouble * global_y_range
gchar ** nan_string
gint option_animate_delay
gboolean option_draw_grid
gboolean option_draw_points
gboolean option_draw_range
gchar * option_legend_position
gint option_line_width
gint option_read_skip_step
gboolean option_separate_start_windows
gboolean option_start_without_control_panel
gboolean option_version_msg


Generated by  Doxygen 1.6.0   Back to index