예제 #1
0
        private static void MakeDrillCutOutOnCopperLayers(IPCBIWindow Parent, IMatrix matrix, IStep step)
        {
            IFilter filter            = new IFilter(Parent);
            int     counterDielectirc = 1;

            foreach (string layerName in matrix.GetAllDrillLayerNames())
            {
                ILayer drill_layer = step.GetLayer(layerName);

                bool lastWasSignal = false;
                foreach (string sigLayer in matrix.GetAllLayerWithThisDrills(layerName))
                {
                    var type = matrix.GetMatrixLayerType(sigLayer);
                    if (type != MatrixLayerType.Dielectric && !matrix.IsSignalLayer(sigLayer)) //only dielectric und signals
                    {
                        continue;
                    }
                    if ((type == MatrixLayerType.Power_ground || type == MatrixLayerType.Signal))
                    {
                        if (lastWasSignal)
                        {
                            //if last and current one are signals -> we need a dielectric between both
                            IODBLayer dielectric = filter.CreateEmptyODBLayer("dielectric_" + counterDielectirc, step.Name);
                            counterDielectirc++;
                            if (dielectric != null)
                            {
                                AddDrillObjects(filter, drill_layer, MatrixLayerType.Dielectric, dielectric);
                                matrix.SetMatrixLayerIndex(dielectric.GetLayerName(), matrix.GetRawIndexByName(sigLayer));
                                matrix.SetMatrixLayerParameter(dielectric.GetLayerName(), MatrixLayerContext.Board, MatrixLayerPolarity.Negative, MatrixLayerType.Dielectric, -1, -1);
                                matrix.SetLayerHeight(dielectric.GetLayerName(), 5); //value in mils
                                matrix.UpdateDataAndList();                          //update list for correct order
                            }
                            else
                            {
                                Debug.WriteLine("error, can't create dielectric...");
                            }
                        }

                        lastWasSignal = true;
                    }
                    else
                    {
                        lastWasSignal = false;
                    }

                    IODBLayer odb_sig_layer = (IODBLayer)step.GetLayer(sigLayer);

                    if (drill_layer.GetType() == typeof(IODBLayer))
                    {
                        AddDrillObjects(filter, drill_layer, type, odb_sig_layer);

                        drill_layer.EnableLayer(false);
                        odb_sig_layer.EnableLayer(true);
                    }
                }
            }

            matrix.UpdateDataAndList();
            Parent.UpdateControlsAndResetView();
        }
        private static void AddNetInfos(IStep step, IODBLayer parentLayer, String NetName, IODBObject netItem)
        {
            if (NetName.Length == 0) //the default net
            {
                NetName = "$NONE$";
            }

            int  lastNetNr = step.GetNets().Count;
            INet outNet    = step.GetNet(NetName);
            int  netNr     = -1;

            if (outNet == null)
            {
                netNr = step.AddNet(NetName, "", out outNet);
            }
            else
            {
                netNr = outNet.GetNetNumber();
            }

            netItem.PcbNetNumber = outNet.GetNetNumber();                          //set the netinformation to the object
            int newNr = outNet.AddLayerRef(parentLayer.GetLayerName(), lastNetNr); //each net saves a list of all layers are used.

            if (newNr == lastNetNr)
            {
                lastNetNr++;
            }
            parentLayer.SetNetNumber(NetName, netItem.PcbNetNumber);                                       //for each object the layer needs information that this net is used.
            outNet.AddFID(PCBI.FidType.Copper, parentLayer.GetLayerName(), netItem.GetIndexOnLayer(), ""); //this is specific to ODB++, if you don't use it and save the data as ODB++ some information get lost.
        }
        public void Execute(IPCBIWindow parentPCBI)
        {
            if (parentPCBI == null)
            {
                MessageBox.Show("No license!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return;
            }

            if (!parentPCBI.JobIsLoaded)
            {
                return;
            }
            IStep curStep = parentPCBI.GetCurrentStep();

            if (curStep == null)
            {
                return;                  //no step -> no job -> break;
            }
            IFilter filter = new IFilter(parentPCBI);

            foreach (ILayer layer in curStep.GetActiveLayerList())
            {
                IODBLayer  newLayer    = filter.CreateEmptyODBLayer("newLayerWithCutting_" + layer.GetLayerName(), curStep.Name, false);
                IPolyClass outlinePoly = curStep.GetPCBOutlinePoly();

                if ((!(layer is IODBLayer)) || !CutRectangle(outlinePoly, (IODBLayer)layer, newLayer, filter, parentPCBI))
                {
                    MessageBox.Show("Something is wrong, cutting has not worked!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            parentPCBI.UpdateView();
            IMatrix matrix = parentPCBI.GetMatrix();

            matrix.UpdateDataAndList();
        }
        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);
            }
        }
예제 #5
0
        public void Execute(IPCBIWindow parent)
        {
            IStep   step   = parent.GetCurrentStep();
            IMatrix matrix = parent.GetMatrix();

            if (matrix == null || step == null)
            {
                return;                                 //if there is no data loaded -> return
            }
            IODBLayer topLayer = step.GetOutsideODBLayer(true);

            if (topLayer != null)
            {
                MarkAllSMDPadsOnLayer(topLayer, matrix.GetAllDrillLayersForThisLayer(topLayer.LayerName), step);
                topLayer.EnableLayer(true); //to see the result for top side immidiatly, it will be enabled
            }
            IODBLayer botLayer = step.GetOutsideODBLayer(false);

            if (botLayer != null)
            {
                MarkAllSMDPadsOnLayer(botLayer, matrix.GetAllDrillLayersForThisLayer(botLayer.LayerName), step);
            }

            parent.UpdateView(); //redraw to show marked smd pads
        }
 private void SelectAllObjectsOnLayer(IODBLayer layer)
 {
     foreach (IODBObject obj in layer.GetAllLayerObjects())
     {
         obj.Select(true);
     }
 }
예제 #7
0
        public void Execute(IPCBIWindow parent)
        {
            IStep step = parent.GetCurrentStep();

            if (step == null)
            {
                return;
            }

            //the symbol diameter selected by user
            float diameterReplacedSymbolsInMils = 1;

            foreach (ILayer activeLayer in step.GetActiveLayerList())
            {
                if (!(activeLayer is IODBLayer)) //component and picture layer irrelevant
                {
                    continue;
                }

                IODBLayer Layer       = (IODBLayer)activeLayer;
                int       symbolIndex = -1;
                IFilter.AddToolDefinitionRound(Layer, diameterReplacedSymbolsInMils);
                foreach (IODBObject obj in Layer.GetAllLayerObjects())
                {
                    if (obj.GetDiameter() == 0) //all elements with diameter 0 replaced by new symbol
                    {
                        if (symbolIndex < 0)
                        {
                            symbolIndex = IFilter.AddToolDefinitionRound(Layer, diameterReplacedSymbolsInMils); //add new symbol only if used
                        }
                        obj.SetSpecifics(obj.GetSpecificsD(), symbolIndex);
                    }
                }
            }
        }
        private static void CreateBoardView(IStep step, IFilter filter, IODBLayer frontLayer, float boardThickness, bool front)
        {
            if (boardThickness > 0)
            {
                #region draw board front
                int shapeIndexBoardHeight = IFilter.AddToolDefinitionRect(frontLayer, boardThickness, boardThickness, boardThickness, false);

                //add line with board symbol index to have correct thickness
                IODBObject boardLineFront = filter.CreateLine(frontLayer);

                ILineSpecificsD lineDetails = (ILineSpecificsD)boardLineFront.GetSpecificsD();
                if (front)
                {
                    lineDetails.Start = new PointD(step.GetBoundsD().Left + boardThickness / 2, 0);
                    lineDetails.End   = new PointD(step.GetBoundsD().Right - boardThickness / 2, 0);
                }
                else
                {
                    lineDetails.Start = new PointD(0, step.GetBoundsD().Top + boardThickness / 2);
                    lineDetails.End   = new PointD(0, step.GetBoundsD().Bottom - boardThickness / 2);
                }
                boardLineFront.SetSpecifics(lineDetails, shapeIndexBoardHeight);
                boardLineFront.ObjectColorTemporary(Color.Green);
                #endregion
            }
        }
예제 #9
0
        public void Execute(IPCBIWindow parent)
        {
            IFilter filter = new IFilter(parent);

            //your code here
            foreach (ILayer layer in parent.GetCurrentStep().GetActiveLayerList())
            {
                List <IODBObject> objectsToMove = new List <IODBObject>();
                foreach (IODBObject obj in layer.GetAllLayerObjects())
                {
                    foreach (DictionaryEntry entry in obj.GetAttributes())
                    {
                        if (entry.Key.ToString() == "_string")
                        {
                            objectsToMove.Add((IODBObject)obj);
                        }
                    }
                }


                IODBLayer newLayer = filter.CreateEmptyODBLayer(layer.GetLayerName() + "_1", parent.GetCurrentStep().Name);
                filter.InsertElementsToLayer(0, newLayer, objectsToMove, new PointD(0, 0), false, false, 0);

                foreach (IODBObject mo in objectsToMove)
                {
                    ((IODBLayer)layer).RemoveObject(mo);
                }
            }

            parent.UpdateControlsAndResetView();
        }
예제 #10
0
        public void Execute(IPCBIWindow parent)
        {
            //your code here
            int count = 0;

            IStep step = parent.GetCurrentStep();

            IODBLayer outsideToplayer = step.GetOutsideODBLayer(true);
            IODBLayer outsideBotlayer = step.GetOutsideODBLayer(false);

            if (step.GetCMPLayer(true) != null)
            {
                step.GetCMPLayer(true).EnableLayer(true);
                foreach (ICMPObject cmp in step.GetCMPLayer(true).GetAllLayerObjects())
                {
                    foreach (IPin pin in cmp.GetPinList())
                    {
                        IODBObject po = pin.GetIPinPad(outsideToplayer, cmp);
                        if (po != null)
                        {
                            IPadSpecifics os = (IPadSpecifics)po.GetSpecifics();
                            if (os.Type == PCBI.Symbol_Type.r)
                            {
                                cmp.ObjectColor = Color.Red;
                                cmp.AddComponentAttribute("techno", "thr");
                                count++;

                                break;
                            }
                        }
                    }
                }
            }
            if (step.GetCMPLayer(false) != null)
            {
                step.GetCMPLayer(false).EnableLayer(true);
                foreach (ICMPObject cmp in step.GetCMPLayer(false).GetAllLayerObjects())
                {
                    foreach (IPin pin in cmp.GetPinList())
                    {
                        IODBObject po = pin.GetIPinPad(outsideBotlayer, cmp);
                        if (po != null)
                        {
                            IPadSpecifics os = (IPadSpecifics)po.GetSpecifics();
                            if (os.Type == PCBI.Symbol_Type.r)
                            {
                                cmp.ObjectColor = Color.Blue;
                                cmp.AddComponentAttribute("techno", "thr");
                                count++;

                                break;
                            }
                        }
                    }
                }
            }

            parent.UpdateView();
        }
        public void Execute(IPCBIWindow parent)
        {
            IStep     step          = parent.GetCurrentStep();
            IFilter   filter        = new IFilter(parent);
            IODBLayer layerPolygons = filter.CreateEmptyODBLayer("polygons_n", step.Name);

            bool polyStart = true;
            List <IODBObject> listOfSelection = step.GetSelectedElements();

            PCBI.MathUtils.IPolyClass poly = new PCBI.MathUtils.IPolyClass();

            foreach (IODBObject obj in listOfSelection)
            {
                IObjectSpecificsD os = obj.GetSpecificsD();

                if (os.GetType() == typeof(IArcSpecificsD))
                {
                    IArcSpecificsD aEdge = (IArcSpecificsD)os;

                    if (polyStart)
                    {
                        polyStart = false;
                    }
                    poly.AddEdge(aEdge.Start, aEdge.End, aEdge.Center, aEdge.ClockWise);
                }
                else if (os.GetType() == typeof(ILineSpecificsD))
                {
                    ILineSpecificsD aEdge = (ILineSpecificsD)os;
                    if (polyStart)
                    {
                        polyStart = false;
                    }
                    poly.AddEdge(aEdge.Start, aEdge.End);
                }
            }

            if (poly.GetSubPolygons().Count > 0)
            {
                foreach (PCBI.MathUtils.IPolyClass polyC in poly.GetSubPolygons())
                {
                    if (polyC.GetBounds().Width > 0.001 && polyC.GetBounds().Height > 0.001)
                    {
                        IODBObject surfaceFromPoly = polyC.GetSurfaceFromPolygon(layerPolygons);
                    }
                }
                layerPolygons.EnableLayer(true);
            }
            else
            {
                IODBObject suf = poly.GetSurfaceFromPolygon(layerPolygons);
                layerPolygons.EnableLayer(true);
            }

            parent.UpdateView();
            IMatrix matrix = parent.GetMatrix();

            matrix.UpdateDataAndList();
        }
        private static void CreateVertLine(IFilter filter, IODBLayer rasterLayer, int shapeIndex, int y, int x)
        {
            IODBObject      rasterLine = filter.CreateLine(rasterLayer);
            ILineSpecificsD line       = (ILineSpecificsD)rasterLine.GetSpecificsD();

            line.Start      = new PCBI.MathUtils.PointD(x, y);
            line.End        = new PCBI.MathUtils.PointD(x, y + 50);
            line.ShapeIndex = shapeIndex;

            rasterLine.SetSpecifics(line);
        }
        public void Execute(IPCBIWindow parent)
        {
            IStep step = parent.GetCurrentStep();

            if (step == null)
            {
                return;
            }
            double tolerance = 1;

            List <IODBObject> selection = step.GetSelectedElements();

            foreach (IODBObject selObj in selection)
            {
                IODBLayer layer = (IODBLayer)step.GetLayer(selObj.GetParentLayerName());

                if (selObj.Type == IObjectType.Line)
                {
                    ILineSpecificsD line     = (ILineSpecificsD)selObj.GetSpecificsD();
                    List <IObject>  startPos = layer.GetAllObjectsOnPosition(line.Start.ToPointF());
                    bool            setColor = true;
                    setColor = CheckConnection(tolerance, selObj, line.Start, startPos, setColor);
                    if (setColor)
                    {
                        List <IObject> endPos = layer.GetAllObjectsOnPosition(line.End.ToPointF());
                        setColor = CheckConnection(tolerance, selObj, line.End, endPos, setColor);
                    }
                    if (setColor)
                    {
                        selObj.ObjectColorTemporary(Color.Aquamarine);
                    }
                }
                else if (selObj.Type == IObjectType.Arc)
                {
                    IArcSpecificsD arc = (IArcSpecificsD)selObj.GetSpecificsD();

                    List <IObject> startPos = layer.GetAllObjectsOnPosition(arc.Start.ToPointF());
                    bool           setColor = true;
                    setColor = CheckConnection(tolerance, selObj, arc.Start, startPos, setColor);
                    if (setColor)
                    {
                        List <IObject> endPos = layer.GetAllObjectsOnPosition(arc.End.ToPointF());
                        setColor = CheckConnection(tolerance, selObj, arc.End, endPos, setColor);
                    }
                    if (setColor)
                    {
                        selObj.ObjectColorTemporary(Color.Aquamarine);
                    }
                }
            }

            step.ClearSelection();
        }
예제 #14
0
        public void CreateCopperLines()
        {
            IFilter filter = new IFilter(Parent);

            IStep curStep = Parent.GetCurrentStep();

            if (curStep == null)
            {
                MessageBox.Show("No Job loaded, please load a job before start this script!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                return;
            }
            IODBLayer fiducialLayer = filter.CreateEmptyODBLayer("copper", curStep.Name);

            if (fiducialLayer == null)
            {
                MessageBox.Show("Can't create new layer!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                return;
            }

            float outerDiameter = 1800;

            int shapeIndex = IFilter.AddToolDefinitionRound(fiducialLayer, outerDiameter / 25.4f, 0);

            PCBI.MathUtils.PointD startLine = new PCBI.MathUtils.PointD(0, 0);
            float distance = 2540 / 25.4f;

            for (int y = 0; y < 39; y++)
            {
                float lastX = 0;
                for (int i = 0; i < 63; i++)
                {
                    IODBObject      line = filter.CreateLine(fiducialLayer);
                    ILineSpecificsD ps   = new ILineSpecificsD();
                    ps.Start = new PCBI.MathUtils.PointD(startLine.X, startLine.Y);
                    float lineEnd = lastX + distance;
                    ps.End        = new PCBI.MathUtils.PointD(lineEnd, startLine.Y);
                    lastX         = lineEnd;
                    ps.ShapeIndex = shapeIndex;
                    ps.Positive   = true;
                    line.SetSpecifics(ps);
                    startLine.X += distance;
                }
                startLine.Y += distance;
                startLine.X  = 0;
            }
            IMatrix matrix = Parent.GetMatrix();

            matrix.UpdateDataAndList();
            Parent.UpdateView();
        }
예제 #15
0
        void MarkAllSMDPadsOnLayer(IODBLayer layer, List <string> allRelevantDrills, IStep step)
        {
            if (layer == null || allRelevantDrills.Count == 0)
            {
                return;
            }
            Dictionary <string, IODBLayer> drills = new Dictionary <string, IODBLayer>();

            //look for all pads if there is a drill inside?
            foreach (IODBObject maybePad in layer.GetAllLayerObjects())
            {
                if (maybePad.Type != IObjectType.Pad || maybePad.ObjectColor == MarkerColor)
                {
                    continue;
                }

                Dictionary <PCBI.FeatureAttributeEnum, string> attribs = maybePad.GetAttributesDictionary();

                if (attribs.ContainsKey(PCBI.FeatureAttributeEnum.smd)) //check for smd attribute
                {
                    //check for drills
                    IPadSpecifics pad = (IPadSpecifics)maybePad.GetSpecifics();
                    if (pad.Type == PCBI.Symbol_Type.r)
                    {
                        continue;                                     //no round pads
                    }
                    foreach (string drillname in allRelevantDrills)
                    {
                        if (!drills.ContainsKey(drillname))
                        {
                            drills.Add(drillname, (IODBLayer)step.GetLayer(drillname));
                        }

                        List <IObject> relevantDrills = drills[drillname].GetAllObjectInRectangle(maybePad.GetBounds());

                        foreach (IODBObject drill in relevantDrills)
                        {
                            if (maybePad.Bounds.Contains(drill.Bounds)) //simple check with bounds inside
                            {
                                maybePad.ObjectColor = MarkerColor;
                                break;
                            }
                        }
                        if (!maybePad.ObjectColor.IsEmpty) //if color -> found and break
                        {
                            break;
                        }
                    }
                }
            }
        }
        public void Execute(IPCBIWindow parent)
        {
            IFilter filter = new IFilter(parent);

            IStep curStep = parent.GetCurrentStep();

            if (curStep == null)
            {
                MessageBox.Show("No Job loaded, please load a job before start this script!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                return;
            }

            IODBLayer fiducialLayer = filter.CreateEmptyODBLayer("fiducial", curStep.Name);

            if (fiducialLayer == null)
            {
                MessageBox.Show("Can't create new layer!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                return;
            }

            int shapeIndex = IFilter.AddToolDefinitionDonut(fiducialLayer, (float)IMath.MM2Mils(2), (float)IMath.MM2Mils(1), -1);

            IODBObject pad = filter.CreatePad(fiducialLayer);

            PointD FidPoint = new PointD(IMath.MM2Mils(3), IMath.MM2Mils(3));

            pad.SetSpecifics(new IPadSpecificsD()
            {
                Location = FidPoint, ShapeIndex = shapeIndex, Positive = true
            });
            IAttributeElement attribute = new IAttributeElement(PCBI.FeatureAttributeEnum.fiducial_name);

            attribute.Value = "fid1";
            IAttribute.SetAttribute(attribute, pad);

            FidPoint = new PointD(IMath.MM2Mils(3), IMath.MM2Mils(147));
            pad      = filter.CreatePad(fiducialLayer);
            pad.SetSpecifics(new IPadSpecificsD()
            {
                Location = FidPoint, ShapeIndex = shapeIndex, Positive = true
            });
            attribute       = new IAttributeElement(PCBI.FeatureAttributeEnum.fiducial_name);
            attribute.Value = "fid1";
            IAttribute.SetAttribute(attribute, pad);
            parent.UpdateControlsAndResetView();
        }
        public void Execute(IPCBIWindow parent)
        {
            IStep step = parent.GetCurrentStep();

            if (step == null)
            {
                return;
            }
            Dictionary <string, string> NetDiffs = new Dictionary <string, string>();

            foreach (string layername in step.GetAllLayerNames())
            {
                ILayer layer = step.GetLayer(layername);

                if (layer == null)
                {
                    continue;
                }
                if (!(layer is IODBLayer))
                {
                    continue;
                }

                IODBLayer mainLayer = (IODBLayer)layer;

                foreach (IODBObject obj in mainLayer.GetAllLayerObjects())
                {
                    if (obj.FreeText.Trim() != obj.NetName.Trim())
                    {
                        if (!NetDiffs.ContainsKey(obj.NetName))
                        {
                            NetDiffs.Add(obj.NetName, obj.FreeText);
                        }
                    }
                }
            }

            //have a list of all differences of netname and freetext
            StringBuilder MessageTextBuilder = new StringBuilder();

            MessageTextBuilder.AppendLine("Differences of FreeText and Net name for:");
            foreach (string key in NetDiffs.Keys)
            {
                MessageTextBuilder.AppendLine("Net " + key + " - " + NetDiffs[key]);
            }

            MessageBox.Show(MessageTextBuilder.ToString(), "Differences", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        /// <summary>
        /// Helper to create Symbols only once.
        /// </summary>
        private static int CheckShapeIndexRound(IFilter pcbiFilter, IODBLayer parentLayer, float thickness)
        {
            int shapeIndex = -1;
            Dictionary <int, PCBI.Automation.IFilter.ToolDefinition> symbolList = pcbiFilter.GetUsedSymbolList(parentLayer);

            foreach (KeyValuePair <int, PCBI.Automation.IFilter.ToolDefinition> symbs in symbolList)
            {
                if (symbs.Value.Diameter == thickness &&
                    symbs.Value.Type == PCBI.Symbol_Type.r)
                {
                    return(symbs.Key);
                }
            }

            shapeIndex = IFilter.AddToolDefinitionRound(parentLayer, thickness);

            return(shapeIndex);
        }
        public void Execute(IPCBIWindow parent)
        {
            bool allCMPHeightsInMM = true;
            //check all pads on top and bot signal layers and mask layers for open space in mask...

            IMatrix matrix = parent.GetMatrix();
            IStep   step   = parent.GetCurrentStep();

            if (step == null || matrix == null)
            {
                return;
            }

            PCB_Investigator.PCBIWindows.PCBIWorkingDialog working = new PCB_Investigator.PCBIWindows.PCBIWorkingDialog();
            working.CanCancel(false);
            working.SetStatusText("Creating 2D side views...");
            working.SetAnimationStatus(true);

            working.ShowWorkingDlgAsThread();

            ICMPLayer topCMPLayer = step.GetCMPLayer(true);
            ICMPLayer botCMPLayer = step.GetCMPLayer(false);

            IFilter filter = new IFilter(parent);

            IODBLayer frontLayer     = filter.CreateEmptyODBLayer("side_front", step.Name, false);
            IODBLayer sideLayer      = filter.CreateEmptyODBLayer("side_side", step.Name, false);
            float     boardThickness = GetBoardHeight(step);

            //board from side and front
            CreateBoardView(step, filter, frontLayer, boardThickness, true);
            CreateBoardView(step, filter, sideLayer, boardThickness, false);

            CreateComponents(true, topCMPLayer, frontLayer, sideLayer, boardThickness / 2, filter, allCMPHeightsInMM);
            CreateComponents(false, botCMPLayer, frontLayer, sideLayer, boardThickness / 2, filter, allCMPHeightsInMM);



            working.DoClose();

            PCB_Investigator.Localization.PCBILocalization.ShowMsgBox("See new layers side... for results.", "Views created", MessageBoxButtons.OK, MessageBoxIcon.Information);
            matrix.UpdateDataAndList();
            parent.UpdateView();
        }
        public void Execute(IPCBIWindow parent)
        {
            RectangleF boundsJob = parent.GetJobBounds();

            if (boundsJob.IsEmpty)
            {
                IStep step = parent.GetCurrentStep();
                if (step == null)
                {
                    return;
                }
                boundsJob = step.GetBounds();

                if (boundsJob.IsEmpty)
                {
                    IMatrix matrix = parent.GetMatrix();
                    if (matrix == null)
                    {
                        return;
                    }

                    RectangleD boundsLayerCombination = new RectangleD();

                    //check signal layers
                    foreach (string layerName in step.GetAllLayerNames())
                    {
                        if (matrix.IsSignalLayer(layerName))
                        {
                            IODBLayer odbLayer = (IODBLayer)step.GetLayer(layerName);

                            RectangleF layerBounds = odbLayer.GetBounds();

                            boundsLayerCombination = IMath.AddRectangleD(boundsLayerCombination, new RectangleD(layerBounds));
                        }
                    }

                    boundsJob = boundsLayerCombination.ToRectangleF();
                }
            }


            MessageBox.Show("The Job has following bounds in mils:" + Environment.NewLine + " X " + boundsJob.X.ToString() + " ; Y " + boundsJob.Y.ToString() + " ; width " + boundsJob.Width + " ; height " + boundsJob.Height, "Job Bounds", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        public void Execute(IPCBIWindow Parent)
        {
            IStep   step   = Parent.GetCurrentStep();
            IMatrix matrix = Parent.GetMatrix();

            if (step == null)
            {
                return;
            }
            IODBObject profile = step.GetPCBOutlineAsODBObject();

            foreach (string layerName in step.GetAllLayerNames())
            {
                if (matrix.GetMatrixLayerType(layerName) == MatrixLayerType.Component)
                {
                    continue; //no component layer
                }
                ILayer Layer = step.GetLayer(layerName);
                if (Layer is IODBLayer)
                {
                    bool      foundOne = false;
                    IODBLayer layer    = (IODBLayer)Layer;
                    foreach (IODBObject obj in layer.GetAllLayerObjects())
                    {
                        if (profile.IsPointOfSecondObjectIncluded(obj))
                        {
                            //inside not relevant
                        }
                        else
                        {
                            obj.Select(true);
                            foundOne = true;
                        }
                    }
                    if (foundOne)
                    {
                        Layer.EnableLayer(true);
                    }
                }
            }
            Parent.UpdateSelection();
            Parent.UpdateView();
        }
        private void ResultDLG_ItemSelectionChanged1(ListView.SelectedListViewItemCollection Selection)
        {
            IStep step = parent.GetCurrentStep();

            if (step != null)
            {
                foreach (ListViewItem lvi in Selection)
                {
                    if (step != null)
                    {
                        step.ClearSelection();
                        ((ICMPObject)lvi.Tag).Select(true);
                        step.TurnOffAllLayer();

                        IODBLayer layer = step.GetOutsideODBLayer(((ICMPObject)lvi.Tag).PlacedTop);
                        if (layer != null)
                        {
                            layer.EnableLayer(true);
                        }

                        parent.UpdateSelection();

                        PCBI.MathUtils.RectangleD zoomRect = ((ICMPObject)lvi.Tag).GetBoundsD();
                        if (zoomRect == PCBI.MathUtils.RectangleD.Empty)
                        {
                            parent.ZoomToSelection();
                        }
                        else
                        {
                            zoomRect.Inflate(zoomRect.Width * 0.5, zoomRect.Height * 0.5);
                            parent.ZoomRect(zoomRect);
                        }
                    }
                    else
                    {
                        ((ICMPObject)lvi.Tag).Select(true);
                        parent.UpdateSelection();
                        parent.UpdateView();
                    }
                }
            }
        }
        public void Execute(IPCBIWindow parent)
        {
            IStep step = parent.GetCurrentStep();

            if (step == null)
            {
                return;
            }

            IFilter   PCBI_filter     = new IFilter(parent);
            IODBLayer newOutlineLayer = PCBI_filter.CreateEmptyODBLayer("poly_to_line", step.Name);

            float LineWith = 10;     //diameter symbol

            foreach (IODBObject obj in step.GetSelectedElements())
            {
                foreach (IObjectSpecifics os in obj.GetOutline())
                {
                    if (os.GetType() == typeof(ILineSpecifics))
                    {
                        ILineSpecifics lineEdges = (ILineSpecifics)os;
                        IODBObject     line      = PCBI_filter.CreateLine(newOutlineLayer);
                        lineEdges.ShapeIndex = CheckShapeIndexRound(PCBI_filter, newOutlineLayer, LineWith);
                        lineEdges.Type       = PCBI.Symbol_Type.r;
                        line.SetSpecifics(lineEdges, lineEdges.ShapeIndex);
                    }
                    else if (os.GetType() == typeof(IArcSpecifics))
                    {
                        IArcSpecifics arcEdges = (IArcSpecifics)os;
                        IODBObject    arc      = PCBI_filter.CreateArc(newOutlineLayer);
                        arcEdges.ShapeIndex = CheckShapeIndexRound(PCBI_filter, newOutlineLayer, LineWith);
                        arcEdges.Type       = PCBI.Symbol_Type.r;
                        arc.SetSpecifics(arcEdges, arcEdges.ShapeIndex);
                    }
                }
            }
            parent.UpdateView();
            IMatrix matrix = parent.GetMatrix();

            matrix.UpdateDataAndList();
        }
예제 #24
0
        public void Execute(IPCBIWindow parent)
        {
            IFilter filter  = new IFilter(parent);
            IStep   curStep = parent.GetCurrentStep();

            if (curStep == null)
            {
                MessageBox.Show("No Job loaded, please load a job before start this script!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                return;
            }

            IODBLayer newLayer = filter.CreateEmptyODBLayer("help_layer", curStep.Name);

            newLayer.EnableLayer(true);

            IMatrix matrix = parent.GetMatrix();

            matrix.UpdateDataAndList();
            parent.UpdateView();
        }
        private void CreateNewLayer(IPCBIWindow parent, string newlayername)
        {
            IFilter filter  = new IFilter(parent);
            IStep   curStep = parent.GetCurrentStep();

            if (curStep == null)
            {
                MessageBox.Show("No Job loaded, please load a job before start this script!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }

            IODBLayer newLayer = filter.CreateEmptyODBLayer(newlayername, curStep.Name);

            newLayer.EnableLayer(true);

            IMatrix matrix = parent.GetMatrix();

            matrix.SetMatrixLayerContext(newlayername, MatrixLayerContext.Board);
            matrix.SetMatrixLayerType(newlayername, MatrixLayerType.Signal);
            matrix.UpdateDataAndList();
            parent.UpdateView();
        }
예제 #26
0
        /// <summary>
        /// Set for all layers netnames, if no connection it will be named with $NONE$
        /// </summary>
        /// <param name="parent">The parent IPCBIWindow</param>
        /// <param name="NetList">A list of all created nets</param>
        /// <param name="netName">The selected net name</param>
        public static void AutoCreateNetNames(IPCBIWindow parent, Dictionary <string, netItem> NetList, string netNameStart)
        {
            IStep currentStep = parent.GetCurrentStep();

            if (currentStep == null)
            {
                return;                      //maybe there are no Job loaded?
            }
            IMatrix matrix = parent.GetMatrix();

            foreach (string layername in currentStep.GetAllLayerNames()) //fo all layers
            {
                //check type
                if (matrix.IsImageLayer(layername))
                {
                    continue;
                }
                if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Component)
                {
                    continue;
                }

                IODBLayer parentLayer = (IODBLayer)currentStep.GetLayer(layername); //this works only because we have no image and no cmp layers

                parentLayer.CreateLayerNetList(true);                               //create internal net list

                foreach (IODBObject objODB in parentLayer.GetAllLayerObjects())     //all items
                {
                    if (objODB.LayerNetNumber == -1)
                    {
                        AddNetInfos(NetList, currentStep, parentLayer, "$NONE$", objODB);       //no connection -> $NONE$-Net
                    }
                    else
                    {
                        AddNetInfos(NetList, currentStep, parentLayer, netNameStart + layername + "_" + objODB.LayerNetNumber, objODB);
                    }
                }
            }
        }
        void MarkMaskOverPadsOnPaste(IODBLayer MaskLayer, IODBLayer PasteLayer, IStep step)
        {
            if (PasteLayer == null || MaskLayer == null)
            {
                return;
            }

            List <IObject> AllMaskPads = MaskLayer.GetAllLayerObjects();

            //look for all pads if there is a paaste element inside?
            foreach (IODBObject maybePad in AllMaskPads)
            {
                if (maybePad.Type != IObjectType.Pad)
                {
                    continue;
                }
                {
                    //check for paste elements
                    List <IObject> relevantPastePads = PasteLayer.GetAllObjectInRectangle(maybePad.Bounds);

                    foreach (IODBObject pasteObj in relevantPastePads)
                    {
                        bool doesIntersect = maybePad.DoesIntersect(pasteObj);
                        if (!doesIntersect && maybePad.IsPointOfSecondObjectIncluded(pasteObj))
                        {
                            continue;     //paste complete in mask
                        }
                        if (!doesIntersect && !pasteObj.IsPointOfSecondObjectIncluded(maybePad))
                        {
                            continue;
                        }

                        maybePad.ObjectColor = MarkerColor;
                        break;
                    }
                }
            }
        }
        private static bool?CheckPadsForFreeMask(IODBLayer SMLayer, IODBObject checkingPad)
        {
            if (checkingPad.Type == IObjectType.Pad)
            {
                bool foundFreeArea = false;
                //check is it free on mask layer?

                #region without cmps
                foreach (IODBObject maskObjects in SMLayer.GetAllObjectInRectangle(checkingPad.GetBoundsD()))
                {
                    if (maskObjects.Bounds.Contains(checkingPad.Bounds))                                                                             //bounds included in mask object?
                    {
                        if (!maskObjects.DoesIntersect(checkingPad) || maskObjects.GetPolygonOutline().isEqualsTol(checkingPad.GetPolygonOutline())) //no intersection?
                        {
                            if (maskObjects.Type == IObjectType.Surface)
                            {
                                //surface is special with holes and convex or concave elements -> one more test
                                if (maskObjects.IsPointOfSecondObjectIncluded(checkingPad))
                                {
                                    foundFreeArea = true;
                                    break;
                                }
                            }
                            else
                            {
                                //mask object should be free!
                                foundFreeArea = true;
                                break;
                            }
                        }
                    }
                }
                #endregion

                return(foundFreeArea);
            }
            return(null);
        }
예제 #29
0
        public void Execute(IPCBIWindow Parent)
        {
            IStep   step   = Parent.GetCurrentStep();
            IMatrix matrix = Parent.GetMatrix();

            if (step == null)
            {
                return;
            }
            IODBObject profile = step.GetPCBOutlineAsODBObject();

            foreach (string layerName in step.GetAllLayerNames())
            {
                if (matrix.GetMatrixLayerType(layerName) == MatrixLayerType.Component)
                {
                    continue; //no component layers
                }
                ILayer Layer = step.GetLayer(layerName);
                if (Layer is IODBLayer)
                {
                    List <IODBObject> objectsToDelete = new List <IODBObject>();
                    IODBLayer         layer           = (IODBLayer)Layer;
                    foreach (IODBObject obj in layer.GetAllLayerObjects())
                    {
                        if (profile.IsPointOfSecondObjectIncluded(obj))
                        {
                            //inside not delete
                        }
                        else
                        {
                            objectsToDelete.Add(obj);
                        }
                    }
                    layer.RemoveObjects(objectsToDelete);
                }
            }
            Parent.UpdateView();
        }
예제 #30
0
        public void Execute(IPCBIWindow parent)
        {
            //only for current step
            IStep step = parent.GetCurrentStep();

            List <INet> allNets           = step.GetNets();
            IODBLayer   topSignal         = step.GetOutsideODBLayer(true);
            IODBLayer   botSignal         = step.GetOutsideODBLayer(false);
            int         countDifferentces = 0;

            foreach (INet net in allNets)
            {
                foreach (INetObject cmpPinCombi in net.ComponentList)
                {
                    IPin pinRel = cmpPinCombi.ICMP.GetPin(cmpPinCombi.PinIndex);

                    string netName = pinRel.GetNetNameOnIPin(cmpPinCombi.ICMP);

                    IODBObject relPad = pinRel.GetIPinPad(cmpPinCombi.ICMP.PlacedTop?topSignal:botSignal, cmpPinCombi.ICMP);

                    if (relPad != null && relPad.NetName != netName)
                    {
                        pinRel.SetPinColor(Color.AliceBlue, cmpPinCombi.ICMP);
                        countDifferentces++;
                    }
                    else
                    {
                        pinRel.SetPinColor(Color.BurlyWood, cmpPinCombi.ICMP);
                    }
                }
            }

            //you can add some code to show a report by using countDifferentces

            parent.UpdateView();
        }