public void Execute(IPCBIWindow parent)
        {
            this.parent = parent;
            IStep step = parent.GetCurrentStep();

            if (step == null)
            {
                return;
            }

            List <string> columsStrings = new List <string>();

            columsStrings.Add("Analyse Resource");
            columsStrings.Add("Reference");
            columsStrings.Add("Distance");
            columsStrings.Add("Rule");
            columsStrings.Add("Start");
            columsStrings.Add("End");
            PCB_Investigator.PCBIWindows.PCBIResultDialog resultDLG = new PCB_Investigator.PCBIWindows.PCBIResultDialog(columsStrings);
            double unit     = 1;
            double distance = PCBI.MathUtils.IMath.MM2Mils(1.0f);

            if (parent.GetUnit())
            {
                unit = 25.4;
                //MessageBox.Show("Component to Outline distance: " + PCBI.MathUtils.IMath.Mils2MM(distance).ToString("N3") + " micron", "DRC Component to Board Outline");
            }
            else
            {
                //MessageBox.Show("Component to Outline distance: " + distance.ToString("N3") + " mils", "DRC Component to Board Outline");
                unit = 1;
            }
            foreach (ICMPObject cmp in step.GetAllCMPObjects())
            {
                PCBI.MathUtils.IPolyClass CMP_Poly = cmp.GetPolygonOutline(false);
                IODBObject boardOutline            = parent.GetCurrentStep().GetPCBOutlineAsODBObject();
                IPolyClass polyOutline             = boardOutline.GetPolygonOutline();
                PointD     start            = new PointD(0, 0);
                PointD     end              = new PointD(0, 0);
                double     measuredDistance = cmp.GetPolygonOutline().DistanceTo(polyOutline, ref start, ref end);
                if (measuredDistance < distance)
                {
                    ListViewItem lvi = new ListViewItem("Cpmp2Outline");
                    lvi.SubItems.Add(cmp.Ref);
                    lvi.SubItems.Add((measuredDistance * unit).ToString());
                    lvi.SubItems.Add((distance * unit).ToString());
                    lvi.SubItems.Add((start * unit).ToString());
                    lvi.SubItems.Add((end * unit).ToString());
                    lvi.Tag = cmp;
                    resultDLG.AddListViewItem(lvi);
                }
            }

            resultDLG.ItemSelectionChanged += ResultDLG_ItemSelectionChanged1;;
            resultDLG.Size = new Size(500, 350);
            resultDLG.Show();
        }
        void Parent_PCBIFormGraphicPaneDrawing(Graphics g, int ClientWidth, int ClientHeight)
        {
            if (!parent.JobIsLoaded) return;

            RectangleF BoardSize = parent.GetJobBounds();

            if (BoardSize == RectangleF.Empty) return;

            Point locationBoard = parent.WorldToClient(BoardSize.Location);
            //Be careful with top and bottom because the display is vertical mirrored!
            Point rightTopBoard = parent.WorldToClient(new PointF(BoardSize.Right, BoardSize.Bottom));
            #region draw down line
            g.DrawLine(Pens.Green, new Point(locationBoard.X, locationBoard.Y + 15), new Point(rightTopBoard.X, locationBoard.Y + 15));
            g.DrawLine(Pens.Green, new Point(locationBoard.X, locationBoard.Y + 10), new Point(locationBoard.X, locationBoard.Y + 20));
            g.DrawLine(Pens.Green, new Point(rightTopBoard.X, locationBoard.Y + 10), new Point(rightTopBoard.X, locationBoard.Y + 20));
            #endregion
            #region draw right line
            g.DrawLine(Pens.Green, new Point(rightTopBoard.X + 15, locationBoard.Y), new Point(rightTopBoard.X + 15, rightTopBoard.Y));
            g.DrawLine(Pens.Green, new Point(rightTopBoard.X + 10, locationBoard.Y), new Point(rightTopBoard.X + 20, locationBoard.Y));
            g.DrawLine(Pens.Green, new Point(rightTopBoard.X + 10, rightTopBoard.Y), new Point(rightTopBoard.X + 20, rightTopBoard.Y));
            #endregion
            //do translate for Strings

            string BoaurdSizeWidth = BoardSize.Width.ToString("N3");
            string BoardSizeHeight = BoardSize.Height.ToString("N3");
            string BoaurdSizeLU = BoardSize.X.ToString("N3") + " / " + BoardSize.Y.ToString("N3");
            string BoardSizeRO = BoardSize.Right.ToString("N3") + " / " + BoardSize.Bottom.ToString("N3");

            if (parent.GetUnit())
            {
                float unit = 25.4f / 1000;
                BoaurdSizeWidth = (BoardSize.Width * unit).ToString("N3");
                BoardSizeHeight = (BoardSize.Height * unit).ToString("N3");
                BoaurdSizeLU = (BoardSize.X * unit).ToString("N3") + " / " + (BoardSize.Y * unit).ToString("N3");
                BoardSizeRO = (BoardSize.Right * unit).ToString("N3") + " / " + (BoardSize.Bottom * unit).ToString("N3");
                g.TranslateTransform(1, -1);
                g.DrawString(BoaurdSizeWidth + " mm", new Font("Arial", 10), Brushes.YellowGreen, new Point((int)((locationBoard.X + rightTopBoard.X) / 2.1), locationBoard.Y + 20));
                g.DrawString(BoardSizeHeight + " mm", new Font("Arial", 10), Brushes.YellowGreen, new Point(rightTopBoard.X + 20, (int)((rightTopBoard.Y + locationBoard.Y) / 2) - 5));

                g.DrawString(BoaurdSizeLU + " mm", new Font("Arial", 10), Brushes.AliceBlue, new Point((int)((locationBoard.X)), locationBoard.Y + 40));
                g.DrawString(BoardSizeRO + " mm", new Font("Arial", 10), Brushes.AliceBlue, new Point(rightTopBoard.X + 20, (int)((rightTopBoard.Y)) - 5));

            }
            else
            {
                g.TranslateTransform(1, -1);
                g.DrawString(BoaurdSizeWidth + " mils", new Font("Arial", 10), Brushes.YellowGreen, new Point((int)((locationBoard.X + rightTopBoard.X) / 2.1), locationBoard.Y + 20));
                g.DrawString(BoardSizeHeight + " mils", new Font("Arial", 10), Brushes.YellowGreen, new Point(rightTopBoard.X + 20, (int)((rightTopBoard.Y + locationBoard.Y) / 2) - 5));


                g.DrawString(BoaurdSizeLU + " mils", new Font("Arial", 10), Brushes.AliceBlue, new Point((int)((locationBoard.X)), locationBoard.Y + 40));
                g.DrawString(BoardSizeRO + " mils", new Font("Arial", 10), Brushes.AliceBlue, new Point(rightTopBoard.X + 20, (int)((rightTopBoard.Y)) - 5));
            }
        }
