作図ソフト dia の改良版
修訂 | c7da45a37c6fbccf93e79e28753030527f21d6e6 (tree) |
---|---|
時間 | 2014-06-08 17:58:07 |
作者 | Hans Breuer <hans@breu...> |
Commiter | Hans Breuer |
Prepare DiaRenderer::draw_arc() to be refined
@@ -529,8 +529,8 @@ draw_arc(DiaRenderer *self, | ||
529 | 529 | real sy=center->y - ry*sin(angle1*G_PI/180); |
530 | 530 | real ex=center->x + rx*cos(angle2*G_PI/180); |
531 | 531 | real ey=center->y - ry*sin(angle2*G_PI/180); |
532 | - int swp = 0; /* always drawin negative direction */ | |
533 | - int large_arc; | |
532 | + int swp = 0; /* always drawing negative direction (still) */ | |
533 | + int large_arc; | |
534 | 534 | gchar sx_buf[DTOSTR_BUF_SIZE]; |
535 | 535 | gchar sy_buf[DTOSTR_BUF_SIZE]; |
536 | 536 | gchar rx_buf[DTOSTR_BUF_SIZE]; |
@@ -582,7 +582,7 @@ fillet(Point *p1, Point *p2, Point *p3, Point *p4, | ||
582 | 582 | /* also this means we need to swap our angles later on */ |
583 | 583 | righthand = TRUE; |
584 | 584 | } |
585 | - /* now calculate the actual angles in a form that the draw arc function | |
585 | + /* now calculate the actual angles in a form that the draw_arc function | |
586 | 586 | of the renderer can use */ |
587 | 587 | start_angle = start_angle*180.0/G_PI; |
588 | 588 | stop_angle = start_angle + stop_angle*180.0/G_PI; |
@@ -798,7 +798,7 @@ arc_update_data(Arc *arc) | ||
798 | 798 | y1 = endpoints[0].y; |
799 | 799 | x2 = endpoints[1].x; |
800 | 800 | y2 = endpoints[1].y; |
801 | - | |
801 | + | |
802 | 802 | lensq = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1); |
803 | 803 | if (fabs(arc->curve_distance) > 0.01) |
804 | 804 | radius = lensq/(8*arc->curve_distance) + arc->curve_distance/2.0; |
@@ -820,6 +820,7 @@ arc_update_data(Arc *arc) | ||
820 | 820 | if (angle2<0) |
821 | 821 | angle2+=360.0; |
822 | 822 | |
823 | + /* swap: draw_arc is always counter-clockwise */ | |
823 | 824 | if (radius<0.0) { |
824 | 825 | real tmp; |
825 | 826 | tmp = angle1; |
@@ -843,6 +844,10 @@ arc_update_data(Arc *arc) | ||
843 | 844 | arc_update_handles(arc); |
844 | 845 | /* startpoint, midpoint, endpoint */ |
845 | 846 | righthand = is_right_hand (&endpoints[0], &arc->middle_handle.pos, &endpoints[1]); |
847 | + /* there should be no need to calculate the direction once more */ | |
848 | + if (!( (righthand && arc->curve_distance <= 0.0) | |
849 | + || (!righthand && arc->curve_distance >= 0.0))) | |
850 | + g_warning ("Standard - Arc: check invariant!"); | |
846 | 851 | connection_update_boundingbox(conn); |
847 | 852 | |
848 | 853 | /* fix boundingbox for arc's special shape XXX find a more elegant way: */ |
@@ -867,8 +872,9 @@ arc_update_data(Arc *arc) | ||
867 | 872 | rectangle_add_point (&obj->bounding_box, &pt); |
868 | 873 | } |
869 | 874 | if (arc->start_arrow.type != ARROW_NONE) { |
870 | - /* a good from-point would be the chord of arrow length, but draw_arc_with_arrows currently uses the tangent | |
871 | - * For big arcs the difference is not huge and the minimum size of small arcs should be limited by the arror length. | |
875 | + /* a good from-point would be the chord of arrow length, but draw_arc_with_arrows | |
876 | + * currently uses the tangent For big arcs the difference is not huge and the | |
877 | + * minimum size of small arcs should be limited by the arror length. | |
872 | 878 | */ |
873 | 879 | Rectangle bbox = {0,}; |
874 | 880 | real tmp; |