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();
        }
コード例 #2
0
        private void fillNODDataList(IPCBIWindow parent, IStep step, IMatrix matrix, List <ICMPObject> lstAllCMPList, List <ThtPin> topTHTPinList, List <ThtPin> botTHTPinList, out List <string> dataList, List <INet> lstINetINetList, List <IODBObject> lstListOfAllDrillObjects, ref List <string> errorLogFile)
        {
            int inCounter4NONENetName = 0;

            dataList = new List <string>();
            string     strTopSigLay = matrix.GetTopSignalLayer();
            string     strBotSigLay = matrix.GetBotSignalLayer();
            IODBLayer  iodblayTopSig, iodblayBotSig, iodblayCurrSigLay;
            string     strPosition = string.Empty;
            string     strTecn     = string.Empty;
            string     strNetName  = string.Empty;
            string     strCmpRef   = string.Empty;
            string     strInfo     = string.Empty;
            ICMPObject iCmOCMPObject;
            char       chrWhiteSpa = ' ';
            int        minAbstand  = 15;
            int        maxAbstand  = 52;
            int        dist        = betterToRead;



            if (lstAllCMPList == null)
            {
                errorLogFile.Add("Method: fillNODDataList + lstAllCMPList is null");
                return;
            }


            // to get the maximum name length

            /*if (lstAllCMPList.Count > 0)
             * {
             *  foreach (ICMPObject cmp in lstAllCMPList)
             *  {
             *      if (cmp != null && !string.IsNullOrEmpty(cmp.PartName))
             *      {
             *          if (maxAbstand < cmp.PartName.Length)
             *          {
             *              maxAbstand = cmp.PartName.Length;
             *          }
             *      }
             *      else
             *      {
             *          errorLogFile.Add("Method: fillNODDataList + lstAllCMPList is null");
             *          return;
             *      }
             *  }
             * }
             * else
             * {
             *  MessageBox.Show("No componentens could be found");
             *  return;
             * }
             *
             *
             *
             * if (lstINetINetList.Count > 0)
             * {
             *  foreach (INet tempNet in lstINetINetList)
             *  {
             *      if (tempNet != null && !string.IsNullOrEmpty(tempNet.NetName))
             *      {
             *          if (maxAbstand < tempNet.NetName.Length)
             *          {
             *              maxAbstand = tempNet.NetName.Length;
             *          }
             *      }
             *      else
             *      {
             *          errorLogFile.Add("Method: fillNODDataList + lstINetInetList is null");
             *          return;
             *      }
             *  }
             * }
             * else
             * {
             *  MessageBox.Show("No componentens could be found");
             *  return;
             * }*/

            maxAbstand = maxAbstand + 2;


            if (!string.IsNullOrEmpty(strTopSigLay))
            {
                iodblayTopSig = (IODBLayer)step.GetLayer(strTopSigLay);
            }
            else
            {
                errorLogFile.Add("Method: fillNODDataList + strTopSigLay is null");
                iodblayTopSig = null;
            }

            if (!string.IsNullOrEmpty(strBotSigLay))
            {
                iodblayBotSig = (IODBLayer)step.GetLayer(strBotSigLay);
            }
            else
            {
                errorLogFile.Add("Method: fillNODDataList + strBotSigLay is null");
                iodblayBotSig = null;
            }

            dataList.Add("* " + "NetName".PadRight(minAbstand, chrWhiteSpa) + "CMP-Ref".PadRight(minAbstand, chrWhiteSpa) + "PinNr.".PadRight(minAbstand, chrWhiteSpa) + "X".PadRight(minAbstand, chrWhiteSpa) + "Y".PadRight(minAbstand, chrWhiteSpa) + "PadSize".PadRight(minAbstand, chrWhiteSpa) + "Pinposition".PadRight(minAbstand, chrWhiteSpa) + "CMP-Typ".PadRight(minAbstand, chrWhiteSpa) + "TEST".PadRight(minAbstand, chrWhiteSpa) + "CHANNEL".PadRight(minAbstand, chrWhiteSpa) + "USER");
            dataList.Add("* ");

            foreach (INet net in lstINetINetList)
            {
                if (net == null)
                {
                    errorLogFile.Add("Method: fillNODDataList + net is null");
                    return;
                }
                List <INetObject> lstNetComponentList = net.ComponentList;

                if (lstNetComponentList == null)
                {
                    errorLogFile.Add("Method: fillNODDataList + lstNetComponentList is null");
                    return;
                }
                foreach (INetObject inetObj in lstNetComponentList)
                {
                    iCmOCMPObject = inetObj.ICMP;
                    if (iCmOCMPObject == null)
                    {
                        errorLogFile.Add("Method: fillNODDataList + iCmOCMPObject is null");
                        continue;
                    }
                    strTecn = string.Empty;


                    bool boPinIsTopSoldered = true;
                    bool boPinIsPartOfTHT   = false;

                    if (!useTHTSearch)
                    {
                        boPinIsTopSoldered = iCmOCMPObject.PlacedTop;
                    }
                    else
                    {
                        if (iCmOCMPObject.PlacedTop)        // true is top layer
                        {
                            boPinIsTopSoldered = true;

                            foreach (var entry in topTHTPinList)
                            {
                                if (entry == null)
                                {
                                    errorLogFile.Add("Method: fillNODDataList + entry is null");
                                    return;
                                }
                                if (entry.Cmp.Ref == iCmOCMPObject.Ref)
                                {
                                    boPinIsPartOfTHT   = true;
                                    boPinIsTopSoldered = false;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            boPinIsTopSoldered = false;

                            foreach (var entry in botTHTPinList)
                            {
                                if (entry == null)
                                {
                                    errorLogFile.Add("Method: fillNODDataList + entry is null");
                                    return;
                                }
                                if (entry.Cmp.Ref == iCmOCMPObject.Ref)
                                {
                                    boPinIsPartOfTHT   = true;
                                    boPinIsTopSoldered = true;
                                    break;
                                }
                            }
                        }
                    }


                    if (boPinIsPartOfTHT == true)
                    {
                        strTecn = "T";
                    }
                    else
                    {
                        strTecn = "S";
                    }

                    if (boPinIsTopSoldered)
                    {
                        strPosition = "T";
                        if (iodblayTopSig != null)
                        {
                            iodblayCurrSigLay = iodblayTopSig;
                        }
                        else
                        {
                            errorLogFile.Add("Method: fillNODDataList + iodblayTopSig is null");
                            return;
                        }
                    }
                    else
                    {
                        strPosition = "B";
                        if (iodblayBotSig != null)
                        {
                            iodblayCurrSigLay = iodblayBotSig;
                        }
                        else
                        {
                            errorLogFile.Add("Method: fillNODDataList + iodblayBotSig is null");
                            return;
                        }
                    }

                    IPin pin = inetObj.GetIPin();
                    {
                        if (pin == null)
                        {
                            errorLogFile.Add("Method: fillNODDataList + pin is null");
                            continue;
                        }
                        IODBObject iodbobPinPad = null;
                        if (iodblayCurrSigLay != null)
                        {
                            iodbobPinPad = pin.GetIPinPad(iodblayCurrSigLay, iCmOCMPObject);
                        }

                        if (net.NetName == null)
                        {
                            errorLogFile.Add("Method: fillNODDataList + net.NetName is null");
                            return;
                        }
                        if (net.NetName == "$NONE$")
                        {
                            strNetName = '"' + net.NetName + inCounter4NONENetName.ToString(System.Globalization.CultureInfo.InvariantCulture) + '"';
                            inCounter4NONENetName++;
                        }
                        else
                        {
                            strNetName = '"' + net.NetName + '"';
                        }
                        strCmpRef = '"' + iCmOCMPObject.Ref + '"';

                        string strPadString = string.Empty;
                        double holeDiameter = 0;
                        bool   rotationExists = false;
                        bool   holeExists = false;
                        double doWidth = 0, doHeight = 0, doDegree = 0;


                        if (iodbobPinPad != null)
                        {
                            IObjectSpecificsD spec = iodbobPinPad.GetSpecificsD();
                            if (spec == null)
                            {
                                errorLogFile.Add("Method: fillNODDataList + spec is null");
                                return;
                            }

                            if (spec is IPadSpecificsD)
                            {
                                IPadSpecificsD pSpec = (IPadSpecificsD)spec;
                                //pSpec.ShapeIndex
                                if (pSpec == null)
                                {
                                    errorLogFile.Add("Method: fillNODDataList + pSpec is null");
                                    return;
                                }
                                IFilter filter = new IFilter(parent);

                                if (filter == null)
                                {
                                    errorLogFile.Add("Method: fillNODDataList + filter is null");
                                    return;
                                }

                                IFilter.ToolDefinition toolDef = filter.GetSymbolByShapeIndex(pSpec.ShapeIndex, iodblayCurrSigLay);
                                if (toolDef == null)
                                {
                                    errorLogFile.Add("Method: fillNODDataList + toolDef is null");
                                    return;
                                }

                                switch (toolDef.Type)
                                {
                                case PCBI.Symbol_Type.r:                //round

                                    foreach (IODBObject drill in lstListOfAllDrillObjects)
                                    {
                                        if (drill == null)
                                        {
                                            errorLogFile.Add("Method: fillNODDataList + drill is null");
                                            return;
                                        }
                                        if (drill.IsPointOfSecondObjectIncluded(iodbobPinPad))
                                        {
                                            holeExists   = true;
                                            holeDiameter = drill.GetDiameter();
                                        }
                                    }
                                    if (holeExists)
                                    {
                                        strPadString = "R" + Math.Round(toolDef.Diameter, 0).ToString(System.Globalization.CultureInfo.InvariantCulture) + "H" + Math.Round(holeDiameter, 0).ToString(System.Globalization.CultureInfo.InvariantCulture);
                                    }
                                    else
                                    {
                                        strPadString = "R" + Math.Round(toolDef.Diameter, 0).ToString(System.Globalization.CultureInfo.InvariantCulture);
                                    }
                                    break;

                                case PCBI.Symbol_Type.s:                // square
                                                                        //toolDef.Diameter;
                                    RectangleD bounds = iodbobPinPad.GetBoundsD();

                                    if (bounds == null)
                                    {
                                        errorLogFile.Add("Method: fillNODDataList + bounds are null");
                                        return;
                                    }

                                    if (pSpec.Rotation != 0)
                                    {
                                        IPolyClass padPoly = iodbobPinPad.GetPolygonOutline();
                                        if (padPoly == null)
                                        {
                                            errorLogFile.Add("Method: fillNODDataList + padPoly is null");
                                            return;
                                        }
                                        padPoly.Rotate(-pSpec.Rotation);
                                        padPoly.UpdateBounds();
                                        bounds = padPoly.GetBounds();
                                    }
                                    strPadString = "X" + Math.Round(bounds.Height, 0).ToString(System.Globalization.CultureInfo.InvariantCulture);
                                    break;

                                case PCBI.Symbol_Type.rect:
                                default:
                                    RectangleD rectBounds = iodbobPinPad.GetBoundsD();
                                    if (rectBounds == null)
                                    {
                                        errorLogFile.Add("Method: fillNODDataList + bounds are null");
                                        return;
                                    }

                                    if (pSpec.Rotation != 0)
                                    {
                                        doDegree       = pSpec.Rotation;
                                        rotationExists = true;
                                        IPolyClass padPoly = iodbobPinPad.GetPolygonOutline();
                                        if (padPoly == null)
                                        {
                                            errorLogFile.Add("Method: fillNODDataList + padPoly is null");
                                            return;
                                        }
                                        padPoly.Rotate(-pSpec.Rotation);
                                        padPoly.UpdateBounds();
                                        rectBounds = padPoly.GetBounds();
                                    }
                                    doWidth  = rectBounds.Width;
                                    doHeight = rectBounds.Height;

                                    if (rotationExists)
                                    {
                                        strPadString = "X" + Math.Round(doWidth, 0).ToString(System.Globalization.CultureInfo.InvariantCulture) + "Y" + Math.Round(doHeight, 0).ToString(System.Globalization.CultureInfo.InvariantCulture) + "A" + Math.Round(doDegree, 0).ToString(System.Globalization.CultureInfo.InvariantCulture);
                                    }
                                    else
                                    {
                                        foreach (IODBObject drill in lstListOfAllDrillObjects)
                                        {
                                            if (drill == null)
                                            {
                                                errorLogFile.Add("Method: fillNODDataList + drill is null");
                                                return;
                                            }
                                            if (drill.IsPointOfSecondObjectIncluded(iodbobPinPad))
                                            {
                                                holeExists   = true;
                                                holeDiameter = drill.GetDiameter();
                                            }
                                        }
                                        if (holeExists)
                                        {
                                            strPadString = "X" + Math.Round(doWidth, 0).ToString(System.Globalization.CultureInfo.InvariantCulture) + "Y" + Math.Round(doHeight, 0).ToString(System.Globalization.CultureInfo.InvariantCulture) + "H" + Math.Round(holeDiameter, 0).ToString(System.Globalization.CultureInfo.InvariantCulture);
                                        }
                                        else
                                        {
                                            strPadString = "X" + Math.Round(doWidth, 0).ToString(System.Globalization.CultureInfo.InvariantCulture) + "Y" + Math.Round(doHeight, 0).ToString(System.Globalization.CultureInfo.InvariantCulture);
                                        }
                                    }


                                    break;
                                }
                            }
                        }
                        else
                        {
                            strPadString = "0";
                            errorLogFile.Add("Method: fillNODDataList + iodbobPinPad is null");
                            return;
                        }
                        string strXValue = (Math.Round(IMath.Mils2MM(pin.GetIPinPositionD(iCmOCMPObject).X), digits)).ToString(System.Globalization.CultureInfo.InvariantCulture);
                        string strYValue = (Math.Round(IMath.Mils2MM(pin.GetIPinPositionD(iCmOCMPObject).Y), digits)).ToString(System.Globalization.CultureInfo.InvariantCulture);



                        strInfo = string.Concat(strNetName.PadRight(strNetName.Length + dist, chrWhiteSpa),
                                                strCmpRef.PadRight(strCmpRef.Length + dist, chrWhiteSpa),
                                                pin.PinNumber.PadRight(pin.PinNumber.Length + dist, chrWhiteSpa),
                                                strXValue.PadRight(strXValue.Length + dist, chrWhiteSpa),
                                                strYValue.PadRight(strYValue.Length + dist, chrWhiteSpa),
                                                strPadString.PadRight(strPadString.Length + dist, chrWhiteSpa),
                                                strPosition.PadRight(strPosition.Length + dist, chrWhiteSpa),
                                                strTecn.PadRight(strTecn.Length + dist, chrWhiteSpa),
                                                "Y".PadRight(2, chrWhiteSpa),
                                                "0".PadRight(2, chrWhiteSpa), " ");

                        if (!dataList.Contains(strInfo))
                        {
                            dataList.Add(strInfo);
                        }
                    }
                }
            }
        }