Example #3
0
        public void Execute(IPCBIWindow parent)
        {
            if (parent.GetCurrentStep() == null)
            {
                return;
            }
            IStep   step   = parent.GetCurrentStep();
            IFilter filter = new IFilter(parent);

            if (parent.GetCurrentStep() == null)
            {
                return;
            }

            if (step.GetCMPLayer(true) != null)
            {
                step.GetCMPLayer(true).EnableLayer(true);
            }
            if (step.GetCMPLayer(false) != null)
            {
                step.GetCMPLayer(false).EnableLayer(true);
            }
            double distance = PCBI.MathUtils.IMath.MM2Mils(0.5f);

            if (parent.GetUnit())
            {
                MessageBox.Show("Component to Outline distance: " + PCBI.MathUtils.IMath.Mils2MM(distance).ToString("N3") + " micron", "DRC Component to Board Outline");
            }
            else
            {
                MessageBox.Show("Component to Outline distance: " + distance.ToString("N3") + " mils", "DRC Component to Board Outline");
            }
            foreach (ICMPObject cmp in step.GetAllCMPObjects())
            {
                PCBI.MathUtils.IPolyClass CMP_Poly = cmp.GetPolygonOutline(false);
                IODBObject boardOutline            = parent.GetCurrentStep().GetPCBOutlineAsODBObject();
                IPolyClass polyOutline             = boardOutline.GetPolygonOutline();
                PointD     start = new PointD(0, 0);
                PointD     end   = new PointD(0, 0);

                if (cmp.GetPolygonOutline().DistanceTo(polyOutline, ref start, ref end) < distance)
                {
                    cmp.Select(true);
                }
            }
            parent.UpdateView();
        }
