2 * gadgets.h,v 1.1.3.1 2000/05/03 21:47:15 hbb Exp
5 /* GNUPLOT - gadgets.h */
8 * Copyright 2000, 2004 Thomas Williams, Colin Kelley
10 * Permission to use, copy, and distribute this software and its
11 * documentation for any purpose with or without fee is hereby granted,
12 * provided that the above copyright notice appear in all copies and
13 * that both that copyright notice and this permission notice appear
14 * in supporting documentation.
16 * Permission to modify the software is granted, but not the right to
17 * distribute the complete modified source code. Modifications are to
18 * be distributed as patches to the released version. Permission to
19 * distribute binaries produced by compiling modified sources is granted,
21 * 1. distribute the corresponding source modifications from the
22 * released version in the form of a patch file along with the binaries,
23 * 2. add special version identification to distinguish your version
24 * in addition to the base release version number,
25 * 3. provide your name and address as the primary contact for the
26 * support of your modified version, and
27 * 4. retain our contact information in regard to use of the base
29 * Permission to distribute the released version of the source code along
30 * with corresponding source modifications in the form of a patch file is
31 * granted with same provisions 2 through 4 for binary distributions.
33 * This software is provided "as is" without express or implied warranty
34 * to the extent permitted by applicable law.
37 #ifndef GNUPLOT_GADGETS_H
38 # define GNUPLOT_GADGETS_H
44 /* Types and variables concerning graphical plot elements that are not
45 * *terminal-specific, are used by both* 2D and 3D plots, and are not
46 * *assignable to any particular * axis. I.e. they belong to neither
47 * *term_api, graphics, graph3d, nor * axis .h files.
50 /* #if... / #include / #define collection: */
52 /* Default point size is taken from the global "pointsize" variable */
53 #define PTSZ_DEFAULT (-2)
54 #define PTSZ_VARIABLE (-3)
56 /* Type definitions */
58 /* Coordinate system specifications: x1/y1, x2/y2, graph-box relative
59 * or screen relative coordinate systems */
60 typedef enum position_type {
68 /* A full 3D position, with all 3 coordinates of different axes,
69 * possibly. Used for 'set label' and 'set arrow' positions: */
70 typedef struct position {
71 enum position_type scalex,scaley,scalez;
75 /* Linked list of structures storing 'set label' information */
76 typedef struct text_label {
77 struct text_label *next; /* pointer to next label in linked list */
78 int tag; /* identifies the label */
84 char *font; /* Entry font added by DJL */
85 struct t_colorspec textcolor;
86 struct lp_style_type lp_properties;
87 struct position offset;
91 /* This is the default state for the axis, timestamp, and plot title labels
92 * indicated by tag = -2 */
93 #define EMPTY_LABELSTRUCT \
94 {NULL, -2, {character, character, character, 0.0, 0.0, 0.0}, CENTRE, 0, 0, \
95 NULL, NULL, {TC_LT, -2, 0.0}, DEFAULT_LP_STYLE_TYPE, \
96 {character, character, character, 0.0, 0.0, 0.0}, FALSE }
98 /* Datastructure for implementing 'set arrow' */
99 typedef struct arrow_def {
100 struct arrow_def *next; /* pointer to next arrow in linked list */
101 int tag; /* identifies the arrow */
104 TBOOLEAN relative; /* second coordinate is relative to first */
105 struct arrow_style_type arrow_properties;
109 /* The only object type supported so far is OBJ_RECTANGLE */
110 typedef struct rectangle {
111 int type; /* 0 = corners; 1 = center + size */
112 t_position bl; /* bottom left */
113 t_position tr; /* top right */
114 t_position center; /* center */
115 t_position extent; /* width and height */
118 /* Datastructure for 'set object' */
119 typedef struct object {
122 int layer; /* behind or back or front */
123 int object_type; /* OBJ_RECTANGLE */
124 fill_style_type fillstyle;
125 lp_style_type lp_properties;
126 union o {t_rectangle rectangle;} o;
128 #define OBJ_RECTANGLE (1)
131 /* Datastructure implementing 'set style line' */
132 struct linestyle_def {
133 struct linestyle_def *next; /* pointer to next linestyle in linked list */
134 int tag; /* identifies the linestyle */
135 struct lp_style_type lp_properties;
138 /* Datastructure implementing 'set style arrow' */
139 struct arrowstyle_def {
140 struct arrowstyle_def *next;/* pointer to next arrowstyle in linked list */
141 int tag; /* identifies the arrowstyle */
142 struct arrow_style_type arrow_properties;
145 /* The stacking direction of the key box: (vertical, horizontal) */
146 typedef enum en_key_stack_direction {
149 } t_key_stack_direction;
151 /* The region, with respect to the border, key is located: (inside, outside) */
152 typedef enum en_key_region {
153 GPKEY_AUTO_INTERIOR_LRTBC, /* Auto placement, left/right/top/bottom/center */
154 GPKEY_AUTO_EXTERIOR_LRTBC, /* Auto placement, left/right/top/bottom/center */
155 GPKEY_AUTO_EXTERIOR_MARGIN, /* Auto placement, margin plus lrc or tbc */
156 GPKEY_USER_PLACEMENT /* User specified placement */
159 /* If exterior, there are 12 possible auto placements. Since
160 left/right/center with top/bottom/center can only define 9
161 locations, further subdivide the exterior region into four
162 subregions for which left/right/center (TMARGIN/BMARGIN)
163 and top/bottom/center (LMARGIN/RMARGIN) creates 12 locations. */
164 typedef enum en_key_ext_region {
171 /* Key sample to the left or the right of the plot title? */
172 typedef enum en_key_sample_positioning {
175 } t_key_sample_positioning;
178 int opt_given; /* option given / not given (otherwise default) */
179 int closeto; /* from list FILLEDCURVES_CLOSED, ... */
180 double at; /* value for FILLEDCURVES_AT... */
181 double aty; /* the other value for FILLEDCURVES_ATXY */
182 int oneside; /* -1 if fill below bound only; +1 if fill above bound only */
184 #define EMPTY_FILLEDCURVES_OPTS { 0, 0, 0.0, 0.0, 0 }
186 #ifdef EAM_HISTOGRAMS
187 typedef struct histogram_style {
188 int type; /* enum t_histogram_type */
189 int gap; /* set style hist gap <n> (space between clusters) */
190 int clustersize; /* number of datasets in this histogram */
191 double start; /* X-coord of first histogram entry */
192 double end; /* X-coord of last histogram entry */
193 int startcolor; /* LT_UNDEFINED or explicit color for first entry */
194 int startpattern; /* LT_UNDEFINED or explicit pattern for first entry */
195 double bar_lw; /* linewidth for error bars */
196 struct histogram_style *next;
197 struct text_label title;
199 typedef enum histogram_type {
201 HT_STACKED_IN_LAYERS,
202 HT_STACKED_IN_TOWERS,
206 #define DEFAULT_HISTOGRAM_STYLE { HT_NONE, 2, 1, 0.0, 0.0, LT_UNDEFINED, LT_UNDEFINED, 0, NULL, EMPTY_LABELSTRUCT }
210 /***********************************************************/
211 /* Variables defined by gadgets.c needed by other modules. */
212 /***********************************************************/
216 /* EAM Feb 2003 - Move all global variables related to key into a */
217 /* single structure. Eventually this will allow multiple keys. */
219 typedef enum keytitle_type {
220 NOAUTO_KEYTITLES, FILENAME_KEYTITLES, COLUMNHEAD_KEYTITLES
224 TBOOLEAN visible; /* Do we show this key at all? */
225 t_key_region region; /* if so: where? */
226 t_key_ext_region margin; /* if exterior: where outside? */
227 struct position user_pos; /* if user specified position, this is it */
228 VERT_JUSTIFY vpos; /* otherwise these guide auto-positioning */
230 t_key_sample_positioning just;
231 t_key_stack_direction stack_dir;
232 double swidth; /* 'width' of the linestyle sample line in the key */
233 double vert_factor; /* user specified vertical spacing multiplier */
234 double width_fix; /* user specified additional (+/-) width of key titles */
236 keytitle_type auto_titles; /* auto title curves unless plotted 'with notitle' */
237 TBOOLEAN reverse; /* key back to front */
238 TBOOLEAN invert; /* key top to bottom */
239 TBOOLEAN enhanced; /* enable/disable enhanced text of key titles */
240 struct lp_style_type box; /* linetype of box around key: */
241 char title[MAX_LINE_LEN+1]; /* title line for the key as a whole */
244 extern legend_key keyT;
246 # define DEFAULT_KEYBOX_LP { 0, LT_NODRAW, 0, 1.0, 1.0, 0 }
248 #define DEFAULT_KEY_POSITION { graph, graph, graph, 0.9, 0.9, 0. }
250 #define DEFAULT_KEY_PROPS \
252 GPKEY_AUTO_INTERIOR_LRTBC, GPKEY_RMARGIN, \
253 DEFAULT_KEY_POSITION, \
255 GPKEY_RIGHT, GPKEY_VERTICAL, \
256 4.0, 1.0, 0.0, 0.0, \
257 FILENAME_KEYTITLES, \
258 FALSE, FALSE, TRUE, \
262 /* bounding box position, in terminal coordinates */
272 * EAM Jan 2006 - Move colorbox structure definition to here from color.h
273 * in order to be able to use struct position
276 #define SMCOLOR_BOX_NO 'n'
277 #define SMCOLOR_BOX_DEFAULT 'd'
278 #define SMCOLOR_BOX_USER 'u'
283 SMCOLOR_BOX_NO .. do not draw the colour box
284 SMCOLOR_BOX_DEFAULT .. draw it at default position and size
285 SMCOLOR_BOX_USER .. draw it at the position given by user
287 char rotation; /* 'v' or 'h' vertical or horizontal box */
288 char border; /* if non-null, a border will be drawn around the box (default) */
290 int layer; /* front or back */
291 struct position origin;
292 struct position size;
295 extern color_box_struct color_box;
296 extern color_box_struct default_color_box;
298 extern BoundingBox plot_bounds; /* Plot Boundary */
299 extern BoundingBox canvas; /* Writable area on terminal */
300 extern BoundingBox *clip_area; /* Current clipping box */
302 extern float xsize; /* x scale factor for size */
303 extern float ysize; /* y scale factor for size */
304 extern float zsize; /* z scale factor for size */
305 extern float xoffset; /* x origin setting */
306 extern float yoffset; /* y origin setting */
307 extern float aspect_ratio; /* 1.0 for square */
308 extern int aspect_ratio_3D; /* 2 for equal scaling of x and y; 3 for z also */
310 /* plot border autosizing overrides, in characters (-1: autosize) */
311 extern t_position lmargin, bmargin, rmargin, tmargin;
312 #define DEFAULT_MARGIN_POSITION {character, character, character, -1, -1, -1}
314 extern FILE *table_outfile;
315 extern TBOOLEAN table_mode;
317 extern struct arrow_def *first_arrow;
319 extern struct text_label *first_label;
321 extern struct linestyle_def *first_linestyle;
323 extern struct arrowstyle_def *first_arrowstyle;
326 extern struct object *first_object;
329 extern text_label title;
331 extern text_label timelabel;
332 #ifndef DEFAULT_TIMESTAMP_FORMAT
333 /* asctime() format */
334 # define DEFAULT_TIMESTAMP_FORMAT "%a %b %d %H:%M:%S %Y"
336 extern int timelabel_rotate;
337 extern int timelabel_bottom;
339 extern TBOOLEAN polar;
341 #define ZERO 1e-8 /* default for 'zero' set option */
342 extern double zero; /* zero threshold, not 0! */
344 extern double pointsize;
346 #define SOUTH 1 /* 0th bit */
347 #define WEST 2 /* 1th bit */
348 #define NORTH 4 /* 2th bit */
349 #define EAST 8 /* 3th bit */
350 #define border_east (draw_border & EAST)
351 #define border_west (draw_border & WEST)
352 #define border_south (draw_border & SOUTH)
353 #define border_north (draw_border & NORTH)
354 #define border_complete ((draw_border & 15) == 15)
355 extern int draw_border;
356 extern int border_layer;
358 extern struct lp_style_type border_lp;
359 extern const struct lp_style_type default_border_lp;
361 extern TBOOLEAN clip_lines1;
362 extern TBOOLEAN clip_lines2;
363 extern TBOOLEAN clip_points;
365 #define SAMPLES 100 /* default number of samples for a plot */
366 extern int samples_1;
367 extern int samples_2;
369 extern double ang2rad; /* 1 or pi/180 */
371 extern enum PLOT_STYLE data_style;
372 extern enum PLOT_STYLE func_style;
374 extern TBOOLEAN parametric;
376 /* If last plot was a 3d one. */
377 extern TBOOLEAN is_3d_plot;
379 /* A macro to check whether 2D functionality is allowed in the last plot:
380 either the plot is a 2D plot, or it is a suitably oriented 3D plot (e.g. map).
384 ( fabs(fmod(surface_rot_z,90.0))<0.1 \
385 && (surface_rot_x>179.9 || surface_rot_x<0.1) ) )
388 extern TBOOLEAN is_cb_plot;
391 /* Plot layer definitions are collected here. */
392 /* Someday they might actually be used. */
393 #define LAYER_BEHIND -1
395 #define LAYER_FRONT 1
396 #define LAYER_PLOTLABELS 99
398 /* Functions exported by gadgets.c */
400 /* moved here from util3d: */
401 void draw_clip_line __PROTO((int, int, int, int));
402 void draw_clip_arrow __PROTO((int, int, int, int, int));
403 int clip_line __PROTO((int *, int *, int *, int *));
404 int clip_point __PROTO((unsigned int, unsigned int));
405 void clip_put_text __PROTO((unsigned int, unsigned int, char *));
407 /* moved here from graph3d: */
408 void clip_move __PROTO((unsigned int x, unsigned int y));
409 void clip_vector __PROTO((unsigned int x, unsigned int y));
411 /* Common routines for setting line or text color from t_colorspec */
412 void apply_pm3dcolor __PROTO((struct t_colorspec *tc, const struct termentry *t));
413 void reset_textcolor __PROTO((const struct t_colorspec *tc, const struct termentry *t));
415 extern fill_style_type default_fillstyle;
418 extern struct object default_rectangle;
419 #define DEFAULT_RECTANGLE_STYLE { NULL, -1, 0, OBJ_RECTANGLE, \
420 {FS_SOLID, 100, 0, LT_BLACK}, \
421 {1, LT_BACKGROUND, 0, 1.0, 0.0}, \
422 {{0, {0,0.,0.,0.}, {0,0.,0.,0.}, {0,0.,0.,0.}, {0,0.,0.,0.}}} }
425 /* filledcurves style options set by 'set style [data|func] filledcurves opts' */
426 extern filledcurves_opts filledcurves_opts_data;
427 extern filledcurves_opts filledcurves_opts_func;
429 /* Prefer line styles over plain line types */
430 extern TBOOLEAN prefer_line_styles;
432 #ifdef EAM_HISTOGRAMS
433 extern histogram_style histogram_opts;
436 void default_arrow_style __PROTO((struct arrow_style_type *arrow));
438 #ifdef EAM_DATASTRINGS
439 void free_labels __PROTO((struct text_label *tl));
442 void get_offsets __PROTO((struct text_label *this_label,
443 struct termentry *t, int *htic, int *vtic));
444 void write_label __PROTO((unsigned int x, unsigned int y, struct text_label *label));
446 #endif /* GNUPLOT_GADGETS_H */