作図ソフト dia の改良版
修訂 | 8ef8e78d630e1f708cded07cc327e227597d82cf (tree) |
---|---|
時間 | 2007-10-07 05:06:42 |
作者 | Hans Breuer <hans@breu...> |
Commiter | Hans Breuer |
major restructuring - getting calculate and draw by function pointer. A
2007-10-06 Hans Breuer <hans@breuer.org>
* lib/arrows.c : major restructuring - getting calculate and draw by
function pointer. A lot of arrows are converted to the new style thus
arrow_bbox() can give the correct bounding box.
* objects/standard/arc.c : bug #340705 and bug #477569
objects/standard/bezier.c : bug #300055
objects/standard/line.c objects/standard/polyline.c
objects/standard/zigzagline.c : not using *BBExtra to adjust the
bounding box for arrows but instead a combination of arrow_bbox()
and calculate_arrow_point()
* lib/bounding_box.c : just a comment for now
* samples/arrows.dia : more coverage
svn path=/trunk/; revision=3800
@@ -1,5 +1,21 @@ | ||
1 | 1 | 2007-10-06 Hans Breuer <hans@breuer.org> |
2 | 2 | |
3 | + * lib/arrows.c : major restructuring - getting calculate and draw by | |
4 | + function pointer. A lot of arrows are converted to the new style thus | |
5 | + arrow_bbox() can give the correct bounding box. | |
6 | + * objects/standard/arc.c : bug #340705 and bug #477569 | |
7 | + objects/standard/bezier.c : bug #300055 | |
8 | + objects/standard/line.c objects/standard/polyline.c | |
9 | + objects/standard/zigzagline.c : not using *BBExtra to adjust the | |
10 | + bounding box for arrows but instead a combination of arrow_bbox() | |
11 | + and calculate_arrow_point() | |
12 | + * lib/bounding_box.c : just a comment for now | |
13 | + * samples/arrows.dia : more coverage | |
14 | + | |
15 | +2007-10-06 Hans Breuer <hans@breuer.org> | |
16 | + | |
17 | + * makefile.msc bindings/makefile.msc : integrated bindings in the build | |
18 | + | |
3 | 19 | * configure.in acinclude.m4 Makefile.am bindings/Makefile.am : |
4 | 20 | build bindings given --with-swig (and SWIG is found) |
5 | 21 | * bindings/dia-diagramdata.h bindings/dia-extra.cpp |
@@ -58,7 +74,7 @@ | ||
58 | 74 | settings from prefs on startup. Fixes bug #479244. Also a bit of |
59 | 75 | cleanup. |
60 | 76 | |
61 | -2007-09-21 Hans Breuer <hans@breuer.org> | |
77 | +2007-09-22 Hans Breuer <hans@breuer.org> | |
62 | 78 | |
63 | 79 | * lib/arrow.[hc] : refactoring to more information hiding: |
64 | 80 | type menudesc renamed to ArrowDesc and moved arrow_types to arrow.c. |
@@ -40,48 +40,6 @@ | ||
40 | 40 | #include "widgets.h" |
41 | 41 | #include "intl.h" |
42 | 42 | |
43 | -struct ArrowDesc { | |
44 | - const char *name; | |
45 | - ArrowType enum_value; | |
46 | -}; | |
47 | - | |
48 | -struct ArrowDesc arrow_types[] = | |
49 | - {{N_("None"),ARROW_NONE}, | |
50 | - {N_("Lines"),ARROW_LINES}, | |
51 | - {N_("Hollow Triangle"),ARROW_HOLLOW_TRIANGLE}, | |
52 | - {N_("Filled Triangle"),ARROW_FILLED_TRIANGLE}, | |
53 | - {N_("Unfilled Triangle"),ARROW_UNFILLED_TRIANGLE}, | |
54 | - {N_("Hollow Diamond"),ARROW_HOLLOW_DIAMOND}, | |
55 | - {N_("Filled Diamond"),ARROW_FILLED_DIAMOND}, | |
56 | - {N_("Half Diamond"), ARROW_HALF_DIAMOND}, | |
57 | - {N_("Half Head"),ARROW_HALF_HEAD}, | |
58 | - {N_("Slashed Cross"),ARROW_SLASHED_CROSS}, | |
59 | - {N_("Filled Ellipse"),ARROW_FILLED_ELLIPSE}, | |
60 | - {N_("Hollow Ellipse"),ARROW_HOLLOW_ELLIPSE}, | |
61 | - {N_("Filled Dot"),ARROW_FILLED_DOT}, | |
62 | - {N_("Dimension Origin"),ARROW_DIMENSION_ORIGIN}, | |
63 | - {N_("Blanked Dot"),ARROW_BLANKED_DOT}, | |
64 | - {N_("Double Hollow Triangle"),ARROW_DOUBLE_HOLLOW_TRIANGLE}, | |
65 | - {N_("Double Filled Triangle"),ARROW_DOUBLE_FILLED_TRIANGLE}, | |
66 | - {N_("Filled Dot and Triangle"), ARROW_FILLED_DOT_N_TRIANGLE}, | |
67 | - {N_("Filled Box"),ARROW_FILLED_BOX}, | |
68 | - {N_("Blanked Box"),ARROW_BLANKED_BOX}, | |
69 | - {N_("Slashed"),ARROW_SLASH_ARROW}, | |
70 | - {N_("Integral Symbol"),ARROW_INTEGRAL_SYMBOL}, | |
71 | - {N_("Crow Foot"),ARROW_CROW_FOOT}, | |
72 | - {N_("Cross"),ARROW_CROSS}, | |
73 | - {N_("1-or-many"),ARROW_ONE_OR_MANY}, | |
74 | - {N_("0-or-many"),ARROW_NONE_OR_MANY}, | |
75 | - {N_("1-or-0"),ARROW_ONE_OR_NONE}, | |
76 | - {N_("1 exactly"),ARROW_ONE_EXACTLY}, | |
77 | - {N_("Filled Concave"),ARROW_FILLED_CONCAVE}, | |
78 | - {N_("Blanked Concave"),ARROW_BLANKED_CONCAVE}, | |
79 | - {N_("Round"), ARROW_ROUNDED}, | |
80 | - {N_("Open Round"), ARROW_OPEN_ROUNDED}, | |
81 | - {N_("Backslash"),ARROW_BACKSLASH}, | |
82 | - {N_("Infinite Line"),ARROW_THREE_DOTS}, | |
83 | - {NULL,0}}; | |
84 | - | |
85 | 43 | /**** prototypes ****/ |
86 | 44 | static void |
87 | 45 | draw_empty_ellipse(DiaRenderer *renderer, Point *to, Point *from, |
@@ -89,14 +47,14 @@ draw_empty_ellipse(DiaRenderer *renderer, Point *to, Point *from, | ||
89 | 47 | Color *fg_color); |
90 | 48 | static void |
91 | 49 | calculate_double_arrow(Point *second_to, Point *second_from, |
92 | - Point *to, Point *from, real length); | |
50 | + const Point *to, const Point *from, real length); | |
93 | 51 | |
94 | 52 | static void |
95 | 53 | draw_crow_foot(DiaRenderer *renderer, Point *to, Point *from, |
96 | 54 | real length, real width, real linewidth, |
97 | 55 | Color *fg_color,Color *bg_color); |
98 | -static void | |
99 | -calculate_diamond(Point *poly/*[4]*/, Point *to, Point *from, | |
56 | +static int | |
57 | +calculate_diamond(Point *poly/*[4]*/, const Point *to, const Point *from, | |
100 | 58 | real length, real width); |
101 | 59 | |
102 | 60 | /** The function calculate_arrow_point adjusts the placement of the line and |
@@ -321,7 +279,7 @@ calculate_arrow_point(const Arrow *arrow, const Point *to, const Point *from, | ||
321 | 279 | * @param length How long the arrowhead should be. |
322 | 280 | * @param width How wide the arrowhead should be. |
323 | 281 | */ |
324 | -static void | |
282 | +static int | |
325 | 283 | calculate_arrow(Point *poly, const Point *to, const Point *from, |
326 | 284 | real length, real width) |
327 | 285 | { |
@@ -353,6 +311,8 @@ calculate_arrow(Point *poly, const Point *to, const Point *from, | ||
353 | 311 | poly[2] = *to; |
354 | 312 | point_sub(&poly[2], &delta); |
355 | 313 | point_add(&poly[2], &orth_delta); |
314 | + | |
315 | + return 3; | |
356 | 316 | } |
357 | 317 | |
358 | 318 | /** Calculate the actual point of a crows-foot arrow. |
@@ -364,8 +324,8 @@ calculate_arrow(Point *poly, const Point *to, const Point *from, | ||
364 | 324 | * @param length How long the arrowhead should be. |
365 | 325 | * @param width How wide the arrowhead should be. |
366 | 326 | */ |
367 | -static void | |
368 | -calculate_crow(Point *poly, Point *to, Point *from, | |
327 | +static int | |
328 | +calculate_crow(Point *poly, const Point *to, const Point *from, | |
369 | 329 | real length, real width) |
370 | 330 | { |
371 | 331 | Point delta; |
@@ -395,6 +355,8 @@ calculate_crow(Point *poly, Point *to, Point *from, | ||
395 | 355 | point_sub(&poly[1], &orth_delta); |
396 | 356 | poly[2] = *to; |
397 | 357 | point_add(&poly[2], &orth_delta); |
358 | + | |
359 | + return 3; | |
398 | 360 | } |
399 | 361 | |
400 | 362 | /** Draw ER arrow for 0..N according to Modern database management, |
@@ -588,7 +550,7 @@ draw_crow_foot(DiaRenderer *renderer, Point *to, Point *from, | ||
588 | 550 | static void |
589 | 551 | draw_lines(DiaRenderer *renderer, Point *to, Point *from, |
590 | 552 | real length, real width, real linewidth, |
591 | - Color *color) | |
553 | + Color *fg_color, Color *bg_color) | |
592 | 554 | { |
593 | 555 | Point poly[3]; |
594 | 556 |
@@ -599,7 +561,14 @@ draw_lines(DiaRenderer *renderer, Point *to, Point *from, | ||
599 | 561 | DIA_RENDERER_GET_CLASS(renderer)->set_linejoin(renderer, LINEJOIN_MITER); |
600 | 562 | DIA_RENDERER_GET_CLASS(renderer)->set_linecaps(renderer, LINECAPS_BUTT); |
601 | 563 | |
602 | - DIA_RENDERER_GET_CLASS(renderer)->draw_polyline(renderer, poly, 3, color); | |
564 | + DIA_RENDERER_GET_CLASS(renderer)->draw_polyline(renderer, poly, 3, fg_color); | |
565 | +} | |
566 | + | |
567 | +static int | |
568 | +calculate_ellipse (Point *poly, const Point *to, const Point *from, | |
569 | + real length, real width) | |
570 | +{ | |
571 | + return calculate_diamond (poly, to, from, length, width); | |
603 | 572 | } |
604 | 573 | |
605 | 574 | /** Draw an arrowhead that is a filled ellipse. |
@@ -734,6 +703,41 @@ draw_empty_ellipse(DiaRenderer *renderer, Point *to, Point *from, | ||
734 | 703 | DIA_RENDERER_GET_CLASS(renderer)->draw_bezier(renderer,bp,sizeof(bp)/sizeof(bp[0]),fg_color); |
735 | 704 | } |
736 | 705 | |
706 | +static int | |
707 | +calculate_box (Point *poly, const Point *to, const Point *from, | |
708 | + real length, real width) | |
709 | +{ | |
710 | + Point vl, vt; | |
711 | + Point bs, be; | |
712 | + | |
713 | + point_copy(&vl,from); point_sub(&vl,to); | |
714 | + if (point_len(&vl) > 0) | |
715 | + point_normalize(&vl); | |
716 | + else { | |
717 | + vl.x = 1.0; vl.y = 0.0; | |
718 | + } | |
719 | + if (!finite(vl.x)) { | |
720 | + vl.x = 1.0; vl.y = 0.0; | |
721 | + } | |
722 | + point_get_perp(&vt,&vl); | |
723 | + | |
724 | + point_copy_add_scaled(&bs,to,&vl,length/4); | |
725 | + point_copy_add_scaled(&be,&bs,&vt,-width/2.0); | |
726 | + point_add_scaled(&bs,&vt,width/2.0); | |
727 | + | |
728 | + point_copy(&poly[0],to); | |
729 | + point_copy(&poly[1],&poly[0]); | |
730 | + point_add_scaled(&poly[0],&vt,width/4.0); | |
731 | + point_add_scaled(&poly[1],&vt,-width/4.0); | |
732 | + point_copy_add_scaled(&poly[2],&poly[1],&vl,length/2.0); | |
733 | + point_copy_add_scaled(&poly[3],&poly[0],&vl,length/2.0); | |
734 | + | |
735 | + poly[4] = bs; | |
736 | + poly[5] = be; | |
737 | + | |
738 | + return 6; | |
739 | +} | |
740 | + | |
737 | 741 | /** Draw an arrow head that is an (optionall) filled box. |
738 | 742 | * @param renderer A renderer instance to draw into |
739 | 743 | * @param to The point that the arrow points to. |
@@ -750,9 +754,7 @@ draw_fill_box(DiaRenderer *renderer, Point *to, Point *from, | ||
750 | 754 | real length, real width, real linewidth, |
751 | 755 | Color *fg_color,Color *bg_color) |
752 | 756 | { |
753 | - Point vl,vt; | |
754 | - Point bs,be; | |
755 | - Point poly[4]; | |
757 | + Point poly[6]; | |
756 | 758 | real lw_factor,clength,cwidth; |
757 | 759 | |
758 | 760 | DIA_RENDERER_GET_CLASS(renderer)->set_linewidth(renderer, linewidth); |
@@ -770,27 +772,7 @@ draw_fill_box(DiaRenderer *renderer, Point *to, Point *from, | ||
770 | 772 | clength = length + lw_factor; |
771 | 773 | cwidth = width + lw_factor; |
772 | 774 | |
773 | - point_copy(&vl,from); point_sub(&vl,to); | |
774 | - if (point_len(&vl) > 0) | |
775 | - point_normalize(&vl); | |
776 | - else { | |
777 | - vl.x = 1.0; vl.y = 0.0; | |
778 | - } | |
779 | - if (!finite(vl.x)) { | |
780 | - vl.x = 1.0; vl.y = 0.0; | |
781 | - } | |
782 | - point_get_perp(&vt,&vl); | |
783 | - | |
784 | - point_copy_add_scaled(&bs,to,&vl,length/4); | |
785 | - point_copy_add_scaled(&be,&bs,&vt,-width/2.0); | |
786 | - point_add_scaled(&bs,&vt,width/2.0); | |
787 | - | |
788 | - point_copy(&poly[0],to); | |
789 | - point_copy(&poly[1],&poly[0]); | |
790 | - point_add_scaled(&poly[0],&vt,cwidth/4.0); | |
791 | - point_add_scaled(&poly[1],&vt,-cwidth/4.0); | |
792 | - point_copy_add_scaled(&poly[2],&poly[1],&vl,clength/2.0); | |
793 | - point_copy_add_scaled(&poly[3],&poly[0],&vl,clength/2.0); | |
775 | + calculate_box (poly, to, from, clength, cwidth); | |
794 | 776 | |
795 | 777 | if (fg_color == bg_color) { |
796 | 778 | DIA_RENDERER_GET_CLASS(renderer)->fill_polygon(renderer, poly, 4, fg_color); |
@@ -798,9 +780,14 @@ draw_fill_box(DiaRenderer *renderer, Point *to, Point *from, | ||
798 | 780 | DIA_RENDERER_GET_CLASS(renderer)->fill_polygon(renderer, poly, 4, bg_color); |
799 | 781 | DIA_RENDERER_GET_CLASS(renderer)->draw_polygon(renderer, poly, 4, fg_color); |
800 | 782 | } |
801 | - DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer,&bs,&be,fg_color); | |
783 | + DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer,&poly[4],&poly[5],fg_color); | |
784 | +} | |
785 | +static int | |
786 | +calculate_dot (Point *poly, const Point *to, const Point *from, | |
787 | + real length, real width) | |
788 | +{ | |
789 | + return calculate_diamond (poly, to, from, length, width); | |
802 | 790 | } |
803 | - | |
804 | 791 | /** Draw a "filled dot" arrow. |
805 | 792 | * @param renderer A renderer instance to draw into |
806 | 793 | * @param to The point that the arrow points to. |
@@ -815,7 +802,7 @@ draw_fill_box(DiaRenderer *renderer, Point *to, Point *from, | ||
815 | 802 | static void |
816 | 803 | draw_fill_dot(DiaRenderer *renderer, Point *to, Point *from, |
817 | 804 | real length, real width, real linewidth, |
818 | - Color *fg_color,Color *bg_color) | |
805 | + Color *fg_color, Color *bg_color) | |
819 | 806 | { |
820 | 807 | BezPoint bp[5]; |
821 | 808 | Point vl,vt; |
@@ -944,6 +931,38 @@ draw_integral(DiaRenderer *renderer, Point *to, Point *from, | ||
944 | 931 | DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &bs, &be, fg_color); |
945 | 932 | DIA_RENDERER_GET_CLASS(renderer)->draw_bezier(renderer,bp,sizeof(bp)/sizeof(bp[0]),fg_color); |
946 | 933 | } |
934 | +static int | |
935 | +calculate_slashed (Point *poly, const Point *to, const Point *from, | |
936 | + real length, real width) | |
937 | +{ | |
938 | + Point vl,vt; | |
939 | + | |
940 | + point_copy(&vl,from); | |
941 | + point_sub(&vl,to); | |
942 | + if (point_len(&vl) > 0) | |
943 | + point_normalize(&vl); | |
944 | + else { | |
945 | + vl.x = 1.0; vl.y = 0.0; | |
946 | + } | |
947 | + if (!finite(vl.x)) { | |
948 | + vl.x = 1.0; vl.y = 0.0; | |
949 | + } | |
950 | + point_get_perp(&vt,&vl); | |
951 | + | |
952 | + point_copy_add_scaled(&poly[2],to,&vl,length/2); | |
953 | + point_copy_add_scaled(&poly[3],&poly[2],&vt,-width/2.0); | |
954 | + point_add_scaled(&poly[2],&vt,width/2.0); | |
955 | + | |
956 | + point_copy_add_scaled(&poly[0],to,&vl,length/2); | |
957 | + point_copy_add_scaled(&poly[1],&poly[0],&vl,length/2); | |
958 | + | |
959 | + point_copy_add_scaled(&poly[4],to,&vl,.1*length); | |
960 | + point_add_scaled(&poly[4],&vt,.4*width); | |
961 | + point_copy_add_scaled(&poly[5],to,&vl,.9*length); | |
962 | + point_add_scaled(&poly[5],&vt,-.4*width); | |
963 | + | |
964 | + return 6; | |
965 | +} | |
947 | 966 | |
948 | 967 | /** Draw the arrowhead that is a line with a slash through it. |
949 | 968 | * @param renderer A renderer instance to draw into |
@@ -960,42 +979,20 @@ draw_integral(DiaRenderer *renderer, Point *to, Point *from, | ||
960 | 979 | static void |
961 | 980 | draw_slashed(DiaRenderer *renderer, Point *to, Point *from, |
962 | 981 | real length, real width, real linewidth, |
963 | - Color *fg_color) | |
982 | + Color *fg_color, Color *bg_color) | |
964 | 983 | { |
965 | - Point vl,vt; | |
966 | - Point bs,be, bs2,be2, bs3,be3; | |
984 | + Point poly[6]; | |
985 | + | |
986 | + calculate_slashed (poly, to, from, length, width); | |
967 | 987 | |
968 | 988 | DIA_RENDERER_GET_CLASS(renderer)->set_linewidth(renderer, linewidth); |
969 | 989 | DIA_RENDERER_GET_CLASS(renderer)->set_linestyle(renderer, LINESTYLE_SOLID); |
970 | 990 | DIA_RENDERER_GET_CLASS(renderer)->set_linejoin(renderer, LINEJOIN_MITER); |
971 | 991 | DIA_RENDERER_GET_CLASS(renderer)->set_linecaps(renderer, LINECAPS_BUTT); |
972 | 992 | |
973 | - point_copy(&vl,from); point_sub(&vl,to); | |
974 | - if (point_len(&vl) > 0) | |
975 | - point_normalize(&vl); | |
976 | - else { | |
977 | - vl.x = 1.0; vl.y = 0.0; | |
978 | - } | |
979 | - if (!finite(vl.x)) { | |
980 | - vl.x = 1.0; vl.y = 0.0; | |
981 | - } | |
982 | - point_get_perp(&vt,&vl); | |
983 | - | |
984 | - point_copy_add_scaled(&bs,to,&vl,length/2); | |
985 | - point_copy_add_scaled(&be,&bs,&vt,-width/2.0); | |
986 | - point_add_scaled(&bs,&vt,width/2.0); | |
987 | - | |
988 | - point_copy_add_scaled(&bs2,to,&vl,length/2); | |
989 | - point_copy_add_scaled(&be2,&bs2,&vl,length/2); | |
990 | - | |
991 | - point_copy_add_scaled(&bs3,to,&vl,.1*length); | |
992 | - point_add_scaled(&bs3,&vt,.4*width); | |
993 | - point_copy_add_scaled(&be3,to,&vl,.9*length); | |
994 | - point_add_scaled(&be3,&vt,-.4*width); | |
995 | - | |
996 | - DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &bs2, &be2, fg_color); | |
997 | - DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &bs, &be, fg_color); | |
998 | - DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &bs3, &be3, fg_color); | |
993 | + DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &poly[0], &poly[1], fg_color); | |
994 | + DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &poly[2], &poly[3], fg_color); | |
995 | + DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &poly[4], &poly[5], fg_color); | |
999 | 996 | } |
1000 | 997 | |
1001 | 998 | /** Calculate positions for the half-head arrow (only left-hand(?) line drawn) |
@@ -1007,20 +1004,19 @@ draw_slashed(DiaRenderer *renderer, Point *to, Point *from, | ||
1007 | 1004 | * @param linewidth The width of the lines used to draw the arrow |
1008 | 1005 | * @bug Describe better what is put into poly. |
1009 | 1006 | */ |
1010 | -static void | |
1011 | -calculate_halfhead(Point *poly, Point *to, Point *from, | |
1012 | - real length, real width, real linewidth) | |
1007 | +static int | |
1008 | +calculate_halfhead(Point *poly, const Point *to, const Point *from, | |
1009 | + real length, real width) | |
1013 | 1010 | { |
1014 | 1011 | Point delta; |
1015 | 1012 | Point orth_delta; |
1016 | 1013 | real len; |
1017 | - real angle, add_len; | |
1014 | + real angle; | |
1018 | 1015 | |
1019 | 1016 | if (width > 0.0000001) { |
1020 | 1017 | angle = atan(length/(width/2)); |
1021 | - add_len = linewidth/cos(angle); | |
1022 | 1018 | } else { |
1023 | - add_len = 0; | |
1019 | + angle = 0; | |
1024 | 1020 | } |
1025 | 1021 | |
1026 | 1022 | delta = *to; |
@@ -1046,9 +1042,10 @@ calculate_halfhead(Point *poly, Point *to, Point *from, | ||
1046 | 1042 | poly[1] = *to; |
1047 | 1043 | poly[2] = *to; |
1048 | 1044 | point_normalize(&delta); |
1049 | - point_scale(&delta, add_len); | |
1045 | + point_scale(&delta, 0); | |
1050 | 1046 | point_sub(&poly[2], &delta); |
1051 | 1047 | /* point_add(&poly[2], &orth_delta);*/ |
1048 | + return 3; | |
1052 | 1049 | } |
1053 | 1050 | |
1054 | 1051 | /** Draw a halfhead arrow. |
@@ -1063,18 +1060,18 @@ calculate_halfhead(Point *poly, Point *to, Point *from, | ||
1063 | 1060 | static void |
1064 | 1061 | draw_halfhead(DiaRenderer *renderer, Point *to, Point *from, |
1065 | 1062 | real length, real width, real linewidth, |
1066 | - Color *color) | |
1063 | + Color *fg_color, Color *bg_color) | |
1067 | 1064 | { |
1068 | 1065 | Point poly[3]; |
1069 | 1066 | |
1070 | - calculate_halfhead(poly, to, from, length, width, linewidth); | |
1067 | + calculate_halfhead(poly, to, from, length, width); | |
1071 | 1068 | |
1072 | 1069 | DIA_RENDERER_GET_CLASS(renderer)->set_linewidth(renderer, linewidth); |
1073 | 1070 | DIA_RENDERER_GET_CLASS(renderer)->set_linestyle(renderer, LINESTYLE_SOLID); |
1074 | 1071 | DIA_RENDERER_GET_CLASS(renderer)->set_linejoin(renderer, LINEJOIN_MITER); |
1075 | 1072 | DIA_RENDERER_GET_CLASS(renderer)->set_linecaps(renderer, LINECAPS_BUTT); |
1076 | 1073 | |
1077 | - DIA_RENDERER_GET_CLASS(renderer)->draw_polyline(renderer, poly, 3, color); | |
1074 | + DIA_RENDERER_GET_CLASS(renderer)->draw_polyline(renderer, poly, 3, fg_color); | |
1078 | 1075 | } |
1079 | 1076 | |
1080 | 1077 | /** Draw a basic triangular arrow. |
@@ -1089,7 +1086,7 @@ draw_halfhead(DiaRenderer *renderer, Point *to, Point *from, | ||
1089 | 1086 | static void |
1090 | 1087 | draw_triangle(DiaRenderer *renderer, Point *to, Point *from, |
1091 | 1088 | real length, real width, real linewidth, |
1092 | - Color *color) | |
1089 | + Color *fg_color, Color *bg_color) | |
1093 | 1090 | { |
1094 | 1091 | Point poly[3]; |
1095 | 1092 |
@@ -1099,7 +1096,7 @@ draw_triangle(DiaRenderer *renderer, Point *to, Point *from, | ||
1099 | 1096 | DIA_RENDERER_GET_CLASS(renderer)->set_linestyle(renderer, LINESTYLE_SOLID); |
1100 | 1097 | DIA_RENDERER_GET_CLASS(renderer)->set_linejoin(renderer, LINEJOIN_MITER); |
1101 | 1098 | |
1102 | - DIA_RENDERER_GET_CLASS(renderer)->draw_polygon(renderer, poly, 3, color); | |
1099 | + DIA_RENDERER_GET_CLASS(renderer)->draw_polygon(renderer, poly, 3, fg_color); | |
1103 | 1100 | } |
1104 | 1101 | |
1105 | 1102 | /** Draw a simple triangular arrow, with filled head. |
@@ -1113,7 +1110,8 @@ draw_triangle(DiaRenderer *renderer, Point *to, Point *from, | ||
1113 | 1110 | */ |
1114 | 1111 | static void |
1115 | 1112 | fill_triangle(DiaRenderer *renderer, Point *to, Point *from, |
1116 | - real length, real width, Color *color) | |
1113 | + real length, real width, real linewidth, | |
1114 | + Color *fg_color, Color *bg_color) | |
1117 | 1115 | { |
1118 | 1116 | Point poly[3]; |
1119 | 1117 |
@@ -1122,7 +1120,7 @@ fill_triangle(DiaRenderer *renderer, Point *to, Point *from, | ||
1122 | 1120 | DIA_RENDERER_GET_CLASS(renderer)->set_fillstyle(renderer, FILLSTYLE_SOLID); |
1123 | 1121 | DIA_RENDERER_GET_CLASS(renderer)->set_linejoin(renderer, LINEJOIN_MITER); |
1124 | 1122 | |
1125 | - DIA_RENDERER_GET_CLASS(renderer)->fill_polygon(renderer, poly, 3, color); | |
1123 | + DIA_RENDERER_GET_CLASS(renderer)->fill_polygon(renderer, poly, 3, bg_color); | |
1126 | 1124 | } |
1127 | 1125 | |
1128 | 1126 | /** Calculate the points needed to draw a diamon arrowhead. |
@@ -1135,10 +1133,9 @@ fill_triangle(DiaRenderer *renderer, Point *to, Point *from, | ||
1135 | 1133 | * @param from The point the arrow points away from (e.g. bezier control line) |
1136 | 1134 | * @param length The length of the arrowhead |
1137 | 1135 | * @param width The width of the arrowhead |
1138 | - * @bug Take linewidth into account. | |
1139 | 1136 | */ |
1140 | -static void | |
1141 | -calculate_diamond(Point *poly, Point *to, Point *from, | |
1137 | +static int | |
1138 | +calculate_diamond(Point *poly, const Point *to, const Point *from, | |
1142 | 1139 | real length, real width) |
1143 | 1140 | { |
1144 | 1141 | Point delta; |
@@ -1172,6 +1169,8 @@ calculate_diamond(Point *poly, Point *to, Point *from, | ||
1172 | 1169 | poly[3] = *to; |
1173 | 1170 | point_sub(&poly[3], &delta); |
1174 | 1171 | point_add(&poly[3], &orth_delta); |
1172 | + | |
1173 | + return 4; | |
1175 | 1174 | } |
1176 | 1175 | |
1177 | 1176 | /** Draw a diamond-shaped arrow head. |
@@ -1212,7 +1211,7 @@ draw_diamond(DiaRenderer *renderer, Point *to, Point *from, | ||
1212 | 1211 | static void |
1213 | 1212 | draw_half_diamond(DiaRenderer *renderer, Point *to, Point *from, |
1214 | 1213 | real length, real width, real linewidth, |
1215 | - Color *color) | |
1214 | + Color *fg_color, Color *bg_color) | |
1216 | 1215 | { |
1217 | 1216 | Point poly[4]; |
1218 | 1217 |
@@ -1223,7 +1222,7 @@ draw_half_diamond(DiaRenderer *renderer, Point *to, Point *from, | ||
1223 | 1222 | DIA_RENDERER_GET_CLASS(renderer)->set_linejoin(renderer, LINEJOIN_MITER); |
1224 | 1223 | DIA_RENDERER_GET_CLASS(renderer)->set_linecaps(renderer, LINECAPS_BUTT); |
1225 | 1224 | |
1226 | - DIA_RENDERER_GET_CLASS(renderer)->draw_polyline(renderer, poly+1, 3, color); | |
1225 | + DIA_RENDERER_GET_CLASS(renderer)->draw_polyline(renderer, poly+1, 3, fg_color); | |
1227 | 1226 | } |
1228 | 1227 | |
1229 | 1228 | /** Draw a filled diamond arrow head. |
@@ -1258,8 +1257,8 @@ fill_diamond(DiaRenderer *renderer, Point *to, Point *from, | ||
1258 | 1257 | * @param width The width of the arrowhead. |
1259 | 1258 | * @bug Describe what is where in the poly array. |
1260 | 1259 | */ |
1261 | -static void | |
1262 | -calculate_slashed_cross(Point *poly, Point *to, Point *from, | |
1260 | +static int | |
1261 | +calculate_slashed_cross(Point *poly, const Point *to, const Point *from, | |
1263 | 1262 | real length, real width) |
1264 | 1263 | { |
1265 | 1264 | Point delta; |
@@ -1296,6 +1295,8 @@ calculate_slashed_cross(Point *poly, Point *to, Point *from, | ||
1296 | 1295 | |
1297 | 1296 | point_add(&poly[4], &orth_delta); |
1298 | 1297 | point_sub(&poly[5], &orth_delta); |
1298 | + | |
1299 | + return 6; | |
1299 | 1300 | } |
1300 | 1301 | |
1301 | 1302 | /** Draw a slashed cross arrowhead. |
@@ -1309,7 +1310,8 @@ calculate_slashed_cross(Point *poly, Point *to, Point *from, | ||
1309 | 1310 | */ |
1310 | 1311 | static void |
1311 | 1312 | draw_slashed_cross(DiaRenderer *renderer, Point *to, Point *from, |
1312 | - real length, real width, real linewidth, Color *color) | |
1313 | + real length, real width, real linewidth, | |
1314 | + Color *fg_color, Color *bg_color) | |
1313 | 1315 | { |
1314 | 1316 | Point poly[6]; |
1315 | 1317 |
@@ -1320,27 +1322,14 @@ draw_slashed_cross(DiaRenderer *renderer, Point *to, Point *from, | ||
1320 | 1322 | DIA_RENDERER_GET_CLASS(renderer)->set_linejoin(renderer, LINEJOIN_MITER); |
1321 | 1323 | DIA_RENDERER_GET_CLASS(renderer)->set_linecaps(renderer, LINECAPS_BUTT); |
1322 | 1324 | |
1323 | - DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &poly[0],&poly[1], color); | |
1324 | - DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &poly[2],&poly[3], color); | |
1325 | - DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &poly[4],&poly[5], color); | |
1325 | + DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &poly[0],&poly[1], fg_color); | |
1326 | + DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &poly[2],&poly[3], fg_color); | |
1327 | + DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &poly[4],&poly[5], fg_color); | |
1326 | 1328 | } |
1327 | - | |
1328 | -/** Draw a backslash arrowhead. | |
1329 | - * @param renderer A renderer instance to draw into | |
1330 | - * @param to The point that the arrow points to. | |
1331 | - * @param from Where the arrow points from (e.g. end of stem) | |
1332 | - * @param length The length of the arrow | |
1333 | - * @param width The width of the arrow | |
1334 | - * @param linewidth The thickness of the lines used to draw the arrow. | |
1335 | - * @param color The color used for drawing the arrowhead. | |
1336 | - * @todo refactor into calculate and draw. | |
1337 | - */ | |
1338 | -static void | |
1339 | -draw_backslash(DiaRenderer *renderer, Point *to, Point *from, | |
1340 | - real length, real width, real linewidth, Color *color) | |
1329 | +static int | |
1330 | +calculate_backslash (Point *poly, const Point *to, const Point *from, | |
1331 | + real length, real width) | |
1341 | 1332 | { |
1342 | - Point point1; | |
1343 | - Point point2; | |
1344 | 1333 | Point delta; |
1345 | 1334 | Point orth_delta; |
1346 | 1335 | real len; |
@@ -1362,22 +1351,42 @@ draw_backslash(DiaRenderer *renderer, Point *to, Point *from, | ||
1362 | 1351 | point_scale(&delta, length/2.0); |
1363 | 1352 | point_scale(&orth_delta, width/2.0); |
1364 | 1353 | |
1365 | - point1 = *to; | |
1366 | - point_sub(&point1, &delta); | |
1367 | - point_sub(&point1, &delta); | |
1368 | - point_sub(&point1, &delta); | |
1369 | - point_add(&point1, &orth_delta); | |
1354 | + poly[0] = *to; | |
1355 | + point_sub(&poly[0], &delta); | |
1356 | + point_sub(&poly[0], &delta); | |
1357 | + point_sub(&poly[0], &delta); | |
1358 | + point_add(&poly[0], &orth_delta); | |
1370 | 1359 | |
1371 | - point2 = *to; | |
1372 | - point_sub(&point2, &delta); | |
1373 | - point_sub(&point2, &orth_delta); | |
1360 | + poly[1] = *to; | |
1361 | + point_sub(&poly[1], &delta); | |
1362 | + point_sub(&poly[1], &orth_delta); | |
1363 | + | |
1364 | + return 2; | |
1365 | +} | |
1366 | +/** Draw a backslash arrowhead. | |
1367 | + * @param renderer A renderer instance to draw into | |
1368 | + * @param to The point that the arrow points to. | |
1369 | + * @param from Where the arrow points from (e.g. end of stem) | |
1370 | + * @param length The length of the arrow | |
1371 | + * @param width The width of the arrow | |
1372 | + * @param linewidth The thickness of the lines used to draw the arrow. | |
1373 | + * @param color The color used for drawing the arrowhead. | |
1374 | + */ | |
1375 | +static void | |
1376 | +draw_backslash(DiaRenderer *renderer, Point *to, Point *from, | |
1377 | + real length, real width, real linewidth, | |
1378 | + Color *fg_color, Color *bg_color) | |
1379 | +{ | |
1380 | + Point poly[2]; | |
1374 | 1381 | |
1382 | + calculate_backslash (poly, to, from, length, width); | |
1383 | + | |
1375 | 1384 | DIA_RENDERER_GET_CLASS(renderer)->set_linewidth(renderer, linewidth); |
1376 | 1385 | DIA_RENDERER_GET_CLASS(renderer)->set_linestyle(renderer, LINESTYLE_SOLID); |
1377 | 1386 | DIA_RENDERER_GET_CLASS(renderer)->set_linejoin(renderer, LINEJOIN_MITER); |
1378 | 1387 | DIA_RENDERER_GET_CLASS(renderer)->set_linecaps(renderer, LINECAPS_BUTT); |
1379 | 1388 | |
1380 | - DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &point1,&point2, color); | |
1389 | + DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &poly[0], &poly[1], fg_color); | |
1381 | 1390 | } |
1382 | 1391 | |
1383 | 1392 | /** Draw a cross-like arrowhead. |
@@ -1391,7 +1400,8 @@ draw_backslash(DiaRenderer *renderer, Point *to, Point *from, | ||
1391 | 1400 | */ |
1392 | 1401 | static void |
1393 | 1402 | draw_cross(DiaRenderer *renderer, Point *to, Point *from, |
1394 | - real length, real width, real linewidth, Color *color) | |
1403 | + real length, real width, real linewidth, | |
1404 | + Color *fg_color, Color *bg_color) | |
1395 | 1405 | { |
1396 | 1406 | Point poly[6]; |
1397 | 1407 |
@@ -1402,7 +1412,7 @@ draw_cross(DiaRenderer *renderer, Point *to, Point *from, | ||
1402 | 1412 | DIA_RENDERER_GET_CLASS(renderer)->set_linejoin(renderer, LINEJOIN_MITER); |
1403 | 1413 | DIA_RENDERER_GET_CLASS(renderer)->set_linecaps(renderer, LINECAPS_BUTT); |
1404 | 1414 | |
1405 | - DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &poly[0],&poly[2], color); | |
1415 | + DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &poly[0],&poly[2], fg_color); | |
1406 | 1416 | /*DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &poly[4],&poly[5], color); */ |
1407 | 1417 | } |
1408 | 1418 |
@@ -1417,7 +1427,7 @@ draw_cross(DiaRenderer *renderer, Point *to, Point *from, | ||
1417 | 1427 | */ |
1418 | 1428 | static void |
1419 | 1429 | calculate_double_arrow(Point *second_to, Point *second_from, |
1420 | - Point *to, Point *from, real length) | |
1430 | + const Point *to, const Point *from, real length) | |
1421 | 1431 | { |
1422 | 1432 | Point delta; |
1423 | 1433 | real len; |
@@ -1454,13 +1464,14 @@ calculate_double_arrow(Point *second_to, Point *second_from, | ||
1454 | 1464 | */ |
1455 | 1465 | static void |
1456 | 1466 | draw_double_triangle(DiaRenderer *renderer, Point *to, Point *from, |
1457 | - real length, real width, real linewidth, Color *color) | |
1467 | + real length, real width, real linewidth, | |
1468 | + Color *fg_color, Color *bg_color) | |
1458 | 1469 | { |
1459 | 1470 | Point second_from, second_to; |
1460 | 1471 | |
1461 | - draw_triangle(renderer, to, from, length, width, linewidth, color); | |
1472 | + draw_triangle(renderer, to, from, length, width, linewidth, fg_color, bg_color); | |
1462 | 1473 | calculate_double_arrow(&second_to, &second_from, to, from, length+linewidth); |
1463 | - draw_triangle(renderer, &second_to, &second_from, length, width, linewidth, color); | |
1474 | + draw_triangle(renderer, &second_to, &second_from, length, width, linewidth, fg_color, bg_color); | |
1464 | 1475 | } |
1465 | 1476 | |
1466 | 1477 | /** Draw a filled double-triangle arrowhead. |
@@ -1474,13 +1485,14 @@ draw_double_triangle(DiaRenderer *renderer, Point *to, Point *from, | ||
1474 | 1485 | */ |
1475 | 1486 | static void |
1476 | 1487 | fill_double_triangle(DiaRenderer *renderer, Point *to, Point *from, |
1477 | - real length, real width, Color *color) | |
1488 | + real length, real width, real linewidth, | |
1489 | + Color *fg_color, Color *bg_color) | |
1478 | 1490 | { |
1479 | 1491 | Point second_from, second_to; |
1480 | 1492 | |
1481 | - fill_triangle(renderer, to, from, length, width, color); | |
1493 | + fill_triangle(renderer, to, from, length, width, linewidth, NULL, bg_color); | |
1482 | 1494 | calculate_double_arrow(&second_to, &second_from, to, from, length); |
1483 | - fill_triangle(renderer, &second_to, &second_from, length, width, color); | |
1495 | + fill_triangle(renderer, &second_to, &second_from, length, width, linewidth, NULL, bg_color); | |
1484 | 1496 | } |
1485 | 1497 | |
1486 | 1498 | /** Calculate the points needed to draw a concave arrowhead. |
@@ -1494,8 +1506,8 @@ fill_double_triangle(DiaRenderer *renderer, Point *to, Point *from, | ||
1494 | 1506 | * @param length The length of the arrow. |
1495 | 1507 | * @param width The width of the arrow. |
1496 | 1508 | */ |
1497 | -static void | |
1498 | -calculate_concave(Point *poly, Point *to, Point *from, | |
1509 | +static int | |
1510 | +calculate_concave(Point *poly, const Point *to, const Point *from, | |
1499 | 1511 | real length, real width) |
1500 | 1512 | { |
1501 | 1513 | Point delta; |
@@ -1536,6 +1548,8 @@ calculate_concave(Point *poly, Point *to, Point *from, | ||
1536 | 1548 | point_sub(&poly[3], &delta); |
1537 | 1549 | point_sub(&poly[3], &delta); |
1538 | 1550 | point_sub(&poly[3], &delta); |
1551 | + | |
1552 | + return 4; | |
1539 | 1553 | } |
1540 | 1554 | |
1541 | 1555 | /** Draw a concave triangle arrowhead. |
@@ -1753,6 +1767,155 @@ draw_three_dots(DiaRenderer *renderer, Point *to, Point *from, | ||
1753 | 1767 | } |
1754 | 1768 | } |
1755 | 1769 | |
1770 | +static void | |
1771 | +draw_hollow_triangle (DiaRenderer *renderer, Point *to, Point *from, | |
1772 | + real length, real width, real linewidth, | |
1773 | + Color *fg_color, Color *bg_color) | |
1774 | +{ | |
1775 | + fill_triangle(renderer, to, from, length, width, linewidth, NULL, bg_color); | |
1776 | + draw_triangle(renderer, to, from, length, width, linewidth, fg_color, NULL); | |
1777 | +} | |
1778 | +static void | |
1779 | +draw_filled_triangle (DiaRenderer *renderer, Point *to, Point *from, | |
1780 | + real length, real width, real linewidth, | |
1781 | + Color *fg_color, Color *bg_color) | |
1782 | +{ | |
1783 | + fill_triangle(renderer, to, from, length, width, linewidth, NULL, fg_color); | |
1784 | + draw_triangle(renderer, to, from, length, width, linewidth, fg_color, NULL); | |
1785 | +} | |
1786 | +static void | |
1787 | +draw_unfilled_triangle (DiaRenderer *renderer, Point *to, Point *from, | |
1788 | + real length, real width, real linewidth, | |
1789 | + Color *fg_color, Color *bg_color) | |
1790 | +{ | |
1791 | + draw_triangle(renderer, to, from, length, width, linewidth, fg_color, bg_color); | |
1792 | +} | |
1793 | +static void | |
1794 | +draw_hollow_diamond (DiaRenderer *renderer, Point *to, Point *from, | |
1795 | + real length, real width, real linewidth, | |
1796 | + Color *fg_color, Color *bg_color) | |
1797 | +{ | |
1798 | + fill_diamond(renderer, to, from, length, width, bg_color); | |
1799 | + draw_diamond(renderer, to, from, length, width, linewidth, fg_color); | |
1800 | +} | |
1801 | +static void | |
1802 | +draw_filled_diamond (DiaRenderer *renderer, Point *to, Point *from, | |
1803 | + real length, real width, real linewidth, | |
1804 | + Color *fg_color, Color *bg_color) | |
1805 | +{ | |
1806 | + fill_diamond(renderer, to, from, length, width, fg_color); | |
1807 | + draw_diamond(renderer, to, from, length, width, linewidth, fg_color); | |
1808 | +} | |
1809 | +static void | |
1810 | +draw_filled_ellipse (DiaRenderer *renderer, Point *to, Point *from, | |
1811 | + real length, real width, real linewidth, | |
1812 | + Color *fg_color, Color *bg_color) | |
1813 | +{ | |
1814 | + draw_fill_ellipse(renderer,to,from,length,width,linewidth,fg_color,fg_color); | |
1815 | +} | |
1816 | +static void | |
1817 | +draw_filled_dot (DiaRenderer *renderer, Point *to, Point *from, | |
1818 | + real length, real width, real linewidth, | |
1819 | + Color *fg_color, Color *bg_color) | |
1820 | +{ | |
1821 | + draw_fill_dot(renderer,to,from,length,width,linewidth,fg_color,fg_color); | |
1822 | +} | |
1823 | +static void | |
1824 | +draw_filled_box (DiaRenderer *renderer, Point *to, Point *from, | |
1825 | + real length, real width, real linewidth, | |
1826 | + Color *fg_color, Color *bg_color) | |
1827 | +{ | |
1828 | + draw_fill_box(renderer,to,from,length,width,linewidth,fg_color,fg_color); | |
1829 | +} | |
1830 | +static void | |
1831 | +draw_filled_concave (DiaRenderer *renderer, Point *to, Point *from, | |
1832 | + real length, real width, real linewidth, | |
1833 | + Color *fg_color, Color *bg_color) | |
1834 | +{ | |
1835 | + draw_concave_triangle(renderer, to, from, length, width, linewidth, fg_color, fg_color); | |
1836 | +} | |
1837 | +static int | |
1838 | +calculate_double_triangle (Point *poly, const Point *to, const Point *from, | |
1839 | + real length, real width) | |
1840 | +{ | |
1841 | + Point second_from, second_to; | |
1842 | + | |
1843 | + calculate_arrow (poly, to, from, length, width); | |
1844 | + calculate_double_arrow(&second_to, &second_from, to, from, length); | |
1845 | + calculate_arrow (poly+3, &second_to, &second_from, length, width); | |
1846 | + return 6; | |
1847 | +} | |
1848 | +static void | |
1849 | +draw_double_hollow_triangle (DiaRenderer *renderer, Point *to, Point *from, | |
1850 | + real length, real width, real linewidth, | |
1851 | + Color *fg_color, Color *bg_color) | |
1852 | +{ | |
1853 | + fill_double_triangle(renderer, to, from, length+(linewidth/2), width, linewidth, fg_color, bg_color); | |
1854 | + draw_double_triangle(renderer, to, from, length, width, linewidth, fg_color, bg_color); | |
1855 | +} | |
1856 | +static void | |
1857 | +draw_double_filled_triangle (DiaRenderer *renderer, Point *to, Point *from, | |
1858 | + real length, real width, real linewidth, | |
1859 | + Color *fg_color, Color *bg_color) | |
1860 | +{ | |
1861 | + fill_double_triangle(renderer, to, from, length, width, linewidth, fg_color, fg_color); | |
1862 | +} | |
1863 | +struct ArrowDesc { | |
1864 | + const char *name; | |
1865 | + ArrowType enum_value; | |
1866 | + /* calculates the points for the arrow, their number is returned */ | |
1867 | + int (*calculate) (Point *poly, /* variable size poly */ | |
1868 | + const Point *to, /* pointing to */ | |
1869 | + const Point *from, /* coming from */ | |
1870 | + real length, /* the arrows length */ | |
1871 | + real width); /* the arrows width */ | |
1872 | + /* draw the arrow, internally calculated with the respective calculate */ | |
1873 | + void (*draw) (DiaRenderer *renderer, | |
1874 | + Point *to, | |
1875 | + Point *from, | |
1876 | + real length, | |
1877 | + real width, | |
1878 | + real linewidth, /* the lines width also used in many arrows */ | |
1879 | + Color *fg_color, /* the main drawin color */ | |
1880 | + Color *bg_color); /* not always used */ | |
1881 | +} arrow_types[] = | |
1882 | + {{N_("None"),ARROW_NONE}, | |
1883 | + {N_("Lines"),ARROW_LINES, calculate_arrow, draw_lines}, | |
1884 | + {N_("Hollow Triangle"), ARROW_HOLLOW_TRIANGLE, calculate_arrow, draw_hollow_triangle}, | |
1885 | + {N_("Filled Triangle"), ARROW_FILLED_TRIANGLE, calculate_arrow, draw_filled_triangle}, | |
1886 | + {N_("Unfilled Triangle"), ARROW_UNFILLED_TRIANGLE, calculate_arrow, draw_unfilled_triangle}, | |
1887 | + {N_("Hollow Diamond"),ARROW_HOLLOW_DIAMOND, calculate_diamond, draw_hollow_diamond}, | |
1888 | + {N_("Filled Diamond"),ARROW_FILLED_DIAMOND, calculate_diamond, draw_filled_diamond}, | |
1889 | + {N_("Half Diamond"), ARROW_HALF_DIAMOND, calculate_diamond, draw_half_diamond}, | |
1890 | + {N_("Half Head"), ARROW_HALF_HEAD, calculate_halfhead, draw_halfhead}, | |
1891 | + {N_("Slashed Cross"), ARROW_SLASHED_CROSS, calculate_slashed_cross, draw_slashed_cross}, | |
1892 | + {N_("Filled Ellipse"), ARROW_FILLED_ELLIPSE, calculate_ellipse, draw_filled_ellipse}, | |
1893 | + {N_("Hollow Ellipse"), ARROW_HOLLOW_ELLIPSE, calculate_ellipse, draw_fill_ellipse}, | |
1894 | + {N_("Filled Dot"), ARROW_FILLED_DOT, calculate_dot, draw_filled_dot}, | |
1895 | + {N_("Dimension Origin"),ARROW_DIMENSION_ORIGIN}, | |
1896 | + {N_("Blanked Dot"),ARROW_BLANKED_DOT, calculate_dot, draw_fill_dot}, | |
1897 | + {N_("Double Hollow Triangle"),ARROW_DOUBLE_HOLLOW_TRIANGLE, calculate_double_triangle, draw_double_hollow_triangle}, | |
1898 | + {N_("Double Filled Triangle"),ARROW_DOUBLE_FILLED_TRIANGLE, calculate_double_triangle, draw_double_filled_triangle}, | |
1899 | + {N_("Filled Dot and Triangle"), ARROW_FILLED_DOT_N_TRIANGLE}, | |
1900 | + {N_("Filled Box"), ARROW_FILLED_BOX, calculate_box, draw_filled_box}, | |
1901 | + {N_("Blanked Box"),ARROW_BLANKED_BOX, calculate_box, draw_fill_box}, | |
1902 | + {N_("Slashed"), ARROW_SLASH_ARROW, calculate_slashed, draw_slashed}, | |
1903 | + {N_("Integral Symbol"),ARROW_INTEGRAL_SYMBOL}, | |
1904 | + {N_("Crow Foot"), ARROW_CROW_FOOT, calculate_crow, draw_crow_foot}, | |
1905 | + {N_("Cross"),ARROW_CROSS, calculate_arrow, draw_cross}, | |
1906 | + {N_("1-or-many"),ARROW_ONE_OR_MANY}, | |
1907 | + {N_("0-or-many"),ARROW_NONE_OR_MANY}, | |
1908 | + {N_("1-or-0"),ARROW_ONE_OR_NONE}, | |
1909 | + {N_("1 exactly"),ARROW_ONE_EXACTLY}, | |
1910 | + {N_("Filled Concave"),ARROW_FILLED_CONCAVE, calculate_concave, draw_filled_concave}, | |
1911 | + {N_("Blanked Concave"),ARROW_BLANKED_CONCAVE, calculate_concave, draw_concave_triangle}, | |
1912 | + {N_("Round"), ARROW_ROUNDED}, | |
1913 | + {N_("Open Round"), ARROW_OPEN_ROUNDED}, | |
1914 | + {N_("Backslash"), ARROW_BACKSLASH, calculate_backslash, draw_backslash}, | |
1915 | + {N_("Infinite Line"),ARROW_THREE_DOTS}, | |
1916 | + {NULL,0} | |
1917 | +}; | |
1918 | + | |
1756 | 1919 | /** following the signature pattern of lib/boundingbox.h |
1757 | 1920 | * the arrow bounding box is added to the given rect |
1758 | 1921 | * @param arrow the arrow |
@@ -1765,23 +1928,26 @@ void | ||
1765 | 1928 | arrow_bbox (const Arrow *arrow, real line_width, const Point *to, const Point *from, |
1766 | 1929 | Rectangle *rect) |
1767 | 1930 | { |
1768 | -#define N_POINTS 3 /* 3 for calculate_arrow() */ | |
1769 | - Point poly[N_POINTS]; | |
1931 | + Point poly[6]; /* Attention: nust be the maximum used! */ | |
1770 | 1932 | PolyBBExtras pextra; |
1933 | + int n_points = 0; | |
1934 | + int idx = arrow_index_from_type(arrow->type); | |
1771 | 1935 | |
1772 | 1936 | if (ARROW_NONE == arrow->type) |
1773 | 1937 | return; /* bbox not growing */ |
1774 | 1938 | |
1775 | 1939 | /* some extra steps necessary for e.g circle shapes? */ |
1776 | - calculate_arrow(poly, to, from, arrow->length, arrow->width); | |
1777 | - | |
1940 | + if (arrow_types[idx].calculate) | |
1941 | + n_points = arrow_types[idx].calculate (poly, to, from, arrow->length, arrow->width); | |
1942 | + else /* fallback, should vanish */ | |
1943 | + n_points = calculate_arrow(poly, to, from, arrow->length, arrow->width); | |
1944 | + g_assert (n_points > 0 && n_points <= sizeof(poly)/sizeof(Point)); | |
1945 | + | |
1778 | 1946 | pextra.start_trans = pextra.end_trans = |
1779 | 1947 | pextra.start_long = pextra.end_long = |
1780 | 1948 | pextra.middle_trans = line_width/2.0; |
1781 | 1949 | |
1782 | - polyline_bbox (poly, N_POINTS, &pextra, TRUE, rect); | |
1783 | - | |
1784 | -#undef N_POINTS | |
1950 | + polyline_bbox (poly, n_points, &pextra, TRUE, rect); | |
1785 | 1951 | } |
1786 | 1952 | |
1787 | 1953 | /** Draw any arrowhead. |
@@ -1804,72 +1970,12 @@ arrow_draw(DiaRenderer *renderer, ArrowType type, | ||
1804 | 1970 | switch(type) { |
1805 | 1971 | case ARROW_NONE: |
1806 | 1972 | break; |
1807 | - case ARROW_LINES: | |
1808 | - draw_lines(renderer, to, from, length, width, linewidth, fg_color); | |
1809 | - break; | |
1810 | - case ARROW_HALF_HEAD: | |
1811 | - draw_halfhead(renderer, to, from, length, width, linewidth, fg_color); | |
1812 | - break; | |
1813 | - case ARROW_HOLLOW_TRIANGLE: | |
1814 | - fill_triangle(renderer, to, from, length, width, bg_color); | |
1815 | - draw_triangle(renderer, to, from, length, width, linewidth, fg_color); | |
1816 | - break; | |
1817 | - case ARROW_UNFILLED_TRIANGLE: | |
1818 | - draw_triangle(renderer, to, from, length, width, linewidth, fg_color); | |
1819 | - break; | |
1820 | - case ARROW_FILLED_TRIANGLE: | |
1821 | - fill_triangle(renderer, to, from, length, width, fg_color); | |
1822 | - break; | |
1823 | - case ARROW_HOLLOW_DIAMOND: | |
1824 | - fill_diamond(renderer, to, from, length, width, bg_color); | |
1825 | - draw_diamond(renderer, to, from, length, width, linewidth, fg_color); | |
1826 | - break; | |
1827 | - case ARROW_FILLED_DIAMOND: | |
1828 | - fill_diamond(renderer, to, from, length, width, fg_color); | |
1829 | - break; | |
1830 | - case ARROW_HALF_DIAMOND: | |
1831 | - /* fill_diamond(renderer, to, from, length, width, bg_color);*/ | |
1832 | - draw_half_diamond(renderer, to, from, length, width, linewidth, fg_color); | |
1833 | - break; | |
1834 | - case ARROW_SLASHED_CROSS: | |
1835 | - draw_slashed_cross(renderer, to, from, length, width, linewidth, fg_color); | |
1836 | - break; | |
1837 | - case ARROW_FILLED_ELLIPSE: | |
1838 | - draw_fill_ellipse(renderer,to,from,length,width,linewidth, | |
1839 | - fg_color,NULL); | |
1840 | - break; | |
1841 | - case ARROW_HOLLOW_ELLIPSE: | |
1842 | - draw_fill_ellipse(renderer,to,from,length,width,linewidth, | |
1843 | - fg_color,bg_color); | |
1844 | - break; | |
1845 | - case ARROW_DOUBLE_HOLLOW_TRIANGLE: | |
1846 | - fill_double_triangle(renderer, to, from, length+(linewidth/2), width, bg_color); | |
1847 | - draw_double_triangle(renderer, to, from, length, width, linewidth, fg_color); | |
1848 | - break; | |
1849 | - case ARROW_DOUBLE_FILLED_TRIANGLE: | |
1850 | - fill_double_triangle(renderer, to, from, length, width, fg_color); | |
1851 | - break; | |
1852 | - case ARROW_FILLED_DOT: | |
1853 | - draw_fill_dot(renderer,to,from,length,width,linewidth,fg_color,fg_color); | |
1854 | - break; | |
1855 | - case ARROW_BLANKED_DOT: | |
1856 | - draw_fill_dot(renderer,to,from,length,width,linewidth,fg_color,bg_color); | |
1857 | - break; | |
1858 | - case ARROW_FILLED_BOX: | |
1859 | - draw_fill_box(renderer,to,from,length,width,linewidth,fg_color,fg_color); | |
1860 | - break; | |
1861 | - case ARROW_BLANKED_BOX: | |
1862 | - draw_fill_box(renderer,to,from,length,width,linewidth,fg_color,bg_color); | |
1863 | - break; | |
1864 | 1973 | case ARROW_DIMENSION_ORIGIN: |
1865 | 1974 | draw_fill_dot(renderer,to,from,length,width,linewidth,fg_color,NULL); |
1866 | 1975 | break; |
1867 | 1976 | case ARROW_INTEGRAL_SYMBOL: |
1868 | 1977 | draw_integral(renderer,to,from,length,width,linewidth,fg_color); |
1869 | 1978 | break; |
1870 | - case ARROW_SLASH_ARROW: | |
1871 | - draw_slashed(renderer,to,from,length,width,linewidth,fg_color); | |
1872 | - break; | |
1873 | 1979 | case ARROW_ONE_OR_MANY: |
1874 | 1980 | draw_one_or_many(renderer,to,from,length,width,linewidth,fg_color,bg_color); |
1875 | 1981 | break; |
@@ -1882,18 +1988,6 @@ arrow_draw(DiaRenderer *renderer, ArrowType type, | ||
1882 | 1988 | case ARROW_ONE_OR_NONE: |
1883 | 1989 | draw_one_or_none(renderer,to,from,length,width,linewidth,fg_color,bg_color); |
1884 | 1990 | break; |
1885 | - case ARROW_CROW_FOOT: | |
1886 | - draw_crow_foot(renderer,to,from,length,width,linewidth,fg_color,bg_color); | |
1887 | - break; | |
1888 | - case ARROW_CROSS: | |
1889 | - draw_cross(renderer, to, from, length, width, linewidth, fg_color); | |
1890 | - break; | |
1891 | - case ARROW_FILLED_CONCAVE: | |
1892 | - draw_concave_triangle(renderer, to, from, length, width, linewidth, fg_color, fg_color); | |
1893 | - break; | |
1894 | - case ARROW_BLANKED_CONCAVE: | |
1895 | - draw_concave_triangle(renderer, to, from, length, width, linewidth, fg_color, bg_color); | |
1896 | - break; | |
1897 | 1991 | case ARROW_ROUNDED: |
1898 | 1992 | draw_rounded(renderer, to, from, length, width, linewidth, fg_color, bg_color); |
1899 | 1993 | break; |
@@ -1905,14 +1999,18 @@ arrow_draw(DiaRenderer *renderer, ArrowType type, | ||
1905 | 1999 | draw_filled_dot_n_triangle(renderer, to, from, length, width, linewidth, |
1906 | 2000 | fg_color, bg_color); |
1907 | 2001 | break; |
1908 | - case ARROW_BACKSLASH: | |
1909 | - draw_backslash(renderer,to,from,length,width,linewidth,fg_color); | |
1910 | - break; | |
1911 | 2002 | case ARROW_THREE_DOTS: |
1912 | 2003 | draw_three_dots(renderer,to,from,length,width,linewidth,fg_color); |
1913 | 2004 | break; |
1914 | 2005 | case MAX_ARROW_TYPE: |
1915 | 2006 | break; |
2007 | + default : | |
2008 | + { | |
2009 | + int idx = arrow_index_from_type(type); | |
2010 | + g_return_if_fail (arrow_types[idx].draw != NULL); | |
2011 | + arrow_types[idx].draw (renderer,to,from,length,width,linewidth,fg_color,bg_color); | |
2012 | + break; | |
2013 | + } | |
1916 | 2014 | } |
1917 | 2015 | if ((type != ARROW_NONE) && (render_bounding_boxes) && (renderer->is_interactive)) { |
1918 | 2016 | Arrow arrow = {type, length, width}; |
@@ -201,7 +201,7 @@ line_bbox(const Point *p1, const Point *p2, | ||
201 | 201 | rect->left = rect->right = p1->x; |
202 | 202 | rect->top = rect->bottom = p1->y; |
203 | 203 | |
204 | - rectangle_add_point(rect,p2); /* as a safety */ | |
204 | + rectangle_add_point(rect,p2); /* as a safety, so we don't need to care if it above or below p1 */ | |
205 | 205 | |
206 | 206 | point_copy_add_scaled(&vl,p1,p2,-1); |
207 | 207 | point_normalize(&vl); |
@@ -554,6 +554,7 @@ EXPORTS | ||
554 | 554 | point_add_scaled |
555 | 555 | point_convex |
556 | 556 | point_copy |
557 | + point_cross | |
557 | 558 | point_dot |
558 | 559 | point_len |
559 | 560 | point_normalize |
@@ -737,6 +737,21 @@ arc_copy(Arc *arc) | ||
737 | 737 | return &newarc->connection.object; |
738 | 738 | } |
739 | 739 | |
740 | +/* copied from lib/diarenderer.c, the one there should be removed */ | |
741 | +static gboolean | |
742 | +is_right_hand (const Point *a, const Point *b, const Point *c) | |
743 | +{ | |
744 | + Point dot1, dot2; | |
745 | + | |
746 | + dot1 = *a; | |
747 | + point_sub(&dot1, c); | |
748 | + point_normalize(&dot1); | |
749 | + dot2 = *b; | |
750 | + point_sub(&dot2, c); | |
751 | + point_normalize(&dot2); | |
752 | + return point_cross(&dot1, &dot2) > 0; | |
753 | +} | |
754 | + | |
740 | 755 | static void |
741 | 756 | arc_update_data(Arc *arc) |
742 | 757 | { |
@@ -747,6 +762,7 @@ arc_update_data(Arc *arc) | ||
747 | 762 | real x1,y1,x2,y2,xc,yc; |
748 | 763 | real lensq, alpha, radius; |
749 | 764 | real angle1, angle2; |
765 | + gboolean righthand; | |
750 | 766 | |
751 | 767 | endpoints = &arc->connection.endpoints[0]; |
752 | 768 | x1 = endpoints[0].x; |
@@ -791,7 +807,12 @@ arc_update_data(Arc *arc) | ||
791 | 807 | extra->start_long = |
792 | 808 | extra->end_long = (arc->line_width / 2.0); |
793 | 809 | |
810 | + /* updates midpoint */ | |
811 | + arc_update_handles(arc); | |
812 | + /* startpoint, midpoint, endpoint */ | |
813 | + righthand = is_right_hand (&endpoints[0], &arc->middle_handle.pos, &endpoints[1]); | |
794 | 814 | connection_update_boundingbox(conn); |
815 | + | |
795 | 816 | /* fix boundingbox for arc's special shape XXX find a more elegant way: */ |
796 | 817 | if (in_angle(0, arc->angle1, arc->angle2)) { |
797 | 818 | /* rigth side, y does not matter if included */ |
@@ -805,7 +826,7 @@ arc_update_data(Arc *arc) | ||
805 | 826 | } |
806 | 827 | if (in_angle(180, arc->angle1, arc->angle2)) { |
807 | 828 | /* left side, y does not matter if included */ |
808 | - Point pt = { arc->center.x - arc->radius - (arc->line_width / 2.0) }; | |
829 | + Point pt = { arc->center.x - arc->radius - (arc->line_width / 2.0), y1 }; | |
809 | 830 | rectangle_add_point (&obj->bounding_box, &pt); |
810 | 831 | } |
811 | 832 | if (in_angle(270, arc->angle1, arc->angle2)) { |
@@ -824,22 +845,18 @@ arc_update_data(Arc *arc) | ||
824 | 845 | Point from = to; |
825 | 846 | point_sub (&from, &arc->center); |
826 | 847 | tmp = from.x; |
827 | - if (angle2 > angle1) | |
848 | + if (righthand) | |
828 | 849 | from.x = -from.y, from.y = tmp; |
829 | 850 | else |
830 | 851 | from.x = from.y, from.y = -tmp; |
831 | 852 | point_add (&from, &to); |
832 | -#if 0 | |
853 | + | |
833 | 854 | calculate_arrow_point(&arc->start_arrow, &to, &from, |
834 | 855 | &move_arrow, &move_line, arc->line_width); |
835 | - /* make them absolute positions, i.e. moved */ | |
836 | - point_add(&move_arrow, &to); | |
837 | - point_add(&move_line, &from); | |
838 | - arrow_bbox(&arc->start_arrow, arc->line_width, &move_arrow, &move_line, &bbox); | |
839 | -#else | |
856 | + /* move them */ | |
857 | + point_sub(&to, &move_arrow); | |
858 | + point_sub(&from, &move_line); | |
840 | 859 | arrow_bbox(&arc->start_arrow, arc->line_width, &to, &from, &bbox); |
841 | -#endif | |
842 | - /* to test the bounding box it was quite useful to */ | |
843 | 860 | rectangle_union(&obj->bounding_box, &bbox); |
844 | 861 | } |
845 | 862 | if (arc->end_arrow.type != ARROW_NONE) { |
@@ -850,23 +867,21 @@ arc_update_data(Arc *arc) | ||
850 | 867 | Point from = to; |
851 | 868 | point_sub (&from, &arc->center); |
852 | 869 | tmp = from.x; |
853 | - if (angle2 > angle1) | |
870 | + if (righthand) | |
854 | 871 | from.x = from.y, from.y = -tmp; |
855 | 872 | else |
856 | 873 | from.x = -from.y, from.y = tmp; |
857 | 874 | point_add (&from, &to); |
858 | 875 | calculate_arrow_point(&arc->end_arrow, &to, &from, |
859 | 876 | &move_arrow, &move_line, arc->line_width); |
860 | - /* make them absolute positions, i.e. moved */ | |
861 | - point_add(&move_arrow, &to); | |
862 | - point_add(&move_line, &from); | |
863 | - arrow_bbox(&arc->end_arrow, arc->line_width, &move_arrow, &move_line, &bbox); | |
877 | + /* move them */ | |
878 | + point_sub(&to, &move_arrow); | |
879 | + point_sub(&from, &move_line); | |
880 | + arrow_bbox(&arc->end_arrow, arc->line_width, &to, &from, &bbox); | |
864 | 881 | rectangle_union(&obj->bounding_box, &bbox); |
865 | 882 | } |
866 | 883 | |
867 | 884 | obj->position = conn->endpoints[0]; |
868 | - | |
869 | - arc_update_handles(arc); | |
870 | 885 | } |
871 | 886 | |
872 | 887 | static void |
@@ -508,31 +508,49 @@ bezierline_update_data(Bezierline *bezierline) | ||
508 | 508 | |
509 | 509 | bezierconn_update_data(bez); |
510 | 510 | |
511 | - extra->start_trans = (bezierline->line_width / 2.0); | |
512 | - extra->end_trans = (bezierline->line_width / 2.0); | |
513 | - extra->middle_trans = (bezierline->line_width / 2.0); | |
514 | - | |
515 | - if (bezierline->start_arrow.type != ARROW_NONE) | |
516 | - extra->start_trans = MAX(extra->start_trans,bezierline->start_arrow.width); | |
517 | - if (bezierline->end_arrow.type != ARROW_NONE) | |
518 | - extra->end_trans = MAX(extra->end_trans,bezierline->end_arrow.width); | |
519 | - | |
520 | - extra->start_long = (bezierline->line_width / 2.0); | |
521 | - extra->end_long = (bezierline->line_width / 2.0); | |
511 | + extra->start_trans = extra->start_long = | |
512 | + extra->middle_trans = | |
513 | + extra->end_trans = extra->end_long = (bezierline->line_width / 2.0); | |
522 | 514 | |
523 | 515 | obj->position = bez->points[0].p1; |
524 | 516 | |
525 | 517 | if (connpoint_is_autogap(bez->object.handles[0]->connected_to) || |
526 | 518 | connpoint_is_autogap(bez->object.handles[3*(bez->numpoints-1)]->connected_to) || |
527 | - bezierline->absolute_start_gap || bezierline->absolute_end_gap) { | |
519 | + bezierline->absolute_start_gap || bezierline->absolute_end_gap || | |
520 | + bezierline->start_arrow.type != ARROW_NONE || bezierline->end_arrow.type != ARROW_NONE) { | |
528 | 521 | Point gap_points[4]; |
522 | + Rectangle bbox_union = {bez->points[0].p1.x, bez->points[0].p1.y, bez->points[0].p1.x, bez->points[0].p1.y}; | |
529 | 523 | compute_gap_points(bezierline, gap_points); |
530 | 524 | exchange_bez_gap_points(bez,gap_points); |
525 | + /* further modifying the points data, accounts for corrcet arrow and bezier bounding box */ | |
526 | + if (bezierline->start_arrow.type != ARROW_NONE) { | |
527 | + Rectangle bbox; | |
528 | + Point move_arrow, move_line; | |
529 | + Point to = bez->points[0].p1, from = bez->points[1].p1; | |
530 | + | |
531 | + calculate_arrow_point(&bezierline->start_arrow, &to, &from, &move_arrow, &move_line, bezierline->line_width); | |
532 | + point_sub(&to, &move_arrow); | |
533 | + point_sub(&bez->points[0].p1, &move_line); | |
534 | + arrow_bbox (&bezierline->start_arrow, bezierline->line_width, &to, &from, &bbox); | |
535 | + rectangle_union (&bbox_union, &bbox); | |
536 | + } | |
537 | + if (bezierline->end_arrow.type != ARROW_NONE) { | |
538 | + Rectangle bbox; | |
539 | + Point move_arrow, move_line; | |
540 | + int num_points = bez->numpoints; | |
541 | + Point to = bez->points[num_points-1].p3, from = bez->points[num_points-1].p2; | |
542 | + | |
543 | + calculate_arrow_point(&bezierline->end_arrow, &to, &from, &move_arrow, &move_line, bezierline->line_width); | |
544 | + point_sub(&to, &move_arrow); | |
545 | + point_sub(&bez->points[num_points-1].p3, &move_line); | |
546 | + arrow_bbox (&bezierline->end_arrow, bezierline->line_width, &to, &from, &bbox); | |
547 | + rectangle_union (&bbox_union, &bbox); | |
548 | + } | |
531 | 549 | bezierconn_update_boundingbox(bez); |
532 | - exchange_bez_gap_points(bez,gap_points); | |
533 | - | |
550 | + rectangle_union (&obj->bounding_box, &bbox_union); | |
551 | + exchange_bez_gap_points(bez,gap_points); | |
534 | 552 | } else { |
535 | - bezierconn_update_boundingbox(bez); | |
553 | + bezierconn_update_boundingbox(bez); | |
536 | 554 | } |
537 | 555 | |
538 | 556 | } |
@@ -513,14 +513,10 @@ line_update_data(Line *line) | ||
513 | 513 | LineBBExtras *extra = &conn->extra_spacing; |
514 | 514 | Point start, end; |
515 | 515 | |
516 | - extra->start_trans = (line->line_width / 2.0); | |
517 | - extra->end_trans = (line->line_width / 2.0); | |
518 | - extra->start_long = (line->line_width / 2.0); | |
516 | + extra->start_trans = | |
517 | + extra->end_trans = | |
518 | + extra->start_long = | |
519 | 519 | extra->end_long = (line->line_width / 2.0); |
520 | - if (line->start_arrow.type != ARROW_NONE) | |
521 | - extra->start_trans = MAX(extra->start_trans,line->start_arrow.width); | |
522 | - if (line->end_arrow.type != ARROW_NONE) | |
523 | - extra->end_trans = MAX(extra->end_trans,line->end_arrow.width); | |
524 | 520 | |
525 | 521 | if (connpoint_is_autogap(line->connection.endpoint_handles[0].connected_to) || |
526 | 522 | connpoint_is_autogap(line->connection.endpoint_handles[1].connected_to)) { |
@@ -539,11 +535,39 @@ line_update_data(Line *line) | ||
539 | 535 | start = conn->endpoints[0]; |
540 | 536 | end = conn->endpoints[1]; |
541 | 537 | } |
538 | + if (line->start_arrow.type != ARROW_NONE) { | |
539 | + Rectangle bbox; | |
540 | + Point move_arrow, move_line; | |
541 | + Point to = start; | |
542 | + Point from = end; | |
543 | + calculate_arrow_point(&line->start_arrow, &to, &from, | |
544 | + &move_arrow, &move_line, line->line_width); | |
545 | + /* move them */ | |
546 | + point_sub(&to, &move_arrow); | |
547 | + point_sub(&from, &move_line); | |
548 | + | |
549 | + arrow_bbox (&line->start_arrow, line->line_width, &to, &from, &bbox); | |
550 | + rectangle_union (&obj->bounding_box, &bbox); | |
551 | + } | |
552 | + if (line->end_arrow.type != ARROW_NONE) { | |
553 | + Rectangle bbox; | |
554 | + Point move_arrow, move_line; | |
555 | + Point to = end; | |
556 | + Point from = start; | |
557 | + calculate_arrow_point(&line->start_arrow, &to, &from, | |
558 | + &move_arrow, &move_line, line->line_width); | |
559 | + /* move them */ | |
560 | + point_sub(&to, &move_arrow); | |
561 | + point_sub(&from, &move_line); | |
562 | + | |
563 | + arrow_bbox (&line->end_arrow, line->line_width, &to, &from, &bbox); | |
564 | + rectangle_union (&obj->bounding_box, &bbox); | |
565 | + } | |
542 | 566 | |
543 | 567 | obj->position = conn->endpoints[0]; |
544 | 568 | |
545 | 569 | connpointline_update(line->cpl); |
546 | - connpointline_putonaline(line->cpl,&start, &end); | |
570 | + connpointline_putonaline(line->cpl, &start, &end); | |
547 | 571 | |
548 | 572 | connection_update_handles(conn); |
549 | 573 | } |
@@ -411,23 +411,53 @@ polyline_update_data(Polyline *polyline) | ||
411 | 411 | PolyConn *poly = &polyline->poly; |
412 | 412 | DiaObject *obj = &poly->object; |
413 | 413 | PolyBBExtras *extra = &poly->extra_spacing; |
414 | + Point gap_endpoints[2]; | |
414 | 415 | |
415 | 416 | polyconn_update_data(&polyline->poly); |
416 | 417 | |
417 | 418 | extra->start_trans = (polyline->line_width / 2.0); |
418 | 419 | extra->end_trans = (polyline->line_width / 2.0); |
419 | 420 | extra->middle_trans = (polyline->line_width / 2.0); |
420 | - | |
421 | - if (polyline->start_arrow.type != ARROW_NONE) | |
422 | - extra->start_trans = MAX(extra->start_trans,polyline->start_arrow.width); | |
423 | - if (polyline->end_arrow.type != ARROW_NONE) | |
424 | - extra->end_trans = MAX(extra->end_trans,polyline->end_arrow.width); | |
425 | - | |
426 | 421 | extra->start_long = (polyline->line_width / 2.0); |
427 | 422 | extra->end_long = (polyline->line_width / 2.0); |
428 | 423 | |
424 | + polyline_calculate_gap_endpoints(polyline, gap_endpoints); | |
425 | + polyline_exchange_gap_points(polyline, gap_endpoints); | |
426 | + | |
429 | 427 | polyconn_update_boundingbox(poly); |
430 | 428 | |
429 | + if (polyline->start_arrow.type != ARROW_NONE) { | |
430 | + Rectangle bbox; | |
431 | + Point move_arrow, move_line; | |
432 | + Point to = gap_endpoints[0]; | |
433 | + Point from = poly->points[1]; | |
434 | + calculate_arrow_point(&polyline->start_arrow, &to, &from, | |
435 | + &move_arrow, &move_line, polyline->line_width); | |
436 | + /* move them */ | |
437 | + point_sub(&to, &move_arrow); | |
438 | + point_sub(&from, &move_line); | |
439 | + | |
440 | + arrow_bbox (&polyline->start_arrow, polyline->line_width, &to, &from, &bbox); | |
441 | + rectangle_union (&obj->bounding_box, &bbox); | |
442 | + } | |
443 | + if (polyline->end_arrow.type != ARROW_NONE) { | |
444 | + Rectangle bbox; | |
445 | + int n = polyline->poly.numpoints; | |
446 | + Point move_arrow, move_line; | |
447 | + Point to = gap_endpoints[1]; | |
448 | + Point from = poly->points[n-2]; | |
449 | + calculate_arrow_point(&polyline->start_arrow, &to, &from, | |
450 | + &move_arrow, &move_line, polyline->line_width); | |
451 | + /* move them */ | |
452 | + point_sub(&to, &move_arrow); | |
453 | + point_sub(&from, &move_line); | |
454 | + | |
455 | + arrow_bbox (&polyline->end_arrow, polyline->line_width, &to, &from, &bbox); | |
456 | + rectangle_union (&obj->bounding_box, &bbox); | |
457 | + } | |
458 | + | |
459 | + polyline_exchange_gap_points(polyline, gap_endpoints); | |
460 | + | |
431 | 461 | obj->position = poly->points[0]; |
432 | 462 | } |
433 | 463 |
@@ -308,22 +308,48 @@ static void | ||
308 | 308 | zigzagline_update_data(Zigzagline *zigzagline) |
309 | 309 | { |
310 | 310 | OrthConn *orth = &zigzagline->orth; |
311 | + DiaObject *obj = &orth->object; | |
311 | 312 | PolyBBExtras *extra = &orth->extra_spacing; |
312 | 313 | |
313 | 314 | orthconn_update_data(&zigzagline->orth); |
314 | 315 | |
315 | 316 | extra->start_long = |
316 | 317 | extra->end_long = |
317 | - extra->middle_trans = zigzagline->line_width/2.0; | |
318 | - extra->start_trans = (zigzagline->line_width / 2.0); | |
319 | - extra->end_trans = (zigzagline->line_width / 2.0); | |
320 | - | |
321 | - if (zigzagline->start_arrow.type != ARROW_NONE) | |
322 | - extra->start_trans = MAX(extra->start_trans,zigzagline->start_arrow.width); | |
323 | - if (zigzagline->end_arrow.type != ARROW_NONE) | |
324 | - extra->end_trans = MAX(extra->end_trans,zigzagline->end_arrow.width); | |
325 | - | |
318 | + extra->middle_trans = | |
319 | + extra->start_trans = | |
320 | + extra->end_trans = (zigzagline->line_width / 2.0); | |
321 | + | |
326 | 322 | orthconn_update_boundingbox(orth); |
323 | + | |
324 | + if (zigzagline->start_arrow.type != ARROW_NONE) { | |
325 | + Rectangle bbox; | |
326 | + Point move_arrow, move_line; | |
327 | + Point to = orth->points[0]; | |
328 | + Point from = orth->points[1]; | |
329 | + calculate_arrow_point(&zigzagline->start_arrow, &to, &from, | |
330 | + &move_arrow, &move_line, zigzagline->line_width); | |
331 | + /* move them */ | |
332 | + point_sub(&to, &move_arrow); | |
333 | + point_sub(&from, &move_line); | |
334 | + | |
335 | + arrow_bbox (&zigzagline->start_arrow, zigzagline->line_width, &to, &from, &bbox); | |
336 | + rectangle_union (&obj->bounding_box, &bbox); | |
337 | + } | |
338 | + if (zigzagline->end_arrow.type != ARROW_NONE) { | |
339 | + Rectangle bbox; | |
340 | + Point move_arrow, move_line; | |
341 | + int n = orth->numpoints; | |
342 | + Point to = orth->points[n-1]; | |
343 | + Point from = orth->points[n-2]; | |
344 | + calculate_arrow_point(&zigzagline->start_arrow, &to, &from, | |
345 | + &move_arrow, &move_line, zigzagline->line_width); | |
346 | + /* move them */ | |
347 | + point_sub(&to, &move_arrow); | |
348 | + point_sub(&from, &move_line); | |
349 | + | |
350 | + arrow_bbox (&zigzagline->end_arrow, zigzagline->line_width, &to, &from, &bbox); | |
351 | + rectangle_union (&obj->bounding_box, &bbox); | |
352 | + } | |
327 | 353 | } |
328 | 354 | |
329 | 355 | static ObjectChange * |