1 /* 2 * $Id: pm3d.h,v 1.35 2016/11/05 21:21:07 sfeam Exp $ 3 */ 4 5 /* GNUPLOT - pm3d.h */ 6 7 /*[ 8 * 9 * Petr Mikulik, since December 1998 10 * Copyright: open source as much as possible 11 * 12 * 13 * What is here: #defines, global variables and declaration of routines for 14 * the pm3d plotting mode 15 * 16 ]*/ 17 18 19 /* avoid multiple includes */ 20 #ifdef HAVE_CONFIG_H 21 # include "config.h" 22 #endif 23 24 #ifndef TERM_HELP 25 26 #ifndef PM3D_H 27 #define PM3D_H 28 29 #include "axis.h" /* only for NONLINEAR_AXES */ 30 #include "graph3d.h" /* struct surface_points */ 31 32 33 34 /**** 35 Global options for pm3d algorithm (to be accessed by set / show) 36 ****/ 37 38 /* 39 where to plot pm3d: base or top (color map) or surface (color surface) 40 The string pm3d.where can be any combination of the #defines below. 41 For instance, "b" plot at botton only, "st" plots firstly surface, then top, etc. 42 */ 43 #define PM3D_AT_BASE 'b' 44 #define PM3D_AT_TOP 't' 45 #define PM3D_AT_SURFACE 's' 46 47 /* 48 options for flushing scans (for pm3d.flush) 49 Note: new terminology compared to my pm3d program; in gnuplot it became 50 begin and right instead of left and right 51 */ 52 #define PM3D_FLUSH_BEGIN 'b' 53 #define PM3D_FLUSH_END 'r' 54 #define PM3D_FLUSH_CENTER 'c' 55 56 /* 57 direction of taking the scans: forward = as the scans are stored in the 58 file; backward = opposite direction, i.e. like from the end of the file 59 */ 60 typedef enum { 61 PM3D_SCANS_AUTOMATIC, 62 PM3D_SCANS_FORWARD, 63 PM3D_SCANS_BACKWARD, 64 PM3D_DEPTH 65 } pm3d_scandir; 66 67 /* 68 clipping method: 69 PM3D_CLIP_1IN: all 4 points of the quadrangle must be defined and at least 70 1 point of the quadrangle must be in the x and y ranges 71 PM3D_CLIP_4IN: all 4 points of the quadrangle must be in the x and y ranges 72 */ 73 #define PM3D_CLIP_1IN '1' 74 #define PM3D_CLIP_4IN '4' 75 76 /* 77 is pm3d plotting style implicit or explicit? 78 */ 79 typedef enum { 80 PM3D_EXPLICIT = 0, 81 PM3D_IMPLICIT = 1 82 } PM3D_IMPL_MODE; 83 84 /* 85 from which corner take the color? 86 */ 87 typedef enum { 88 /* keep the following order of PM3D_WHICHCORNER_C1 .. _C4 */ 89 PM3D_WHICHCORNER_C1 = 0, /* corner 1: first scan, first point */ 90 PM3D_WHICHCORNER_C2 = 1, /* corner 2: first scan, second point */ 91 PM3D_WHICHCORNER_C3 = 2, /* corner 3: second scan, first point */ 92 PM3D_WHICHCORNER_C4 = 3, /* corner 4: second scan, second point */ 93 /* the rest can be in any order */ 94 PM3D_WHICHCORNER_MEAN = 4, /* average z-value from all 4 corners */ 95 PM3D_WHICHCORNER_GEOMEAN = 5, /* geometrical mean of 4 corners */ 96 PM3D_WHICHCORNER_HARMEAN = 6, /* harmonic mean of 4 corners */ 97 PM3D_WHICHCORNER_MEDIAN = 7, /* median of 4 corners */ 98 PM3D_WHICHCORNER_RMS = 8, /* root mean square of 4 corners*/ 99 PM3D_WHICHCORNER_MIN = 9, /* minimum of 4 corners */ 100 PM3D_WHICHCORNER_MAX = 10,/* maximum of 4 corners */ 101 PM3D_COLOR_BY_NORMAL = 11 /* derive color from surface normal (not currently used) */ 102 } PM3D_WHICH_CORNERS2COLOR; 103 104 /* 105 structure defining all properties of pm3d plotting mode 106 (except for the properties of the smooth color box, see color_box instead) 107 */ 108 typedef struct { 109 char where[7]; /* base, top, surface */ 110 char flush; /* left, right, center */ 111 char ftriangles; /* 0/1 (don't) draw flushing triangles */ 112 char clip; /* 1in, 4in */ 113 TBOOLEAN no_clipcb; /* FALSE: cb<0 treated as 0 TRUE: cb<0 treated as NaN */ 114 pm3d_scandir direction; 115 TBOOLEAN base_sort; /* default: depth sort by mean z; true: use z=0.0 */ 116 PM3D_IMPL_MODE implicit; 117 /* 1: [default] draw ALL surfaces with pm3d 118 0: only surfaces specified with 'with pm3d' */ 119 PM3D_WHICH_CORNERS2COLOR which_corner_color; 120 /* default: average color from all 4 points */ 121 int interp_i; /* # of interpolation steps along scanline */ 122 int interp_j; /* # of interpolation steps between scanlines */ 123 lp_style_type border; /* LT_NODRAW to disable. From `set pm3d border <linespec> */ 124 } pm3d_struct; 125 126 extern pm3d_struct pm3d; 127 128 typedef struct lighting_model { 129 double strength; /* 0 = no lighting model; 1 = full shading */ 130 double spec; /* specular component 0-1 */ 131 double ambient; /* ambient component 0-1 */ 132 double Phong; /* Phong exponent */ 133 int rot_z; /* illumination angle */ 134 int rot_x; /* illumination angle */ 135 TBOOLEAN fixed; /* TRUE means the light does not rotate */ 136 } lighting_model; 137 138 extern lighting_model pm3d_shade; 139 140 /* Used to initialize `set pm3d border` */ 141 extern struct lp_style_type default_pm3d_border; 142 143 /* Used by routine filled_quadrangle() in color.c */ 144 extern struct lp_style_type pm3d_border_lp; 145 extern TBOOLEAN track_pm3d_quadrangles; 146 147 #if defined(NONLINEAR_AXES) && (NONLINEAR_AXES > 0) 148 # define z2cb(z) (z) 149 #else 150 /* The original routine, with log/unlog dance steps */ 151 # define z2cb(z) z2cb_with_logs(z) 152 #endif 153 154 155 /**** 156 Declaration of routines 157 ****/ 158 159 int get_pm3d_at_option __PROTO((char *pm3d_where)); 160 void pm3d_depth_queue_clear __PROTO((void)); 161 void pm3d_depth_queue_flush __PROTO((void)); 162 void pm3d_reset __PROTO((void)); 163 void pm3d_draw_one __PROTO((struct surface_points* plots)); 164 void pm3d_add_quadrangle __PROTO((struct surface_points* plot, gpdPoint *corners)); 165 double z2cb_with_logs __PROTO((double z)); 166 double cb2gray __PROTO((double cb)); 167 void 168 pm3d_rearrange_scan_array __PROTO((struct surface_points* this_plot, 169 struct iso_curve*** first_ptr, int* first_n, int* first_invert, 170 struct iso_curve*** second_ptr, int* second_n, int* second_invert)); 171 172 void set_plot_with_palette __PROTO((int plot_num, int plot_mode)); 173 174 TBOOLEAN is_plot_with_palette __PROTO((void)); 175 TBOOLEAN is_plot_with_colorbox __PROTO((void)); 176 177 #endif /* PM3D_H */ 178 179 #endif /* TERM_HELP */ 180 181 /* eof pm3d.h */ 182