[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: CVS update: o_basic.c
User: ahvezda
Date: 06/12/16 23:14:07
Modified: . o_basic.c o_complex_basic.c o_list.c o_net_basic.c
o_selection.c o_text_basic.c s_basic.c s_page.c
Log:
Merged Carlos' glist work via Peter Brett's patch sets to the trunk.
Revision Changes Path
1.15 +50 -12 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.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- o_basic.c 5 Jul 2006 03:13:38 -0000 1.14
+++ o_basic.c 17 Dec 2006 04:14:07 -0000 1.15
@@ -87,24 +87,18 @@
}
}
-/*! \brief Recalculate position of all objects.
+/*! \brief Recalculate position of the given object.
* \par Function Description
- * This function will take a list of objects and recalculate their
- * positions on the screen.
+ * This function will take an object and recalculate its
+ * position on the screen.
*
* \param [in] w_current The TOPLEVEL object.
- * \param [in,out] object_list OBJECT list to recalculate.
+ * \param [in,out] o_current OBJECT to recalculate.
*
*/
-void o_recalc(TOPLEVEL *w_current, OBJECT *object_list)
+void o_recalc_single_object(TOPLEVEL *w_current, OBJECT *o_current)
{
- OBJECT *o_current;
-
- if (object_list == NULL)
- return;
-
- o_current = object_list;
- while (o_current != NULL) {
+ if (o_current != NULL) {
switch(o_current->type) {
case(OBJ_LINE):
@@ -144,11 +138,55 @@
o_arc_recalc(w_current, o_current);
break;
}
+ }
+}
+
+/*! \brief Recalculate position of a list of objects.
+ * \par Function Description
+ * This function will take a list of objects and recalculate their
+ * positions on the screen.
+ *
+ * \param [in] w_current The TOPLEVEL object.
+ * \param [in,out] object_list OBJECT list to recalculate.
+ *
+ */
+void
+o_recalc_object_list(TOPLEVEL *w_current, OBJECT *object_list)
+{
+ OBJECT *o_current;
+ o_current = object_list;
+ while (o_current != NULL) {
+ o_recalc_single_object(w_current, o_current);
o_current = o_current->next;
}
}
+/*! \brief Recalculate position of a list (GList) of objects.
+ * \par Function Description
+ * This function will take a list (GList) of objects and recalculate their
+ * positions on the screen.
+ *
+ * \param [in] w_current The TOPLEVEL object.
+ * \param [in,out] object_glist OBJECT list to recalculate.
+ *
+ */
+void
+o_recalc_object_glist(TOPLEVEL *w_current, GList *object_glist)
+{
+ GList *list = object_glist;
+ OBJECT *o_current;
+
+ while (list != NULL) {
+ o_current = (OBJECT *) list->data;
+ o_recalc_single_object(w_current, o_current);
+ list = list->next;
+ }
+}
+
+
+
+
/*! \brief Set an #OBJECT's line options.
* \par Function Description
* This function allows a line's end, type, width, length and space to be set.
1.30 +186 -111 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.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- o_complex_basic.c 7 Dec 2006 04:24:18 -0000 1.29
+++ o_complex_basic.c 17 Dec 2006 04:14:07 -0000 1.30
@@ -43,57 +43,51 @@
#include <dmalloc.h>
#endif
-/*! \brief
- * \par Function Description
+/*! \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] rleft pointer to the left coordinate of the object.
+ * \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.
*
*/
-void get_complex_bounds(TOPLEVEL *w_current, OBJECT *complex,
- int *left, int *top, int *right, int *bottom)
+void get_single_object_bounds(TOPLEVEL *w_current, OBJECT *o_current,
+ int *rleft, int *rtop, int *rright, int *rbottom)
{
- OBJECT *o_current=NULL;
- int rleft, rtop, rright, rbottom;
-
- *left = rleft = 999999;
- *top = rtop = 9999999;
- *right = rright = 0;
- *bottom = rbottom = 0;
-
-
-
- o_current = complex;
-
- while ( o_current != NULL ) {
+ if (o_current != NULL) {
switch(o_current->type) {
case(OBJ_LINE):
- get_line_bounds(w_current, o_current->line, &rleft, &rtop, &rright, &rbottom);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ get_circle_bounds(w_current, o_current->circle, rleft, rtop, rright, rbottom);
break;
case(OBJ_COMPLEX):
case(OBJ_PLACEHOLDER):
/* recursive objects ?*/
- get_complex_bounds(w_current, o_current->complex->prim_objs, &rleft, &rtop, &rright, &rbottom);
+ get_object_list_bounds(w_current, o_current->complex->prim_objs, rleft, rtop, rright, rbottom);
break;
case(OBJ_TEXT):
@@ -101,22 +95,51 @@
/* 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);
+ get_text_bounds(w_current, o_current, rleft, rtop, rright, rbottom);
}
break;
case(OBJ_PIN):
- get_pin_bounds(w_current, o_current->line, &rleft, &rtop, &rright, &rbottom);
+ 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);
+ get_arc_bounds(w_current, o_current, rleft, rtop, rright, rbottom);
break;
default:
break;
}
+ }
+}
+
+/*! \brief Return the bounds of the given list of objects.
+ * \par Given a 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.
+ */
+void
+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;
+
+
+ o_current = complex;
+
+ 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;
@@ -128,14 +151,19 @@
}
-/*! \brief
- * \par Function Description
- *
+/*! \brief Return the bounds of the given GList of objects.
+ * \par Given a 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.
*/
-void get_complex_bounds_selection(TOPLEVEL *w_current, SELECTION *head,
+void get_object_glist_bounds(TOPLEVEL *w_current, GList *head,
int *left, int *top, int *right, int *bottom)
{
- SELECTION *s_current=NULL;
+ GList *s_current=NULL;
OBJECT *o_current=NULL;
int rleft, rtop, rright, rbottom;
@@ -148,66 +176,12 @@
while ( s_current != NULL ) {
- o_current = s_current->selected_object;
-
- if (!o_current) {
- fprintf(stderr, "Got NULL in get_complex_bounds_selection\n");
- exit(-1);
- }
-
- 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_COMPLEX):
- case(OBJ_PLACEHOLDER):
- /* recursive objects ?*/
- get_complex_bounds(w_current, o_current->complex->prim_objs, &rleft, &rtop, &rright, &rbottom);
- 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)) {
- get_text_bounds(w_current, o_current, &rleft, &rtop, &rright, &rbottom);
- }
- break;
-
- case(OBJ_PIN):
- get_pin_bounds(w_current, o_current->line, &rleft, &rtop, &rright, &rbottom);
- break;
+ o_current = (OBJECT *) s_current->data;
- case(OBJ_ARC):
- get_arc_bounds(w_current, o_current, &rleft, &rtop, &rright, &rbottom);
- break;
+ g_assert (o_current != NULL);
- default:
- break;
- }
+ get_single_object_bounds(w_current, o_current, &rleft, &rtop,
+ &rright, &rbottom);
if (rleft < *left) *left = rleft;
if (rtop < *top) *top = rtop;
@@ -372,6 +346,8 @@
int promotableAttribute = FALSE;
char *ptr;
+ g_return_val_if_fail(object != NULL, FALSE);
+
if (object->type != OBJ_TEXT || object->attribute || object->attached_to)
{
return FALSE; /* not a text item or is already attached */
@@ -428,6 +404,8 @@
*/
int o_complex_is_embedded(OBJECT *o_current)
{
+ g_return_val_if_fail(o_current != NULL, 0);
+
if(o_current->complex == NULL)
return 0;
@@ -445,7 +423,8 @@
* \par Function Description
*
*/
-OBJECT *o_complex_add(TOPLEVEL *w_current, OBJECT *object_list, char type,
+OBJECT *o_complex_add(TOPLEVEL *w_current, OBJECT *object_list,
+ GList **object_glist, char type,
int color, int x, int y, int angle,
int mirror, char *clib,
char *basename, int selectable,
@@ -457,8 +436,15 @@
OBJECT *temp_parent=NULL;
int save_adding_sel = 0;
int loaded_normally = FALSE;
-
+ gboolean use_object_list;
char *filename;
+ GList *glist_ptr;
+
+ if (object_list) {
+ use_object_list = TRUE;
+ } else {
+ use_object_list = FALSE;
+ }
new_node = s_basic_init_object("complex");
new_node->type = type;
@@ -634,9 +620,35 @@
/* Isolate tmp completely, now that it's removed from list */
tmp->next=tmp->prev=NULL;
-
+ if (use_object_list) {
object_list = (OBJECT *) s_basic_link_object(tmp, object_list);
o_attrib_attach (w_current, object_list, tmp, new_node);
+ }
+ else {
+ if (object_glist) {
+ *object_glist = g_list_append (*object_glist, tmp);
+
+ glist_ptr = *object_glist;
+ while (glist_ptr) {
+ if (glist_ptr->prev == NULL) {
+ ((OBJECT *) glist_ptr->data)->prev = NULL;
+ } else {
+ ((OBJECT *) glist_ptr->data)->prev = glist_ptr->prev->data;
+ }
+ if (glist_ptr->next == NULL) {
+ ((OBJECT *) glist_ptr->data)->next = NULL;
+ } else {
+ ((OBJECT *) glist_ptr->data)->next = glist_ptr->next->data;
+ }
+ glist_ptr = glist_ptr->next;
+ }
+
+ o_attrib_attach (w_current, ((OBJECT *) g_list_last(*object_glist)->data),
+ tmp, new_node);
+ } else {
+ o_attrib_attach (w_current, NULL, tmp, new_node);
+ }
+ }
o_text_translate_world(w_current, x, y, tmp);
} else { /* not promoting now, but deal with floating attribs */
@@ -659,19 +671,45 @@
w_current->page_current->object_tail = temp_tail;
w_current->page_current->object_parent = temp_parent;
+ if (use_object_list) {
object_list = (OBJECT *) s_basic_link_object(new_node, object_list);
object_list->complex->prim_objs = prim_objs;
+ }
+ else {
+ new_node->complex->prim_objs = prim_objs;
+ if (object_glist) {
+ *object_glist = g_list_append (*object_glist, new_node);
+
+ glist_ptr = *object_glist;
+ while (glist_ptr) {
+ if (glist_ptr->prev == NULL) {
+ ((OBJECT *) glist_ptr->data)->prev = NULL;
+ } else {
+ ((OBJECT *) glist_ptr->data)->prev = glist_ptr->prev->data;
+ }
+ if (glist_ptr->next == NULL) {
+ ((OBJECT *) glist_ptr->data)->next = NULL;
+ } else {
+ ((OBJECT *) glist_ptr->data)->next = glist_ptr->next->data;
+ }
+ glist_ptr = glist_ptr->next;
+ }
+ object_list = (OBJECT *) (g_list_last(*object_glist)->data);
+ } else {
+ object_list = new_node;
+ }
+ }
/* do not mirror/rotate/translate/connect the primitive objects if the
* component was not loaded via o_read
*/
if (loaded_normally == TRUE) {
if (mirror) {
- o_complex_mirror_lowlevel(w_current, x, y, object_list);
+ o_complex_mirror_lowlevel(w_current, x, y, new_node);
}
- o_complex_rotate_lowlevel(w_current, x, y, angle, angle, object_list);
+ o_complex_rotate_lowlevel(w_current, x, y, angle, angle, new_node);
o_complex_world_translate(w_current, x, y, prim_objs);
if (!w_current->ADDING_SEL) {
@@ -750,7 +788,10 @@
/* libhack */
/* o_recalc(w_current, o_current->complex);*/
- get_complex_bounds(w_current, o_current->complex->prim_objs, &left, &top, &right, &bottom);
+ 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;
@@ -761,6 +802,7 @@
o_current->complex->y,
&o_current->complex->screen_x,
&o_current->complex->screen_y);
+
}
/*! \brief
@@ -836,7 +878,7 @@
clib = (gchar*)clibs->data;
}
- object_list = o_complex_add(w_current, object_list, type,
+ object_list = o_complex_add(w_current, object_list, NULL, type,
WHITE,
x1, y1,
angle, mirror,
@@ -855,6 +897,8 @@
int selectable;
char *buf = NULL;
+ g_return_val_if_fail (object != NULL, NULL);
+
if (object->sel_func != NULL)
selectable = 1;
else
@@ -1049,6 +1093,10 @@
{
int left, right, top, bottom;
+ g_return_if_fail(object != NULL);
+ g_return_if_fail((object->type == OBJ_COMPLEX) ||
+ (object->type == OBJ_PLACEHOLDER));
+
object->complex->x = object->complex->x + x1;
object->complex->y = object->complex->y + y1;
@@ -1060,7 +1108,7 @@
o_complex_world_translate(w_current, x1, y1,
object->complex->prim_objs);
- get_complex_bounds(w_current, object->complex->prim_objs,
+ get_object_list_bounds(w_current, object->complex->prim_objs,
&left, &top, &right, &bottom);
object->left = left;
@@ -1081,6 +1129,8 @@
int color;
int selectable;
+ g_return_val_if_fail(o_current != NULL, NULL);
+
if (o_current->saved_color == -1) {
color = o_current->color;
} else {
@@ -1093,7 +1143,7 @@
selectable = FALSE;
}
- new_obj = o_complex_add(w_current, list_tail, o_current->type, color,
+ new_obj = o_complex_add(w_current, list_tail, NULL, o_current->type, color,
o_current->complex->x, o_current->complex->y,
o_current->complex->angle, o_current->complex->mirror,
o_current->complex_clib, o_current->complex_basename,
@@ -1135,6 +1185,8 @@
int color;
int selectable;
+ g_return_val_if_fail(o_current != NULL, NULL);
+
if (o_current->saved_color == -1) {
color = o_current->color;
} else {
@@ -1188,6 +1240,8 @@
*/
void o_complex_delete(TOPLEVEL *w_current, OBJECT *delete)
{
+ g_return_if_fail(delete != NULL);
+
/* first remove complex pointer */
if (delete->complex) {
if (delete->complex->prim_objs) {
@@ -1249,6 +1303,8 @@
*/
void o_complex_set_color_single(OBJECT *o_current, int color)
{
+ g_return_if_fail(o_current != NULL);
+
switch(o_current->type) {
case(OBJ_LINE):
case(OBJ_NET):
@@ -1372,6 +1428,8 @@
*/
void o_complex_unset_color_single(OBJECT *o_current)
{
+ g_return_if_fail(o_current != NULL);
+
switch(o_current->type) {
case(OBJ_LINE):
case(OBJ_NET):
@@ -1485,6 +1543,12 @@
printf("------- a %d ac %d\n", angle, angle_change);
#endif
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(((object->type == OBJ_COMPLEX) ||
+ (object->type == OBJ_PLACEHOLDER)));
+ g_return_if_fail(object->complex != NULL);
+
+
/* do individual complex objects */
o_current = object->complex->prim_objs;
@@ -1547,6 +1611,11 @@
{
OBJECT *o_current=NULL;
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(((object->type == OBJ_COMPLEX) ||
+ (object->type == OBJ_PLACEHOLDER)));
+ g_return_if_fail(object->complex != NULL);
+
/* do individual complex objects */
o_current = object->complex->prim_objs;
@@ -1611,6 +1680,12 @@
OBJECT *o_current=NULL;
OBJECT *found;
+ g_return_val_if_fail(object != NULL, NULL);
+ g_return_val_if_fail(((object->type == OBJ_COMPLEX) ||
+ (object->type == OBJ_PLACEHOLDER)) , NULL);
+ g_return_val_if_fail(object->complex != NULL, NULL);
+
+
/* go inside complex objects */
o_current = object->complex->prim_objs;
@@ -1655,10 +1730,10 @@
double inside_major, inside_minor;
double outside_major, outside_minor;
- if (object->type != OBJ_COMPLEX && object->type != OBJ_PLACEHOLDER)
- {
- return;
- }
+ g_return_if_fail (object != NULL);
+ g_return_if_fail ((object->type == OBJ_COMPLEX ||
+ object->type == OBJ_PLACEHOLDER));
+ g_return_if_fail (object->complex != NULL);
/* first look on the inside for the symversion= attribute */
inside = o_attrib_search_name(object->complex->prim_objs, "symversion", 0);
1.19 +4 -4 eda/geda/gaf/libgeda/src/o_list.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: o_list.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_list.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- o_list.c 5 Jul 2006 03:13:38 -0000 1.18
+++ o_list.c 17 Dec 2006 04:14:07 -0000 1.19
@@ -253,10 +253,10 @@
* \return OBJECT pointer.
*/
OBJECT *o_list_copy_all_selection2(TOPLEVEL *w_current,
- SELECTION *src_list_head,
+ GList *src_list_head,
OBJECT *dest_list_head, int flag)
{
- SELECTION *src;
+ GList *src;
OBJECT *object;
OBJECT *dest;
OBJECT *temp_parent=NULL;
@@ -283,7 +283,7 @@
/* first do all NON text items */
while(src != NULL) {
- object = src->selected_object;
+ object = (OBJECT *) src->data;
/* unselect the object before the copy */
o_selection_unselect(object);
@@ -318,7 +318,7 @@
/* then do all text items */
while(src != NULL) {
- object = src->selected_object;
+ object = (OBJECT *) src->data;
/* unselect the object before the copy */
o_selection_unselect(object);
1.33 +5 -4 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.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- o_net_basic.c 7 Dec 2006 04:24:18 -0000 1.32
+++ o_net_basic.c 17 Dec 2006 04:14:07 -0000 1.33
@@ -917,16 +917,17 @@
changed++;
if (other_object->selected == TRUE ) {
- o_selection_remove(w_current->page_current->selection2_head,
+ o_selection_remove(&(w_current->page_current->selection_list),
other_object);
reselect_new=TRUE;
}
if (reselect_new == TRUE) {
- o_selection_remove(w_current->page_current->selection2_head,
+ o_selection_remove(&(w_current->page_current->selection_list),
object);
- o_selection_add(w_current->page_current->selection2_head,
+ w_current->page_current->selection_list =
+ o_selection_add(w_current->page_current->selection_list,
object);
}
1.8 +63 -264 eda/geda/gaf/libgeda/src/o_selection.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: o_selection.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_selection.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- o_selection.c 15 Jul 2006 17:00:51 -0000 1.7
+++ o_selection.c 17 Dec 2006 04:14:07 -0000 1.8
@@ -46,195 +46,35 @@
#include <dmalloc.h>
#endif
-/*! \todo Finish function documentation!!!
- * \brief
- * \par Function Description
- *
- */
-SELECTION *o_selection_return_tail(SELECTION *head)
-{
- SELECTION *s_current=NULL;
- SELECTION *ret_struct=NULL;
-
- s_current = head;
- while ( s_current != NULL ) { /* goto end of list */
- ret_struct = s_current;
- s_current = s_current->next;
- }
-
- return(ret_struct);
-}
-
-/*! \todo Finish function documentation!!!
- * \brief
- * \par Function Description
- *
- */
-SELECTION *o_selection_return_head(SELECTION *tail)
-{
- SELECTION *s_current=NULL;
- SELECTION *ret_struct=NULL;
-
- s_current = tail;
- while ( s_current != NULL ) { /* goto end of list */
- ret_struct = s_current;
- s_current = s_current->prev;
- }
-
- return(ret_struct);
-}
-
-/*! \todo Finish function documentation!!!
- * \brief
- * \par Function Description
- *
- */
-SELECTION *o_selection_new_head(void)
-{
- SELECTION *s_new;
-
- s_new = (SELECTION *) g_malloc(sizeof(SELECTION));
- s_new->selected_object = NULL;
- s_new->prev = NULL;
- s_new->next = NULL;
-
- return(s_new);
-}
-
-/*! \todo Finish function documentation!!!
- * \brief
- * \par Function Description
- *
+/*! \brief Selects the given object and adds it to the selection list
+ * \par Selects the given object and does the needed work to make the
+ * object visually selected.
+ * \param [in] head Selection list
+ * \param [in] o_selected Object to select.
+ * \returns a pointer to the selection list, with the object added.
*/
-void o_selection_destroy_head(SELECTION *s_head)
+GList *o_selection_add(GList *head, OBJECT *o_selected)
{
- g_free(s_head);
-}
-
-/*! \todo Finish function documentation!!!
- * \brief
- * \par Function Description
- *
- */
-/* also does the needed work to make the object visually selected */
-SELECTION *o_selection_add(SELECTION *head, OBJECT *o_selected)
-{
- SELECTION *tail;
- SELECTION *s_new;
-
- s_new = (SELECTION *) g_malloc(sizeof(SELECTION));
-
- if (o_selected != NULL) {
- s_new->selected_object = o_selected;
- } else {
- fprintf(stderr, "Got NULL passed to o_selection_new\n");
- }
-
o_selection_select(o_selected, SELECT_COLOR);
-
- if (head == NULL) {
- s_new->prev = NULL; /* setup previous link */
- s_new->next = NULL;
- return(s_new);
- } else {
- tail = o_selection_return_tail(head);
- s_new->prev = tail; /* setup previous link */
- s_new->next = NULL;
- tail->next = s_new;
- return(tail->next);
- }
-}
-
-/*! \todo Finish function documentation!!!
- * \brief
- * \par Function Description
- *
- */
-/* it's okay to call this with an o_selected which is not necessarily */
-/* selected */
-void o_selection_remove(SELECTION *head, OBJECT *o_selected)
-{
- SELECTION *s_current;
-
- if (o_selected == NULL) {
- fprintf(stderr, "Got NULL for o_selected in o_selection_remove\n");
- return;
- }
-
- s_current = head;
-
- while (s_current != NULL) {
- if (s_current->selected_object == o_selected) {
- if (s_current->next)
- s_current->next->prev = s_current->prev;
- else
- s_current->next = NULL;
-
- if (s_current->prev)
- s_current->prev->next = s_current->next;
- else
- s_current->prev = NULL;
-
- o_selection_unselect(s_current->selected_object);
-
- s_current->selected_object = NULL;
- g_free(s_current);
- return;
- }
- s_current = s_current->next;
- }
-}
-
-/*! \todo Finish function documentation!!!
- * \brief
- * \par Function Description
- *
- */
-/* removes all but the head node */
-void o_selection_remove_most(TOPLEVEL *w_current, SELECTION *head)
-{
- SELECTION *s_current;
- SELECTION *s_prev;
-
- s_current = o_selection_return_tail(head);
-
- while (s_current != NULL) {
- if (s_current->selected_object != NULL) {
- s_prev = s_current->prev;
-
- o_selection_unselect(s_current->selected_object);
-
- o_redraw_single(w_current,
- s_current->selected_object);
-
- s_current->selected_object = NULL;
- g_free(s_current);
- s_current = s_prev;
- } else {
- break;
- }
- }
-
- /* clear out any dangling pointers */
- head->next=NULL;
+ return (g_list_append(head, o_selected));
}
-/*! \todo Finish function documentation!!!
- * \brief
- * \par Function Description
+/*! \brief Prints the given selection list.
+ * \par Prints the given selection list.
+ * \param [in] head Selection list to print.
*
*/
-void o_selection_print_all( SELECTION *head )
+void o_selection_print_all( GList *head )
{
- SELECTION *s_current;
+ GList *s_current;
s_current = head;
printf("START printing selection ********************\n");
while(s_current != NULL) {
- if (s_current->selected_object) {
+ if (s_current->data) {
printf("Selected object: %d\n",
- s_current->selected_object->sid);
+ ( (OBJECT *) s_current->data)->sid);
}
s_current = s_current->next;
}
@@ -243,32 +83,12 @@
}
-/*! \todo Finish function documentation!!!
- * \brief
- * \par Function Description
- *
- */
-void o_selection_destroy_all(SELECTION *head)
-{
- SELECTION *s_current;
- SELECTION *s_prev;
-
- s_current = o_selection_return_tail(head);
-
- while (s_current != NULL) {
- s_prev = s_current->prev;
- s_current->selected_object = NULL;
- g_free(s_current);
- s_current = s_prev;
- }
-}
-
-/*! \todo Finish function documentation!!!
- * \brief
- * \par Function Description
- *
+/*! \brief Selects the given object.
+ * \par Sets the select flag, saves the color, and then selects the
+ * given object
+ * \param [in] o_selected Object to select.
+ * \param [in] color color of the selected object.
*/
-/* this sets the select flag, saves the color, and then sets the color */
void o_selection_select(OBJECT *object, int color)
{
if (object->selected == TRUE) {
@@ -292,13 +112,12 @@
}
}
-/*! \todo Finish function documentation!!!
- * \brief
- * \par Function Description
- *
+/*! \brief Unselects the given object.
+ * \par Unsets the select flag, restores the original color of the
+ * given object.
+ * This function should not be called by anybody outside of this file.
+ * \param [in] object Object to unselect.
*/
-/* this unsets the select flag and restores the original color */
-/* this function should not be called by anybody outside of this file */
void o_selection_unselect(OBJECT *object)
{
object->selected = FALSE;
@@ -307,81 +126,61 @@
/* grips are erase */
object->color = object->saved_color;
if (object->type == OBJ_COMPLEX || object->type == OBJ_PLACEHOLDER) {
+ if (!object->complex) {
+ fprintf(stderr, "o_selection_unselect: Called with NULL object.\n");
+ return;
+ }
o_complex_unset_color(object->complex->prim_objs);
} else if (object->type == OBJ_TEXT) {
+ if (!object->text) {
+ fprintf(stderr, "o_selection_unselect: Called with NULL object.\n");
+ return;
+ }
o_complex_unset_color(object->text->prim_objs);
}
object->saved_color = -1;
}
-/*! \todo Finish function documentation!!!
- * \brief
- * \par Function Description
- *
- */
-OBJECT *o_selection_return_first_object(SELECTION *head)
-{
- if (!head)
- return(NULL);
-
- if (!head->next)
- return(NULL);
-
- if (!head->next->selected_object)
- return(NULL);
-
- return(head->next->selected_object);
-}
-
-/*! \todo Finish function documentation!!!
- * \brief
- * \par Function Description
- *
+/*! \brief Removes the given object from the selection list
+ * \par Removes the given object from the selection list and does the
+ * needed work to make the object visually unselected.
+ * It's ok to call this function with an object which is not necessarily
+ * selected.
+ * \param [in] head Pointer to the selection list
+ * \param [in] o_selected Object to unselect and remove from the list.
*/
-/* Nth starts counting a ZERO */
-/* doesn't consider the head node an object */
-OBJECT *o_selection_return_nth_object(SELECTION *head, int count)
+void
+o_selection_remove(GList **head, OBJECT *o_selected)
{
- int internal_counter = 0;
- SELECTION *s_current;
-
- s_current = head->next;
-
- while (s_current != NULL) {
- if (internal_counter == count) {
- if (s_current->selected_object) {
- return(s_current->selected_object);
- }
+ if (o_selected == NULL) {
+ fprintf(stderr, "Got NULL for o_selected in o_selection_remove\n");
+ return;
}
- internal_counter++;
- s_current = s_current->next;
+ if (g_list_find(*head, o_selected) != NULL) {
+ o_selection_unselect(o_selected);
+ *head = g_list_remove(*head, o_selected);
}
- return(NULL);
}
-/*! \todo Finish function documentation!!!
- * \brief
- * \par Function Description
- *
+/*! \brief Unselects all the objects in the given list.
+ * \par Unselects all objects in the given list, does the
+ * needed work to make the objects visually unselected, and redraw them.
+ * \param [in] w_current TOPLEVEL struct.
+ * \param [in] head Pointer to the selection list
*/
-int o_selection_return_num(SELECTION *head)
+void
+o_selection_unselect_list(TOPLEVEL *w_current, GList **head)
{
- int counter = 0;
- SELECTION *s_current;
-
- if (!head) {
- return 0;
- }
-
- /* skip over head */
- s_current = head->next;
+ GList *list = *head;
- while (s_current != NULL) {
- counter++;
- s_current = s_current->next;
+ while (list != NULL) {
+ o_selection_unselect((OBJECT *) list->data);
+ o_redraw_single(w_current, (OBJECT *) list->data);
+ list = list->next;
}
- return(counter);
+ g_list_free(*head);
+ *head = NULL;
}
1.25 +4 -4 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.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- o_text_basic.c 7 Dec 2006 04:24:18 -0000 1.24
+++ o_text_basic.c 17 Dec 2006 04:14:07 -0000 1.25
@@ -69,7 +69,7 @@
void get_text_bounds(TOPLEVEL *w_current, OBJECT *o_current,
int *left, int *top, int *right, int *bottom)
{
- get_complex_bounds(w_current, o_current->text->prim_objs, left, top,
+ get_object_list_bounds(w_current, o_current->text->prim_objs, left, top,
right, bottom);
}
@@ -1017,7 +1017,7 @@
return;
}
- get_complex_bounds(w_current, o_current->text->prim_objs,
+ get_object_list_bounds(w_current, o_current->text->prim_objs,
&left, &top, &right, &bottom);
o_current->left = left;
o_current->top = top;
1.25 +56 -18 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.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- s_basic.c 6 Aug 2006 16:45:31 -0000 1.24
+++ s_basic.c 17 Dec 2006 04:14:07 -0000 1.25
@@ -362,26 +362,10 @@
* \par Function Description
*
*/
-void s_delete(TOPLEVEL *w_current, OBJECT *o_current)
+void
+s_delete_object(TOPLEVEL *w_current, OBJECT *o_current)
{
if (o_current != NULL) {
-
-
-#if DEBUG
- printf("sdel: %s\n", o_current->name);
- printf("sdel: %d\n", o_current->sid);
-#endif
-
- if (o_current->next)
- o_current->next->prev = o_current->prev;
- else
- o_current->next = NULL;
-
- if (o_current->prev)
- o_current->prev->next = o_current->next;
- else
- o_current->prev = NULL;
-
s_conn_remove(w_current, o_current);
/* second half of if is odd that we need it? hack */
@@ -512,6 +496,36 @@
* \par Function Description
*
*/
+void
+s_delete(TOPLEVEL *w_current, OBJECT *o_current)
+{
+ if (o_current != NULL) {
+
+
+#if DEBUG
+ printf("sdel: %s\n", o_current->name);
+ printf("sdel: %d\n", o_current->sid);
+#endif
+
+ if (o_current->next)
+ o_current->next->prev = o_current->prev;
+ else
+ o_current->next = NULL;
+
+ if (o_current->prev)
+ o_current->prev->next = o_current->next;
+ else
+ o_current->prev = NULL;
+
+ s_delete_object(w_current, o_current);
+ }
+}
+
+/*! \todo Finish function documentation!!!
+ * \brief
+ * \par Function Description
+ *
+ */
/* deletes everything include the head */
void s_delete_list_fromstart(TOPLEVEL *w_current, OBJECT *start)
{
@@ -561,6 +575,30 @@
/*! \todo Finish function documentation!!!
* \brief
* \par Function Description
+ *
+ */
+/* deletes everything include the head */
+void
+s_delete_object_glist(TOPLEVEL *w_current, GList *list)
+{
+ OBJECT *o_current=NULL;
+ GList *ptr;
+
+ ptr = g_list_last(list);
+
+ /* do the delete backwards */
+ while(ptr != NULL) {
+ o_current = (OBJECT *) ptr->data;
+ s_delete_object(w_current, o_current);
+ ptr = ptr->prev;
+ }
+
+}
+
+
+/*! \todo Finish function documentation!!!
+ * \brief
+ * \par Function Description
* This function removes one object pointed by parameter <B>object</B> from
* a list as far as it does not represents a head. If so the function returns
* NULL. If not it returns the pointer on the object, i.e. the same as the
1.26 +14 -9 eda/geda/gaf/libgeda/src/s_page.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: s_page.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/s_page.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- s_page.c 30 Sep 2006 17:52:00 -0000 1.25
+++ s_page.c 17 Dec 2006 04:14:07 -0000 1.26
@@ -100,15 +100,12 @@
page->object_head->type = OBJ_HEAD;
/* new selection mechanism */
- page->selection2_head = page->selection2_tail =
- o_selection_new_head();
+ page->selection_list = NULL;
/* net/pin/bus stretch when doing moves */
page->stretch_head = page->stretch_tail = s_stretch_new_head();
- page->complex_place_tail = page->complex_place_head =
- s_basic_init_object("complex_place_head");
- page->complex_place_tail->type = OBJ_HEAD;
+ page->complex_place_list = NULL;
/* add p_attrib and p_attached_to */
page->attrib_place_tail = page->attrib_place_head =
@@ -169,6 +166,7 @@
gchar *real_filename;
gchar *only_filename;
gchar *dirname;
+ int redraw_status=toplevel->DONT_REDRAW;
g_assert (page->pid != -1);
@@ -211,13 +209,20 @@
}
g_free(real_filename);
- /* first delete objects of page */
+ /* first unselect the objects, without redrawing them */
+ toplevel->DONT_REDRAW = 1;
+ o_selection_unselect_list(toplevel, &(page->selection_list));
+ toplevel->DONT_REDRAW = redraw_status;
+
+ /* then delete objects of page */
s_delete_list_fromstart (toplevel, page->object_head);
toplevel->REMOVING_SEL = 1;
- s_delete_list_fromstart (toplevel, page->complex_place_head);
+ /* The complex place list contain a reference to the objects in the page */
+ /* So don't free the objects there. */
+ g_list_free (page->complex_place_list);
+ page->complex_place_list = NULL;
s_delete_list_fromstart (toplevel, page->attrib_place_head);
- o_selection_destroy_all (page->selection2_head);
toplevel->REMOVING_SEL = 0;
#if DEBUG
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs