70 #define SWAP_BALCK_WHEN_WHITE
100 #define use_experimental_hidden_line_hack
102 static int force_edges = 0;
103 static int disable_background = 0;
105 static DrvOpt cgm_options[] = { {
"force_edges",
DRV_INT, &force_edges,
"Force edges to be drawn on filled polygongs (0|1)" },
106 {
"no_paper",
DRV_INT, &disable_background,
"Disable background (0|1)" },
107 { NULL,
DRV_INT, NULL, NULL } };
124 int colour_index[256];
135 int last_line_colour;
137 int last_fill_colour;
144 int disable_background;
148 void plD_line_cgm(
PLStream *,
short,
short,
short,
short );
149 void plD_polyline_cgm(
PLStream *,
short *,
short *,
PLINT );
159 #ifndef ENABLE_DYNDRIVERS
160 pdt->
pl_MenuStr =
"CGM (Computer Graphics metafile) file";
189 free( (
void *)
pls->
dev );
191 pls->
dev = calloc( 1, (
size_t)
sizeof ( cgm_Dev ) );
193 plexit(
"plD_init_cgm_Dev: Out of memory." );
195 dev = (cgm_Dev *)
pls->
dev;
200 dev->force_edges = force_edges;
201 dev->disable_background = disable_background;
204 dev->fill_colour = dev->colour;
205 dev->last_fill_colour = -1;
206 dev->last_line_colour = -1;
238 plD_init_cgm_Dev(
pls );
239 dev = (cgm_Dev *)
pls->
dev;
262 #ifdef use_experimental_hidden_line_hack
264 if ( dev->cgmx > dev->cgmy )
281 plP_setphy( 0, dev->scale * dev->cgmx, 0, dev->scale * dev->cgmy );
291 plD_line_cgm(
PLStream *
pls,
short x1a,
short y1a,
short x2a,
short y2a )
293 cgm_Dev *dev = (cgm_Dev *)
pls->
dev;
294 int x1 = x1a / dev->scale, y1 = y1a / dev->scale, x2 = x2a / dev->scale, y2 = y2a / dev->scale;
304 if ( dev->last_line_colour != dev->colour )
307 dev->last_line_colour = dev->colour;
310 cdLine( dev->im_out, x1, y1, x2, y2 );
322 cgm_Dev *dev = (cgm_Dev *)
pls->
dev;
326 if ( ( points = calloc( npts, (
size_t)
sizeof (
cdPoint ) ) ) == NULL )
328 plexit(
"Memory allocation error in \"plD_polyline_cgm\"" );
331 for ( i = 0; i < npts; i++ )
333 points[i].x = xa[i] / dev->scale;
334 points[i].y = ( ya[i] / dev->scale );
343 if ( dev->last_line_colour != dev->colour )
346 dev->last_line_colour = dev->colour;
363 cgm_Dev *dev = (cgm_Dev *)
pls->
dev;
373 plexit(
"Memory allocation error in \"plD_fill_polygon_cgm\"" );
378 points[i].x =
pls->
dev_x[i] / dev->scale;
379 points[i].y = (
pls->
dev_y[i] / dev->scale );
390 if ( ( dev->fill_colour != dev->last_fill_colour ) || ( dev->force_edges == 1 ) )
400 if ( dev->force_edges == 1 )
406 dev->last_fill_colour = dev->fill_colour;
411 if ( dev->force_edges == 1 )
427 int ncol0 =
pls->
ncol0, total_colours;
429 cgm_Dev *dev = (cgm_Dev *)
pls->
dev;
430 PLFLT tmp_colour_pos;
439 plwarn(
"Too many colours in cmap0." );
446 total_colours = ncol0 + ncol1;
451 ncol1 = total_colours - ncol0;
455 plexit(
"Problem setting colourmap in CGM driver." );
468 #ifdef SWAP_BALCK_WHEN_WHITE
504 for ( i = 0; i < ncol0; i++ )
511 plwarn(
"Problem setting cmap0 in CGM driver." );
523 for ( i = 0; i < ncol1; i++ )
525 if ( ncol1 < pls->ncol1 )
535 tmp_colour_pos = i > 0 ?
pls->
ncol1 * ( (
PLFLT) i / ncol1 ) : 0;
546 cmap1col.
r, cmap1col.
g, cmap1col.
b )
549 plwarn(
"Problem setting cmap1 in CGM driver." );
567 cgm_Dev *dev = (cgm_Dev *)
pls->
dev;
568 PLFLT tmp_colour_pos;
588 plwarn(
"Problem changing colour in \"PLSTATE_COLOR0\"" );
590 dev->colour = dev->totcol;
593 dev->fill_colour = dev->colour;
604 dev->colour =
pls->
ncol0 + (int) tmp_colour_pos;
609 dev->fill_colour = dev->colour;
666 dev = (cgm_Dev *)
pls->
dev;
699 if ( dev->disable_background != 1 )
722 cgm_Dev *dev = (cgm_Dev *)
pls->
dev;
742 cgm_Dev *dev = (cgm_Dev *)
pls->
dev;
750 dev->colour_index[i] = -1;
752 dev->fill_colour = dev->colour;
753 dev->last_fill_colour = -1;
754 dev->last_line_colour = -1;
int cdSetEdgeWidth(cdImagePtr im, int edwidth)
int cdSetLineType(cdImagePtr im, int lntype)
int cdSetEdgeColor(cdImagePtr im, int edcolor)
int cdSetEdgeVis(cdImagePtr im, int edvis)
int cdImageCgm(cdImagePtr im, FILE *out)
int cdCgmNewPic(cdImagePtr im, int sticky)
int cdPolyLine(cdImagePtr im, cdPointPtr p, int n)
int cdLine(cdImagePtr im, int x1, int y1, int x2, int y2)
int cdImageColorClear(cdImagePtr im)
int cdPolygon(cdImagePtr im, cdPointPtr p, int n)
int cdImageColorAllocate(cdImagePtr im, int r, int g, int b)
int cdSetLineWidth(cdImagePtr im, int lnwidth)
int cdSetFillColor(cdImagePtr im, int incolor)
int cdSetFillStyle(cdImagePtr im, int instyle)
int cdRectangle(cdImagePtr im, int x1, int y1, int x2, int y2)
int cdSetLineColor(cdImagePtr im, int lncolor)
int cdImageDestroy(cdImagePtr im)
cdImagePtr cdImageCreate(int sx, int sy)
void(* plD_tidy_fp)(struct PLStream_struct *)
void(* plD_eop_fp)(struct PLStream_struct *)
void(* plD_line_fp)(struct PLStream_struct *, short, short, short, short)
void(* plD_init_fp)(struct PLStream_struct *)
void(* plD_polyline_fp)(struct PLStream_struct *, short *, short *, PLINT)
void(* plD_esc_fp)(struct PLStream_struct *, PLINT, void *)
void(* plD_state_fp)(struct PLStream_struct *, PLINT)
void(* plD_bop_fp)(struct PLStream_struct *)
PLDLLIMPEXP_DRIVER void plD_dispatch_init_cgm(PLDispatchTable *pdt)
int plParseDrvOpts(DrvOpt *acc_opt)
void plP_setpxl(PLFLT xpmm, PLFLT ypmm)
void plP_setphy(PLINT xmin, PLINT xmax, PLINT ymin, PLINT ymax)
static PLStream * pls[PL_NSTREAMS]
void plFamInit(PLStream *pls)
void plwarn(PLCHAR_VECTOR errormsg)
void plcol_interp(PLStream *pls, PLColor *newcolor, int i, int ncol)
void plCloseFile(PLStream *pls)
void plOpenFile(PLStream *pls)
void plexit(PLCHAR_VECTOR errormsg)
void plGetFam(PLStream *pls)
#define PLDLLIMPEXP_DRIVER
#define PLPLOT_MM_PER_INCH
#define PLPLOT_DEFAULT_WIDTH_PIXELS
#define PLPLOT_DEFAULT_HEIGHT_PIXELS
#define PLPLOT_DEFAULT_PIXELS_PER_INCH
static void fill_polygon(PLStream *pls)
plD_polyline_fp pl_polyline