[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: CVS update: Makefile.am
User: pcjc2
Date: 07/04/17 16:19:23
Modified: . Makefile.am a_basic.c f_image.c f_print.c g_smob.c
o_arc_basic.c o_basic.c o_box_basic.c o_bus_basic.c
o_circle_basic.c o_complex_basic.c o_line_basic.c
o_net_basic.c o_picture.c o_pin_basic.c
o_text_basic.c s_basic.c s_toplevel.c
Log:
Merge changes from noscreen branch
Revision Changes Path
1.61 +0 -0 eda/geda/gaf/libgeda/src/Makefile.am
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Makefile.am
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/Makefile.am,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -b -r1.60 -r1.61
--- Makefile.am 24 Feb 2007 18:43:16 -0000 1.60
+++ Makefile.am 17 Apr 2007 20:19:20 -0000 1.61
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.60 2007/02/24 18:43:16 pcjc2 Exp $
+# $Id: Makefile.am,v 1.61 2007/04/17 20:19:20 pcjc2 Exp $
#
# NOTE: Don't forget that in the libtool distribution, files in this
# directory are distributed by the demo_distfiles variable in the top
1.23 +1 -0 eda/geda/gaf/libgeda/src/a_basic.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: a_basic.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/a_basic.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- a_basic.c 30 Sep 2006 16:27:23 -0000 1.22
+++ a_basic.c 17 Apr 2007 20:19:20 -0000 1.23
@@ -467,6 +467,7 @@
w_current->page_current->object_tail = temp_tail;
w_current->page_current->object_parent = temp_parent;
+ o_complex_recalc( w_current, object_list );
embedded_level--;
} else {
fprintf(stderr, "Read unexpected embedded "
1.20 +4 -4 eda/geda/gaf/libgeda/src/f_image.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: f_image.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/f_image.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- f_image.c 22 Sep 2006 18:48:07 -0000 1.19
+++ f_image.c 17 Apr 2007 20:19:20 -0000 1.20
@@ -187,7 +187,7 @@
/* printf("%d %d\n", w_current->paper_width, w_current->paper_height);*/
- world_get_complex_bounds(w_current,
+ world_get_object_list_bounds(w_current,
w_current->page_current->object_head,
&origin_x, &origin_y,
&right, &bottom);
1.28 +4 -4 eda/geda/gaf/libgeda/src/f_print.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: f_print.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/f_print.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- f_print.c 10 Feb 2007 21:08:18 -0000 1.27
+++ f_print.c 17 Apr 2007 20:19:20 -0000 1.28
@@ -443,7 +443,7 @@
/* printf("%d %d\n", w_current->paper_width, w_current->paper_height);*/
- world_get_complex_bounds(w_current,
+ world_get_object_list_bounds(w_current,
w_current->page_current->object_head,
&origin_x, &origin_y,
&right, &bottom);
1.15 +7 -5 eda/geda/gaf/libgeda/src/g_smob.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: g_smob.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/g_smob.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- g_smob.c 5 Apr 2007 22:59:57 -0000 1.14
+++ g_smob.c 17 Apr 2007 20:19:20 -0000 1.15
@@ -377,8 +377,10 @@
/*! \brief Get the bounds of an attribute.
* \par Function Description
* Get the bounds of an attribute.
- * I got top and bottom values reversed from world_get_complex_bounds,
- * so don\'t rely on the position in the list.
+ * WARNING: top and bottom are mis-named in world-coords,
+ * top is the smallest "y" value, and bottom is the largest.
+ * Be careful! This doesn't correspond to what you'd expect,
+ * nor to the coordinate system who's origin is the bottom, left of the page.
* \param[in] attrib_smob the attribute.
* \return a list of the bounds of the <B>attrib smob</B>.
* The list has the format: ( (left right) (top bottom) )
1.35 +22 -101 eda/geda/gaf/libgeda/src/o_arc_basic.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: o_arc_basic.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_arc_basic.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- o_arc_basic.c 24 Feb 2007 18:43:16 -0000 1.34
+++ o_arc_basic.c 17 Apr 2007 20:19:21 -0000 1.35
@@ -208,9 +208,6 @@
* If <B>whichone</B> is equal to #ARC_END_ANGLE, the <B>x</B> parameter is the ending angle of the arc.
* <B>x</B> is in degrees. <B>y</B> is ignored.
*
- * The screen coordinates of the arc and its bounding box are computed again
- * after the change in world coordinates.
- *
* \param [in] w_current The TOPLEVEL object.
* \param [in,out] object
* \param [in] x
@@ -529,110 +526,28 @@
* pointed structure.
* It also recalculates the <B>OBJECT</B> specific fields and the bounding box of the arc.
*
- * The bounding box - in screen units - is recalculated with the <B>get_arc_bounds()</B> function.
+ * The bounding box - in world units - is recalculated with the <B>world_get_arc_bounds()</B> function.
*
* \param [in] w_current The TOPLEVEL object.
* \param [in] o_current
*/
void o_arc_recalc(TOPLEVEL *w_current, OBJECT *o_current)
{
- int screen_x1, screen_y1, screen_x2, screen_y2;
int left, right, top, bottom;
if (o_current->arc == NULL) {
return;
}
- /* update the screen_x and screen_y fields of the arc */
- WORLDtoSCREEN(w_current, o_current->arc->x, o_current->arc->y,
- &screen_x1, &screen_y1);
-
- o_current->arc->screen_x = screen_x1; /* x coord */
- o_current->arc->screen_y = screen_y1; /* y coord */
-
- /* update the screen_width and screen_height fields of the arc */
- WORLDtoSCREEN(w_current,
- o_current->arc->x + o_current->arc->width,
- o_current->arc->y - o_current->arc->height,
- &screen_x2, &screen_y2);
-
- o_current->arc->screen_width = screen_x2 - screen_x1; /* width */
- o_current->arc->screen_height = screen_y2 - screen_y1; /* height */
-
/* recalculates the bounding box */
- get_arc_bounds(w_current, o_current, &left, &top, &right, &bottom);
- o_current->left = left;
- o_current->top = top;
- o_current->right = right;
- o_current->bottom = bottom;
+ world_get_arc_bounds(w_current, o_current, &left, &top, &right, &bottom);
+ o_current->w_left = left;
+ o_current->w_top = top;
+ o_current->w_right = right;
+ o_current->w_bottom = bottom;
}
-/*! \brief
- * \par Function Description
- * This function calculates the smallest rectangle the arc can be drawn into.
- * The <B>OBJECT</B> pointed by object is assumed to be an arc.
- * The <B>left</B>, <B>top</B>, <B>right</B> and <B>bottom</B> pointed integers define
- * this rectangle at the end of the function. It is expressed in screen units.
- *
- * The process is divided into two steps : the first step is to calculate the
- * coordinates of the two ends of the arc and the coordinates of the center.
- * They form a first rectangle but (depending on the start angle and the sweep
- * of the arc) not the right.
- *
- * \param [in] w_current The TOPLEVEL object.
- * \param [in] object
- * \param [out] left
- * \param [out] top
- * \param [out] right
- * \param [out] bottom
- */
-void get_arc_bounds(TOPLEVEL *w_current, OBJECT *object,
- int *left, int *top, int *right, int *bottom)
-{
- int x1, y1, x2, y2, x3, y3;
- int radius, start_angle, end_angle;
- int i, angle;
-
- radius = object->arc->screen_width / 2;
- start_angle = object->arc->start_angle % 360;
- end_angle = object->arc->end_angle % 360;
-
- x1 = object->arc->screen_x;
- y1 = object->arc->screen_y;
- x2 = x1 + radius * cos(start_angle * M_PI / 180);
- y2 = y1 - radius * sin(start_angle * M_PI / 180);
- x3 = x1 + radius * cos((start_angle + end_angle) * M_PI / 180);
- y3 = y1 - radius * sin((start_angle + end_angle) * M_PI / 180);
-
- *left = (x1 < x2) ? ((x1 < x3) ? x1 : x3) : ((x2 < x3) ? x2 : x3);
- *right = (x1 > x2) ? ((x1 > x3) ? x1 : x3) : ((x2 > x3) ? x2 : x3);
- *top = (y1 < y2) ? ((y1 < y3) ? y1 : y3) : ((y2 < y3) ? y2 : y3);
- *bottom = (y1 > y2) ? ((y1 > y3) ? y1 : y3) : ((y2 > y3) ? y2 : y3);
-
- /*! \note
- * The previous rectangle is extended to the final one by checking
- * whether the arc is over a main axis (vertical or horizontal).
- * If so, the rectangle is extended in these directions.
- */
- angle = ((int) (start_angle / 90)) * 90;
- for(i = 0; i < 4; i++) {
- angle = angle + 90;
- if(angle < start_angle + end_angle) {
- if(angle % 360 == 0) *right = x1 + radius;
- if(angle % 360 == 90) *top = y1 - radius;
- if(angle % 360 == 180) *left = x1 - radius;
- if(angle % 360 == 270) *bottom = y1 + radius;
- } else {
- break;
- }
- }
-
- /* PB : bounding box has to take into account the width of the line it is
- composed with, ie adding/substracting half the width to this box */
- /* PB : but width is unknown here */
-
-}
/*! \brief
* \par Function Description
@@ -658,6 +573,9 @@
int x1, y1, x2, y2, x3, y3;
int radius, start_angle, end_angle;
int i, angle;
+ int halfwidth;
+
+ halfwidth = object->line_width / 2;
radius = object->arc->width / 2;
start_angle = object->arc->start_angle % 360;
@@ -672,8 +590,8 @@
*left = (x1 < x2) ? ((x1 < x3) ? x1 : x3) : ((x2 < x3) ? x2 : x3);
*right = (x1 > x2) ? ((x1 > x3) ? x1 : x3) : ((x2 > x3) ? x2 : x3);
- *bottom = (y1 < y2) ? ((y1 < y3) ? y1 : y3) : ((y2 < y3) ? y2 : y3);
- *top = (y1 > y2) ? ((y1 > y3) ? y1 : y3) : ((y2 > y3) ? y2 : y3);
+ *bottom = (y1 > y2) ? ((y1 > y3) ? y1 : y3) : ((y2 > y3) ? y2 : y3);
+ *top = (y1 < y2) ? ((y1 < y3) ? y1 : y3) : ((y2 < y3) ? y2 : y3);
/*! \note
* The previous rectangle is extended to the final one
@@ -685,15 +603,20 @@
angle = angle + 90;
if(angle < start_angle + end_angle) {
if(angle % 360 == 0) *right = x1 + radius;
- if(angle % 360 == 90) *top = y1 + radius;
+ if(angle % 360 == 90) *bottom = y1 + radius;
if(angle % 360 == 180) *left = x1 - radius;
- if(angle % 360 == 270) *bottom = y1 - radius;
+ if(angle % 360 == 270) *top = y1 - radius;
} else {
break;
}
}
- /* PB : same problem as above */
+ /* This isn't strictly correct, but a 1st order approximation */
+ *left -= halfwidth;
+ *top -= halfwidth;
+ *right += halfwidth;
+ *bottom += halfwidth;
+
}
@@ -1492,11 +1415,9 @@
if (end_angle < start_angle)
end_angle += 360;
- width = o_current->arc->screen_width;
- height = o_current->arc->screen_height;
-
- x = o_current->arc->screen_x;
- y = o_current->arc->screen_y;
+ width = SCREENabs( w_current, o_current->arc->width);
+ height = SCREENabs( w_current, o_current->arc->height);
+ WORLDtoSCREEN( w_current, o_current->arc->x, o_current->arc->y, &x, &y );
#ifdef HAS_LIBGD
1.17 +3 -0 eda/geda/gaf/libgeda/src/o_basic.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: o_basic.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_basic.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- o_basic.c 24 Feb 2007 18:43:16 -0000 1.16
+++ o_basic.c 17 Apr 2007 20:19:21 -0000 1.17
@@ -243,6 +243,9 @@
o_current->line_length = length;
o_current->line_space = space;
+
+ /* Recalculate the object's bounding box */
+ o_recalc_single_object( w_current, o_current );
}
/*! \brief Set #OBJECT's fill options.
1.28 +42 -82 eda/geda/gaf/libgeda/src/o_box_basic.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: o_box_basic.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_box_basic.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- o_box_basic.c 24 Feb 2007 18:43:16 -0000 1.27
+++ o_box_basic.c 17 Apr 2007 20:19:21 -0000 1.28
@@ -169,7 +169,7 @@
* The dimensions of the new box are set with the ones of the original box.
* The two boxes have the same line type and the same filling options.
*
- * The coordinates and the values in screen unit are computed with
+ * The coordinates and the values in world unit are computed with
* #o_box_recalc().
*/
@@ -279,7 +279,7 @@
object->box->lower_y = tmp;
}
- /* recalculate the screen coords and the boundings */
+ /* recalculate the world coords and the boundings */
o_box_recalc(w_current, object);
}
@@ -566,7 +566,7 @@
object->box->lower_x += world_centerx;
object->box->lower_y += world_centery;
- /* recalc boundings and screen coords */
+ /* recalc boundings and world coords */
o_box_recalc(w_current, object);
}
@@ -614,17 +614,15 @@
object->box->lower_x += world_centerx;
object->box->lower_y += world_centery;
- /* recalc boundings and screen coords */
+ /* recalc boundings and world coords */
o_box_recalc(w_current, object);
}
-/*! \brief Recalculate BOX coordinates in SCREEN units.
+/*! \brief Recalculate BOX coordinates in WORLD units.
* \par Function Description
- * This function recalculates the screen coords of the <B>o_current</B> pointed
- * box object from its world coords.
- *
- * The box coordinates and its bounding are recalculated
+ * This function recalculates the box coordinates and its
+ * bounding are recalculated as well.
*
* \param [in] w_current The TOPLEVEL object.
* \param [in,out] o_current BOX OBJECT to be recalculated.
@@ -632,63 +630,18 @@
void o_box_recalc(TOPLEVEL *w_current, OBJECT *o_current)
{
int left, top, right, bottom;
- int screen_x1, screen_y1;
- int screen_x2, screen_y2;
if (o_current->box == NULL) {
return;
}
- /* update the screen coords of the upper left corner of the box */
- WORLDtoSCREEN(w_current,
- o_current->box->upper_x, o_current->box->upper_y,
- &screen_x1, &screen_y1);
- o_current->box->screen_upper_x = screen_x1;
- o_current->box->screen_upper_y = screen_y1;
-
- /* update the screen coords of the lower right corner of the box */
- WORLDtoSCREEN(w_current,
- o_current->box->lower_x, o_current->box->lower_y,
- &screen_x2, &screen_y2);
- o_current->box->screen_lower_x = screen_x2;
- o_current->box->screen_lower_y = screen_y2;
-
- /* update the bounding box - screen unit */
- get_box_bounds(w_current, o_current->box, &left, &top, &right, &bottom);
- o_current->left = left;
- o_current->top = top;
- o_current->right = right;
- o_current->bottom = bottom;
-}
+ /* update the bounding box - world unit */
+ world_get_box_bounds(w_current, o_current, &left, &top, &right, &bottom);
+ o_current->w_left = left;
+ o_current->w_top = top;
+ o_current->w_right = right;
+ o_current->w_bottom = bottom;
-/*! \brief Get BOX bounding rectangle.
- * \par Function Description
- * This function sets the <B>left</B>, <B>top</B>, <B>right</B> and <B>bottom</B>
- * parameters to the bounding rectangle of the box object described in
- * <B>*box</B> in SCREEN units.
- *
- * \param [in] w_current The TOPLEVEL object.
- * \param [in] box BOX OBJECT to read coordinates from.
- * \param [out] left Left box coordinate in SCREEN units.
- * \param [out] top Top box coordinate in SCREEN units.
- * \param [out] right Right box coordinate in SCREEN units.
- * \param [out] bottom Bottom box coordinate in SCREEN units.
- */
-void get_box_bounds(TOPLEVEL *w_current, BOX *box,
- int *left, int *top, int *right, int *bottom)
-{
- *left = box->screen_upper_x;
- *top = box->screen_upper_y;
- *right = box->screen_lower_x;
- *bottom = box->screen_lower_y;
-
- /* PB : bounding box has to take into account the width of the line */
- /* PB : but line width is unknown here */
-
- *left = *left - 4;
- *top = *top - 4;
- *right = *right + 4;
- *bottom = *bottom + 4;
}
/*! \brief Get BOX bounding rectangle in WORLD coordinates.
@@ -698,27 +651,29 @@
* in world units.
*
* \param [in] w_current The TOPLEVEL object.
- * \param [in] box BOX OBJECT to read coordinates from.
+ * \param [in] object BOX OBJECT to read coordinates from.
* \param [out] left Left box coordinate in WORLD units.
* \param [out] top Top box coordinate in WORLD units.
* \param [out] right Right box coordinate in WORLD units.
* \param [out] bottom Bottom box coordinate in WORLD units.
*/
-void world_get_box_bounds(TOPLEVEL *w_current, BOX *box,
+void world_get_box_bounds(TOPLEVEL *w_current, OBJECT *object,
int *left, int *top, int *right, int *bottom)
{
- /* pb20011002 - why using min and max here and not above ? */
- *left = min(box->upper_x, box->lower_x);
- *top = min(box->upper_y, box->lower_y);
- *right = max(box->upper_x, box->lower_x);
- *bottom = max(box->upper_y, box->lower_y);
-
- /* PB : same as above here for width of edges */
+ int halfwidth;
-#if DEBUG
- printf("box: %d %d %d %d\n", *left, *top, *right, *bottom);
-#endif
+ halfwidth = object->line_width / 2;
+ *left = min(object->box->upper_x, object->box->lower_x);
+ *top = min(object->box->upper_y, object->box->lower_y);
+ *right = max(object->box->upper_x, object->box->lower_x);
+ *bottom = max(object->box->upper_y, object->box->lower_y);
+
+ /* This isn't strictly correct, but a 1st order approximation */
+ *left -= halfwidth;
+ *top -= halfwidth;
+ *right += halfwidth;
+ *bottom += halfwidth;
}
/*! \brief Print BOX to Postscript document.
@@ -1567,7 +1522,7 @@
int origin_x, int origin_y, int color_mode)
{
int color;
-
+ int s_upper_x, s_upper_y, s_lower_x, s_lower_y;
if (o_current == NULL) {
printf("got null in o_box_image_write\n");
@@ -1581,18 +1536,23 @@
color = image_black;
}
- /* assumes screen coords are already calculated correctly */
#ifdef HAS_LIBGD
+ WORLDtoSCREEN(w_current,
+ o_current->box->upper_x,
+ o_current->box->upper_y,
+ &s_upper_x, &s_upper_y);
+ WORLDtoSCREEN(w_current,
+ o_current->box->lower_x,
+ o_current->box->lower_y,
+ &s_lower_x, &s_lower_y);
+
gdImageSetThickness(current_im_ptr, SCREENabs(w_current,
o_current->line_width));
gdImageRectangle(current_im_ptr,
- o_current->box->screen_upper_x,
- o_current->box->screen_upper_y,
- o_current->box->screen_lower_x,
- o_current->box->screen_lower_y,
+ s_upper_x, s_upper_y,
+ s_lower_x, s_lower_y,
color);
#endif
-
}
1.19 +37 -163 eda/geda/gaf/libgeda/src/o_bus_basic.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: o_bus_basic.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_bus_basic.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- o_bus_basic.c 24 Feb 2007 18:43:16 -0000 1.18
+++ o_bus_basic.c 17 Apr 2007 20:19:21 -0000 1.19
@@ -47,53 +47,10 @@
* \par Function Description
*
*/
-void get_bus_bounds(TOPLEVEL *w_current, LINE *line, int *left, int *top,
+void world_get_bus_bounds(TOPLEVEL *w_current, OBJECT *object, int *left, int *top,
int *right, int *bottom)
{
- *left = w_current->width;
- *top = w_current->height;
- *right = 0;
- *bottom = 0;
-
- if (line->screen_x[0] < *left) *left = line->screen_x[0];
- if (line->screen_x[0] > *right) *right = line->screen_x[0];
- if (line->screen_y[0] < *top) *top = line->screen_y[0];
- if (line->screen_y[0] > *bottom) *bottom = line->screen_y[0];
-
- if (line->screen_x[1] < *left) *left = line->screen_x[1];
- if (line->screen_x[1] > *right) *right = line->screen_x[1];
- if (line->screen_y[1] < *top) *top = line->screen_y[1];
- if (line->screen_y[1] > *bottom) *bottom = line->screen_y[1];
-
- *left = *left - 4;
- *top = *top - 4;
-
- *right = *right + 4;
- *bottom = *bottom + 4;
-}
-
-/* \brief
- * \par Function Description
- *
- */
-void world_get_bus_bounds(TOPLEVEL *w_current, LINE *line, int *left, int *top,
- int *right, int *bottom)
-{
- *left = w_current->init_right;
- *top = w_current->init_bottom;
- *right = 0;
- *bottom = 0;
-
- if (line->x[0] < *left) *left = line->x[0];
- if (line->x[0] > *right) *right = line->x[0];
- if (line->y[0] < *top) *top = line->y[0];
- if (line->y[0] > *bottom) *bottom = line->y[0];
-
- if (line->x[1] < *left) *left = line->x[1];
- if (line->x[1] > *right) *right = line->x[1];
- if (line->y[1] < *top) *top = line->y[1];
- if (line->y[1] > *bottom) *bottom = line->y[1];
-
+ world_get_line_bounds( w_current, object, left, top, right, bottom );
}
/* \brief
@@ -105,7 +62,6 @@
int x1, int y1, int x2, int y2,
int bus_ripper_direction)
{
- int screen_x, screen_y;
int left, right, top, bottom;
OBJECT *new_node;
@@ -120,31 +76,16 @@
new_node->line->y[0] = y1;
new_node->line->x[1] = x2;
new_node->line->y[1] = y2;
-
- WORLDtoSCREEN(w_current,
- new_node->line->x[0], new_node->line->y[0],
- &screen_x,
- &screen_y);
-
- new_node->line->screen_x[0] = screen_x;
- new_node->line->screen_y[0] = screen_y;
-
- WORLDtoSCREEN(w_current,
- new_node->line->x[1], new_node->line->y[1],
- &screen_x,
- &screen_y);
-
- new_node->line->screen_x[1] = screen_x;
- new_node->line->screen_y[1] = screen_y;
+ new_node->line_width = BUS_WIDTH;
new_node->bus_ripper_direction = bus_ripper_direction;
- get_bus_bounds(w_current, new_node->line, &left, &top, &right, &bottom);
+ world_get_bus_bounds(w_current, new_node, &left, &top, &right, &bottom);
- new_node->left = left;
- new_node->top = top;
- new_node->right = right;
- new_node->bottom = bottom;
+ new_node->w_left = left;
+ new_node->w_top = top;
+ new_node->w_right = right;
+ new_node->w_bottom = bottom;
new_node->draw_func = bus_draw_func;
new_node->sel_func = select_func;
@@ -168,8 +109,6 @@
*/
void o_bus_recalc(TOPLEVEL *w_current, OBJECT *o_current)
{
- int screen_x1, screen_y1;
- int screen_x2, screen_y2;
int left, right, top, bottom;
if (o_current == NULL) {
@@ -180,29 +119,12 @@
return;
}
- WORLDtoSCREEN(w_current, o_current->line->x[0],
- o_current->line->y[0],
- &screen_x1,
- &screen_y1);
-
- o_current->line->screen_x[0] = screen_x1;
- o_current->line->screen_y[0] = screen_y1;
-
- WORLDtoSCREEN(w_current, o_current->line->x[1],
- o_current->line->y[1],
- &screen_x2,
- &screen_y2);
-
- o_current->line->screen_x[1] = screen_x2;
- o_current->line->screen_y[1] = screen_y2;
-
-
- get_bus_bounds(w_current, o_current->line, &left, &top, &right, &bottom);
+ world_get_bus_bounds(w_current, o_current, &left, &top, &right, &bottom);
- o_current->left = left;
- o_current->top = top;
- o_current->right = right;
- o_current->bottom = bottom;
+ o_current->w_left = left;
+ o_current->w_top = top;
+ o_current->w_right = right;
+ o_current->w_bottom = bottom;
}
@@ -296,43 +218,24 @@
*/
void o_bus_translate_world(TOPLEVEL *w_current, int x1, int y1, OBJECT *object)
{
- int screen_x1, screen_y1;
- int screen_x2, screen_y2;
int left, right, top, bottom;
if (object == NULL) printf("btw NO!\n");
- /* Do world coords */
+ /* Update world coords */
object->line->x[0] = object->line->x[0] + x1;
object->line->y[0] = object->line->y[0] + y1;
object->line->x[1] = object->line->x[1] + x1;
object->line->y[1] = object->line->y[1] + y1;
- /* update screen coords */
- WORLDtoSCREEN(w_current, object->line->x[0],
- object->line->y[0],
- &screen_x1,
- &screen_y1);
-
- object->line->screen_x[0] = screen_x1;
- object->line->screen_y[0] = screen_y1;
-
- WORLDtoSCREEN(w_current, object->line->x[1],
- object->line->y[1],
- &screen_x2,
- &screen_y2);
-
- object->line->screen_x[1] = screen_x2;
- object->line->screen_y[1] = screen_y2;
-
- /* update bounding box */
- get_bus_bounds(w_current, object->line, &left, &top, &right, &bottom);
-
- object->left = left;
- object->top = top;
- object->right = right;
- object->bottom = bottom;
+ /* Update bounding box */
+ world_get_bus_bounds(w_current, object, &left, &top, &right, &bottom);
+
+ object->w_left = left;
+ object->w_top = top;
+ object->w_right = right;
+ object->w_bottom = bottom;
s_tile_update_object(w_current, object);
}
@@ -362,11 +265,6 @@
o_current->line->x[1], o_current->line->y[1],
o_current->bus_ripper_direction);
- new_obj->line->screen_x[0] = o_current->line->screen_x[0];
- new_obj->line->screen_y[0] = o_current->line->screen_y[0];
- new_obj->line->screen_x[1] = o_current->line->screen_x[1];
- new_obj->line->screen_y[1] = o_current->line->screen_y[1];
-
new_obj->line->x[0] = o_current->line->x[0];
new_obj->line->y[0] = o_current->line->y[0];
new_obj->line->x[1] = o_current->line->x[1];
@@ -437,10 +335,7 @@
void o_bus_image_write(TOPLEVEL *w_current, OBJECT *o_current,
int origin_x, int origin_y, int color_mode)
{
- int offset, offset2;
- int cross;
- int x1, y1;
- int x2, y2;
+ int x[2], y[2];
int color;
if (o_current == NULL) {
@@ -454,34 +349,22 @@
color = image_black;
}
- offset = SCREENabs(w_current, BUS_WIDTH);
-
- /*
- offset = 7 * (float) w_current->height/ (float) w_current->width;
- offset2 = 7 * (float) w_current->height/ (float) w_current->width*2;
-
- printf("%f %d %d\n", (float) ( (float) w_current->height/ (float) w_current->width),
- offset, offset2);
- */
-
- offset2 = offset*2;
-
- cross = offset;
-
- x1 = o_current->line->screen_x[0];
- y1 = o_current->line->screen_y[0];
- x2 = o_current->line->screen_x[1];
- y2 = o_current->line->screen_y[1];
-
- /* assumes screen coords are already calculated correctly */
#ifdef HAS_LIBGD
+ WORLDtoSCREEN(w_current,
+ o_current->line->x[0],
+ o_current->line->y[0],
+ &x[0], &y[0]);
+ WORLDtoSCREEN(w_current,
+ o_current->line->x[1],
+ o_current->line->y[1],
+ &x[1], &y[1]);
+
gdImageSetThickness(current_im_ptr, SCREENabs(w_current, BUS_WIDTH));
- gdImageLine(current_im_ptr, x1, y1, x2, y2, color);
+ gdImageLine(current_im_ptr, x[0], y[0], x[1], y[1], color);
#endif
-
}
@@ -710,26 +593,17 @@
void o_bus_modify(TOPLEVEL *w_current, OBJECT *object,
int x, int y, int whichone)
{
- int screen_x, screen_y;
int left, right, top, bottom;
object->line->x[whichone] = x;
object->line->y[whichone] = y;
- WORLDtoSCREEN(w_current,
- object->line->x[whichone],
- object->line->y[whichone],
- &screen_x, &screen_y);
-
- object->line->screen_x[whichone] = screen_x;
- object->line->screen_y[whichone] = screen_y;
-
- get_bus_bounds(w_current, object->line, &left, &top, &right, &bottom);
-
- object->left = left;
- object->top = top;
- object->right = right;
- object->bottom = bottom;
+ world_get_bus_bounds(w_current, object, &left, &top, &right, &bottom);
+
+ object->w_left = left;
+ object->w_top = top;
+ object->w_right = right;
+ object->w_bottom = bottom;
s_tile_update_object(w_current, object);
}
1.29 +37 -96 eda/geda/gaf/libgeda/src/o_circle_basic.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: o_circle_basic.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_circle_basic.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- o_circle_basic.c 24 Feb 2007 18:43:16 -0000 1.28
+++ o_circle_basic.c 17 Apr 2007 20:19:21 -0000 1.29
@@ -116,7 +116,7 @@
new_node->draw_func = circle_draw_func;
new_node->sel_func = select_func;
- /* compute the bounding box and screen coords */
+ /* compute the bounding box coords */
o_circle_recalc(w_current, new_node);
/* add the object to the list */
@@ -165,7 +165,7 @@
* circle. The two circle have the same line type and the same filling
* options.
*
- * The coordinates and the values in screen unit are computed with
+ * The bounding box coordinates are computed with
* #o_circle_recalc().
*/
/* modify */
@@ -211,8 +211,8 @@
* If <B>whichone</B> is equal to <B>CIRCLE_RADIUS</B>, the radius is given by
* <B>x</B> - in world units. <B>y</B> is ignored.
*
- * The screen coords and the bounding box of the circle object are updated
- * after the modification of its parameters.
+ * The bounding box of the circle object is updated after the modification of its
+ * parameters.
*
* \param [in] w_current The TOPLEVEL object.
* \param [in,out] object Circle OBJECT to modify.
@@ -248,7 +248,7 @@
break;
}
- /* recalculate the screen coords and the boundings */
+ /* recalculate the boundings */
o_circle_recalc(w_current, object);
}
@@ -549,74 +549,22 @@
*/
void o_circle_recalc(TOPLEVEL *w_current, OBJECT *o_current)
{
- int screen_x1, screen_y1;
int left, right, top, bottom;
if (o_current->circle == NULL) {
return;
}
-#if DEBUG
- printf("drawing circle\n");
-#endif
-
-
- /* update the screen coords of the center of the circle */
- WORLDtoSCREEN(w_current,
- o_current->circle->center_x, o_current->circle->center_y,
- &screen_x1, &screen_y1);
- o_current->circle->screen_x = screen_x1;
- o_current->circle->screen_y = screen_y1;
-
- /* update the value of the radius in screen unit */
- o_current->circle->screen_radius = SCREENabs(w_current,
- o_current->circle->radius);
-
- /* update the bounding box - screen unit */
- get_circle_bounds(w_current, o_current->circle,
+ /* update the bounding box - world unit */
+ world_get_circle_bounds(w_current, o_current,
&left, &top, &right, &bottom);
- o_current->left = left;
- o_current->top = top;
- o_current->right = right;
- o_current->bottom = bottom;
+ o_current->w_left = left;
+ o_current->w_top = top;
+ o_current->w_right = right;
+ o_current->w_bottom = bottom;
}
-/*! \brief Get circle bounding rectangle.
- * \par Function Description
- * This function sets the <B>left</B>, <B>top</B>, <B>right</B>
- * and <B>bottom</B> pointed variables to the boundings of the circle object
- * described in <B>*circle</B> in screen unit.
- *
- * The function finds the smallest rectangle that cover this circle.
- *
- * \param [in] w_current The TOPLEVEL object.
- * \param [in] circle Circle OBJECT to read coordinates from.
- * \param [out] left Left circle coordinate in SCREEN units.
- * \param [out] top Top circle coordinate in SCREEN units.
- * \param [out] right Right circle coordinate in SCREEN units.
- * \param [out] bottom Bottom circle coordinate in SCREEN units.
- */
-void get_circle_bounds(TOPLEVEL *w_current, CIRCLE *circle,
- int *left, int *top,
- int *right, int *bottom)
-{
- *left = circle->screen_x - circle->screen_radius;
- *top = circle->screen_y - circle->screen_radius;
- *right = circle->screen_x + circle->screen_radius;
- *bottom = circle->screen_y + circle->screen_radius;
-
- /* PB : need to take into account the width of the line */
-
- /* out temp
- *left = *left - 4;
- *top = *top - 4;
-
- *right = *right + 4;
- *bottom = *bottom + 4;
- */
-}
-
/*! \brief Get circle bounding rectangle in WORLD coordinates.
* \par Function Description
* This function sets the <B>left</B>, <B>top</B>, <B>right</B> and <B>bottom</B>
@@ -624,43 +572,29 @@
* in world units.
*
* \param [in] w_current The TOPLEVEL object.
- * \param [in] circle Circle OBJECT to read coordinates from.
+ * \param [in] object Circle OBJECT to read coordinates from.
* \param [out] left Left circle coordinate in WORLD units.
* \param [out] top Top circle coordinate in WORLD units.
* \param [out] right Right circle coordinate in WORLD units.
* \param [out] bottom Bottom circle coordinate in WORLD units.
*/
-void world_get_circle_bounds(TOPLEVEL *w_current, CIRCLE *circle, int *left,
+void world_get_circle_bounds(TOPLEVEL *w_current, OBJECT *object, int *left,
int *top, int *right, int *bottom)
{
+ int halfwidth;
- *left = w_current->init_right;
- *top = w_current->init_bottom;
- *right = 0;
- *bottom = 0;
-
+ halfwidth = object->line_width / 2;
- *left = circle->center_x - circle->radius;
- *top = circle->center_y - circle->radius;
- *right = circle->center_x + circle->radius;
- *bottom = circle->center_y + circle->radius;
-
- /*
- *left = points->x1;
- *top = points->y1;
- *right = points->x1+(temp);
- *bottom = points->y1-(temp);
- */
-
- /*
- *left = min(circle->x1, circle->x1+temp);
- *top = min(circle->y1, circle->y1-temp);
- *right = max(circle->x1, circle->x1+temp);
- *bottom = max(circle->y1, circle->y1-temp);*/
-
-#if DEBUG
- printf("circle: %d %d %d %d\n", *left, *top, *right, *bottom);
-#endif
+ *left = object->circle->center_x - object->circle->radius;
+ *top = object->circle->center_y - object->circle->radius;
+ *right = object->circle->center_x + object->circle->radius;
+ *bottom = object->circle->center_y + object->circle->radius;
+
+ /* This isn't strictly correct, but a 1st order approximation */
+ *left -= halfwidth;
+ *top -= halfwidth;
+ *right += halfwidth;
+ *bottom += halfwidth;
}
@@ -1294,6 +1228,8 @@
void o_circle_image_write(TOPLEVEL *w_current, OBJECT *o_current,
int origin_x, int origin_y, int color_mode)
{
+ int diameter;
+ int s_x, s_y;
int color;
if (o_current == NULL) {
@@ -1309,14 +1245,19 @@
#ifdef HAS_LIBGD
+ diameter = SCREENabs(w_current, o_current->circle->radius)*2;
+ WORLDtoSCREEN(w_current,
+ o_current->circle->center_x,
+ o_current->circle->center_y,
+ &s_x, &s_y);
+
gdImageSetThickness(current_im_ptr, SCREENabs(w_current,
o_current->line_width));
gdImageArc(current_im_ptr,
- o_current->circle->screen_x,
- o_current->circle->screen_y,
- SCREENabs(w_current, o_current->circle->radius)*2,
- SCREENabs(w_current, o_current->circle->radius)*2,
+ s_x, s_y,
+ diameter,
+ diameter,
0, 360,
color);
#endif
1.32 +104 -217 eda/geda/gaf/libgeda/src/o_complex_basic.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: o_complex_basic.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_complex_basic.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- o_complex_basic.c 24 Feb 2007 18:43:16 -0000 1.31
+++ o_complex_basic.c 17 Apr 2007 20:19:21 -0000 1.32
@@ -51,66 +51,49 @@
* \param [out] rtop pointer to the top coordinate of the object.
* \param [out] rright pointer to the right coordinate of the object.
* \param [out] rbottom pointer to the bottom coordinate of the object.
- *
+ * \return If any bounds were found for the object
+ * \retval 0 No bound was found
+ * \retval 1 Bound was found
*/
-void get_single_object_bounds(TOPLEVEL *w_current, OBJECT *o_current,
+int world_get_single_object_bounds(TOPLEVEL *w_current, OBJECT *o_current,
int *rleft, int *rtop, int *rright, int *rbottom)
{
if (o_current != NULL) {
switch(o_current->type) {
case(OBJ_LINE):
- get_line_bounds(w_current, o_current->line, rleft, rtop, rright, rbottom);
- break;
-
case(OBJ_NET):
- /* same as a line (diff name)*/
- get_net_bounds(w_current, o_current->line, rleft, rtop, rright, rbottom);
- break;
-
case(OBJ_BUS):
- /* same as a line (diff name)*/
- get_bus_bounds(w_current, o_current->line, rleft, rtop, rright, rbottom);
- break;
-
case(OBJ_BOX):
- get_box_bounds(w_current, o_current->box, rleft, rtop, rright, rbottom);
- break;
-
case(OBJ_PICTURE):
- get_picture_bounds(w_current, o_current->picture, rleft, rtop, rright, rbottom);
- break;
-
case(OBJ_CIRCLE):
- get_circle_bounds(w_current, o_current->circle, rleft, rtop, rright, rbottom);
- break;
-
+ case(OBJ_PIN):
+ case(OBJ_ARC):
case(OBJ_COMPLEX):
case(OBJ_PLACEHOLDER):
- /* recursive objects ?*/
- get_object_list_bounds(w_current, o_current->complex->prim_objs, rleft, rtop, rright, rbottom);
- break;
+ *rleft = o_current->w_left;
+ *rtop = o_current->w_top;
+ *rright = o_current->w_right;
+ *rbottom = o_current->w_bottom;
+ return 1;
case(OBJ_TEXT):
/* only do bounding boxes for visible or doing show_hidden_text*/
/* you might lose some attrs though */
- if (o_current->visibility == VISIBLE ||
- (o_current->visibility == INVISIBLE && w_current->show_hidden_text)) {
- get_text_bounds(w_current, o_current, rleft, rtop, rright, rbottom);
+ if ( o_current->visibility == VISIBLE ||
+ w_current->show_hidden_text ) {
+ *rleft = o_current->w_left;
+ *rtop = o_current->w_top;
+ *rright = o_current->w_right;
+ *rbottom = o_current->w_bottom;
+ return 1;
}
break;
- case(OBJ_PIN):
- get_pin_bounds(w_current, o_current->line, rleft, rtop, rright, rbottom);
- break;
-
- case(OBJ_ARC):
- get_arc_bounds(w_current, o_current, rleft, rtop, rright, rbottom);
- break;
-
default:
break;
}
}
+ return 0;
}
/*! \brief Return the bounds of the given list of objects.
@@ -121,34 +104,39 @@
* \param [out] top pointer to the top coordinate of the object.
* \param [out] right pointer to the right coordinate of the object.
* \param [out] bottom pointer to the bottom coordinate of the object.
+ * \return If any bounds were found for the list of objects
+ * \retval 0 No bounds were found
+ * \retval 1 Bound was found
*/
-void
-get_object_list_bounds(TOPLEVEL *w_current, OBJECT *complex,
+int
+world_get_object_list_bounds(TOPLEVEL *w_current, OBJECT *complex,
int *left, int *top, int *right, int *bottom)
{
OBJECT *o_current=NULL;
int rleft, rtop, rright, rbottom;
-
- *left = rleft = 999999;
- *top = rtop = 9999999;
- *right = rright = 0;
- *bottom = rbottom = 0;
-
+ int found = 0;
o_current = complex;
+ // Find the first object with bounds, and set the bounds variables, then expand as necessary
while ( o_current != NULL ) {
- get_single_object_bounds(w_current, o_current, &rleft, &rtop,
- &rright, &rbottom);
- if (rleft < *left) *left = rleft;
- if (rtop < *top) *top = rtop;
- if (rright > *right) *right = rright;
- if (rbottom > *bottom) *bottom = rbottom;
-
-
- o_current=o_current->next;
+ if ( world_get_single_object_bounds( w_current, o_current, &rleft, &rtop, &rright, &rbottom) ) {
+ if ( found ) {
+ *left = min( *left, rleft );
+ *top = min( *top, rtop );
+ *right = max( *right, rright );
+ *bottom = max( *bottom, rbottom );
+ } else {
+ *left = rleft;
+ *top = rtop;
+ *right = rright;
+ *bottom = rbottom;
+ found = 1;
}
-
+ }
+ o_current = o_current->next;
+ }
+ return found;
}
/*! \brief Return the bounds of the given GList of objects.
@@ -159,158 +147,69 @@
* \param [out] top pointer to the top coordinate of the object.
* \param [out] right pointer to the right coordinate of the object.
* \param [out] bottom pointer to the bottom coordinate of the object.
+ * \return If any bounds were found for the list of objects
+ * \retval 0 No bounds were found
+ * \retval 1 Bound was found
*/
-void get_object_glist_bounds(TOPLEVEL *w_current, GList *head,
+int world_get_object_glist_bounds(TOPLEVEL *w_current, GList *head,
int *left, int *top, int *right, int *bottom)
{
GList *s_current=NULL;
OBJECT *o_current=NULL;
int rleft, rtop, rright, rbottom;
-
- *left = rleft = 999999;
- *top = rtop = 9999999;
- *right = rright = 0;
- *bottom = rbottom = 0;
+ int found = 0;
s_current = head;
+ // Find the first object with bounds, and set the bounds variables, then expand as necessary
while ( s_current != NULL ) {
-
o_current = (OBJECT *) s_current->data;
-
g_assert (o_current != NULL);
-
- get_single_object_bounds(w_current, o_current, &rleft, &rtop,
- &rright, &rbottom);
-
- if (rleft < *left) *left = rleft;
- if (rtop < *top) *top = rtop;
- if (rright > *right) *right = rright;
- if (rbottom > *bottom) *bottom = rbottom;
-
-
- s_current=s_current->next;
- }
-
-}
-
-/*! \brief Return the bounds of the given object.
- * \par Given an object, calcule the bounds coordinates.
- * \param [in] w_current The toplevel structure.
- * \param [in] o_current The object to look the bounds for.
- * \param [out] left pointer to the left coordinate of the object.
- * \param [out] top pointer to the top coordinate of the object.
- * \param [out] right pointer to the right coordinate of the object.
- * \param [out] bottom pointer to the bottom coordinate of the object.
- *
- */
-void world_get_single_object_bounds(TOPLEVEL *w_current, OBJECT *o_current,
- int *left, int *top,
- int *right, int *bottom)
-{
- if (o_current != NULL ) {
- switch(o_current->type) {
- case(OBJ_LINE):
- world_get_line_bounds(w_current, o_current->line,
- left, top, right, bottom);
- break;
-
- case(OBJ_NET):
- /* same as a line (diff name)*/
- world_get_net_bounds(w_current, o_current->line,
- left, top, right, bottom);
- break;
-
- case(OBJ_BUS):
- /* same as a line (diff name)*/
- world_get_bus_bounds(w_current, o_current->line,
- left, top, right, bottom);
- break;
-
-
- case(OBJ_BOX):
- world_get_box_bounds(w_current, o_current->box,
- left, top, right, bottom);
- break;
-
- case(OBJ_PICTURE):
- world_get_picture_bounds(w_current, o_current->picture,
- left, top, right, bottom);
- break;
-
- case(OBJ_CIRCLE):
- world_get_circle_bounds(w_current, o_current->circle,
- left, top, right, bottom);
- break;
-
- case(OBJ_COMPLEX):
- case(OBJ_PLACEHOLDER):
- /* recursive objects ?*/
- world_get_complex_bounds(w_current, o_current->complex->prim_objs,
- left, top, right, bottom);
- break;
-
- case(OBJ_TEXT):
- /* only do bounding boxes for visible or doing show hidden text */
- /* you might lose some attrs though */
- if (o_current->visibility == VISIBLE ||
- (o_current->visibility == INVISIBLE &&
- w_current->show_hidden_text)) {
- world_get_text_bounds(w_current, o_current,
- left, top, right, bottom);
- }
- break;
-
- case(OBJ_PIN):
- world_get_pin_bounds(w_current, o_current->line,
- left, top, right, bottom);
- break;
-
- case(OBJ_ARC):
- world_get_arc_bounds(w_current, o_current,
- left, top, right, bottom);
- break;
-
- default:
- break;
- }
- }
-}
-
-
-/*! \brief Return the bounds of the given complex (or list of OBJECTs).
- * \par Given a complex (list of objects), calcule the bounds coordinates.
- * \param [in] w_current The toplevel structure.
- * \param [in] complex The list of objects to look the bounds for.
- * \param [out] left pointer to the left coordinate of the object.
- * \param [out] top pointer to the top coordinate of the object.
- * \param [out] right pointer to the right coordinate of the object.
- * \param [out] bottom pointer to the bottom coordinate of the object.
+ if ( world_get_single_object_bounds( w_current, o_current, &rleft, &rtop, &rright, &rbottom) ) {
+ if ( found ) {
+ *left = min( *left, rleft );
+ *top = min( *top, rtop );
+ *right = max( *right, rright );
+ *bottom = max( *bottom, rbottom );
+ } else {
+ *left = rleft;
+ *top = rtop;
+ *right = rright;
+ *bottom = rbottom;
+ found = 1;
+ }
+ }
+ s_current = s_current->next;
+ }
+ return found;
+}
+
+/*! \brief Queries the bounds of a complex object.
+ * \par Function Description
+ * This function returns the bounding box of the complex object
+ * <B>object</B>.
+ *
+ * \param [in] w_current The toplevel environment.
+ * \param [in] complex The complex object.
+ * \param [out] left The leftmost edge of the bounding box (in
+ * world units).
+ * \param [out] top The upper edge of the bounding box (in
+ * world units).
+ * \param [out] right The rightmost edge of the bounding box (in
+ * world units).
+ * \param [out] bottom The bottom edge of the bounding box (in
+ * screen units).
*/
void world_get_complex_bounds(TOPLEVEL *w_current, OBJECT *complex,
int *left, int *top, int *right, int *bottom)
{
- OBJECT *o_current=NULL;
- int rleft, rtop, rright, rbottom;
-
- *left = rleft = w_current->init_right;
- *top = rtop = w_current->init_bottom;;
- *right = rright = 0;
- *bottom = rbottom = 0;
-
- o_current = complex;
-
- while ( o_current != NULL ) {
- world_get_single_object_bounds (w_current, o_current,
- &rleft, &rtop, &rright, &rbottom);
+ g_return_if_fail (complex != NULL &&
+ (complex->type == OBJ_COMPLEX ||
+ complex->type == OBJ_PLACEHOLDER) &&
+ complex->complex != NULL);
- if (rleft < *left) *left = rleft;
- if (rtop < *top) *top = rtop;
- if (rright > *right) *right = rright;
- if (rbottom > *bottom) *bottom = rbottom;
-
- o_current=o_current->next;
- }
+ world_get_object_list_bounds (w_current, complex->complex->prim_objs->next,
+ left, top, right, bottom);
}
@@ -464,9 +363,6 @@
new_node->complex->x = x;
new_node->complex->y = y;
- WORLDtoSCREEN(w_current, x, y,
- &new_node->complex->screen_x,
- &new_node->complex->screen_y);
new_node->draw_func = complex_draw_func;
@@ -717,6 +613,11 @@
}
}
+ if (use_object_list)
+ o_complex_recalc(w_current, object_list);
+ else
+ o_complex_recalc(w_current, new_node);
+
g_free(filename);
return(object_list);
}
@@ -738,9 +639,6 @@
new_node->complex = (COMPLEX *) g_malloc(sizeof(COMPLEX));
new_node->complex->x = x;
new_node->complex->y = y;
- WORLDtoSCREEN(w_current, x, y,
- &new_node->complex->screen_x,
- &new_node->complex->screen_y);
new_node->complex->angle = angle;
new_node->complex->mirror = 0;
@@ -791,17 +689,11 @@
if ((!o_current) || (o_current->type != OBJ_COMPLEX && o_current->type != OBJ_PLACEHOLDER))
return;
- get_object_list_bounds(w_current, o_current->complex->prim_objs, &left, &top, &right, &bottom);
- o_current->left = left;
- o_current->top = top;
- o_current->right = right;
- o_current->bottom = bottom;
-
- WORLDtoSCREEN(w_current,
- o_current->complex->x,
- o_current->complex->y,
- &o_current->complex->screen_x,
- &o_current->complex->screen_y);
+ world_get_complex_bounds(w_current, o_current, &left, &top, &right, &bottom);
+ o_current->w_left = left;
+ o_current->w_top = top;
+ o_current->w_right = right;
+ o_current->w_bottom = bottom;
}
@@ -1066,21 +958,16 @@
object->complex->x = object->complex->x + x1;
object->complex->y = object->complex->y + y1;
- WORLDtoSCREEN(w_current, object->complex->x,
- object->complex->y,
- &object->complex->screen_x,
- &object->complex->screen_y);
-
o_complex_world_translate(w_current, x1, y1,
object->complex->prim_objs);
- get_object_list_bounds(w_current, object->complex->prim_objs,
+ world_get_object_list_bounds(w_current, object->complex->prim_objs,
&left, &top, &right, &bottom);
- object->left = left;
- object->top = top;
- object->right = right;
- object->bottom = bottom;
+ object->w_left = left;
+ object->w_top = top;
+ object->w_right = right;
+ object->w_bottom = bottom;
}
/*! \brief
1.28 +51 -123 eda/geda/gaf/libgeda/src/o_line_basic.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: o_line_basic.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_line_basic.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- o_line_basic.c 24 Feb 2007 18:43:16 -0000 1.27
+++ o_line_basic.c 17 Apr 2007 20:19:21 -0000 1.28
@@ -103,7 +103,7 @@
new_node->draw_func = line_draw_func;
new_node->sel_func = select_func;
- /* compute bounding box and screen coords */
+ /* compute bounding box */
o_line_recalc(w_current, new_node);
object_list = (OBJECT *) s_basic_link_object(new_node, object_list);
@@ -149,7 +149,7 @@
* of the original line. The two lines have the sale line type and
* filling options.
*
- * The coordinates and the values in screen unit are computed with
+ * The bounding box are computed with
* #o_line_recalc().
*/
@@ -168,7 +168,7 @@
o_current->fill_pitch1, o_current->fill_angle1,
o_current->fill_pitch2, o_current->fill_angle2);
- /* calc the screen coords */
+ /* calc the bounding box */
o_line_recalc(w_current, o_current);
/* new_obj->attribute = 0;*/
@@ -231,7 +231,7 @@
return;
}
- /* recalculate the screen coords and the boundings */
+ /* recalculate the bounding box */
o_line_recalc(w_current, object);
}
@@ -405,40 +405,23 @@
void o_line_translate_world(TOPLEVEL *w_current,
int x1, int y1, OBJECT *object)
{
- int screen_x1, screen_y1;
- int screen_x2, screen_y2;
int left, right, top, bottom;
if (object == NULL) printf("ltw NO!\n");
- /* Do world coords */
+ /* Update world coords */
object->line->x[0] = object->line->x[0] + x1;
object->line->y[0] = object->line->y[0] + y1;
object->line->x[1] = object->line->x[1] + x1;
object->line->y[1] = object->line->y[1] + y1;
- /* update screen coords */
- WORLDtoSCREEN(w_current, object->line->x[0],
- object->line->y[0],
- &screen_x1,
- &screen_y1);
- object->line->screen_x[0] = screen_x1;
- object->line->screen_y[0] = screen_y1;
-
- WORLDtoSCREEN(w_current, object->line->x[1],
- object->line->y[1],
- &screen_x2,
- &screen_y2);
- object->line->screen_x[1] = screen_x2;
- object->line->screen_y[1] = screen_y2;
-
- /* update bounding box */
- get_line_bounds(w_current, object->line, &left, &top, &right, &bottom);
-
- object->left = left;
- object->top = top;
- object->right = right;
- object->bottom = bottom;
+ /* Update bounding box */
+ world_get_line_bounds(w_current, object, &left, &top, &right, &bottom);
+
+ object->w_left = left;
+ object->w_top = top;
+ object->w_right = right;
+ object->w_bottom = bottom;
}
@@ -527,88 +510,29 @@
/*! \brief Recalculate line coordinates in SCREEN units.
* \par Function Description
- * This function recalculate the screen coords of the <B>o_current</B>
- * pointed line object from its world coords.
- *
- * The line ends coordinates and its bounding box are recalculated
+ * This function recalculate the bounding box of the <B>o_current</B>
*
* \param [in] w_current The TOPLEVEL object.
* \param [in,out] o_current Line OBJECT to be recalculated.
*/
void o_line_recalc(TOPLEVEL *w_current, OBJECT *o_current)
{
- int screen_x1, screen_y1;
- int screen_x2, screen_y2;
int left, right, top, bottom;
if (o_current->line == NULL) {
return;
}
- /* update the screen coords of end 1 of the line */
- WORLDtoSCREEN(w_current,
- o_current->line->x[0], o_current->line->y[0],
- &screen_x1, &screen_y1);
- o_current->line->screen_x[0] = screen_x1;
- o_current->line->screen_y[0] = screen_y1;
-
- /* update the screen coords of end 2 of the line */
- WORLDtoSCREEN(w_current,
- o_current->line->x[1], o_current->line->y[1],
- &screen_x2, &screen_y2);
- o_current->line->screen_x[1] = screen_x2;
- o_current->line->screen_y[1] = screen_y2;
-
/* update the bounding box - screen unit */
- get_line_bounds(w_current, o_current->line,
+ world_get_line_bounds(w_current, o_current,
&left, &top, &right, &bottom);
- o_current->left = left;
- o_current->top = top;
- o_current->right = right;
- o_current->bottom = bottom;
+ o_current->w_left = left;
+ o_current->w_top = top;
+ o_current->w_right = right;
+ o_current->w_bottom = bottom;
}
-/*! \brief Get line bounding rectangle.
- * \par Function Description
- * This function sets the <B>left</B>, <B>top</B>, <B>right</B> and
- * <B>bottom</B> parameters to the boundings of the line object described
- * by <B>*line</B> in screen units.
- *
- * \param [in] w_current The TOPLEVEL object.
- * \param [in] line line OBJECT to read coordinates from.
- * \param [out] left Left line coordinate in SCREEN units.
- * \param [out] top Top line coordinate in SCREEN units.
- * \param [out] right Right line coordinate in SCREEN units.
- * \param [out] bottom Bottom line coordinate in SCREEN units.
- */
-void get_line_bounds(TOPLEVEL *w_current, LINE *line, int *left, int *top,
- int *right, int *bottom)
-{
- *left = w_current->width;
- *top = w_current->height;
- *right = 0;
- *bottom = 0;
-
- if (line->screen_x[0] < *left) *left = line->screen_x[0];
- if (line->screen_x[0] > *right) *right = line->screen_x[0];
- if (line->screen_y[0] < *top) *top = line->screen_y[0];
- if (line->screen_y[0] > *bottom) *bottom = line->screen_y[0];
-
- if (line->screen_x[1] < *left) *left = line->screen_x[1];
- if (line->screen_x[1] > *right) *right = line->screen_x[1];
- if (line->screen_y[1] < *top) *top = line->screen_y[1];
- if (line->screen_y[1] > *bottom) *bottom = line->screen_y[1];
-
- /* PB : bounding box has to take into account the width of the line */
- /* PB : but line width is unknown here */
-
- *left = *left - 4;
- *top = *top - 4;
- *right = *right + 4;
- *bottom = *bottom + 4;
-}
-
/*! \brief Get line bounding rectangle in WORLD coordinates.
* \par Function Description
* This function sets the <B>left</B>, <B>top</B>, <B>right</B> and
@@ -616,30 +540,29 @@
* in <B>*line</B> in world units.
*
* \param [in] w_current The TOPLEVEL object.
- * \param [in] line Line OBJECT to read coordinates from.
+ * \param [in] OBJECT Line OBJECT to read coordinates from.
* \param [out] left Left line coordinate in WORLD units.
* \param [out] top Top line coordinate in WORLD units.
* \param [out] right Right line coordinate in WORLD units.
* \param [out] bottom Bottom line coordinate in WORLD units.
*/
-void world_get_line_bounds(TOPLEVEL *w_current, LINE *line,
+void world_get_line_bounds(TOPLEVEL *w_current, OBJECT *object,
int *left, int *top, int *right, int *bottom)
{
- *left = w_current->init_right;
- *top = w_current->init_bottom;
- *right = 0;
- *bottom = 0;
-
- if (line->x[0] < *left) *left = line->x[0];
- if (line->x[0] > *right) *right = line->x[0];
- if (line->y[0] < *top) *top = line->y[0];
- if (line->y[0] > *bottom) *bottom = line->y[0];
-
- if (line->x[1] < *left) *left = line->x[1];
- if (line->x[1] > *right) *right = line->x[1];
- if (line->y[1] < *top) *top = line->y[1];
- if (line->y[1] > *bottom) *bottom = line->y[1];
+ int halfwidth;
+ halfwidth = object->line_width / 2;
+
+ *left = min( object->line->x[0], object->line->x[1] );
+ *top = min( object->line->y[0], object->line->y[1] );
+ *right = max( object->line->x[0], object->line->x[1] );
+ *bottom = max( object->line->y[0], object->line->y[1] );
+
+ /* This isn't strictly correct, but a 1st order approximation */
+ *left -= halfwidth;
+ *top -= halfwidth;
+ *right += halfwidth;
+ *bottom += halfwidth;
}
/*! \brief Print line to Postscript document.
@@ -1313,6 +1236,7 @@
void o_line_image_write(TOPLEVEL *w_current, OBJECT *o_current,
int origin_x, int origin_y, int color_mode)
{
+ int x[2], y[2];
int color;
if (o_current == NULL) {
@@ -1326,17 +1250,23 @@
color = image_black;
}
- /* assumes screen coords are already calculated correctly */
#ifdef HAS_LIBGD
+ WORLDtoSCREEN(w_current,
+ o_current->line->x[0],
+ o_current->line->y[0],
+ &x[0], &y[0]);
+ WORLDtoSCREEN(w_current,
+ o_current->line->x[1],
+ o_current->line->y[1],
+ &x[1], &y[1]);
+
gdImageSetThickness(current_im_ptr, SCREENabs(w_current,
o_current->line_width));
gdImageLine(current_im_ptr,
- o_current->line->screen_x[0],
- o_current->line->screen_y[0],
- o_current->line->screen_x[1],
- o_current->line->screen_y[1],
+ x[0], y[0],
+ x[1], y[1],
color);
#endif
}
@@ -1360,7 +1290,7 @@
object->line->x[1] = object->line->x[1] * x_scale;
object->line->y[1] = object->line->y[1] * y_scale;
- /* update screen coords */
+ /* update boundingbox */
o_line_recalc(w_current, object);
}
@@ -1387,10 +1317,8 @@
return(TRUE);
}
- *x1 = line->screen_x[0];
- *y1 = line->screen_y[0];
- *x2 = line->screen_x[1];
- *y2 = line->screen_y[1];
+ WORLDtoSCREEN( w_current, line->x[0], line->y[0], x1, y1 );
+ WORLDtoSCREEN( w_current, line->x[1], line->y[1], x2, y2 );
visible = SCREENclip_change(w_current, x1, y1, x2, y2);
1.36 +37 -184 eda/geda/gaf/libgeda/src/o_net_basic.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: o_net_basic.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_net_basic.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- o_net_basic.c 24 Feb 2007 18:43:16 -0000 1.35
+++ o_net_basic.c 17 Apr 2007 20:19:21 -0000 1.36
@@ -52,77 +52,10 @@
* \param [out] right
* \param [out] bottom
*/
-void get_net_bounds(TOPLEVEL *w_current, LINE *line, int *left, int *top,
- int *right, int *bottom)
-{
- *left = w_current->width;
- *top = w_current->height;
- *right = 0;
- *bottom = 0;
-
- if (line->screen_x[0] < *left)
- *left = line->screen_x[0];
- if (line->screen_x[0] > *right)
- *right = line->screen_x[0];
- if (line->screen_y[0] < *top)
- *top = line->screen_y[0];
- if (line->screen_y[0] > *bottom)
- *bottom = line->screen_y[0];
-
- if (line->screen_x[1] < *left)
- *left = line->screen_x[1];
- if (line->screen_x[1] > *right)
- *right = line->screen_x[1];
- if (line->screen_y[1] < *top)
- *top = line->screen_y[1];
- if (line->screen_y[1] > *bottom)
- *bottom = line->screen_y[1];
-
- *left = *left - 4;
- *top = *top - 4;
-
- *right = *right + 4;
- *bottom = *bottom + 4;
-}
-
-
-/*! \todo Finish function documentation!!!
- * \brief
- * \par Function Description
- *
- * \param [in] w_current The TOPLEVEL object.
- * \param [in] line
- * \param [out] left
- * \param [out] top
- * \param [out] right
- * \param [out] bottom
- */
-void world_get_net_bounds(TOPLEVEL *w_current, LINE *line, int *left,
+void world_get_net_bounds(TOPLEVEL *w_current, OBJECT *object, int *left,
int *top, int *right, int *bottom)
{
- *left = w_current->init_right;
- *top = w_current->init_bottom;
- *right = 0;
- *bottom = 0;
-
- if (line->x[0] < *left)
- *left = line->x[0];
- if (line->x[0] > *right)
- *right = line->x[0];
- if (line->y[0] < *top)
- *top = line->y[0];
- if (line->y[0] > *bottom)
- *bottom = line->y[0];
-
- if (line->x[1] < *left)
- *left = line->x[1];
- if (line->x[1] > *right)
- *right = line->x[1];
- if (line->y[1] < *top)
- *top = line->y[1];
- if (line->y[1] > *bottom)
- *bottom = line->y[1];
-
+ world_get_line_bounds( w_current, object, left, top, right, bottom );
}
/*! \todo Finish function documentation!!!
@@ -142,7 +75,6 @@
OBJECT *o_net_add(TOPLEVEL *w_current, OBJECT *object_list, char type,
int color, int x1, int y1, int x2, int y2)
{
- int screen_x, screen_y;
int left, right, top, bottom;
OBJECT *new_node;
@@ -157,28 +89,15 @@
new_node->line->y[0] = y1;
new_node->line->x[1] = x2;
new_node->line->y[1] = y2;
+ new_node->line_width = NET_WIDTH;
- WORLDtoSCREEN(w_current,
- new_node->line->x[0], new_node->line->y[0],
- &screen_x, &screen_y);
-
- new_node->line->screen_x[0] = screen_x;
- new_node->line->screen_y[0] = screen_y;
-
- WORLDtoSCREEN(w_current,
- new_node->line->x[1], new_node->line->y[1],
- &screen_x, &screen_y);
-
- new_node->line->screen_x[1] = screen_x;
- new_node->line->screen_y[1] = screen_y;
-
- get_net_bounds(w_current, new_node->line, &left, &top, &right,
+ world_get_net_bounds(w_current, new_node, &left, &top, &right,
&bottom);
- new_node->left = left;
- new_node->top = top;
- new_node->right = right;
- new_node->bottom = bottom;
+ new_node->w_left = left;
+ new_node->w_top = top;
+ new_node->w_right = right;
+ new_node->w_bottom = bottom;
new_node->draw_func = net_draw_func;
new_node->sel_func = select_func;
@@ -204,8 +123,6 @@
*/
void o_net_recalc(TOPLEVEL *w_current, OBJECT *o_current)
{
- int screen_x1, screen_y1;
- int screen_x2, screen_y2;
int left, right, top, bottom;
if (o_current == NULL) {
@@ -216,25 +133,13 @@
return;
}
- WORLDtoSCREEN(w_current, o_current->line->x[0],
- o_current->line->y[0], &screen_x1, &screen_y1);
-
- o_current->line->screen_x[0] = screen_x1;
- o_current->line->screen_y[0] = screen_y1;
-
- WORLDtoSCREEN(w_current, o_current->line->x[1],
- o_current->line->y[1], &screen_x2, &screen_y2);
-
- o_current->line->screen_x[1] = screen_x2;
- o_current->line->screen_y[1] = screen_y2;
-
- get_net_bounds(w_current, o_current->line, &left, &top, &right,
+ world_get_net_bounds(w_current, o_current, &left, &top, &right,
&bottom);
- o_current->left = left;
- o_current->top = top;
- o_current->right = right;
- o_current->bottom = bottom;
+ o_current->w_left = left;
+ o_current->w_top = top;
+ o_current->w_right = right;
+ o_current->w_bottom = bottom;
}
@@ -323,40 +228,25 @@
void o_net_translate_world(TOPLEVEL *w_current, int x1, int y1,
OBJECT *object)
{
- int screen_x1, screen_y1;
- int screen_x2, screen_y2;
int left, right, top, bottom;
if (object == NULL)
printf("ntw NO!\n");
- /* Do world coords */
+ /* Update world coords */
object->line->x[0] = object->line->x[0] + x1;
object->line->y[0] = object->line->y[0] + y1;
object->line->x[1] = object->line->x[1] + x1;
object->line->y[1] = object->line->y[1] + y1;
- /* update screen coords */
- WORLDtoSCREEN(w_current, object->line->x[0],
- object->line->y[0], &screen_x1, &screen_y1);
-
- object->line->screen_x[0] = screen_x1;
- object->line->screen_y[0] = screen_y1;
-
- WORLDtoSCREEN(w_current, object->line->x[1],
- object->line->y[1], &screen_x2, &screen_y2);
-
- object->line->screen_x[1] = screen_x2;
- object->line->screen_y[1] = screen_y2;
-
- /* update bounding box */
- get_net_bounds(w_current, object->line, &left, &top, &right, &bottom);
-
- object->left = left;
- object->top = top;
- object->right = right;
- object->bottom = bottom;
+ /* Update bounding box */
+ world_get_net_bounds(w_current, object, &left, &top, &right, &bottom);
+
+ object->w_left = left;
+ object->w_top = top;
+ object->w_right = right;
+ object->w_bottom = bottom;
s_tile_update_object(w_current, object);
}
@@ -388,11 +278,6 @@
o_current->line->x[0], o_current->line->y[0],
o_current->line->x[1], o_current->line->y[1]);
- new_obj->line->screen_x[0] = o_current->line->screen_x[0];
- new_obj->line->screen_y[0] = o_current->line->screen_y[0];
- new_obj->line->screen_x[1] = o_current->line->screen_x[1];
- new_obj->line->screen_y[1] = o_current->line->screen_y[1];
-
new_obj->line->x[0] = o_current->line->x[0];
new_obj->line->y[0] = o_current->line->y[0];
new_obj->line->x[1] = o_current->line->x[1];
@@ -464,11 +349,7 @@
void o_net_image_write(TOPLEVEL *w_current, OBJECT *o_current,
int origin_x, int origin_y, int color_mode)
{
- int offset, offset2;
- int cross;
- int x1, y1;
- int x2, y2;
- int endpoint_color;
+ int x[2], y[2];
int color;
if (o_current == NULL) {
@@ -482,27 +363,15 @@
color = image_black;
}
- offset = SCREENabs(w_current, NET_WIDTH);
-
- /*
- offset = 7 * (float) w_current->height/ (float) w_current->width;
- offset2 = 7 * (float) w_current->height/ (float) w_current->width*2;
-
- printf("%f %d %d\n", (float) ( (float) w_current->height/ (float) w_current->width),
- offset, offset2);
- */
-
- offset2 = offset * 2;
-
- cross = offset;
-
- x1 = o_current->line->screen_x[0];
- y1 = o_current->line->screen_y[0];
- x2 = o_current->line->screen_x[1];
- y2 = o_current->line->screen_y[1];
-
- /* assumes screen coords are already calculated correctly */
#ifdef HAS_LIBGD
+ WORLDtoSCREEN(w_current,
+ o_current->line->x[0],
+ o_current->line->y[0],
+ &x[0], &y[0]);
+ WORLDtoSCREEN(w_current,
+ o_current->line->x[1],
+ o_current->line->y[1],
+ &x[1], &y[1]);
if (w_current->net_style == THICK) {
gdImageSetThickness(current_im_ptr, SCREENabs(w_current,
@@ -511,16 +380,8 @@
gdImageSetThickness(current_im_ptr, 0);
}
- gdImageLine(current_im_ptr, x1, y1, x2, y2, color);
+ gdImageLine(current_im_ptr, x[0], y[0], x[1], y[1], color);
#endif
-
- if (color_mode == TRUE) {
- endpoint_color =
- o_image_geda2gd_color(w_current->net_endpoint_color);
- } else {
- endpoint_color = image_black;
- }
-
}
/*! \todo Finish function documentation!!!
@@ -886,25 +747,17 @@
void o_net_modify(TOPLEVEL *w_current, OBJECT *object,
int x, int y, int whichone)
{
- int screen_x, screen_y;
int left, right, top, bottom;
object->line->x[whichone] = x;
object->line->y[whichone] = y;
- WORLDtoSCREEN(w_current,
- object->line->x[whichone],
- object->line->y[whichone], &screen_x, &screen_y);
-
- object->line->screen_x[whichone] = screen_x;
- object->line->screen_y[whichone] = screen_y;
-
- get_net_bounds(w_current, object->line, &left, &top, &right, &bottom);
+ world_get_net_bounds(w_current, object, &left, &top, &right, &bottom);
- object->left = left;
- object->top = top;
- object->right = right;
- object->bottom = bottom;
+ object->w_left = left;
+ object->w_top = top;
+ object->w_right = right;
+ object->w_bottom = bottom;
s_tile_update_object(w_current, object);
}
1.7 +16 -64 eda/geda/gaf/libgeda/src/o_picture.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: o_picture.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_picture.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- o_picture.c 24 Feb 2007 18:43:16 -0000 1.6
+++ o_picture.c 17 Apr 2007 20:19:21 -0000 1.7
@@ -454,12 +454,10 @@
return(object_list);
}
-/*! \brief Recalculate picture coordinates in SCREEN units.
+/*! \brief Recalculate picture bounding box.
* \par Function Description
- * This function recalculates the screen coords of the <B>o_current</B>
- * parameter picture object from its world coords.
- *
- * The picture coordinates and its bounding are recalculated
+ * This function recalculates the bounding box of the <B>o_current</B>
+ * parameter picture object.
*
* \param [in] w_current The TOPLEVEL object.
* \param [in,out] o_current Picture OBJECT to be recalculated.
@@ -467,57 +465,18 @@
void o_picture_recalc(TOPLEVEL *w_current, OBJECT *o_current)
{
int left, top, right, bottom;
- int screen_x1, screen_y1;
- int screen_x2, screen_y2;
if (o_current->picture == NULL) {
return;
}
- /* update the screen coords of the upper left corner of the picture */
- WORLDtoSCREEN(w_current,
- o_current->picture->upper_x, o_current->picture->upper_y,
- &screen_x1, &screen_y1);
- o_current->picture->screen_upper_x = screen_x1;
- o_current->picture->screen_upper_y = screen_y1;
-
- /* update the screen coords of the lower right corner of the picture */
- WORLDtoSCREEN(w_current,
- o_current->picture->lower_x, o_current->picture->lower_y,
- &screen_x2, &screen_y2);
- o_current->picture->screen_lower_x = screen_x2;
- o_current->picture->screen_lower_y = screen_y2;
-
- /* update the bounding picture - screen unit */
- get_picture_bounds(w_current, o_current->picture,
+ /* update the bounding picture - world units */
+ world_get_picture_bounds(w_current, o_current,
&left, &top, &right, &bottom);
- o_current->left = left;
- o_current->top = top;
- o_current->right = right;
- o_current->bottom = bottom;
-
-}
-
-/*! \brief Get picture bounding rectangle.
- * \par Function Description
- * This function sets the <B>left</B>, <B>top</B>, <B>right</B> and
- * <B>bottom</B> parameters to the boundings of the picture object described
- * in <B>*picture</B> in SCREEN units.
- *
- * \param [in] w_current The TOPLEVEL object.
- * \param [in] picture Picture OBJECT to read coordinates from.
- * \param [out] left Left picture coordinate in SCREEN units.
- * \param [out] top Top picture coordinate in SCREEN units.
- * \param [out] right Right pircture coordinate in SCREEN units.
- * \param [out] bottom Bottom picture coordinate in SCREEN units.
- */
-void get_picture_bounds(TOPLEVEL *w_current, PICTURE *picture,
- int *left, int *top, int *right, int *bottom)
-{
- *left = picture->screen_upper_x;
- *top = picture->screen_upper_y;
- *right = picture->screen_lower_x;
- *bottom = picture->screen_lower_y;
+ o_current->w_left = left;
+ o_current->w_top = top;
+ o_current->w_right = right;
+ o_current->w_bottom = bottom;
}
@@ -528,26 +487,19 @@
* described in <B>*picture</B> in WORLD units.
*
* \param [in] w_current The TOPLEVEL object.
- * \param [in] picture Picture OBJECT to read coordinates from.
+ * \param [in] object Picture OBJECT to read coordinates from.
* \param [out] left Left picture coordinate in WORLD units.
* \param [out] top Top picture coordinate in WORLD units.
* \param [out] right Right picture coordinate in WORLD units.
* \param [out] bottom Bottom picture coordinate in WORLD units.
*/
-void world_get_picture_bounds(TOPLEVEL *w_current, PICTURE *picture,
+void world_get_picture_bounds(TOPLEVEL *w_current, OBJECT *object,
int *left, int *top, int *right, int *bottom)
{
- /* pb20011002 - why using min and max here and not above ? */
- *left = min(picture->upper_x, picture->lower_x);
- *top = min(picture->upper_y, picture->lower_y);
- *right = max(picture->upper_x, picture->lower_x);
- *bottom = max(picture->upper_y, picture->lower_y);
-
- /* PB : same as above here for width of edges */
-
-#if DEBUG
- printf("picture: %d %d %d %d\n", *left, *top, *right, *bottom);
-#endif
+ *left = min(object->picture->upper_x, object->picture->lower_x);
+ *top = min(object->picture->upper_y, object->picture->lower_y);
+ *right = max(object->picture->upper_x, object->picture->lower_x);
+ *bottom = max(object->picture->upper_y, object->picture->lower_y);
}
1.26 +59 -160 eda/geda/gaf/libgeda/src/o_pin_basic.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: o_pin_basic.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_pin_basic.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- o_pin_basic.c 24 Feb 2007 18:43:16 -0000 1.25
+++ o_pin_basic.c 17 Apr 2007 20:19:21 -0000 1.26
@@ -46,53 +46,10 @@
* \par Function Description
*
*/
-void get_pin_bounds(TOPLEVEL *w_current, LINE *line, int *left, int *top,
+void world_get_pin_bounds(TOPLEVEL *w_current, OBJECT *object, int *left, int *top,
int *right, int *bottom)
{
- *left = w_current->width;
- *top = w_current->height;
- *right = 0;
- *bottom = 0;
-
- if (line->screen_x[0] < *left) *left = line->screen_x[0];
- if (line->screen_x[0] > *right) *right = line->screen_x[0];
- if (line->screen_y[0] < *top) *top = line->screen_y[0];
- if (line->screen_y[0] > *bottom) *bottom = line->screen_y[0];
-
- if (line->screen_x[1] < *left) *left = line->screen_x[1];
- if (line->screen_x[1] > *right) *right = line->screen_x[1];
- if (line->screen_y[1] < *top) *top = line->screen_y[1];
- if (line->screen_y[1] > *bottom) *bottom = line->screen_y[1];
-
- *left = *left - 4;
- *top = *top - 4;
-
- *right = *right + 4;
- *bottom = *bottom + 4;
-}
-
-/*! \todo Finish function documentation!!!
- * \brief
- * \par Function Description
- *
- */
-void world_get_pin_bounds(TOPLEVEL *w_current, LINE *line, int *left, int *top,
- int *right, int *bottom)
-{
- *left = w_current->init_right;
- *top = w_current->init_bottom;
- *right = 0;
- *bottom = 0;
-
- if (line->x[0] < *left) *left = line->x[0];
- if (line->x[0] > *right) *right = line->x[0];
- if (line->y[0] < *top) *top = line->y[0];
- if (line->y[0] > *bottom) *bottom = line->y[0];
-
- if (line->x[1] < *left) *left = line->x[1];
- if (line->x[1] > *right) *right = line->x[1];
- if (line->y[1] < *top) *top = line->y[1];
- if (line->y[1] > *bottom) *bottom = line->y[1];
+ world_get_line_bounds( w_current, object, left, top, right, bottom );
}
/*! \todo Finish function documentation!!!
@@ -104,7 +61,6 @@
char type, int color,
int x1, int y1, int x2, int y2, int pin_type, int whichend)
{
- int screen_x, screen_y;
int left, right, top, bottom;
OBJECT *new_node;
@@ -118,29 +74,14 @@
new_node->line->y[0] = y1;
new_node->line->x[1] = x2;
new_node->line->y[1] = y2;
+ new_node->line_width = PIN_WIDTH;
- WORLDtoSCREEN(w_current,
- new_node->line->x[0], new_node->line->y[0],
- &screen_x,
- &screen_y);
+ world_get_pin_bounds(w_current, new_node, &left, &top, &right, &bottom);
- new_node->line->screen_x[0] = screen_x;
- new_node->line->screen_y[0] = screen_y;
-
- WORLDtoSCREEN(w_current,
- new_node->line->x[1], new_node->line->y[1],
- &screen_x,
- &screen_y);
-
- new_node->line->screen_x[1] = screen_x;
- new_node->line->screen_y[1] = screen_y;
-
- get_pin_bounds(w_current, new_node->line, &left, &top, &right, &bottom);
-
- new_node->left = left;
- new_node->top = top;
- new_node->right = right;
- new_node->bottom = bottom;
+ new_node->w_left = left;
+ new_node->w_top = top;
+ new_node->w_right = right;
+ new_node->w_bottom = bottom;
new_node->draw_func = pin_draw_func;
new_node->sel_func = select_func;
@@ -182,37 +123,18 @@
*/
void o_pin_recalc(TOPLEVEL *w_current, OBJECT *o_current)
{
- int screen_x1, screen_y1;
- int screen_x2, screen_y2;
int left, right, top, bottom;
if (o_current->line == NULL) {
return;
}
+ world_get_pin_bounds(w_current, o_current, &left, &top, &right, &bottom);
- WORLDtoSCREEN(w_current, o_current->line->x[0],
- o_current->line->y[0],
- &screen_x1,
- &screen_y1);
-
- o_current->line->screen_x[0] = screen_x1;
- o_current->line->screen_y[0] = screen_y1;
-
- WORLDtoSCREEN(w_current, o_current->line->x[1],
- o_current->line->y[1],
- &screen_x2,
- &screen_y2);
-
- o_current->line->screen_x[1] = screen_x2;
- o_current->line->screen_y[1] = screen_y2;
-
- get_pin_bounds(w_current, o_current->line, &left, &top, &right, &bottom);
-
- o_current->left = left;
- o_current->top = top;
- o_current->right = right;
- o_current->bottom = bottom;
+ o_current->w_left = left;
+ o_current->w_top = top;
+ o_current->w_right = right;
+ o_current->w_bottom = bottom;
}
@@ -320,43 +242,24 @@
*/
void o_pin_translate_world(TOPLEVEL *w_current, int x1, int y1, OBJECT *object)
{
- int screen_x1, screen_y1;
- int screen_x2, screen_y2;
int left, right, top, bottom;
if (object == NULL) printf("ptw NO!\n");
- /* Do world coords */
+ /* Update world coords */
object->line->x[0] = object->line->x[0] + x1;
object->line->y[0] = object->line->y[0] + y1;
object->line->x[1] = object->line->x[1] + x1;
object->line->y[1] = object->line->y[1] + y1;
- /* update screen coords */
- WORLDtoSCREEN(w_current, object->line->x[0],
- object->line->y[0],
- &screen_x1,
- &screen_y1);
-
- object->line->screen_x[0] = screen_x1;
- object->line->screen_y[0] = screen_y1;
-
- WORLDtoSCREEN(w_current, object->line->x[1],
- object->line->y[1],
- &screen_x2,
- &screen_y2);
-
- object->line->screen_x[1] = screen_x2;
- object->line->screen_y[1] = screen_y2;
-
- /* update bounding box */
- get_pin_bounds(w_current, object->line, &left, &top, &right, &bottom);
-
- object->left = left;
- object->top = top;
- object->right = right;
- object->bottom = bottom;
+ /* Update bounding box */
+ world_get_pin_bounds(w_current, object, &left, &top, &right, &bottom);
+
+ object->w_left = left;
+ object->w_top = top;
+ object->w_right = right;
+ object->w_bottom = bottom;
s_tile_update_object(w_current, object);
}
@@ -383,14 +286,6 @@
o_current->line->x[1], o_current->line->y[1],
o_current->pin_type, o_current->whichend);
- /* why is this here ? */
- /* because they all have it, and it is used during outline actions */
- new_obj->line->screen_x[0] = o_current->line->screen_x[0];
- new_obj->line->screen_y[0] = o_current->line->screen_y[0];
- new_obj->line->screen_x[1] = o_current->line->screen_x[1];
- new_obj->line->screen_y[1] = o_current->line->screen_y[1];
-
-
new_obj->line->x[0] = o_current->line->x[0];
new_obj->line->y[0] = o_current->line->y[0];
new_obj->line->x[1] = o_current->line->x[1];
@@ -454,6 +349,7 @@
void o_pin_image_write(TOPLEVEL *w_current, OBJECT *o_current,
int origin_x, int origin_y, int color_mode)
{
+ int x[2], y[2];
int color;
if (o_current == NULL) {
@@ -467,8 +363,15 @@
color = image_black;
}
- /* assumes screen coords are already calculated correctly */
#ifdef HAS_LIBGD
+ WORLDtoSCREEN(w_current,
+ o_current->line->x[0],
+ o_current->line->y[0],
+ &x[0], &y[0]);
+ WORLDtoSCREEN(w_current,
+ o_current->line->x[1],
+ o_current->line->y[1],
+ &x[1], &y[1]);
if (w_current->pin_style == THICK) {
gdImageSetThickness(current_im_ptr, SCREENabs(w_current,
@@ -478,10 +381,8 @@
}
gdImageLine(current_im_ptr,
- o_current->line->screen_x[0],
- o_current->line->screen_y[0],
- o_current->line->screen_x[1],
- o_current->line->screen_y[1],
+ x[0], y[0],
+ x[1], y[1],
color);
#endif
}
@@ -544,26 +445,17 @@
void o_pin_modify(TOPLEVEL *w_current, OBJECT *object,
int x, int y, int whichone)
{
- int screen_x, screen_y;
int left, right, top, bottom;
object->line->x[whichone] = x;
object->line->y[whichone] = y;
- WORLDtoSCREEN(w_current,
- object->line->x[whichone],
- object->line->y[whichone],
- &screen_x, &screen_y);
-
- object->line->screen_x[whichone] = screen_x;
- object->line->screen_y[whichone] = screen_y;
-
- get_pin_bounds(w_current, object->line, &left, &top, &right, &bottom);
-
- object->left = left;
- object->top = top;
- object->right = right;
- object->bottom = bottom;
+ world_get_pin_bounds(w_current, object, &left, &top, &right, &bottom);
+
+ object->w_left = left;
+ object->w_top = top;
+ object->w_right = right;
+ object->w_bottom = bottom;
s_tile_update_object(w_current, object);
}
@@ -583,34 +475,40 @@
int min0, min1;
int min0_whichend, min1_whichend;
int rleft, rtop, rright, rbottom;
+ int found;
if (object_list && num_pins) {
if (num_pins == 1 || w_current->force_boundingbox) {
- world_get_complex_bounds(w_current, object_list,
+ world_get_object_list_bounds(w_current, object_list,
&left, &top, &right, &bottom);
} else {
- left = rleft = w_current->init_right;
- top = rtop = w_current->init_bottom;;
- right = rright = 0;
- bottom = rbottom = 0;
+ found = 0;
/* only look at the pins to calculate bounds of the symbol */
o_current = object_list;
while (o_current != NULL) {
if (o_current->type == OBJ_PIN) {
- world_get_pin_bounds(w_current, o_current->line,
- &rleft, &rtop, &rright, &rbottom);
+ rleft = o_current->w_left;
+ rtop = o_current->w_top;
+ rright = o_current->w_right;
+ rbottom = o_current->w_bottom;
+
+ if ( found ) {
+ left = min( left, rleft );
+ top = min( top, rtop );
+ right = max( right, rright );
+ bottom = max( bottom, rbottom );
+ } else {
+ left = rleft;
+ top = rtop;
+ right = rright;
+ bottom = rbottom;
+ found = 1;
+ }
}
-
- if (rleft < left) left = rleft;
- if (rtop < top) top = rtop;
- if (rright > right) right = rright;
- if (rbottom > bottom) bottom = rbottom;
-
o_current=o_current->next;
}
-
}
} else {
return;
@@ -618,6 +516,7 @@
o_current = object_list;
while (o_current != NULL) {
+ /* Determine which end of the pin is on or nearest the boundary */
if (o_current->type == OBJ_PIN && o_current->whichend == -1) {
if (o_current->line->y[0] == o_current->line->y[1]) {
/* horizontal */
1.28 +19 -57 eda/geda/gaf/libgeda/src/o_text_basic.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: o_text_basic.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_text_basic.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- o_text_basic.c 24 Feb 2007 18:43:16 -0000 1.27
+++ o_text_basic.c 17 Apr 2007 20:19:21 -0000 1.28
@@ -66,22 +66,10 @@
* \par Function Description
*
*/
-void get_text_bounds(TOPLEVEL *w_current, OBJECT *o_current,
- int *left, int *top, int *right, int *bottom)
-{
- get_object_list_bounds(w_current, o_current->text->prim_objs, left, top,
- right, bottom);
-}
-
-/*! \todo Finish function documentation!!!
- * \brief
- * \par Function Description
- *
- */
-void world_get_text_bounds(TOPLEVEL *w_current, OBJECT *o_current, int *left,
+int world_get_text_bounds(TOPLEVEL *w_current, OBJECT *o_current, int *left,
int *top, int *right, int *bottom)
{
- world_get_complex_bounds(w_current, o_current->text->prim_objs,
+ return world_get_object_list_bounds(w_current, o_current->text->prim_objs,
left, top, right, bottom);
}
@@ -887,7 +875,6 @@
OBJECT *temp_list=NULL;
OBJECT *temp_parent=NULL;
TEXT *text;
- int left, right, top, bottom;
char *name = NULL;
char *value = NULL;
char *output_string = NULL;
@@ -907,7 +894,6 @@
text->alignment = alignment;
text->x = x;
text->y = y;
- WORLDtoSCREEN(w_current, x, y, &text->screen_x, &text->screen_y);
text->angle = angle;
new_node->text = text;
@@ -990,13 +976,8 @@
w_current->page_current->object_parent = temp_parent;
- get_text_bounds(w_current, object_list, &left, &top, &right, &bottom);
-
- /* set the new object's bounding box */
- object_list->left = left;
- object_list->top = top;
- object_list->right = right;
- object_list->bottom = bottom;
+ /* Update bounding box */
+ o_text_recalc( w_current, object_list );
if (name) g_free(name);
if (value) g_free(value);
@@ -1017,17 +998,13 @@
return;
}
- get_object_list_bounds(w_current, o_current->text->prim_objs,
- &left, &top, &right, &bottom);
- o_current->left = left;
- o_current->top = top;
- o_current->right = right;
- o_current->bottom = bottom;
+ if ( !world_get_text_bounds(w_current, o_current, &left, &top, &right, &bottom) )
+ return;
- WORLDtoSCREEN(w_current, o_current->text->x,
- o_current->text->y,
- &o_current->text->screen_x,
- &o_current->text->screen_y);
+ o_current->w_left = left;
+ o_current->w_top = top;
+ o_current->w_right = right;
+ o_current->w_bottom = bottom;
}
/*! \todo Finish function documentation!!!
@@ -1358,6 +1335,8 @@
o_current->text->displayed_height = 0;
}
+ o_text_recalc( w_current, o_current );
+
w_current->page_current->object_parent = temp_parent;
if (name) g_free(name);
if (value) g_free(value);
@@ -1372,30 +1351,13 @@
void o_text_translate_world(TOPLEVEL *w_current,
int x1, int y1, OBJECT *o_current)
{
- int screen_x, screen_y;
- int left, right, top, bottom;
-
-
o_current->text->x = o_current->text->x + x1;
o_current->text->y = o_current->text->y + y1;
- /* update screen coords */
- WORLDtoSCREEN(w_current, o_current->text->x, o_current->text->y,
- &screen_x, &screen_y);
-
- o_current->text->screen_x = screen_x;
- o_current->text->screen_y = screen_y;
-
o_complex_world_translate(w_current, x1, y1, o_current->text->prim_objs);
- /* update bounding box */
- /* do it */
- get_text_bounds(w_current, o_current, &left, &top, &right, &bottom);
-
- o_current->left = left;
- o_current->top = top;
- o_current->right = right;
- o_current->bottom = bottom;
+ /* Update bounding box */
+ o_text_recalc( w_current, o_current );
}
/*! \todo Finish function documentation!!!
1.26 +4 -10 eda/geda/gaf/libgeda/src/s_basic.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: s_basic.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/s_basic.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- s_basic.c 17 Dec 2006 04:14:07 -0000 1.25
+++ s_basic.c 17 Apr 2007 20:19:21 -0000 1.26
@@ -169,10 +169,10 @@
sprintf(new_node->name, "%s.%d", name, new_node->sid);
/* Setup the bounding box */
- new_node->top = 999999;
- new_node->left = 999999;
- new_node->right = 0;
- new_node->bottom = 0;
+ new_node->w_top = 0;
+ new_node->w_left = 0;
+ new_node->w_right = 0;
+ new_node->w_bottom = 0;
/* Setup line/circle structs */
new_node->line = NULL;
@@ -209,19 +209,13 @@
new_node->line_end = END_NONE;
new_node->line_type = TYPE_SOLID;
new_node->line_width = 0;
- new_node->screen_line_width = 0;
new_node->line_space = 0;
- new_node->screen_line_space = 0;
new_node->line_length = 0;
- new_node->screen_line_length = 0;
new_node->fill_width = 0;
- new_node->screen_fill_width = 0;
new_node->fill_angle1 = 0;
new_node->fill_angle2 = 0;
new_node->fill_pitch1 = 0;
- new_node->screen_fill_pitch1 = 0;
new_node->fill_pitch2 = 0;
- new_node->screen_fill_pitch2 = 0;
new_node->attribs = NULL;
new_node->attached_to = NULL;
1.19 +2 -0 eda/geda/gaf/libgeda/src/s_toplevel.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: s_toplevel.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/s_toplevel.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- s_toplevel.c 24 Feb 2007 10:46:25 -0000 1.18
+++ s_toplevel.c 17 Apr 2007 20:19:21 -0000 1.19
@@ -416,6 +416,8 @@
toplevel->print_command = NULL;
+ toplevel->select_slack_pixels = 4;
+
toplevel->net_naming_priority = 0;
toplevel->hierarchy_traversal = 0;
toplevel->hierarchy_uref_mangle = 0;
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs