コード例 #1
0
ファイル: move.c プロジェクト: fruoff/pcb-fruoff
/* ---------------------------------------------------------------------------
 * moves a polygon between layers
 */
static void *
MovePolygonToLayer (LayerType *Layer, PolygonType *Polygon)
{
  PolygonTypePtr newone;
  struct mptlc d;

  if (TEST_FLAG (LOCKFLAG, Polygon))
    {
      Message (_("Sorry, the object is locked\n"));
      return NULL;
    }
  if (((long int) Dest == -1) || (Layer == Dest))
    return (Polygon);
  AddObjectToMoveToLayerUndoList (POLYGON_TYPE, Layer, Polygon, Polygon);
  if (Layer->On)
    ErasePolygon (Polygon);
  /* Move all of the thermals with the polygon */
  d.snum = GetLayerNumber (PCB->Data, Layer);
  d.dnum = GetLayerNumber (PCB->Data, Dest);
  d.polygon = Polygon;
  d.type = PIN_TYPE;
  r_search (PCB->Data->pin_tree, &Polygon->BoundingBox, NULL, mptl_pin_callback, &d);
  d.type = VIA_TYPE;
  r_search (PCB->Data->via_tree, &Polygon->BoundingBox, NULL, mptl_pin_callback, &d);
  newone = (struct polygon_st *)MovePolygonToLayerLowLevel (Layer, Polygon, Dest);
  InitClip (PCB->Data, Dest, newone);
  if (Dest->On)
    {
      DrawPolygon (Dest, newone);
      Draw ();
    }
  return (newone);
}
コード例 #2
0
ファイル: clip.c プロジェクト: descent/twin
int main(int argc, char *argv[]) {
    tmsg Msg;
    udat Code;
    uldat err, WinN = 1;
    
    if (InitClip()) while ((Msg=TwReadMsg(TRUE))) {
	if (Msg->Type==TW_MSG_WIDGET_KEY) {
	    
	    tevent_keyboard EventK = &Msg->Event.EventKeyboard;
	    Code=EventK->Code;
	    (void)TwWriteAsciiWindow(EventK->W, EventK->SeqLen, EventK->AsciiSeq);
	    
	} else if (Msg->Type==TW_MSG_SELECTION) {
	    /*
	     * send Msg->Event.EventSelection.Window as ReqPrivate field,
	     * so that we will get it back in TW_MSG_SELECTIONNOTIFY message
	     * without having to store it manually
	     */
	    TwRequestSelection(TwGetOwnerSelection(), Msg->Event.EventSelection.W);
	    
	} else if (Msg->Type==TW_MSG_SELECTIONNOTIFY) {
	    
	    tevent_selectionnotify EventN = &Msg->Event.EventSelectionNotify;
	    if (EventN->Magic == TW_SEL_TEXTMAGIC)
		(void)TwWriteAsciiWindow(EventN->ReqPrivate, EventN->Len, EventN->Data);
	    
	} else if (Msg->Type==TW_MSG_SELECTIONCLEAR) {
	    ;
	} else if (Msg->Type==TW_MSG_WIDGET_GADGET) {
	    
	    tevent_gadget EventG = &Msg->Event.EventGadget;
	    if (EventG->Code == 0 && EventG->W == Clip_Win) {
		TwUnMapWindow(Clip_Win);
		TwDeleteWindow(Clip_Win);
		if (!--WinN)
		    break;
	    }
	}
    }
    if ((err = TwErrno))
	fprintf(stderr, "%s: libTw error: %s%s\n", argv[0],
		TwStrError(err), TwStrErrorDetail(err, TwErrnoDetail));
    
    if (!TwInPanic()) {
	/* these are not strictly necessary, as the server would cleanup by itself... */
	TwDeleteMenu(Clip_Menu);
	TwDeleteMsgPort(Clip_MsgPort);
	TwClose();
	return 0;
    }
    return 1;
}
コード例 #3
0
ファイル: remove.c プロジェクト: bert/pcb-rnd
/* ---------------------------------------------------------------------------
 * removes a polygon-point from a polygon
 */
