Esempio n. 1
0
u8 Get_RA_LDPC_8812(struct sta_info *psta)
{
	uint8_t	bLDPC = 0;

	if (psta->mac_id == 1)
		bLDPC = 0;
	else
		if (psta != NULL) {
#ifdef CONFIG_80211AC_VHT
			if (IsSupportedVHT(psta->wireless_mode)) {
				if (TEST_FLAG(psta->vhtpriv.ldpc_cap, LDPC_VHT_CAP_TX))
					bLDPC = 1;
				else
					bLDPC = 0;
			} else
				if (IsSupportedTxHT(psta->wireless_mode)) {
					if (TEST_FLAG(psta->htpriv.ldpc_cap, LDPC_HT_CAP_TX))
						bLDPC = 1;
					else
						bLDPC = 0;
				} else
#endif
				bLDPC = 0;
	}

	return (bLDPC << 2);
}
Esempio n. 2
0
static int
name_callback (const BoxType * box, void *cl)
{
  TextTypePtr text = (TextTypePtr) box;
  struct ans_info *i = (struct ans_info *) cl;
  ElementTypePtr element = (ElementTypePtr) text->Element;
  double newarea;

  if (TEST_FLAG (i->locked, text))
    return 0;

  if ((FRONT (element) || i->BackToo) && !TEST_FLAG (HIDENAMEFLAG, element) &&
      POINT_IN_BOX (PosX, PosY, &text->BoundingBox))
    {
      /* use the text with the smallest bounding box */
      newarea = (text->BoundingBox.X2 - text->BoundingBox.X1) *
	(double) (text->BoundingBox.Y2 - text->BoundingBox.Y1);
      if (newarea < i->area)
	{
	  i->area = newarea;
	  *i->ptr1 = element;
	  *i->ptr2 = *i->ptr3 = text;
	}
      return 1;
    }
  return 0;
}
Esempio n. 3
0
File: gui-misc.c Progetto: bert/pcb
/* ---------------------------------------------------------------------------
 * output of status line
 */
void
ghid_set_status_line_label (void)
{
  gchar *flag = TEST_FLAG (ALLDIRECTIONFLAG, PCB)
                ? "all"
                : (PCB->Clipping == 0
                    ? "45"
                    : (PCB->Clipping == 1
                      ? "45_/"
                      : "45\\_"));
  gchar *text = pcb_g_strdup_printf (
        _("%m+<b>view</b>=%s  "
          "<b>grid</b>=%$mS  "
          "%s%s  "
          "<b>line</b>=%mS  "
          "<b>via</b>=%mS (%mS)  %s"
          "<b>clearance</b>=%mS  "
          "<b>text</b>=%i%%  "
          "<b>buffer</b>=#%i"),
      Settings.grid_unit->allow,
      Settings.ShowBottomSide ? C_("status", "bottom") : C_("status", "top"),
      PCB->Grid,
      flag, TEST_FLAG (RUBBERBANDFLAG, PCB) ? ",R  " : "  ",
      Settings.LineThickness,
      Settings.ViaThickness,
      Settings.ViaDrillingHole,
      ghidgui->compact_horizontal ? "\n" : "",
      Settings.Keepaway,
      Settings.TextScale, Settings.BufferNumber + 1);

  ghid_status_line_set_text (text);
  g_free (text);
}
Esempio n. 4
0
static int
rat_callback (const BoxType * b, void *cl)
{
  RatType *rat = (RatType *)b;

  set_object_color ((AnyObjectType *) rat, NULL, PCB->RatSelectedColor,
                    PCB->ConnectedColor, PCB->FoundColor, PCB->RatColor);

  if (Settings.RatThickness < 100)
    rat->Thickness = pixel_slop * Settings.RatThickness;
  /* rats.c set VIAFLAG if this rat goes to a containing poly: draw a donut */
  if (TEST_FLAG(VIAFLAG, rat))
    {
      int w = rat->Thickness;

      if (TEST_FLAG (THINDRAWFLAG, PCB))
        gui->graphics->set_line_width (Output.fgGC, 0);
      else
        gui->graphics->set_line_width (Output.fgGC, w);
      gui->graphics->draw_arc (Output.fgGC, rat->Point1.X, rat->Point1.Y,
                               w * 2, w * 2, 0, 360);
    }
  else
    gui->graphics->draw_pcb_line (Output.fgGC, (LineType *) rat);
  return 1;
}
Esempio n. 5
0
/* ---------------------------------------------------------------------------
 * draws solder mask layer - this will cover nearly everything
 */
