34 #define WIDTH_NORMAL 1
42 static int onetime =
TRUE;
54 static char *FillStr =
"<Fill 3>";
55 static char *NoFillStr =
"<Fill 15>";
57 static void mif_reset(
void)
63 static void init_mif(
void)
89 static void mifptarray(
point * A,
int n)
94 fprintf(Output_file,
" <NumPoints %d>\n", n);
95 for (i = 0; i < n; i++) {
99 fprintf(Output_file,
" <Point %.2f %.2f>\n", p.
x, p.
y);
117 "<Font <FFamily `%s'> <FSize %.1f pt> <FWeight %s> <FAngle %s>>\n",
121 static void mif_color(
int i)
123 static char *mifcolor[] = {
124 "black",
"white",
"red",
"green",
"blue",
"cyan",
125 "magenta",
"yellow",
"comment",
126 "aquamarine",
"plum",
"peru",
"pink",
"mediumpurple",
"grey",
127 "lightgrey",
"lightskyblue",
"lightcoral",
"yellowgreen",
131 fprintf(Output_file,
"<Separation %d>\n", i);
133 fprintf(Output_file,
"<ObColor `%s'>\n", mifcolor[i]);
138 fprintf(Output_file,
"<Pen %d> <Fill %d> <PenWidth %d>\n",
142 static void mif_comment(
char *
str)
144 fprintf(Output_file,
"# %s\n", str);
148 mif_begin_job(FILE * ofp,
graph_t * g,
const char **lib,
char *
info[],
point pages)
151 N_pages = pages.
x * pages.
y;
153 "<MIFFile 3.00> # Generated by %s version %s (%s)\n", info[0],
155 fprintf(Output_file,
"# Title: %s\n",
agnameof(g));
156 fprintf(Output_file,
"# Pages: %d\n", N_pages);
157 fprintf(Output_file,
"<Units Upt>\n");
158 fprintf(Output_file,
"<ColorCatalog \n");
159 fprintf(Output_file,
" <Color \n");
160 fprintf(Output_file,
" <ColorTag `Black'>\n");
161 fprintf(Output_file,
" <ColorCyan 0.000000>\n");
162 fprintf(Output_file,
" <ColorMagenta 0.000000>\n");
163 fprintf(Output_file,
" <ColorYellow 0.000000>\n");
164 fprintf(Output_file,
" <ColorBlack 100.000000>\n");
165 fprintf(Output_file,
" <ColorAttribute ColorIsBlack>\n");
166 fprintf(Output_file,
" <ColorAttribute ColorIsReserved>\n");
167 fprintf(Output_file,
" > # end of Color\n");
168 fprintf(Output_file,
" <Color \n");
169 fprintf(Output_file,
" <ColorTag `White'>\n");
170 fprintf(Output_file,
" <ColorCyan 0.000000>\n");
171 fprintf(Output_file,
" <ColorMagenta 0.000000>\n");
172 fprintf(Output_file,
" <ColorYellow 0.000000>\n");
173 fprintf(Output_file,
" <ColorBlack 0.000000>\n");
174 fprintf(Output_file,
" <ColorAttribute ColorIsWhite>\n");
175 fprintf(Output_file,
" <ColorAttribute ColorIsReserved>\n");
176 fprintf(Output_file,
" > # end of Color\n");
177 fprintf(Output_file,
" <Color \n");
178 fprintf(Output_file,
" <ColorTag `Red'>\n");
179 fprintf(Output_file,
" <ColorCyan 0.000000>\n");
180 fprintf(Output_file,
" <ColorMagenta 100.000000>\n");
181 fprintf(Output_file,
" <ColorYellow 100.000000>\n");
182 fprintf(Output_file,
" <ColorBlack 0.000000>\n");
183 fprintf(Output_file,
" <ColorAttribute ColorIsRed>\n");
184 fprintf(Output_file,
" <ColorAttribute ColorIsReserved>\n");
185 fprintf(Output_file,
" > # end of Color\n");
186 fprintf(Output_file,
" <Color \n");
187 fprintf(Output_file,
" <ColorTag `Green'>\n");
188 fprintf(Output_file,
" <ColorCyan 100.000000>\n");
189 fprintf(Output_file,
" <ColorMagenta 0.000000>\n");
190 fprintf(Output_file,
" <ColorYellow 100.000000>\n");
191 fprintf(Output_file,
" <ColorBlack 0.000000>\n");
192 fprintf(Output_file,
" <ColorAttribute ColorIsGreen>\n");
193 fprintf(Output_file,
" <ColorAttribute ColorIsReserved>\n");
194 fprintf(Output_file,
" > # end of Color\n");
195 fprintf(Output_file,
" <Color \n");
196 fprintf(Output_file,
" <ColorTag `Blue'>\n");
197 fprintf(Output_file,
" <ColorCyan 100.000000>\n");
198 fprintf(Output_file,
" <ColorMagenta 100.000000>\n");
199 fprintf(Output_file,
" <ColorYellow 0.000000>\n");
200 fprintf(Output_file,
" <ColorBlack 0.000000>\n");
201 fprintf(Output_file,
" <ColorAttribute ColorIsBlue>\n");
202 fprintf(Output_file,
" <ColorAttribute ColorIsReserved>\n");
203 fprintf(Output_file,
" > # end of Color\n");
204 fprintf(Output_file,
" <Color \n");
205 fprintf(Output_file,
" <ColorTag `Cyan'>\n");
206 fprintf(Output_file,
" <ColorCyan 100.000000>\n");
207 fprintf(Output_file,
" <ColorMagenta 0.000000>\n");
208 fprintf(Output_file,
" <ColorYellow 0.000000>\n");
209 fprintf(Output_file,
" <ColorBlack 0.000000>\n");
210 fprintf(Output_file,
" <ColorAttribute ColorIsCyan>\n");
211 fprintf(Output_file,
" <ColorAttribute ColorIsReserved>\n");
212 fprintf(Output_file,
" > # end of Color\n");
213 fprintf(Output_file,
" <Color \n");
214 fprintf(Output_file,
" <ColorTag `Magenta'>\n");
215 fprintf(Output_file,
" <ColorCyan 0.000000>\n");
216 fprintf(Output_file,
" <ColorMagenta 100.000000>\n");
217 fprintf(Output_file,
" <ColorYellow 0.000000>\n");
218 fprintf(Output_file,
" <ColorBlack 0.000000>\n");
219 fprintf(Output_file,
" <ColorAttribute ColorIsMagenta>\n");
220 fprintf(Output_file,
" <ColorAttribute ColorIsReserved>\n");
221 fprintf(Output_file,
" > # end of Color\n");
222 fprintf(Output_file,
" <Color \n");
223 fprintf(Output_file,
" <ColorTag `Yellow'>\n");
224 fprintf(Output_file,
" <ColorCyan 0.000000>\n");
225 fprintf(Output_file,
" <ColorMagenta 0.000000>\n");
226 fprintf(Output_file,
" <ColorYellow 100.000000>\n");
227 fprintf(Output_file,
" <ColorBlack 0.000000>\n");
228 fprintf(Output_file,
" <ColorAttribute ColorIsYellow>\n");
229 fprintf(Output_file,
" <ColorAttribute ColorIsReserved>\n");
230 fprintf(Output_file,
" > # end of Color\n");
231 fprintf(Output_file,
" <Color \n");
232 fprintf(Output_file,
" <ColorTag `aquamarine'>\n");
233 fprintf(Output_file,
" <ColorCyan 100.000000>\n");
234 fprintf(Output_file,
" <ColorMagenta 0.000000>\n");
235 fprintf(Output_file,
" <ColorYellow 18.000000>\n");
236 fprintf(Output_file,
" <ColorBlack 0.000000>\n");
237 fprintf(Output_file,
" > # end of Color\n");
238 fprintf(Output_file,
" <Color \n");
239 fprintf(Output_file,
" <ColorTag `plum'>\n");
240 fprintf(Output_file,
" <ColorCyan 0.000000>\n");
241 fprintf(Output_file,
" <ColorMagenta 100.000000>\n");
242 fprintf(Output_file,
" <ColorYellow 0.000000>\n");
243 fprintf(Output_file,
" <ColorBlack 33.000000>\n");
244 fprintf(Output_file,
" > # end of Color\n");
245 fprintf(Output_file,
" <Color \n");
246 fprintf(Output_file,
" <ColorTag `peru'>\n");
247 fprintf(Output_file,
" <ColorCyan 0.000000>\n");
248 fprintf(Output_file,
" <ColorMagenta 24.000000>\n");
249 fprintf(Output_file,
" <ColorYellow 100.000000>\n");
250 fprintf(Output_file,
" <ColorBlack 32.000000>\n");
251 fprintf(Output_file,
" > # end of Color\n");
252 fprintf(Output_file,
" <Color \n");
253 fprintf(Output_file,
" <ColorTag `pink'>\n");
254 fprintf(Output_file,
" <ColorCyan 0.000000>\n");
255 fprintf(Output_file,
" <ColorMagenta 50.000000>\n");
256 fprintf(Output_file,
" <ColorYellow 0.000000>\n");
257 fprintf(Output_file,
" <ColorBlack 0.000000>\n");
258 fprintf(Output_file,
" > # end of Color\n");
259 fprintf(Output_file,
" <Color \n");
260 fprintf(Output_file,
" <ColorTag `mediumpurple'>\n");
261 fprintf(Output_file,
" <ColorCyan 40.000000>\n");
262 fprintf(Output_file,
" <ColorMagenta 100.000000>\n");
263 fprintf(Output_file,
" <ColorYellow 0.000000>\n");
264 fprintf(Output_file,
" <ColorBlack 0.000000>\n");
265 fprintf(Output_file,
" > # end of Color\n");
266 fprintf(Output_file,
" <Color \n");
267 fprintf(Output_file,
" <ColorTag `grey'>\n");
268 fprintf(Output_file,
" <ColorCyan 0.000000>\n");
269 fprintf(Output_file,
" <ColorMagenta 0.000000>\n");
270 fprintf(Output_file,
" <ColorYellow 0.000000>\n");
271 fprintf(Output_file,
" <ColorBlack 50.000000>\n");
272 fprintf(Output_file,
" > # end of Color\n");
273 fprintf(Output_file,
" <Color \n");
274 fprintf(Output_file,
" <ColorTag `lightgrey'>\n");
275 fprintf(Output_file,
" <ColorCyan 0.000000>\n");
276 fprintf(Output_file,
" <ColorMagenta 0.000000>\n");
277 fprintf(Output_file,
" <ColorYellow 0.000000>\n");
278 fprintf(Output_file,
" <ColorBlack 25.000000>\n");
279 fprintf(Output_file,
" > # end of Color\n");
280 fprintf(Output_file,
" <Color \n");
281 fprintf(Output_file,
" <ColorTag `lightskyblue'>\n");
282 fprintf(Output_file,
" <ColorCyan 38.000000>\n");
283 fprintf(Output_file,
" <ColorMagenta 33.000000>\n");
284 fprintf(Output_file,
" <ColorYellow 0.000000>\n");
285 fprintf(Output_file,
" <ColorBlack 0.000000>\n");
286 fprintf(Output_file,
" > # end of Color\n");
287 fprintf(Output_file,
" <Color \n");
288 fprintf(Output_file,
" <ColorTag `lightcoral'>\n");
289 fprintf(Output_file,
" <ColorCyan 0.000000>\n");
290 fprintf(Output_file,
" <ColorMagenta 50.000000>\n");
291 fprintf(Output_file,
" <ColorYellow 60.000000>\n");
292 fprintf(Output_file,
" <ColorBlack 0.000000>\n");
293 fprintf(Output_file,
" > # end of Color\n");
294 fprintf(Output_file,
" <Color \n");
295 fprintf(Output_file,
" <ColorTag `yellowgreen'>\n");
296 fprintf(Output_file,
" <ColorCyan 31.000000>\n");
297 fprintf(Output_file,
" <ColorMagenta 0.000000>\n");
298 fprintf(Output_file,
" <ColorYellow 100.000000>\n");
299 fprintf(Output_file,
" <ColorBlack 0.000000>\n");
300 fprintf(Output_file,
" > # end of Color\n");
301 fprintf(Output_file,
"> # end of ColorCatalog\n");
304 static void mif_end_job(
void)
306 fprintf(Output_file,
"# end of MIFFile\n");
313 fprintf(Output_file,
"<BRect %d %d %d %d>\n",
321 mif_begin_page(
graph_t * g,
point page,
double scale,
int rot,
332 " <ArrowStyle <TipAngle 15> <BaseAngle 90> <Length %.1f> <HeadType Filled>>\n",
336 static void mif_begin_context(
void)
339 cstk[SP + 1] = cstk[SP];
343 static void mif_end_context(
void)
347 if (cstk[SP].color_ix != (c = cstk[psp].color_ix))
349 if (cstk[SP].font_was_set)
350 mif_font(&(cstk[psp]));
351 if (cstk[SP].style_was_set)
352 mif_style(&(cstk[psp]));
357 static void mif_set_font(
char *name,
double size)
366 if ((q = strchr(p,
'-'))) {
377 static void mif_set_color(
char *name)
382 static char *mifcolor[] = {
383 "black",
"white",
"red",
"green",
"blue",
"cyan",
384 "magenta",
"yellow",
"comment",
385 "aquamarine",
"plum",
"peru",
"pink",
"mediumpurple",
"grey",
386 "lightgrey",
"lightskyblue",
"lightcoral",
"yellowgreen",
391 for (i = 0; mifcolor[i]; i++) {
398 agerr(
AGERR,
"color %s not supported in MIF\n", name);
401 static void mif_set_style(
char **
s)
407 while ((line = *s++)) {
408 if (
streq(line,
"solid"))
410 else if (
streq(line,
"dashed"))
412 else if (
streq(line,
"dotted"))
418 else if (
streq(line,
"filled"))
420 else if (
streq(line,
"unfilled"))
424 "mif_set_style: unsupported style %s - ignoring\n",
433 static char *mif_string(
char *s)
435 static char *buf =
NULL;
436 static int bufsize = 0;
442 buf =
N_GNEW(bufsize,
char);
447 if (pos > (bufsize - 8)) {
478 static void mif_textpara(
point p, textpara_t * para)
484 mp.
y = p.
y - cstk[SP].
fontsz / 2 + 2;
485 switch (para->just) {
499 "<TextLine <Angle %d> <TLOrigin %.2f %.2f> <TLAlignment %s>",
500 Rot, mp.
x, mp.
y, anchor);
501 fprintf(Output_file,
" <String `%s'>>\n", mif_string(para->str));
504 static void mif_bezier(
point * A,
int n,
int arrow_at_start,
505 int arrow_at_end,
int filled)
508 "<PolyLine <Fill 15> <Smoothed Yes> <HeadCap Square>\n");
510 fprintf(Output_file,
">\n");
513 static void mif_polygon(
point * A,
int n,
int filled)
515 fprintf(Output_file,
"<Polygon %s\n", (filled ? FillStr : NoFillStr));
517 fprintf(Output_file,
">\n");
520 static void mif_ellipse(
point p,
int rx,
int ry,
int filled)
532 fprintf(Output_file,
"<Ellipse %s <BRect %.2f %.2f %.1f %.1f>>\n",
533 filled ? FillStr : NoFillStr,
534 mp.
x, mp.
y, Scale * (rx + rx), Scale * (ry + ry));
537 static void mif_polyline(
point * A,
int n)
539 fprintf(Output_file,
"<PolyLine <HeadCap Square>\n");
541 fprintf(Output_file,
">\n");
546 static boolean onetime =
TRUE;
548 agerr(
AGERR,
"custom shapes not available with this driver\n");
555 mif_begin_job, mif_end_job,
564 mif_begin_context, mif_end_context,
566 mif_set_font, mif_textpara,
567 mif_set_color, mif_set_color, mif_set_style,
568 mif_ellipse, mif_polygon,
569 mif_bezier, mif_polyline,
void * grealloc(void *ptr, size_t size)
int agerr(agerrlevel_t level, const char *fmt,...)
struct context_t context_t
CGRAPH_API char * agnameof(void *)
if(aagss+aagstacksize-1<=aagssp)
char * canontoken(char *str)
int strcasecmp(const char *s1, const char *s2)