static void *
RemovePolygonPoint (LayerTypePtr Layer,
		    PolygonTypePtr Polygon, PointTypePtr Point)
{
  Cardinal point_idx;
  Cardinal i;
  Cardinal contour;
  Cardinal contour_start, contour_end, contour_points;

  point_idx = polygon_point_idx (Polygon, Point);
  contour = polygon_point_contour (Polygon, point_idx);
  contour_start = (contour == 0) ? 0 : Polygon->HoleIndex[contour - 1];
  contour_end = (contour == Polygon->HoleIndexN) ? Polygon->PointN :
                                                   Polygon->HoleIndex[contour];
  contour_points = contour_end - contour_start;

  if (contour_points <= 3)
    return RemovePolygonContour (Layer, Polygon, contour);

  if (Layer->On)
    ErasePolygon (Polygon);

  /* insert the polygon-point into the undo list */
  AddObjectToRemovePointUndoList (POLYGONPOINT_TYPE, Layer, Polygon, point_idx);
  r_delete_entry (Layer->polygon_tree, (BoxType *) Polygon);

  /* remove point from list, keep point order */
  for (i = point_idx; i < Polygon->PointN - 1; i++)
    Polygon->Points[i] = Polygon->Points[i + 1];
  Polygon->PointN--;

  /* Shift down indices of any holes */
  for (i = 0; i < Polygon->HoleIndexN; i++)
    if (Polygon->HoleIndex[i] > point_idx)
      Polygon->HoleIndex[i]--;

  SetPolygonBoundingBox (Polygon);
  r_insert_entry (Layer->polygon_tree, (BoxType *) Polygon, 0);
  RemoveExcessPolygonPoints (Layer, Polygon);
  InitClip (PCB->Data, Layer, Polygon);

  /* redraw polygon if necessary */
  if (Layer->On)
    {
      DrawPolygon (Layer, Polygon);
      if (!Bulk)
	Draw ();
    }
  return NULL;
}
コード例 #4
0
ファイル: insert.c プロジェクト: thequux/pcb
/* ---------------------------------------------------------------------------
 * inserts a point into a polygon
 */
static void *
InsertPointIntoPolygon (LayerTypePtr Layer, PolygonTypePtr Polygon)
{
  PointType save;
  Cardinal n;
  LineType line;

  if (!Forcible)
    {
      /*
       * first make sure adding the point is sensible
       */
      line.Thickness = 0;
      line.Point1 = Polygon->Points[prev_contour_point (Polygon, InsertAt)];
      line.Point2 = Polygon->Points[InsertAt];
      if (IsPointOnLine ((float) InsertX, (float) InsertY, 0.0, &line))
	return (NULL);
    }
  /*
   * second, shift the points up to make room for the new point
   */
  ErasePolygon (Polygon);
  r_delete_entry (Layer->polygon_tree, (BoxTypePtr) Polygon);
  save = *CreateNewPointInPolygon (Polygon, InsertX, InsertY);
  for (n = Polygon->PointN - 1; n > InsertAt; n--)
    Polygon->Points[n] = Polygon->Points[n - 1];

  /* Shift up indices of any holes */
  for (n = 0; n < Polygon->HoleIndexN; n++)
    if (Polygon->HoleIndex[n] > InsertAt ||
	(InsertLast && Polygon->HoleIndex[n] == InsertAt))
      Polygon->HoleIndex[n]++;

  Polygon->Points[InsertAt] = save;
  SetChangedFlag (true);
  AddObjectToInsertPointUndoList (POLYGONPOINT_TYPE, Layer, Polygon,
				  &Polygon->Points[InsertAt]);

  SetPolygonBoundingBox (Polygon);
  r_insert_entry (Layer->polygon_tree, (BoxType *) Polygon, 0);
  InitClip (PCB->Data, Layer, Polygon);
  if (Forcible || !RemoveExcessPolygonPoints (Layer, Polygon))
    {
      DrawPolygon (Layer, Polygon, 0);
      Draw ();
    }
  return (&Polygon->Points[InsertAt]);
}
コード例 #5
0
ファイル: copy.c プロジェクト: bgamari/geda-pcb
/* ---------------------------------------------------------------------------
 * copies a polygon 
 */
static void *
CopyPolygon (LayerType *Layer, PolygonType *Polygon)
{
  PolygonType *polygon;

  polygon = CreateNewPolygon (Layer, NoFlags ());
  CopyPolygonLowLevel (polygon, Polygon);
  MovePolygonLowLevel (polygon, DeltaX, DeltaY);
  if (!Layer->polygon_tree)
    Layer->polygon_tree = r_create_tree (NULL, 0, 0);
  r_insert_entry (Layer->polygon_tree, (BoxType *) polygon, 0);
  InitClip (PCB->Data, Layer, polygon);
  DrawPolygon (Layer, polygon);
  AddObjectToCreateUndoList (POLYGON_TYPE, Layer, polygon, polygon);
  return (polygon);
}
コード例 #6
0
ファイル: autocrop.c プロジェクト: bert/pcb-plugins
static void *
MyMovePolygonLowLevel (DataType *Data, LayerType *Layer, PolygonType *Polygon, Coord dx, Coord dy)
{
  if (Data)
  {
    r_delete_entry (Layer->polygon_tree, (BoxType *) Polygon);
  }
  /* move.c actually only moves points, note no Data/Layer args */
  MovePolygonLowLevel (Polygon, dx, dy);
  if (Data)
  {
    r_insert_entry (Layer->polygon_tree, (BoxType *) Polygon, 0);
    InitClip(Data, Layer, Polygon);
  }
  return Polygon;
}
コード例 #7
0
ファイル: remove.c プロジェクト: bert/pcb-rnd
/* ---------------------------------------------------------------------------
 * removes a contour from a polygon.
 * If removing the outer contour, it removes the whole polygon.
 */
