[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

PATCH: Filled Dot and Triangle arrow (for message diagrammes)



On Mon, Nov 24, 2003 at 11:29:37AM -0600, Lars Clausen wrote:
> Is the dot supposed to be as big as the arrow behind it?  It looks really
> funny.  Also, you shouldn't put new arrows into the middle of the list, as
> that will mess with the other arrows saved in diagrams.  We ought to go to

I just looked again: I already put the new arrow at the end
of the ArrowType enum in lib/arrow.h in the first place.  It 
is only not at the end of the menu menudesc arrow_types, but
by purpose.  The new arrow "fits" better behind the double
triangles.  So I send the original patch again.

Please apply!

Cheers,
-- 
W. Borgert <debacle@debian.org>
diff -uraN dia/lib/arrows.c dia.new/lib/arrows.c
--- dia/lib/arrows.c	2003-09-12 23:27:37.000000000 +0000
+++ dia.new/lib/arrows.c	2003-09-12 23:25:56.000000000 +0000
@@ -50,8 +50,9 @@
    {N_("Filled Dot"),ARROW_FILLED_DOT},
    {N_("Dimension Origin"),ARROW_DIMENSION_ORIGIN},
    {N_("Blanked Dot"),ARROW_BLANKED_DOT},
-   {N_("Double Hollow triangle"),ARROW_DOUBLE_HOLLOW_TRIANGLE},
-   {N_("Double Filled triangle"),ARROW_DOUBLE_FILLED_TRIANGLE},
+   {N_("Double Hollow Triangle"),ARROW_DOUBLE_HOLLOW_TRIANGLE},
+   {N_("Double Filled Triangle"),ARROW_DOUBLE_FILLED_TRIANGLE},
+   {N_("Filled Dot and Triangle"), ARROW_FILLED_DOT_N_TRIANGLE},
    {N_("Filled Box"),ARROW_FILLED_BOX},
    {N_("Blanked Box"),ARROW_BLANKED_BOX},
    {N_("Slashed"),ARROW_SLASH_ARROW},
@@ -242,6 +243,12 @@
     point_normalize(move_line);
     point_scale(move_line, 2*arrow->length);
     return;
+  case ARROW_FILLED_DOT_N_TRIANGLE:
+    *move_line = *to;
+    point_sub(move_line, from);
+    point_normalize(move_line);
+    point_scale(move_line, arrow->length + arrow->width);
+    return;
   default: 
     move_arrow->x = 0.0;
     move_arrow->y = 0.0;
@@ -1042,6 +1049,42 @@
   DIA_RENDERER_GET_CLASS(renderer)->draw_arc(renderer, &p, width, length, angle_start - 180.0, angle_start, fg_color);  
 }
 
+static void
+draw_filled_dot_n_triangle(DiaRenderer *renderer, Point *to, Point *from,
+			   real length, real width, real linewidth,
+			   Color *fg_color, Color *bg_color)
+{
+  Point p_dot = *to, p_tri = *to, delta;
+  real len, rayon;
+  real rapport;
+  Point poly[3];
+
+  DIA_RENDERER_GET_CLASS(renderer)->set_linecaps(renderer, LINECAPS_BUTT);
+  DIA_RENDERER_GET_CLASS(renderer)->set_linejoin(renderer, LINEJOIN_MITER);
+  DIA_RENDERER_GET_CLASS(renderer)->set_linestyle(renderer, LINESTYLE_SOLID);
+  DIA_RENDERER_GET_CLASS(renderer)->set_linewidth(renderer, linewidth);
+  
+  delta = *from;
+  
+  point_sub(&delta, to);	
+  
+  len = sqrt(point_dot(&delta, &delta)); /* line length */
+  
+  /* dot */
+  rayon = (width / 2.0);
+  rapport = rayon / len;
+  p_dot.x += delta.x * rapport;
+  p_dot.y += delta.y * rapport;
+  DIA_RENDERER_GET_CLASS(renderer)->fill_ellipse(renderer, &p_dot,
+						 width, width, fg_color);
+  /* triangle */
+  rapport = width / len;
+  p_tri.x += delta.x * rapport;
+  p_tri.y += delta.y * rapport;
+  calculate_arrow(poly, &p_tri, from, length, width);
+  DIA_RENDERER_GET_CLASS(renderer)->fill_polygon(renderer, poly, 3, fg_color);
+}
+
 void
 arrow_draw(DiaRenderer *renderer, ArrowType type,
 	   Point *to, Point *from,
@@ -1136,5 +1179,9 @@
     draw_open_rounded(renderer, to, from, length, width, linewidth,
 		      fg_color, bg_color);
     break;
+  case ARROW_FILLED_DOT_N_TRIANGLE:
+    draw_filled_dot_n_triangle(renderer, to, from, length, width, linewidth,
+			       fg_color, bg_color);
+    break;
   } 
 }
diff -uraN dia/lib/arrows.h dia.new/lib/arrows.h
--- dia/lib/arrows.h	2003-09-12 23:27:37.000000000 +0000
+++ dia.new/lib/arrows.h	2003-09-12 23:25:56.000000000 +0000
@@ -56,6 +56,7 @@
   ARROW_ROUNDED,
   ARROW_HALF_DIAMOND,		/* ---< */
   ARROW_OPEN_ROUNDED,		/* ---c */
+  ARROW_FILLED_DOT_N_TRIANGLE,	/* ---|>o */
 } ArrowType;
 
 struct menudesc {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK