diff -ur --new-file transfig.3.2.3d.orig/doc/fig2dev.1 transfig.3.2.3d/doc/fig2dev.1 --- transfig.3.2.3d.orig/doc/fig2dev.1 Tue May 29 21:13:26 2001 +++ transfig.3.2.3d/doc/fig2dev.1 Fri Jun 21 12:27:04 2002 @@ -42,7 +42,7 @@ .LP Xfig version 3.2.3 and later saves and allows the user to edit comments for each Fig object. These comments are output with several of the output languages, -such as PostScript, CGM, LaTeX, MetaFont, PicTeX, (as % comments), +such as PostScript, CGM, SML, LaTeX, MetaFont, PicTeX, (as % comments), tk (as # comments), and pic (as .\\" comments). .SH GENERAL OPTIONS @@ -52,7 +52,7 @@ Valid languages are \fBbox, cgm, epic, eepic, eepicemu, eps, gif, ibmgl, jpeg, latex, map (HTML image map), mf (MetaFont), mp (MetaPost), mmp (MultiMetaPost), -pcx, pdf, pic, pictex, png, ppm, ps, +pcx, pdf, pic, pictex, png, ppm, ps, sml, sxd, pstex, pstex_t, sld (AutoCad slide format), textyl, \fR tiff, tk (tcl/tk), tpic, xbm and .B xpm. diff -ur --new-file transfig.3.2.3d.orig/fig2dev/Imakefile transfig.3.2.3d/fig2dev/Imakefile --- transfig.3.2.3d.orig/fig2dev/Imakefile Thu Apr 19 19:19:38 2001 +++ transfig.3.2.3d/fig2dev/Imakefile Wed Jul 17 10:45:55 2002 @@ -290,6 +290,7 @@ InstallScript(fig2ps2tex,$(BINDIR)) InstallScript(fig2ps2tex.sh,$(BINDIR)) InstallScript(pic2tpic,$(BINDIR)) +InstallScript(fig2sxd,$(BINDIR)) InstallManPage(fig2ps2tex,$(MANDIR)) InstallManPage(pic2tpic,$(MANDIR)) diff -ur --new-file transfig.3.2.3d.orig/fig2dev/Makefile.noimake transfig.3.2.3d/fig2dev/Makefile.noimake --- transfig.3.2.3d.orig/fig2dev/Makefile.noimake Tue May 29 21:16:37 2001 +++ transfig.3.2.3d/fig2dev/Makefile.noimake Wed Jul 17 10:42:57 2002 @@ -720,6 +720,11 @@ else (set -x; $(MKDIRHIER) $(DESTDIR)$(BINDIR)); fi $(INSTALL) $(INSTALLFLAGS) $(INSTBINFLAGS) pic2tpic.script $(DESTDIR)$(BINDIR)/pic2tpic +install:: fig2sxd.sh + @if [ -d $(DESTDIR)$(BINDIR) ]; then set +x; \ + else (set -x; $(MKDIRHIER) $(DESTDIR)$(BINDIR)); fi + $(INSTALL) $(INSTALLFLAGS) $(INSTBINFLAGS) fig2sxd.sh $(DESTDIR)$(BINDIR)/fig2sxd.sh + install.man:: fig2ps2tex.man @if [ -d $(DESTDIR)$(MANDIR) ]; then set +x; \ else (set -x; $(MKDIRHIER) $(DESTDIR)$(MANDIR)); fi diff -ur --new-file transfig.3.2.3d.orig/fig2dev/dev/Imakefile transfig.3.2.3d/fig2dev/dev/Imakefile --- transfig.3.2.3d.orig/fig2dev/dev/Imakefile Thu Feb 15 18:45:35 2001 +++ transfig.3.2.3d/fig2dev/dev/Imakefile Sun Jan 13 21:20:35 2002 @@ -38,12 +38,12 @@ READJPGO=readjpg.o #endif -SRCS = genbox.c gencgm.c genepic.c genibmgl.c genlatex.c genmap.c genmf.c genpic.c \ +SRCS = genbox.c gencgm.c genepic.c genibmgl.c genlatex.c gensml.c gensxd.c genmap.c genmf.c genpic.c \ genpictex.c genps.c genpdf.c genpstex.c gentextyl.c gentk.c gentpic.c \ genbitmaps.c genge.c genmp.c setfigfont.c psencode.c \ readpics.c readeps.c readgif.c readpcx.c readppm.c \ readxbm.c readtif.c $(READPNGS) $(READJPGS) $(READXPMS) -LIBOBJS = genbox.o gencgm.o genepic.o genibmgl.o genlatex.o genmap.o genmf.o genpic.o \ +LIBOBJS = genbox.o gencgm.o genepic.o genibmgl.o genlatex.o gensml.o gensxd.o genmap.o genmf.o genpic.o \ genpictex.o genps.o genpdf.o genpstex.o gentextyl.o gentk.o gentpic.o \ genbitmaps.o genge.o genmp.o setfigfont.o psencode.o \ readpics.o readeps.o readgif.o readpcx.o readppm.o \ diff -ur --new-file transfig.3.2.3d.orig/fig2dev/dev/genps.c transfig.3.2.3d/fig2dev/dev/genps.c --- transfig.3.2.3d.orig/fig2dev/dev/genps.c Fri Apr 20 19:37:01 2001 +++ transfig.3.2.3d/fig2dev/dev/genps.c Thu Jul 4 20:21:27 2002 @@ -225,10 +225,10 @@ {"TIFF", "MM\000*", 4, read_tif, False}, {"XBM", "#define", 7, read_xbm, True}, #ifdef USE_PNG - {"PNG", "\211\120\116\107\015\012\032\012", 8, read_png, True}, +// {"PNG", "\211\120\116\107\015\012\032\012", 8, read_png, True}, #endif #ifdef USE_JPEG - {"JPEG", "\377\330\377\340", 4, read_jpg, True}, +// {"JPEG", "\377\330\377\340", 4, read_jpg, True}, #endif #ifdef USE_XPM {"XPM", "/* XPM */", 9, read_xpm, False}, diff -ur --new-file transfig.3.2.3d.orig/fig2dev/dev/gensml.c transfig.3.2.3d/fig2dev/dev/gensml.c --- transfig.3.2.3d.orig/fig2dev/dev/gensml.c Thu Jan 1 01:00:00 1970 +++ transfig.3.2.3d/fig2dev/dev/gensml.c Fri Jun 21 12:36:00 2002 @@ -0,0 +1,864 @@ + + +/* + * TransFig: Facility for Translating Fig code + * Copyright (c) 1991 by Micah Beck + * Parts Copyright (c) 1985-1988 by Supoj Sutanthavibul + * Parts Copyright (c) 1989-1999 by Brian V. Smith + * + * Any party obtaining a copy of these files is granted, free of charge, a + * full and unrestricted irrevocable, world-wide, paid up, royalty-free, + * nonexclusive right and license to deal in this software and + * documentation files (the "Software"), including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons who receive + * copies from any such party to do so, with the only requirement being + * that this copyright notice remain intact. + * + */ + +/* + * gensml.c : Kivio Stencil driver for fig2dev + * + * Author: Peter Korf + * Code stolen from genlatex.c + * + */ +#if defined(hpux) || defined(SYSV) || defined(SVR4) +#include +#endif +#include +#include "fig2dev.h" +#include "object.h" +#include "texfonts.h" + +extern double rad2deg; +extern void unpsfont(); + +//static put_box(); +//static put_arc_box(); +//static single_line(); +//static start_line(); +void end_line(); +void setcolor(int,int); + + +//static put_solidline(); +//static put_dashline(); +//static put_dotline(); +//static put_quarter(); + +#define rint(a) floor((a)+0.5) /* close enough? */ + +#define DESC_NAME "unknown" +extern char *from; + +#define SWAP(x,y) {tmp=x; x=y; y=tmp;} +//#define TRANS(x,y) (*translate_coordinates)(&x,&y) +//#define TRANS2(x1,y1,x2,y2) (*translate_coordinates)(&x1,&y1); \ +// (*translate_coordinates)(&x2,&y2) +//#define TRANSD(x,y) (*translate_coordinates_d)(&x,&y) +#define TRANS(x,y) translate1(&x,&y) +#define TRANS2(x1,y1,x2,y2) translate1(&x1,&y1);translate1(&x2,&y2); + +#ifndef MIN +#define MIN(x,y) (((x) <= (y))? (x): (y)) +#endif +#ifndef MAX +#define MAX(x,y) (((x) >= (y))? (x): (y)) +#endif +#define ABS(x) (((x) >= 0)? (x): -(x)) +#define round4(x) ((round(10000.0*(x))/10000.0)) +#define round6(x) ((round(1000000.0*(x))/1000000.0)) +#define MAXCIRCLEDIA 80 +#define MAXCIRCLERAD ((MAXCIRCLEDIA-0.5)/(2*72.27)) + + +#define SCALEFAKTOR 300 + +static char desc_name[] = DESC_NAME; +static float offsetx,offsety,scale=1; +static int counter=0; + +static unsigned int rgbColorVal(int colorIndex); +// static unsigned int setStyle(F_compound *objects;); + + +static int verbose;// = 0; +extern double dash_mag;// = 1.0; +extern int thick_width;// = 2; +extern double tolerance;// = 2.0; +extern double arc_tolerance;// = 1.0; +extern int (*translate_coordinates)();// = NULL; +extern int (*translate_coordinates_d)();// = NULL; +extern double unitlength; +static int cur_thickness;// 1; +extern double ldot_diameter;// .0/72.0; +extern char *dot_cmd;// =tindot; +extern char *ldot_cmd;// =hin_ldot; +extern double dot_xoffset; +extern double dot_yoffset; +extern double ldot_xoffset; +extern double ldot_yoffset; + + +static +translate1(xp, yp) +float *xp, *yp; +{ +if (verbose) fprintf(tfp, "\n",*xp,offsetx,scale); + *xp = (float)(*xp-offsetx)/scale; + *yp = (float)(*yp-offsety)/scale; + +//*xp = *xp + 1; +//*yp = *yp + 1; + } + +static +translate2(xp, yp) +float *xp, *yp; +{ +if (verbose) fprintf(tfp, "\n"); + +// *xp /= (double)120; +// *yp /= (double)120; + *xp = (*xp-offsetx)/scale; + *yp = (*yp-offsety)/scale; +// *xp = *xp + 1; +// *yp = (double)(TOP - *yp -1); + } + +static translate1_d(xp, yp) +float *xp, *yp; +{ +if (verbose) fprintf(tfp, "\n"); +// *xp /= (double)120; +// *yp /= (double)120; + *xp = (*xp-offsetx)/scale; + *yp = (*yp-offsety)/scale; +// *xp = *xp + 1.0; +// *yp = *yp + 1.0; + } +static +translate2_d(xp, yp) +float *xp, *yp; +{ +if (verbose) fprintf(tfp, "\n"); +// *xp /= (double)120; +// *yp /= (double)120; + *xp = (*xp-offsetx)/scale; + *yp = (*yp-offsety)/scale; +// *xp = *xp + 1.0; +// *yp = (double)TOP - *yp -1.0; + } + +void +gensml_option(opt, optarg) + char opt, *optarg; +{ + int i; + + switch (opt) { + case 'a': + fprintf(stderr, "warning: latex option -a obsolete"); + break; + + case 'd': + dash_mag = atof(optarg); /* set dash magnification */ + break; + + dash_mag = atof(optarg); /* set dash magnification */ + break; + + + case 'f': /* set default text font */ + for ( i = 1; i <= MAX_FONT; i++ ) + if ( !strcmp(optarg, texfontnames[i]) ) break; + + if ( i > MAX_FONT) + { + fprintf(stderr, + "warning: non-standard font name %s ignored\n", optarg); + } + else + { + texfontnames[0] = texfontnames[i]; +#ifdef NFSS + texfontfamily[0] = texfontfamily[i]; + texfontseries[0] = texfontseries[i]; + texfontshape[0] = texfontshape[i]; +#endif + } + break; + + case 'l': /* set thin/thick line threshold */ + thick_width = atoi(optarg); + break; + + case 'v': + verbose = 1; /* verbose mode */ + break; + + case 'n': + sprintf(desc_name,"%s",optarg); /* description name (library) */ + break; + + case 's': + case 'm': + case 'L': + break; + + break; + + default: + put_msg(Err_badarg, opt, "latex"); + exit(1); + } +} + +void +gensml_start(objects) + F_compound *objects; +{ + int tmp; + char name1[40]=" "; + float x1,y1,x2,y2; + strncpy((char *)name1,from,strlen(from)-4); + +// strncpy((char *)name1,(char *)name1,strlen(name1)-4); +// memcpy(rindex((const char*)from,'.'),'\0',1); +// name[strlen((const char*)from)]='\0'; + /* print any whole-figure comments prefixed with "%" */ + fprintf(tfp, "\n"); + +// if (objects->comments) { +// print_comments(""); +// } + +// fprintf(tfp, "\n",from); + fprintf(tfp, "\n" ); + fprintf(tfp, "\n" ); + fprintf(tfp, "\n" ); + +// print_comments("comments, "\"/>"); + fprintf(tfp, "<Id data=\"%s\"/>\n",name1); + if (objects->comments) { + print_comments("<Description data=\" ",objects->comments, "\"/>"); + print_comments("<Title data=\" ",objects->comments, "\"/>"); + } else + { + fprintf(tfp, "<Description data=\"%s\"/>\n",name1); + fprintf(tfp, "<Title data=\"%s\"/>\n",name1); + } + fprintf(tfp, "<Version data=\"0.1\"/>\n" ); + fprintf(tfp, "<Web data=\"www.xfig.org\"/>\n" ); + fprintf(tfp, "<Email data=\"peter@niendo.de\"/>\n" ); + fprintf(tfp, "<Copyright data=\"see README files \"/>\n" ); + fprintf(tfp, "<AutoUpdate data=\"off\"/>\n" ); + fprintf(tfp, "</KivioSMLStencilSpawnerInfo>\n" ); + + texfontsizes[0] = texfontsizes[1] = + TEXFONTSIZE(font_size?font_size:DEFAULT_FONT_SIZE); + mag=1; + ppi=1; + unitlength = mag/ppi; + dash_mag /= unitlength; + +// fprintf(tfp, "mag: %f,ppi: %f,dashmag; %f\n",mag,ppi,dash_mag); + +// fprintf(tfp, "x1: %d,y1: %d,x2; %d,y2 %d\n", +// objects->nwcorner.x, +// objects->nwcorner.y,objects->secorner.x,objects->secorner.y); + //translate_coordinates = translate2; + //translate_coordinates_d = translate2_d; + offsetx=(float)llx; + offsety=(float)lly; + + x1=(float)llx; + y1=(float)lly; + x2=(float)urx; + y2=(float)ury; + TRANS2(x1, y1, x2, y2); + //if (llx > urx) SWAP(llx, urx) + //if (lly > ury) SWAP(lly, ury) + +// if((urx>300) || (ury>300)) { + + scale=urx/SCALEFAKTOR; + +// if (scale<1) scale=1; + +// urx=(double)urx/6; +// ury=(double)ury/6; + fprintf(tfp, "<Dimensions w=\"%.3f\" h=\"%.3f\" defaultAspect=\"0.75\"/>\n",x2/scale,y2/scale); + fprintf(tfp, "<KivioShape type=\"TextBox\" name=\"TextBox%d\" x=\"0.0\" y=\"0.0\" w=\"%.3f\" h=\"%.3f\" />\n",counter++,x2/scale,y2/scale); + +// TRANS2(llx, lly, urx, ury); +// } else +// fprintf(tfp, "<Dimensions w=\"%d\" h=\"%d\" defaultAspect=\"0.75\"/>\n",urx,ury); + + + + + + /* LaTeX start */ + + /* print any whole-figure comments prefixed with "%" */ +// if (objects->comments) { +// fprintf(tfp,"%%\n"); +// print_comments("% ",objects->comments, ""); +// fprintf(tfp,"%%\n"); +// } + +// fprintf(tfp, "\\setlength{\\unitlength}{%lisp}%%\n", +// (long) (round(4736286.72*unitlength))); + /* define the SetFigFont macro */ +// define_setfigfont(tfp); +// fprintf(tfp, "\\begin{picture}(%d,%d)(%d,%d)\n", +// urx-llx, ury-lly, llx, lly); + +} + +int +gensml_end() +{ + fprintf(tfp, "</KivioShapeStencil>\n"); + /* all ok */ + return 0; +} + + +void +gensml_line(l) + F_line *l; +{ + F_point *p, *q; + float x, y,x1,y1, llx, lly, urx, ury, arrow; + float r1,r2; + int type=0; + if (verbose) + fprintf(tfp, "<!--depth: %d, Type: %d, Style: %d, Farbe_fill: %d, Farbe_pen: %d -->\n",l->depth,l->type,l->fill_style,l->fill_color,l->pen_color); + + /* print any comments prefixed with "%" */ + //print_comments("% ",l->comments, ""); + +// set_linewidth(l->thickness); +// setcolor(l->pen_color); + p = l->points; + q = p->next; + + + + if (q == NULL) { /* A single point line */ + + x = p->x; y = p->y; + TRANS(x, y); + +// fprintf(tfp, "\\put(%3d,%3d){\\makebox(%.4f,%.4f){%s}}\n", +// x, y, dot_xoffset, dot_yoffset, dot_cmd); + fprintf(tfp, "<KivioShape type=\"LineArray\" name=\"Point%d\">\n",counter++); + + fprintf(tfp, "\t<Line x1=\"%.3f\" y1=\"%.3f\" x2=\"%.3f\" y2=\"%.3f\"/>\n", + x, y, x+0.001, y+0.001); + } + + /* a box, perhaps with rounded corners */ + else + switch (l->type) { + case T_BOX: + case T_ARC_BOX: { + x = p->x; y = p->y; + TRANS(x, y); + llx = urx = x; + lly = ury = y; + while (q != NULL) { + x = q->x; y = q->y; + TRANS(x, y); + if (x < llx) llx = x; + if (y < lly) lly = y; + if (x > urx) urx = x; + if (y > ury) ury = y; + q = q->next; + } + + //if ((l->fill_style != -1) && (l->fill_color !=-1 )) { + if (l->type == T_ARC_BOX) { + // put_arc_box (llx, lly, urx, ury, l->radius, l->style, l->style_val); + r1=l->radius/scale/ppi; + r2=l->radius/scale/ppi; +// //TRANS(r1,r2); + fprintf(tfp, "<KivioShape type=\"RoundRectangle\" name=\"RoundRectangle%d\" x=\"%.3f\" y=\"%.3f\" w=\"%.3f\" h=\"%.3f\" r1=\"%0.2f\" r2=\"%0.2f\">\n", + counter++, llx, lly, urx-llx, ury-lly,r1,r2); + } + else { + fprintf(tfp, "<KivioShape type=\"Rectangle\" name=\"Rectangle%d\" x=\"%.3f\" y=\"%.3f\" w=\"%.3f\" h=\"%.3f\">\n", + counter++, llx, lly, urx-llx, ury-lly); + + + } + /*} else + { + fprintf(tfp, "<KivioShape type=\"LineArray\" name=\"Rectangle%d\">\n",counter++); + fprintf(tfp, "\t<Line x1=\"%.3f\" y1=\"%.3f\" x2=\"%.3f\" y2=\"%.3f\"/>\n", + llx, lly, urx,lly); + fprintf(tfp, "\t<Line x1=\"%.3f\" y1=\"%.3f\" x2=\"%.3f\" y2=\"%.3f\"/>\n", + urx,lly, urx,ury); + fprintf(tfp, "\t<Line x1=\"%.3f\" y1=\"%.3f\" x2=\"%.3f\" y2=\"%.3f\"/>\n", + urx,ury,llx,ury); + fprintf(tfp, "\t<Line x1=\"%.3f\" y1=\"%.3f\" x2=\"%.3f\" y2=\"%.3f\"/>\n", + llx,ury, llx,lly); + } +*/ + break; + } + case T_POLYLINE: + case T_POLYGON: { + + if ( (l->fill_style == -1) && (l->fill_color ==-1 )) + { + fprintf(tfp, "<KivioShape type=\"Polyline\" name=\"Polyline%d\">\n",counter++); + type=0; + } + else + { + fprintf(tfp, "<KivioShape type=\"Polygon\" name=\"Polygon%d\">\n",counter++); + + + type=0; + + // fprintf(tfp, "<KivioShape type=\"LineArray\" name=\"LineArray%d\">\n",counter++); + //type=1; + } + + +// if (l->type == T_BOUNDINGBOX) +// fprintf(tfp, "<KivioShape type=\"Polygon\" name=\"Lines\">\n"); + + + + while (q != NULL) { + //arrow = 0; + //if (l->for_arrow && q->next == NULL) + //arrow = 1; + //if (l->back_arrow && p == l->points) + //arrow = (arrow)? 2: -1; + if (type==0) { + // if ((l->type == T_POLYGON) && (l->fill_style != UNFILLED)) { + x = p->x; y = p->y; + TRANS(x, y); + fprintf(tfp, "\t<KivioPoint x=\"%.3f\" y=\"%.3f\"/>\n",x,y); + } + else { + x=p->x; + y=p->y; + x1=q->x; + y1=q->y; + TRANS2(x, y, x1, y1); + fprintf(tfp, "\t<Line x1=\"%.3f\" y1=\"%.3f\" x2=\"%.3f\" y2=\"%.3f\"/>\n", + x, y, x1,y1); + + // single_line(p->x, p->y, q->x, q->y, arrow, l->style, l->style_val); + } + + p = q; + q = q->next; + } + + if (type==0) { + + x = p->x; y = p->y; + TRANS(x, y); + fprintf(tfp, "\t<KivioPoint x=\"%.3f\" y=\"%.3f\"/>\n",x,y); + } + break; + } + default: { fprintf(stderr, "Objekt nicht unterstützt\n"); + } + + } + set_linewidth(l->thickness,l->pen_color); + //if (type==0) + set_arrow(&(l->for_arrow),&(l->back_arrow)); + + setcolor(l->fill_style,l->fill_color); + end_line(); +} + +void +gensml_spline(s) + F_spline *s; +{ + fprintf(stderr, "Can't generate spline; omitting object\n"); + } + +void +gensml_ellipse(e) + F_ellipse *e; +{ + float x, y, d, dx, dy; + + if (verbose) + if (verbose) + fprintf(tfp, "<!--depth: %d, Type: %d, Style: %d, Farbe_fill: %d, Farbe_pen: %d -->\n",e->depth,e->type,e->fill_style,e->fill_color,e->pen_color); + + /* print any comments prefixed with "%" */ + print_comments("<!-- ",e->comments, "-->"); + + switch (e->style) { + case SOLID_LINE: + break; + case DASH_LINE: + fprintf(stderr, "Dashed circles and elipses not supported\n"); + break; + case DOTTED_LINE: + fprintf(stderr, "Dotted circles and elipses not supported\n"); + break; + } + + x = e->center.x; + y = e->center.y; + TRANS(x, y); + +TRANS(x, y); + if ((e->type == T_CIRCLE_BY_RAD || e->type == T_CIRCLE_BY_DIA) + && e->radiuses.x*unitlength <= MAXCIRCLERAD) { + d = 2 * e->radiuses.x; + + + + if (e->fill_style == BLACK_FILL) +// fprintf(tfp, "\\put(%3d,%3d){\\circle*{%d}}\n", x, y, d) + ; + else { +// fprintf(tfp, "\\put(%3d,%3d){\\circle{%d}}\n", x, y, d); + if (e->fill_style != UNFILLED) + fprintf(stderr, "Circle area fill not implemented\n"); + } + fprintf(tfp, "<!-- -->\n"); + + + fprintf(tfp, "<KivioShape type=\"Ellipse\" name=\"Circle%d\" x=\"%.3f\" y=\"%.3f\" w=\"%.3f\" h=\"%.3f\">\n", + counter++,x, y, d, d); + + } else { + dx = 2*e->radiuses.x/scale; + dy = 2*e->radiuses.y /scale; + x = e->center.x-e->radiuses.x; + y = e->center.y-e->radiuses.y; + + TRANS(x,y); + fprintf(tfp, "<KivioShape type=\"Ellipse\" name=\"Ellipse%d\" x=\"%.3f\" y=\"%.3f\" w=\"%.3f\" h=\"%.3f\">\n", + counter++,x, y, dx, dy); + } + setcolor(e->fill_style,e->fill_color); + set_linewidth(e->thickness,e->pen_color); + end_line(); + } + +void +gensml_text(t) + F_text *t; +{ + float x, y; + char *tpos; + unsigned char *cp; + + if (verbose) + fprintf(tfp, "<!-- Fig TEXT object-->\n"); + + /* print any comments prefixed with "%" */ + print_comments("<!-- ",t->comments, "-->"); + + x = t->base_x; + y = t->base_y; + TRANS(x, y); + + switch (t->type) { + + case T_LEFT_JUSTIFIED: + case DEFAULT: + tpos = "0"; + break; + + case T_CENTER_JUSTIFIED: + tpos = "1"; + break; + + case T_RIGHT_JUSTIFIED: + tpos = "[rb]"; + break; + + default: + fprintf(stderr, "Text incorrectly positioned\n"); + tpos = "[lb]"; /* make left in this case */ + } + + /* smash is used to position text at baseline */ +// unpsfont(t); + +fprintf(tfp, "<KivioShape type=\"TextBox\" name=\"TextBox%d\" x=\"%.3f\" y=\"%.3f\" w=\"100\" h=\"100\">\n",counter++,x,y); +fprintf(tfp, " <Position x=\"0\" y=\"0\" />\n"); +fprintf(tfp, " <Dimension w=\"100\" h=\"100\" />\n"); +setcolor(1,t->color); +fprintf(tfp, " <KivioTextStyle vTextAlign=\"32\" isHtml=\"0\" hTextAlign=\"%d\" text=\"%s\" />\n",t->type,t->cstring); +fprintf(tfp, " <Font fixedPitch=\"0\" size=\"%d\" strikeOut=\"0\" family=\"\" bold=\"0\" underline=\"0\" color=\"#0\"/>\n",t->size); +fprintf(tfp, "</KivioShape>\n"); + + { int texsize; + double baselineskip; + + texsize = TEXFONTMAG(t); + baselineskip = (texsize * 1.2); + + } + + +} + +void +gensml_arc(a) + F_arc *a; +{ + F_pos p1, p2, pq[4]; + double cx, cy; + double v1x, v1y, v2x, v2y; + double r, angle1, angle2; + float q1, q2 ; + float y,x; + int p1_arrow, p2_arrow,i; + static char *ad1[4] = { " 0,-1", " 1, 0", " 0, 1", "-1, 0" }; + static char *ad2[4] = { "-1, 0", " 0,-1", " 1, 0", " 0, 1" }; + + if (verbose) + fprintf(tfp, "<!-- Fig ARC object -->\n"); + + /* print any comments prefixed with "%" */ + // print_comments("% ",a->comments, ""); + +// set_linewidth(a->thickness); +// if (a->fill_style != UNFILLED) setcolor(a->pen_color); +// switch (a->style) { +// case SOLID_LINE: +// break; +// case DASH_LINE: +// fprintf(stderr, "Dashed arcs not supported\n"); +// break; +// case DOTTED_LINE: +// fprintf(stderr, "Dotted arcs not supported\n"); +// break; +// } +// if (a->direction == 1) { +// p1 = a->point[0]; +// p2 = a->point[2]; +// p1_arrow = (a->back_arrow != NULL); +// p2_arrow = (a->for_arrow != NULL); +// } else { +// p1 = a->point[2]; +// p2 = a->point[0]; +// p1_arrow = (a->for_arrow != NULL); +// p2_arrow = (a->back_arrow != NULL); +// } + + + fprintf(tfp, "<KivioShape type=\"Bezier\" name=\"Bezier%d\">\n",counter++); + + +/* cx = a->center.x; + cy = a->center.y; + TRANS2(p1.x, p1.y, p2.x, p2.y); + TRANSD(cx, cy); + /*** compute vectors and angles from arc center to p1, p2 ***/ +/* v1x = (double)p1.x - cx; + v1y = (double)p1.y - cy; + v2x = (double)p2.x - cx; + v2y = (double)p2.y - cy; + angle1 = atan2(v1y, v1x) * rad2deg; + angle2 = atan2(v2y, v2x) * rad2deg; + if (angle1 < 0.0) + angle1 += 360.0; + if (angle2 < 0.0) + angle2 += 360.0; + /* compute arc radius */ +// r = sqrt(v1x*v1x+v1y*v1y); + /*** compute intersection of arc with x and y axis (origin at cx, cy) */ +// pq[0].x = round(cx); +// pq[0].y = round(cy + r); +// pq[1].x = round(cx - r); +// pq[1].y = round(cy); +// pq[2].x = round(cx); +// pq[2].y = round(cy - r); +// pq[3].x = round(cx + r); +// pq[3].y = round(cy); + + + for(i=0;i<=2;i++) { + x=a->point[i].x; + y=a->point[i].y; + TRANS(x,y); + fprintf(tfp, "\t<KivioPoint x=\"%.3f\" y=\"%.3f\" type=\"bezier\" />\n",x,y); + if (i==1) fprintf(tfp, "\t<KivioPoint x=\"%.3f\" y=\"%.3f\" type=\"bezier\" />\n",x,y); + } + + /*** compute in which quadrants p1 and p2 are located ***/ + /*q1 = (int)(angle1/90.0); + q2 = (int)(angle2/90.0); + if (fabs(angle1 - 90.0*q1) > arc_tolerance + || fabs(angle2 - 90.0*q2) > arc_tolerance) + // fprintf(stderr, "Approximating arc by ovals\n"); + + /*** Draw arc ** + if (a->type == T_OPEN_ARC && a->thickness != 0 && p1_arrow) + // fprintf(tfp, "\\put(%3d,%3d){\\vector(%s){0}}\n", p1.x, p1.y, ad1[q1]); + + + while (q1 != q2) { + put_quarter(p1, pq[q1], q1); + p1 = pq[q1]; + q1 = (q1 + 1) % 4; + } + put_quarter(p1, p2, q1); + if (a->type == T_OPEN_ARC && a->thickness != 0 && p2_arrow) + // fprintf(tfp, "\\put(%3d,%3d){\\vector(%s){0}}\n", p2.x, p2.y, ad2[q2]); + + if (a->fill_style != UNFILLED) + fprintf(stderr, "Arc area fill not implemented\n"); +// resetcolor(a->pen_color); + */ + setcolor(a->fill_style,a->fill_color); + set_linewidth(a->thickness,a->pen_color); + end_line(); + + } + + +#define MAXCOLORS 32 + +/* need this for communication between color routines. Sorry */ +static int lastcolor=-1; + +void setcolor(sty,col) +int sty,col; +{ +int color,style; + +color=rgbColorVal(col); + +if(col==7) { + if(sty==20) + color=255; + else + color=(255/20)*sty; + color=256*256*color+256*color+color; + } + +if((col==0) || (col==-1)) { +if(sty==20) + color=0; + else + color=255-(255/20)*sty; + color=256*256*color+256*color+color; + } + +if(sty==-1) + style=0; + else + style=1; + + fprintf(tfp, "\t<KivioFillStyle colorStyle=\"%d\" color=\"#%6.6x\" />\n", style ,color); +return; +} + +int +set_linewidth(w,col) + int w,col; +{ + float i,x; + x=1; + i=w/20; + fprintf(tfp, "\t<KivioLineStyle width=\"%.3f\" capStyle=\"32\" pattern=\"1\" joinStyle=\"128\" color=\"#%6.6x\" />\n", + i,rgbColorVal(col) ); +} + + +void end_line() +{ + fprintf(tfp, "</KivioShape>\n"); +} + +int +set_arrow(F_arrow *for_arrow,F_arrow *back_arrow) +{ +int f, f_t, f_ht, f_wid, b, b_t, b_ht, b_wid; + +if (verbose) fprintf(tfp, "<!--%d %d -->\n",(for_arrow==NULL),(back_arrow==NULL)); + +if(((for_arrow==NULL)==0) && ((back_arrow==NULL)==0)) { + return; +} + + if((for_arrow!=NULL)==0) { + f_t=for_arrow->type==0 ? 1 : 2; + f_wid=for_arrow->wid; + f_ht=for_arrow->ht; + } + else + { + f_t==0; + f_wid=0; + f_ht=0; + } + if((back_arrow!=NULL)==0) { + b_t=back_arrow->type==0 ? 1 : 2; + b_wid=back_arrow->wid; + b_ht=back_arrow->ht; + } + else + { + b_t=0; + b_wid=0; + b_ht=0; + } + fprintf(tfp, "<KivioArrowHeads>\n"); + fprintf(tfp, "\t<KivioArrowHead w=\"%d\" l=\"%d\" type=\"%d\" cut=\"0\" />\n",f_wid,f_ht,f_t); + fprintf(tfp, "\t<KivioArrowHead w=\"%d\" l=\"%d\" type=\"%d\" cut=\"0\" />\n",b_wid,b_ht,b_t); + fprintf(tfp, "</KivioArrowHeads>\n"); + return; +} + +static unsigned int +rgbColorVal(int colorIndex) +{ + extern User_color user_colors[]; + unsigned int rgb; + static unsigned int rgbColors[NUM_STD_COLS] = { + 0x000000, 0x0000ff, 0x00ff00, 0x00ffff, 0xff0000, 0xff00ff, + 0xffff00, 0xffffff, 0x00008f, 0x0000b0, 0x0000d1, 0x87cfff, + 0x008f00, 0x00b000, 0x00d100, 0x008f8f, 0x00b0b0, 0x00d1d1, + 0x8f0000, 0xb00000, 0xd10000, 0x8f008f, 0xb000b0, 0xd100d1, + 0x803000, 0xa14000, 0xb46100, 0xff8080, 0xffa1a1, 0xffbfbf, + 0xffe0e0, 0xffd600 + }; + + if (colorIndex == DEFAULT) + rgb = rgbColors[0]; + else if (colorIndex < NUM_STD_COLS) + rgb = rgbColors[colorIndex]; + else + rgb = ((user_colors[colorIndex-NUM_STD_COLS].r & 0xff) << 16) + | ((user_colors[colorIndex-NUM_STD_COLS].g & 0xff) << 8) + | (user_colors[colorIndex-NUM_STD_COLS].b & 0xff); + return rgb; +} + + +struct driver dev_sml = { + gensml_option, + gensml_start, + gensml_arc, + gensml_ellipse, + gensml_line, + gensml_spline, + gensml_text, + gensml_end, + EXCLUDE_TEXT +}; diff -ur --new-file transfig.3.2.3d.orig/fig2dev/dev/gensxd.c transfig.3.2.3d/fig2dev/dev/gensxd.c --- transfig.3.2.3d.orig/fig2dev/dev/gensxd.c Thu Jan 1 01:00:00 1970 +++ transfig.3.2.3d/fig2dev/dev/gensxd.c Wed Jul 17 10:47:50 2002 @@ -0,0 +1,764 @@ +/* + * TransFig: Facility for Translating Fig code + * Copyright (c) 1991 by Micah Beck + * Parts Copyright (c) 1985-1988 by Supoj Sutanthavibul + * Parts Copyright (c) 1989-1999 by Brian V. Smith + * + * Any party obtaining a copy of these files is granted, free of charge, a + * full and unrestricted irrevocable, world-wide, paid up, royalty-free, + * nonexclusive right and license to deal in this software and + * documentation files (the "Software"), including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons who receive + * copies from any such party to do so, with the only requirement being + * that this copyright notice remain intact. + * + */ + +/* + * gensxd.c : ooOffice xml driver for fig2dev + * + * Author: Peter Korf + * Code stolen from gensxd.c + * + */ +#if defined(hpux) || defined(SYSV) || defined(SVR4) +#include <sys/types.h> +#endif +#include <sys/file.h> +#include "fig2dev.h" +#include "object.h" +#include "texfonts.h" + +extern double rad2deg; +extern void unpsfont(); + +#define rint(a) floor((a)+0.5) /* close enough? */ + +#define DESC_NAME "unknown" + +#define HEAD_TAG "\nHEAD" +#define MIDDLE_TAG "\nMIDDLE" +#define END_TAG "\nEND" +#define STYLE_TAG "\nSTYLE" +#define BODY_TAG "\nBODY" +#define COMMENT_TAG "\nCOMMENT" +extern char *from; + +#ifndef MIN +#define MIN(x,y) (((x) <= (y))? (x): (y)) +#endif +#ifndef MAX +#define MAX(x,y) (((x) >= (y))? (x): (y)) +#endif +#define ABS(x) (((x) >= 0)? (x): -(x)) +#define round4(x) ((round(10000.0*(x))/10000.0)) +#define round6(x) ((round(1000000.0*(x))/1000000.0)) +#define MAXCIRCLEDIA 80 +#define MAXCIRCLERAD ((MAXCIRCLEDIA-0.5)/(2*72.27)) + +#define DISTANCE(x,y) sqrt(x*x+y*y) + +#define SCALEFAKTOR 300 + +static char desc_name[] = DESC_NAME; +static float offsetx,offsety,scale=1; +static int counter=0,counter_text=0; + + +static unsigned int rgbColorVal(int colorIndex); +// static unsigned int setStyle(F_compound *objects;); + + +static int verbose;// = 0; +extern double dash_mag;// = 1.0; +extern int thick_width;// = 2; +extern double tolerance;// = 2.0; +extern double arc_tolerance;// = 1.0; +extern int (*translate_coordinates)();// = NULL; +extern int (*translate_coordinates_d)();// = NULL; +extern double unitlength; +static int cur_thickness;// 1; +extern double ldot_diameter;// .0/72.0; +extern char *dot_cmd;// =tindot; +extern char *ldot_cmd;// =hin_ldot; +extern double dot_xoffset; +extern double dot_yoffset; +extern double ldot_xoffset; +extern double ldot_yoffset; + + +void gensxd_option(opt, optarg) + char opt, *optarg; +{ + int i; + + switch (opt) { + case 'a': + fprintf(stderr, "warning: latex option -a obsolete"); + break; + + case 'd': + dash_mag = atof(optarg); /* set dash magnification */ + break; + + dash_mag = atof(optarg); /* set dash magnification */ + break; + + + case 'f': /* set default text font */ + for ( i = 1; i <= MAX_FONT; i++ ) + if ( !strcmp(optarg, texfontnames[i]) ) break; + + if ( i > MAX_FONT) + { + fprintf(stderr, + "warning: non-standard font name %s ignored\n", optarg); + } + else + { + texfontnames[0] = texfontnames[i]; +#ifdef NFSS + texfontfamily[0] = texfontfamily[i]; + texfontseries[0] = texfontseries[i]; + texfontshape[0] = texfontshape[i]; +#endif + } + break; + + case 'l': /* set thin/thick line threshold */ + thick_width = atoi(optarg); + break; + + case 'v': + verbose = 1; /* verbose mode */ + break; + + case 'n': + sprintf(desc_name,"%s",optarg); /* description name (library) */ + break; + + case 's': + case 'm': + case 'L': + break; + + break; + + default: + put_msg(Err_badarg, opt, "latex"); + exit(1); + } +} + +void +gensxd_start(objects) + F_compound *objects; +{ + int tmp; + char name1[40]=" "; + float x1,y1,x2,y2; +// strncpy((char *)name1,from,strlen(from)-4); + fprintf(tfp,COMMENT_TAG "<!-- please use the script fig2sxd to create the sxd file -->"); + fprintf(tfp,HEAD_TAG "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); + fprintf(tfp,HEAD_TAG "<!DOCTYPE office:document-content PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\" \"office.dtd\">"); + fprintf(tfp,HEAD_TAG "<office:document-content xmlns:office=\"http://openoffice.org/2000/office\" xmlns:style=\"http://openoffice.org/2000/style\" xmlns:text=\"http://openoffice.org/2000/text\" xmlns:table=\"http://openoffice.org/2000/table\" xmlns:draw=\"http://openoffice.org/2000/drawing\" xmlns:fo=\"http://www.w3.org/1999/XSL/Format\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:number=\"http://openoffice.org/2000/datastyle\" xmlns:presentation=\"http://openoffice.org/2000/presentation\" xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns:chart=\"http://openoffice.org/2000/chart\" xmlns:dr3d=\"http://openoffice.org/2000/dr3d\" xmlns:math=\"http://www.w3.org/1998/Math/MathML\" xmlns:form=\"http://openoffice.org/2000/form\" xmlns:script=\"http://openoffice.org/2000/script\" office:class=\"drawing\" office:version=\"1.0\">"); + fprintf(tfp,HEAD_TAG "<office:script/>"); + fprintf(tfp,HEAD_TAG "<office:automatic-styles>"); + fprintf(tfp,HEAD_TAG "<style:style style:name=\"dp1\" style:family=\"drawing-page\"/>"); + +fprintf(tfp,MIDDLE_TAG "</office:automatic-styles>"); +fprintf(tfp,MIDDLE_TAG "<office:body>"); +fprintf(tfp,MIDDLE_TAG "<draw:page draw:name=\"page1\" draw:style-name=\"dp1\" draw:master-page-name=\"Standard\">"); + +} + +int gensxd_end() +{ + fprintf(tfp, END_TAG "</draw:page></office:body></office:document-content>"); + fprintf(tfp,COMMENT_TAG "<!-- please use the script fig2sxd to create the sxd file -->"); + /* all ok */ + return 0; +} + + +void gensxd_line(F_line *l) +{ + + F_point *p, *q, *r; + float x, y,x1,y1, llx, lly, urx, ury, arrow; + float r1,r2; + int type=0; + + p = l->points; + +fprintf(tfp, COMMENT_TAG " - Linie %d\n",l->type); + print_style(l->style, + l->thickness, + l->pen_color, + l->fill_color, + l->pen, + l->fill_style, + l->join_style, + l->for_arrow, + l->back_arrow, + l->cap_style); + + switch (l->type) { + case T_POLYLINE: + if (p->next == NULL) { + fprintf (tfp, COMMENT_TAG "POINT %d %d", p->x, p->y); + } + /* A single point line */ + /* Dot ? */ + if (l->fill_style == -1) { + draw_poly(l,"polyline"); + } else { + draw_poly(l,"polygon"); + } + break; + case T_ARC_BOX: + case T_BOX: + draw_box(l); + break; + case T_POLYGON: + draw_poly(l,"polygon"); + break; + case T_PIC_BOX: +// put_pic(l); + break; + default: + counter++; + fprintf(tfp, COMMENT_TAG "unkown\n"); + } + +} + +void gensxd_spline(F_spline *s) +{ + fprintf(tfp, COMMENT_TAG "Spline\n"); + +// fprintf(stderr, "Can't generate spline; omitting object\n"); +} + +void gensxd_ellipse(F_ellipse *e) +{ +fprintf(tfp, COMMENT_TAG "ellipse\n"); + + print_style(e->style, + e->thickness, + e->pen_color, + e->fill_color, + e->pen, + e->fill_style, + -1, + NULL, + NULL, + -1); + + switch (e->type) { + case T_CIRCLE_BY_RAD: + case T_CIRCLE_BY_DIA: + draw_round(e,"circle"); + break; + case T_ELLIPSE_BY_RAD: + case T_ELLIPSE_BY_DIA: + draw_round(e,"ellipse"); + break; + default: + }; +} + +void gensxd_text(F_text *t) +{ + + float x, y; + char *tpos; + unsigned char *cp; +fprintf(tfp, COMMENT_TAG "Text\n"); + + print_style_text(t->type, + t->color, + t->font, + t->size); + + + start_tag("text-box",t->depth); + + if (t->angle != 0) { + fprintf(tfp, " draw:transform=\"rotate (%G)\" ",t->angle); + } + + fprintf(tfp, "draw:auto-grow-width=\"true\" "); + fprintf(tfp, "draw:auto-grow-height=\"true\" "); + + fprintf(tfp, "svg:width=\"%G\" ",t->length); + fprintf(tfp, "svg:height=\"%G\" ",t->height); + fprintf(tfp, "svg:x=\"%d\" ",t->base_x); + fprintf(tfp, "svg:y=\"%G\" ",t->base_y-t->height); + + fprintf(tfp, "><text:p text:style-name=\"P1\"><text:span text:style-name=\"T%d\">%s</text:span></text:p></draw:text-box>",counter_text++,t->cstring); + + if (verbose) + fprintf(tfp, "<!-- Fig TEXT object-->\n"); + +} + +void gensxd_arc(F_arc *a) +{ +fprintf(tfp, COMMENT_TAG "arc\n"); + +if (a->direction == 1) { + print_style(a->style, + a->thickness, + a->pen_color, + a->fill_color, + a->pen, + a->fill_style, + -1, + a->for_arrow, + a->back_arrow, + a->cap_style); + +} else { + + print_style(a->style, + a->thickness, + a->pen_color, + a->fill_color, + a->pen, + a->fill_style, + -1, + a->back_arrow, + a->for_arrow, + a->cap_style); +} + switch (a->type) { + + case T_OPEN_ARC: + draw_arc(a,"arc"); + break; + case T_PIE_WEDGE_ARC: + draw_arc(a,"section"); + break; + default: + } + +} + + +print_style_text(int type, + int color, + int font, + double size) { +char *align_names[] = +{ + "left", + "center", + "right", +}; + +fprintf(tfp,STYLE_TAG "<style:style style:parent-style-name=\"standard\" style:name=\"xfig%d\" style:family=\"graphics\">",counter); +fprintf(tfp,STYLE_TAG "<style:properties draw:textarea-vertical-align=\"middle\" "); + +fprintf(tfp, "draw:textarea-horizontal-align=\"%s\" ",align_names[type]); +//fprintf(tfp, "draw:textarea-horizontal-align=\"%s\" ",align_names[type]); + fprintf(tfp, "draw:stroke=\"none\" "); + + fprintf(tfp, "svg:stroke-color=\"#%6.6x\" ",rgbColorVal(color)); + + fprintf(tfp, "draw:fill=\"none\" "); + fprintf(tfp, "draw:fill-color=\"#%6.6x\" ",rgbColorVal(color)); + + fprintf(tfp, "/></style:style>"); + + fprintf(tfp,STYLE_TAG "<style:style style:parent-style-name=\"standard\" style:name=\"P%d\" style:family=\"paragraph\">",counter_text); + fprintf(tfp,STYLE_TAG "<style:properties "); +// fprintf(tfp, " draw:fit-to-size=\"true\" "); + + + switch (font) { + case ITALIC_FONT: + fprintf(tfp, " fo:font-style=\"italic\" "); + case BOLD_FONT: + fprintf(tfp, " fo:font-weight=\"bold\" "); + } + + fprintf(tfp, "fo:color=\"#%6.6x\" ",rgbColorVal(color)); + fprintf(tfp, "fo:font-size=\"%Gpt\" ",size); + + fprintf(tfp, "/></style:style>"); + + +} + + +print_style(int style, + int thickness, + int pen_color, + int fill_color, + int pen, + int fill_style, + int join_style, + F_arrow *for_arrow, + F_arrow *back_arrow, + int cap_style) + +{ + int color; + + +char *joinstyle_names[] = { + "miter", + "bevel", + "round" +}; + +char *dash_names[] = +{ + "unkown", + "Fine Dashed", + "Fine Dotted", + "Line with Fine Dots" + "2 Dots 1 Dash", + "Ultrafine 2 Dots 3 Dashes", + "unkown", +}; + +char *hatch_names[] = +{ + "BLACK 45 Degrees", +}; + + +fprintf(tfp, COMMENT_TAG "<!-- fill_color %d, fill_style %d -->\n",fill_color,fill_style); + +fprintf(tfp,STYLE_TAG "<style:style style:parent-style-name=\"standard\" style:name=\"xfig%d\" style:family=\"graphics\">",counter); +fprintf(tfp,STYLE_TAG "<style:properties draw:textarea-vertical-align=\"middle\" "); + +if (thickness > 0) { + switch (style) { + case SOLID_LINE: + fprintf(tfp, "draw:stroke=\"solid\" "); + break; + default: + fprintf(tfp, "draw:stroke=\"dash\" "); + fprintf(tfp, "draw:stroke-dash=\"%s\" ",dash_names[style]); + break; + }; + + fprintf(tfp, "svg:stroke-width=\"%d\" ",thickness); + fprintf(tfp, "svg:stroke-color=\"#%6.6x\" ",rgbColorVal(pen_color)); +} else { + fprintf(tfp, "draw:stroke=\"none\" "); +} + +print_arrow(for_arrow,"start"); +print_arrow(back_arrow,"end"); + +if (join_style != -1) { + fprintf(tfp, "svg:stroke-linejoin=\"%s\" ",joinstyle_names[join_style]); +} + + +switch (fill_color) { + case -1: + case 0: + case 7: + if (fill_style == -1 ) { + fprintf(tfp, "draw:fill=\"none\" "); + } + if ((0<=fill_style) && (fill_style<=20)) { + fprintf(tfp, "draw:fill=\"solid\" "); + if (fill_color==7) { + color=(255/20)*(fill_style); + } else { + color=255-(255/20)*(fill_style); + } + color=256*256*color+256*color+color; + fprintf(tfp, "draw:fill-color=\"#%6.6x\" ",color); + } + if ((fill_style>=21) && (fill_style<=40)) { + fprintf(tfp, "draw:fill=\"not used\" "); + } + if ((fill_style>=41) && (fill_style<=56)) { + fprintf(tfp, "draw:fill=\"hatch\" "); + } + break; + default: + if (fill_style == -1) { + fprintf(tfp, "draw:fill=\"none\" "); + + } + if (fill_style == 0) { + fprintf(tfp, "draw:fill=\"solid\" "); + fprintf(tfp, "draw:fill-color=\"#000000\" "); + + + } + if (fill_style == 40) { + fprintf(tfp, "draw:fill=\"solid\" "); + fprintf(tfp, "draw:fill-color=\"#ffffff\" "); + + } + if ((fill_style>0) && (fill_style<40)) { + fprintf(tfp, "draw:fill=\"solid\" "); + fprintf(tfp, "draw:fill-color=\"#%6.6x\" ",rgbColorVal(fill_color)); + } + if ((fill_style>=41) && (fill_style<=56)) { + fprintf(tfp, "draw:fill=\"hatch\" "); + fprintf(tfp, "draw:fill-hatch-name=\"#%s\" ",hatch_names[0]); + + } +} +//draw:transparency + + fprintf(tfp, "/></style:style>"); + +} + + +#define MAXCOLORS 32 + +/* need this for communication between color routines. Sorry */ +static int lastcolor=-1; + + +static unsigned int +rgbColorVal(int colorIndex) +{ + extern User_color user_colors[]; + unsigned int rgb; + static unsigned int rgbColors[NUM_STD_COLS] = { + 0x000000, 0x0000ff, 0x00ff00, 0x00ffff, 0xff0000, 0xff00ff, + 0xffff00, 0xffffff, 0x00008f, 0x0000b0, 0x0000d1, 0x87cfff, + 0x008f00, 0x00b000, 0x00d100, 0x008f8f, 0x00b0b0, 0x00d1d1, + 0x8f0000, 0xb00000, 0xd10000, 0x8f008f, 0xb000b0, 0xd100d1, + 0x803000, 0xa14000, 0xb46100, 0xff8080, 0xffa1a1, 0xffbfbf, + 0xffe0e0, 0xffd600 + }; + + if (colorIndex == DEFAULT) + rgb = rgbColors[0]; + else if (colorIndex < NUM_STD_COLS) + rgb = rgbColors[colorIndex]; + else + rgb = ((user_colors[colorIndex-NUM_STD_COLS].r & 0xff) << 16) + | ((user_colors[colorIndex-NUM_STD_COLS].g & 0xff) << 8) + | (user_colors[colorIndex-NUM_STD_COLS].b & 0xff); + return rgb; +} + + +start_tag(char *name,int depth) { + fprintf(tfp, BODY_TAG "<draw:%s draw:style-name=\"xfig%d\" draw:text-style-name=\"P0\" draw:layer=\"layout\" ",name,counter++); + fprintf(tfp, "draw:zindex=\"%d\" ",depth); +}; + +draw_round(F_ellipse *e,char *name) { + F_point *q; + int max_x,max_y; + start_tag(name,e->depth); + +// draw:kind (full|section|cut|arc) + + fprintf(tfp, "draw:kind=\"full\" "); + fprintf(tfp, "svg:width=\"%d\" ",e->radiuses.x*2); + fprintf(tfp, "svg:height=\"%d\" ",e->radiuses.y*2); + fprintf(tfp, "svg:x=\"%d\" ",e->center.x - e->radiuses.x); + fprintf(tfp, "svg:y=\"%d\" ",e->center.y - e->radiuses.y); + if (e->angle != 0) { + fprintf(tfp, "draw:transform=\"rotate (%f)\" ",e->angle); + } + fprintf(tfp, "/>"); +} + +draw_arc(F_arc *a,char *name) { + F_point *q; + int arc,max_x,max_y; + F_pos p1, p2, p3, pq[4]; + double x1,y1,x2,y2,x3,y3,A,B,C; + double dx,dy,sx,sy,ex,ey; + double cx, cy; + double v1x, v1y, v2x, v2y; + double r, angle1, angle2; + + start_tag("ellipse",a->depth); + +// draw:kind (full|section|cut|arc) +// FIXME: math problems + +if (a->direction == 1) { +return; + p1 = a->point[2]; + p3 = a->point[0]; +// sx = a->point[0].x; sy = a->point[0].y; +// ex = a->point[2].x; ey = a->point[2].y; + +// p1_arrow = (a->back_arrow != NULL); +// p2_arrow = (a->for_arrow != NULL); + } else { + p1 = a->point[0]; + p3 = a->point[2]; +// sx = a->point[2].x; sy = a->point[2].y; +// ex = a->point[0].x; ey = a->point[0].y; + +// p1_arrow = (a->for_arrow != NULL); +// p2_arrow = (a->back_arrow != NULL); + } + + sx = a->point[0].x; sy = a->point[0].y; + ex = a->point[2].x; ey = a->point[2].y; + + cx = a->center.x; cy = a->center.y; + +// direction = a->direction; + dx = cx - sx; + dy = cy - sy; + r = sqrt(dx*dx+dy*dy); + if (cx==sx) + angle1 = (sy-cy > 0? 90.0: -90.0); + else + angle1 = atan2((sy-cy),(sx-cx)) * 180 / M_PI; + if (cx==ex) + angle2 = (ey-cy > 0 ? 90.0: -90.0); + else + angle2 = atan2((ey-cy),(ex-cx)) * 180 /M_PI; + + + + angle1 = (angle1 < 0 ? angle1+360: angle1); + angle2 = (angle2 < 0 ? angle2+360: angle2); + + if (abs(angle1)>90) + angle1=180-180-angle1; + else + angle1=-angle1; + + if (abs(angle2)>90) + angle2=180-180-angle2; + else + angle2=-angle2; + + + +// fprintf(tfp, COMMENT_TAG " %G %G",v1x,v1y); +// fprintf(tfp, COMMENT_TAG " %G %G",v2x,v2y); +// fprintf(tfp, COMMENT_TAG " %d %d",p1.x,p1.y); +// fprintf(tfp, COMMENT_TAG " %d %d",p2.x,p2.y); +// fprintf(tfp, COMMENT_TAG " %d %d",p3.x,p3.y); +// fprintf(tfp, COMMENT_TAG " %G %G\n",a->center.x,a->center.y); + + fprintf(tfp, "draw:kind=\"%s\" ",name); + fprintf(tfp, "svg:x=\"%G\" ",cx-r); + fprintf(tfp, "svg:y=\"%G\" ",cy-r); + fprintf(tfp, "svg:width=\"%G\" ",2*r); + fprintf(tfp, "svg:height=\"%G\" ",2*r); + fprintf(tfp, "draw:start-angle=\"%.2f\" ",angle2); + fprintf(tfp, "draw:end-angle=\"%.2f\" " ,angle1); + + +// if (a->angle != 0) { +// fprintf(tfp, "draw:transform=\"rotate (%f)\" ",a->angle); +// } + fprintf(tfp, "/>"); +} + +draw_poly(F_line *l,char *name) { + F_point *q; + int max_x,max_y,min_x,min_y; + + fprintf(tfp, COMMENT_TAG " Linie %d\n",l->type); + + start_tag(name,l->depth); + + fprintf(tfp, "draw:points=\""); + + q=l->points; + max_x=q->x; + max_y=q->y; + min_x=q->x; + min_y=q->y; + + while (q != NULL) { + max_x=MAX(max_x,q->x); + max_y=MAX(max_y,q->y); + min_x=MIN(min_x,q->x); + min_y=MIN(min_y,q->y); + + fprintf(tfp, "%d,%d ",q->x,q->y); + q=q->next; + } + + fprintf(tfp, "\" "); + fprintf(tfp, "svg:viewBox=\"%d %d %d %d\" ",min_x-1,min_y-1,max_x+1,max_y+1); + fprintf(tfp, "svg:x=\"%d\" svg:y=\"%d\" svg:width=\"%d\" svg:heigth=\"%d\" ",min_x-1,min_y-1,max_x+1,max_y+1); + + fprintf(tfp, "/>"); +} + +draw_line(F_line *l) { + start_tag("line",l->depth); + + fprintf(tfp, "svg:x1=\"%d\" ",l->points->x); + fprintf(tfp, "svg:y1=\"%d\" ",l->points->y); + fprintf(tfp, "svg:x2=\"%d\" ",l->points->next->x); + fprintf(tfp, "svg:y2=\"%d\" ",l->points->next->y); + + fprintf(tfp, "/>"); +} + +draw_box(F_line *l) { + F_point *p, *q; + int x1,x2,y1,y2; + p = l->points; + q = p->next->next; + + x1=MIN(p->x,q->x); + x2=MAX(p->x,q->x); + y1=MIN(p->y,q->y); + y2=MAX(p->y,q->y); + + + + start_tag("rect",l->depth); + fprintf(tfp, "svg:x=\"%d\" ",x1); + fprintf(tfp, "svg:y=\"%d\" ",y1); + + fprintf(tfp, "svg:width =\"%d\" ",x2-x1); + fprintf(tfp, "svg:height=\"%d\" ",y2-y1); + + if (l->type==T_ARC_BOX) { + fprintf(tfp, "draw:corner-radius=\"%d\" ",l->radius); + } + fprintf(tfp, "/>"); + +} + +print_arrow(F_arrow *arrow,char *name) { +char *arrow_names[] = { + "Line Arrow", + "Arrow", + "Arrow concave", + "Arrow convex" +}; + +if (arrow != NULL) { + fprintf(tfp, " draw:marker-%s=\"%s\" ",name,arrow_names[arrow->type]); + fprintf(tfp, " draw:marker-%s-width=\"%G\" ",name,arrow->wid*3); + fprintf(tfp, " draw:marker-%s-height=\"%G\" ",name,arrow->ht*3); + fprintf(tfp, " draw:marker-%s-center=\"true\" ",name); +} +} + +struct driver dev_sxd = { + gensxd_option, + gensxd_start, + gensxd_arc, + gensxd_ellipse, + gensxd_line, + gensxd_spline, + gensxd_text, + gensxd_end, + INCLUDE_TEXT +}; diff -ur --new-file transfig.3.2.3d.orig/fig2dev/drivers.h transfig.3.2.3d/fig2dev/drivers.h --- transfig.3.2.3d.orig/fig2dev/drivers.h Thu Feb 15 18:44:33 2001 +++ transfig.3.2.3d/fig2dev/drivers.h Fri Jun 21 12:29:54 2002 @@ -35,6 +35,8 @@ extern struct driver dev_ge; extern struct driver dev_bitmaps; extern struct driver dev_map; +extern struct driver dev_sml; +extern struct driver dev_sxd; /* all the bitmap formats use the dev_bitmaps driver */ @@ -65,6 +67,8 @@ {"pstex", &dev_pstex}, {"pstex_t", &dev_pstex_t}, {"sld", &dev_bitmaps}, + {"sml", &dev_sml}, + {"sxd", &dev_sxd}, {"textyl", &dev_textyl}, {"tiff", &dev_bitmaps}, {"tk", &dev_tk}, diff -ur --new-file transfig.3.2.3d.orig/fig2dev/fig2sxd.script transfig.3.2.3d/fig2dev/fig2sxd.script --- transfig.3.2.3d.orig/fig2dev/fig2sxd.script Thu Jan 1 01:00:00 1970 +++ transfig.3.2.3d/fig2dev/fig2sxd.script Wed Jul 17 11:01:47 2002 @@ -0,0 +1,36 @@ +#!/bin/sh +# script to convert fig to sxd +# email: peter@niendo.de + +tempdir=./standard; + +if test "$1" != ""; then + +mkdir $tempdir + +name=`echo $1 | sed s/.fig//` + +#cp -R ./standard $name + +echo exporting $name.fig to $name.sxd + +fig2dev -Lsxd $name.fig >dummy || echo Fehler bei: $name + +cat dummy | grep "^HEAD" | sed -e 's/HEAD//' >$tempdir/content.xml +cat dummy | grep "^STYLE" | sed -e 's/STYLE//' >>$tempdir/content.xml +cat dummy | grep "^MIDDLE" | sed -e 's/MIDDLE//' >>$tempdir/content.xml +cat dummy | grep "^BODY" | sed -e 's/BODY//' >>$tempdir/content.xml +cat dummy | grep "^END" | sed -e 's/END//' >>$tempdir/content.xml + +cd ./standard +zip -r ../$name.sxd * >/dev/null +cd .. +else + +echo "use ./pack <filename.fig>" +echo export filename.fig to filename.sxd +echo +echo you need a directory called $tempdir, which should be +echo empty or an uncompressed sxd file. +echo +fi diff -ur --new-file transfig.3.2.3d.orig/patchlevel.h transfig.3.2.3d/patchlevel.h --- transfig.3.2.3d.orig/patchlevel.h Tue May 29 21:12:37 2001 +++ transfig.3.2.3d/patchlevel.h Thu Jul 4 10:47:19 2002 @@ -16,4 +16,4 @@ */ #define VERSION "3.2" -#define PATCHLEVEL "3d" +#define PATCHLEVEL "3d-sml-sxd_0.2"