Ejemplo n.º 1
0
/* ---------------------------------------------------------------------------
 * draws the attached object while in MOVE_MODE or COPY_MODE
 */
static void
XORDrawMoveOrCopyObject (void)
{
  RubberbandTypePtr ptr;
  Cardinal i;
  LocationType dx = Crosshair.X - Crosshair.AttachedObject.X,
    dy = Crosshair.Y - Crosshair.AttachedObject.Y;

  switch (Crosshair.AttachedObject.Type)
    {
    case VIA_TYPE:
      {
	PinTypePtr via = (PinTypePtr) Crosshair.AttachedObject.Ptr1;

	gui->draw_arc (Crosshair.GC,
		       via->X + dx,
		       via->Y + dy,
		       via->Thickness / 2, via->Thickness / 2, 0, 360);
	break;
      }

    case LINE_TYPE:
      {
	LineTypePtr line = (LineTypePtr) Crosshair.AttachedObject.Ptr2;

	XORDrawAttachedLine (line->Point1.X + dx, line->Point1.Y + dy,
			     line->Point2.X + dx, line->Point2.Y + dy,
			     line->Thickness);
	break;
      }

    case ARC_TYPE:
      {
	ArcTypePtr Arc = (ArcTypePtr) Crosshair.AttachedObject.Ptr2;

	gui->draw_arc (Crosshair.GC,
		       Arc->X + dx,
		       Arc->Y + dy,
		       Arc->Width, Arc->Height, Arc->StartAngle, Arc->Delta);
	break;
      }

    case POLYGON_TYPE:
      {
	PolygonTypePtr polygon =
	  (PolygonTypePtr) Crosshair.AttachedObject.Ptr2;

	/* the tmp polygon has n+1 points because the first
	 * and the last one are set to the same coordinates
	 */
	XORPolygon (polygon, dx, dy);
	break;
      }

    case LINEPOINT_TYPE:
      {
	LineTypePtr line;
	PointTypePtr point;

	line = (LineTypePtr) Crosshair.AttachedObject.Ptr2;
	point = (PointTypePtr) Crosshair.AttachedObject.Ptr3;
	if (point == &line->Point1)
	  XORDrawAttachedLine (point->X + dx,
			       point->Y + dy, line->Point2.X,
			       line->Point2.Y, line->Thickness);
	else
	  XORDrawAttachedLine (point->X + dx,
			       point->Y + dy, line->Point1.X,
			       line->Point1.Y, line->Thickness);
	break;
      }

    case POLYGONPOINT_TYPE:
      {
	PolygonTypePtr polygon;
	PointTypePtr point;
	Cardinal point_idx, prev, next;

	polygon = (PolygonTypePtr) Crosshair.AttachedObject.Ptr2;
	point = (PointTypePtr) Crosshair.AttachedObject.Ptr3;
	point_idx = polygon_point_idx (polygon, point);

	/* get previous and following point */
	prev = prev_contour_point (polygon, point_idx);
	next = next_contour_point (polygon, point_idx);

	/* draw the two segments */
	gui->draw_line (Crosshair.GC,
			polygon->Points[prev].X, polygon->Points[prev].Y,
			point->X + dx, point->Y + dy);
	gui->draw_line (Crosshair.GC,
			point->X + dx, point->Y + dy,
			polygon->Points[next].X, polygon->Points[next].Y);
	break;
      }

    case ELEMENTNAME_TYPE:
      {
	/* locate the element "mark" and draw an association line from crosshair to it */
	ElementTypePtr element =
	  (ElementTypePtr) Crosshair.AttachedObject.Ptr1;

	gui->draw_line (Crosshair.GC,
			element->MarkX,
			element->MarkY, Crosshair.X, Crosshair.Y);
	/* fall through to move the text as a box outline */
      }
    case TEXT_TYPE:
      {
	TextTypePtr text = (TextTypePtr) Crosshair.AttachedObject.Ptr2;
	BoxTypePtr box = &text->BoundingBox;
	gui->draw_rect (Crosshair.GC,
			box->X1 + dx,
			box->Y1 + dy, box->X2 + dx, box->Y2 + dy);
	break;
      }

      /* pin/pad movements result in moving an element */
    case PAD_TYPE:
    case PIN_TYPE:
    case ELEMENT_TYPE:
      XORDrawElement ((ElementTypePtr) Crosshair.AttachedObject.Ptr2, dx, dy);
      break;
    }

  /* draw the attached rubberband lines too */
  i = Crosshair.AttachedObject.RubberbandN;
  ptr = Crosshair.AttachedObject.Rubberband;
  while (i)
    {
      PointTypePtr point1, point2;

      if (TEST_FLAG (VIAFLAG, ptr->Line))
	{
	  /* this is a rat going to a polygon.  do not draw for rubberband */;
	}
      else if (TEST_FLAG (RUBBERENDFLAG, ptr->Line))
	{
	  /* 'point1' is always the fix-point */
	  if (ptr->MovedPoint == &ptr->Line->Point1)
	    {
	      point1 = &ptr->Line->Point2;
	      point2 = &ptr->Line->Point1;
	    }
	  else
	    {
	      point1 = &ptr->Line->Point1;
	      point2 = &ptr->Line->Point2;
	    }
	  XORDrawAttachedLine (point1->X,
			       point1->Y, point2->X + dx,
			       point2->Y + dy, ptr->Line->Thickness);
	}
      else if (ptr->MovedPoint == &ptr->Line->Point1)
	XORDrawAttachedLine (ptr->Line->Point1.X + dx,
			     ptr->Line->Point1.Y + dy,
			     ptr->Line->Point2.X + dx,
			     ptr->Line->Point2.Y + dy, ptr->Line->Thickness);

      ptr++;
      i--;
    }
}
Ejemplo n.º 2
0
/* ---------------------------------------------------------------------------
 * draws additional stuff that follows the crosshair
 */