void
DrawMask (int side, const BoxType *screen)
{
  int thin = TEST_FLAG(THINDRAWFLAG, PCB) || TEST_FLAG(THINDRAWPOLYFLAG, PCB);

  if (thin)
    gui->graphics->set_color (Output.pmGC, PCB->MaskColor);
  else
    {
      DrawMaskBoardArea (HID_MASK_BEFORE, screen);
      gui->graphics->use_mask (HID_MASK_CLEAR);
    }

  r_search (PCB->Data->pin_tree, screen, NULL, clearPin_callback, NULL);
  r_search (PCB->Data->via_tree, screen, NULL, clearPin_callback, NULL);
  r_search (PCB->Data->pad_tree, screen, NULL, clearPad_callback, &side);

  if (thin)
    gui->graphics->set_color (Output.pmGC, "erase");
  else
    {
      DrawMaskBoardArea (HID_MASK_AFTER, screen);
      gui->graphics->use_mask (HID_MASK_OFF);
    }
}
Esempio n. 6
0
/* ---------------------------------------------------------------------------
 * draw a via object
 */
void
DrawVia (PinType *Via)
{
  AddPart (Via);
  if (!TEST_FLAG (HOLEFLAG, Via) && TEST_FLAG (DISPLAYNAMEFLAG, Via))
    DrawViaName (Via);
}
void
Set_RA_LDPC_8812(
	struct sta_info	*psta,
	BOOLEAN			bLDPC
	)
{
	if(psta == NULL)
		return;
#ifdef CONFIG_80211AC_VHT
	if(psta->wireless_mode == WIRELESS_11_5AC)
	{
		if(bLDPC && TEST_FLAG(psta->vhtpriv.ldpc_cap, LDPC_VHT_CAP_TX))
			SET_FLAG(psta->vhtpriv.ldpc_cap, LDPC_VHT_ENABLE_TX);
		else
			CLEAR_FLAG(psta->vhtpriv.ldpc_cap, LDPC_VHT_ENABLE_TX);
	}
	else if(IsSupportedTxHT(psta->wireless_mode) || IsSupportedVHT(psta->wireless_mode))
	{
		if(bLDPC && TEST_FLAG(psta->htpriv.ldpc_cap, LDPC_HT_CAP_TX))
			SET_FLAG(psta->htpriv.ldpc_cap, LDPC_HT_ENABLE_TX);
		else
			CLEAR_FLAG(psta->htpriv.ldpc_cap, LDPC_HT_ENABLE_TX);
	}
#endif

	//DBG_871X("MacId %d bLDPC %d\n", psta->mac_id, bLDPC);
}
Esempio n. 8
0
/* ---------------------------------------------------------------------------
 * draw a pin object
 */
void
DrawPin (PinType *Pin)
{
  AddPart (Pin);
  if ((!TEST_FLAG (HOLEFLAG, Pin) && TEST_FLAG (DISPLAYNAMEFLAG, Pin))
      || doing_pinout)
    DrawPinName (Pin);
}
Esempio n. 9
0
Boolean
__indexable( Association_Mode* the_assoc, char* file, int line )
{
  if( !the_assoc )
    CHILLEXCEPTION( file, line, EMPTY, NULL_ASSOCIATION );
  if( !TEST_FLAG(the_assoc, IO_ISASSOCIATED) )
    CHILLEXCEPTION( file, line, NOTASSOCIATED, IS_NOT_ASSOCIATED );
  return TEST_FLAG(the_assoc, IO_INDEXABLE) ? True : False;
}
Esempio n. 10
0
static int
FlagElementName (void  *data)
{
  if (TEST_FLAG (NAMEONPCBFLAG, PCB))
    return 2;
  if (TEST_FLAG (DESCRIPTIONFLAG, PCB))
    return 1;
  return 3;
}
Esempio n. 11
0
static int
clearPin_callback (const BoxType * b, void *cl)
{
  PinType *pin = (PinType *) b;
  if (TEST_FLAG (THINDRAWFLAG, PCB) || TEST_FLAG (THINDRAWPOLYFLAG, PCB))
    gui->graphics->thindraw_pcb_pv (Output.pmGC, Output.pmGC, pin, false, true);
  else
    gui->graphics->fill_pcb_pv (Output.pmGC, Output.pmGC, pin, false, true);
  return 1;
}
Esempio n. 12
0
/* ---------------------------------------------------------------------------
 * output of status line
 */
