r5480 - trunk/eda/fped

werner at docs.openmoko.org werner at docs.openmoko.org
Tue Aug 18 22:52:10 CEST 2009


Author: werner
Date: 2009-08-18 22:52:09 +0200 (Tue, 18 Aug 2009)
New Revision: 5480

Modified:
   trunk/eda/fped/TODO
   trunk/eda/fped/gui_tool.c
   trunk/eda/fped/inst.c
   trunk/eda/fped/inst.h
   trunk/eda/fped/meas.c
   trunk/eda/fped/meas.h
Log:
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



Modified: trunk/eda/fped/TODO
===================================================================
--- trunk/eda/fped/TODO	2009-08-17 21:00:09 UTC (rev 5479)
+++ trunk/eda/fped/TODO	2009-08-18 20:52:09 UTC (rev 5480)
@@ -35,7 +35,6 @@
 - 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
 

Modified: trunk/eda/fped/gui_tool.c
===================================================================
--- trunk/eda/fped/gui_tool.c	2009-08-17 21:00:09 UTC (rev 5479)
+++ trunk/eda/fped/gui_tool.c	2009-08-18 20:52:09 UTC (rev 5480)
@@ -471,12 +471,10 @@
 	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 @@
 	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 @@
 {
 	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:

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c	2009-08-17 21:00:09 UTC (rev 5479)
+++ trunk/eda/fped/inst.c	2009-08-18 20:52:09 UTC (rev 5480)
@@ -737,9 +737,13 @@
 {
 	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 @@
 			(*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 @@
 				next = inst->next;
 				free(inst);
 			}
-		reset_samples(pkg->samples);
+		reset_samples(pkg->samples, pkg->n_samples);
 		free(pkg->samples);
 		free(pkg);
 		pkg = next_pkg;

Modified: trunk/eda/fped/inst.h
===================================================================
--- trunk/eda/fped/inst.h	2009-08-17 21:00:09 UTC (rev 5479)
+++ trunk/eda/fped/inst.h	2009-08-18 20:52:09 UTC (rev 5480)
@@ -114,6 +114,7 @@
 	struct inst *insts[ip_n];
 	struct inst **next_inst[ip_n];
 	struct sample **samples;
+	int n_samples;
 	struct pkg *next;
 };
 

Modified: trunk/eda/fped/meas.c
===================================================================
--- trunk/eda/fped/meas.c	2009-08-17 21:00:09 UTC (rev 5479)
+++ trunk/eda/fped/meas.c	2009-08-18 20:52:09 UTC (rev 5480)
@@ -27,12 +27,12 @@
 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]);

Modified: trunk/eda/fped/meas.h
===================================================================
--- trunk/eda/fped/meas.h	2009-08-17 21:00:09 UTC (rev 5479)
+++ trunk/eda/fped/meas.h	2009-08-18 20:52:09 UTC (rev 5480)
@@ -60,7 +60,7 @@
 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);




More information about the commitlog mailing list