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);
            }
        }
Exemplo n.º 2
0
        private void SetToGrid(float grid, IPCBIWindow parent)
        {
            IStep step = parent.GetCurrentStep();

            foreach (IODBObject obj in step.GetSelectedElements())
            {
                IObjectSpecifics obs = obj.GetSpecifics();
                if (obs.GetType() == typeof(ILineSpecifics))
                {
                    ILineSpecifics lines = (ILineSpecifics)obs;
                    lines.Start.X = correction(lines.Start.X, grid);
                    lines.Start.Y = correction(lines.Start.Y, grid);

                    lines.End.X = correction(lines.End.X, grid);
                    lines.End.Y = correction(lines.End.Y, grid);
                    obj.SetSpecifics(lines);
                }
                else
                if (obs.GetType() == typeof(IPadSpecifics))
                {
                    IPadSpecifics pads = (IPadSpecifics)obs;

                    pads.Location.X = correction(pads.Location.X, grid);
                    pads.Location.Y = correction(pads.Location.Y, grid);
                    obj.SetSpecifics(pads);
                }
            }
        }
Exemplo n.º 3
0
        private double CalculateNetLenth(List <IODBObject> list)
        {
            double distance = 0;

            foreach (IODBObject odbObj in list)
            {
                IObjectSpecifics lineSpec = odbObj.GetSpecifics();
                if (lineSpec.GetType() == typeof(ILineSpecifics))
                {
                    distance += distancePointToPoint(((ILineSpecifics)lineSpec).Start, ((ILineSpecifics)lineSpec).End);
                }
            }
            return(distance);
        }
Exemplo n.º 4
0
        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)
        {
            //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();
        }