void
ghid_set_status_line_label (void)
{
  gchar text[512];

  if (!Settings.grid_units_mm)
    snprintf (text, sizeof (text),
	      _("<b>%c  view</b>=%s  "
		"<b>grid</b>=%.1f:%i  "
		"%s%s  "
		"<b>line</b>=%.1f  "
		"<b>via</b>=%.1f(%.1f)  %s"
		"<b>clearance</b>=%.1f  "
		"<b>text</b>=%i%%  "
		"<b>buffer</b>=#%i"),
	      PCB->Changed ? '*' : ' ',
	      Settings.ShowSolderSide ? _("solder") : _("component"),
	      PCB->Grid / 100.0,
	      (int) Settings.GridFactor,
	      TEST_FLAG (ALLDIRECTIONFLAG, PCB) ? "all" :
	      (PCB->Clipping == 0 ? "45" :
	       (PCB->Clipping == 1 ? "45_/" : "45\\_")),
	      TEST_FLAG (RUBBERBANDFLAG, PCB) ? ",R  " : "  ",
	      Settings.LineThickness / 100.0,
	      Settings.ViaThickness / 100.0,
	      Settings.ViaDrillingHole / 100.0,
	      ghidgui->compact_horizontal ? "\n" : "",
	      Settings.Keepaway / 100.0,
	      Settings.TextScale, Settings.BufferNumber + 1);
  else
    snprintf (text, sizeof (text),
	      _("<b>%c  view</b>=%s  "
		"<b>grid</b>=%5.3f:%i  "
		"%s%s  "
		"<b>line</b>=%5.3f  "
		"<b>via</b>=%5.3f(%5.3f)  %s"
		"<b>clearance</b>=%5.3f  "
		"<b>text</b>=%i%%  "
		"<b>buffer</b>=#%i"),
	      PCB->Changed ? '*' : ' ',
	      Settings.ShowSolderSide ? _("solder") : _("component"),
	      PCB->Grid * COOR_TO_MM, (int) Settings.GridFactor,
	      TEST_FLAG (ALLDIRECTIONFLAG, PCB) ? "all" :
	      (PCB->Clipping == 0 ? "45" :
	       (PCB->Clipping == 1 ? "45_/" : "45\\_")),
	      TEST_FLAG (RUBBERBANDFLAG, PCB) ? ",R  " : "  ",
	      Settings.LineThickness * COOR_TO_MM,
	      Settings.ViaThickness * COOR_TO_MM,
	      Settings.ViaDrillingHole * COOR_TO_MM,
	      ghidgui->compact_horizontal ? "\n" : "",
	      Settings.Keepaway * COOR_TO_MM,
	      Settings.TextScale, Settings.BufferNumber + 1);

  ghid_status_line_set_text (text);
}
Esempio n. 13
0
void
common_thindraw_pcb_pv (hidGC fg_gc, hidGC bg_gc, PinType *pv, bool drawHole, bool mask)
{
  Coord w = mask ? pv->Mask : pv->Thickness;
  Coord r = w / 2;

  if (TEST_FLAG (HOLEFLAG, pv))
    {
      if (mask)
	gui->graphics->draw_arc (fg_gc, pv->X, pv->Y, r, r, 0, 360);
      if (drawHole)
        {
	  r = pv->DrillingHole / 2;
          gui->graphics->set_line_cap (bg_gc, Round_Cap);
          gui->graphics->set_line_width (bg_gc, 0);
          gui->graphics->draw_arc (bg_gc, pv->X, pv->Y, r, r, 0, 360);
        }
      return;
    }

  if (TEST_FLAG (SQUAREFLAG, pv))
    {
      Coord l = pv->X - r;
      Coord b = pv->Y - r;
      Coord r = l + w;
      Coord t = b + w;

      gui->graphics->set_line_cap (fg_gc, Round_Cap);
      gui->graphics->set_line_width (fg_gc, 0);
      gui->graphics->draw_line (fg_gc, r, t, r, b);
      gui->graphics->draw_line (fg_gc, l, t, l, b);
      gui->graphics->draw_line (fg_gc, r, t, l, t);
      gui->graphics->draw_line (fg_gc, r, b, l, b);

    }
  else if (TEST_FLAG (OCTAGONFLAG, pv))
    {
      draw_octagon_poly (fg_gc, pv->X, pv->Y, w, true);
    }
  else /* draw a round pin or via */
    {
      gui->graphics->set_line_cap (fg_gc, Round_Cap);
      gui->graphics->set_line_width (fg_gc, 0);
      gui->graphics->draw_arc (fg_gc, pv->X, pv->Y, r, r, 0, 360);
    }

  /* and the drilling hole  (which is always round */
  if (drawHole)
    {
      gui->graphics->set_line_cap (bg_gc, Round_Cap);
      gui->graphics->set_line_width (bg_gc, 0);
      gui->graphics->draw_arc (bg_gc, pv->X, pv->Y, pv->DrillingHole / 2,
                     pv->DrillingHole / 2, 0, 360);
    }
}
Esempio n. 14
0
/* ---------------------------------------------------------------------------
 * Find a particular pad from an element name and pin number
 */
