I would like to use dia for ERDs but there were no appropriate "arrows" to
represent the cardinality of relationships, so I hacked in "crows feet" this
afternoon against dia .88.1. Attached is a patch of my changes. (this is
the first patch I've ever generated, so let me know if I need to give diff
different options)
_________________________
Richard Rowell
rwrowell@bellsouth.net
If Java had true garbage collection, most programs would delete themselves
upon execution. - Robert Sewell
diff -aur -xMakefile dia-0.88.1/app/lineprops_area.c dia-0.88.1-hacked/app/lineprops_area.c
--- dia-0.88.1/app/lineprops_area.c Mon Apr 30 19:55:37 2001
+++ dia-0.88.1-hacked/app/lineprops_area.c Thu Jan 24 16:47:24 2002
@@ -461,6 +461,36 @@
y+4); /*cross*/
}
break;
+
+ case ARROW_CROW_FOOT:
+ if (arrow->left) {
+ gdk_draw_line(win, gc, x+5,y+height/2, x+width,y+height/2); /*line*/
+ gdk_draw_line(win, gc, x+5,y+height/2-5, x+5+height/2,y+height/2);
+ gdk_draw_line(win, gc, x+5,y+height/2+5, x+5+height/2,y+height/2);
+ /*cross */
+ } else {
+ gdk_draw_line(win, gc, x,y+height/2, x+width-5,y+height/2); /*line*/
+ gdk_draw_line(win, gc, x+width-5,y+height/2-5, x+width-height/2-5,y+height/2);
+ gdk_draw_line(win, gc, x+width-5,y+height/2+5, x+width-height/2-5,y+height/2);
+ }
+ break;
+
+ case ARROW_CROSS:
+ if (arrow->left) {
+ gdk_draw_line(win, gc, x+5,y+height/2, x+width,y+height/2); /*line*/
+ //gdk_draw_line(win, gc, x+5+height/4,y+height/2-5, x+5+height/4,y+height/2+5);
+ gdk_draw_line(win, gc, x+height/2,y+height-4, x+height/2,y+4);
+ /*cross */
+ } else {
+ gdk_draw_line(win, gc, x,y+height/2, x+width-5,y+height/2); /*line*/
+ gdk_draw_line(win, gc, x+width-height/2,y+height-4, x+width-height/2,
+ y+4); /*cross*/
+
+ }
+ break;
+
+
+
}
gdk_gc_set_line_attributes(gc, gcvalues.line_width, gcvalues.line_style,
gcvalues.cap_style, gcvalues.join_style);
@@ -763,7 +793,7 @@
menu = gtk_menu_new();
gtk_object_set_data_full(GTK_OBJECT(chooser), button_menu_key, menu,
(GtkDestroyNotify)gtk_widget_unref);
- for (i = 0; i <= ARROW_INTEGRAL_SYMBOL; i++) {
+ for (i = 0; i <= ARROW_CROSS; i++) {
mi = gtk_menu_item_new();
gtk_object_set_data(GTK_OBJECT(mi), menuitem_enum_key, GINT_TO_POINTER(i));
ar = dia_arrow_preview_new(i, left);
Only in dia-0.88.1-hacked/app: tags
Only in dia-0.88.1-hacked: config.cache
Only in dia-0.88.1-hacked: config.h
Only in dia-0.88.1-hacked: config.log
Only in dia-0.88.1-hacked: config.status
Only in dia-0.88.1: core-translation-report
Only in dia-0.88.1-hacked: dia.keys
Only in dia-0.88.1-hacked/doc/en: stamp-doc
diff -aur -xMakefile dia-0.88.1/lib/arrows.c dia-0.88.1-hacked/lib/arrows.c
--- dia-0.88.1/lib/arrows.c Mon Apr 30 19:55:38 2001
+++ dia-0.88.1-hacked/lib/arrows.c Thu Jan 24 18:03:21 2002
@@ -67,6 +67,58 @@
}
static void
+calculate_crow(Point *poly/*[3]*/, Point *to, Point *from,
+ real length, real width)
+{
+ Point delta;
+ Point orth_delta;
+ real len;
+
+ delta = *to;
+ point_sub(&delta, from);
+ len = point_len(&delta);
+ if (len <= 0.0001) {
+ delta.x=1.0;
+ delta.y=0.0;
+ } else {
+ delta.x/=len;
+ delta.y/=len;
+ }
+
+ orth_delta.x = delta.y;
+ orth_delta.y = -delta.x;
+
+ point_scale(&delta, length);
+ point_scale(&orth_delta, width/2.0);
+
+
+ poly[0] = *to;
+ point_sub(&poly[0], &delta);
+ poly[1] = *to;
+ point_sub(&poly[1], &orth_delta);
+ poly[2] = *to;
+ point_add(&poly[2], &orth_delta);
+}
+
+static void
+draw_crow_foot(Renderer *renderer, Point *to, Point *from,
+ real length, real width, real linewidth,
+ Color *fg_color,Color *bg_color)
+{
+
+ Point poly[3];
+
+ calculate_crow(poly, to, from, length, width);
+
+ renderer->ops->set_linewidth(renderer, linewidth);
+ renderer->ops->set_linestyle(renderer, LINESTYLE_SOLID);
+ renderer->ops->set_linejoin(renderer, LINEJOIN_MITER);
+
+ renderer->ops->draw_line(renderer,&poly[0],&poly[1],fg_color);
+ renderer->ops->draw_line(renderer,&poly[0],&poly[2],fg_color);
+}
+
+static void
draw_lines(Renderer *renderer, Point *to, Point *from,
real length, real width, real linewidth,
Color *color)
@@ -355,13 +407,12 @@
point_copy_add_scaled(&be3,to,&vl,.9*length);
point_add_scaled(&be3,&vt,-.4*width);
- renderer->ops->draw_line(renderer, to, &bs2, bg_color); /* kludge */
+ renderer->ops->draw_line(renderer, to, &bs2, bg_color);
renderer->ops->draw_line(renderer, &bs2, &be2, fg_color);
renderer->ops->draw_line(renderer, &bs, &be, fg_color);
renderer->ops->draw_line(renderer, &bs3, &be3, fg_color);
}
-
/* Only draw the upper part of the arrow */
static void
draw_halfhead(Renderer *renderer, Point *to, Point *from,
@@ -542,6 +593,23 @@
renderer->ops->draw_line(renderer, &poly[4],&poly[5], color);
}
+static void
+draw_cross(Renderer *renderer, Point *to, Point *from,
+ real length, real width, real linewidth, Color *color)
+{
+ Point poly[6];
+
+ calculate_arrow(poly, to, from, length, width);
+
+ renderer->ops->set_linewidth(renderer, linewidth);
+ renderer->ops->set_linestyle(renderer, LINESTYLE_SOLID);
+ renderer->ops->set_linejoin(renderer, LINEJOIN_MITER);
+ renderer->ops->set_linecaps(renderer, LINECAPS_BUTT);
+
+ renderer->ops->draw_line(renderer, &poly[0],&poly[2], color);
+ //renderer->ops->draw_line(renderer, &poly[4],&poly[5], color);
+}
+
static void
calculate_double_arrow(Point *second_to, Point *second_from,
Point *to, Point *from, real length)
@@ -663,6 +731,13 @@
case ARROW_SLASH_ARROW:
draw_slashed(renderer,to,from,length,width,linewidth,fg_color,bg_color);
break;
+ case ARROW_CROW_FOOT:
+ draw_crow_foot(renderer,to,from,length,width,linewidth,fg_color,bg_color);
+ break;
+ case ARROW_CROSS:
+ draw_cross(renderer, to, from, length, width, linewidth, fg_color);
+ break;
+
}
}
diff -aur -xMakefile dia-0.88.1/lib/arrows.h dia-0.88.1-hacked/lib/arrows.h
--- dia-0.88.1/lib/arrows.h Mon Apr 30 19:55:38 2001
+++ dia-0.88.1-hacked/lib/arrows.h Thu Jan 24 15:59:45 2002
@@ -46,7 +46,9 @@
ARROW_FILLED_BOX, /* {filled box} */
ARROW_BLANKED_BOX, /* {blanked box} */
ARROW_SLASH_ARROW, /* {slash arrow} */
- ARROW_INTEGRAL_SYMBOL /* {integral symbol} */
+ ARROW_INTEGRAL_SYMBOL, /* {integral symbol} */
+ ARROW_CROW_FOOT,
+ ARROW_CROSS
} ArrowType;
typedef struct {
Only in dia-0.88.1-hacked/lib: tags
diff -aur -xMakefile dia-0.88.1/lib/widgets.c dia-0.88.1-hacked/lib/widgets.c
--- dia-0.88.1/lib/widgets.c Mon Apr 30 19:55:40 2001
+++ dia-0.88.1-hacked/lib/widgets.c Thu Jan 24 16:10:26 2002
@@ -672,6 +672,8 @@
{N_("Blanked Box"),ARROW_BLANKED_BOX},
{N_("Slashed"),ARROW_SLASH_ARROW},
{N_("Integral Symbol"),ARROW_INTEGRAL_SYMBOL},
+ {N_("Crow Foot"),ARROW_CROW_FOOT},
+ {N_("Cross"),ARROW_CROSS},
{NULL,0}};
static void
Only in dia-0.88.1-hacked: libtool
Only in dia-0.88.1-hacked/po: Makefile.in
Only in dia-0.88.1-hacked/po: POTFILES
Only in dia-0.88.1/sheets: sheet-translation-report
Only in dia-0.88.1-hacked: stamp-h
Only in dia-0.88.1-hacked: tags