PLplot 5.15.0
Loading...
Searching...
No Matches
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 )
57extern "C" {
58#endif
59
60typedef 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
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.
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
113 // Marker type, Marker size, marker color
114 int mtype;
115 int msize;
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
122
124
125
126// Point type for use in polygon drawing.
127
128typedef struct cdPointStruct
129{
130 int x, y, e;
132
133
134
135// Functions to manipulate images.
136
137CDDLLIMPEXP cdImagePtr cdImageCreate( int sx, int sy );
138CDDLLIMPEXP int cdCgmNewPic( cdImagePtr im, int sticky );
139CDDLLIMPEXP int cdImageCgm( cdImagePtr im, FILE * );
140CDDLLIMPEXP int cdImageDestroy( cdImagePtr im );
141
142// Use cdLine, not cdImageLine
143CDDLLIMPEXP 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.
146CDDLLIMPEXP int cdRectangle( cdImagePtr im, int x1, int y1, int x2, int y2 );
147// center x, then center y, then radius of circle
148CDDLLIMPEXP int cdCircle( cdImagePtr im, int cx, int cy, int r );
149// start, middle and end of arc
150CDDLLIMPEXP 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
152CDDLLIMPEXP int cdArc3PtClose( cdImagePtr im, int sx, int sy, int ix, int iy, int ex, int ey, int cl );
153CDDLLIMPEXP int cdEllipse( cdImagePtr im, int cx, int cy, int d1x, int d1y, int d2x, int d2y );
154CDDLLIMPEXP int cdMarker( cdImagePtr im, int x, int y );
155// polyshapes
156CDDLLIMPEXP int cdPolygon( cdImagePtr im, cdPointPtr p, int n );
157CDDLLIMPEXP int cdPolygonSet( cdImagePtr im, cdPointPtr p, int n );
158CDDLLIMPEXP int cdPolyLine( cdImagePtr im, cdPointPtr p, int n );
159CDDLLIMPEXP int cdPolyMarker( cdImagePtr im, cdPointPtr p, int n );
160
161// Functions for Compatibility with gd
162CDDLLIMPEXP int cdImageLine( cdImagePtr im, int x1, int y1, int x2, int y2, int color );
163CDDLLIMPEXP int cdImageRectangle( cdImagePtr im, int x1, int y1, int x2, int y2, int color );
164
165
166CDDLLIMPEXP 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
169CDDLLIMPEXP int cdText( cdImagePtr im, int x, int y, const char * );
170
171
172// Functions for allocating colors
173CDDLLIMPEXP int cdImageColorAllocate( cdImagePtr im, int r, int g, int b );
174CDDLLIMPEXP int cdImageColorClosest( cdImagePtr im, int r, int g, int b );
175CDDLLIMPEXP int cdImageColorExact( cdImagePtr im, int r, int g, int b );
176CDDLLIMPEXP int cdImageColorDeallocate( cdImagePtr /* im */, int /* color */ );
177// wogl: the parameter names are commented to avoid compiler warnings
178CDDLLIMPEXP int cdImageColor16( cdImagePtr im );
179
180// gej: functions that set style attributes
181CDDLLIMPEXP int cdSetLineAttrib( cdImagePtr im, int lntype, int lnwidth, int lncolor );
182CDDLLIMPEXP int cdSetShapeFillAttrib( cdImagePtr im, int instyle, int incolor, int inhatch );
183CDDLLIMPEXP int cdSetShapeEdgeAttrib( cdImagePtr im, int edtype, int edwidth, int edcolor, int edvis );
184CDDLLIMPEXP int cdSetTextAttrib( cdImagePtr im, int font, int color, int height );
185CDDLLIMPEXP int cdSetMarkerAttrib( cdImagePtr im, int mtype, int msize, int mcolor );
186
187// gej: or if you prefer, set the attributes individually
188CDDLLIMPEXP int cdSetLineType( cdImagePtr im, int lntype );
189CDDLLIMPEXP int cdSetLineWidth( cdImagePtr im, int lnwidth );
190CDDLLIMPEXP int cdSetLineColor( cdImagePtr im, int lncolor );
191CDDLLIMPEXP int cdSetFillStyle( cdImagePtr im, int instyle );
192CDDLLIMPEXP int cdSetFillColor( cdImagePtr im, int incolor );
193CDDLLIMPEXP int cdSetFillHatch( cdImagePtr im, int inhatch );
194CDDLLIMPEXP int cdSetEdgeType( cdImagePtr im, int edtype );
195CDDLLIMPEXP int cdSetEdgeWidth( cdImagePtr im, int edwidth );
196CDDLLIMPEXP int cdSetEdgeColor( cdImagePtr im, int edcolor );
197CDDLLIMPEXP int cdSetEdgeVis( cdImagePtr im, int edvis );
198CDDLLIMPEXP int cdSetTextFont( cdImagePtr im, int font );
199CDDLLIMPEXP int cdSetTextColor( cdImagePtr im, int color );
200CDDLLIMPEXP int cdSetTextHeight( cdImagePtr im, int height );
201// geJ: these individual attributes can't be set with a group function
202CDDLLIMPEXP int cdSetTextPath( cdImagePtr im, int tpath );
203CDDLLIMPEXP int cdSetTextOrient( cdImagePtr im, int xup, int yup, int xbase, int ybase );
204CDDLLIMPEXP int cdSetMarkerType( cdImagePtr im, int mtype );
205CDDLLIMPEXP int cdSetMarkerSize( cdImagePtr im, int msize );
206CDDLLIMPEXP int cdSetMarkerColor( cdImagePtr im, int mcolor );
207
208// EJ: Expert Functions, If you just need more control
209CDDLLIMPEXP int cdImageSetSize( cdImagePtr im, int x, int y );
210CDDLLIMPEXP int cdImageSetLineSpec( cdImagePtr im, int specmode );
211CDDLLIMPEXP int cdImageSetMarkerSpec( cdImagePtr im, int specmode );
212CDDLLIMPEXP int cdImageSetEdgeSpec( cdImagePtr im, int specmode );
213CDDLLIMPEXP int cdImageSetOutput( cdImagePtr im, FILE *output );
214CDDLLIMPEXP int cdImageAddFont( cdImagePtr im, const char *fontname );
215CDDLLIMPEXP int cdImageClearFonts( cdImagePtr im );
216CDDLLIMPEXP cdImagePtr cdImageStartCgm();
217CDDLLIMPEXP int cdCgmHeader( cdImagePtr );
218CDDLLIMPEXP int cdCgmPic( cdImagePtr, int );
219CDDLLIMPEXP int cdImageSetDefaults( cdImagePtr im );
220CDDLLIMPEXP int cdImageEndPic( cdImagePtr im );
221CDDLLIMPEXP 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.
244CDDLLIMPEXP int cdImageColorClear( cdImagePtr im );
245
246#if defined ( __cplusplus ) || defined ( c_plusplus )
247}
248#endif
249
250
251#endif
CDDLLIMPEXP int cdImageColorExact(cdImagePtr im, int r, int g, int b)
Definition: cd.c:1826
CDDLLIMPEXP int cdSetTextColor(cdImagePtr im, int color)
Definition: cd.c:1257
CDDLLIMPEXP int cdSetLineColor(cdImagePtr im, int lncolor)
Definition: cd.c:703
CDDLLIMPEXP cdImagePtr cdImageStartCgm()
Definition: cd.c:3246
CDDLLIMPEXP int cdImageColorClear(cdImagePtr im)
Definition: cd.c:1815
CDDLLIMPEXP int cdImageSetEdgeSpec(cdImagePtr im, int specmode)
Definition: cd.c:3134
CDDLLIMPEXP int cdSetTextFont(cdImagePtr im, int font)
Definition: cd.c:1192
CDDLLIMPEXP int cdMarker(cdImagePtr im, int x, int y)
Definition: cd.c:2188
CDDLLIMPEXP int cdSetTextAttrib(cdImagePtr im, int font, int color, int height)
Definition: cd.c:1720
CDDLLIMPEXP int cdImageColorAllocate(cdImagePtr im, int r, int g, int b)
Definition: cd.c:1966
CDDLLIMPEXP int cdImageBoundsSafe(cdImagePtr im, int x, int y)
Definition: cd.c:3073
CDDLLIMPEXP int cdLine(cdImagePtr im, int x1, int y1, int x2, int y2)
Definition: cd.c:2116
struct cdImageStruct cdImage
CDDLLIMPEXP int cdPolyMarker(cdImagePtr im, cdPointPtr p, int n)
Definition: cd.c:2859
CDDLLIMPEXP int cdText(cdImagePtr im, int x, int y, const char *)
Definition: cd.c:2945
struct cdPointStruct cdPoint
CDDLLIMPEXP int cdSetMarkerType(cdImagePtr im, int mtype)
Definition: cd.c:1465
CDDLLIMPEXP int cdSetTextPath(cdImagePtr im, int tpath)
Definition: cd.c:1357
CDDLLIMPEXP int cdCgmPic(cdImagePtr, int)
Definition: cd.c:365
CDDLLIMPEXP int cdPolyLine(cdImagePtr im, cdPointPtr p, int n)
Definition: cd.c:2772
CDDLLIMPEXP int cdImageSetMarkerSpec(cdImagePtr im, int specmode)
Definition: cd.c:3123
CDDLLIMPEXP int cdImageLine(cdImagePtr im, int x1, int y1, int x2, int y2, int color)
Definition: cd.c:3034
CDDLLIMPEXP int cdSetEdgeWidth(cdImagePtr im, int edwidth)
Definition: cd.c:1010
CDDLLIMPEXP int cdImageSetSize(cdImagePtr im, int x, int y)
Definition: cd.c:3104
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 cdSetFillHatch(cdImagePtr im, int inhatch)
Definition: cd.c:880
CDDLLIMPEXP cdImagePtr cdImageCreate(int sx, int sy)
Definition: cd.c:31
CDDLLIMPEXP int cdSetMarkerColor(cdImagePtr im, int mcolor)
Definition: cd.c:1594
CDDLLIMPEXP int cdImageSetLineSpec(cdImagePtr im, int specmode)
Definition: cd.c:3112
CDDLLIMPEXP int cdImageColor16(cdImagePtr im)
Definition: cd.c:1989
CDDLLIMPEXP int cdSetShapeFillAttrib(cdImagePtr im, int instyle, int incolor, int inhatch)
Definition: cd.c:1668
CDDLLIMPEXP int cdImageRectangle(cdImagePtr im, int x1, int y1, int x2, int y2, int color)
Definition: cd.c:3082
CDDLLIMPEXP int cdImageSetOutput(cdImagePtr im, FILE *output)
Definition: cd.c:3145
CDDLLIMPEXP int cdImageAddFont(cdImagePtr im, const char *fontname)
Definition: cd.c:3163
CDDLLIMPEXP int cdImageColorClosest(cdImagePtr im, int r, int g, int b)
Definition: cd.c:1786
CDDLLIMPEXP int cdSetMarkerSize(cdImagePtr im, int msize)
Definition: cd.c:1522
CDDLLIMPEXP int cdSetEdgeType(cdImagePtr im, int edtype)
Definition: cd.c:947
CDDLLIMPEXP int cdSetTextHeight(cdImagePtr im, int height)
Definition: cd.c:1311
CDDLLIMPEXP int cdCircle(cdImagePtr im, int cx, int cy, int r)
Definition: cd.c:2309
CDDLLIMPEXP int cdPolygonSet(cdImagePtr im, cdPointPtr p, int n)
Definition: cd.c:2675
struct cdPointStruct * cdPointPtr
CDDLLIMPEXP int cdPolygon(cdImagePtr im, cdPointPtr p, int n)
Definition: cd.c:2581
CDDLLIMPEXP int cdSetLineWidth(cdImagePtr im, int lnwidth)
Definition: cd.c:631
cdImage * cdImagePtr
Definition: cd.h:123
CDDLLIMPEXP int cdRectangle(cdImagePtr im, int x1, int y1, int x2, int y2)
Definition: cd.c:2235
CDDLLIMPEXP int cdImageCgm(cdImagePtr im, FILE *)
Definition: cd.c:560
CDDLLIMPEXP int cdImageEndPic(cdImagePtr im)
Definition: cd.c:3300
CDDLLIMPEXP int cdSetLineType(cdImagePtr im, int lntype)
Definition: cd.c:574
CDDLLIMPEXP int cdCgmHeader(cdImagePtr)
Definition: cd.c:214
CDDLLIMPEXP int cdImageColorDeallocate(cdImagePtr, int)
Definition: cd.c:2104
CDDLLIMPEXP int cdImageClearFonts(cdImagePtr im)
Definition: cd.c:3198
CDDLLIMPEXP int cdSetEdgeColor(cdImagePtr im, int edcolor)
Definition: cd.c:1080
#define cdMaxColors
Definition: cd.h:30
CDDLLIMPEXP int cdSetShapeEdgeAttrib(cdImagePtr im, int edtype, int edwidth, int edcolor, int edvis)
Definition: cd.c:1693
CDDLLIMPEXP int cdSetTextOrient(cdImagePtr im, int xup, int yup, int xbase, int ybase)
Definition: cd.c:1409
CDDLLIMPEXP int cdSetLineAttrib(cdImagePtr im, int lntype, int lnwidth, int lncolor)
Definition: cd.c:1652
CDDLLIMPEXP int cdSetFillColor(cdImagePtr im, int incolor)
Definition: cd.c:822
CDDLLIMPEXP int cdSetFillStyle(cdImagePtr im, int instyle)
Definition: cd.c:761
CDDLLIMPEXP int cdEllipse(cdImagePtr im, int cx, int cy, int d1x, int d1y, int d2x, int d2y)
Definition: cd.c:2524
CDDLLIMPEXP int cdImageEndCgm(cdImagePtr im)
Definition: cd.c:3337
CDDLLIMPEXP int cdImageDestroy(cdImagePtr im)
Definition: cd.c:1766
CDDLLIMPEXP int cdSetEdgeVis(cdImagePtr im, int edvis)
Definition: cd.c:1137
CDDLLIMPEXP int cdImageSetDefaults(cdImagePtr im)
Definition: cd.c:3209
CDDLLIMPEXP int cdArc3Pt(cdImagePtr im, int sx, int sy, int ix, int iy, int ex, int ey)
Definition: cd.c:2376
CDDLLIMPEXP int cdSetMarkerAttrib(cdImagePtr im, int mtype, int msize, int mcolor)
Definition: cd.c:1750
CDDLLIMPEXP int cdCgmNewPic(cdImagePtr im, int sticky)
Definition: cd.c:542
static int color
Definition: ps.c:78
int mcolor
Definition: cd.h:116
int sy
Definition: cd.h:85
int shapestyle
Definition: cd.h:93
unsigned char * desc
Definition: cd.h:75
int edgewidth
Definition: cd.h:104
short int numfonts
Definition: cd.h:77
int textfont
Definition: cd.h:109
int shapecolor
Definition: cd.h:96
unsigned char * curelemlist
Definition: cd.h:120
int textpath
Definition: cd.h:112
FILE * outfile
Definition: cd.h:78
long int bytestoend
Definition: cd.h:118
int markerspec
Definition: cd.h:83
int edgecolor
Definition: cd.h:105
int picnum
Definition: cd.h:72
int msize
Definition: cd.h:115
long int listlen
Definition: cd.h:119
int linespec
Definition: cd.h:81
int red[cdMaxColors]
Definition: cd.h:65
int edgevis
Definition: cd.h:106
unsigned char * fontlist
Definition: cd.h:76
int colorsTotal
Definition: cd.h:69
int lwidth
Definition: cd.h:89
int blue[cdMaxColors]
Definition: cd.h:67
unsigned char * elemlist
Definition: cd.h:63
int textcolor
Definition: cd.h:110
int ltype
Definition: cd.h:88
short int state
Definition: cd.h:64
int edgespec
Definition: cd.h:82
int shapehatch
Definition: cd.h:100
int lcolor
Definition: cd.h:90
int mtype
Definition: cd.h:114
int sx
Definition: cd.h:84
int textheight
Definition: cd.h:111
int open[cdMaxColors]
Definition: cd.h:68
int edgetype
Definition: cd.h:103
int green[cdMaxColors]
Definition: cd.h:66
int x
Definition: cd.h:130
int e
Definition: cd.h:130
int y
Definition: cd.h:130