private void DrawSelectedCompsCount(Graphics g)
        {
            String Text    = "Selected Components:  " + parent.GetCurrentStep().GetSelectedCMPsCount().ToString();
            SizeF  strSize = g.MeasureString(Text, new Font("Arial", 10));
            Brush  TextB   = new SolidBrush(Color.FromArgb(180, 0, 250, 250));

            g.FillRectangle(TextB, 0, 140, strSize.Width, strSize.Height);
            g.DrawString(Text, new Font("Arial", 10), Brushes.DarkBlue, new PointF(0, 140));
        }
        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();
        }
 private ICMPObject GetComponent(string RefName)
 {
     foreach (ICMPObject cmp in PCBI_Parent.GetCurrentStep().GetAllCMPObjects())
     {
         if (cmp.Ref == RefName)
         {
             attribCount++;
             return(cmp);
         }
     }
     return(null);
 }
Exemplo n.º 4
0
        public void CreatePads()
        {
            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;
            float innerDiameter = 1000;

            int shapeIndex = IFilter.AddToolDefinitionDonut(fiducialLayer, outerDiameter / 25.4f, innerDiameter / 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++)
            {
                for (int i = 0; i < 63; i++)
                {
                    IODBObject     pad = filter.CreatePad(fiducialLayer);
                    IPadSpecificsD ps  = new IPadSpecificsD();
                    ps.Location   = new PCBI.MathUtils.PointD(startLine.X, startLine.Y);
                    ps.ShapeIndex = shapeIndex;
                    ps.Positive   = true;
                    pad.SetSpecifics(ps);
                    startLine.X += distance;
                }
                startLine.Y += distance;
                startLine.X  = 0;
            }
            IMatrix matrix = Parent.GetMatrix();

            matrix.UpdateDataAndList();
            Parent.UpdateView();
        }
