Beispiel #1
0
/* ---------------------------------------------------------------------------
 * copies an element onto the PCB.  Then does a draw. 
 */
static void *
CopyElement (ElementType *Element)
{

#ifdef DEBUG
  printf("Entered CopyElement, trying to copy element %s\n",
	 Element->Name[1].TextString);
#endif

  ElementType *element = CopyElementLowLevel (PCB->Data, Element,
                                              TEST_FLAG (UNIQUENAMEFLAG, PCB),
                                              DeltaX, DeltaY, NOCOPY_FLAGS);

  /* this call clears the polygons */
  AddObjectToCreateUndoList (ELEMENT_TYPE, element, element, element);
  if (PCB->ElementOn && (FRONT (element) || PCB->InvisibleObjectsOn))
    {
      DrawElementName (element);
      DrawElementPackage (element);
    }
  if (PCB->PinOn)
    {
      DrawElementPinsAndPads (element);
    }
#ifdef DEBUG
  printf(" ... Leaving CopyElement.\n");
#endif
  return (element);
}
Beispiel #2
0
static Boolean
replace_one_footprint_translate_only(ElementTypePtr old_element,
                                     ElementTypePtr new_element)
{
  /* Just requires one corresponding pad/pin.  Does no rotations. */
  if (! have_any_corresponding_pad_or_pin(old_element, new_element,
                                          NULL, NULL)) {
    return False;
  }

  /* Create copy of new element. */
  ElementTypePtr copy_element =
    CopyElementLowLevel(PCB->Data, NULL, new_element, False, 0, 0);

  PadOrPinType old_pp = make_pad_or_pin(NULL, NULL);
  PadOrPinType copy_pp = make_pad_or_pin(NULL, NULL);
  if (! have_any_corresponding_pad_or_pin(old_element, copy_element,
                                          &old_pp, &copy_pp)) {
    base_log("Error: Couldn't find any corresponding pads or pins.");
    return False;
  }
  replace_one_footprint_aux(old_element, &old_pp, NULL,
                            copy_element, &copy_pp, NULL);
  debug_log("Used translation-only replacement.\n");
  return True;
}
Beispiel #3
0
static Boolean
replace_one_footprint_quick(ElementTypePtr old_element,
                            ElementTypePtr new_element)
{
  /* Requires that there be two non-coincident, uniquely numbered
     pads/pins that correspond between the old and new element. */
  if (! have_two_corresponding_unique_non_coincident(old_element,
                                                     new_element,
                                                     NULL, NULL,
                                                     NULL, NULL)) {
    return False;
  }

  /* Create copy of new element. */
  ElementTypePtr copy_element =
    CopyElementLowLevel(PCB->Data, NULL, new_element, False, 0, 0);

  PadOrPinType old1_pp;
  PadOrPinType old2_pp;
  PadOrPinType copy1_pp;
  PadOrPinType copy2_pp;
  if (! have_two_corresponding_unique_non_coincident(old_element,
                                                     copy_element,
                                                     &old1_pp, &old2_pp,
                                                     &copy1_pp, &copy2_pp)) {
      base_log("Error: Couldn't find two corresponding, unique, "
               "non-coincident element pads/pins.");
      return False;
  }
  replace_one_footprint_aux(old_element, &old1_pp, &old2_pp,
                            copy_element, &copy1_pp, &copy2_pp);
  debug_log("Used quick replacement.\n");
  return True;
}
Beispiel #4
0
static Boolean
replace_one_footprint_expensive(ElementTypePtr old_element,
                                ElementTypePtr new_element)
{
  /* Requires that there be two corresponding, non-coincident
     pads/pins; non-unique pad/pin numbers okay.

     It's expensive because it does an exhaustive comparison of the
     resulting transformations for the four possible 90 degree
     rotations plus combinations of same-numbered pads/pins.  Should
     only be necessary if the element *only* has pads and pins that
     share the same pad/pin number. */
  if (! have_two_corresponding_non_coincident(old_element, new_element,
                                              NULL, NULL, NULL, NULL)) {
    return False;
  }

  /* Create copy of new element. */
  ElementTypePtr copy_element =
    CopyElementLowLevel(PCB->Data, NULL, new_element, False, 0, 0);

  int old_ppd_len = 0;
  ElementPadPinData* old_ppd =
    alloc_pad_pin_data_array(old_element, &old_ppd_len);

  int copy_ppd_len = 0;
  ElementPadPinData* copy_ppd =
    alloc_pad_pin_data_array(copy_element, &copy_ppd_len);

  int copy_index1 = 0;
  int copy_index2 = 0;
  if (! find_non_coincident(copy_ppd, copy_ppd_len,
                            &copy_index1, &copy_index2)) {
    base_log("Error: Couldn't find non-coincident element pads/pins.");
    MYFREE(old_ppd);
    MYFREE(copy_ppd);
    return False;
  }

  Boolean reflect = IS_REFLECTED(new_element, old_element);
  int old_index1 = 0;
  int old_index2 = 0;
  if (! find_best_corresponding_pads_or_pins(copy_ppd, copy_ppd_len,
                                             copy_index1, copy_index2,
                                             reflect,
                                             old_ppd, old_ppd_len,
                                             &old_index1, &old_index2)) {
    MYFREE(old_ppd);
    MYFREE(copy_ppd);
    return False;
  }

  replace_one_footprint_aux(old_element,
                            &old_ppd[old_index1].pp,
                            &old_ppd[old_index2].pp,
                            copy_element,
                            &copy_ppd[copy_index1].pp,
                            &copy_ppd[copy_index2].pp);
  MYFREE(old_ppd);
  MYFREE(copy_ppd);
  debug_log("Used expensive replacement.\n");
  return True;
}
Beispiel #5
0
static void
pinout_set_data (GhidPinoutPreview * pinout, ElementType * element)
{
  gint tx, ty, x_min = 0, y_min = 0;

  if (element == NULL)
    {
      FreeElementMemory (&pinout->element);
      pinout->w_pixels = 0;
      pinout->h_pixels = 0;
      return;
    }

  /* 
   * copy element data 
   * enable output of pin and padnames
   * move element to a 5% offset from zero position
   * set all package lines/arcs to zero width
   */
  CopyElementLowLevel (NULL, &pinout->element, element, FALSE, 0, 0);
  PIN_LOOP (&pinout->element);
  {
    tx = abs (pinout->element.Pin[0].X - pin->X);
    ty = abs (pinout->element.Pin[0].Y - pin->Y);
    if (x_min == 0 || (tx != 0 && tx < x_min))
      x_min = tx;
    if (y_min == 0 || (ty != 0 && ty < y_min))
      y_min = ty;
    SET_FLAG (DISPLAYNAMEFLAG, pin);
  }
  END_LOOP;

  PAD_LOOP (&pinout->element);
  {
    tx = abs (pinout->element.Pad[0].Point1.X - pad->Point1.X);
    ty = abs (pinout->element.Pad[0].Point1.Y - pad->Point1.Y);
    if (x_min == 0 || (tx != 0 && tx < x_min))
      x_min = tx;
    if (y_min == 0 || (ty != 0 && ty < y_min))
      y_min = ty;
    SET_FLAG (DISPLAYNAMEFLAG, pad);
  }
  END_LOOP;


  MoveElementLowLevel (NULL, &pinout->element,
		       Settings.PinoutOffsetX -
		       pinout->element.BoundingBox.X1,
		       Settings.PinoutOffsetY -
		       pinout->element.BoundingBox.Y1);

  if (!pinout_zoom_fit (pinout, 2))
    pinout_zoom_fit (pinout, 3);

  ELEMENTLINE_LOOP (&pinout->element);
  {
    line->Thickness = 0;
  }
  END_LOOP;

  ARC_LOOP (&pinout->element);
  {
    /* 
     * for whatever reason setting a thickness of 0 causes the arcs to
     * not display so pick 1 which does display but is still quite
     * thin.
     */
    arc->Thickness = 1;
  }
  END_LOOP;
}
Beispiel #6
0
/* ---------------------------------------------------------------------------
 * copies a element to buffer
 */
static void *
AddElementToBuffer (ElementType *Element)
{
  return CopyElementLowLevel (Dest, Element, false, 0, 0, NOCOPY_FLAGS | ExtraFlag);
}