private static float GetCurrentDiameter(GerberLayer gd, string cps) { if (gd._apertures[cps].GetApertureType() == ApertureData.ApertureType.Circle) { // Only circles are valid return(((ApertureDataCircle)gd._apertures[cps]).Diameter); } Logger.Warn("Invalid Aperature data, defaulting thickness of line stroke to 0.1"); return(0.1f); }
private static void AddSimpleLine(GerberLayer gd, float x1, float y1, float x2, float y2, float strokeThickness) { var line = new PcbLine { Left = x1, Top = y1, Width = x2 - x1, Height = y2 - y1 }; if (x1 < gd._xmin) { gd._xmin = x1; } if (x1 > gd._xmax) { gd._xmax = x1; } if (x2 < gd._xmin) { gd._xmin = x2; } if (x2 > gd._xmax) { gd._xmax = x2; } if (y1 < gd._ymin) { gd._ymin = y1; } if (y1 > gd._ymax) { gd._ymax = y1; } if (y2 < gd._ymin) { gd._ymin = y2; } if (y2 > gd._ymax) { gd._ymax = y2; } line.StrokeThickness = strokeThickness; gd.PcbShapes.Add(line); }
private static void PerformFlash(GerberLayer gl, PointF currentPos, string currentPenString) { // Flash at current position // This could also be a rectangular shape if (gl._apertures[currentPenString].GetApertureType() == ApertureData.ApertureType.Rectangular) { var ad = (ApertureDataRect)gl._apertures[currentPenString]; var rect = new PcbRect { Left = currentPos.X - ad.Width / 2.0f, Top = currentPos.Y - ad.Height / 2.0f, Width = ad.Width, Height = ad.Height }; gl.PcbShapes.Add(rect); } else if (gl._apertures[currentPenString].GetApertureType() == ApertureData.ApertureType.Circle) { var ad = (ApertureDataCircle)gl._apertures[currentPenString]; var circle = new PcbEllipse { Left = currentPos.X - ad.Diameter / 2.0f, Top = currentPos.Y - ad.Diameter / 2.0f, Width = ad.Diameter, Height = ad.Diameter }; gl.PcbShapes.Add(circle); } else if (gl._apertures[currentPenString].GetApertureType() == ApertureData.ApertureType.Oval) { var ad = (ApertureDataOval)gl._apertures[currentPenString]; var oval = new PcbEllipse { Left = currentPos.X - ad.Width / 2.0f, Top = currentPos.Y - ad.Height / 2.0f, Width = ad.Width, Height = ad.Height }; gl.PcbShapes.Add(oval); } }