Beispiel #1
0
/* ---------------------------------------------------------------------------
 * inserts a point into a rat-line
 */
static void *
InsertPointIntoRat (RatTypePtr Rat)
{
  LineTypePtr newone;

  newone = CreateDrawnLineOnLayer (CURRENT, Rat->Point1.X, Rat->Point1.Y,
				InsertX, InsertY, Settings.LineThickness,
				2 * Settings.Keepaway, Rat->Flags);
  if (!newone)
    return newone;
  AddObjectToCreateUndoList (LINE_TYPE, CURRENT, newone, newone);
  EraseRat (Rat);
  DrawLine (CURRENT, newone, 0);
  newone = CreateDrawnLineOnLayer (CURRENT, Rat->Point2.X, Rat->Point2.Y,
				InsertX, InsertY, Settings.LineThickness,
				2 * Settings.Keepaway, Rat->Flags);
  if (newone)
    {
      AddObjectToCreateUndoList (LINE_TYPE, CURRENT, newone, newone);
      DrawLine (CURRENT, newone, 0);
    }
  MoveObjectToRemoveUndoList (RATLINE_TYPE, Rat, Rat, Rat);
  Draw ();
  return (newone);
}
Beispiel #2
0
/* ---------------------------------------------------------------------------
 * inserts a point into a line
 */
static void *
InsertPointIntoLine (LayerTypePtr Layer, LineTypePtr Line)
{
  LineTypePtr line;
  LocationType X, Y;

  if (((Line->Point1.X == InsertX) && (Line->Point1.Y == InsertY)) ||
      ((Line->Point2.X == InsertX) && (Line->Point2.Y == InsertY)))
    return (NULL);
  X = Line->Point2.X;
  Y = Line->Point2.Y;
  AddObjectToMoveUndoList (LINEPOINT_TYPE, Layer, Line, &Line->Point2,
			   InsertX - X, InsertY - Y);
  EraseLine (Line);
  r_delete_entry (Layer->line_tree, (BoxTypePtr) Line);
  Line->Point2.X = InsertX;
  Line->Point2.Y = InsertY;
  SetLineBoundingBox (Line);
  r_insert_entry (Layer->line_tree, (BoxTypePtr) Line, 0);
  DrawLine (Layer, Line, 0);
  /* we must create after playing with Line since creation may
   * invalidate the line pointer
   */
  if ((line = CreateDrawnLineOnLayer (Layer, InsertX, InsertY,
				      X, Y,
				      Line->Thickness, Line->Clearance,
				      Line->Flags)))
    {
      AddObjectToCreateUndoList (LINE_TYPE, Layer, line, line);
      DrawLine (Layer, line, 0);
      /* creation call adds it to the rtree */
    }
  Draw ();
  return (line);
}
Beispiel #3
0
/* ---------------------------------------------------------------------------
 * copies a line 
 */
static void *
CopyLine (LayerType *Layer, LineType *Line)
{
  LineType *line;

  line = CreateDrawnLineOnLayer (Layer, Line->Point1.X + DeltaX,
				 Line->Point1.Y + DeltaY,
				 Line->Point2.X + DeltaX,
				 Line->Point2.Y + DeltaY, Line->Thickness,
				 Line->Clearance,
				 MaskFlags (Line->Flags, NOCOPY_FLAGS));
  if (!line)
    return (line);
  if (Line->Number)
    line->Number = strdup (Line->Number);
  DrawLine (Layer, line);
  AddObjectToCreateUndoList (LINE_TYPE, Layer, line, line);
  return (line);
}
Beispiel #4
0
/* ---------------------------------------------------------------------------
 * copies a line 
 */
static void *
CopyLine (LayerTypePtr Layer, LineTypePtr Line)
{
  LineTypePtr line;

  line = CreateDrawnLineOnLayer (Layer, Line->Point1.X + DeltaX,
				 Line->Point1.Y + DeltaY,
				 Line->Point2.X + DeltaX,
				 Line->Point2.Y + DeltaY, Line->Thickness,
				 Line->Clearance,
				 MaskFlags (Line->Flags, FOUNDFLAG));
  if (!line)
    return (line);
  if (Line->Number)
    line->Number = MyStrdup (Line->Number, "CopyLine");
  DrawLine (Layer, line, 0);
  AddObjectToCreateUndoList (LINE_TYPE, Layer, line, line);
  return (line);
}
Beispiel #5
0
static int
FontEdit (int argc, char **argv, Coord Ux, Coord Uy) {
    FontType *font;
    SymbolType *symbol;
    LayerType *lfont, *lorig, *lwidth, *lgrid;
    int s, l;

    if (hid_actionl ("New", "Font", 0)) {
        return 1;
    }

    Settings.grid_unit = get_unit_struct("mil");
    Settings.Bloat = PCB->Bloat = 1;
    Settings.Shrink = PCB->Shrink = 1;
    Settings.minWid = PCB->minWid = 1;
    Settings.minSlk = PCB->minSlk = 1;
    MoveLayerToGroup (max_copper_layer + TOP_SILK_LAYER, 0);
    MoveLayerToGroup (max_copper_layer + BOTTOM_SILK_LAYER, 1);

    while (PCB->Data->LayerN > 4) {
        MoveLayer (4, -1);
    }

    for (l = 0; l < 4; l++) {
        MoveLayerToGroup (l, l);
    }

    PCB->MaxWidth = CELL_SIZE * 18;
    PCB->MaxHeight = CELL_SIZE * ((MAX_FONTPOSITION + 15) / 16 + 2);
    PCB->Grid = MIL_TO_COORD (5);
    PCB->Data->Layer[0].Name = strdup ("Font");
    PCB->Data->Layer[1].Name = strdup ("OrigFont");
    PCB->Data->Layer[2].Name = strdup ("Width");
    PCB->Data->Layer[3].Name = strdup ("Grid");
    hid_action ("PCBChanged");
    hid_action ("LayersChanged");
    lfont = PCB->Data->Layer + 0;
    lorig = PCB->Data->Layer + 1;
    lwidth = PCB->Data->Layer + 2;
    lgrid = PCB->Data->Layer + 3;
    font = &PCB->Font;

    for (s = 0; s <= MAX_FONTPOSITION; s++) {
        Coord ox = (s % 16 + 1) * CELL_SIZE;
        Coord oy = (s / 16 + 1) * CELL_SIZE;
        Coord w, miny, maxy, maxx = 0;
        symbol = &font->Symbol[s];
        miny = MIL_TO_COORD (5);
        maxy = font->MaxHeight;

        for (l = 0; l < symbol->LineN; l++) {
            CreateDrawnLineOnLayer (lfont,
                                    symbol->Line[l].Point1.X + ox,
                                    symbol->Line[l].Point1.Y + oy,
                                    symbol->Line[l].Point2.X + ox,
                                    symbol->Line[l].Point2.Y + oy,
                                    symbol->Line[l].Thickness,
                                    symbol->Line[l].Thickness, NoFlags ());
            CreateDrawnLineOnLayer (lorig, symbol->Line[l].Point1.X + ox,
                                    symbol->Line[l].Point1.Y + oy,
                                    symbol->Line[l].Point2.X + ox,
                                    symbol->Line[l].Point2.Y + oy,
                                    symbol->Line[l].Thickness,
                                    symbol->Line[l].Thickness, NoFlags ());

            if (maxx < symbol->Line[l].Point1.X) {
                maxx = symbol->Line[l].Point1.X;
            }

            if (maxx < symbol->Line[l].Point2.X) {
                maxx = symbol->Line[l].Point2.X;
            }
        }

        w = maxx + symbol->Delta + ox;
        CreateDrawnLineOnLayer (lwidth,
                                w, miny + oy,
                                w, maxy + oy, MIL_TO_COORD (1), MIL_TO_COORD (1), NoFlags ());
    }

    for (l = 0; l < 16; l++) {
        int x = (l + 1) * CELL_SIZE;
        CreateDrawnLineOnLayer (lgrid, x, 0, x, PCB->MaxHeight, MIL_TO_COORD (1),
                                MIL_TO_COORD (1), NoFlags ());
    }

    for (l = 0; l <= MAX_FONTPOSITION / 16 + 1; l++) {
        int y = (l + 1) * CELL_SIZE;
        CreateDrawnLineOnLayer (lgrid, 0, y, PCB->MaxWidth, y, MIL_TO_COORD (1),
                                MIL_TO_COORD (1), NoFlags ());
    }

    return 0;
}
Beispiel #6
0
static int
FontEdit (int argc, char **argv, int Ux, int Uy)
{
  FontType *font;
  SymbolType *symbol;
  LayerTypePtr lfont, lorig, lwidth, lgrid;
  int s, l;

  if (hid_actionl ("New", "Font", 0))
    return 1;

  while (PCB->Data->LayerN > 4)
    MoveLayer (4, -1);
  for (l = 0; l < 4; l++)
    {
      MoveLayerToGroup (l, l);
    }
  PCB->MaxWidth = CELL_SIZE * 18;
  PCB->MaxHeight = CELL_SIZE * ((MAX_FONTPOSITION + 15) / 16 + 2);
  PCB->Grid = 500.0;
  PCB->Data->Layer[0].Name = MyStrdup ("Font", "FontEdit");
  PCB->Data->Layer[1].Name = MyStrdup ("OrigFont", "FontEdit");
  PCB->Data->Layer[2].Name = MyStrdup ("Width", "FontEdit");
  PCB->Data->Layer[3].Name = MyStrdup ("Grid", "FontEdit");
  hid_action ("PCBChanged");
  hid_action ("LayersChanged");

  lfont = PCB->Data->Layer + 0;
  lorig = PCB->Data->Layer + 1;
  lwidth = PCB->Data->Layer + 2;
  lgrid = PCB->Data->Layer + 3;

  font = &PCB->Font;
  for (s = 0; s <= MAX_FONTPOSITION; s++)
    {
      int ox = (s % 16 + 1) * CELL_SIZE;
      int oy = (s / 16 + 1) * CELL_SIZE;
      int w, miny, maxy, maxx = 0;

      symbol = &font->Symbol[s];

      miny = 500;
      maxy = font->MaxHeight;

      for (l = 0; l < symbol->LineN; l++)
	{
	  CreateDrawnLineOnLayer (lfont,
				  symbol->Line[l].Point1.X + ox,
				  symbol->Line[l].Point1.Y + oy,
				  symbol->Line[l].Point2.X + ox,
				  symbol->Line[l].Point2.Y + oy,
				  symbol->Line[l].Thickness,
				  symbol->Line[l].Thickness, NoFlags ());
	  CreateDrawnLineOnLayer (lorig, symbol->Line[l].Point1.X + ox,
				  symbol->Line[l].Point1.Y + oy,
				  symbol->Line[l].Point2.X + ox,
				  symbol->Line[l].Point2.Y + oy,
				  symbol->Line[l].Thickness,
				  symbol->Line[l].Thickness, NoFlags ());
	  if (maxx < symbol->Line[l].Point1.X)
	    maxx = symbol->Line[l].Point1.X;
	  if (maxx < symbol->Line[l].Point2.X)
	    maxx = symbol->Line[l].Point2.X;
	}
      w = maxx + symbol->Delta + ox;
      CreateDrawnLineOnLayer (lwidth,
			      w, miny + oy,
			      w, maxy + oy, 100, 100, NoFlags ());
    }

  for (l = 0; l < 16; l++)
    {
      int x = (l + 1) * CELL_SIZE;
      CreateDrawnLineOnLayer (lgrid, x, 0, x, PCB->MaxHeight, 100, 100,
			      NoFlags ());
    }
  for (l = 0; l <= MAX_FONTPOSITION / 16 + 1; l++)
    {
      int y = (l + 1) * CELL_SIZE;
      CreateDrawnLineOnLayer (lgrid, 0, y, PCB->MaxWidth, y, 100, 100,
			      NoFlags ());
    }
  return 0;
}