コード例 #1
0
ファイル: buffer.c プロジェクト: bgamari/geda-pcb
/* ---------------------------------------------------------------------------
 * calculates the bounding box of the buffer
 */
void
SetBufferBoundingBox (BufferType *Buffer)
{
  BoxType *box = GetDataBoundingBox (Buffer->Data);

  if (box)
    Buffer->BoundingBox = *box;
}
コード例 #2
0
ファイル: autocrop.c プロジェクト: bert/pcb-plugins
static int
autocrop (int argc, char **argv, Coord x, Coord y)
{
//  int changed = 0;
  Coord dx, dy, pad;
  BoxType *box;

  box = GetDataBoundingBox (PCB->Data); /* handy! */
  if (!box || (box->X1 == box->X2 || box->Y1 == box->Y2))
  {
    /* board would become degenerate */
    return 0;
  }
  /*
   * Now X1/Y1 are the distance to move the left/top edge
   * (actually moving all components to the left/up) such that
   * the exact edge of the leftmost/topmost component would touch
   * the edge.  Reduce the move by the edge relief requirement XXX
   * and expand the board by the same amount.
   */
  pad = PCB->minWid * 5; /* XXX real edge clearance */
  dx = -box->X1 + pad;
  dy = -box->Y1 + pad;
  box->X2 += pad;
  box->Y2 += pad;
  /*
   * Round move to keep components grid-aligned, then translate the
   * upper coordinates into the new space.
   */
  dx -= dx % (long) PCB->Grid;
  dy -= dy % (long) PCB->Grid;
  box->X2 += dx;
  box->Y2 += dy;
  /*
   * Avoid touching any data if there's nothing to do.
   */
  if (dx == 0 && dy == 0 && PCB->MaxWidth == box->X2
    && PCB->MaxHeight == box->Y2)
  {
    return 0;
  }
  /* Resize -- XXX cannot be undone */
  PCB->MaxWidth = box->X2;
  PCB->MaxHeight = box->Y2;
  MoveAll (dx, dy);
  IncrementUndoSerialNumber ();
  Redraw ();
  SetChangedFlag (1);
  return 0;
}