All pastes #349358 Raw Edit

Miscellany

public text v1 · immutable
#349358 ·published 2007-02-10 18:53 UTC
rendered paste body
/* LINE code: in libgeda/o_line_basic.c */
gboolean
world_get_line_bounds (TOPLEVEL *toplevel, OBJECT *line,
                       gint *left, gint *bottom, gint *right, gint *top) {
  /* test line */
  
  left   = MIN (...);
  bottom = MIN (...);
  right  = MAX (...);
  top    = MAX (...);

  /* object visible, bbox OK */
  return TRUE;
}

void
o_line_translate (TOPLEVEL *toplevel, OBJECT *line, gint dx, gint dy) {
  line->x1 += dx;
  line->y1 += dy;
  line->x2 += dx;
  line->y2 += dy;
}



/* OBJECT specific: in libgeda/o_basic.c */

void
o_translate (TOPLEVEL *toplevel, OBJECT *object, gint dx, gint dy) {
  switch (object->type) {
      case OBJ_LINE:
        o_line_translate (toplevel, object, dx, dy);
        break;
      case ...:
  }
  o_update_bounds (toplevel, object);
}

void
o_update_bounds (TOPLEVEL *toplevel, OBJECT *object)
{
  gint right, bottom, top, left;

  switch (object->type) {
      case OBJ_LINE:
        world_get_line_bounds (toplevel, object, &right, &bottom, &top, &left);
        break;
      case ...:
  }
  object->left = left;
  object->right = right;
  object->bottom = bottom;
  object->top = top;
}

void
o_get_bounds (TOPLEVEL *toplevel, OBJECT *object, gint *left, gint *bottom, gint *top, gint *left)
{
  top = object->top;
  bottom = object->bottom;
  right = object->right;
  left = object->left;
}