1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-09-28 19:59:49 +03:00

Finally found a nice way to draw arcs in the GUI.

- we freed a package's samples list after recalculating the number of samples,
  which caused a crash after adding a new vector. We now record the original 
  list length in the package structure.
- when dragging a circle, offer the end point first, so that it becomes an arc



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5480 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
werner 2009-08-18 20:52:09 +00:00
parent de044ca61f
commit 37b52f23fe
6 changed files with 19 additions and 20 deletions

1
TODO
View File

@ -35,7 +35,6 @@ Bugs:
- whenever we call parse_* for input parsing, we may leak lots of expressions
- can't edit measurement labels through the GUI
- r of rpads is misleading, particularly if we have a circle
- we can't enter an arc through the GUI / can't convert a circle to an arc
- using variables in a measurement offset causes a crash because evaluation
takes place after all table entries have been visited

View File

@ -471,12 +471,10 @@ struct pix_buf *draw_move_arc(struct inst *inst, struct coord pos, int i)
case 0:
c = pos;
break;
case 1:
from = pos;
if (inst->obj->u.arc.start != inst->obj->u.arc.end)
break;
/* fall through */
case 2:
from = pos;
break;
case 1:
to = pos;
break;
default:
@ -502,7 +500,7 @@ struct pix_buf *draw_move_arc(struct inst *inst, struct coord pos, int i)
buf = save_pix_buf(DA,
c.x-r_save, c.y-r_save, c.x+r_save, c.y+r_save, 1);
draw_arc(DA, gc_drag, FALSE, c.x, c.y, r, a1, a2);
if (i == 2) {
if (i == 1) {
end = rotate_r(c, r_save, -a2);
gdk_draw_line(DA, gc_drag, c.x, c.y, end.x, end.y);
}
@ -514,19 +512,15 @@ void do_move_to_arc(struct inst *inst, struct inst *to, int i)
{
struct vec *vec = inst_get_vec(to);
struct obj *obj = inst->obj;
int is_circle;
is_circle = obj->u.arc.start == obj->u.arc.end;
switch (i) {
case 0:
obj->base = vec;
break;
case 1:
obj->u.arc.start = vec;
if (!is_circle)
break;
/* fall through */
case 2:
obj->u.arc.start = vec;
break;
case 1:
obj->u.arc.end = vec;
break;
default:

11
inst.c
View File

@ -737,9 +737,13 @@ static int arc_op_anchors(struct inst *inst, struct vec ***anchors)
{
struct obj *obj = inst->obj;
/*
* Put end point first so that this is what we grab if dragging a
* circle (thereby turning it into an arc).
*/
anchors[0] = &obj->base;
anchors[1] = &obj->u.arc.start;
anchors[2] = &obj->u.arc.end;
anchors[1] = &obj->u.arc.end;
anchors[2] = &obj->u.arc.start;
return 3;
}
@ -959,6 +963,7 @@ void inst_select_pkg(const char *name)
(*pkg)->next_inst[prio] = &(*pkg)->insts[prio];
(*pkg)->samples =
zalloc_size(sizeof(struct sample *)*n_samples);
(*pkg)->n_samples = n_samples;
}
curr_pkg = *pkg;
}
@ -986,7 +991,7 @@ static void free_pkgs(struct pkg *pkg)
next = inst->next;
free(inst);
}
reset_samples(pkg->samples);
reset_samples(pkg->samples, pkg->n_samples);
free(pkg->samples);
free(pkg);
pkg = next_pkg;

1
inst.h
View File

@ -114,6 +114,7 @@ struct pkg {
struct inst *insts[ip_n];
struct inst **next_inst[ip_n];
struct sample **samples;
int n_samples;
struct pkg *next;
};

4
meas.c
View File

@ -27,12 +27,12 @@ int n_samples;
struct num eval_unit(const struct expr *expr, const struct frame *frame);
void reset_samples(struct sample **samples)
void reset_samples(struct sample **samples, int n)
{
struct sample *next;
int i;
for (i = 0; i != n_samples; i++)
for (i = 0; i != n; i++)
while (samples[i]) {
next = samples[i]->next;
free(samples[i]);

2
meas.h
View File

@ -60,7 +60,7 @@ struct coord meas_find_next(lt_op_type lt, const struct sample *s,
struct coord meas_find_max(lt_op_type lt, const struct sample *s);
void reset_samples(struct sample **samples);
void reset_samples(struct sample **samples, int n);
void meas_start(void);
void meas_post(const struct vec *vec, struct coord pos);
int instantiate_meas(void);