static void
DrawAttached (bool BlockToo)
{
  BDimension s;
  switch (Settings.Mode)
    {
    case VIA_MODE:
      gui->draw_arc (Crosshair.GC,
		     Crosshair.X,
		     Crosshair.Y,
		     Settings.ViaThickness / 2,
		     Settings.ViaThickness / 2, 0, 360);
      if (TEST_FLAG (SHOWDRCFLAG, PCB))
	{
	  s = Settings.ViaThickness / 2 + PCB->Bloat + 1;
	  gui->set_color (Crosshair.GC, Settings.CrossColor);
	  gui->draw_arc (Crosshair.GC,
			 Crosshair.X, Crosshair.Y, s, s, 0, 360);
	  gui->set_color (Crosshair.GC, Settings.CrosshairColor);
	}
      break;

      /* the attached line is used by both LINEMODE, POLYGON_MODE and POLYGONHOLE_MODE*/
    case POLYGON_MODE:
    case POLYGONHOLE_MODE:
      /* draw only if starting point is set */
      if (Crosshair.AttachedLine.State != STATE_FIRST)
	gui->draw_line (Crosshair.GC,
			Crosshair.AttachedLine.Point1.X,
			Crosshair.AttachedLine.Point1.Y,
			Crosshair.AttachedLine.Point2.X,
			Crosshair.AttachedLine.Point2.Y);

      /* draw attached polygon only if in POLYGON_MODE or POLYGONHOLE_MODE */
      if (Crosshair.AttachedPolygon.PointN > 1)
	{
	  XORPolygon (&Crosshair.AttachedPolygon, 0, 0);
	}
      break;

    case ARC_MODE:
      if (Crosshair.AttachedBox.State != STATE_FIRST)
	{
	  XORDrawAttachedArc (Settings.LineThickness);
	  if (TEST_FLAG (SHOWDRCFLAG, PCB))
	    {
	      gui->set_color (Crosshair.GC, Settings.CrossColor);
	      XORDrawAttachedArc (Settings.LineThickness +
				  2 * (PCB->Bloat + 1));
	      gui->set_color (Crosshair.GC, Settings.CrosshairColor);
	    }

	}
      break;

    case LINE_MODE:
      /* draw only if starting point exists and the line has length */
      if (Crosshair.AttachedLine.State != STATE_FIRST &&
	  Crosshair.AttachedLine.draw)
	{
	  XORDrawAttachedLine (Crosshair.AttachedLine.Point1.X,
			       Crosshair.AttachedLine.Point1.Y,
			       Crosshair.AttachedLine.Point2.X,
			       Crosshair.AttachedLine.Point2.Y,
			       PCB->RatDraw ? 10 : Settings.LineThickness);
	  /* draw two lines ? */
	  if (PCB->Clipping)
	    XORDrawAttachedLine (Crosshair.AttachedLine.Point2.X,
				 Crosshair.AttachedLine.Point2.Y,
				 Crosshair.X, Crosshair.Y,
				 PCB->RatDraw ? 10 : Settings.LineThickness);
	  if (TEST_FLAG (SHOWDRCFLAG, PCB))
	    {
	      gui->set_color (Crosshair.GC, Settings.CrossColor);
	      XORDrawAttachedLine (Crosshair.AttachedLine.Point1.X,
				   Crosshair.AttachedLine.Point1.Y,
				   Crosshair.AttachedLine.Point2.X,
				   Crosshair.AttachedLine.Point2.Y,
				   PCB->RatDraw ? 10 : Settings.LineThickness
				   + 2 * (PCB->Bloat + 1));
	      if (PCB->Clipping)
		XORDrawAttachedLine (Crosshair.AttachedLine.Point2.X,
				     Crosshair.AttachedLine.Point2.Y,
				     Crosshair.X, Crosshair.Y,
				     PCB->RatDraw ? 10 : Settings.
				     LineThickness + 2 * (PCB->Bloat + 1));
	      gui->set_color (Crosshair.GC, Settings.CrosshairColor);
	    }
	}
      break;

    case PASTEBUFFER_MODE:
      XORDrawBuffer (PASTEBUFFER);
      break;

    case COPY_MODE:
    case MOVE_MODE:
      XORDrawMoveOrCopyObject ();
      break;

    case INSERTPOINT_MODE:
      XORDrawInsertPointObject ();
      break;
    }

  /* an attached box does not depend on a special mode */
  if (Crosshair.AttachedBox.State == STATE_SECOND ||
      (BlockToo && Crosshair.AttachedBox.State == STATE_THIRD))
    {
      LocationType x1, y1, x2, y2;

      x1 = Crosshair.AttachedBox.Point1.X;
      y1 = Crosshair.AttachedBox.Point1.Y;
      x2 = Crosshair.AttachedBox.Point2.X;
      y2 = Crosshair.AttachedBox.Point2.Y;
      gui->draw_rect (Crosshair.GC, x1, y1, x2, y2);
    }
}
Ejemplo n.º 3
0
/* ---------------------------------------------------------------------------
 * draws additional stuff that follows the crosshair
 */
void
DrawAttached (void)
{
    switch (Settings.Mode)
    {
    case VIA_MODE:
    {
        /* Make a dummy via structure to draw from */
        PinType via;
        via.X = Crosshair.X;
        via.Y = Crosshair.Y;
        via.Thickness = Settings.ViaThickness;
        via.Clearance = 2 * Settings.Keepaway;
        via.DrillingHole = Settings.ViaDrillingHole;
        via.Mask = 0;
        via.Flags = NoFlags ();

        gui->thindraw_pcb_pv (Crosshair.GC, Crosshair.GC, &via, true, false);

        if (TEST_FLAG (SHOWDRCFLAG, PCB))
        {
            /* XXX: Naughty cheat - use the mask to draw DRC clearance! */
            via.Mask = Settings.ViaThickness + PCB->Bloat * 2;
            gui->set_color (Crosshair.GC, Settings.CrossColor);
            gui->thindraw_pcb_pv (Crosshair.GC, Crosshair.GC, &via, false, true);
            gui->set_color (Crosshair.GC, Settings.CrosshairColor);
        }
        break;
    }

    /* the attached line is used by both LINEMODE, POLYGON_MODE and POLYGONHOLE_MODE*/
    case POLYGON_MODE:
    case POLYGONHOLE_MODE:
        /* draw only if starting point is set */
        if (Crosshair.AttachedLine.State != STATE_FIRST)
            gui->draw_line (Crosshair.GC,
                            Crosshair.AttachedLine.Point1.X,
                            Crosshair.AttachedLine.Point1.Y,
                            Crosshair.AttachedLine.Point2.X,
                            Crosshair.AttachedLine.Point2.Y);

        /* draw attached polygon only if in POLYGON_MODE or POLYGONHOLE_MODE */
        if (Crosshair.AttachedPolygon.PointN > 1)
        {
            XORPolygon (&Crosshair.AttachedPolygon, 0, 0);
        }
        break;

    case ARC_MODE:
        if (Crosshair.AttachedBox.State != STATE_FIRST)
        {
            XORDrawAttachedArc (Settings.LineThickness);
            if (TEST_FLAG (SHOWDRCFLAG, PCB))
            {
                gui->set_color (Crosshair.GC, Settings.CrossColor);
                XORDrawAttachedArc (Settings.LineThickness +
                                    2 * (PCB->Bloat + 1));
                gui->set_color (Crosshair.GC, Settings.CrosshairColor);
            }

        }
        break;

    case LINE_MODE:
        /* draw only if starting point exists and the line has length */
        if (Crosshair.AttachedLine.State != STATE_FIRST &&
                Crosshair.AttachedLine.draw)
        {
            XORDrawAttachedLine (Crosshair.AttachedLine.Point1.X,
                                 Crosshair.AttachedLine.Point1.Y,
                                 Crosshair.AttachedLine.Point2.X,
                                 Crosshair.AttachedLine.Point2.Y,
                                 PCB->RatDraw ? 10 : Settings.LineThickness);
            /* draw two lines ? */
            if (PCB->Clipping)
                XORDrawAttachedLine (Crosshair.AttachedLine.Point2.X,
                                     Crosshair.AttachedLine.Point2.Y,
                                     Crosshair.X, Crosshair.Y,
                                     PCB->RatDraw ? 10 : Settings.LineThickness);
            if (TEST_FLAG (SHOWDRCFLAG, PCB))
            {
                gui->set_color (Crosshair.GC, Settings.CrossColor);
                XORDrawAttachedLine (Crosshair.AttachedLine.Point1.X,
                                     Crosshair.AttachedLine.Point1.Y,
                                     Crosshair.AttachedLine.Point2.X,
                                     Crosshair.AttachedLine.Point2.Y,
                                     PCB->RatDraw ? 10 : Settings.LineThickness
                                     + 2 * (PCB->Bloat + 1));
                if (PCB->Clipping)
                    XORDrawAttachedLine (Crosshair.AttachedLine.Point2.X,
                                         Crosshair.AttachedLine.Point2.Y,
                                         Crosshair.X, Crosshair.Y,
                                         PCB->RatDraw ? 10 : Settings.
                                         LineThickness + 2 * (PCB->Bloat + 1));
                gui->set_color (Crosshair.GC, Settings.CrosshairColor);
            }
        }
        break;

    case PASTEBUFFER_MODE:
        XORDrawBuffer (PASTEBUFFER);
        break;

    case COPY_MODE:
    case MOVE_MODE:
        XORDrawMoveOrCopyObject ();
        break;

    case INSERTPOINT_MODE:
        XORDrawInsertPointObject ();
        break;
    }

    /* an attached box does not depend on a special mode */
    if (Crosshair.AttachedBox.State == STATE_SECOND ||
            Crosshair.AttachedBox.State == STATE_THIRD)
    {
        Coord x1, y1, x2, y2;

        x1 = Crosshair.AttachedBox.Point1.X;
        y1 = Crosshair.AttachedBox.Point1.Y;
        x2 = Crosshair.AttachedBox.Point2.X;
        y2 = Crosshair.AttachedBox.Point2.Y;
        gui->draw_rect (Crosshair.GC, x1, y1, x2, y2);
    }
}