static void *
RemovePolygonContour (LayerTypePtr Layer,
                      PolygonTypePtr Polygon,
                      Cardinal contour)
{
  Cardinal contour_start, contour_end, contour_points;
  Cardinal i;

  if (contour == 0)
    return RemovePolygon (Layer, Polygon);

  if (Layer->On)
    {
      ErasePolygon (Polygon);
      if (!Bulk)
        Draw ();
    }

  /* Copy the polygon to the undo list */
  AddObjectToRemoveContourUndoList (POLYGON_TYPE, Layer, Polygon);

  contour_start = (contour == 0) ? 0 : Polygon->HoleIndex[contour - 1];
  contour_end = (contour == Polygon->HoleIndexN) ? Polygon->PointN :
                                                   Polygon->HoleIndex[contour];
  contour_points = contour_end - contour_start;

  /* remove points from list, keep point order */
  for (i = contour_start; i < Polygon->PointN - contour_points; i++)
    Polygon->Points[i] = Polygon->Points[i + contour_points];
  Polygon->PointN -= contour_points;

  /* remove hole from list and shift down remaining indices */
  for (i = contour; i < Polygon->HoleIndexN; i++)
    Polygon->HoleIndex[i - 1] = Polygon->HoleIndex[i] - contour_points;
  Polygon->HoleIndexN--;

  InitClip (PCB->Data, Layer, Polygon);
  /* redraw polygon if necessary */
  if (Layer->On)
    {
      DrawPolygon (Layer, Polygon);
      if (!Bulk)
        Draw ();
    }
  return NULL;
}
コード例 #8
0
ファイル: move.c プロジェクト: fruoff/pcb-fruoff
/* ---------------------------------------------------------------------------
 * moves a polygon
 */
static void *
MovePolygon (LayerTypePtr Layer, PolygonTypePtr Polygon)
{
  if (Layer->On)
    {
      ErasePolygon (Polygon);
    }
  r_delete_entry (Layer->polygon_tree, (BoxType *)Polygon);
  MovePolygonLowLevel (Polygon, DeltaX, DeltaY);
  r_insert_entry (Layer->polygon_tree, (BoxType *)Polygon, 0);
  InitClip (PCB->Data, Layer, Polygon);
  if (Layer->On)
    {
      DrawPolygon (Layer, Polygon);
      Draw ();
    }
  return (Polygon);
}
コード例 #9
0
ファイル: move.c プロジェクト: fruoff/pcb-fruoff
/* ---------------------------------------------------------------------------
 * moves a polygon-point
 */
static void *
MovePolygonPoint (LayerTypePtr Layer, PolygonTypePtr Polygon,
		  PointTypePtr Point)
{
  if (Layer->On)
    {
      ErasePolygon (Polygon);
    }
  r_delete_entry (Layer->polygon_tree, (BoxType *)Polygon);
  MOVE (Point->X, Point->Y, DeltaX, DeltaY);
  SetPolygonBoundingBox (Polygon);
  r_insert_entry (Layer->polygon_tree, (BoxType *)Polygon, 0);
  RemoveExcessPolygonPoints (Layer, Polygon);
  InitClip (PCB->Data, Layer, Polygon);
  if (Layer->On)
    {
      DrawPolygon (Layer, Polygon);
      Draw ();
    }
  return (Point);
}
コード例 #10
0
ファイル: remove.c プロジェクト: bert/pcb-rnd
/* ---------------------------------------------------------------------------
 * removes a polygon-point from a polygon and destroys the data
 */
static void *
DestroyPolygonPoint (LayerTypePtr Layer,
		     PolygonTypePtr Polygon, PointTypePtr Point)
{
  Cardinal point_idx;
  Cardinal i;
  Cardinal contour;
  Cardinal contour_start, contour_end, contour_points;

  point_idx = polygon_point_idx (Polygon, Point);
  contour = polygon_point_contour (Polygon, point_idx);
  contour_start = (contour == 0) ? 0 : Polygon->HoleIndex[contour - 1];
  contour_end = (contour == Polygon->HoleIndexN) ? Polygon->PointN :
                                                   Polygon->HoleIndex[contour];
  contour_points = contour_end - contour_start;

  if (contour_points <= 3)
    return RemovePolygonContour (Layer, Polygon, contour);

  r_delete_entry (Layer->polygon_tree, (BoxType *) Polygon);

  /* remove point from list, keep point order */
  for (i = point_idx; i < Polygon->PointN - 1; i++)
    Polygon->Points[i] = Polygon->Points[i + 1];
  Polygon->PointN--;

  /* Shift down indices of any holes */
  for (i = 0; i < Polygon->HoleIndexN; i++)
    if (Polygon->HoleIndex[i] > point_idx)
      Polygon->HoleIndex[i]--;

  SetPolygonBoundingBox (Polygon);
  r_insert_entry (Layer->polygon_tree, (BoxType *) Polygon, 0);
  InitClip (PCB->Data, Layer, Polygon);
  return (Polygon);
}