예제 #1
0
        private static PcbGraphics PolylineHelper(PcbUnits coordinateUnits,Piece item)
        {
            PcbGraphicsLayer l = PcbGraphicsLayer.TopSilk;
            PcbLineType      t = PcbLineType.Solid;

            if (Piece.GraphicsLayerMapping.ContainsKey(item.CurrentLayer))
            {
                l = Piece.GraphicsLayerMapping[item.CurrentLayer];
            }
            else
            {
                WarningListener.AddFormat(new NotImplementedException(),
                                          "Default graphics layer used instead of #{0}",item.CurrentLayer);
            }
            if (Piece.LineTypeMapping.ContainsKey(item.CurrentLineType))
            {
                t = Piece.LineTypeMapping[item.CurrentLineType];
            }
            else
            {
                WarningListener.AddFormat(new NotImplementedException(),
                                          "Default line type used instead of {0}",Enum.GetName(typeof(Piece.LineType),item.CurrentLineType));
            }
            PcbGraphics g = new PcbGraphics(coordinateUnits,coordinateUnits,l,item.XY.Count - 1);

            for (int i = 1; i < item.XY.Count; i++)
            {
                g.Lines.Add(new PcbSilkLine(item.XY[i - 1],item.XY[i],coordinateUnits,coordinateUnits,item.Width,t));
            }
            return(g);
        }
예제 #2
0
        private static void ProcessDecalPieces(PcbDesign res,PcbUnits coordinateUnits,Partdecal decal)
        {
            //Pieces are graphics and traces
            res.Traces.Capacity   += decal.Pieces.Count(x => x.CurrentType == Piece.PieceType.Copper);
            res.Graphics.Capacity += decal.Pieces.Count(x => x.CurrentType != Piece.PieceType.Copper);
            foreach (var item in decal.Pieces)
            {
                switch (item.CurrentType)
                {
                case Piece.PieceType.Open:
                    res.Graphics.Add(PolylineHelper(coordinateUnits,item));
                    break;

                case Piece.PieceType.Closed:
                    res.Graphics.Add(PolylineHelper(coordinateUnits,item));
                    break;

                case Piece.PieceType.Copper:
                    //Should move it to LINES instead of PARTDECAL
                    res.Traces.Add(
                        new PcbTrace(item.CurrentLayer == Piece.LayerAllNumber ? PcbLayer.All : (PcbLayer)item.CurrentLayer,
                                     item.Width,coordinateUnits,coordinateUnits,item.XY));
                    break;

                default:
                    WarningListener.AddFormat(new NotImplementedException(),
                                              "Decal type {0} ignored.",Enum.GetName(typeof(Piece.PieceType),item.CurrentType));
                    break;
                }
            }
        }