Exemplo n.º 5
0
        void Parent_PCBISelectionChanged(object sender, EventArgs e)
        {
            if (!parent.JobIsLoaded)
            {
                return;
            }
            if (parent.GetCurrentStep().GetSelectedElements().Count < 1)
            {
                listToShow.Clear();
                return;
            }

            RectangleF ObjSize = RectangleF.Empty;

            foreach (IObject obj in parent.GetCurrentStep().GetSelectedElements())
            {
                if (ObjSize == RectangleF.Empty)
                {
                    ObjSize = obj.GetBounds();
                }
                else
                {
                    ObjSize = RectangleF.Union(ObjSize, obj.GetBounds());
                }
            }

            foreach (ICMPObject obj in parent.GetCurrentStep().GetSelectedCMPs())
            {
                PCBI.Automation.DrawingParameters.IComponentParameters dp = new PCBI.Automation.DrawingParameters.IComponentParameters();
                dp.ShowPins = false;
                if (ObjSize == RectangleF.Empty)
                {
                    if (dp.ShowPins)
                    {
                        ObjSize = obj.GetBounds();
                    }
                    else
                    {
                        ObjSize = new RectangleF((float)obj.GetBodyBoundsD().X, (float)obj.GetBodyBoundsD().Y, (float)obj.GetBodyBoundsD().Width, (float)obj.GetBodyBoundsD().Height);
                    }
                }
                else
                {
                    ObjSize = RectangleF.Union(ObjSize, obj.GetBounds());
                }
            }
            listToShow.Add(ObjSize);
        }
        public void Execute(IPCBIWindow parent)
        {
            IFilter           filter         = new IFilter(parent);
            IODBObject        outlinePolygon = filter.CreateOutlinePolygon();
            IStep             parentStep     = parent.GetCurrentStep();
            ISurfaceSpecifics spec           = (ISurfaceSpecifics)outlinePolygon.GetSpecifics();

            spec.StartPolygon(false, new PointF());
            RectangleF newBounds = new RectangleF(0, 0, 15000, 10000);

            //create 4 lines and add them to an contour polygon
            PointF leftUp    = new PointF(newBounds.Left, newBounds.Top);
            PointF leftDown  = new PointF(newBounds.Left, newBounds.Bottom);
            PointF rightUp   = new PointF(newBounds.Right, newBounds.Top);
            PointF rightDown = new PointF(newBounds.Right, newBounds.Bottom);

            spec.AddLine(leftUp, rightUp);
            spec.AddLine(rightUp, rightDown);
            spec.AddLine(rightDown, leftDown);
            spec.AddLine(leftDown, leftUp);

            spec.EndPolygon(); //close the new contour

            parentStep.SetPCBOutline(spec);
            parent.UpdateView();
        }
        public void Execute(IPCBIWindow parent)
        {
            string netName = "TestNet";

            PCB_Investigator.PCBIWindows.PCBIEnterTextDialog enterDLG = new PCB_Investigator.PCBIWindows.PCBIEnterTextDialog("Enter Net Name", "Net Name", netName, false, false);
            if (enterDLG.ShowDialog() == DialogResult.OK)
            {
                netName = enterDLG.GetText();
            }
            else
            {
                return;
            }

            IStep currentStep = parent.GetCurrentStep();

            foreach (IODBObject selectedObj in currentStep.GetSelectedElements())
            {
                ILayer parentLayer = currentStep.GetLayer(selectedObj.GetParentLayerName());
                if (parentLayer == null)
                {
                    continue;
                }

                if (parentLayer is IODBLayer)
                {
                    AddNetInfos(currentStep, (IODBLayer)parentLayer, netName, selectedObj);
                }
            }

            parent.UpdateView();
        }
        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
            }
            ILayer topMaskLayer  = step.GetLayer(matrix.FindSideLayerLayerName(MatrixLayerType.Solder_mask, true));
            ILayer topPasteLayer = step.GetLayer(matrix.FindSideLayerLayerName(MatrixLayerType.Solder_paste, true));

            if (topMaskLayer != null && topPasteLayer != null)
            {
                MarkMaskOverPadsOnPaste((IODBLayer)topMaskLayer, (IODBLayer)topPasteLayer, step);
            }

            ILayer botMaskLayer  = step.GetLayer(matrix.FindSideLayerLayerName(MatrixLayerType.Solder_mask, false));
            ILayer botPasteLayer = step.GetLayer(matrix.FindSideLayerLayerName(MatrixLayerType.Solder_paste, false));

            if (botMaskLayer != null && botPasteLayer != null)
            {
                MarkMaskOverPadsOnPaste((IODBLayer)botMaskLayer, (IODBLayer)botPasteLayer, step);
            }


            parent.UpdateView(); //redraw to show marked smd pads
        }
        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();
        }
Exemplo n.º 10
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
        }
Exemplo n.º 11
0
        public void Execute(IPCBIWindow parent)
        {
            //fill code here code
            IStep step  = parent.GetCurrentStep();
            bool  onOff = false;

            if (step == null)
            {
                return;
            }

            while (true)
            {
                Thread.Sleep(1000);
                foreach (IODBObject objSel in step.GetSelectedElements())
                {
                    if (onOff)
                    {
                        parent.IColorsetting.DrawOnlySelectedElements = true;
                        objSel.ObjectColorTemporary(Color.White);
                    }
                    else
                    {
                        objSel.ObjectColorTemporary(Color.Empty);
                    }
                }
                onOff = !onOff;

                parent.UpdateView();
                if (isDisposed)
                {
                    break;
                }
            }
        }
Exemplo n.º 12
0
        public void Execute(IPCBIWindow mainWindowPCBI)
        {
            IStep step = mainWindowPCBI.GetCurrentStep();

            if (step == null)
            {
                return;
            }

            ICMPLayer layerCMPsTop = step.GetCMPLayer(true);

            //exisits the compnenent layer?
            if (layerCMPsTop == null)
            {
                return;
            }

            foreach (string layername in step.GetAllLayerNames())
            {
                List <ILayer> layers = new List <ILayer>();
                layers.Add(step.GetLayer(layername));
                SaveImageFromComponent(step, layers, FileLocation);
            }
            //something went wrong?
            string errorLog = IAutomation.GetErrorLog();

            if (errorLog.Length > 0)
            {
                System.Diagnostics.Debug.WriteLine(errorLog);
            }
        }
