1 /* GNUPLOT - graph3d.h */
2 
3 /*[
4  * Copyright 1999, 2004   Thomas Williams, Colin Kelley
5  *
6  * Permission to use, copy, and distribute this software and its
7  * documentation for any purpose with or without fee is hereby granted,
8  * provided that the above copyright notice appear in all copies and
9  * that both that copyright notice and this permission notice appear
10  * in supporting documentation.
11  *
12  * Permission to modify the software is granted, but not the right to
13  * distribute the complete modified source code.  Modifications are to
14  * be distributed as patches to the released version.  Permission to
15  * distribute binaries produced by compiling modified sources is granted,
16  * provided you
17  *   1. distribute the corresponding source modifications from the
18  *    released version in the form of a patch file along with the binaries,
19  *   2. add special version identification to distinguish your version
20  *    in addition to the base release version number,
21  *   3. provide your name and address as the primary contact for the
22  *    support of your modified version, and
23  *   4. retain our contact information in regard to use of the base
24  *    software.
25  * Permission to distribute the released version of the source code along
26  * with corresponding source modifications in the form of a patch file is
27  * granted with same provisions 2 through 4 for binary distributions.
28  *
29  * This software is provided "as is" without express or implied warranty
30  * to the extent permitted by applicable law.
31 ]*/
32 
33 #ifndef GNUPLOT_GRAPH3D_H
34 # define GNUPLOT_GRAPH3D_H
35 
36 /* #if... / #include / #define collection: */
37 
38 #include "syscfg.h"
39 #include "gp_types.h"
40 
41 #include "gadgets.h"
42 #include "term_api.h"
43 
44 /* Type definitions */
45 
46 typedef enum en_dgrid3d_mode {
47     DGRID3D_DEFAULT,
48     DGRID3D_QNORM,
49     DGRID3D_SPLINES,
50     DGRID3D_GAUSS,
51     DGRID3D_EXP,
52     DGRID3D_CAUCHY,
53     DGRID3D_BOX,
54     DGRID3D_HANN,
55     DGRID3D_OTHER
56 } t_dgrid3d_mode;
57 
58 typedef enum en_contour_placement {
59     /* Where to place contour maps if at all. */
60     CONTOUR_NONE,
61     CONTOUR_BASE,
62     CONTOUR_SRF,
63     CONTOUR_BOTH
64 } t_contour_placement;
65 
66 typedef double transform_matrix[4][4]; /* HBB 990826: added */
67 
68 typedef struct gnuplot_contours {
69     struct gnuplot_contours *next;
70     struct coordinate *coords;
71     char isNewLevel;
72     char label[32];
73     int num_pts;
74     double z;
75 } gnuplot_contours;
76 
77 typedef struct iso_curve {
78     struct iso_curve *next;
79     int p_max;			/* how many points are allocated */
80     int p_count;			/* count of points in points */
81     struct coordinate *points;
82 } iso_curve;
83 
84 typedef struct surface_points {
85 
86     struct surface_points *next_sp; /* pointer to next plot in linked list */
87     int token;			/* last token used, for second parsing pass */
88     enum PLOT_TYPE plot_type;	/* DATA2D? DATA3D? FUNC2D FUNC3D? NODATA? */
89     enum PLOT_STYLE plot_style;	/* style set by "with" or by default */
90     char *title;		/* plot title, a.k.a. key entry */
91     t_position *title_position;	/* title at {beginning|end|<xpos>,<ypos>} */
92     TBOOLEAN title_no_enhanced;	/* don't typeset title in enhanced mode */
93     TBOOLEAN title_is_automated;/* TRUE if title was auto-generated */
94     TBOOLEAN title_is_suppressed;/* TRUE if 'notitle' was specified */
95     TBOOLEAN noautoscale;	/* ignore data from this plot during autoscaling */
96     struct lp_style_type lp_properties;
97     struct arrow_style_type arrow_properties;
98     struct fill_style_type fill_properties;
99     struct text_label *labels;	/* Only used if plot_style == LABELPOINTS */
100     struct t_image image_properties;	/* only used if plot_style is IMAGE, RGBIMAGE or RGBA_IMAGE */
101     struct udvt_entry *sample_var;	/* used by '+' if plot has private sampling range */
102     struct udvt_entry *sample_var2;	/* used by '++' if plot has private sampling range */
103 
104     /* 2D and 3D plot structure fields overlay only to this point */
105 
106     TBOOLEAN opt_out_of_hidden3d; /* set by "nohidden" option to splot command */
107     TBOOLEAN opt_out_of_contours; /* set by "nocontours" option to splot command */
108     TBOOLEAN opt_out_of_surface;  /* set by "nosurface" option to splot command */
109     TBOOLEAN pm3d_color_from_column;
110     TBOOLEAN has_grid_topology;
111     int hidden3d_top_linetype;	/* before any calls to load_linetype() */
112     int iteration;		/* needed for tracking iteration */
113 
114     struct vgrid *vgrid;	/* used only for voxel plots */
115     double iso_level;		/* used only for voxel plots */
116 
117     /* Data files only - num of isolines read from file. For functions,  */
118     /* num_iso_read is the number of 'primary' isolines (in x direction) */
119     int num_iso_read;
120     struct gnuplot_contours *contours; /* NULL if not doing contours. */
121     struct iso_curve *iso_crvs;	/* the actual data */
122     char pm3d_where[7];		/* explicitly given base, top, surface */
123 
124 } surface_points;
125 
126 /* Variables of graph3d.c needed by other modules: */
127 
128 extern int xmiddle, ymiddle, xscaler, yscaler;
129 extern double floor_z, floor_z1;
130 extern double ceiling_z, base_z; /* made exportable for PM3D */
131 extern transform_matrix trans_mat;
132 extern double xscale3d, yscale3d, zscale3d;
133 extern double xcenter3d, ycenter3d, zcenter3d;
134 extern double radius_scaler;
135 
136 extern t_contour_placement draw_contour;
137 extern TBOOLEAN	clabel_onecolor;
138 extern int clabel_start;
139 extern int clabel_interval;
140 extern char *clabel_font;
141 
142 extern TBOOLEAN	draw_surface;
143 extern TBOOLEAN	implicit_surface;
144 
145 /* is hidden3d display wanted? */
146 extern TBOOLEAN	hidden3d;
147 extern int hidden3d_layer;	/* LAYER_FRONT or LAYER_BACK */
148 
149 extern float surface_rot_z;
150 extern float surface_rot_x;
151 extern float surface_scale;
152 extern float surface_zscale;
153 extern float surface_lscale;
154 extern float mapview_scale;
155 extern float azimuth;
156 extern TBOOLEAN splot_map, xz_projection, yz_projection;
157 
158 typedef struct {
159     double z;
160     TBOOLEAN absolute;
161 } t_xyplane;
162 
163 extern t_xyplane xyplane;
164 
165 #define ISO_SAMPLES 10		/* default number of isolines per splot */
166 extern int iso_samples_1;
167 extern int iso_samples_2;
168 
169 #ifdef USE_MOUSE
170 extern int axis3d_o_x, axis3d_o_y, axis3d_x_dx, axis3d_x_dy, axis3d_y_dx, axis3d_y_dy;
171 #endif
172 
173 typedef enum {
174     NORMAL_REPLOT = 0,	/* e.g. "replot" command */
175     AXIS_ONLY_ROTATE,	/* suppress replots during 3D rotation by ctrl-left-mouse */
176     NORMAL_REFRESH,	/* e.g. "refresh" command */
177     QUICK_REFRESH	/* auto-generated refresh during 3D rotation */
178 } REPLOT_TYPE;
179 
180 
181 /* Prototypes from file "graph3d.c" */
182 
183 void do_3dplot(struct surface_points *plots, int pcount, REPLOT_TYPE quick);
184 void map3d_position(struct position *pos, int *x, int *y, const char *what);
185 void map3d_position_double(struct position *pos, double *x, double *y, const char *what);
186 void map3d_position_r(struct position *pos, int *x, int *y, const char *what);
187 void map3d_position_r_double(struct position *pos, double *x, double *y, const char *what);
188 
189 
190 #endif /* GNUPLOT_GRAPH3D_H */
191