private void MakeObjectsNegative(IODBLayer Layer) { foreach (IODBObject obj in Layer.GetAllLayerObjects()) { IObjectSpecifics os = obj.GetSpecifics(); if (os.GetType() == typeof(IPadSpecifics)) { ((IPadSpecifics)os).Positive = false; } if (os.GetType() == typeof(IArcSpecifics)) { ((IArcSpecifics)os).Positive = false; } if (os.GetType() == typeof(ILineSpecifics)) { ((ILineSpecifics)os).Positive = false; } if (os.GetType() == typeof(ISurfaceSpecifics)) { ((ISurfaceSpecifics)os).Positive = false; } if (os.GetType() == typeof(ITextSpecifics)) { ((ITextSpecifics)os).Positive = false; } obj.SetSpecifics(os); } }
private void SelectAllObjectsOnLayer(IODBLayer layer) { foreach (IODBObject obj in layer.GetAllLayerObjects()) { obj.Select(true); } }
public void Execute(IPCBIWindow parent) { IStep step = parent.GetCurrentStep(); if (step == null) { return; } //the symbol diameter selected by user float diameterReplacedSymbolsInMils = 1; foreach (ILayer activeLayer in step.GetActiveLayerList()) { if (!(activeLayer is IODBLayer)) //component and picture layer irrelevant { continue; } IODBLayer Layer = (IODBLayer)activeLayer; int symbolIndex = -1; IFilter.AddToolDefinitionRound(Layer, diameterReplacedSymbolsInMils); foreach (IODBObject obj in Layer.GetAllLayerObjects()) { if (obj.GetDiameter() == 0) //all elements with diameter 0 replaced by new symbol { if (symbolIndex < 0) { symbolIndex = IFilter.AddToolDefinitionRound(Layer, diameterReplacedSymbolsInMils); //add new symbol only if used } obj.SetSpecifics(obj.GetSpecificsD(), symbolIndex); } } } }
void MarkAllSMDPadsOnLayer(IODBLayer layer, List <string> allRelevantDrills, IStep step) { if (layer == null || allRelevantDrills.Count == 0) { return; } Dictionary <string, IODBLayer> drills = new Dictionary <string, IODBLayer>(); //look for all pads if there is a drill inside? foreach (IODBObject maybePad in layer.GetAllLayerObjects()) { if (maybePad.Type != IObjectType.Pad || maybePad.ObjectColor == MarkerColor) { continue; } Dictionary <PCBI.FeatureAttributeEnum, string> attribs = maybePad.GetAttributesDictionary(); if (attribs.ContainsKey(PCBI.FeatureAttributeEnum.smd)) //check for smd attribute { //check for drills IPadSpecifics pad = (IPadSpecifics)maybePad.GetSpecifics(); if (pad.Type == PCBI.Symbol_Type.r) { continue; //no round pads } foreach (string drillname in allRelevantDrills) { if (!drills.ContainsKey(drillname)) { drills.Add(drillname, (IODBLayer)step.GetLayer(drillname)); } List <IObject> relevantDrills = drills[drillname].GetAllObjectInRectangle(maybePad.GetBounds()); foreach (IODBObject drill in relevantDrills) { if (maybePad.Bounds.Contains(drill.Bounds)) //simple check with bounds inside { maybePad.ObjectColor = MarkerColor; break; } } if (!maybePad.ObjectColor.IsEmpty) //if color -> found and break { break; } } } } }
public void Execute(IPCBIWindow parent) { IStep step = parent.GetCurrentStep(); if (step == null) { return; } Dictionary <string, string> NetDiffs = new Dictionary <string, string>(); foreach (string layername in step.GetAllLayerNames()) { ILayer layer = step.GetLayer(layername); if (layer == null) { continue; } if (!(layer is IODBLayer)) { continue; } IODBLayer mainLayer = (IODBLayer)layer; foreach (IODBObject obj in mainLayer.GetAllLayerObjects()) { if (obj.FreeText.Trim() != obj.NetName.Trim()) { if (!NetDiffs.ContainsKey(obj.NetName)) { NetDiffs.Add(obj.NetName, obj.FreeText); } } } } //have a list of all differences of netname and freetext StringBuilder MessageTextBuilder = new StringBuilder(); MessageTextBuilder.AppendLine("Differences of FreeText and Net name for:"); foreach (string key in NetDiffs.Keys) { MessageTextBuilder.AppendLine("Net " + key + " - " + NetDiffs[key]); } MessageBox.Show(MessageTextBuilder.ToString(), "Differences", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public void Execute(IPCBIWindow Parent) { IStep step = Parent.GetCurrentStep(); IMatrix matrix = Parent.GetMatrix(); if (step == null) { return; } IODBObject profile = step.GetPCBOutlineAsODBObject(); foreach (string layerName in step.GetAllLayerNames()) { if (matrix.GetMatrixLayerType(layerName) == MatrixLayerType.Component) { continue; //no component layer } ILayer Layer = step.GetLayer(layerName); if (Layer is IODBLayer) { bool foundOne = false; IODBLayer layer = (IODBLayer)Layer; foreach (IODBObject obj in layer.GetAllLayerObjects()) { if (profile.IsPointOfSecondObjectIncluded(obj)) { //inside not relevant } else { obj.Select(true); foundOne = true; } } if (foundOne) { Layer.EnableLayer(true); } } } Parent.UpdateSelection(); Parent.UpdateView(); }
/// <summary> /// Set for all layers netnames, if no connection it will be named with $NONE$ /// </summary> /// <param name="parent">The parent IPCBIWindow</param> /// <param name="NetList">A list of all created nets</param> /// <param name="netName">The selected net name</param> public static void AutoCreateNetNames(IPCBIWindow parent, Dictionary <string, netItem> NetList, string netNameStart) { IStep currentStep = parent.GetCurrentStep(); if (currentStep == null) { return; //maybe there are no Job loaded? } IMatrix matrix = parent.GetMatrix(); foreach (string layername in currentStep.GetAllLayerNames()) //fo all layers { //check type if (matrix.IsImageLayer(layername)) { continue; } if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Component) { continue; } IODBLayer parentLayer = (IODBLayer)currentStep.GetLayer(layername); //this works only because we have no image and no cmp layers parentLayer.CreateLayerNetList(true); //create internal net list foreach (IODBObject objODB in parentLayer.GetAllLayerObjects()) //all items { if (objODB.LayerNetNumber == -1) { AddNetInfos(NetList, currentStep, parentLayer, "$NONE$", objODB); //no connection -> $NONE$-Net } else { AddNetInfos(NetList, currentStep, parentLayer, netNameStart + layername + "_" + objODB.LayerNetNumber, objODB); } } } }
void MarkMaskOverPadsOnPaste(IODBLayer MaskLayer, IODBLayer PasteLayer, IStep step) { if (PasteLayer == null || MaskLayer == null) { return; } List <IObject> AllMaskPads = MaskLayer.GetAllLayerObjects(); //look for all pads if there is a paaste element inside? foreach (IODBObject maybePad in AllMaskPads) { if (maybePad.Type != IObjectType.Pad) { continue; } { //check for paste elements List <IObject> relevantPastePads = PasteLayer.GetAllObjectInRectangle(maybePad.Bounds); foreach (IODBObject pasteObj in relevantPastePads) { bool doesIntersect = maybePad.DoesIntersect(pasteObj); if (!doesIntersect && maybePad.IsPointOfSecondObjectIncluded(pasteObj)) { continue; //paste complete in mask } if (!doesIntersect && !pasteObj.IsPointOfSecondObjectIncluded(maybePad)) { continue; } maybePad.ObjectColor = MarkerColor; break; } } } }
public void Execute(IPCBIWindow Parent) { IStep step = Parent.GetCurrentStep(); IMatrix matrix = Parent.GetMatrix(); if (step == null) { return; } IODBObject profile = step.GetPCBOutlineAsODBObject(); foreach (string layerName in step.GetAllLayerNames()) { if (matrix.GetMatrixLayerType(layerName) == MatrixLayerType.Component) { continue; //no component layers } ILayer Layer = step.GetLayer(layerName); if (Layer is IODBLayer) { List <IODBObject> objectsToDelete = new List <IODBObject>(); IODBLayer layer = (IODBLayer)Layer; foreach (IODBObject obj in layer.GetAllLayerObjects()) { if (profile.IsPointOfSecondObjectIncluded(obj)) { //inside not delete } else { objectsToDelete.Add(obj); } } layer.RemoveObjects(objectsToDelete); } } Parent.UpdateView(); }
public void Execute(IPCBIWindow parent) { //your code here if (parent == null) { return; } System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NumberDecimalSeparator = "."; nfi.NumberGroupSeparator = ""; IStep step = parent.GetCurrentStep(); IFilter filter = new IFilter(parent); StringBuilder sb = new StringBuilder(); IMatrix m = parent.GetMatrix(); List <int> netnumbers = step.GetAllNetNrs(); Dictionary <int, List <PCBIObject> > allNetNrsWithItems = PCBI.Automation.NetCreation.NetCreator.CreateGlobalNet(step, m, true); foreach (int netlist in allNetNrsWithItems.Keys) { foreach (PCBIObject oObject in allNetNrsWithItems[netlist]) { oObject.iObj.PcbNetNumber = oObject.NetNrGlobal; } } List <string> names = step.GetAllLayerNames(); foreach (string layername in names) { if (step.GetLayer(layername).GetType() == typeof(IODBLayer)) { IODBLayer layer = (IODBLayer)step.GetLayer(layername); if (m.GetMatrixLayerType(layername) == MatrixLayerType.Signal || m.GetMatrixLayerType(layername) == MatrixLayerType.Rout || m.GetMatrixLayerType(layername) == MatrixLayerType.Drill || m.GetMatrixLayerType(layername) == MatrixLayerType.Mask) { foreach (IODBObject obj in layer.GetAllLayerObjects()) { int PCB_NetNum = obj.PcbNetNumber; int LayerNetNum = obj.LayerNetNumber; obj.FreeText = PCB_NetNum.ToString(); //sb.Append("P: " + PCB_NetNum.ToString() + "L: " + LayerNetNum.ToString() + Environment.NewLine); } } } } sb.Append("P VER IPC D 356" + Environment.NewLine); sb.Append("P IMAGE PRIMARY" + Environment.NewLine); sb.Append("C Created with PCB-Investigator" + Environment.NewLine); sb.Append("P Creation date:" + DateTime.Now.ToShortDateString() + Environment.NewLine); sb.Append("C " + step.Name + " " + parent.GetJobName() + Environment.NewLine); sb.Append("C" + Environment.NewLine); sb.Append("P CUST 0" + Environment.NewLine); #region descriptions // Units of measurement : //SI Metric //CUST 0 or CUST Inches and degrees //CUST 1 Millimeters and degrees //CUST 2 Inches and radians //ALLOWED OPERATION CODES (columns 1-3) //317 Through hole. Alternatively it can represent a feature and through hole at a point. //017 Continuation record that defines a through hole associated with the previous record //367 Non-plated tooling hole //327 Surface mount feature //027 Continuation record that defines a through hole associated with the previous record //099 Test point location of the feature described in the previous record //088 Solder mask clearance of the feature described in the previous record //307 Blind or buried via //309 Image 2 through NNNN offset data //370 In-board resistor, capacitor or inductor //070 Continuation of In-board resistor, capacitor or inductor //378 Conductor segment data //078 Continuation record of conductor segment data //379 Adjacency data record //079 Continuation of adjacency data record //380 On-board resistor, capacitor or inductor //080 Continuation of on-board resistor, capacitor or inductor //389 Board, panel or sub-panel , scoring or other fabrication outline data //089 Continuation of outline data //390 Non-test feature such as fiducials , targets , test status marking location , etc … //090 Reference for high-voltage isolation , impedance and other specified tests //999 End of Job data file #endregion List <string> drillNames = m.GetAllDrillLayerNames(); foreach (string drilName in drillNames) { IODBLayer layer = (IODBLayer)step.GetLayer(drilName); string LayerNumber = m.GetRawIndexByName(layer.LayerName).ToString(); foreach (IODBObject via in layer.GetAllLayerObjects()) { string NetName = via.PcbNetNumber.ToString();; IObjectSpecifics viaSpec = via.GetSpecifics(); if (viaSpec.GetType() == typeof(IPadSpecifics)) { float x = ((IPadSpecifics)viaSpec).Location.X; float y = ((IPadSpecifics)viaSpec).Location.Y; double diameter = ((IPadSpecifics)viaSpec).Diameter; string currentLine = new string(' ', 255); currentLine = currentLine.Insert(0, "317"); currentLine = currentLine.Insert(4, NetName); currentLine = currentLine.Insert(21, "VIA"); currentLine = currentLine.Insert(27, "-"); //currentLine = currentLine.Insert(28, LayerNumber); currentLine = currentLine.Insert(33, "D"); currentLine = currentLine.Insert(34, diameter.ToString("N2", nfi)); currentLine = currentLine.Insert(38, "P "); currentLine = currentLine.Insert(42, "X"); if (Math.Sign(x) == 1) { currentLine = currentLine.Insert(43, "+"); } else { currentLine = currentLine.Insert(43, "-"); } currentLine = currentLine.Insert(44, x.ToString("N2", nfi)); currentLine = currentLine.Insert(50, "Y"); if (Math.Sign(y) == 1) { currentLine = currentLine.Insert(51, "+"); } else { currentLine = currentLine.Insert(51, "-"); } currentLine = currentLine.Insert(52, y.ToString("N2", nfi)); currentLine = currentLine.Insert(58, "X"); currentLine = currentLine.Insert(59, diameter.ToString("N2", nfi)); currentLine = currentLine.Insert(63, "Y"); currentLine = currentLine.Insert(64, diameter.ToString("N2", nfi)); currentLine = currentLine.Insert(73, "S"); currentLine = currentLine.Insert(74, "3"); sb.Append(currentLine + Environment.NewLine); } } } IODBLayer LayerPTop = (IODBLayer)step.GetLayer(m.GetTopSignalLayer()); if (LayerPTop != null) { string LayerNumber = m.GetRawIndexByName(LayerPTop.LayerName).ToString(); foreach (IODBObject padTop in LayerPTop.GetAllLayerObjects()) { string NetName = padTop.PcbNetNumber.ToString();; IObjectSpecifics os = padTop.GetSpecifics(); if (os.GetType() == typeof(IPadSpecifics)) { IPadSpecifics oPad = (IPadSpecifics)os; PointF PadMidPoint = new PointF(padTop.GetBounds().X + padTop.GetBounds().Width / 2, padTop.GetBounds().Y + padTop.GetBounds().Height / 2); string currentLine = new string(' ', 255); currentLine = currentLine.Insert(0, "327"); currentLine = currentLine.Insert(4, NetName); currentLine = currentLine.Insert(21, "PAD"); currentLine = currentLine.Insert(27, " "); currentLine = currentLine.Insert(28, LayerNumber); currentLine = currentLine.Insert(33, "D"); currentLine = currentLine.Insert(34, padTop.GetBounds().Width.ToString("N2", nfi)); currentLine = currentLine.Insert(38, "P "); currentLine = currentLine.Insert(42, "X"); if (Math.Sign(PadMidPoint.X) == 1) { currentLine = currentLine.Insert(43, "+"); } else { currentLine = currentLine.Insert(43, "-"); } currentLine = currentLine.Insert(44, PadMidPoint.X.ToString("N2", nfi)); currentLine = currentLine.Insert(50, "Y"); if (Math.Sign(PadMidPoint.Y) == 1) { currentLine = currentLine.Insert(51, "+"); } else { currentLine = currentLine.Insert(51, "-"); } currentLine = currentLine.Insert(52, PadMidPoint.Y.ToString("N2", nfi)); currentLine = currentLine.Insert(58, "W"); currentLine = currentLine.Insert(59, padTop.GetBounds().Width.ToString("N2", nfi)); currentLine = currentLine.Insert(63, "H"); currentLine = currentLine.Insert(64, padTop.GetBounds().Height.ToString("N2", nfi)); currentLine = currentLine.Insert(73, "S"); currentLine = currentLine.Insert(74, "1"); sb.Append(currentLine + Environment.NewLine); } } } IODBLayer LayerPBot = (IODBLayer)step.GetLayer(m.GetBotSignalLayer()); if (LayerPBot != null) { string LayerNumber = m.GetRawIndexByName(LayerPBot.LayerName).ToString(); foreach (IODBObject padBot in LayerPBot.GetAllLayerObjects()) { string NetName = padBot.PcbNetNumber.ToString();; IObjectSpecifics os = padBot.GetSpecifics(); if (os.GetType() == typeof(IPadSpecifics)) { IPadSpecifics oPad = (IPadSpecifics)os; PointF PadMidPoint = new PointF(padBot.GetBounds().X + padBot.GetBounds().Width / 2, padBot.GetBounds().Y + padBot.GetBounds().Height / 2); string currentLine = new string(' ', 255); currentLine = currentLine.Insert(0, "327"); currentLine = currentLine.Insert(4, NetName); currentLine = currentLine.Insert(21, "PAD"); currentLine = currentLine.Insert(27, " "); currentLine = currentLine.Insert(28, LayerNumber); currentLine = currentLine.Insert(33, "D"); currentLine = currentLine.Insert(34, padBot.GetBounds().Width.ToString("N2", nfi)); currentLine = currentLine.Insert(38, "P "); currentLine = currentLine.Insert(42, "X"); if (Math.Sign(PadMidPoint.X) == 1) { currentLine = currentLine.Insert(43, "+"); } else { currentLine = currentLine.Insert(43, "-"); } currentLine = currentLine.Insert(44, PadMidPoint.X.ToString("N2", nfi)); currentLine = currentLine.Insert(50, "Y"); if (Math.Sign(PadMidPoint.Y) == 1) { currentLine = currentLine.Insert(51, "+"); } else { currentLine = currentLine.Insert(51, "-"); } currentLine = currentLine.Insert(52, PadMidPoint.Y.ToString("N2", nfi)); currentLine = currentLine.Insert(58, "W"); currentLine = currentLine.Insert(59, padBot.GetBounds().Width.ToString("N2", nfi)); currentLine = currentLine.Insert(63, "H"); currentLine = currentLine.Insert(64, padBot.GetBounds().Height.ToString("N2", nfi)); currentLine = currentLine.Insert(73, "S"); currentLine = currentLine.Insert(74, "1"); sb.Append(currentLine + Environment.NewLine); } } } sb.Append("999" + Environment.NewLine); // End of File string text = sb.ToString(); Directory.CreateDirectory(parent.GetODBJobDirectory() + "\\user\\"); FileStream fs = new FileStream(parent.GetODBJobDirectory() + "\\user\\IPC356.txt", FileMode.OpenOrCreate); StreamWriter sr = new StreamWriter(fs, Encoding.UTF8); fs.SetLength(0); sr.WriteLine(text); sr.Close(); fs.Close(); parent.UpdateView(); }
public void Execute(IPCBIWindow parent) { double sizeRouting = PCBI.MathUtils.IMath.MM2Mils(2); //2 mm double sizeCutout = PCBI.MathUtils.IMath.MM2Mils(2); //2 mm double spaceCutout = PCBI.MathUtils.IMath.MM2Mils(100); //100 mm double lengthCutout = PCBI.MathUtils.IMath.MM2Mils(5); //5 mm double sumUpLength = 0; //offset for start IStep step = parent.GetCurrentStep(); if (step == null) { return; } PCBI.MathUtils.IPolyClass polyOfOutline = step.GetPCBOutlinePoly(); if (polyOfOutline.GetEdgeCount() == 0) { return; } IFilter filter = new IFilter(parent); IODBLayer HelperLayer = filter.CreateEmptyODBLayer("rout_outline_helper", step.Name); //this helper layer contains the uncutted line elements IODBLayer outlineLayerRouting = filter.CreateEmptyODBLayer("rout_outline", step.Name); IODBLayer cutoutLayerRouting = filter.CreateEmptyODBLayer("rout_cutout", step.Name); #region clean layers for multi use List <IODBObject> objListToRemove = new List <IODBObject>(); foreach (IODBObject obj in HelperLayer.GetAllLayerObjects()) { objListToRemove.Add(obj); } HelperLayer.RemoveObjects(objListToRemove); objListToRemove = new List <IODBObject>(); foreach (IODBObject obj in cutoutLayerRouting.GetAllLayerObjects()) { objListToRemove.Add(obj); } cutoutLayerRouting.RemoveObjects(objListToRemove); objListToRemove = new List <IODBObject>(); foreach (IODBObject obj in outlineLayerRouting.GetAllLayerObjects()) { objListToRemove.Add(obj); } outlineLayerRouting.RemoveObjects(objListToRemove); #endregion int shapeIndexOutlinediameter = IFilter.AddToolDefinitionRound(HelperLayer, (float)sizeRouting); foreach (PCBI.MathUtils.IEdge edge in polyOfOutline.GetEdges()) { #region outline elements if (edge.Type == IEdgeType.Arc) { IODBObject newArc = filter.CreateArc(HelperLayer); IArcSpecificsD arc = (IArcSpecificsD)newArc.GetSpecificsD(); arc.ClockWise = ((IArcEdge)edge).ClockWise; if (arc.ClockWise) { arc.Start = edge.Begin; arc.End = edge.End; } else { arc.End = edge.Begin; arc.Start = edge.End; } arc.Center = ((PCBI.MathUtils.IArcEdge)edge).Center; arc.ShapeIndex = shapeIndexOutlinediameter; newArc.SetSpecifics(arc); } else { IODBObject newLine = filter.CreateLine(HelperLayer); ILineSpecificsD line = (ILineSpecificsD)newLine.GetSpecificsD(); line.Start = edge.Begin; line.End = edge.End; line.ShapeIndex = shapeIndexOutlinediameter; newLine.SetSpecifics(line); } #endregion } //make one surface of all lines and arcs HelperLayer.CreateLayerNetList(true); HelperLayer.PolygonizeLayer(0, false); PointD lastPToIdentifyHole = PointD.InfPoint; foreach (IODBObject surface in HelperLayer.GetAllLayerObjects()) { #region replace surfaces by routing lines and arcs if (surface.Type != IObjectType.Surface) { continue; } objListToRemove.Add(surface); List <ISurfaceSpecificsD> isle = ((ISurfaceSpecificsD)surface.GetSpecificsD()).SplitInIsleAndHoles(parent); if (isle.Count > 0) { for (int i = 0; i < isle.Count; i++) { bool foundelement = false; foreach (IODBObject linesAndArcs in isle[i].GetOutline()) { if (linesAndArcs.Type == IObjectType.Arc) { #region arc IODBObject newArc = filter.CreateArc(HelperLayer); IArcSpecificsD arc = (IArcSpecificsD)linesAndArcs.GetSpecificsD(); if (lastPToIdentifyHole == PointD.InfPoint || !(lastPToIdentifyHole != arc.Start && lastPToIdentifyHole != arc.End)) { lastPToIdentifyHole = arc.End; } else { break; } newArc.SetSpecifics(arc); #endregion } else { #region line IODBObject newLine = filter.CreateLine(HelperLayer); ILineSpecificsD line = (ILineSpecificsD)linesAndArcs.GetSpecificsD(); if (lastPToIdentifyHole == PointD.InfPoint || line.Start == lastPToIdentifyHole) { lastPToIdentifyHole = line.End; } else { break; } newLine.SetSpecifics(line); #endregion } foundelement = true; } if (foundelement) { break; } } } #endregion } HelperLayer.RemoveObjects(objListToRemove); //surface remove int shapeIndexCutoutdiameter = IFilter.AddToolDefinitionRound(outlineLayerRouting, (float)sizeCutout); int shapeIndexCutoutdiameter2 = IFilter.AddToolDefinitionRound(cutoutLayerRouting, (float)sizeCutout); double sumUpGap = 0; foreach (IODBObject lineOrArc in HelperLayer.GetAllLayerObjects()) { if (lineOrArc.Type == IObjectType.Line) { #region lines ILineSpecificsD line = (ILineSpecificsD)lineOrArc.GetSpecificsD(); double length = IMath.DistancePointToPoint(line.Start, line.End); double lengthComplete = length; while (true) { if (length <= lengthCutout) { #region short lines sumUpLength += lengthCutout; if (sumUpLength > spaceCutout) { sumUpGap += lengthCutout; IODBObject lineObj = filter.CreateLine(cutoutLayerRouting); ILineSpecificsD lineSub = (ILineSpecificsD)lineOrArc.GetSpecificsD(); lineSub.ShapeIndex = shapeIndexCutoutdiameter2; lineSub.Start = IMath.GetPointOnLine(line.Start, line.End, lengthComplete - length); length = 0; lineSub.End = IMath.GetPointOnLine(line.Start, line.End, lengthComplete - length); lineObj.SetSpecifics(lineSub); if (sumUpGap > lengthCutout) { sumUpGap = 0; sumUpLength = 0; } IAttributeElement attribRoutningComp = new IAttributeElement(PCBI.FeatureAttributeEnum.comp); attribRoutningComp.Value = "none"; IAttribute.SetAttribute(attribRoutningComp, lineObj); } else { IODBObject lineObj = filter.CreateLine(outlineLayerRouting); ILineSpecificsD lineSub = (ILineSpecificsD)lineOrArc.GetSpecificsD(); lineSub.ShapeIndex = shapeIndexCutoutdiameter; lineSub.Start = IMath.GetPointOnLine(line.Start, line.End, lengthComplete - length); length = 0; lineSub.End = IMath.GetPointOnLine(line.Start, line.End, lengthComplete - length); lineObj.SetSpecifics(lineSub); IAttributeElement attribRoutningComp = new IAttributeElement(PCBI.FeatureAttributeEnum.comp); attribRoutningComp.Value = "none"; IAttribute.SetAttribute(attribRoutningComp, lineObj); } break; #endregion } else { #region long lines sumUpLength += lengthCutout; if (sumUpLength > spaceCutout || sumUpGap > 0) { sumUpGap += lengthCutout; IODBObject lineObj = filter.CreateLine(cutoutLayerRouting); ILineSpecificsD lineSub = (ILineSpecificsD)lineOrArc.GetSpecificsD(); lineSub.ShapeIndex = shapeIndexCutoutdiameter2; lineSub.Start = IMath.GetPointOnLine(line.Start, line.End, lengthComplete - length); length -= lengthCutout; lineSub.End = IMath.GetPointOnLine(line.Start, line.End, lengthComplete - length); lineObj.SetSpecifics(lineSub); if (sumUpGap > lengthCutout) { sumUpGap = 0; sumUpLength = 0; } IAttributeElement attribRoutningComp = new IAttributeElement(PCBI.FeatureAttributeEnum.comp); attribRoutningComp.Value = "none"; IAttribute.SetAttribute(attribRoutningComp, lineObj); } else { IODBObject lineObj = filter.CreateLine(outlineLayerRouting); ILineSpecificsD lineSub = (ILineSpecificsD)lineOrArc.GetSpecificsD(); lineSub.ShapeIndex = shapeIndexCutoutdiameter; lineSub.Start = IMath.GetPointOnLine(line.Start, line.End, lengthComplete - length); length -= lengthCutout; lineSub.End = IMath.GetPointOnLine(line.Start, line.End, lengthComplete - length); lineObj.SetSpecifics(lineSub); IAttributeElement attribRoutningComp = new IAttributeElement(PCBI.FeatureAttributeEnum.comp); attribRoutningComp.Value = "none"; IAttribute.SetAttribute(attribRoutningComp, lineObj); } #endregion } } #endregion } else if (lineOrArc.Type == IObjectType.Arc) { #region arcs IArcSpecificsD arc = (IArcSpecificsD)lineOrArc.GetSpecificsD(); double arcLength = IMath.DistancePointToPoint(arc.Start, arc.End); sumUpLength += arcLength; if (sumUpLength > spaceCutout || sumUpGap > 0) { sumUpGap += arcLength; IODBObject arcObj = filter.CreateArc(cutoutLayerRouting); arc.ShapeIndex = shapeIndexCutoutdiameter2; arcObj.SetSpecifics(arc); if (sumUpGap > lengthCutout) { sumUpGap = 0; sumUpLength = 0; } IAttributeElement attribRoutningComp = new IAttributeElement(PCBI.FeatureAttributeEnum.comp); attribRoutningComp.Value = "none"; IAttribute.SetAttribute(attribRoutningComp, arcObj); } else { IODBObject arcObj = filter.CreateArc(outlineLayerRouting); arc.ShapeIndex = shapeIndexCutoutdiameter; arcObj.SetSpecifics(arc); IAttributeElement attribRoutningComp = new IAttributeElement(PCBI.FeatureAttributeEnum.comp); attribRoutningComp.Value = "none"; IAttribute.SetAttribute(attribRoutningComp, arcObj); } #endregion } } //additional attributes are .feed, .speed, .rout_flag, .comp. and .rout_chain IMatrix matrix = parent.GetMatrix(); if (matrix != null) { matrix.UpdateDataAndList(); } parent.UpdateView(); }
internal static bool CutRectangle(IPolyClass rectanglePoly, IODBLayer layer, IODBLayer NewlayerToAddElements, IFilter filter, IPCBIWindow parentPCBI) { if (layer == null) { return(false); //no layer } if (NewlayerToAddElements == null) { return(false); //no layer for new elements } //use bounds to get relevant objects //cut intersecting objects //helper for Symbols Dictionary <int, int> symbolUsed = new Dictionary <int, int>(); //Performance RectangleD relevantRectangle = rectanglePoly.GetBounds(); foreach (IODBObject obj in layer.GetAllLayerObjects()) { if (relevantRectangle.IntersectsWith(obj.GetBoundsD())) { #region cut elements //cutting IPolyClass polygon = obj.GetPolygonOutline(); IPolyClass cuttingPolygon; if (rectanglePoly.GetBounds().Contains(polygon.GetBounds())) { cuttingPolygon = polygon; } else { cuttingPolygon = polygon.Intersect(rectanglePoly); } if (cuttingPolygon.GetEdgeCount() == 0) { continue; //bounds cutting but not of any interest } List <ISurfaceSpecificsD> subPolygons = cuttingPolygon.SplitInIsleAndHoles(parentPCBI, NewlayerToAddElements); foreach (ISurfaceSpecificsD subPolygon in subPolygons) //create part surfaces { IODBObject surface = filter.CreatePolygon(NewlayerToAddElements); subPolygon.Positive = obj.Positive; surface.SetSpecifics(subPolygon); Dictionary <string, string> attributes = obj.GetAttributesDictionaryStringKeys(); foreach (string attribute in attributes.Keys) { surface.SetAttribute(attributes[attribute], attribute); //copy attributes } } #endregion } else { //not relevant -> ignore } } return(true); //finish }
public void Execute(IPCBIWindow parent) { //check all pads on top and bot signal layers and mask layers for open space in mask... IMatrix matrix = parent.GetMatrix(); IStep step = parent.GetCurrentStep(); if (step == null || matrix == null) { return; } PCB_Investigator.PCBIWindows.PCBIWorkingDialog working = new PCB_Investigator.PCBIWindows.PCBIWorkingDialog(); working.CanCancel(false); working.SetStatusText("Checking for free pads on Solder Mask..."); working.SetAnimationStatus(true); working.ShowWorkingDlgAsThread(); IODBLayer SMTLayerTop = null; IODBLayer SMTLayerBot = null; IODBLayer SignalTop = (IODBLayer)step.GetLayer(matrix.GetTopSignalLayer()); IODBLayer SignalBot = (IODBLayer)step.GetLayer(matrix.GetBotSignalLayer(false)); bool signalBlockFound = false; foreach (string layername in step.GetAllLayerNames()) { if (!signalBlockFound && matrix.GetMatrixLayerType(layername) == MatrixLayerType.Solder_mask && SMTLayerTop == null) { SMTLayerTop = (IODBLayer)step.GetLayer(layername); } else if (signalBlockFound && matrix.GetMatrixLayerType(layername) == MatrixLayerType.Solder_mask && SMTLayerBot == null) { SMTLayerBot = (IODBLayer)step.GetLayer(layername); } } //check signal pads free? bool topPadsFree = true; bool botPadsFree = true; if (SignalTop != null && SMTLayerTop != null) { ICMPLayer topCMPLayer = step.GetCMPLayer(true); if (topCMPLayer == null) { foreach (IODBObject checkingPad in SignalTop.GetAllLayerObjects()) { bool?foundFreeArea = CheckPadsForFreeMask(SMTLayerTop, checkingPad); if (foundFreeArea == false) { checkingPad.ObjectColorTemporary(Color.DarkBlue); topPadsFree = false; } } } else { topPadsFree = CheckPadsForFreeMask(SMTLayerTop, SignalTop, topCMPLayer); } } if (SignalBot != null && SMTLayerBot != null) { ICMPLayer botCMPLayer = step.GetCMPLayer(false); if (botCMPLayer == null) { foreach (IODBObject checkingPad in SignalBot.GetAllLayerObjects()) { bool?foundFreeArea = CheckPadsForFreeMask(SMTLayerBot, checkingPad); if (foundFreeArea == false) { checkingPad.ObjectColorTemporary(Color.DarkBlue); botPadsFree = false; } } } else { botPadsFree = CheckPadsForFreeMask(SMTLayerTop, SignalBot, botCMPLayer); } } working.DoClose(); if (topPadsFree && botPadsFree) { PCB_Investigator.Localization.PCBILocalization.ShowMsgBox("Top and Bot Signal Layer Pads free on mask layers.", "Both Sides free", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (!topPadsFree && !botPadsFree) { PCB_Investigator.Localization.PCBILocalization.ShowMsgBox("Please check both sides manualy, there are closed pads found.", "No Side free", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { if (topPadsFree) { PCB_Investigator.Localization.PCBILocalization.ShowMsgBox("Top Side is ok, all pads free on mask layer top. Check bot layer for blue elements!", "Top OK", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { PCB_Investigator.Localization.PCBILocalization.ShowMsgBox("Bot Side is ok, all pads free on mask layer bot. Check top layer for blue elements!", "Bot OK", MessageBoxButtons.OK, MessageBoxIcon.Information); } } parent.UpdateView(); }
public void Execute(IPCBIWindow parent) { if (parent == null) { return; } TextType tt = TextType.angle; ShowInputDialog(ref tt); // MessageBox.Show( tt.ToString()); IMatrix m = parent.GetMatrix(); IStep step = parent.GetCurrentStep(); if (tt == TextType.angle) { foreach (string layerName in m.GetAllSignalLayerNames()) { IODBLayer layer = (IODBLayer)step.GetLayer(layerName); foreach (IODBObject obj in layer.GetAllLayerObjects()) { IObjectSpecifics os = obj.GetSpecifics(); if (os.GetType() == typeof(ILineSpecifics)) { ILineSpecifics lineEdges = (ILineSpecifics)os; double angle = PCBI.MathUtils.IMath.GetAngle(PCBI.MathUtils.PointD.FromPointF(lineEdges.Start), PCBI.MathUtils.PointD.FromPointF(lineEdges.End)); obj.FreeText = "? " + angle.ToString(); } if (os.GetType() == typeof(IPadSpecifics)) { IPadSpecifics PAD = (IPadSpecifics)os; double angle = PAD.Rotation; obj.FreeText = "? " + angle.ToString(); } } } } if (tt == TextType.lenght) { foreach (string layerName in m.GetAllSignalLayerNames()) { IODBLayer layer = (IODBLayer)step.GetLayer(layerName); foreach (IODBObject obj in layer.GetAllLayerObjects()) { IObjectSpecifics os = obj.GetSpecifics(); if (os.GetType() == typeof(ILineSpecifics)) { ILineSpecifics lineEdges = (ILineSpecifics)os; double length = PCBI.MathUtils.IMath.DistancePointToPoint(PCBI.MathUtils.PointD.FromPointF(lineEdges.Start), PCBI.MathUtils.PointD.FromPointF(lineEdges.End)) / 100; if (parent.GetUnit()) { length *= 2.54f; } length = Math.Round(length, 2); obj.FreeText = "L: " + length.ToString(); } if (os.GetType() == typeof(IPadSpecifics)) { IPadSpecifics PAD = (IPadSpecifics)os; RectangleF bounds = obj.GetBounds(); double w = bounds.Width / 100; double h = bounds.Height / 100; if (parent.GetUnit()) { w *= 2.54f; h *= 2.54f; } w = Math.Round(w, 2); h = Math.Round(h, 2); obj.FreeText = "w: " + w.ToString() + " h: " + h.ToString(); } } } } if (tt == TextType.ViaCount) { foreach (INet NetList in step.GetNets()) { int drillCount = 0; foreach (IODBObject obj in NetList.GetAllNetObjects(parent)) { if (m.GetMatrixLayerType(obj.GetParentLayerName()) == MatrixLayerType.Drill) { drillCount++; } } foreach (IODBObject obj in NetList.GetAllNetObjects(parent)) { obj.FreeText = "DrillCount: " + drillCount.ToString(); } } } if (tt == TextType.NetOnLayer) { foreach (INet NetList in step.GetNets()) { string LNames = ""; foreach (string LayerNames in NetList.GetAllUsedLayers(step)) { if (m.GetMatrixLayerType(LayerNames) == MatrixLayerType.Signal) { LNames += LayerNames + "; "; } } foreach (IODBObject obj in NetList.GetAllNetObjects(parent)) { obj.FreeText = "layer: " + LNames; } } } if (tt == TextType.NetLength) { foreach (INet NetList in step.GetNets()) { double length = CalculateNetLenth(NetList.GetAllNetObjects(parent)) / 100; if (parent.GetUnit()) { length *= 2.54f; } foreach (IODBObject obj in NetList.GetAllNetObjects(parent)) { obj.FreeText = "Netlength: " + Math.Round(length, 2); } } } parent.ShowFreeTextInfoOnAllLayer = true; parent.UpdateView(); }
public void Execute(IPCBIWindow parent) { IStep step = parent.GetCurrentStep(); IMatrix matrix = parent.GetMatrix(); if (step == null || matrix == null) { return; } IODBLayer IODBLayerOrg = null; IODBLayer IODBLayerNew = null; foreach (ILayer activeLayer in step.GetActiveLayerList()) //search for the first two active layer to copy from first to second { if (activeLayer is IODBLayer) { if (IODBLayerOrg == null) { IODBLayerOrg = (IODBLayer)activeLayer; } else if (IODBLayerNew == null) { IODBLayerNew = (IODBLayer)activeLayer; } else { break; //only the first two layers... } } } if (IODBLayerOrg == null || IODBLayerNew == null) { return; } IFilter filter = new IFilter(parent); if (IODBLayerOrg is IODBLayer) { Dictionary <int, int> ShapeIndexOldNew = new Dictionary <int, int>(); //set new shape index if symbol is created. foreach (IODBObject obj in IODBLayerOrg.GetAllLayerObjects()) { IODBObject objNew = null; IObjectSpecificsD spec = obj.GetSpecificsD(); switch (obj.Type) { case IObjectType.Arc: objNew = filter.CreateArc(IODBLayerNew); if (!ShapeIndexOldNew.ContainsKey(((IArcSpecificsD)spec).ShapeIndex)) { int indexNew = IFilter.AddToolFromODBString(IODBLayerNew, ((IArcSpecificsD)spec).ODBSymbol_String); ShapeIndexOldNew.Add(((IArcSpecificsD)spec).ShapeIndex, indexNew); } ((IArcSpecificsD)spec).ShapeIndex = ShapeIndexOldNew[((IArcSpecificsD)spec).ShapeIndex]; break; case IObjectType.Line: objNew = filter.CreateLine(IODBLayerNew); if (!ShapeIndexOldNew.ContainsKey(((ILineSpecificsD)spec).ShapeIndex)) { int indexNew = IFilter.AddToolFromODBString(IODBLayerNew, ((ILineSpecificsD)spec).ODBSymbol_String); ShapeIndexOldNew.Add(((ILineSpecificsD)spec).ShapeIndex, indexNew); } ((ILineSpecificsD)spec).ShapeIndex = ShapeIndexOldNew[((ILineSpecificsD)spec).ShapeIndex]; break; case IObjectType.Pad: objNew = filter.CreatePad(IODBLayerNew); if (!ShapeIndexOldNew.ContainsKey(((IPadSpecificsD)spec).ShapeIndex)) { IFilter.ToolDefinition toolDef = filter.GetSymbolByShapeIndex(((IPadSpecificsD)spec).ShapeIndex, (IODBLayer)IODBLayerOrg); int indexNew = -1; if (toolDef.Type == PCBI.Symbol_Type.special) { indexNew = IFilter.AddToolDefinitionSpecial(IODBLayerNew, (IODBLayer)IODBLayerOrg, toolDef.ShapeIndex); } else { indexNew = IFilter.AddToolFromODBString(IODBLayerNew, ((IPadSpecificsD)spec).ODBSymbol_String); } ShapeIndexOldNew.Add(((IPadSpecificsD)spec).ShapeIndex, indexNew); } ((IPadSpecificsD)spec).ShapeIndex = ShapeIndexOldNew[((IPadSpecificsD)spec).ShapeIndex]; break; case IObjectType.Surface: objNew = filter.CreatePolygon(IODBLayerNew); break; case IObjectType.Text: objNew = filter.CreateText(IODBLayerNew); break; default: System.Diagnostics.Debug.WriteLine("Case not possible!"); break; } if (objNew != null) { objNew.SetSpecifics(spec); } } } else { System.Diagnostics.Debug.WriteLine("Not implemented for components!"); } parent.UpdateView(); }
public void Execute(IPCBIWindow parent) { if (parent.GetCurrentStep() == null) { return; } bool clearLayer = false; IStep step = parent.GetCurrentStep(); IFilter filter = new IFilter(parent); if (parent.GetCurrentStep() == null) { return; } IODBLayer layerTopPins = null; IODBLayer layerbotPins = null; if (layerTopPins == null) { layerTopPins = filter.CreateEmptyODBLayer("component_top_shapes", step.Name); if (clearLayer) { foreach (IODBObject o in layerTopPins.GetAllLayerObjects()) { layerTopPins.RemoveObject(o); } } } if (layerbotPins == null) { layerbotPins = filter.CreateEmptyODBLayer("component_bot_shapes", step.Name); if (clearLayer) { foreach (IODBObject o in layerbotPins.GetAllLayerObjects()) { layerbotPins.RemoveObject(o); } } } foreach (ICMPObject cmp in step.GetAllCMPObjects()) { PCBI.MathUtils.IPolyClass CMP_Poly = cmp.GetPolygonOutline(false); IODBObject outlinePolygon; if (cmp.PlacedTop) { outlinePolygon = filter.CreatePolygon(layerTopPins); } else { outlinePolygon = filter.CreatePolygon(layerbotPins); } ISurfaceSpecifics CMP_Body_Polygon = (ISurfaceSpecifics)outlinePolygon.GetSpecifics(); bool polyStart = true; foreach (IEdge edge in CMP_Poly.GetEdges()) { if (polyStart) { polyStart = false; CMP_Body_Polygon.StartPolygon(false, new PointF((float)edge.Begin.X, (float)edge.Begin.Y)); } else if (edge is IArcEdge) { IArcEdge aEdge = (IArcEdge)edge; PointF start = new PointF((float)aEdge.Begin.X, (float)aEdge.Begin.Y); PointF end = new PointF((float)aEdge.End.X, (float)aEdge.End.Y); PointF center = new PointF((float)aEdge.Center.X, (float)aEdge.Center.Y); CMP_Body_Polygon.AddArc(start, end, center, aEdge.ClockWise); } else if (edge is ILineEdge) { ILineEdge aEdge = (ILineEdge)edge; PointF start = new PointF((float)aEdge.Begin.X, (float)aEdge.Begin.Y); PointF end = new PointF((float)aEdge.End.X, (float)aEdge.End.Y); CMP_Body_Polygon.AddLine(start, end); } } CMP_Body_Polygon.EndPolygon(); //close the new contour outlinePolygon.SetSpecifics(CMP_Body_Polygon); } layerbotPins.EnableLayer(true); layerTopPins.EnableLayer(true); parent.UpdateView(); parent.UpdateControlsAndResetView(); }
public void Execute(IPCBIWindow parent) { //example to check first solder paste with first solder mask distances. double maxDist = 2; //mils wdlg = new PCB_Investigator.PCBIWindows.PCBIWorkingDialog(); wdlg.SetAnimationStatus(false); wdlg.SetStatusPercent(0); wdlg.SetStatusText("Working"); wdlg.CanCancel(true); IMatrix matrix = parent.GetMatrix(); IStep step = parent.GetCurrentStep(); wdlg.ShowWorkingDlgAsThread(); List <string> layerNames = step.GetAllLayerNames(); double value = 0; double valueStep = ((100.0 / layerNames.Count)); Dictionary <IODBObject.DistanceResultClass, IODBObject> DistanceList = new Dictionary <IODBObject.DistanceResultClass, IODBObject>(); IODBLayer SMTLayer = null; IODBLayer SPLayer = null; foreach (string layername in step.GetAllLayerNames()) { wdlg.SetStatusText("Working on " + layername + "..."); value += valueStep; wdlg.SetStatusPercent((int)(value)); if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Solder_paste && SPLayer == null) //find top solderpaste { SPLayer = (IODBLayer)step.GetLayer(layername); } else if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Solder_mask && SMTLayer == null) //find top mask layer { SMTLayer = (IODBLayer)step.GetLayer(layername); } if (SMTLayer != null && SPLayer != null) { foreach (IODBObject IODBO1 in SPLayer.GetAllLayerObjects()) { RectangleD boundsToInflate = IODBO1.GetBoundsD(); boundsToInflate.Inflate(maxDist, maxDist); foreach (IODBObject IODBO2 in SMTLayer.GetAllObjectInRectangle(boundsToInflate)) { IODBObject.DistanceResultClass distance = IODBO1.DistanceTo(IODBO2); if (distance.Distance >= 0) { DistanceList.Add(distance, IODBO2); IODBO2.ObjectColorTemporary(Color.DarkRed); } } } break; } } wdlg.Dispose(); if (DistanceList.Count > 0) //write result to excel { StringBuilder sb = new StringBuilder(); var excelType = Type.GetTypeFromProgID("Excel.Application"); dynamic excel = Activator.CreateInstance(excelType); excel.Visible = true; excel.Workbooks.Add(); foreach (IODBObject.DistanceResultClass distanceResult in DistanceList.Keys) { sb.Append("\t" + DistanceList[distanceResult].PcbNetNumber + "\t" + distanceResult.From + "\t" + distanceResult.To + "\t" + distanceResult.Distance + Environment.NewLine); } string LVText = "Distances\tNet Number\tMask Layer\tSolder Paste\tValue" + Environment.NewLine + sb.ToString(); string LVCsv = sb.ToString(); DataObject LVDataObject = new DataObject(); LVDataObject.SetData(DataFormats.Text, true, LVText); LVDataObject.SetData(DataFormats.CommaSeparatedValue, true, LVCsv); Clipboard.SetDataObject(LVDataObject, true); excel.ActiveSheet.Paste(); //release the object System.Runtime.InteropServices.Marshal.ReleaseComObject(excel); } else { MessageBox.Show("No Results found...\n Please check Layers for Paste- or Mask layers!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Execute(IPCBIWindow parent) { if (parent.GetCurrentStep() == null) { return; } bool clearLayer = false; IStep step = parent.GetCurrentStep(); IODBLayer layerTopPins = null; IODBLayer layerbotPins = null; IFilter filter = new IFilter(parent); if (layerTopPins == null) { layerTopPins = filter.CreateEmptyODBLayer("component_top_shapes", step.Name); if (clearLayer) { foreach (IODBObject o in layerTopPins.GetAllLayerObjects()) { layerTopPins.RemoveObject(o); } } } if (layerbotPins == null) { layerbotPins = filter.CreateEmptyODBLayer("component_bot_shapes", step.Name); if (clearLayer) { foreach (IODBObject o in layerbotPins.GetAllLayerObjects()) { layerbotPins.RemoveObject(o); } } } // Pins foreach (ICMPObject cmp in step.GetAllCMPObjects()) { foreach (IPin pin in cmp.GetPinList()) { IODBObject outlinePolygon = null; if (cmp.PlacedTop) { outlinePolygon = filter.CreatePolygon(layerTopPins); } else { outlinePolygon = filter.CreatePolygon(layerbotPins); } ISurfaceSpecifics specOutline = (ISurfaceSpecifics)outlinePolygon.GetSpecifics(); bool polyStart = true; PointF StartPoint = new PointF(0, 0); PointF EndPoint = new PointF(0, 0); foreach (IEdge edge in pin.GetPolygonOutline(cmp).GetEdges()) { if (polyStart) { polyStart = false; StartPoint = new PointF((float)edge.Begin.X, (float)edge.Begin.Y); specOutline.StartPolygon(false, StartPoint); if (edge is IArcEdge) { IArcEdge aEdge = (IArcEdge)edge; PointF start = new PointF((float)aEdge.Begin.X, (float)aEdge.Begin.Y); PointF end = new PointF((float)aEdge.End.X, (float)aEdge.End.Y); PointF center = new PointF((float)aEdge.Center.X, (float)aEdge.Center.Y); specOutline.AddArc(start, end, center, aEdge.ClockWise); if (aEdge.ClockWise) { EndPoint = end; } else { EndPoint = start; } } else if (edge is ILineEdge) { ILineEdge aEdge = (ILineEdge)edge; PointF start = new PointF((float)aEdge.Begin.X, (float)aEdge.Begin.Y); PointF end = new PointF((float)aEdge.End.X, (float)aEdge.End.Y); specOutline.AddLine(start, end); EndPoint = end; } } else if (edge is IArcEdge) { IArcEdge aEdge = (IArcEdge)edge; PointF start = new PointF((float)aEdge.Begin.X, (float)aEdge.Begin.Y); PointF end = new PointF((float)aEdge.End.X, (float)aEdge.End.Y); PointF center = new PointF((float)aEdge.Center.X, (float)aEdge.Center.Y); specOutline.AddArc(start, end, center, aEdge.ClockWise); if (aEdge.ClockWise) { EndPoint = end; } else { EndPoint = start; } } else if (edge is ILineEdge) { ILineEdge aEdge = (ILineEdge)edge; PointF start = new PointF((float)aEdge.Begin.X, (float)aEdge.Begin.Y); PointF end = new PointF((float)aEdge.End.X, (float)aEdge.End.Y); specOutline.AddLine(start, end); EndPoint = end; } } specOutline.EndPolygon(); //close the new contour outlinePolygon.SetSpecifics(specOutline); outlinePolygon.ObjectColor = Color.Blue; } } layerbotPins.EnableLayer(true); layerTopPins.EnableLayer(true); parent.UpdateView(); parent.UpdateControlsAndResetView(); }
public void Execute(IPCBIWindow parent) { string PackageName = "TESTPUNKT"; bool topSide = true; bool useFlattenStep = true; if (!parent.JobIsLoaded) { return; } IFilter filter = new IFilter(parent); IStep step = parent.GetCurrentStep(); IMatrix matrix = parent.GetMatrix(); if (matrix == null) { return; } step.TurnOffAllLayer(); step.ClearSelection(); //nicht für flatten step, da durch Threads zu langsam und dann evtl die neuen Daten wieder gelöscht werden! if (!useFlattenStep) { matrix.DelateLayer("testpoint_locations_top", false); matrix.DelateLayer("testpoint_locations_bot", false); } if (topSide) { CreateForOneSide(true, step, filter, PackageName, matrix.GetAllDrillLayersForThisLayer(matrix.GetTopSignalLayer())); } else { CreateForOneSide(false, step, filter, PackageName, matrix.GetAllDrillLayersForThisLayer(matrix.GetBotSignalLayer())); } //gitter 500x500 IODBLayer rasterLayer = filter.CreateEmptyODBLayer("raster", step.Name); int shapeIndex = IFilter.AddToolDefinitionRound(rasterLayer, 10); RectangleF boundsStep = step.GetBounds(); int countYLines = (int)(boundsStep.Height / 500) + 1; int countXLines = (int)(boundsStep.Width / 500) + 1; for (int y = 0; y <= countYLines; y++) { for (int x = 0; x <= countXLines; x++) { for (int i = 0; i < 5; i++) //5 sublines { int yVal = y * 500; int xVal = x * 500; if (x < countXLines) { CreateHorLine(filter, rasterLayer, shapeIndex, yVal, xVal + i * 100 + 25); } if (y < countYLines) { CreateVertLine(filter, rasterLayer, shapeIndex, yVal + i * 100 + 25, xVal); } } } } for (int y = 0; y < countYLines; y++) { #region draw text IODBObject textForPad = filter.CreateText(rasterLayer); ITextSpecificsD text = (ITextSpecificsD)textForPad.GetSpecificsD(); text.Text = "Y" + (y + 1); text.TextSize = new SizeF(50, 80); text.Location = new PCBI.MathUtils.PointD(-120, y * 500 + 200); text.WidthFactor = 1; textForPad.SetSpecifics(text); //right side IODBObject textForPad2 = filter.CreateText(rasterLayer); ITextSpecificsD text2 = (ITextSpecificsD)textForPad.GetSpecificsD(); text2.Text = text.Text; text2.TextSize = new SizeF(50, 80); text2.Location = new PCBI.MathUtils.PointD(countXLines * 500 + 120, y * 500 + 200); text2.WidthFactor = 1; textForPad2.SetSpecifics(text2); } for (int x = 0; x < countXLines; x++) { IODBObject textForPad = filter.CreateText(rasterLayer); ITextSpecificsD text = (ITextSpecificsD)textForPad.GetSpecificsD(); text.Text = "X" + (x + 1); text.TextSize = new SizeF(50, 80); text.Location = new PCBI.MathUtils.PointD(x * 500 + 200, -100); text.Rotation = -90; text.WidthFactor = 1; textForPad.SetSpecifics(text); //top side IODBObject textForPad2 = filter.CreateText(rasterLayer); ITextSpecificsD text2 = (ITextSpecificsD)textForPad.GetSpecificsD(); text2.Text = text.Text; text2.TextSize = new SizeF(50, 80); text2.Location = new PCBI.MathUtils.PointD(x * 500 + 300, countYLines * 500 + 100); text2.Rotation = 90; text2.WidthFactor = 1; textForPad2.SetSpecifics(text2); #endregion } foreach (string drillName in matrix.GetAllDrillLayerNames()) { IODBLayer drillLayer = (IODBLayer)step.GetLayer(drillName); foreach (IODBObject drill in drillLayer.GetAllLayerObjects()) { Dictionary <PCBI.FeatureAttributeEnum, string> attribs = drill.GetAttributesDictionary(); if (drill.Type == IObjectType.Pad && attribs.ContainsKey(PCBI.FeatureAttributeEnum.drill) && attribs.ContainsKey(PCBI.FeatureAttributeEnum.geometry)) { if (attribs[PCBI.FeatureAttributeEnum.drill].ToUpperInvariant() == "NON_PLATED" && attribs[PCBI.FeatureAttributeEnum.geometry].ToUpperInvariant() == "ICTAUFNAHME") { IODBObject drillMarker = filter.CreatePad(rasterLayer); IPadSpecificsD drillSpec = (IPadSpecificsD)drill.GetSpecificsD(); int shapeIndexNew = IFilter.AddToolDefinitionRound(rasterLayer, (float)drillSpec.Diameter); drillSpec.ShapeIndex = shapeIndexNew; drillMarker.SetSpecifics(drillSpec); } } } } matrix.UpdateDataAndList(); if (!useFlattenStep) { parent.UIAction.Execute(ID_ActionItem.ID_PRINT_PREVIEW); } }