Example #4
0
        void Parent_PCBIFormGraphicPaneDrawing(Graphics g, int ClientWidth, int ClientHeight)
        {
            foreach (RectangleF BoardSize in listToShow)
            {
                if (BoardSize == RectangleF.Empty)
                {
                    return;
                }

                Point locationBoard = parent.WorldToClient(BoardSize.Location);
                //Be careful with top and bottom because the display is vertical mirrored!
                Point rightTopBoard  = parent.WorldToClient(new PointF(BoardSize.Right, BoardSize.Bottom));
                Point middleTopBoard = parent.WorldToClient(new PointF(BoardSize.Left, BoardSize.Bottom));

                #region draw down line
                g.DrawLine(Pens.Green, new Point(locationBoard.X, locationBoard.Y + 15), new Point(rightTopBoard.X, locationBoard.Y + 15));
                g.DrawLine(Pens.Green, new Point(locationBoard.X, locationBoard.Y + 10), new Point(locationBoard.X, locationBoard.Y + 20));
                g.DrawLine(Pens.Green, new Point(rightTopBoard.X, locationBoard.Y + 10), new Point(rightTopBoard.X, locationBoard.Y + 20));
                #endregion
                #region draw right line
                g.DrawLine(Pens.Green, new Point(rightTopBoard.X + 15, locationBoard.Y), new Point(rightTopBoard.X + 15, rightTopBoard.Y));
                g.DrawLine(Pens.Green, new Point(rightTopBoard.X + 10, locationBoard.Y), new Point(rightTopBoard.X + 20, locationBoard.Y));
                g.DrawLine(Pens.Green, new Point(rightTopBoard.X + 10, rightTopBoard.Y), new Point(rightTopBoard.X + 20, rightTopBoard.Y));
                #endregion
                //do translate for Strings

                string BoardSizeWidth  = BoardSize.Width.ToString("N3");
                string BoardSizeHeight = BoardSize.Height.ToString("N3");
                string BoardSizeLU     = BoardSize.X.ToString("N3") + " / " + BoardSize.Y.ToString("N3");
                string BoardSizeRO     = BoardSize.Right.ToString("N3") + " / " + BoardSize.Bottom.ToString("N3");
                PointF center          = new PointF(BoardSize.X + BoardSize.Width / 2, BoardSize.Y + BoardSize.Height / 2);
                Point  centerBoard     = parent.WorldToClient(center);
                string BoardCenter     = center.X.ToString("N3") + " / " + center.Y.ToString("N3");
                if (parent.GetUnit())
                {
                    float unit = 25.4f / 1000;
                    BoardSizeWidth  = (BoardSize.Width * unit).ToString("N3");
                    BoardSizeHeight = (BoardSize.Height * unit).ToString("N3");
                    BoardSizeLU     = (BoardSize.X * unit).ToString("N3") + " / " + (BoardSize.Y * unit).ToString("N3");
                    BoardSizeRO     = (BoardSize.Right * unit).ToString("N3") + " / " + (BoardSize.Bottom * unit).ToString("N3");
                    BoardCenter     = (center.X * unit).ToString("N3") + " / " + (center.Y * unit).ToString("N3");

                    g.TranslateTransform(1, -1);
                    g.DrawString(BoardSizeWidth + " mm", new Font("Arial", 10), Brushes.Green, new Point((int)((locationBoard.X + rightTopBoard.X) / 2.1), locationBoard.Y + 20));
                    g.DrawString(BoardSizeHeight + " mm", new Font("Arial", 10), Brushes.Green, new Point(rightTopBoard.X + 20, (int)((rightTopBoard.Y + locationBoard.Y) / 2) - 5));

                    g.DrawString(BoardSizeLU + " mm", new Font("Arial", 10), Brushes.Aqua, new Point((int)((locationBoard.X)), locationBoard.Y + 40));
                    g.DrawString(BoardSizeRO + " mm", new Font("Arial", 10), Brushes.Aqua, new Point(rightTopBoard.X + 20, (int)((rightTopBoard.Y)) - 5));
                    g.DrawString("C:" + BoardCenter + " mm", new Font("Arial", 10), Brushes.Yellow, new Point(middleTopBoard.X, (int)((middleTopBoard.Y)) - 15));
                }
                else
                {
                    g.TranslateTransform(1, -1);
                    g.DrawString(BoardSizeWidth + " mils", new Font("Arial", 10), Brushes.Aqua, new Point((int)((locationBoard.X + rightTopBoard.X) / 2.1), locationBoard.Y + 20));
                    g.DrawString(BoardSizeHeight + " mils", new Font("Arial", 10), Brushes.Aqua, new Point(rightTopBoard.X + 20, (int)((rightTopBoard.Y + locationBoard.Y) / 2) - 5));


                    g.DrawString(BoardSizeLU + " mils", new Font("Arial", 10), Brushes.Aqua, new Point((int)((locationBoard.X)), locationBoard.Y + 40));
                    g.DrawString(BoardSizeRO + " mils", new Font("Arial", 10), Brushes.Aqua, new Point(rightTopBoard.X + 20, (int)((rightTopBoard.Y)) - 5));
                    g.DrawString("C:" + BoardCenter + " mils", new Font("Arial", 10), Brushes.Yellow, new Point(middleTopBoard.X, (int)((middleTopBoard.Y)) - 15));
                }
            }
        }
        void Parent_PCBIFormGraphicPaneDrawing(Graphics g, int ClientWidth, int ClientHeight)
        {
            if (!parent.JobIsLoaded)
            {
                return;
            }

            RectangleF BoardSize = RectangleF.Empty;

            foreach (IObject obj in parent.GetCurrentStep().GetSelectedElements())
            {
                if (BoardSize == RectangleF.Empty)
                {
                    BoardSize = obj.GetBounds();
                }
                else
                {
                    BoardSize = RectangleF.Union(BoardSize, obj.GetBounds());
                }
            }
            foreach (ICMPObject obj in parent.GetCurrentStep().GetSelectedCMPs())
            {
                PCBI.Automation.DrawingParameters.IComponentParameters dp = new PCBI.Automation.DrawingParameters.IComponentParameters();
                dp.ShowPins = false;
                if (BoardSize == RectangleF.Empty)
                {
                    if (dp.ShowPins)
                    {
                        BoardSize = obj.GetBounds();
                    }
                    else
                    {
                        BoardSize = new RectangleF((float)obj.GetBodyBoundsD().X, (float)obj.GetBodyBoundsD().Y, (float)obj.GetBodyBoundsD().Width, (float)obj.GetBodyBoundsD().Height);
                    }
                }
                else
                {
                    BoardSize = RectangleF.Union(BoardSize, obj.GetBounds());
                }
            }

            if (BoardSize == RectangleF.Empty)
            {
                return;
            }

            Point locationBoard = parent.WorldToClient(BoardSize.Location);
            //Be careful with top and bottom because the display is vertical mirrored!
            Point rightTopBoard  = parent.WorldToClient(new PointF(BoardSize.Right, BoardSize.Bottom));
            Point middleTopBoard = parent.WorldToClient(new PointF(BoardSize.Left, BoardSize.Bottom));

            #region draw down line
            g.DrawLine(Pens.Green, new Point(locationBoard.X, locationBoard.Y + 15), new Point(rightTopBoard.X, locationBoard.Y + 15));
            g.DrawLine(Pens.Green, new Point(locationBoard.X, locationBoard.Y + 10), new Point(locationBoard.X, locationBoard.Y + 20));
            g.DrawLine(Pens.Green, new Point(rightTopBoard.X, locationBoard.Y + 10), new Point(rightTopBoard.X, locationBoard.Y + 20));
            #endregion
            #region draw right line
            g.DrawLine(Pens.Green, new Point(rightTopBoard.X + 15, locationBoard.Y), new Point(rightTopBoard.X + 15, rightTopBoard.Y));
            g.DrawLine(Pens.Green, new Point(rightTopBoard.X + 10, locationBoard.Y), new Point(rightTopBoard.X + 20, locationBoard.Y));
            g.DrawLine(Pens.Green, new Point(rightTopBoard.X + 10, rightTopBoard.Y), new Point(rightTopBoard.X + 20, rightTopBoard.Y));
            #endregion
            //do translate for Strings

            string BoardSizeWidth  = BoardSize.Width.ToString("N3");
            string BoardSizeHeight = BoardSize.Height.ToString("N3");
            string BoardSizeLU     = BoardSize.X.ToString("N3") + " / " + BoardSize.Y.ToString("N3");
            string BoardSizeRO     = BoardSize.Right.ToString("N3") + " / " + BoardSize.Bottom.ToString("N3");
            PointF center          = new PointF(BoardSize.X + BoardSize.Width / 2, BoardSize.Y + BoardSize.Height / 2);
            Point  centerBoard     = parent.WorldToClient(center);
            string BoardCenter     = center.X.ToString("N3") + " / " + center.Y.ToString("N3");
            if (parent.GetUnit())
            {
                float unit = 25.4f / 1000;
                BoardSizeWidth  = (BoardSize.Width * unit).ToString("N3");
                BoardSizeHeight = (BoardSize.Height * unit).ToString("N3");
                BoardSizeLU     = (BoardSize.X * unit).ToString("N3") + " / " + (BoardSize.Y * unit).ToString("N3");
                BoardSizeRO     = (BoardSize.Right * unit).ToString("N3") + " / " + (BoardSize.Bottom * unit).ToString("N3");
                BoardCenter     = (center.X * unit).ToString("N3") + " / " + (center.Y * unit).ToString("N3");

                g.TranslateTransform(1, -1);
                g.DrawString(BoardSizeWidth + " mm", new Font("Arial", 10), Brushes.Green, new Point((int)((locationBoard.X + rightTopBoard.X) / 2.1), locationBoard.Y + 20));
                g.DrawString(BoardSizeHeight + " mm", new Font("Arial", 10), Brushes.Green, new Point(rightTopBoard.X + 20, (int)((rightTopBoard.Y + locationBoard.Y) / 2) - 5));

                g.DrawString(BoardSizeLU + " mm", new Font("Arial", 10), Brushes.Aqua, new Point((int)((locationBoard.X)), locationBoard.Y + 40));
                g.DrawString(BoardSizeRO + " mm", new Font("Arial", 10), Brushes.Aqua, new Point(rightTopBoard.X + 20, (int)((rightTopBoard.Y)) - 5));
                g.DrawString("C:" + BoardCenter + " mm", new Font("Arial", 10), Brushes.Yellow, new Point(middleTopBoard.X, (int)((middleTopBoard.Y)) - 15));
            }
            else
            {
                g.TranslateTransform(1, -1);
                g.DrawString(BoardSizeWidth + " mils", new Font("Arial", 10), Brushes.Aqua, new Point((int)((locationBoard.X + rightTopBoard.X) / 2.1), locationBoard.Y + 20));
                g.DrawString(BoardSizeHeight + " mils", new Font("Arial", 10), Brushes.Aqua, new Point(rightTopBoard.X + 20, (int)((rightTopBoard.Y + locationBoard.Y) / 2) - 5));


                g.DrawString(BoardSizeLU + " mils", new Font("Arial", 10), Brushes.Aqua, new Point((int)((locationBoard.X)), locationBoard.Y + 40));
                g.DrawString(BoardSizeRO + " mils", new Font("Arial", 10), Brushes.Aqua, new Point(rightTopBoard.X + 20, (int)((rightTopBoard.Y)) - 5));
                g.DrawString("C:" + BoardCenter + " mils", new Font("Arial", 10), Brushes.Yellow, new Point(middleTopBoard.X, (int)((middleTopBoard.Y)) - 15));
            }
        }
