mirror of
git://projects.qi-hardware.com/fped.git
synced 2025-04-21 12:27:27 +03:00
- README: described use of semicolons
- README: added that loops can also execute zero times - accept labels only at the beginning of a line - rectangles and lines no longer use the bounding box for drawing (caused offset problems since we now correct for the line width) - dist_rect and inside_rect no longer require their input pre-sorted - pad instances now have their own structure and no longer abuse the bounding box to know the pad coordinates - Makefile: use $(GEN) for fig2dev, to reduce chattiness - when dragging a point, the symbol is now adjusted accordingly - added moving of rects, pads, circles, and arcs - added creation of pads - moved rotate_r from gui_inst.c to coord.c - new function "theta" that combines most of the angle calculations - save_pix_buf: y < 0 clipping changed width, not height git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5386 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
43
gui_inst.c
43
gui_inst.c
@@ -176,7 +176,7 @@ unit_type gui_dist_line(struct inst *self, struct coord pos, unit_type scale)
|
||||
r = self->u.rect.width/scale/2;
|
||||
if (r < SELECT_R)
|
||||
r = SELECT_R;
|
||||
d = dist_line(pos, self->bbox.min, self->bbox.max)/scale;
|
||||
d = dist_line(pos, self->base, self->u.rect.end)/scale;
|
||||
return d > r ? -1 : d;
|
||||
}
|
||||
|
||||
@@ -203,21 +203,22 @@ unit_type gui_dist_rect(struct inst *self, struct coord pos, unit_type scale)
|
||||
r = self->u.rect.width/scale/2;
|
||||
if (r < SELECT_R)
|
||||
r = SELECT_R;
|
||||
d = dist_rect(pos, self->bbox.min, self->bbox.max)/scale;
|
||||
d = dist_rect(pos, self->base, self->u.rect.end)/scale;
|
||||
return d > r ? -1 : d;
|
||||
}
|
||||
|
||||
|
||||
void gui_draw_rect(struct inst *self, struct draw_ctx *ctx)
|
||||
{
|
||||
struct coord min = translate(ctx, self->bbox.min);
|
||||
struct coord max = translate(ctx, self->bbox.max);
|
||||
struct coord min = translate(ctx, self->base);
|
||||
struct coord max = translate(ctx, self->u.rect.end);
|
||||
GdkGC *gc;
|
||||
|
||||
sort_coord(&min, &max);
|
||||
gc = gc_obj[get_mode(self)];
|
||||
set_width(gc, self->u.rect.width/ctx->scale);
|
||||
gdk_draw_rectangle(DA, gc, FALSE,
|
||||
min.x, max.y, max.x-min.x, min.y-max.y);
|
||||
min.x, min.y, max.x-min.x, max.y-min.y);
|
||||
}
|
||||
|
||||
|
||||
@@ -228,31 +229,32 @@ unit_type gui_dist_pad(struct inst *self, struct coord pos, unit_type scale)
|
||||
{
|
||||
unit_type d;
|
||||
|
||||
if (inside_rect(pos, self->bbox.min, self->bbox.max))
|
||||
if (inside_rect(pos, self->base, self->u.pad.other))
|
||||
return SELECT_R;
|
||||
d = dist_rect(pos, self->bbox.min, self->bbox.max)/scale;
|
||||
d = dist_rect(pos, self->base, self->u.pad.other)/scale;
|
||||
return d > SELECT_R ? -1 : d;
|
||||
}
|
||||
|
||||
|
||||
void gui_draw_pad(struct inst *self, struct draw_ctx *ctx)
|
||||
{
|
||||
struct coord min = translate(ctx, self->bbox.min);
|
||||
struct coord max = translate(ctx, self->bbox.max);
|
||||
struct coord min = translate(ctx, self->base);
|
||||
struct coord max = translate(ctx, self->u.pad.other);
|
||||
GdkGC *gc;
|
||||
struct coord c;
|
||||
unit_type h, w;
|
||||
|
||||
gc = gc_pad[get_mode(self)];
|
||||
sort_coord(&min, &max);
|
||||
gdk_draw_rectangle(DA, gc, TRUE,
|
||||
min.x, max.y, max.x-min.x, min.y-max.y);
|
||||
min.x, min.y, max.x-min.x, max.y-min.y);
|
||||
|
||||
gc = gc_ptext[get_mode(self)];
|
||||
c = add_vec(min, max);
|
||||
h = min.y-max.y;
|
||||
h = max.y-min.y;
|
||||
w = max.x-min.x;
|
||||
render_text(DA, gc, c.x/2, c.y/2, w <= h*1.1 ? 0 : 90, self->u.name,
|
||||
PAD_FONT, 0.5, 0.5,
|
||||
render_text(DA, gc, c.x/2, c.y/2, w <= h*1.1 ? 0 : 90,
|
||||
self->u.pad.name, PAD_FONT, 0.5, 0.5,
|
||||
w-2*PAD_BORDER, h-2*PAD_BORDER);
|
||||
}
|
||||
|
||||
@@ -260,17 +262,6 @@ void gui_draw_pad(struct inst *self, struct draw_ctx *ctx)
|
||||
/* ----- arc --------------------------------------------------------------- */
|
||||
|
||||
|
||||
static struct coord rotate_r(struct coord center, unit_type r, double angle)
|
||||
{
|
||||
struct coord res;
|
||||
|
||||
angle = angle/180.0*M_PI;
|
||||
res.x = center.x+r*cos(angle);
|
||||
res.y = center.y+r*sin(angle);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
unit_type gui_dist_arc(struct inst *self, struct coord pos, unit_type scale)
|
||||
{
|
||||
struct coord c = self->base;
|
||||
@@ -305,9 +296,7 @@ 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 = atan2(pos.y-c.y, pos.x-c.x)/M_PI*180.0;
|
||||
if (angle < 0)
|
||||
angle += 180;
|
||||
angle = theta(c, pos);
|
||||
a2 = self->u.arc.a2;
|
||||
if (a2 < self->u.arc.a1)
|
||||
a2 += 180;
|
||||
|
||||
Reference in New Issue
Block a user