PLplot  5.15.0
cd.h
Go to the documentation of this file.
1 #ifndef CD_H
2 #define CD_H 1
3 
4 // cd.h: declarations file for the cgmdraw module.
5 //
6 // Written by G. Edward Johnson <mailto:lorax@nist.gov>
7 // Date: April 1996
8 // Copyright: cd software produced by NIST, an agency of the
9 // U.S. government, is by statute not subject to copyright
10 // in the United States. Recipients of this software assume all
11 // responsibilities associated with its operation, modification
12 // and maintenance.
13 //
14 // Portions of this package are from the gd package written by
15 // Thomas Boutell and are copyright 1994, 1995, Quest Protein
16 // Database Center, Cold Spring Harbor Labs. They are marked in the
17 // source code.
18 //
19 //
20 
21 // #include <prof.h>
22 
23 // stdio is needed for file I/O.
24 #include <stdio.h>
25 #include "cddll.h"
26 // This can not be changed to a value larger than 256, though smaller
27 // values can be used.
28 //
29 
30 #define cdMaxColors 256
31 
32 // If you know you will be working with large pictures, increase the values
33 // of the next two constants.
34 //
35 
36 // The initial size of the element list. When it fills up, we will just
37 // make it bigger. Starting with a larger number reduces the frequency of
38 // the list growing, but increases the memory needed for small pictures
39 //
40 
41 #define CDSTARTLISTSIZE 4096
42 
43 // How much the element list grows by. When the list fills up, we allocate
44 // a new larger list. This number is how much larger. using a larger number
45 // decreases the frequency of the list growing, but if only a small amount
46 // more is needed, it could waste memory
47 //
48 
49 #define CDGROWLISTSIZE 2048
50 
51 // Image type. See functions below; you will not need to change
52 // the elements directly. Use the provided macros to
53 // access sx, sy, the color table, and colorsTotal for
54 // read-only purposes.
55 
56 #if defined ( __cplusplus ) || defined ( c_plusplus )
57 extern "C" {
58 #endif
59 
60 typedef struct cdImageStruct
61 {
62  // Don't mess with these
63  unsigned char * elemlist;
64  short int state;
70  // You can have multiple pictures in the file, this keeps track
71  // of which one you are on
72  int picnum;
73  // these take effect only when the first picture is created.
74  // subsequent changes have no effect
75  unsigned char *desc;
76  unsigned char *fontlist;
77  short int numfonts;
78  FILE *outfile;
79  // these take effect when a new picture is opened. Subsequent
80  // changes are for the next picture
81  int linespec;
82  int edgespec;
84  int sx;
85  int sy;
86  // these take effect immediately
87  // Linetype, line width, line color have a broader scope in CGM
88  int ltype;
89  int lwidth;
90  int lcolor;
91  // interior style [of filled objects] (for me) can be empty, hollow,
92  // solid, hatch [don't do pattern, geometric pattern, interpolated
94  // fill color, color used on inside of closed objects, significant
95  // if interior style is hollow, solid, hatch, or geometric pattern
97  // hatch index, which hatch style to use, 1=horizontal, 2=vertical,
98  // 3=pos.slope, 4=neg.slope, 5=hor/vert.crosshatch,
99  // 6=pos/neg.crosshatch
101  // The edges of filled shapes can have line styles too. They
102  // correspond to the ones for lines. These next few set them.
103  int edgetype;
106  int edgevis; // is the edge visible or invisible
107  // now for the TEXT related attributes, Text Color, Text Height,
108  // and Text font index
109  int textfont;
112  int textpath;
113  // Marker type, Marker size, marker color
114  int mtype;
115  int msize;
116  int mcolor;
117  // the next three are used for maintaining the element list
118  long int bytestoend; // number of bytes to end of the element list
119  long int listlen; // the total length of the element list
120  unsigned char * curelemlist; // where we curently are in the list
121 } cdImage;
122 
123 typedef cdImage * cdImagePtr;
124 
125 
126 // Point type for use in polygon drawing.
127 
128 typedef struct cdPointStruct
129 {
130  int x, y, e;
131 } cdPoint, *cdPointPtr;
132 
133 
134 
135 // Functions to manipulate images.
136 
137 CDDLLIMPEXP cdImagePtr cdImageCreate( int sx, int sy );
138 CDDLLIMPEXP int cdCgmNewPic( cdImagePtr im, int sticky );
139 CDDLLIMPEXP int cdImageCgm( cdImagePtr im, FILE * );
140 CDDLLIMPEXP int cdImageDestroy( cdImagePtr im );
141 
142 // Use cdLine, not cdImageLine
143 CDDLLIMPEXP int cdLine( cdImagePtr im, int x1, int y1, int x2, int y2 );
144 // Corners specified (not width and height). Upper left first, lower right
145 // second.
146 CDDLLIMPEXP int cdRectangle( cdImagePtr im, int x1, int y1, int x2, int y2 );
147 // center x, then center y, then radius of circle
148 CDDLLIMPEXP int cdCircle( cdImagePtr im, int cx, int cy, int r );
149 // start, middle and end of arc
150 CDDLLIMPEXP int cdArc3Pt( cdImagePtr im, int sx, int sy, int ix, int iy, int ex, int ey );
151 // cl is 0 for pie closure, 1 for cord closure
152 CDDLLIMPEXP int cdArc3PtClose( cdImagePtr im, int sx, int sy, int ix, int iy, int ex, int ey, int cl );
153 CDDLLIMPEXP int cdEllipse( cdImagePtr im, int cx, int cy, int d1x, int d1y, int d2x, int d2y );
154 CDDLLIMPEXP int cdMarker( cdImagePtr im, int x, int y );
155 // polyshapes
156 CDDLLIMPEXP int cdPolygon( cdImagePtr im, cdPointPtr p, int n );
157 CDDLLIMPEXP int cdPolygonSet( cdImagePtr im, cdPointPtr p, int n );
158 CDDLLIMPEXP int cdPolyLine( cdImagePtr im, cdPointPtr p, int n );
159 CDDLLIMPEXP int cdPolyMarker( cdImagePtr im, cdPointPtr p, int n );
160 
161 // Functions for Compatibility with gd
162 CDDLLIMPEXP int cdImageLine( cdImagePtr im, int x1, int y1, int x2, int y2, int color );
163 CDDLLIMPEXP int cdImageRectangle( cdImagePtr im, int x1, int y1, int x2, int y2, int color );
164 
165 
166 CDDLLIMPEXP int cdImageBoundsSafe( cdImagePtr im, int x, int y );
167 // These put characters in the picture. CGM can handle fonts
168 // (x,y) is the lower left corner of where the text goes
169 CDDLLIMPEXP int cdText( cdImagePtr im, int x, int y, const char * );
170 
171 
172 // Functions for allocating colors
173 CDDLLIMPEXP int cdImageColorAllocate( cdImagePtr im, int r, int g, int b );
174 CDDLLIMPEXP int cdImageColorClosest( cdImagePtr im, int r, int g, int b );
175 CDDLLIMPEXP int cdImageColorExact( cdImagePtr im, int r, int g, int b );
176 CDDLLIMPEXP int cdImageColorDeallocate( cdImagePtr /* im */, int /* color */ );
177 // wogl: the parameter names are commented to avoid compiler warnings
178 CDDLLIMPEXP int cdImageColor16( cdImagePtr im );
179 
180 // gej: functions that set style attributes
181 CDDLLIMPEXP int cdSetLineAttrib( cdImagePtr im, int lntype, int lnwidth, int lncolor );
182 CDDLLIMPEXP int cdSetShapeFillAttrib( cdImagePtr im, int instyle, int incolor, int inhatch );
183 CDDLLIMPEXP int cdSetShapeEdgeAttrib( cdImagePtr im, int edtype, int edwidth, int edcolor, int edvis );
184 CDDLLIMPEXP int cdSetTextAttrib( cdImagePtr im, int font, int color, int height );
185 CDDLLIMPEXP int cdSetMarkerAttrib( cdImagePtr im, int mtype, int msize, int mcolor );
186 
187 // gej: or if you prefer, set the attributes individually
188 CDDLLIMPEXP int cdSetLineType( cdImagePtr im, int lntype );
189 CDDLLIMPEXP int cdSetLineWidth( cdImagePtr im, int lnwidth );
190 CDDLLIMPEXP int cdSetLineColor( cdImagePtr im, int lncolor );
191 CDDLLIMPEXP int cdSetFillStyle( cdImagePtr im, int instyle );
192 CDDLLIMPEXP int cdSetFillColor( cdImagePtr im, int incolor );
193 CDDLLIMPEXP int cdSetFillHatch( cdImagePtr im, int inhatch );
194 CDDLLIMPEXP int cdSetEdgeType( cdImagePtr im, int edtype );
195 CDDLLIMPEXP int cdSetEdgeWidth( cdImagePtr im, int edwidth );
196 CDDLLIMPEXP int cdSetEdgeColor( cdImagePtr im, int edcolor );
197 CDDLLIMPEXP int cdSetEdgeVis( cdImagePtr im, int edvis );
198 CDDLLIMPEXP int cdSetTextFont( cdImagePtr im, int font );
199 CDDLLIMPEXP int cdSetTextColor( cdImagePtr im, int color );
200 CDDLLIMPEXP int cdSetTextHeight( cdImagePtr im, int height );
201 // geJ: these individual attributes can't be set with a group function
202 CDDLLIMPEXP int cdSetTextPath( cdImagePtr im, int tpath );
203 CDDLLIMPEXP int cdSetTextOrient( cdImagePtr im, int xup, int yup, int xbase, int ybase );
204 CDDLLIMPEXP int cdSetMarkerType( cdImagePtr im, int mtype );
205 CDDLLIMPEXP int cdSetMarkerSize( cdImagePtr im, int msize );
206 CDDLLIMPEXP int cdSetMarkerColor( cdImagePtr im, int mcolor );
207 
208 // EJ: Expert Functions, If you just need more control
209 CDDLLIMPEXP int cdImageSetSize( cdImagePtr im, int x, int y );
210 CDDLLIMPEXP int cdImageSetLineSpec( cdImagePtr im, int specmode );
211 CDDLLIMPEXP int cdImageSetMarkerSpec( cdImagePtr im, int specmode );
212 CDDLLIMPEXP int cdImageSetEdgeSpec( cdImagePtr im, int specmode );
213 CDDLLIMPEXP int cdImageSetOutput( cdImagePtr im, FILE *output );
214 CDDLLIMPEXP int cdImageAddFont( cdImagePtr im, const char *fontname );
215 CDDLLIMPEXP int cdImageClearFonts( cdImagePtr im );
216 CDDLLIMPEXP cdImagePtr cdImageStartCgm();
217 CDDLLIMPEXP int cdCgmHeader( cdImagePtr );
218 CDDLLIMPEXP int cdCgmPic( cdImagePtr, int );
219 CDDLLIMPEXP int cdImageSetDefaults( cdImagePtr im );
220 CDDLLIMPEXP int cdImageEndPic( cdImagePtr im );
221 CDDLLIMPEXP int cdImageEndCgm( cdImagePtr im );
222 
223 // Macros to access information about images. READ ONLY. Changing
224 // these values will NOT have the desired result.
225 #define cdImageSX( im ) ( ( im )->sx )
226 #define cdImageSY( im ) ( ( im )->sy )
227 #define cdImageColorsTotal( im ) ( ( im )->colorsTotal )
228 #define cdImageRed( im, c ) ( ( im )->red[( c )] )
229 #define cdImageGreen( im, c ) ( ( im )->green[( c )] )
230 #define cdImageBlue( im, c ) ( ( im )->blue[( c )] )
231 
232 // Source: Independent JPEG Group
233 // In ANSI C, and indeed any rational implementation, size_t is also the
234 // type returned by sizeof(). However, it seems there are some irrational
235 // implementations out there, in which sizeof() returns an int even though
236 // size_t is defined as long or unsigned long. To ensure consistent results
237 // we always use this SIZEOF() macro in place of using sizeof() directly.
238 //
239 
240 #define SIZEOF( object ) ( (size_t) sizeof ( object ) )
241 
242 // GeJ: these are helper functions I use in cd. That means DON'T call
243 // them from your program. Yes, that means you.
244 CDDLLIMPEXP int cdImageColorClear( cdImagePtr im );
245 
246 #if defined ( __cplusplus ) || defined ( c_plusplus )
247 }
248 #endif
249 
250 
251 #endif
CDDLLIMPEXP int cdImageAddFont(cdImagePtr im, const char *fontname)
Definition: cd.c:3163
CDDLLIMPEXP int cdEllipse(cdImagePtr im, int cx, int cy, int d1x, int d1y, int d2x, int d2y)
Definition: cd.c:2524
CDDLLIMPEXP int cdCgmHeader(cdImagePtr)
Definition: cd.c:214
int open[cdMaxColors]
Definition: cd.h:68
CDDLLIMPEXP int cdSetShapeEdgeAttrib(cdImagePtr im, int edtype, int edwidth, int edcolor, int edvis)
Definition: cd.c:1693
CDDLLIMPEXP int cdSetTextFont(cdImagePtr im, int font)
Definition: cd.c:1192
int textcolor
Definition: cd.h:110
CDDLLIMPEXP int cdPolygonSet(cdImagePtr im, cdPointPtr p, int n)
Definition: cd.c:2675
int edgespec
Definition: cd.h:82
struct cdPointStruct * cdPointPtr
CDDLLIMPEXP int cdPolyMarker(cdImagePtr im, cdPointPtr p, int n)
Definition: cd.c:2859
int lwidth
Definition: cd.h:89
CDDLLIMPEXP int cdSetMarkerColor(cdImagePtr im, int mcolor)
Definition: cd.c:1594
int red[cdMaxColors]
Definition: cd.h:65
int shapestyle
Definition: cd.h:93
CDDLLIMPEXP cdImagePtr cdImageCreate(int sx, int sy)
Definition: cd.c:31
int edgecolor
Definition: cd.h:105
unsigned char * fontlist
Definition: cd.h:76
CDDLLIMPEXP int cdImageSetLineSpec(cdImagePtr im, int specmode)
Definition: cd.c:3112
CDDLLIMPEXP int cdImageColorClosest(cdImagePtr im, int r, int g, int b)
Definition: cd.c:1786
CDDLLIMPEXP int cdPolygon(cdImagePtr im, cdPointPtr p, int n)
Definition: cd.c:2581
short int state
Definition: cd.h:64
#define cdMaxColors
Definition: cd.h:30
CDDLLIMPEXP int cdSetTextOrient(cdImagePtr im, int xup, int yup, int xbase, int ybase)
Definition: cd.c:1409
long int listlen
Definition: cd.h:119
int sy
Definition: cd.h:85
int blue[cdMaxColors]
Definition: cd.h:67
CDDLLIMPEXP int cdImageSetDefaults(cdImagePtr im)
Definition: cd.c:3209
CDDLLIMPEXP int cdSetLineAttrib(cdImagePtr im, int lntype, int lnwidth, int lncolor)
Definition: cd.c:1652
CDDLLIMPEXP int cdImageColorAllocate(cdImagePtr im, int r, int g, int b)
Definition: cd.c:1966
CDDLLIMPEXP int cdMarker(cdImagePtr im, int x, int y)
Definition: cd.c:2188
int lcolor
Definition: cd.h:90
int textheight
Definition: cd.h:111
CDDLLIMPEXP int cdCgmPic(cdImagePtr, int)
Definition: cd.c:365
static int color
Definition: ps.c:78
CDDLLIMPEXP int cdCgmNewPic(cdImagePtr im, int sticky)
Definition: cd.c:542
int shapecolor
Definition: cd.h:96
unsigned char * elemlist
Definition: cd.h:63
long int bytestoend
Definition: cd.h:118
int textfont
Definition: cd.h:109
CDDLLIMPEXP int cdImageColor16(cdImagePtr im)
Definition: cd.c:1989
CDDLLIMPEXP int cdImageEndCgm(cdImagePtr im)
Definition: cd.c:3337
int shapehatch
Definition: cd.h:100
int ltype
Definition: cd.h:88
CDDLLIMPEXP int cdImageClearFonts(cdImagePtr im)
Definition: cd.c:3198
CDDLLIMPEXP int cdSetMarkerType(cdImagePtr im, int mtype)
Definition: cd.c:1465
int mcolor
Definition: cd.h:116
CDDLLIMPEXP int cdSetLineWidth(cdImagePtr im, int lnwidth)
Definition: cd.c:631
int edgevis
Definition: cd.h:106
int sx
Definition: cd.h:84
int textpath
Definition: cd.h:112
int mtype
Definition: cd.h:114
int msize
Definition: cd.h:115
CDDLLIMPEXP int cdImageBoundsSafe(cdImagePtr im, int x, int y)
Definition: cd.c:3073
unsigned char * desc
Definition: cd.h:75
CDDLLIMPEXP int cdPolyLine(cdImagePtr im, cdPointPtr p, int n)
Definition: cd.c:2772
CDDLLIMPEXP int cdSetTextColor(cdImagePtr im, int color)
Definition: cd.c:1257
cdImage * cdImagePtr
Definition: cd.h:123
int edgewidth
Definition: cd.h:104
CDDLLIMPEXP int cdSetShapeFillAttrib(cdImagePtr im, int instyle, int incolor, int inhatch)
Definition: cd.c:1668
CDDLLIMPEXP int cdImageLine(cdImagePtr im, int x1, int y1, int x2, int y2, int color)
Definition: cd.c:3034
int markerspec
Definition: cd.h:83
CDDLLIMPEXP int cdSetFillHatch(cdImagePtr im, int inhatch)
Definition: cd.c:880
int green[cdMaxColors]
Definition: cd.h:66
struct cdImageStruct cdImage
CDDLLIMPEXP int cdImageColorExact(cdImagePtr im, int r, int g, int b)
Definition: cd.c:1826
CDDLLIMPEXP int cdImageColorDeallocate(cdImagePtr, int)
Definition: cd.c:2104
CDDLLIMPEXP int cdSetFillStyle(cdImagePtr im, int instyle)
Definition: cd.c:761
int linespec
Definition: cd.h:81
CDDLLIMPEXP int cdImageSetEdgeSpec(cdImagePtr im, int specmode)
Definition: cd.c:3134
unsigned char * curelemlist
Definition: cd.h:120
CDDLLIMPEXP int cdArc3PtClose(cdImagePtr im, int sx, int sy, int ix, int iy, int ex, int ey, int cl)
Definition: cd.c:2458
CDDLLIMPEXP int cdImageDestroy(cdImagePtr im)
Definition: cd.c:1766
CDDLLIMPEXP int cdImageColorClear(cdImagePtr im)
Definition: cd.c:1815
CDDLLIMPEXP int cdCircle(cdImagePtr im, int cx, int cy, int r)
Definition: cd.c:2309
CDDLLIMPEXP int cdText(cdImagePtr im, int x, int y, const char *)
Definition: cd.c:2945
int edgetype
Definition: cd.h:103
short int numfonts
Definition: cd.h:77
CDDLLIMPEXP int cdImageEndPic(cdImagePtr im)
Definition: cd.c:3300
CDDLLIMPEXP int cdSetMarkerSize(cdImagePtr im, int msize)
Definition: cd.c:1522
CDDLLIMPEXP int cdSetEdgeVis(cdImagePtr im, int edvis)
Definition: cd.c:1137
CDDLLIMPEXP int cdSetMarkerAttrib(cdImagePtr im, int mtype, int msize, int mcolor)
Definition: cd.c:1750
struct cdPointStruct cdPoint
CDDLLIMPEXP int cdImageCgm(cdImagePtr im, FILE *)
Definition: cd.c:560
int colorsTotal
Definition: cd.h:69
CDDLLIMPEXP int cdSetEdgeColor(cdImagePtr im, int edcolor)
Definition: cd.c:1080
CDDLLIMPEXP int cdSetEdgeType(cdImagePtr im, int edtype)
Definition: cd.c:947
CDDLLIMPEXP int cdSetTextAttrib(cdImagePtr im, int font, int color, int height)
Definition: cd.c:1720
CDDLLIMPEXP int cdLine(cdImagePtr im, int x1, int y1, int x2, int y2)
Definition: cd.c:2116
CDDLLIMPEXP int cdRectangle(cdImagePtr im, int x1, int y1, int x2, int y2)
Definition: cd.c:2235
CDDLLIMPEXP int cdImageSetMarkerSpec(cdImagePtr im, int specmode)
Definition: cd.c:3123
CDDLLIMPEXP cdImagePtr cdImageStartCgm()
Definition: cd.c:3246
CDDLLIMPEXP int cdImageSetSize(cdImagePtr im, int x, int y)
Definition: cd.c:3104
CDDLLIMPEXP int cdSetTextHeight(cdImagePtr im, int height)
Definition: cd.c:1311
CDDLLIMPEXP int cdSetFillColor(cdImagePtr im, int incolor)
Definition: cd.c:822
int picnum
Definition: cd.h:72
CDDLLIMPEXP int cdSetLineType(cdImagePtr im, int lntype)
Definition: cd.c:574
CDDLLIMPEXP int cdSetLineColor(cdImagePtr im, int lncolor)
Definition: cd.c:703
int y
Definition: cd.h:130
CDDLLIMPEXP int cdImageSetOutput(cdImagePtr im, FILE *output)
Definition: cd.c:3145
CDDLLIMPEXP int cdArc3Pt(cdImagePtr im, int sx, int sy, int ix, int iy, int ex, int ey)
Definition: cd.c:2376
FILE * outfile
Definition: cd.h:78
CDDLLIMPEXP int cdImageRectangle(cdImagePtr im, int x1, int y1, int x2, int y2, int color)
Definition: cd.c:3082
CDDLLIMPEXP int cdSetEdgeWidth(cdImagePtr im, int edwidth)
Definition: cd.c:1010
CDDLLIMPEXP int cdSetTextPath(cdImagePtr im, int tpath)
Definition: cd.c:1357