Example #6
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 Report_Via_Pad()
        {
            var excelType = Type.GetTypeFromProgID("Excel.Application");

            dynamic excel = Activator.CreateInstance(excelType);

            excel.Visible = true;
            excel.Workbooks.Add();
            //////

            StringBuilder sb = new StringBuilder();

            IStep   step = Parent.GetCurrentStep();
            IMatrix m    = Parent.GetMatrix();

            foreach (INet NetList in step.GetNets())
            {
                foreach (IODBObject obj in NetList.GetAllNetObjects(Parent))
                {
                    if (m.GetMatrixLayerType(obj.GetParentLayerName()) == MatrixLayerType.Drill)
                    {
                        if (obj.Type == IObjectType.Pad)
                        {
                            IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics();
                            float         x  = ps.Location.X;
                            float         Y  = ps.Location.Y;
                            if (Parent.GetUnit())
                            {
                                float unit = 25.4f / 1000;
                                x = x * unit;
                                Y = Y * unit;
                            }
                            sb.Append("Via;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine);
                        }
                    }
                    else
                    if (obj.GetParentLayerName().ToLower() == m.GetTopSignalLayer().ToLower())
                    {
                        if (obj.Type == IObjectType.Pad)
                        {
                            IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics();
                            if (ps.Type != PCBI.Symbol_Type.r)
                            {
                                float x = ps.Location.X;
                                float Y = ps.Location.Y;
                                if (Parent.GetUnit())
                                {
                                    float unit = 25.4f / 1000;
                                    x = x * unit;
                                    Y = Y * unit;
                                }
                                sb.Append("PAD_top;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine);
                            }
                        }
                    }
                    else
                    if (obj.GetParentLayerName().ToLower() == m.GetBotSignalLayer().ToLower())
                    {
                        if (obj.Type == IObjectType.Pad)
                        {
                            IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics();
                            if (ps.Type != PCBI.Symbol_Type.r)
                            {
                                float x = ps.Location.X;
                                float Y = ps.Location.Y;
                                if (Parent.GetUnit())
                                {
                                    float unit = 25.4f / 1000;
                                    x = x * unit;
                                    Y = Y * unit;
                                }
                                sb.Append("PAD_bot;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine);
                            }
                        }
                    }
                }
            }
            //////

            //string LVText = "Type\tNetName\tposx\tposy" + Environment.NewLine + sb.ToString();
            string     LVText       = "Type;NetName;posx;posy" + Environment.NewLine + sb.ToString();
            string     LVCsv        = sb.ToString();
            DataObject LVDataObject = new DataObject();

            LVDataObject.SetData(DataFormats.Text, false, LVText);
            LVDataObject.SetData(DataFormats.CommaSeparatedValue, false, LVCsv);
            Clipboard.SetDataObject(LVDataObject, true);

            excel.ActiveSheet.Paste();

            //release the object
            System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
        }
Example #8
0
            public void SetInfos(IPCBIWindow parentPCBI)
            {
                if (!parentPCBI.JobIsLoaded)
                {
                    return;
                }

                IStep   curStep = parentPCBI.GetCurrentStep();
                IMatrix matrix  = parentPCBI.GetMatrix();

                if (curStep == null || matrix == null)
                {
                    return;                                    //sollte nicht vorkommen wenn job geladen ist
                }
                PCB_Investigator.PCBIWindows.PCBIWorkingDialog working = new PCB_Investigator.PCBIWindows.PCBIWorkingDialog();
                working.CanCancel(false);
                working.SetAnimationStatus(true);
                working.ShowWorkingDlgAsThread();
                richTextBoxMain.Clear();

                bool mm = parentPCBI.GetUnit();

                richTextBoxMain.Font = new System.Drawing.Font("Verdana", 10);

                working.SetStatusText("Working on Step Information " + curStep.Name + "...");

                float boardArea = curStep.CalculateBoardArea();

                if (mm)
                {
                    boardArea = (float)Math.Round(boardArea * (25.4 * 25.4) / 1000000, 3);
                }

                foreach (ILayer activeLayer in curStep.GetActiveLayerList())
                {
                    richTextBoxMain.AppendText("Layer " + activeLayer.GetLayerName() + Environment.NewLine);
                    richTextBoxMain.AppendText(Environment.NewLine);

                    working.SetStatusText("Working on Layer " + activeLayer.GetLayerName() + "...");

                    #region size of layer
                    RectangleF bounds = activeLayer.GetBounds();

                    richTextBoxMain.AppendText("Bounds: " + Environment.NewLine +
                                               "XMin " + (mm ? (IMath.Mils2MM(bounds.Left).ToString("F3") + " mm") : (bounds.Left.ToString("F3") + " mil")) + Environment.NewLine +
                                               "YMin " + (mm ? (IMath.Mils2MM(bounds.Top).ToString("F3") + " mm") : (bounds.Top.ToString("F3") + " mil")) + Environment.NewLine +
                                               "XMax " + (mm ? (IMath.Mils2MM(bounds.Right).ToString("F3") + " mm") : (bounds.Right.ToString("F3") + " mil")) + Environment.NewLine +
                                               "YMax " + (mm ? (IMath.Mils2MM(bounds.Bottom).ToString("F3") + " mm") : (bounds.Bottom.ToString("F3") + " mil")) + Environment.NewLine
                                               );
                    richTextBoxMain.AppendText(Environment.NewLine);
                    richTextBoxMain.AppendText("Width  " + (mm ? (IMath.Mils2MM(bounds.Width).ToString("F3") + " mm") : (bounds.Width.ToString("F3") + " mil")) + Environment.NewLine);
                    richTextBoxMain.AppendText("Height " + (mm ? (IMath.Mils2MM(bounds.Height).ToString("F3") + " mm") : (bounds.Height.ToString("F3") + " mil")) + Environment.NewLine);

                    richTextBoxMain.AppendText(Environment.NewLine);
                    #endregion

                    #region area calculation
                    if (activeLayer is IODBLayer)
                    {
                        IODBLayer odbActiveLayer = (IODBLayer)activeLayer;

                        float areaOfLayer = odbActiveLayer.CalculateArea(true);
                        if (mm)
                        {
                            richTextBoxMain.AppendText("Used Area   " + (Math.Round(areaOfLayer * (25.4 * 25.4) / 1000000, 3).ToString("F3")) + " of " + boardArea.ToString("F3") + " mm?" + Environment.NewLine);
                        }
                        else
                        {
                            richTextBoxMain.AppendText("Used Area   " + Math.Round(areaOfLayer, 2).ToString("F2") + " of " + (boardArea.ToString("F2")) + " mils?" + Environment.NewLine);
                        }
                    }
                    #endregion

                    #region count elements
                    int counterArc      = 0;
                    int counterCMPs     = 0;
                    int counterLines    = 0;
                    int counterSurfaces = 0;
                    int counterText     = 0;
                    int counterPads     = 0;

                    foreach (IObject obj in activeLayer.GetAllLayerObjects()) //count all elements
                    {
                        if (obj.Type == IObjectType.Arc)
                        {
                            counterArc++;
                        }
                        else if (obj.Type == IObjectType.Component)
                        {
                            counterCMPs++;
                        }
                        else if (obj.Type == IObjectType.Line)
                        {
                            counterLines++;
                        }
                        else if (obj.Type == IObjectType.Pad)
                        {
                            counterPads++;
                        }
                        else if (obj.Type == IObjectType.Surface)
                        {
                            counterSurfaces++;
                        }
                        else if (obj.Type == IObjectType.Text)
                        {
                            counterText++;
                        }
                    }
                    richTextBoxMain.AppendText(Environment.NewLine);

                    if (counterArc > 0)
                    {
                        richTextBoxMain.AppendText("Count Arcs:         " + counterArc.ToString("N0") + Environment.NewLine);
                    }
                    if (counterCMPs > 0)
                    {
                        richTextBoxMain.AppendText("Count Components:   " + counterCMPs.ToString("N0") + Environment.NewLine);
                    }
                    if (counterLines > 0)
                    {
                        richTextBoxMain.AppendText("Count Lines:        " + counterLines.ToString("N0") + Environment.NewLine);
                    }
                    if (counterPads > 0)
                    {
                        richTextBoxMain.AppendText("Count Pads:         " + counterPads.ToString("N0") + Environment.NewLine);
                    }
                    if (counterSurfaces > 0)
                    {
                        richTextBoxMain.AppendText("Count Area Fills:   " + counterSurfaces.ToString("N0") + Environment.NewLine);
                    }
                    if (counterText > 0)
                    {
                        richTextBoxMain.AppendText("Count Texts:        " + counterText.ToString("N0") + Environment.NewLine);
                    }
                    richTextBoxMain.AppendText(Environment.NewLine);
                    #endregion

                    #region matrix infos
                    MatrixLayerContext  context  = matrix.GetMatrixLayerContext(activeLayer.GetLayerName());
                    MatrixLayerPolarity polarity = matrix.GetMatrixLayerPolarity(activeLayer.GetLayerName());
                    MatrixLayerType     type     = matrix.GetMatrixLayerType(activeLayer.GetLayerName());
                    int index = matrix.GetRawIndexByName(activeLayer.GetLayerName());

                    richTextBoxMain.AppendText("Matrix Index " + index + ", Context " + context + ", Polarity " + polarity + ", Type " + type + Environment.NewLine);
                    #endregion

                    richTextBoxMain.AppendText(Environment.NewLine);
                    richTextBoxMain.AppendText(Environment.NewLine);
                    richTextBoxMain.AppendText(Environment.NewLine);
                }

                working.DoClose();
            }
        private void DrawSingleBoard(Graphics g, RectangleF BoardSize, PointD originOfBoard, int pcbCount, string BoardName, string Rotation)
        {
            Point locationBoard = parent.WorldToClient(BoardSize.Location);
            Point rightTopBoard = parent.WorldToClient(new PointF(BoardSize.Right, BoardSize.Bottom));

            RectangleF alphaRect = NormalizedRectangleDMinMax(locationBoard.X, locationBoard.Y, rightTopBoard.X, rightTopBoard.Y);

            g.FillRectangle(new SolidBrush(Color.FromArgb(100, 100, 100, 100)), alphaRect);


            #region draw down line
            g.DrawLine(Pens.Blue, new Point(locationBoard.X, locationBoard.Y), new Point(rightTopBoard.X, locationBoard.Y));
            #endregion
            #region draw top line
            g.DrawLine(Pens.Green, new Point(locationBoard.X, rightTopBoard.Y), new Point(rightTopBoard.X, rightTopBoard.Y));
            g.DrawLine(Pens.Green, new Point(locationBoard.X, locationBoard.Y), new Point(locationBoard.X, rightTopBoard.Y));
            #endregion
            #region draw right line
            g.DrawLine(Pens.Green, new Point(rightTopBoard.X, locationBoard.Y), new Point(rightTopBoard.X, rightTopBoard.Y));
            #endregion
            Point originBoard = parent.WorldToClient(originOfBoard);
            g.FillEllipse(new SolidBrush(Color.Yellow), new RectangleF((float)originBoard.X - 3, (float)originBoard.Y - 3, 6, 6));
            g.DrawString("PCB_" + pcbCount.ToString() + ": " + BoardName, new Font("Arial", 10), Brushes.AliceBlue, new Point((int)((originBoard.X)), originBoard.Y + 4));
            //do translate for Strings

            string BoaurdSizeWidth  = BoardSize.Width.ToString("N3");
            string BoardSizeHeight  = BoardSize.Height.ToString("N3");
            string BoaurdSizeLU     = BoardSize.X.ToString("N3") + " / " + BoardSize.Y.ToString("N3");
            string BoardSizeRO      = BoardSize.Right.ToString("N3") + " / " + BoardSize.Bottom.ToString("N3");
            string OriginBoardPoint = originOfBoard.X.ToString("N3") + " / " + originOfBoard.Y.ToString("N3");

            if (parent.GetUnit())
            {
                float unit = 25.4f / 1000;
                BoaurdSizeWidth  = (BoardSize.Width * unit).ToString("N3");
                BoardSizeHeight  = (BoardSize.Height * unit).ToString("N3");
                BoaurdSizeLU     = (BoardSize.X * unit).ToString("N3") + " / " + (BoardSize.Y * unit).ToString("N3");
                BoardSizeRO      = (BoardSize.Right * unit).ToString("N3") + " / " + (BoardSize.Bottom * unit).ToString("N3");
                OriginBoardPoint = (originOfBoard.X * unit).ToString("N3") + " / " + (originOfBoard.Y * unit).ToString("N3");
                // g.TranslateTransform(1, -1);
                g.DrawString(BoaurdSizeWidth + " mm", new Font("Arial", 10), Brushes.YellowGreen, new Point((int)((locationBoard.X + rightTopBoard.X) / 2.1), locationBoard.Y - 20));
                g.DrawString(BoardSizeHeight + " mm", new Font("Arial", 10), Brushes.YellowGreen, new Point(rightTopBoard.X - 70, (int)((rightTopBoard.Y + locationBoard.Y) / 2) - 5));

                g.DrawString(BoaurdSizeLU + " mm", new Font("Arial", 10), Brushes.AliceBlue, new Point((int)((locationBoard.X)), locationBoard.Y - 20));
                g.DrawString(BoardSizeRO + " mm", new Font("Arial", 10), Brushes.AliceBlue, new Point(rightTopBoard.X - 120, (int)((rightTopBoard.Y)) + 10));

                g.DrawString(OriginBoardPoint + " mm Angle:" + Rotation, new Font("Arial", 10), Brushes.AliceBlue, new Point(originBoard.X, (int)((originBoard.Y)) + 20));
            }
            else
            {
                //  g.TranslateTransform(1, -1);
                g.DrawString(BoaurdSizeWidth + " mils", new Font("Arial", 10), Brushes.YellowGreen, new Point((int)((locationBoard.X + rightTopBoard.X) / 2.1), locationBoard.Y - 20));
                g.DrawString(BoardSizeHeight + " mils", new Font("Arial", 10), Brushes.YellowGreen, new Point(rightTopBoard.X - 70, (int)((rightTopBoard.Y + locationBoard.Y) / 2) - 10));


                g.DrawString(BoaurdSizeLU + " mils", new Font("Arial", 10), Brushes.AliceBlue, new Point((int)((locationBoard.X)), locationBoard.Y - 20));
                g.DrawString(BoardSizeRO + " mils", new Font("Arial", 10), Brushes.AliceBlue, new Point(rightTopBoard.X - 120, (int)((rightTopBoard.Y)) + 10));

                g.DrawString(OriginBoardPoint + " mils Angle:" + Rotation, new Font("Arial", 10), Brushes.AliceBlue, new Point(originBoard.X, (int)((originBoard.Y)) + 20));
            }
        }
        public void Execute(IPCBIWindow parent)
        {
            //set options here:
            bool   onlySelectedComponent = true;
            bool   CalculateTopSide      = true;
            bool   CalculateBotSide      = true;
            double TopArea = 0;
            double BotArea = 0;

            IStep step = parent.GetCurrentStep();

            if (step == null)
            {
                return;               //no project loaded
            }
            List <ICMPObject> allCMPs = step.GetAllCMPObjects();

            foreach (ICMPObject cmp in allCMPs)
            {
                if (onlySelectedComponent && !cmp.IsSelected)
                {
                    continue;
                }

                PCBI.MathUtils.IPolyClass polygonOfCMP = cmp.GetPolygonOutline();

                foreach (PCBI.MathUtils.IEdge edge in polygonOfCMP.GetEdges())
                {
                    if (!CalculateTopSide && cmp.PlacedTop)
                    {
                        continue;
                    }
                    if (!CalculateBotSide && !cmp.PlacedTop)
                    {
                        continue;
                    }

                    //work with integrals to calculate the area
                    double extent = 0;
                    if (edge.Type == IEdgeType.Line)
                    {
                        extent = PCBI.MathUtils.IMath.DistancePointToPoint(edge.Begin, edge.End);
                    }
                    else
                    {
                        // Pi * R * winkel /180
                        double angle  = PCBI.MathUtils.IMath.GetAngle(edge.Begin, edge.End, ((PCBI.MathUtils.IArcEdge)edge).Center, ((PCBI.MathUtils.IArcEdge)edge).ClockWise);
                        double radius = PCBI.MathUtils.IMath.DistancePointToPoint(edge.Begin, ((PCBI.MathUtils.IArcEdge)edge).Center);
                        extent = Math.PI * radius * angle / 180;
                    }
                    if (cmp.PlacedTop)
                    {
                        TopArea += extent * cmp.CompHEIGHT;
                    }
                    else
                    {
                        BotArea += extent * cmp.CompHEIGHT;
                    }
                }
            }

            double areaPCB = step.CalculateBoardArea();

            if (parent.GetUnit())              //change mils? to cm?
            {
                areaPCB = areaPCB / 155000.31; //(1/2.54*2.54)
                TopArea = TopArea / 155000.31;
                BotArea = BotArea / 155000.31;
            }

            System.Windows.Forms.MessageBox.Show((onlySelectedComponent ? "Selected Component side walls:" : "All side walls of Components:") + Environment.NewLine +
                                                 (CalculateTopSide ? "Top Side Components: " + TopArea + Environment.NewLine : "") +
                                                 (CalculateBotSide ? "Bot Side Components: " + BotArea + Environment.NewLine : "") +
                                                 ((!CalculateBotSide && !CalculateTopSide) ? "No Elements allowed, please run check with other parameters!" : "") + Environment.NewLine +
                                                 "Board Area " + areaPCB + (parent.GetUnit() ?  " cm?":" mils?")
                                                 , "Result", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
        }