static bool
FindPad (char *ElementName, char *PinNum, ConnectionType * conn, bool Same)
{
  ElementTypePtr element;
  Cardinal i;

  if ((element = SearchElementByName (PCB->Data, ElementName)) != NULL)
    {
      for (i = 0; i < element->PadN; i++)
	if (NSTRCMP (PinNum, element->Pad[i].Number) == 0 && (!Same
							      ||
							      !TEST_FLAG
							      (DRCFLAG,
							       &element->
							       Pad[i])))
	  {
	    conn->type = PAD_TYPE;
	    conn->ptr2 = &element->Pad[i];
	    conn->group =
	      TEST_FLAG (ONSOLDERFLAG, &element->Pad[i]) ? SLayer : CLayer;
	    if (TEST_FLAG (EDGE2FLAG, &element->Pad[i]))
	      {
		conn->X = element->Pad[i].Point2.X;
		conn->Y = element->Pad[i].Point2.Y;
	      }
	    else
	      {
		conn->X = element->Pad[i].Point1.X;
		conn->Y = element->Pad[i].Point1.Y;
	      }
	    break;
	  }
      if (i == element->PadN)
	{
	  for (i = 0; i < element->PinN; i++)
	    if (!TEST_FLAG (HOLEFLAG, &element->Pin[i]) &&
		element->Pin[i].Number &&
		NSTRCMP (PinNum, element->Pin[i].Number) == 0 &&
		(!Same || !TEST_FLAG (DRCFLAG, &element->Pin[i])))
	      {
		conn->type = PIN_TYPE;
		conn->ptr2 = &element->Pin[i];
		conn->group = SLayer;	/* any layer will do */
		conn->X = element->Pin[i].X;
		conn->Y = element->Pin[i].Y;
		break;
	      }
	  if (i == element->PinN)
	    return (false);
	}
      conn->ptr1 = element;
      return (true);
    }
  return (false);
}
Esempio n. 15
0
File: rats.c Progetto: rlutz/pcb
/*!
 * \brief Find a particular pad from an element name and pin number.
 */