Exemplo n.º 13
0
        private void PrepareFor3D_inNBI(IPCBIWindow Parent)
        {
            IMatrix matrix = Parent.GetMatrix();
            IStep   step   = Parent.GetCurrentStep();

            MakeSolderMaskPositive(matrix);
            MakeDrillCutOutOnCopperLayers(Parent, matrix, step);

            Parent.UIAction.Execute(ID_ActionItem.ID_CLEAR_SELECTION);
            Parent.UIAction.Execute(ID_ActionItem.ID_ALL_LAYER_OFF);
            Parent.UIAction.Execute(ID_ActionItem.ID_ALL_SIGNAL_LAYER_ON);
            Parent.UpdateView();

            Parent.UIAction.Execute(ID_ActionItem.ID_SAVE);

            String JobLocation = Parent.GetODBJobDirectory();

            if (File.Exists(pathNBICatia))
            {
                try
                {
                    ProcessStartInfo ps = new ProcessStartInfo(pathNBICatia, "\"" + JobLocation + "\"");
                    Process.Start(ps);
                    //  Process.Start(pathNBICatia + " " + "\"" +  JobLocation + "\"");
                }

                catch (Exception ex)
                {
                    PCB_Investigator.Localization.PCBILocalization.ShowMsgBox("Can not open NBI, because " + ex.Message.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
        }
Exemplo n.º 14
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();
        }
Exemplo n.º 15
0
        public void parent_PCBIActiveLayerChanged(object sender, EventArgs e)
        {
            int   i    = 0;
            IStep step = Parent.GetCurrentStep();

            if (step == null)
            {
                return;
            }
            List <ILayer> activeLayers = step.GetActiveLayerList();

            if (activeLayers.Count != 2)
            {
                return;
            }
            foreach (ILayer layer in activeLayers)
            {
                if (layer.GetType() == typeof(IODBLayer))
                {
                    if (i == 0)
                    {
                        i++;
                        ((IODBLayer)layer).Col = Color.FromArgb(255, 255, 250, 0);
                    }
                    else
                    if (i == 1)
                    {
                        ((IODBLayer)layer).Col = Color.FromArgb(255, 255, 240, 0);
                    }
                }
            }
            Parent.IColorsetting.ColorMix = PCBI.DrawingMode.special;
            Parent.UpdateView();
        }
Exemplo n.º 16
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);
                    }
                }
            }
        }
        public void Execute(IPCBIWindow parent)
        {
            IMatrix m    = parent.GetMatrix();
            IStep   step = parent.GetCurrentStep();


            foreach (ICMPObject comp in step.GetAllCMPObjects())
            {
                IPackageSpecificsD pack     = comp.GetPackageSpecificsD();
                RectangleD         rectBody = pack.GetBodyBounds();
                RectangleD         rect     = pack.GetBounds();
                comp.AddComponentAttribute("Body_Width", rectBody.Width.ToString());
                comp.AddComponentAttribute("Body_Height", rectBody.Height.ToString());
                // rect = GetPinBounds(comp);
                comp.AddComponentAttribute("Pin_Width", rect.Width.ToString());
                comp.AddComponentAttribute("Pin_Height", rect.Height.ToString());
                comp.AddComponentAttribute("Pin_Area", (rect.Height * rect.Width).ToString());
                //   if(comp.GetPinList().Count == 2)
                // {
                //   string shouldBe = GetGeometrieName(rect.Height * rect.Width);
                //  comp.AddComponentAttribute("Geometry_Calculated", shouldBe );
                // }
            }

            parent.UpdateView();
        }
Exemplo n.º 18
0
        private void SetToGrid(float grid, IPCBIWindow parent)
        {
            IStep step = parent.GetCurrentStep();

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

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

                    pads.Location.X = correction(pads.Location.X, grid);
                    pads.Location.Y = correction(pads.Location.Y, grid);
                    obj.SetSpecifics(pads);
                }
            }
        }
