1 /*---------------------------------------------------------------------------- 2 * SciPlot A generalized plotting widget 3 * 4 * Copyright (c) 1996 Robert W. McMullen 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Library General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Library General Public License for more details. 15 * 16 * You should have received a copy of the GNU Library General Public 17 * License along with this library; if not, write to the Free 18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * 20 * 21 * Author: Rob McMullen <rwmcm@mail.ae.utexas.edu> 22 * http://www.ae.utexas.edu/~rwmcm 23 */ 24 25 #ifndef _SCIPLOTP_H 26 #define _SCIPLOTP_H 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 #include <X11/CoreP.h> 33 #ifdef MOTIF 34 #if XmVersion == 1001 35 #include <Xm/XmP.h> 36 #else 37 #include <Xm/PrimitiveP.h> 38 #endif 39 #endif 40 #ifdef __sgi 41 #include <sys/types.h> 42 #include <malloc.h> 43 #endif /* __sgi */ 44 45 #include "SciPlot.h" 46 #include <X11/Xcms.h> 47 48 #define powi(a,i) (real)pow(a,(double)((int)i)) 49 50 #define NUMPLOTLINEALLOC 5 51 #define NUMPLOTDATAEXTRA 25 52 #define NUMPLOTITEMALLOC 256 53 #define NUMPLOTITEMEXTRA 64 54 #define DEG2RAD (3.1415926535897931160E0/180.0) 55 56 typedef struct { 57 int dummy; /* keep compiler happy with dummy field */ 58 } SciPlotClassPart; 59 60 61 typedef struct _SciPlotClassRec { 62 CoreClassPart core_class; 63 #ifdef MOTIF 64 XmPrimitiveClassPart primitive_class; 65 #endif 66 SciPlotClassPart plot_class; 67 } SciPlotClassRec; 68 69 extern SciPlotClassRec sciplotClassRec; 70 71 typedef enum { 72 SciPlotFALSE, 73 SciPlotPoint, 74 SciPlotLine, 75 SciPlotRect, 76 SciPlotFRect, 77 SciPlotCircle, 78 SciPlotFCircle, 79 SciPlotStartTextTypes, 80 SciPlotText, 81 SciPlotVText, 82 SciPlotEndTextTypes, 83 SciPlotPoly, 84 SciPlotFPoly, 85 SciPlotClipRegion, 86 SciPlotClipClear, 87 SciPlotENDOFLIST 88 } SciPlotTypeEnum; 89 90 typedef enum { 91 SciPlotDrawingAny, 92 SciPlotDrawingAxis, 93 SciPlotDrawingLegend, 94 SciPlotDrawingLine 95 } SciPlotDrawingEnum; 96 97 typedef struct _SciPlotItem { 98 SciPlotTypeEnum type; 99 SciPlotDrawingEnum drawing_class; 100 union { 101 struct { 102 short color; 103 short style; 104 real x, y; 105 } pt; 106 struct { 107 short color; 108 short style; 109 real x1, y1, x2, y2; 110 } line; 111 struct { 112 short color; 113 short style; 114 real x, y, w, h; 115 } rect; 116 struct { 117 short color; 118 short style; 119 real x, y, r; 120 } circ; 121 struct { 122 short color; 123 short style; 124 short count; 125 real x[4], y[4]; 126 } poly; 127 struct { 128 short color; 129 short style; 130 short font; 131 short length; 132 real x, y; 133 char *text; 134 } text; 135 struct { 136 short color; 137 short style; 138 } any; 139 140 } kind; 141 short individually_allocated; 142 struct _SciPlotItem *next; 143 } SciPlotItem; 144 145 typedef struct { 146 int LineStyle; 147 int LineColor; 148 int PointStyle; 149 int PointColor; 150 int number; 151 int allocated; 152 realpair *data; 153 char *legend; 154 real markersize; 155 realpair min, max; 156 Boolean draw, used; 157 } SciPlotList; 158 159 typedef struct { 160 real Origin; 161 real Size; 162 real Center; 163 real TitlePos; 164 real AxisPos; 165 real LabelPos; 166 real LegendPos; 167 real LegendSize; 168 real DrawOrigin; 169 real DrawSize; 170 real DrawMax; 171 real MajorInc; 172 int MajorNum; 173 int MinorNum; 174 int Precision; 175 } SciPlotAxis; 176 177 typedef struct { 178 int id; 179 XFontStruct *font; 180 } SciPlotFont; 181 182 typedef struct { 183 int flag; 184 char *PostScript; 185 char *X11; 186 Boolean PSUsesOblique; 187 Boolean PSUsesRoman; 188 } SciPlotFontDesc; 189 190 typedef struct { 191 /* Public stuff ... */ 192 char *TransientPlotTitle; 193 char *TransientXLabel; 194 char *TransientYLabel; 195 int Margin; 196 int TitleMargin; 197 int LegendMargin; 198 int LegendLineSize; 199 int MajorTicSize; 200 int DefaultMarkerSize; 201 int ChartType; 202 Boolean ScaleToFit; 203 Boolean Degrees; 204 Boolean XLog; 205 Boolean YLog; 206 Boolean XAutoScale; 207 Boolean YAutoScale; 208 Boolean XAxisNumbers; 209 Boolean YAxisNumbers; 210 Boolean XOrigin; 211 Boolean YOrigin; 212 Boolean DrawMajor; 213 Boolean DrawMinor; 214 Boolean DrawMajorTics; 215 Boolean DrawMinorTics; 216 Boolean ShowLegend; 217 Boolean ShowTitle; 218 Boolean ShowXLabel; 219 Boolean ShowYLabel; 220 Boolean YNumHorz; 221 Boolean LegendThroughPlot; 222 Boolean Monochrome; 223 Font TitleFID; 224 int TitleFont; 225 int LabelFont; 226 int AxisFont; 227 int BackgroundColor; 228 int ForegroundColor; 229 230 /* Private stuff ... */ 231 char *plotTitle; 232 char *xlabel; 233 char *ylabel; 234 realpair Min, Max; 235 realpair UserMin, UserMax; 236 real PolarScale; 237 SciPlotAxis x, y; 238 int titleFont; 239 int labelFont; 240 int axisFont; 241 242 GC defaultGC; 243 GC dashGC; 244 Colormap cmap; 245 Pixel *colors; 246 int num_colors; 247 SciPlotFont *fonts; 248 int num_fonts; 249 250 int alloc_plotlist; 251 int num_plotlist; 252 SciPlotList *plotlist; 253 int alloc_drawlist; 254 int num_drawlist; 255 SciPlotItem *drawlist; 256 SciPlotDrawingEnum current_id; /* id of current item. Used for erasing */ 257 Boolean update; 258 } SciPlotPart; 259 260 typedef struct _SciPlotRec { 261 CorePart core; 262 #ifdef MOTIF 263 XmPrimitivePart primitive; 264 #endif 265 SciPlotPart plot; 266 } SciPlotRec; 267 268 #ifdef __cplusplus 269 }; 270 #endif 271 272 #endif /* _SCIPLOTP_H */ 273