• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

作図ソフト dia の改良版


Commit MetaInfo

Révision9f7e2a9b612f117602a775cfb4c5aee529ab4154 (tree)
l'heure2014-06-08 17:57:32
AuteurHans Breuer <hans@breu...>
CommiterHans Breuer

Message de Log

cgm: replace magic numbers with named constants

No behavior change intended nor observed. There is no effect on the
exported files.

Change Summary

Modification

--- a/plug-ins/cgm/cgm.c
+++ b/plug-ins/cgm/cgm.c
@@ -25,6 +25,8 @@
2525 #include <config.h>
2626 #endif
2727
28+#include "cgm.h"
29+
2830 #include <stdio.h>
2931 #include <string.h>
3032 #include <math.h>
@@ -133,7 +135,7 @@ write_real(FILE *fp, double x)
133135 }
134136
135137 static void
136-write_elhead(FILE *fp, int el_class, int el_id, int nparams)
138+write_elhead(FILE *fp, CgmElementClass el_class, int el_id, int nparams)
137139 {
138140 guint16 head;
139141
@@ -398,7 +400,7 @@ LineAttrCGM *lnew, *lold;
398400
399401 if ( lnew->cap != lold->cap )
400402 {
401- write_elhead(renderer->file, 5, 37, 4);
403+ write_elhead(renderer->file, CGM_ATTRIB, CGM_LINE_CAP, 4);
402404 write_int16(renderer->file, lnew->cap);
403405 write_int16(renderer->file, 3); /* cap of dashlines match */
404406 /* normal cap */
@@ -406,19 +408,19 @@ LineAttrCGM *lnew, *lold;
406408 }
407409 if ( lnew->join != lold->join )
408410 {
409- write_elhead(renderer->file, 5, 38, 2);
411+ write_elhead(renderer->file, CGM_ATTRIB, CGM_LINE_JOIN, 2);
410412 write_int16(renderer->file, lnew->join);
411413 lold->join = lnew->join;
412414 }
413415 if ( lnew->style != lold->style )
414416 {
415- write_elhead(renderer->file, 5, 2, 2);
417+ write_elhead(renderer->file, CGM_ATTRIB, CGM_LINE_TYPE, 2);
416418 write_int16(renderer->file, lnew->style);
417419 lold->style = lnew->style;
418420 }
419421 if ( lnew->width != lold->width )
420422 {
421- write_elhead(renderer->file, 5, 3, REALSIZE);
423+ write_elhead(renderer->file, CGM_ATTRIB, CGM_LINE_WIDTH, REALSIZE);
422424 write_real(renderer->file, lnew->width);
423425 lold->width = lnew->width;
424426 }
@@ -428,7 +430,7 @@ LineAttrCGM *lnew, *lold;
428430 lnew->color.blue != lold->color.blue ||
429431 lnew->color.alpha != lold->color.alpha)
430432 {
431- write_elhead(renderer->file, 5, 4, 3); /* line colour */
433+ write_elhead(renderer->file, CGM_ATTRIB, CGM_LINE_COLOR, 3); /* line color */
432434 write_colour(renderer->file, &lnew->color);
433435 putc(0, renderer->file);
434436 lold->color = lnew->color;
@@ -464,7 +466,7 @@ FillEdgeAttrCGM *fnew, *fold;
464466 fnew->edgevis = 0; /* edge off */
465467 if ( fnew->edgevis != fold->edgevis )
466468 {
467- write_elhead(renderer->file, 5, 30, 2);
469+ write_elhead(renderer->file, CGM_ATTRIB, CGM_EDGE_VISIBILITY, 2);
468470 write_int16(renderer->file, fnew->edgevis);
469471 fold->edgevis = fnew->edgevis;
470472 }
@@ -474,13 +476,13 @@ FillEdgeAttrCGM *fnew, *fold;
474476 fnew->edgevis = 1; /* edge on */
475477 if ( fnew->edgevis != fold->edgevis )
476478 {
477- write_elhead(renderer->file, 5, 30, 2);
479+ write_elhead(renderer->file, CGM_ATTRIB, CGM_EDGE_VISIBILITY, 2);
478480 write_int16(renderer->file, fnew->edgevis);
479481 fold->edgevis = fnew->edgevis;
480482 }
481483 if ( fnew->cap != fold->cap )
482484 {
483- write_elhead(renderer->file, 5, 44, 4);
485+ write_elhead(renderer->file, CGM_ATTRIB, CGM_EDGE_CAP, 4);
484486 write_int16(renderer->file, fnew->cap);
485487 write_int16(renderer->file, 3); /* cap of dashlines match */
486488 /* normal cap */
@@ -488,19 +490,19 @@ FillEdgeAttrCGM *fnew, *fold;
488490 }
489491 if ( fnew->join != fold->join )
490492 {
491- write_elhead(renderer->file, 5, 45, 2);
493+ write_elhead(renderer->file, CGM_ATTRIB, CGM_EDGE_JOIN, 2);
492494 write_int16(renderer->file, fnew->join);
493- fold->join = fnew->join;
495+ fold->join = fnew->join;
494496 }
495497 if ( fnew->style != fold->style )
496498 {
497- write_elhead(renderer->file, 5, 27, 2);
499+ write_elhead(renderer->file, CGM_ATTRIB, CGM_EDGE_TYPE, 2);
498500 write_int16(renderer->file, fnew->style);
499501 fold->style = fnew->style;
500502 }
501503 if ( fnew->width != fold->width )
502504 {
503- write_elhead(renderer->file, 5, 28, REALSIZE);
505+ write_elhead(renderer->file, CGM_ATTRIB, CGM_EDGE_WIDTH, REALSIZE);
504506 write_real(renderer->file, fnew->width);
505507 fold->width = fnew->width;
506508 }
@@ -510,7 +512,7 @@ FillEdgeAttrCGM *fnew, *fold;
510512 fnew->color.blue != fold->color.blue ||
511513 fnew->color.alpha != fold->color.alpha)
512514 {
513- write_elhead(renderer->file, 5, 29, 3); /* line colour */
515+ write_elhead(renderer->file, CGM_ATTRIB, CGM_EDGE_COLOR, 3); /* line color */
514516 write_colour(renderer->file, &fnew->color);
515517 putc(0, renderer->file);
516518 fold->color = fnew->color;
@@ -522,7 +524,7 @@ FillEdgeAttrCGM *fnew, *fold;
522524 fnew->fill_style = 4; /* empty */
523525 if ( fnew->fill_style != fold->fill_style )
524526 {
525- write_elhead(renderer->file, 5, 22, 2);
527+ write_elhead(renderer->file, CGM_ATTRIB, CGM_INTERIOR_STYLE, 2);
526528 write_int16(renderer->file, fnew->fill_style);
527529 fold->fill_style = fnew->fill_style;
528530 }
@@ -532,7 +534,7 @@ FillEdgeAttrCGM *fnew, *fold;
532534 fnew->fill_style = 1; /* solid fill */
533535 if ( fnew->fill_style != fold->fill_style )
534536 {
535- write_elhead(renderer->file, 5, 22, 2);
537+ write_elhead(renderer->file, CGM_ATTRIB, CGM_INTERIOR_STYLE, 2);
536538 write_int16(renderer->file, fnew->fill_style);
537539 fold->fill_style = fnew->fill_style;
538540 }
@@ -542,7 +544,7 @@ FillEdgeAttrCGM *fnew, *fold;
542544 fnew->fill_color.blue != fold->fill_color.blue ||
543545 fnew->fill_color.alpha != fold->fill_color.alpha)
544546 {
545- write_elhead(renderer->file, 5, 23, 3); /* fill colour */
547+ write_elhead(renderer->file, CGM_ATTRIB, CGM_FILL_COLOR, 3); /* fill color */
546548 write_colour(renderer->file, &fnew->fill_color);
547549 putc(0, renderer->file);
548550 fold->fill_color = fnew->fill_color;
@@ -565,7 +567,7 @@ TextAttrCGM *tnew, *told;
565567 */
566568 if ( tnew->font_num != told->font_num )
567569 {
568- write_elhead(renderer->file, 5, 10, 2);
570+ write_elhead(renderer->file, CGM_ATTRIB, CGM_TEXT_FONT_INDEX, 2);
569571 write_int16(renderer->file, tnew->font_num);
570572 told->font_num = tnew->font_num;
571573 }
@@ -581,7 +583,7 @@ TextAttrCGM *tnew, *told;
581583 h_basecap = 0.9 * (tnew->font_height -
582584 dia_font_descent("Aq",renderer->font,
583585 tnew->font_height));
584- write_elhead(renderer->file, 5, 15, REALSIZE);
586+ write_elhead(renderer->file, CGM_ATTRIB, CGM_CHARACTER_HEIGHT, REALSIZE);
585587 write_real(renderer->file, h_basecap);
586588 told->font_height = tnew->font_height;
587589 }
@@ -592,7 +594,7 @@ TextAttrCGM *tnew, *told;
592594 tnew->color.blue != told->color.blue ||
593595 tnew->color.alpha != told->color.alpha)
594596 {
595- write_elhead(renderer->file, 5, 14, 3); /* text colour */
597+ write_elhead(renderer->file, CGM_ATTRIB, CGM_TEXT_COLOR, 3); /* text colour */
596598 write_colour(renderer->file, &tnew->color);
597599 putc(0, renderer->file);
598600 told->color = tnew->color;
@@ -611,9 +613,9 @@ end_render(DiaRenderer *self)
611613 CgmRenderer *renderer = CGM_RENDERER(self);
612614
613615 /* end picture */
614- write_elhead(renderer->file, 0, 5, 0);
616+ write_elhead(renderer->file, CGM_DELIM, CGM_END_PICTURE, 0);
615617 /* end metafile */
616- write_elhead(renderer->file, 0, 2, 0);
618+ write_elhead(renderer->file, CGM_DELIM, CGM_END_METAFILE, 0);
617619
618620 fclose(renderer->file);
619621 }
@@ -718,7 +720,7 @@ set_fillstyle(DiaRenderer *self, FillStyle mode)
718720 #if 0
719721 switch(mode) {
720722 case FILLSTYLE_SOLID:
721- write_elhead(renderer->file, 5, 22, 2);
723+ write_elhead(renderer->file, CGM_ATTRIB, CGM_INTERIOR_STYLE, 2);
722724 write_int16(renderer->file, 1);
723725 break;
724726 default:
@@ -749,7 +751,7 @@ draw_line(DiaRenderer *self,
749751
750752 write_line_attributes(renderer, line_colour);
751753
752- write_elhead(renderer->file, 4, 1, 4 * REALSIZE);
754+ write_elhead(renderer->file, CGM_ELEMENT, CGM_POLYLINE, 2 * 2 * REALSIZE);
753755 write_real(renderer->file, start->x);
754756 write_real(renderer->file, swap_y(renderer, start->y));
755757 write_real(renderer->file, end->x);
@@ -766,7 +768,7 @@ draw_polyline(DiaRenderer *self,
766768
767769 write_line_attributes(renderer, line_colour);
768770
769- write_elhead(renderer->file, 4, 1, num_points * 2 * REALSIZE);
771+ write_elhead(renderer->file, CGM_ELEMENT, CGM_POLYLINE, num_points * 2 * REALSIZE);
770772 for (i = 0; i < num_points; i++) {
771773 write_real(renderer->file, points[i].x);
772774 write_real(renderer->file, swap_y(renderer, points[i].y));
@@ -783,7 +785,7 @@ draw_polygon (DiaRenderer *self,
783785
784786 write_filledge_attributes(renderer, fill, stroke);
785787
786- write_elhead(renderer->file, 4, 7, num_points * 2 * REALSIZE);
788+ write_elhead(renderer->file, CGM_ELEMENT, CGM_POLYGON, num_points * 2 * REALSIZE);
787789 for (i = 0; i < num_points; i++) {
788790 write_real(renderer->file, points[i].x);
789791 write_real(renderer->file, swap_y(renderer, points[i].y));
@@ -799,7 +801,7 @@ draw_rect(DiaRenderer *self,
799801
800802 write_filledge_attributes(renderer, fill, stroke);
801803
802- write_elhead(renderer->file, 4, 11, 4 * REALSIZE);
804+ write_elhead(renderer->file, CGM_ELEMENT, CGM_RECTANGLE, 4 * REALSIZE);
803805 write_real(renderer->file, ul_corner->x);
804806 write_real(renderer->file, swap_y(renderer, ul_corner->y));
805807 write_real(renderer->file, lr_corner->x);
@@ -807,11 +809,11 @@ draw_rect(DiaRenderer *self,
807809 }
808810
809811 static void
810-write_ellarc(CgmRenderer *renderer,
811- int elemid,
812- Point *center,
813- real width, real height,
814- real angle1, real angle2 )
812+write_ellarc (CgmRenderer *renderer,
813+ CgmElementId elemid,
814+ Point *center,
815+ real width, real height,
816+ real angle1, real angle2 )
815817 {
816818 real rx = width / 2, ry = height / 2;
817819 int len;
@@ -828,8 +830,8 @@ write_ellarc(CgmRenderer *renderer,
828830 /*
829831 ** Elliptical Arc (18) or Elliptical Arc close (19).
830832 */
831- len = elemid == 18 ? (10 * REALSIZE) : (10 * REALSIZE + 2);
832- write_elhead(renderer->file, 4, elemid, len);
833+ len = elemid == CGM_ELLIPTICAL_ARC ? (10 * REALSIZE) : (10 * REALSIZE + 2);
834+ write_elhead(renderer->file, CGM_ELEMENT, elemid, len);
833835 write_real(renderer->file, center->x); /* center */
834836 write_real(renderer->file, ynew);
835837 write_real(renderer->file, center->x + rx); /* axes 1 */
@@ -845,7 +847,7 @@ write_ellarc(CgmRenderer *renderer,
845847 /*
846848 ** Elliptical arc close, use PIE closure.
847849 */
848- if ( elemid == 19 )
850+ if ( elemid == CGM_ELLIPTICAL_ARC_CLOSE )
849851 write_int16(renderer->file, 0);
850852 }
851853
@@ -860,7 +862,7 @@ draw_arc(DiaRenderer *self,
860862 CgmRenderer *renderer = CGM_RENDERER(self);
861863
862864 write_line_attributes(renderer, colour);
863- write_ellarc(renderer, 18, center, width, height, angle1, angle2);
865+ write_ellarc(renderer, CGM_ELLIPTICAL_ARC, center, width, height, angle1, angle2);
864866 }
865867
866868 static void
@@ -873,7 +875,7 @@ fill_arc(DiaRenderer *self,
873875 CgmRenderer *renderer = CGM_RENDERER(self);
874876
875877 write_filledge_attributes(renderer, colour, NULL);
876- write_ellarc(renderer, 19, center, width, height, angle1, angle2);
878+ write_ellarc(renderer, CGM_ELLIPTICAL_ARC_CLOSE, center, width, height, angle1, angle2);
877879 }
878880
879881 static void
@@ -888,7 +890,7 @@ draw_ellipse(DiaRenderer *self,
888890 write_filledge_attributes(renderer, fill, stroke);
889891
890892 ynew = swap_y(renderer, center->y);
891- write_elhead(renderer->file, 4, 17, 6 * REALSIZE);
893+ write_elhead(renderer->file, CGM_ELEMENT, CGM_ELLIPSE, 6 * REALSIZE);
892894 write_real(renderer->file, center->x); /* center */
893895 write_real(renderer->file, ynew);
894896 write_real(renderer->file, center->x + width/2); /* axes 1 */
@@ -919,7 +921,7 @@ write_bezier(CgmRenderer *renderer,
919921 g_warning("only first BezPoint can be a BEZ_MOVE_TO");
920922 break;
921923 case BEZ_LINE_TO:
922- write_elhead(renderer->file, 4, 1, 4 * REALSIZE);
924+ write_elhead(renderer->file, CGM_ELEMENT, CGM_POLYLINE, 4 * REALSIZE);
923925 write_real(renderer->file, current.x);
924926 write_real(renderer->file, current.y);
925927 write_real(renderer->file, points[i].p1.x);
@@ -928,7 +930,7 @@ write_bezier(CgmRenderer *renderer,
928930 current.y = swap_y(renderer, points[i].p1.y);
929931 break;
930932 case BEZ_CURVE_TO:
931- write_elhead(renderer->file, 4, 26, 8 * REALSIZE + 2);
933+ write_elhead(renderer->file, CGM_ELEMENT, CGM_POLYBEZIER, 8 * REALSIZE + 2);
932934 write_int16(renderer->file, 1);
933935 write_real(renderer->file, current.x);
934936 write_real(renderer->file, current.y);
@@ -979,9 +981,9 @@ draw_beziergon (DiaRenderer *self,
979981 /*
980982 ** A filled bezier is created by using it within a figure.
981983 */
982- write_elhead(renderer->file, 0, 8, 0); /* begin figure */
984+ write_elhead(renderer->file, CGM_DELIM, CGM_BEGIN_FIGURE, 0); /* begin figure */
983985 write_bezier(renderer, points, numpoints);
984- write_elhead(renderer->file, 0, 9, 0); /* end figure */
986+ write_elhead(renderer->file, CGM_DELIM, CGM_END_FIGURE, 0); /* end figure */
985987 }
986988
987989
@@ -1019,7 +1021,7 @@ draw_string(DiaRenderer *self,
10191021 }
10201022 /* work out size of first chunk of text */
10211023 chunk = MIN(maxfirstchunk, len);
1022- write_elhead(renderer->file, 4, 4, 2 * REALSIZE + 2 + 1 + chunk);
1024+ write_elhead(renderer->file, CGM_ELEMENT, CGM_TEXT, 2 * REALSIZE + 2 + 1 + chunk);
10231025 write_real(renderer->file, x);
10241026 write_real(renderer->file, y);
10251027 write_int16(renderer->file, (len == chunk)); /* last chunk? */
@@ -1033,7 +1035,7 @@ draw_string(DiaRenderer *self,
10331035 while (len > 0) {
10341036 /* append text */
10351037 chunk = MIN(maxappendchunk, len);
1036- write_elhead(renderer->file, 4, 6, 2 + 1 + chunk);
1038+ write_elhead(renderer->file, CGM_ELEMENT, CGM_APPEND_TEXT, 2 + 1 + chunk);
10371039 write_int16(renderer->file, (len == chunk));
10381040 putc(chunk, renderer->file);
10391041 fwrite(text, sizeof(char), chunk, renderer->file);
@@ -1079,7 +1081,7 @@ draw_image(DiaRenderer *self,
10791081 clines = chunk / rowlen;
10801082 chunk = clines * rowlen;
10811083
1082- write_elhead(renderer->file, 4, 9, 6*REALSIZE + 8 + chunk);
1084+ write_elhead(renderer->file, CGM_ELEMENT, CGM_CELL_ARRAY, 6*REALSIZE + 8 + chunk);
10831085 write_real(renderer->file, x1); /* first corner */
10841086 write_real(renderer->file, y1);
10851087 write_real(renderer->file, x2); /* second corner */
@@ -1091,7 +1093,7 @@ draw_image(DiaRenderer *self,
10911093 write_int16(renderer->file, dia_image_width(image));
10921094 write_int16(renderer->file, clines);
10931095
1094- write_int16(renderer->file, 8); /* colour precision */
1096+ write_int16(renderer->file, 8); /* color precision */
10951097 write_int16(renderer->file, 1); /* packed encoding */
10961098
10971099 fwrite(ptr, sizeof(guint8), chunk, renderer->file);
@@ -1128,14 +1130,14 @@ export_cgm(DiagramData *data, DiaContext *ctx,
11281130
11291131 /* write BEGMF */
11301132 len = strlen(dia_version_string);
1131- write_elhead(file, 0, 1, len + 1);
1133+ write_elhead(file, CGM_DELIM, CGM_BEGIN_METAFILE, len + 1);
11321134 putc(len, file);
11331135 fwrite(dia_version_string, sizeof(char), len, file);
11341136 if (!IS_ODD(len))
11351137 putc(0, file);
11361138
11371139 /* write metafile version */
1138- write_elhead(file, 1, 1, 2);
1140+ write_elhead(file, CGM_DESC, CGM_METAFILE_VERSION, 2);
11391141 write_uint16(file, 3); /* use version 3 because we may use polybeziers */
11401142
11411143 #if 0
@@ -1149,48 +1151,48 @@ export_cgm(DiagramData *data, DiaContext *ctx,
11491151 #endif
11501152
11511153 /* set integer precision */
1152- write_elhead(file, 1, 4, 2);
1154+ write_elhead(file, CGM_DESC, CGM_INTEGER_PRECISION, 2);
11531155 write_int16(file, 16);
11541156
11551157 /* write element virtual device unit type */
1156- write_elhead(file, 1, 3, 2);
1158+ write_elhead(file, CGM_DESC, CGM_VDC_TYPE, 2);
11571159 write_int16(file, 1); /* real number */
11581160
11591161 /* write the colour precision */
1160- write_elhead(file, 1, 7, 2);
1161- write_int16(file, 8); /* 8 bits per chanel */
1162+ write_elhead(file, CGM_DESC, CGM_COLOUR_PRECISION, 2);
1163+ write_int16(file, 8); /* 8 bits per channel */
11621164
11631165 /* write element list command */
1164- write_elhead(file, 1, 11, 6);
1166+ write_elhead(file, CGM_DESC, CGM_METAFILE_ELEMENT_LIST, 6);
11651167 write_int16(file, 1);
11661168 write_int16(file, -1);
11671169 write_int16(file, 5);
11681170
11691171 /* write font list */
11701172 init_fonts();
1171- write_elhead(file, 1, 13, fontlistlen);
1173+ write_elhead(file, CGM_DESC, CGM_FONT_LIST, fontlistlen);
11721174 fwrite(fontlist, sizeof(char), fontlistlen, file);
11731175 if (IS_ODD(fontlistlen))
11741176 putc(0, file);
11751177
11761178 /* begin picture */
11771179 len = strlen(diafilename);
1178- write_elhead(file, 0, 3, len + 1);
1180+ write_elhead(file, CGM_DELIM, CGM_BEGIN_PICTURE, len + 1);
11791181 putc(len, file);
11801182 fwrite(diafilename, sizeof(char), len, file);
11811183 if (!IS_ODD(len))
11821184 putc(0, file);
11831185
1184- /* write the colour mode string */
1185- write_elhead(file, 2, 2, 2);
1186- write_int16(file, 1); /* direct colour mode (as opposed to indexed) */
1186+ /* write the color mode string */
1187+ write_elhead(file, CGM_PICDESC, CGM_COLOR_SELECTION_MODE, 2);
1188+ write_int16(file, 1); /* direct color mode (as opposed to indexed) */
11871189
11881190 /* write edge width mode */
1189- write_elhead(file, 2, 5, 2);
1191+ write_elhead(file, CGM_PICDESC, CGM_EDGE_WIDTH_SPECIFICATION_MODE, 2);
11901192 write_int16(file, 0); /* relative to virtual device coordinates */
11911193
11921194 /* write line width mode */
1193- write_elhead(file, 2, 3, 2);
1195+ write_elhead(file, CGM_PICDESC, CGM_LINE_WIDTH_SPECIFICATION_MODE, 2);
11941196 write_int16(file, 0); /* relative to virtual device coordinates */
11951197
11961198 extent = &data->extents;
@@ -1200,7 +1202,7 @@ export_cgm(DiagramData *data, DiaContext *ctx,
12001202 ** 'portable' CGM
12011203 */
12021204 /* write extents */
1203- write_elhead(file, 2, 6, 4 * REALSIZE);
1205+ write_elhead(file, CGM_PICDESC, CGM_VDC_EXTENT, 4 * REALSIZE);
12041206 write_real(file, extent->left);
12051207 write_real(file, extent->top);
12061208 write_real(file, extent->right);
@@ -1208,23 +1210,23 @@ export_cgm(DiagramData *data, DiaContext *ctx,
12081210 renderer->y1 = extent->top;
12091211 renderer->y0 = extent->bottom;
12101212
1211- /* write back colour */
1212- write_elhead(file, 2, 7, 3);
1213+ /* write back color */
1214+ write_elhead(file, CGM_PICDESC, CGM_BACKGROUND_COLOR, 3);
12131215 write_colour(file, &data->bg_color);
12141216 putc(0, file);
12151217
12161218 /* begin the picture body */
1217- write_elhead(file, 0, 4, 0);
1219+ write_elhead(file, CGM_DELIM, CGM_BEGIN_PICTURE_BODY, 0);
12181220
12191221 /* make text be the right way up */
1220- write_elhead(file, 5, 16, 4 * REALSIZE);
1222+ write_elhead(file, CGM_ATTRIB, CGM_CHARACTER_ORIENTATION, 4 * REALSIZE);
12211223 write_real(file, 0);
12221224 write_real(file, 1);
12231225 write_real(file, 1);
12241226 write_real(file, 0);
12251227
12261228 /* set the text alignment to left/base */
1227- write_elhead(file, 5, 18, 4 + 2 * REALSIZE);
1229+ write_elhead(file, CGM_ATTRIB, CGM_TEXT_ALIGNMENT, 4 + 2 * REALSIZE);
12281230 write_int16(file, 1); /* left */
12291231 write_int16(file, 4); /* base */
12301232 write_real(file, 0.0);
--- /dev/null
+++ b/plug-ins/cgm/cgm.h
@@ -0,0 +1,110 @@
1+/* Dia -- an diagram creation/manipulation program
2+ * Copyright (C) 1998 Alexander Larsson
3+ *
4+ * cgm.h -- Named constants for Dia CGM plug-in
5+ * Copyright (C) 2014 Hans Breuer <hans@breuer.org>
6+ *
7+ * This program is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation; either version 2 of the License, or
10+ * (at your option) any later version.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program; if not, write to the Free Software
19+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20+ */
21+
22+/*!
23+ * Including parts of CGM v3.0 specification via:
24+ * http://en.wikipedia.org/wiki/Computer_Graphics_Metafile#cite_note-2
25+ */
26+
27+typedef enum {
28+ CGM_DELIM = 0, /*!< Metafile Delimiter Elements */
29+ CGM_DESC = 1, /*!< Metafile Descriptor Elements */
30+ CGM_PICDESC = 2, /*!< Metafile Picture Descriptor Elements */
31+ CGM_ELEMENT = 4, /*!< Metafile Graphical Primitives ... */
32+ CGM_ATTRIB = 5 /*!< ... with Associated Attributes */
33+} CgmElementClass;
34+
35+/* CGM_DELIM: Metafile Delimiter Elements */
36+typedef enum {
37+ CG_NOOP = 0,
38+ CGM_BEGIN_METAFILE = 1, /*!< has 1 parameter: P1: (string fixed) metafile name */
39+ CGM_END_METAFILE = 2,
40+ CGM_BEGIN_PICTURE = 3, /*!< has 1 parameter: P1: (string fixed) picture name */
41+ CGM_BEGIN_PICTURE_BODY = 4,
42+ CGM_END_PICTURE = 5,
43+ CGM_BEGIN_SEGMENT = 6, /*!< has 1 parameter: P1: (name) segment identifier */
44+ CGM_END_SEGMENT = 7,
45+ CGM_BEGIN_FIGURE = 8, /*!< CGM v3? */
46+ CGM_END_FIGURE = 9 /*!< CGM v3? */
47+} CgmDelimElementId;
48+/* CGM_DESC: Metafile Descriptor Elements */
49+typedef enum {
50+ CGM_METAFILE_VERSION = 1, /*!< valid values are 1, 2, 3, 4 */
51+ CGM_METAFILE_DESCRIPTION = 2,
52+ CGM_VDC_TYPE = 3, /*<! 0,1 */
53+ CGM_INTEGER_PRECISION = 4, /*!< 8,16,24,32 */
54+ CGM_REAL_PRECISION = 5, /*!< {0,1}, {9,12,16,32}, {23,52,16,32} - 32/64 bit, floating/fixed point */
55+ CGM_COLOUR_PRECISION = 7, /*!< 8,16,24,32 */
56+ CGM_METAFILE_ELEMENT_LIST = 11,
57+ CGM_FONT_LIST = 13
58+} CgmDescElementId;
59+/* CGM_PICDESC: Metafile Picture Descriptor Elements */
60+typedef enum {
61+ CGM_COLOR_SELECTION_MODE = 2,
62+ CGM_LINE_WIDTH_SPECIFICATION_MODE = 3,
63+ CGM_EDGE_WIDTH_SPECIFICATION_MODE = 5,
64+ CGM_VDC_EXTENT = 6,
65+ CGM_BACKGROUND_COLOR = 7
66+} CgmPicdescElementId;
67+/* CGM_ELEMENT: Metafile Graphical Element */
68+typedef enum {
69+ CGM_POLYLINE = 1,
70+ CGM_DISJOINT_POLYLINE = 2,
71+ CGM_POLYMARKER = 3,
72+ CGM_TEXT = 4,
73+ CGM_RESTRICTED_TEXT = 5,
74+ CGM_APPEND_TEXT = 6,
75+ CGM_POLYGON = 7,
76+ CGM_POLYGON_SET = 8,
77+ CGM_CELL_ARRAY = 9, /*!< aka. bitmap */
78+ CGM_RECTANGLE = 11,
79+ CGM_CIRCLE = 12,
80+ CGM_CIRCULAR_ARC_CENTER = 15,
81+ CGM_CIRCULAR_ARC_CENTER_CLOSE = 16,
82+ CGM_ELLIPSE = 17,
83+ CGM_ELLIPTICAL_ARC = 18,
84+ CGM_ELLIPTICAL_ARC_CLOSE = 19,
85+ CGM_NURBS = 25, /*!< CGM 3.0: NON-UNIFORM RATIONAL B-SPLINE */
86+ CGM_POLYBEZIER = 26 /*!< CGM 3.0 */
87+} CgmElementId;
88+
89+/* CGM_ATTRIB: Metafile Graphical ... Associated Attributes */
90+enum CgmAttribElementId {
91+ CGM_LINE_TYPE = 2, /*!< v1: (1=solid or 2=dashed) v3?: adds (3=dot 4=dash-dot 5=dash-dot-dot) */
92+ CGM_LINE_WIDTH = 3,
93+ CGM_LINE_COLOR = 4,
94+ CGM_TEXT_FONT_INDEX = 10,
95+ CGM_TEXT_COLOR = 14,
96+ CGM_CHARACTER_HEIGHT = 15,
97+ CGM_CHARACTER_ORIENTATION = 16,
98+ CGM_TEXT_ALIGNMENT = 18,
99+ /* CGM_ATTRIB: Filled-Area ... Attributes */
100+ CGM_INTERIOR_STYLE = 22, /*!< (1= solid or 4 = empty) */
101+ CGM_FILL_COLOR = 23,
102+ CGM_EDGE_TYPE = 27, /*!< (1=solid or 2=dashed) */
103+ CGM_EDGE_WIDTH = 28,
104+ CGM_EDGE_COLOR = 29,
105+ CGM_EDGE_VISIBILITY = 30, /*!< (1 = on) */
106+ CGM_LINE_CAP = 37,
107+ CGM_LINE_JOIN = 38,
108+ CGM_EDGE_CAP = 44,
109+ CGM_EDGE_JOIN = 45,
110+};