Exemplo n.º 19
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();
        }
Exemplo n.º 20
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();
        }
Exemplo n.º 21
0
        public void Execute(IPCBIWindow parent)
        {
            wdlg = new PCB_Investigator.PCBIWindows.PCBIWorkingDialog();
            wdlg.SetAnimationStatus(false);
            wdlg.SetStatusPercent(0);
            wdlg.SetStatusText("Working");
            wdlg.CanCancel(true);

            IStep curStep = parent.GetCurrentStep();

            if (curStep == null)
            {
                return;
            }

            Dictionary <string, double> smallestDiameterList = new Dictionary <string, double>();
            StringBuilder sbResult = new StringBuilder();

            wdlg.ShowWorkingDlgAsThread();

            List <string> netNames  = curStep.GetAllNetNames();
            double        value     = 0;
            double        valueStep = ((100.0 / netNames.Count));


            foreach (string netName in curStep.GetAllNetNames())
            {
                INet net = curStep.GetNet(netName);

                wdlg.SetStatusText("Working on " + netName + "...");
                value += valueStep;
                wdlg.SetStatusPercent((int)(value));

                List <IODBObject> allNetElements = net.GetAllNetObjects(parent);
                if (allNetElements.Count == 0)
                {
                    continue;
                }

                double smallestDiameter = allNetElements[0].GetDiameter();
                foreach (IODBObject netElement in allNetElements)
                {
                    double currentDiameter = netElement.GetDiameter();
                    if (currentDiameter < 0)
                    {
                        continue;                      //e.g. surfaces have no diameter
                    }
                    if (currentDiameter < smallestDiameter)
                    {
                        smallestDiameter = currentDiameter;
                    }
                }

                smallestDiameterList.Add(netName, smallestDiameter);
                sbResult.AppendLine(netName + ": " + smallestDiameter.ToString() + " mils");
            }
            wdlg.Dispose();
            PCB_Investigator.Localization.PCBILocalization.ShowMsgBox("All smallest Net Diameters:" + Environment.NewLine + sbResult.ToString(), "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemplo n.º 22
0
        public static void Execute(IPCBIWindow parent)
        {
            //check all selected lines, if lines on lines cut them

            IStep   step   = parent.GetCurrentStep();
            IFilter filter = new IFilter(parent);

            if (step == null)
            {
                return;
            }

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

            PCB_Investigator.PCBIWindows.PCBIWorkingDialog working = new PCB_Investigator.PCBIWindows.PCBIWorkingDialog();
            StopCutting = false;
            working.SetStatusText("Working on splitting lines...");
            working.CancelPressed += Working_CancelPressed;
            working.CanCancel(true);
            working.SetAnimationStatus(false);

            working.ShowWorkingDlgAsThread();

            for (int i = 0; i < selectedElements.Count; i++)
            {
                if (StopCutting)
                {
                    break;
                }

                working.SetStatusPercent(i * 100 / selectedElements.Count);

                IODBObject evtlLine = selectedElements[i];
                if (evtlLine.Type != IObjectType.Line)
                {
                    continue;
                }

                ILineSpecificsD line = (ILineSpecificsD)evtlLine.GetSpecificsD();
                for (int j = i + 1; j < selectedElements.Count; j++)
                {
                    IODBObject evtlLine2 = selectedElements[j];
                    if (evtlLine2.Type != IObjectType.Line || evtlLine == evtlLine2)
                    {
                        continue;
                    }
                    ILineSpecificsD line2 = (ILineSpecificsD)evtlLine2.GetSpecificsD();

                    PointD crossingP = IMath.CrossingPoint(line.Start, line.End, line2.Start, line2.End, true);
                    if (PointD.InfPoint != crossingP)
                    {
                        CreateSplittedLines(step, filter, evtlLine2, line2, crossingP, ref selectedElements);
                        CreateSplittedLines(step, filter, evtlLine, line, crossingP, ref selectedElements);
                        line = (ILineSpecificsD)evtlLine.GetSpecificsD(); //changed, get it new
                    }
                }
            }
            working.DoClose();
        }
        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();
        }
Exemplo n.º 24
0
 void parent_PCBISelectionChanged(object sender, EventArgs e)
 {
     pcbDoc.UnSelectAll();
     foreach (ICMPObject cmp in Parent.GetCurrentStep().GetSelectedCMPs())
     {
         pcbDoc.FindComponent(cmp.Ref).Selected = true;
     }
     pcbDoc.ActiveView.SetExtentsToSelection();
 }
Exemplo n.º 25
0
 public void Execute(IPCBIWindow parent)
 {
     PCBI.Automation.IMatrix matrix = parent.GetMatrix();
     PCBI.Automation.IStep   step   = parent.GetCurrentStep();
     SetMatrixOrder(matrix, step);
     matrix.Save();
     parent.UpdateControlsAndResetView();
     parent.UpdateView();
     parent.UpdateView();
 }
        private void DrawComponentInfo(Graphics g)
        {
            int xPos = 30;
            int posY = 80;

            foreach (ICMPObject cmp in parent.GetCurrentStep().GetSelectedCMPs())
            {
                String Text     = cmp.Ref;
                SizeF  strSize  = g.MeasureString(Text, new Font("Arial", 20));
                Brush  TextB    = new SolidBrush(Color.FromArgb(180, 250, 250, 0));
                Brush  TextBRef = new SolidBrush(Color.FromArgb(180, 250, 250, 240));
                g.FillRectangle(TextBRef, xPos, posY, strSize.Width, strSize.Height);
                g.DrawString(Text, new Font("Arial", 20), Brushes.Black, new PointF(xPos, posY));
                posY   += 40;
                Text    = "Part Name: " + cmp.PartName;
                strSize = g.MeasureString(Text, new Font("Arial", 10));
                g.FillRectangle(TextB, xPos, posY, strSize.Width, strSize.Height);
                g.DrawString(Text, new Font("Arial", 10), Brushes.Black, new PointF(xPos, posY));
                posY   += 20;
                Text    = "Package Name: " + cmp.UsedPackageName;
                strSize = g.MeasureString(Text, new Font("Arial", 10));
                g.FillRectangle(TextB, xPos, posY, strSize.Width, strSize.Height);
                g.DrawString(Text, new Font("Arial", 10), Brushes.Black, new PointF(xPos, posY));
                posY += 20;
                foreach (string attrib in cmp.GetComponentAttributes())
                {
                    Text    = attrib;
                    strSize = g.MeasureString(Text, new Font("Arial", 10));
                    g.FillRectangle(TextB, xPos, posY, strSize.Width, strSize.Height);
                    g.DrawString(Text, new Font("Arial", 10), Brushes.Black, new PointF(xPos, posY));
                    posY += 20;
                }
                foreach (string attrib in cmp.GetGeometryAttributes())
                {
                    Text    = attrib;
                    strSize = g.MeasureString(Text, new Font("Arial", 10));
                    g.FillRectangle(TextB, xPos, posY, strSize.Width, strSize.Height);
                    g.DrawString(Text, new Font("Arial", 10), Brushes.Black, new PointF(xPos, posY));
                    posY += 20;
                }
                break;
            }
        }
 public void Execute(IPCBIWindow parent)
 {
     //your code here
     if (parent.JobIsLoaded)
     {
         List <string> columheader = new List <string>();
         columheader.Add("Layer Name");
         columheader.Add("Layer Thickness µm");
         columheader.Add("Layer Position µm");
         PCB_Investigator.PCBIWindows.PCBIResultDialog layerDlg = new PCBIResultDialog(columheader, "Matrix");
         IStep   step   = parent.GetCurrentStep();
         IMatrix matrix = parent.GetMatrix();
         //	bool toggle = true;
         foreach (string layername in matrix.GetAllLayerNames())
         {
             ListViewItem lvi = new ListViewItem(layername);
             // if (toggle)
             //  {
             //      lvi.BackColor = Color.LightBlue;
             //   }
             //  toggle = !toggle;
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Signal)
             {
                 lvi.BackColor = Color.Orange;
             }
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Power_ground)
             {
                 lvi.BackColor = Color.Orange;
             }
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Solder_mask)
             {
                 lvi.BackColor = Color.LightGreen;
             }
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Solder_paste)
             {
                 lvi.BackColor = Color.LightYellow;
             }
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Dielectric)
             {
                 lvi.BackColor = Color.GreenYellow;
             }
             if (matrix.GetMatrixLayerType(layername) == MatrixLayerType.Component)
             {
                 lvi.BackColor = Color.LightSteelBlue;
             }
             double Layerpos       = IMath.Mils2MM(MatrixHelpers.GetLayerPositionInStackUp(layername, step, matrix)) * 1000;
             double layerthickness = IMath.Mils2MM(step.GetHeightOfLayer(layername)) * 1000;
             lvi.SubItems.Add(layerthickness.ToString("N2"));
             lvi.SubItems.Add(Layerpos.ToString("N2"));
             layerDlg.AddListViewItem(lvi);
         }
         layerDlg.ShowDlg(PCBIResultDialog.WindowType.Modal);
         parent.UpdateView();
     }
 }
        void Parent_PCBIFormGraphicPaneDrawing(Graphics g, int ClientWidth, int ClientHeight)
        {
            if (!parent.JobIsLoaded)
            {
                return;
            }


            g.TranslateTransform(1, -1);

            foreach (IODBObject obj in parent.GetCurrentStep().GetSelectedElements())
            {
                if (obj.GetSpecifics() is ILineSpecifics)
                {
                    ILineSpecifics ls  = (ILineSpecifics)obj.GetSpecifics();
                    Pen            pen = new Pen(Color.Aquamarine, 10);
                    pen.DashOffset = 4;
                    //pen.DashPattern = 0.5f;
                    pen.DashStyle = DashStyle.DashDotDot;
                    pen.StartCap  = LineCap.Triangle;
                    pen.EndCap    = LineCap.ArrowAnchor;

                    g.DrawLine(pen, parent.WorldToClient(ls.Start), parent.WorldToClient(ls.End));


                    Point locatioStart = parent.WorldToClient(ls.Start);
                    locatioStart = new Point(locatioStart.X - 20, locatioStart.Y - 20);
                    RectangleF SRect  = new RectangleF(locatioStart, new Size(40, 40));
                    Pen        PStart = new Pen(Color.AliceBlue, 4);
                    g.DrawEllipse(PStart, SRect);
                }
                else if (obj.GetSpecifics() is IArcSpecifics)
                {
                    IArcSpecifics aspec = (IArcSpecifics)obj.GetSpecifics();
                    Pen           pen   = new Pen(Color.Yellow, 10);
                    pen.DashOffset = 4;
                    //pen.DashPattern = 0.5f;
                    pen.DashStyle = DashStyle.DashDotDot;
                    pen.StartCap  = LineCap.Triangle;
                    pen.EndCap    = LineCap.ArrowAnchor;

                    g.DrawLine(pen, parent.WorldToClient(aspec.Start), parent.WorldToClient(aspec.End));

                    g.DrawLine(pen, parent.WorldToClient(aspec.Start), parent.WorldToClient(aspec.Center));
                    g.DrawLine(pen, parent.WorldToClient(aspec.End), parent.WorldToClient(aspec.Center));

                    Point locatioStart = parent.WorldToClient(aspec.Start);
                    locatioStart = new Point(locatioStart.X - 20, locatioStart.Y - 20);
                    RectangleF SRect  = new RectangleF(locatioStart, new Size(40, 40));
                    Pen        PStart = new Pen(Color.AliceBlue, 4);
                    g.DrawEllipse(PStart, SRect);
                }
            }
        }
        void Parent_PCBIFormGraphicPaneDrawing(Graphics g, int ClientWidth, int ClientHeight)
        {
            if (!parent.JobIsLoaded)
            {
                return;
            }
            int   pcbCount  = 0;
            IStep PanelStep = parent.GetCurrentStep();

            if (PanelStep == null)
            {
                return;
            }

            RectangleF PanelSize = PanelStep.GetBounds();

            if (PanelSize == RectangleF.Empty)
            {
                return;
            }
            DrawSingleBoard(g, PanelSize, new PointD(0, 0), pcbCount, PanelStep.Name, "0");
            pcbCount++;
            List <IStep.StepAndRepeatClass> srList = PanelStep.GetChildStepClasses();

            foreach (IStep.StepAndRepeatClass sr in srList)
            {
                IStep step = parent.GetStep(sr.NAME);
                System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix();
                matrix.Rotate(-(float)sr.ANGLE, System.Drawing.Drawing2D.MatrixOrder.Append);
                matrix.Translate((float)sr.X, (float)sr.Y, System.Drawing.Drawing2D.MatrixOrder.Append);
                RectangleF BoardSize     = IMath.RectangleTransformWithMatrix(step.GetBoundsD(), matrix).ToRectangleF();
                PointD     originOfBoard = new PointD(sr.X, sr.Y);
                IMath.TransformPoint(matrix, originOfBoard);
                DrawSingleBoard(g, BoardSize, originOfBoard, pcbCount, sr.NAME, sr.ANGLE.ToString("N2"));
                if (sr.NX > 1 || sr.NY > 1)
                {
                    for (int iy = 0; iy < sr.NY; iy++)
                    {
                        for (int ix = 0; ix < sr.NX; ix++)
                        {
                            System.Drawing.Drawing2D.Matrix matrixsr = matrix.Clone();
                            double offsetX = sr.DX * ix;
                            double offsetY = sr.DY * iy;
                            matrixsr.Translate((float)offsetX, (float)offsetY, System.Drawing.Drawing2D.MatrixOrder.Append);
                            BoardSize     = IMath.RectangleTransformWithMatrix(step.GetBoundsD(), matrixsr).ToRectangleF();
                            originOfBoard = new PointD(sr.X + offsetX, sr.Y + offsetY);
                            DrawSingleBoard(g, BoardSize, originOfBoard, pcbCount, sr.NAME, sr.ANGLE.ToString("N2"));
                            pcbCount++;
                        }
                    }
                }
                pcbCount++;
            }
        }
        public void Execute(IPCBIWindow parent)
        {
            IStep         step        = parent.GetCurrentStep();
            IFilter       filter      = new IFilter(parent);
            List <String> GroundNames = new List <string>();

            GroundNames.Add("gnd");
            GroundNames.Add("ground");
            GroundNames.Add("/gnd");
            List <String> VCCNames = new List <string>();

            VCCNames.Add("3v");
            VCCNames.Add("vcc");
            VCCNames.Add("vtt");
            VCCNames.Add("/1v");

            foreach (ICMPObject cmp in step.GetAllCMPObjects())
            {
                if (cmp.GetPinList().Count == 2)
                {
                    List <IPin> plist    = cmp.GetPinList();
                    bool        gndfound = false;
                    bool        vccFound = false;
                    foreach (IPin pin in plist)
                    {
                        if (StartsWithStringOfList(GroundNames, pin.GetNetNameOnIPin(cmp).ToLower()))
                        {
                            gndfound = true;
                        }
                        if (StartsWithStringOfList(VCCNames, pin.GetNetNameOnIPin(cmp).ToLower()))
                        {
                            vccFound = true;
                        }
                    }
                    if (gndfound && vccFound)
                    {
                        cmp.ObjectColor = Color.ForestGreen;
                        foreach (IPin pin in plist)
                        {
                            if (StartsWithStringOfList(GroundNames, pin.GetNetNameOnIPin(cmp).ToLower()))
                            {
                                pin.SetPinColor(Color.BlueViolet, cmp);
                            }
                            if (StartsWithStringOfList(VCCNames, pin.GetNetNameOnIPin(cmp).ToLower()))
                            {
                                pin.SetPinColor(Color.Red, cmp);
                            }
                        }
                    }
                }
            }
            parent.UpdateView();
        }