static bool
FindPad (char *ElementName, char *PinNum, ConnectionType * conn, bool Same)
{
  ElementType *element;
  GList *i;

  if ((element = SearchElementByName (PCB->Data, ElementName)) == NULL)
    return false;

  for (i = element->Pad; i != NULL; i = g_list_next (i))
    {
      PadType *pad = i->data;

      if (NSTRCMP (PinNum, pad->Number) == 0 &&
          (!Same || !TEST_FLAG (DRCFLAG, pad)))
        {
          conn->type = PAD_TYPE;
          conn->ptr1 = element;
          conn->ptr2 = pad;
          conn->group = TEST_FLAG (ONSOLDERFLAG, pad) ? bottom_group : top_group;

          if (TEST_FLAG (EDGE2FLAG, pad))
            {
              conn->X = pad->Point2.X;
              conn->Y = pad->Point2.Y;
            }
          else
            {
              conn->X = pad->Point1.X;
              conn->Y = pad->Point1.Y;
            }
          return true;
        }
    }

  for (i = element->Pin; i != NULL; i = g_list_next (i))
    {
      PinType *pin = i->data;

      if (!TEST_FLAG (HOLEFLAG, pin) &&
          pin->Number && NSTRCMP (PinNum, pin->Number) == 0 &&
          (!Same || !TEST_FLAG (DRCFLAG, pin)))
        {
          conn->type = PIN_TYPE;
          conn->ptr1 = element;
          conn->ptr2 = pin;
          conn->group = bottom_group;        /* any layer will do */
          conn->X = pin->X;
          conn->Y = pin->Y;
          return true;
        }
    }

  return false;
}
Esempio n. 16
0
static int
drcPad_callback (const BoxType * b, void *cl)
{
  PadTypePtr pad = (PadTypePtr) b;
  struct drc_info *i = (struct drc_info *) cl;

  if (TEST_FLAG (ONSOLDERFLAG, pad) == i->solder &&
      !TEST_FLAG (FOUNDFLAG, pad) && LinePadIntersect (i->line, pad))
    longjmp (i->env, 1);
  return 1;
}
Esempio n. 17
0
bool
pad_or_pin_test_flag(const PadOrPinType* pp, unsigned long flag)
{
  if (pp->pad) {
    return TEST_FLAG(flag, pp->pad);
  } else if (pp->pin) {
    return TEST_FLAG(flag, pp->pin);
  } else {
    return false;
  }
}
Esempio n. 18
0
static void
_draw_pv (PinType *pv, bool draw_hole)
{
  if (TEST_FLAG (THINDRAWFLAG, PCB))
    gui->graphics->thindraw_pcb_pv (Output.fgGC, Output.fgGC, pv, draw_hole, false);
  else
    gui->graphics->fill_pcb_pv (Output.fgGC, Output.bgGC, pv, draw_hole, false);

  if ((!TEST_FLAG (HOLEFLAG, pv) && TEST_FLAG (DISPLAYNAMEFLAG, pv)) || doing_pinout)
    _draw_pv_name (pv);
}
Esempio n. 19
0
/*++////////////////////////////////////////////////////////////////////////////

ClassSpinDownPowerHandler()

Routine Description:

    This routine is a callback for disks and other things which require both
    a start and a stop to be sent to the device.  (actually the starts are
    almost always optional, since most device power themselves on to process
    commands, but i digress).
    
    Determines proper use of spinup, spindown, and queue locking based upon
    ScanForSpecialFlags in the FdoExtension.  This is the most common power
    handler passed into classpnp.sys

Arguments:

    DeviceObject - Supplies the functional device object

    Irp - Supplies the request to be retried.

Return Value:

    None

--*/
NTSTATUS
NTAPI
ClassSpinDownPowerHandler(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP Irp
    )
{
    PFUNCTIONAL_DEVICE_EXTENSION fdoExtension;
    CLASS_POWER_OPTIONS options;

    fdoExtension = (PFUNCTIONAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;

    //
    // this will set all options to FALSE
    //

    RtlZeroMemory(&options, sizeof(CLASS_POWER_OPTIONS));

    //
    // check the flags to see what options we need to worry about
    //

    if (!TEST_FLAG(fdoExtension->ScanForSpecialFlags,
                  CLASS_SPECIAL_DISABLE_SPIN_DOWN)) {
        options.HandleSpinDown = TRUE;
    }

    if (!TEST_FLAG(fdoExtension->ScanForSpecialFlags,
                  CLASS_SPECIAL_DISABLE_SPIN_UP)) {
        options.HandleSpinUp = TRUE;
    }

    if (!TEST_FLAG(fdoExtension->ScanForSpecialFlags,
                  CLASS_SPECIAL_NO_QUEUE_LOCK)) {
        options.LockQueue = TRUE;
    }

    DebugPrint((3, "ClasspPowerHandler: Devobj %p\n"
                "\t%shandling spin down\n"
                "\t%shandling spin up\n"
                "\t%slocking queue\n",
                DeviceObject,
                (options.HandleSpinDown ? "" : "not "),
                (options.HandleSpinUp   ? "" : "not "),
                (options.LockQueue      ? "" : "not ")
                ));

    //
    // do all the dirty work
    //

    return ClasspPowerHandler(DeviceObject, Irp, options);
} // end ClassSpinDownPowerHandler()
Esempio n. 20
0
static void
_draw_pad (hidGC gc, PadType *pad, bool clear, bool mask)
{
  if (clear && !mask && pad->Clearance <= 0)
    return;

  if (TEST_FLAG (THINDRAWFLAG, PCB) ||
      (clear && TEST_FLAG (THINDRAWPOLYFLAG, PCB)))
    gui->graphics->thindraw_pcb_pad (gc, pad, clear, mask);
  else
    gui->graphics->fill_pcb_pad (gc, pad, clear, mask);
}
Esempio n. 21
0
void __noreturn reboot(void)
{
    uint8_t tmp;
    disable_interrupts();
    do {
        tmp = io_inb(KEYBOARD_CMND);
        if (TEST_FLAG(tmp, KBD_KDATA_BIT) != 0)
            io_inb(KEYBOARD_DATA);
    } while (TEST_FLAG(tmp, KBD_UDATA_BIT) != 0);
    io_outb(KEYBOARD_CMND, KEYBOARD_RESET);
    printk(PRINTK_ERROR "Rebooting");
    hang();
}
Esempio n. 22
0
static void
set_object_color (AnyObjectType *obj, char *warn_color, char *selected_color,
                  char *connected_color, char *found_color, char *normal_color)
{
  char *color;

  if      (warn_color      != NULL && TEST_FLAG (WARNFLAG,      obj)) color = warn_color;
  else if (selected_color  != NULL && TEST_FLAG (SELECTEDFLAG,  obj)) color = selected_color;
  else if (connected_color != NULL && TEST_FLAG (CONNECTEDFLAG, obj)) color = connected_color;
  else if (found_color     != NULL && TEST_FLAG (FOUNDFLAG,     obj)) color = found_color;
  else                                                                color = normal_color;

  gui->graphics->set_color (Output.fgGC, color);
}
Esempio n. 23
0
void frame_alloc(struct page* page, page_flags_t flags)
{
    if (page->frame) {
        return; /* Already allocated. */
    }
    uint32_t i = frame_get_first_free();
    if (i >= ((uint32_t)-1)) {
        panic("%s: out of memory", __func__);
    }
    frame_set(i * PAGE_SIZE);
    page->present = TEST_FLAG(flags, PAGE_FLAGS_PRESENT)   ? 1 : 0;
    page->rw      = TEST_FLAG(flags, PAGE_FLAGS_WRITEABLE) ? 1 : 0;
    page->user    = TEST_FLAG(flags, PAGE_FLAGS_USER_MODE) ? 1 : 0;
    page->frame   = i;
}
Esempio n. 24
0
/* ---------------------------------------------------------------------------
 * 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);
}
Esempio n. 25
0
/* ---------------------------------------------------------------------------
 * moves a line between layers
 */
static void *
MoveRatToLayer (RatType *Rat)
{
  LineTypePtr newone;
  //Coord X1 = Rat->Point1.X, Y1 = Rat->Point1.Y;
  //Coord X1 = Rat->Point1.X, Y1 = Rat->Point1.Y;
  // if VIAFLAG
  //   if we're on a pin, add a thermal
  //   else make a via and a wire, but 0-length wire not good
  // else as before

  newone = CreateNewLineOnLayer (Dest, Rat->Point1.X, Rat->Point1.Y,
			      Rat->Point2.X, Rat->Point2.Y,
			      Settings.LineThickness, 2 * Settings.Keepaway,
			      Rat->Flags);
  if (TEST_FLAG (CLEARNEWFLAG, PCB))
    SET_FLAG (CLEARLINEFLAG, newone);
  if (!newone)
    return (NULL);
  AddObjectToCreateUndoList (LINE_TYPE, Dest, newone, newone);
  if (PCB->RatOn)
    EraseRat (Rat);
  MoveObjectToRemoveUndoList (RATLINE_TYPE, Rat, Rat, Rat);
  DrawLine (Dest, newone);
  Draw ();
  return (newone);
}
Esempio n. 26
0
/* ---------------------------------------------------------------------------
 * moves an arc between layers
 */
static void *
MoveArcToLayer (LayerType *Layer, ArcType *Arc)
{
  ArcTypePtr newone;

  if (TEST_FLAG (LOCKFLAG, Arc))
    {
      Message (_("Sorry, the object is locked\n"));
      return NULL;
    }
  if (Dest == Layer && Layer->On)
    {
      DrawArc (Layer, Arc);
      Draw ();
    }
  if (((long int) Dest == -1) || Dest == Layer)
    return (Arc);
  AddObjectToMoveToLayerUndoList (ARC_TYPE, Layer, Arc, Arc);
  RestoreToPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
  if (Layer->On)
    EraseArc (Arc);
  newone = (ArcTypePtr)MoveArcToLayerLowLevel (Layer, Arc, Dest);
  ClearFromPolygon (PCB->Data, ARC_TYPE, Dest, Arc);
  if (Dest->On)
    DrawArc (Dest, newone);
  Draw ();
  return (newone);
}
Esempio n. 27
0
static int
element_callback (const BoxType * box, void *cl)
{
  ElementTypePtr element = (ElementTypePtr) box;
  struct ans_info *i = (struct ans_info *) cl;
  double newarea;

  if (TEST_FLAG (i->locked, element))
    return 0;

  if ((FRONT (element) || i->BackToo) &&
      POINT_IN_BOX (PosX, PosY, &element->VBox))
    {
      /* use the element with the smallest bounding box */
      newarea = (element->VBox.X2 - element->VBox.X1) *
	(double) (element->VBox.Y2 - element->VBox.Y1);
      if (newarea < i->area)
	{
	  i->area = newarea;
	  *i->ptr1 = *i->ptr2 = *i->ptr3 = element;
	  return 1;
	}
    }
  return 0;
}
Esempio n. 28
0
static int
linepoint_callback (const BoxType * b, void *cl)
{
  LineTypePtr line = (LineTypePtr) b;
  struct line_info *i = (struct line_info *) cl;
  int ret_val = 0;
  double d;

  if (TEST_FLAG (i->locked, line))
    return 0;

  /* some stupid code to check both points */
  d = Distance (PosX, PosY, line->Point1.X, line->Point1.Y);
  if (d < i->least)
    {
      i->least = d;
      *i->Line = line;
      *i->Point = &line->Point1;
      ret_val = 1;
    }

  d = Distance (PosX, PosY, line->Point2.X, line->Point2.Y);
  if (d < i->least)
    {
      i->least = d;
      *i->Line = line;
      *i->Point = &line->Point2;
      ret_val = 1;
    }
  return ret_val;
}
Esempio n. 29
0
/* ---------------------------------------------------------------------------
 * Update the X, Y and group position information stored in the NetList after
 * elements have possibly been moved, rotated, flipped, etc.
 */
static void
UpdateXY (NetListTypePtr Nets)
{
  Cardinal SLayer, CLayer;
  Cardinal i, j;
  /* find layer groups of the component side and solder side */
  SLayer = GetLayerGroupNumberByNumber (solder_silk_layer);
  CLayer = GetLayerGroupNumberByNumber (component_silk_layer);
  /* update all nets */
  for (i = 0; i < Nets->NetN; i++)
    {
      for (j = 0; j < Nets->Net[i].ConnectionN; j++)
	{
	  ConnectionTypePtr c = &(Nets->Net[i].Connection[j]);
	  switch (c->type)
	    {
	    case PAD_TYPE:
	      c->group = TEST_FLAG (ONSOLDERFLAG,
				    (ElementTypePtr) c->ptr1)
		? SLayer : CLayer;
	      c->X = ((PadTypePtr) c->ptr2)->Point1.X;
	      c->Y = ((PadTypePtr) c->ptr2)->Point1.Y;
	      break;
	    case PIN_TYPE:
	      c->group = SLayer;	/* any layer will do */
	      c->X = ((PinTypePtr) c->ptr2)->X;
	      c->Y = ((PinTypePtr) c->ptr2)->Y;
	      break;
	    default:
	      Message ("Odd connection type encountered in " "UpdateXY");
	      break;
	    }
	}
    }
}
Esempio n. 30
0
static void select_cb(void *obj_, void *ud)
{
	select_t *ctx = ud;
	AnyObjectTypePtr obj = obj_;
	if (TEST_FLAG(ctx->flag, obj))
		search_append(ctx->search, obj);
}