[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: CVS update: g_hook.c



  User: cnieves 
  Date: 07/04/14 14:11:44

  Modified:    .        g_hook.c
  Log:
  Fixed get bounds funcs so they don't traverse the whole object list.
  
  * src/g_hook.c: Fixed custom_world_get_single_object_bounds,
  
    and custom_world_get_object_list_bounds, so they don't traverse
  
    the whole object list.
  
  
  
  
  Revision  Changes    Path
  1.19      +95 -43    eda/geda/gaf/gschem/src/g_hook.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: g_hook.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/g_hook.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -b -r1.18 -r1.19
  --- g_hook.c	23 Dec 2006 20:00:06 -0000	1.18
  +++ g_hook.c	14 Apr 2007 18:11:44 -0000	1.19
  @@ -32,6 +32,21 @@
   #include <dmalloc.h>
   #endif
   
  +/* Private function declarations */
  +static void custom_world_get_single_object_bounds 
  +                                       (TOPLEVEL *w_current, OBJECT *o_current,
  +                                        int *left, int *top, 
  +                                        int *right, int *bottom,
  +                                        GList *exclude_attrib_list,
  +					GList *exclude_obj_type_list);
  +
  +static void custom_world_get_object_list_bounds 
  +  (TOPLEVEL *w_current, OBJECT *o_current,
  +   int *left, int *top, 
  +   int *right, int *bottom,
  +   GList *exclude_attrib_list,
  +   GList *exclude_obj_type_list);
  +
   /*! \todo Finish function documentation!!!
    *  \brief
    *  \par Function Description
  @@ -398,13 +413,13 @@
    *  \param [out] bottom  Bottom bound of the object.
    *
    */
  -static void custom_world_get_complex_bounds (TOPLEVEL *w_current, OBJECT *o_current,
  +static void custom_world_get_single_object_bounds 
  +                                       (TOPLEVEL *w_current, OBJECT *o_current,
                                           int *left, int *top, 
                                           int *right, int *bottom,
                                           GList *exclude_attrib_list,
   					GList *exclude_obj_type_list) {
       OBJECT *obj_ptr = NULL;
  -    ATTRIB *attr_ptr = NULL;
       int rleft, rright, rbottom, rtop;
       char *text_value; 
       char *name_ptr, *value_ptr, aux_ptr[2];
  @@ -414,21 +429,12 @@
       *top = rtop = w_current->init_bottom;;
       *right = *bottom = rright = rbottom = 0;
       
  -    if (o_current->type == OBJ_PIN) {
  -      attr_ptr = o_current->attribs;
  -      if (attr_ptr)
  -	obj_ptr = attr_ptr->object;
  -      else 
  -	obj_ptr = NULL;
  -    } else {
         obj_ptr = o_current;
  -    }
  -
  -    while (obj_ptr != NULL) {
         sprintf(aux_ptr, "%c", obj_ptr->type);
         include_text = TRUE;
  +      if (!g_list_find_custom(exclude_obj_type_list, aux_ptr, 
  +			      (GCompareFunc) &strcmp)) {
   
  -      if (!g_list_find_custom(exclude_obj_type_list, aux_ptr, (GCompareFunc) &strcmp)) {
   	switch(obj_ptr->type) {
             case (OBJ_PIN):
   	    world_get_single_object_bounds (w_current, obj_ptr,
  @@ -441,8 +447,10 @@
   		  g_list_find_custom(exclude_attrib_list, name_ptr, (GCompareFunc) &strcmp)) {
   		include_text = FALSE;
   	      }
  -	      if (g_list_find_custom(exclude_attrib_list, "all", (GCompareFunc) &strcmp))
  +	      if (g_list_find_custom(exclude_attrib_list, "all", 
  +				     (GCompareFunc) &strcmp)) {
   		include_text = FALSE;
  +	      }
   	      if (include_text) {
   		world_get_single_object_bounds (w_current, obj_ptr, 
   						&rleft, &rtop, &rright, &rbottom);
  @@ -453,7 +461,7 @@
   	    break;
             case (OBJ_COMPLEX):
             case (OBJ_PLACEHOLDER):
  -	    custom_world_get_complex_bounds(w_current, 
  +	    custom_world_get_object_list_bounds(w_current, 
   					    o_current->complex->prim_objs, 
   					    left, top, right, bottom,
   					    exclude_attrib_list,
  @@ -465,25 +473,69 @@
   					    &rleft, &rtop, &rright, &rbottom);
   	    break;
   	}
  -      }
         
         if (rleft < *left) *left = rleft;
         if (rtop < *top) *top = rtop;
         if (rright > *right) *right = rright;
         if (rbottom > *bottom) *bottom = rbottom;
         
  -      if (o_current->type == OBJ_PIN) {
  -	attr_ptr = attr_ptr->next;
  -	if (attr_ptr)
  -	  obj_ptr = attr_ptr->object;
  -	else
  -	  obj_ptr = NULL;
  +	/* If it's a pin object, check the pin attributes */
  +	if (obj_ptr->type == OBJ_PIN) {
  +	  ATTRIB *a_current = obj_ptr->attribs;
  +	  while (a_current) {
  +	    g_assert(a_current->object);
  +
  +	    if (a_current->object->type == OBJ_TEXT) {
  +	      custom_world_get_single_object_bounds(w_current, 
  +						    a_current->object,
  +						    &rleft, &rtop, 
  +						    &rright, &rbottom,
  +						    exclude_attrib_list,
  +						    exclude_obj_type_list);
  +	      if (rleft < *left) *left = rleft;
  +	      if (rtop < *top) *top = rtop;
  +	      if (rright > *right) *right = rright;
  +	      if (rbottom > *bottom) *bottom = rbottom;
         }
  -      else {
  -	obj_ptr = obj_ptr->next;
  +	    
  +	    a_current = a_current->next;
         }
       }
     } 
  +}
  +
  +static void custom_world_get_object_list_bounds 
  +  (TOPLEVEL *w_current, OBJECT *o_current,
  +   int *left, int *top, 
  +   int *right, int *bottom,
  +   GList *exclude_attrib_list,
  +   GList *exclude_obj_type_list) {
  + 
  +  OBJECT *obj_ptr=NULL;
  +  int rleft, rtop, rright, rbottom;
  +	
  +  *left = rleft = 999999;
  +  *top = rtop = 9999999;
  +  *right = rright = 0;
  +  *bottom = rbottom = 0;
  +	
  +
  +  obj_ptr = o_current;
  +	
  +  while ( obj_ptr != NULL ) {
  +    custom_world_get_single_object_bounds(w_current, obj_ptr, &rleft, &rtop, 
  +					  &rright, &rbottom,
  +					  exclude_attrib_list,
  +					  exclude_obj_type_list);
  +    if (rleft < *left) *left = rleft;
  +    if (rtop < *top) *top = rtop;
  +    if (rright > *right) *right = rright;
  +    if (rbottom > *bottom) *bottom = rbottom;
  +	
  +
  +    obj_ptr=obj_ptr->next;
  +  }
  +}
   
   /*! \brief Get the object bounds of the given object, excluding the object
    *  types or the attributes given as parameters.
  @@ -549,7 +601,7 @@
     if (g_list_find_custom(exclude_attrib_list, "all", (GCompareFunc) &strcmp))
       exclude_all_attribs = TRUE;
   
  -  custom_world_get_complex_bounds (w_current, object,
  +  custom_world_get_single_object_bounds (w_current, object,
   				   &left, &top, 
   				   &right, &bottom, 
   				   exclude_attrib_list,
  
  
  


_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs