PLplot
5.10.0
|
00001 #ifndef CD_H 00002 #define CD_H 1 00003 00004 // cd.h: declarations file for the cgmdraw module. 00005 // 00006 // Written by G. Edward Johnson <mailto:lorax@nist.gov> 00007 // Date: April 1996 00008 // Copyright: cd software produced by NIST, an agency of the 00009 // U.S. government, is by statute not subject to copyright 00010 // in the United States. Recipients of this software assume all 00011 // responsibilities associated with its operation, modification 00012 // and maintenance. 00013 // 00014 // Portions of this package are from the gd package written by 00015 // Thomas Boutell and are copyright 1994, 1995, Quest Protein 00016 // Database Center, Cold Spring Harbor Labs. They are marked in the 00017 // source code. 00018 // 00019 // 00020 00021 // #include <prof.h> 00022 00023 // stdio is needed for file I/O. 00024 #include <stdio.h> 00025 #include "cddll.h" 00026 // This can not be changed to a value larger than 256, though smaller 00027 // values can be used. 00028 // 00029 00030 #define cdMaxColors 256 00031 00032 // If you know you will be working with large pictures, increase the values 00033 // of the next two constants. 00034 // 00035 00036 // The initial size of the element list. When it fills up, we will just 00037 // make it bigger. Starting with a larger number reduces the frequency of 00038 // the list growing, but increases the memory needed for small pictures 00039 // 00040 00041 #define CDSTARTLISTSIZE 4096 00042 00043 // How much the element list grows by. When the list fills up, we allocate 00044 // a new larger list. This number is how much larger. using a larger number 00045 // decreases the frequency of the list growing, but if only a small amount 00046 // more is needed, it could waste memory 00047 // 00048 00049 #define CDGROWLISTSIZE 2048 00050 00051 // Image type. See functions below; you will not need to change 00052 // the elements directly. Use the provided macros to 00053 // access sx, sy, the color table, and colorsTotal for 00054 // read-only purposes. 00055 00056 #if defined ( __cplusplus ) || defined ( c_plusplus ) 00057 extern "C" { 00058 #endif 00059 00060 typedef struct cdImageStruct 00061 { 00062 // Don't mess with these 00063 unsigned char * elemlist; 00064 short int state; 00065 int red[cdMaxColors]; 00066 int green[cdMaxColors]; 00067 int blue[cdMaxColors]; 00068 int open[cdMaxColors]; 00069 int colorsTotal; 00070 // You can have multiple pictures in the file, this keeps track 00071 // of which one you are on 00072 int picnum; 00073 // these take effect only when the first picture is created. 00074 // subsequent changes have no effect 00075 unsigned char *desc; 00076 unsigned char *fontlist; 00077 short int numfonts; 00078 FILE *outfile; 00079 // these take effect when a new picture is opened. Subsequent 00080 // changes are for the next picture 00081 int linespec; 00082 int edgespec; 00083 int markerspec; 00084 int sx; 00085 int sy; 00086 // these take effect immediately 00087 // Linetype, line width, line color have a broader scope in CGM 00088 int ltype; 00089 int lwidth; 00090 int lcolor; 00091 // interior style [of filled objects] (for me) can be empty, hollow, 00092 // solid, hatch [don't do pattern, geometric pattern, interpolated 00093 int shapestyle; 00094 // fill color, color used on inside of closed objects, significant 00095 // if interior style is hollow, solid, hatch, or geometric pattern 00096 int shapecolor; 00097 // hatch index, which hatch style to use, 1=horizontal, 2=vertical, 00098 // 3=pos.slope, 4=neg.slope, 5=hor/vert.crosshatch, 00099 // 6=pos/neg.crosshatch 00100 int shapehatch; 00101 // The edges of filled shapes can have line styles too. They 00102 // correspond to the ones for lines. These next few set them. 00103 int edgetype; 00104 int edgewidth; 00105 int edgecolor; 00106 int edgevis; // is the edge visible or invisible 00107 // now for the TEXT related attributes, Text Color, Text Height, 00108 // and Text font index 00109 int textfont; 00110 int textcolor; 00111 int textheight; 00112 int textpath; 00113 // Marker type, Marker size, marker color 00114 int mtype; 00115 int msize; 00116 int mcolor; 00117 // the next three are used for maintaining the element list 00118 long int bytestoend; // number of bytes to end of the element list 00119 long int listlen; // the total length of the element list 00120 unsigned char * curelemlist; // where we curently are in the list 00121 } cdImage; 00122 00123 typedef cdImage * cdImagePtr; 00124 00125 00126 // Point type for use in polygon drawing. 00127 00128 typedef struct cdPointStruct 00129 { 00130 int x, y, e; 00131 } cdPoint, *cdPointPtr; 00132 00133 00134 00135 // Functions to manipulate images. 00136 00137 CDDLLIMPEXP cdImagePtr cdImageCreate( int sx, int sy ); 00138 CDDLLIMPEXP int cdCgmNewPic( cdImagePtr im, int sticky ); 00139 CDDLLIMPEXP int cdImageCgm( cdImagePtr im, FILE * ); 00140 CDDLLIMPEXP int cdImageDestroy( cdImagePtr im ); 00141 00142 // Use cdLine, not cdImageLine 00143 CDDLLIMPEXP int cdLine( cdImagePtr im, int x1, int y1, int x2, int y2 ); 00144 // Corners specified (not width and height). Upper left first, lower right 00145 // second. 00146 CDDLLIMPEXP int cdRectangle( cdImagePtr im, int x1, int y1, int x2, int y2 ); 00147 // center x, then center y, then radius of circle 00148 CDDLLIMPEXP int cdCircle( cdImagePtr im, int cx, int cy, int r ); 00149 // start, middle and end of arc 00150 CDDLLIMPEXP int cdArc3Pt( cdImagePtr im, int sx, int sy, int ix, int iy, int ex, int ey ); 00151 // cl is 0 for pie closure, 1 for cord closure 00152 CDDLLIMPEXP int cdArc3PtClose( cdImagePtr im, int sx, int sy, int ix, int iy, int ex, int ey, int cl ); 00153 CDDLLIMPEXP int cdEllipse( cdImagePtr im, int cx, int cy, int d1x, int d1y, int d2x, int d2y ); 00154 CDDLLIMPEXP int cdMarker( cdImagePtr im, int x, int y ); 00155 // polyshapes 00156 CDDLLIMPEXP int cdPolygon( cdImagePtr im, cdPointPtr p, int n ); 00157 CDDLLIMPEXP int cdPolygonSet( cdImagePtr im, cdPointPtr p, int n ); 00158 CDDLLIMPEXP int cdPolyLine( cdImagePtr im, cdPointPtr p, int n ); 00159 CDDLLIMPEXP int cdPolyMarker( cdImagePtr im, cdPointPtr p, int n ); 00160 00161 // Functions for Compatibility with gd 00162 CDDLLIMPEXP int cdImageLine( cdImagePtr im, int x1, int y1, int x2, int y2, int color ); 00163 CDDLLIMPEXP int cdImageRectangle( cdImagePtr im, int x1, int y1, int x2, int y2, int color ); 00164 00165 00166 CDDLLIMPEXP int cdImageBoundsSafe( cdImagePtr im, int x, int y ); 00167 // These put characters in the picture. CGM can handle fonts 00168 // (x,y) is the lower left corner of where the text goes 00169 CDDLLIMPEXP int cdText( cdImagePtr im, int x, int y, const char * ); 00170 00171 00172 // Functions for allocating colors 00173 CDDLLIMPEXP int cdImageColorAllocate( cdImagePtr im, int r, int g, int b ); 00174 CDDLLIMPEXP int cdImageColorClosest( cdImagePtr im, int r, int g, int b ); 00175 CDDLLIMPEXP int cdImageColorExact( cdImagePtr im, int r, int g, int b ); 00176 CDDLLIMPEXP int cdImageColorDeallocate( cdImagePtr /* im */, int /* color */ ); 00177 // wogl: the parameter names are commented to avoid compiler warnings 00178 CDDLLIMPEXP int cdImageColor16( cdImagePtr im ); 00179 00180 // gej: functions that set style attributes 00181 CDDLLIMPEXP int cdSetLineAttrib( cdImagePtr im, int lntype, int lnwidth, int lncolor ); 00182 CDDLLIMPEXP int cdSetShapeFillAttrib( cdImagePtr im, int instyle, int incolor, int inhatch ); 00183 CDDLLIMPEXP int cdSetShapeEdgeAttrib( cdImagePtr im, int edtype, int edwidth, int edcolor, int edvis ); 00184 CDDLLIMPEXP int cdSetTextAttrib( cdImagePtr im, int font, int color, int height ); 00185 CDDLLIMPEXP int cdSetMarkerAttrib( cdImagePtr im, int mtype, int msize, int mcolor ); 00186 00187 // gej: or if you prefer, set the attributes individually 00188 CDDLLIMPEXP int cdSetLineType( cdImagePtr im, int lntype ); 00189 CDDLLIMPEXP int cdSetLineWidth( cdImagePtr im, int lnwidth ); 00190 CDDLLIMPEXP int cdSetLineColor( cdImagePtr im, int lncolor ); 00191 CDDLLIMPEXP int cdSetFillStyle( cdImagePtr im, int instyle ); 00192 CDDLLIMPEXP int cdSetFillColor( cdImagePtr im, int incolor ); 00193 CDDLLIMPEXP int cdSetFillHatch( cdImagePtr im, int inhatch ); 00194 CDDLLIMPEXP int cdSetEdgeType( cdImagePtr im, int edtype ); 00195 CDDLLIMPEXP int cdSetEdgeWidth( cdImagePtr im, int edwidth ); 00196 CDDLLIMPEXP int cdSetEdgeColor( cdImagePtr im, int edcolor ); 00197 CDDLLIMPEXP int cdSetEdgeVis( cdImagePtr im, int edvis ); 00198 CDDLLIMPEXP int cdSetTextFont( cdImagePtr im, int font ); 00199 CDDLLIMPEXP int cdSetTextColor( cdImagePtr im, int color ); 00200 CDDLLIMPEXP int cdSetTextHeight( cdImagePtr im, int height ); 00201 // geJ: these individual attributes can't be set with a group function 00202 CDDLLIMPEXP int cdSetTextPath( cdImagePtr im, int tpath ); 00203 CDDLLIMPEXP int cdSetTextOrient( cdImagePtr im, int xup, int yup, int xbase, int ybase ); 00204 CDDLLIMPEXP int cdSetMarkerType( cdImagePtr im, int mtype ); 00205 CDDLLIMPEXP int cdSetMarkerSize( cdImagePtr im, int msize ); 00206 CDDLLIMPEXP int cdSetMarkerColor( cdImagePtr im, int mcolor ); 00207 00208 // EJ: Expert Functions, If you just need more control 00209 CDDLLIMPEXP int cdImageSetSize( cdImagePtr im, int x, int y ); 00210 CDDLLIMPEXP int cdImageSetLineSpec( cdImagePtr im, int specmode ); 00211 CDDLLIMPEXP int cdImageSetMarkerSpec( cdImagePtr im, int specmode ); 00212 CDDLLIMPEXP int cdImageSetEdgeSpec( cdImagePtr im, int specmode ); 00213 CDDLLIMPEXP int cdImageSetOutput( cdImagePtr im, FILE *output ); 00214 CDDLLIMPEXP int cdImageAddFont( cdImagePtr im, const char *fontname ); 00215 CDDLLIMPEXP int cdImageClearFonts( cdImagePtr im ); 00216 CDDLLIMPEXP cdImagePtr cdImageStartCgm(); 00217 CDDLLIMPEXP int cdCgmHeader( cdImagePtr ); 00218 CDDLLIMPEXP int cdCgmPic( cdImagePtr, int ); 00219 CDDLLIMPEXP int cdImageSetDefaults( cdImagePtr im ); 00220 CDDLLIMPEXP int cdImageEndPic( cdImagePtr im ); 00221 CDDLLIMPEXP int cdImageEndCgm( cdImagePtr im ); 00222 00223 // Macros to access information about images. READ ONLY. Changing 00224 // these values will NOT have the desired result. 00225 #define cdImageSX( im ) ( ( im )->sx ) 00226 #define cdImageSY( im ) ( ( im )->sy ) 00227 #define cdImageColorsTotal( im ) ( ( im )->colorsTotal ) 00228 #define cdImageRed( im, c ) ( ( im )->red[( c )] ) 00229 #define cdImageGreen( im, c ) ( ( im )->green[( c )] ) 00230 #define cdImageBlue( im, c ) ( ( im )->blue[( c )] ) 00231 00232 // Source: Independent JPEG Group 00233 // In ANSI C, and indeed any rational implementation, size_t is also the 00234 // type returned by sizeof(). However, it seems there are some irrational 00235 // implementations out there, in which sizeof() returns an int even though 00236 // size_t is defined as long or unsigned long. To ensure consistent results 00237 // we always use this SIZEOF() macro in place of using sizeof() directly. 00238 // 00239 00240 #define SIZEOF( object ) ( (size_t) sizeof ( object ) ) 00241 00242 // GeJ: these are helper functions I use in cd. That means DON'T call 00243 // them from your program. Yes, that means you. 00244 CDDLLIMPEXP int cdImageColorClear( cdImagePtr im ); 00245 00246 #if defined ( __cplusplus ) || defined ( c_plusplus ) 00247 } 00248 #endif 00249 00250 00251 #endif