private void buttonAddToReferences_Click(object sender, EventArgs e)
        {
            System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();
            nfi.NumberDecimalSeparator = ".";
            nfi.NumberGroupSeparator   = ",";
            // find designator colum
            int columDesignator = 0;

            attribCount = 0;
            //         for (int colDes = 0; colDes < myDataGridView.Rows[0].Cells.Count; colDes++)
            //         {
            //             if (myDataGridView.Columns[colDes].HeaderText.ToLower().Trim() == "designator")
            //             {
            //                 columDesignator = colDes;
            //                 break;
            //             }
            //         }
            columDesignator = comboBoxREfColum.SelectedIndex;
            for (int rows = 0; rows < myDataGridView.Rows.Count - 1; rows++)
            {
                myDataGridView.Rows[rows].Cells[columDesignator].Style.BackColor = Color.Red;
                string Designators = myDataGridView.Rows[rows].Cells[columDesignator].Value.ToString();
                Designators = CreateNewRefList(Designators);
                string[] desList = Designators.Split(',');
                foreach (string CompDesignator in desList)
                {
                    ICMPObject cmp = GetComponent(CompDesignator.Trim());
                    if (cmp == null)
                    {
                        continue;
                    }
                    for (int col = 0; col < myDataGridView.Rows[rows].Cells.Count; col++)
                    {
                        if (col == columDesignator)
                        {
                            continue;
                        }
                        if (myDataGridView.Columns[col].HeaderText.ToLower() == "height")
                        {
                            IComponentSpecifics cs = (IComponentSpecifics)cmp.GetSpecifics();
                            cs.Height = float.Parse(myDataGridView.Rows[rows].Cells[col].Value.ToString().Replace(",", "."), nfi);
                            cmp.SetSpecifics(cs);
                        }
                        else
                        {
                            cmp.AddComponentAttribute(myDataGridView.Columns[col].HeaderText, myDataGridView.Rows[rows].Cells[col].Value.ToString(), false);  // HeaderText.toLower() ??
                            myDataGridView.Rows[rows].Cells[columDesignator].Style.BackColor = Color.GreenYellow;
                        }
                    }
                }
            }
            if (attribCount > 0)
            {
                MessageBox.Show(attribCount.ToString() + " : Components changed, " + PCBI_Parent.GetCurrentStep().GetAllCMPObjects().Count.ToString() + " Components in design", "Finished");
            }
            else
            {
                MessageBox.Show("No attributes added", "Finished without success");
            }
        }
        private RectangleF GetPinBounds(ICMPObject comp)
        {
            RectangleF b_all = RectangleF.Empty;

            foreach (IPin pin in comp.GetPinList())
            {
                pin.GetBounds(comp);
                RectangleF b1 = pin.GetBounds(comp);
                b_all = AddRectangleF(b1, b_all);
            }
            return(b_all);
        }
예제 #3
0
        private void buttonAddToReferences_Click(object sender, EventArgs e)
        {
            if (PCBI_Parent == null)
            {
                return;
            }

            for (int rows = 0; rows < myDataGridView.Rows.Count - 1; rows++)
            {
                ICMPObject cmp = GetComponent(myDataGridView.Rows[rows].Cells[0].Value.ToString());
                if (cmp == null)
                {
                    continue;
                }

                for (int col = 1; col < myDataGridView.Rows[rows].Cells.Count; col++)
                {
                    //myDataGridView.Rows[0].Cells[col].Value.ToString()
                    cmp.AddComponentAttribute(myDataGridView.Columns[col].HeaderText.ToString(), myDataGridView.Rows[rows].Cells[col].Value.ToString(), false);
                }
            }
        }
예제 #4
0
        private void CheckTestpoints(ICMPLayer layer, ref PCB_Investigator.PCBIWindows.PCBIReportDialog reportDlg)
        {
            if (layer == null)
            {
                MessageBox.Show("Layer is null referenced.");
                return;
            }

            reportDlg.AppendLog("Analyzing " + layer.GetLayerName());

            PointD fromPoint = PointD.Empty, toPoint = PointD.Empty;

            List <IObject> allComponents = layer.GetAllLayerObjects();
            double         maxDistance   = Math.Max(MinDistanceTP2TP, MinDistanceTP2CMP) * 1.01;

            int tpCountOK = 0;

            foreach (IObject element in allComponents)
            {
                if (element is ICMPObject)
                {
                    ICMPObject tpCmp = (ICMPObject)element;

                    if (tpCmp.Ref.StartsWith(tpReferencePrexix))  //cmp is a Testpoint...
                    {
                        tpCountTotal++;
                        bool       hasWrongDistance = false;
                        RectangleD checkRect        = tpCmp.GetBoundsD();
                        checkRect.Inflate(maxDistance, maxDistance);

                        IPolyClass tpPoly = tpCmp.GetPolygonOutline(false);

                        foreach (IObject nearElement in layer.GetAllObjectInRectangle(checkRect))
                        {
                            if (nearElement is ICMPObject)
                            {
                                ICMPObject nearCmp = (ICMPObject)nearElement;
                                if (tpCmp.Ref == nearCmp.Ref)
                                {
                                    continue;
                                }
                                if (!nearCmp.Ref.StartsWith(tpReferencePrexix) && nearCmp.CompHEIGHT < PCBI.MathUtils.IMath.MM2Mils(5))
                                {
                                    continue;                                                                                                     // Abfrage ob Bauteil kleiner 5 mm, dann ignorieren ausser Testpunkte
                                }
                                IPolyClass nearCmpPoly = nearCmp.GetPolygonOutline(false);

                                if (tpPoly != null && nearCmpPoly != null)
                                {
                                    double distance    = tpPoly.DistanceTo(nearCmpPoly, ref fromPoint, ref toPoint);
                                    double distanceC2C = IMath.DistancePointToPoint(nearCmp.Position, tpCmp.Position);
                                    if (nearCmp.Ref.StartsWith(tpReferencePrexix))  //nearCmpPoly is also a Testpoint...
                                    {
                                        if (distance < MinDistanceTP2TP)
                                        {
                                            if (hasWrongDistance == false)
                                            {
                                                tpCmp.ObjectColor = Color.Orange;
                                                hasWrongDistance  = true;
                                            }
                                            reportDlg.AppendLog(" -> " + tpCmp.Ref + " too close to " + nearCmp.Ref + " (" + PCBI.MathUtils.IMath.Mils2MM(distance).ToString("F3") + "mm)", PCB_Investigator.PCBIWindows.PCBIReportDialog.LogType.Warning);
                                        }
                                        if (distanceC2C < MinDistanceCenterTP2TP)
                                        {
                                            if (hasWrongDistance == false)
                                            {
                                                tpCmp.ObjectColor = Color.Orange;
                                                hasWrongDistance  = true;
                                            }
                                            reportDlg.AppendLog(" -> " + tpCmp.Ref + " Center to Center" + nearCmp.Ref + " (" + PCBI.MathUtils.IMath.Mils2MM(distanceC2C).ToString("F3") + "mm)", PCB_Investigator.PCBIWindows.PCBIReportDialog.LogType.Error);
                                        }
                                    }
                                    else
                                    {
                                        if (distance < MinDistanceTP2CMP)
                                        {
                                            if (hasWrongDistance)
                                            {
                                                tpCmp.ObjectColor = Color.Red;
                                                hasWrongDistance  = true;
                                            }
                                            reportDlg.AppendLog(" -> " + tpCmp.Ref + " too close to " + nearCmp.Ref + " (" + PCBI.MathUtils.IMath.Mils2MM(distance).ToString("F3") + "mm)", PCB_Investigator.PCBIWindows.PCBIReportDialog.LogType.Warning);
                                        }
                                    }
                                }
                            }
                        }

                        if (!hasWrongDistance)
                        {
                            tpCountOK++;
                            tpCmp.ObjectColor = Color.Green;
                            reportDlg.AppendLog(" -> " + tpCmp.Ref + " is OK");
                        }
                    }
                }
            }

            reportDlg.AppendLog("=> " + tpCountOK + " of " + tpCountTotal + " Testpoints are OK");
        }
 public IPolyClass ThtPolyDrill;                                               // and a polygon of  each the drill below the pins
 public ThtPin(ICMPObject cmp, IPin pin, IODBObject drill, IPolyClass thtPoly) // constructor definition
 {
     this.Cmp = cmp; this.Pin = pin; this.Drill = drill; this.ThtPolyDrill = thtPoly;
 }