1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-11-22 11:41:52 +02:00

Various bugfixes.

- also dump the part name
- if given a zero-length vector, draw_arrow now draws a vertical arrow instead 
  of overflowing
- fixed angle calculation when drawing and selecting arcs
- redraw the screen after deselecting when we begin dragging



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5395 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
werner 2009-08-06 12:07:24 +00:00
parent 995aa4ca04
commit dc09f3435d
5 changed files with 26 additions and 10 deletions

1
TODO
View File

@ -19,7 +19,6 @@ Style:
Bugs:
- default silk width has no business being hard-coded in obj.c
- after moving, arc sometimes wrap the wrong way
- undelete only works if not much has changed since the deletion
Code cleanup:

5
dump.c
View File

@ -355,9 +355,10 @@ int dump(FILE *file)
fprintf(file, "/* MACHINE-GENERATED ! */\n\n");
for (frame = frames; frame; frame = frame->next) {
if (!frame->name)
if (!frame->name) {
fprintf(file, "part \"%s\"\n", part_name);
dump_frame(file, frame, "");
else {
} else {
fprintf(file, "frame %s {\n", frame->name);
dump_frame(file, frame, "\t");
fprintf(file, "}\n\n");

View File

@ -172,6 +172,7 @@ static gboolean button_press_event(GtkWidget *widget, GdkEventButton *event,
}
if (res) {
inst_deselect();
redraw();
dragging = 1;
drag_escaped = 0;
drag_start = pos;

View File

@ -97,7 +97,12 @@ static void draw_arrow(struct draw_ctx *ctx, GdkGC *gc, int fill,
struct coord p[3];
struct coord side;
if (from.x == to.x && from.y == to.y) {
side.x = 0;
side.y = -len;
} else {
side = normalize(sub_vec(to, from), len);
}
p[0] = add_vec(to, rotate(side, 180-angle));
p[1] = to;
p[2] = add_vec(to, rotate(side, 180+angle));
@ -267,7 +272,7 @@ unit_type gui_dist_arc(struct inst *self, struct coord pos, unit_type scale)
struct coord c = self->base;
struct coord p;
unit_type r, d_min, d;
double angle, a2;
double angle, a1, a2;
r = self->u.arc.width/scale/2;
if (r < SELECT_R)
@ -297,10 +302,15 @@ unit_type gui_dist_arc(struct inst *self, struct coord pos, unit_type scale)
/* see if we're close to the part that's actually drawn */
angle = theta(c, pos);
a1 = self->u.arc.a1;
a2 = self->u.arc.a2;
if (a2 < self->u.arc.a1)
a2 += 180;
return angle >= self->u.arc.a1 && angle <= a2 ? d : -1;
if (angle < 0)
angle += 360;
if (a2 < a1)
a2 += 360;
if (angle < a1)
angle += 360;
return angle >= a1 && angle <= a2 ? d : -1;
}

View File

@ -103,8 +103,13 @@ void restore_pix_buf(struct pix_buf *buf)
void draw_arc(GdkDrawable *da, GdkGC *gc, int fill,
int x, int y, int r, double a1, double a2)
{
if (a1 == a2)
a2 = a1+360;
/*
* This adjustment handles two distinct cases:
* - if a1 == a2, we make sure we draw a full circle
* - the end angle a2 must always be greater than the start angle a1
*/
if (a2 <= a1)
a2 += 360;
gdk_draw_arc(da, gc, fill, x-r, y-r, 2*r, 2*r, a1*64, (a2-a1)*64);
}