1 /* 2 * $Header: /cvs/oleo/src/sciplot.h,v 1.6 2000/11/22 19:33:01 danny Exp $ 3 * 4 * This file is part of GNU plotutils. 5 * 6 * Copyright � 2000 Free Software Foundation, Inc. 7 * Written by Danny Backx <danny@gnu.org>, 2000. 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2, or (at your option) 12 * any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 22 * 02111-1307, USA. 23 */ 24 #ifndef __SCIPLOT_H__ 25 #define __SCIPLOT_H__ 26 27 #include <stdio.h> 28 #include <plot.h> 29 30 /* 31 * Enumerations and macros for parameter values 32 */ 33 typedef enum SpPlotType { 34 SP_PLOT_NONE = 0, 35 SP_PLOT_XY, 36 SP_PLOT_BAR, 37 SP_PLOT_PIE, 38 39 SP_PLOT_LAST /* Don't add any after this */ 40 } SpPlotType; 41 42 /* style of graph frame; the 1st four of these are increasingly fancy, but 43 the last (AXES_AT_ORIGIN) is an altogether different style */ 44 typedef enum 45 { 46 NO_AXES = 0, AXES = 1, AXES_AND_BOX = 2, AXES_AND_BOX_AND_GRID = 3, AXES_AT_ORIGIN = 4 47 } grid_type; 48 49 /* bit fields in portmanteau variables */ 50 enum { X_AXIS = 0x1, Y_AXIS = 0x2 }; 51 52 #define NO_OF_LINEMODES 5 /* see linemode.c */ 53 #define MAX_COLOR_NAME_LEN 32 /* long enough for all of libplot's colors */ 54 55 /* types of line */ 56 extern const char *linemodes[NO_OF_LINEMODES]; 57 extern const char *colorstyle[NO_OF_LINEMODES]; 58 59 /* 60 * Structures used in the API 61 */ 62 typedef struct MultigrapherStruct Multigrapher; 63 64 /* Definition of the Point structure. The point-reader (in reader.c) 65 returns a list of these from a specified input stream, and the 66 multigrapher (in plotter.c) interprets them as polyline vertices, and 67 plots the resulting polyline(s). Each polyline comprises a run of 68 points, each (except the first) connected to the previous point, 69 provided that `pendown' is true. The final seven fields should be the 70 same for each point in a polyline. */ 71 72 typedef struct 73 { 74 double x, y; /* location of the point in user coordinates */ 75 int have_x_errorbar, have_y_errorbar; 76 double xmin, xmax; /* meaningful only if have_x_errorbar field is set */ 77 double ymin, ymax; /* meaningful only if have_y_errorbar field is set */ 78 int pendown; /* connect to previous point? (if false, polyline ends) */ 79 /* following fields are polyline attributes: constant over a polyline */ 80 int symbol; /* either a number indicating which standard marker 81 * symbol is to be plotted at the point (<0 means none) 82 * or an character to be plotted, depending on the value: 83 * 0-31: a marker number, or 32-up: a character. */ 84 double symbol_size; /* symbol size, as frac. of size of plotting area */ 85 const char *symbol_font_name; /* font from which symbols >= 32 are taken */ 86 int linemode; /* linemode of polyline (<0 means no polyline) */ 87 double line_width; /* line width as fraction of size of the display */ 88 double fill_fraction; /* in interval [0,1], <0 means polyline isn't filled */ 89 int use_color; /* color/monochrome interpretation of linemode */ 90 91 char *label; /* For pie charts */ 92 int dataset; /* For XY, bar charts */ 93 } Point; 94 95 /* 96 * Public functions 97 */ 98 Multigrapher * sp_create_plot(plPlotter *plotter, const SpPlotType plot_type); 99 100 void sp_destroy_plot(Multigrapher *); 101 102 void sp_begin_plot(Multigrapher *mg, double scale, double trans_x, double trans_y); 103 void sp_end_plot(Multigrapher *); 104 105 void sp_set_parameters(void); /* set all parameters */ 106 void sp_set_plot_type(Multigrapher *, SpPlotType); /* Set the plot type to e.g. Bar Chart */ 107 108 void sp_draw_frame(Multigrapher *multigrapher, int draw_canvas); 109 void sp_plot_point(Multigrapher *multigrapher, const Point *point); 110 void sp_plot_point_simple(Multigrapher *mg, int connected, double x, double y); 111 112 void sp_flush(Multigrapher *); /* ??? end_polyline_and_flush */ 113 114 void sp_set_title(Multigrapher *mg, const char *title); 115 void sp_set_axis_title(Multigrapher *mg, const int axis, const char *title); 116 void sp_set_axis_range(Multigrapher *mg, int axis, double min, double max, double spacing, int log_axis); 117 118 void sp_first_dataset(Multigrapher *mg); 119 void sp_next_dataset(Multigrapher *mg); 120 121 void sp_setcolor(Multigrapher *mg, char *color); 122 123 /* 124 * Legend 125 */ 126 void sp_legend_draw(Multigrapher *mg); 127 void sp_legend_label(Multigrapher *mg, int i, char *s); 128 129 /* 130 * Ticks on axes 131 */ 132 133 typedef enum { 134 SP_TICK_DEFAULT = 0, 135 SP_TICK_PRINTF = 1, 136 SP_TICK_STRFTIME = 2, 137 SP_TICK_CUSTOM = 3, 138 SP_TICK_NONE = 4, 139 140 SP_TICK_LAST 141 } tick_type_e; 142 143 144 typedef char *(*axis_xlate_tick)(double value); 145 void sp_set_axis_ticktype(Multigrapher *mg, int axis, 146 double round_to, double incr, axis_xlate_tick xlate_tick); 147 148 /* 149 * Historic functions 150 */ 151 void begin_graph(Multigrapher *multigrapher, double scale, double trans_x, double trans_y); 152 void end_graph(Multigrapher *mg); 153 Multigrapher *new_multigrapher(const char *display_type, const char *bg_color, 154 const char *bitmap_size, const char *max_line_length, 155 const char *meta_portable, const char *page_size, const char *rotation_angle, 156 int save_screen); 157 158 int delete_multigrapher (Multigrapher *multigrapher); 159 160 void set_graph_parameters(Multigrapher *multigrapher, double frame_line_width, 161 const char *frame_color, const char *title, const char *title_font_name, 162 double title_font_size, double tick_size, grid_type grid_spec, double x_min, 163 double x_max, double x_spacing, double y_min, double y_max, double y_spacing, 164 int spec_x_spacing, int spec_y_spacing, double width, double height, double up, 165 double right, const char *x_font_name, double x_font_size, const char *x_label, 166 const char *y_font_name, double y_font_size, const char *y_label, 167 int no_rotate_y_label, int log_axis, int round_to_next_tick, 168 int switch_axis_end, int omit_labels, int clip_mode, double blankout_fraction, 169 int transpose_axes); 170 171 void draw_frame_of_graph(Multigrapher *multigrapher, int draw_canvas); 172 173 void plot_point(Multigrapher *multigrapher, const Point *point); 174 175 void plot_point_array(Multigrapher *multigrapher, const Point *p, int length); 176 void end_polyline_and_flush(Multigrapher *multigrapher); 177 void sp_set_axis_label_font_size(Multigrapher *mg, int axis, double s); 178 179 /* Don't add anything after this */ 180 181 #endif /* __SCIPLOT_H__ */ 182