00001 #ifndef GD_GRAPH_H
00002 #define GD_GRAPH_H 1
00003
00004 #ifdef __cplusplus
00005 extern "C" {
00006 #endif
00007
00008 #include <stdio.h>
00009 #include <gd.h>
00010
00050
00051 #define NUM_COLORS 8
00052 #define NUM_MARKERS 10
00053
00054 typedef enum gdgMarker {
00055 FILLED_SQUARE,
00056 OPEN_SQUARE,
00057 POINT,
00059 HORIZONTAL_CROSS,
00060 DIAGONAL_CROSS,
00061 OPEN_TRIANGLE,
00062 FILLED_TRIANGLE,
00063 OPEN_UTRIANGLE,
00064 FILLED_UTRIANGLE,
00065 FILLED_CIRCLE,
00066 OPEN_CIRCLE,
00067 AUTO_MARKER
00068 } gdgMarkerType;
00069
00070
00071 typedef struct gdgIM {
00072 char ***labels;
00073 char ***links;
00074 FILE *out;
00075 int both;
00076 } gdgImageMapInfo;
00080 typedef enum gdgBar {
00081 FILLED,
00082 OPEN,
00083 OUTLINE
00084 } gdgBarType;
00085
00086 typedef struct gdgPlot {
00087 int lineColor;
00088 int markerColor;
00089 int useLine;
00090 int noSort;
00091 gdgMarkerType marker;
00092 int markerSize;
00093 double *x;
00094 double *y;
00095 int numPoints;
00096 struct gdgPlot *next;
00097 } *gdgPlotPtr;
00098
00099 typedef struct gdgImage {
00100 int height;
00101 int width;
00102 int x1,x2,y1,y2;
00103 char *xlabel;
00104 char *ylabel;
00105 char *title;
00106 char **legends;
00107 gdgMarkerType marker;
00108 gdgBarType bar;
00109
00110 int markerSize;
00111 gdImagePtr im;
00112 double ymin;
00113 double ymax;
00114 gdgPlotPtr plots;
00115 gdgImageMapInfo mapinfo;
00116 int numPlots;
00117 int dataPlotted;
00118 int lineColorMark;
00119 int pointColorMark;
00120 int markerStyleMark;
00121
00122
00123 int BLACK;
00124 int WHITE;
00125 int RED;
00126 int GREEN;
00127 int BLUE;
00128 int CHARTREUSE;
00129 int CHOCOLATE;
00130 int CYAN;
00131 int GRAY;
00132 int MAGENTA;
00133 int ORANGE;
00134 int YELLOW;
00135 int LIGHT_GRAY;
00136 int allColors[NUM_COLORS];
00137 gdgMarkerType allMarkers[NUM_MARKERS];
00138 } *gdgImagePtr;
00139
00140
00141
00142
00145 #define gdgGetGD(gdg) gdg->im
00146
00147
00148
00149
00151 gdgImagePtr gdgCreatePlot(int width, int height);
00153 void gdgImageDestroy(gdgImagePtr gdg);
00154
00155
00159 void gdgSetColorMap(int map);
00160
00161
00166 void gdgSetLegend(gdgImagePtr gdg, char **legends);
00167
00168 void gdgSetImageMap(gdgImagePtr gdg, gdgImageMapInfo mapinfo);
00169
00170
00172 void gdgSetYLabel(gdgImagePtr gdg, char *ylabel);
00174 void gdgSetXLabel(gdgImagePtr gdg, char *xlabel);
00176 void gdgSetTitle(gdgImagePtr gdg, char *title);
00177
00179 void gdgSetMarker(gdgImagePtr gdg, gdgMarkerType marker);
00180
00182 void gdgSetBar(gdgImagePtr gdg, gdgBarType bar);
00183
00186 void gdgSetMarkerSize(gdgImagePtr gdg, int size);
00187
00188 void gdgSetYScale(gdgImagePtr gdg, double ymin, double ymax);
00189
00193 void gdgSetUseLine(int val);
00194
00200 void gdgSetNoSort(int val);
00201
00202
00207 int gdgGetColor(const gdgImagePtr gdg, const char *color);
00208
00209
00214 void gdgImage2DPlot(gdgImagePtr gdg, int numPoints, double *x, double *y, int markerColor, int lineColor);
00215
00223 void gdgImageHist(gdgImagePtr gdg, int numPoints, double *x, int maxBreaks, int noYscale, int color);
00224
00240 void gdgImageHeat(gdgImagePtr gdg, int numRows, int numCols, double **matrix, char **xlabels, char **ylabels, double squishWithin, int autoCenter);
00241
00243 void gdgImagePng(gdgImagePtr gdg, FILE *out);
00248 void gdgImageJpeg(gdgImagePtr gdg, FILE *out, int quality);
00249
00250
00251
00252 #ifdef __cplusplus
00253 }
00254 #endif
00255
00256 #endif