Exemplo n.º 1
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.º 2
0
        private static void AddDrillObjects(IFilter filter, ILayer drill_layer, MatrixLayerType type, IODBLayer odb_sig_layer)
        {
            Dictionary <int, int> symbolUsed = new Dictionary <int, int>();

            foreach (IODBObject obj in drill_layer.GetAllLayerObjects())
            {
                #region one drill layer
                obj.Select(true);
                if (obj.Type == IObjectType.Pad)
                {
                    IPadSpecifics ops = (IPadSpecifics)obj.GetSpecifics();
                    if (type != MatrixLayerType.Dielectric)
                    {
                        ops.Positive = false;
                    }
                    else
                    {
                        ops.Positive = true;
                    }

                    if (!symbolUsed.ContainsKey(ops.ShapeIndex))
                    {
                        int index = IFilter.AddToolFromODBString(odb_sig_layer, ops.ODBSymbol_String);
                        symbolUsed.Add(ops.ShapeIndex, index);
                    }

                    ops.ShapeIndex = symbolUsed[ops.ShapeIndex];

                    IODBObject pad = filter.CreatePad(odb_sig_layer);
                    pad.SetSpecifics(ops);
                }
                else if (obj.Type == IObjectType.Line)
                {
                    ILineSpecifics ops = (ILineSpecifics)obj.GetSpecifics();
                    if (type != MatrixLayerType.Dielectric)
                    {
                        ops.Positive = false;
                    }
                    else
                    {
                        ops.Positive = true;
                    }

                    if (!symbolUsed.ContainsKey(ops.ShapeIndex))
                    {
                        int index = IFilter.AddToolFromODBString(odb_sig_layer, ops.ODBSymbol_String);
                        symbolUsed.Add(ops.ShapeIndex, index);
                    }

                    ops.ShapeIndex = symbolUsed[ops.ShapeIndex];

                    IODBObject line = filter.CreateLine(odb_sig_layer);
                    line.SetSpecifics(ops);
                }

                #endregion
            }
        }
        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);
                }
            }
        }
        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();
        }
        void Parent_PCBIFormGraphicPaneDrawing(Graphics g, int ClientWidth, int ClientHeight)
        {
            if (!parent.JobIsLoaded)
            {
                return;
            }

            IStep step = parent.GetCurrentStep();

            if (step == null)
            {
                return;
            }

            foreach (IODBObject selectedObject in step.GetSelectedElements())
            {
                if (selectedObject.Type == IObjectType.Line)
                {
                    ILineSpecifics line        = (ILineSpecifics)selectedObject.GetSpecifics();
                    Point          startOfLine = parent.WorldToClient(line.Start);
                    float          dimaeter    = (float)line.Diameter;

                    g.DrawLine(Pens.Bisque, new PointF(startOfLine.X, startOfLine.Y + dimaeter), new PointF(startOfLine.X + dimaeter, startOfLine.Y));
                    g.DrawLine(Pens.Bisque, new PointF(startOfLine.X + dimaeter, startOfLine.Y), new PointF(startOfLine.X, startOfLine.Y - dimaeter));
                    g.DrawLine(Pens.Bisque, new PointF(startOfLine.X + dimaeter, startOfLine.Y), new PointF(startOfLine.X - dimaeter, startOfLine.Y));
                }
                else if (selectedObject.Type == IObjectType.Arc)
                {
                    IArcSpecifics arc        = (IArcSpecifics)selectedObject.GetSpecifics();
                    Point         startOfArc = parent.WorldToClient(arc.Start);
                    float         dimaeter   = (float)arc.PenWidth;

                    g.DrawLine(Pens.Bisque, new PointF(startOfArc.X, startOfArc.Y + dimaeter), new PointF(startOfArc.X + dimaeter, startOfArc.Y));
                    g.DrawLine(Pens.Bisque, new PointF(startOfArc.X + dimaeter, startOfArc.Y), new PointF(startOfArc.X, startOfArc.Y - dimaeter));
                    g.DrawLine(Pens.Bisque, new PointF(startOfArc.X + dimaeter, startOfArc.Y), new PointF(startOfArc.X - dimaeter, startOfArc.Y));
                }
            }
        }
Exemplo n.º 6
0
        public void Execute(IPCBIWindow parent)
        {
            if (parent == null)
            {
                return;
            }
            TextType tt = TextType.angle;

            ShowInputDialog(ref tt);

            // MessageBox.Show( tt.ToString());
            IMatrix m    = parent.GetMatrix();
            IStep   step = parent.GetCurrentStep();

            if (tt == TextType.angle)
            {
                foreach (string layerName in m.GetAllSignalLayerNames())
                {
                    IODBLayer layer = (IODBLayer)step.GetLayer(layerName);

                    foreach (IODBObject obj in layer.GetAllLayerObjects())
                    {
                        IObjectSpecifics os = obj.GetSpecifics();
                        if (os.GetType() == typeof(ILineSpecifics))
                        {
                            ILineSpecifics lineEdges = (ILineSpecifics)os;
                            double         angle     = PCBI.MathUtils.IMath.GetAngle(PCBI.MathUtils.PointD.FromPointF(lineEdges.Start), PCBI.MathUtils.PointD.FromPointF(lineEdges.End));
                            obj.FreeText = "? " + angle.ToString();
                        }
                        if (os.GetType() == typeof(IPadSpecifics))
                        {
                            IPadSpecifics PAD   = (IPadSpecifics)os;
                            double        angle = PAD.Rotation;
                            obj.FreeText = "? " + angle.ToString();
                        }
                    }
                }
            }
            if (tt == TextType.lenght)
            {
                foreach (string layerName in m.GetAllSignalLayerNames())
                {
                    IODBLayer layer = (IODBLayer)step.GetLayer(layerName);

                    foreach (IODBObject obj in layer.GetAllLayerObjects())
                    {
                        IObjectSpecifics os = obj.GetSpecifics();
                        if (os.GetType() == typeof(ILineSpecifics))
                        {
                            ILineSpecifics lineEdges = (ILineSpecifics)os;

                            double length = PCBI.MathUtils.IMath.DistancePointToPoint(PCBI.MathUtils.PointD.FromPointF(lineEdges.Start), PCBI.MathUtils.PointD.FromPointF(lineEdges.End)) / 100;
                            if (parent.GetUnit())
                            {
                                length *= 2.54f;
                            }
                            length       = Math.Round(length, 2);
                            obj.FreeText = "L: " + length.ToString();
                        }
                        if (os.GetType() == typeof(IPadSpecifics))
                        {
                            IPadSpecifics PAD    = (IPadSpecifics)os;
                            RectangleF    bounds = obj.GetBounds();
                            double        w      = bounds.Width / 100;
                            double        h      = bounds.Height / 100;

                            if (parent.GetUnit())
                            {
                                w *= 2.54f;
                                h *= 2.54f;
                            }
                            w            = Math.Round(w, 2);
                            h            = Math.Round(h, 2);
                            obj.FreeText = "w: " + w.ToString() + " h: " + h.ToString();
                        }
                    }
                }
            }
            if (tt == TextType.ViaCount)
            {
                foreach (INet NetList in step.GetNets())
                {
                    int drillCount = 0;
                    foreach (IODBObject obj in NetList.GetAllNetObjects(parent))
                    {
                        if (m.GetMatrixLayerType(obj.GetParentLayerName()) == MatrixLayerType.Drill)
                        {
                            drillCount++;
                        }
                    }
                    foreach (IODBObject obj in NetList.GetAllNetObjects(parent))
                    {
                        obj.FreeText = "DrillCount: " + drillCount.ToString();
                    }
                }
            }
            if (tt == TextType.NetOnLayer)
            {
                foreach (INet NetList in step.GetNets())
                {
                    string LNames = "";
                    foreach (string LayerNames in NetList.GetAllUsedLayers(step))
                    {
                        if (m.GetMatrixLayerType(LayerNames) == MatrixLayerType.Signal)
                        {
                            LNames += LayerNames + "; ";
                        }
                    }
                    foreach (IODBObject obj in NetList.GetAllNetObjects(parent))
                    {
                        obj.FreeText = "layer: " + LNames;
                    }
                }
            }
            if (tt == TextType.NetLength)
            {
                foreach (INet NetList in step.GetNets())
                {
                    double length = CalculateNetLenth(NetList.GetAllNetObjects(parent)) / 100;
                    if (parent.GetUnit())
                    {
                        length *= 2.54f;
                    }
                    foreach (IODBObject obj in NetList.GetAllNetObjects(parent))
                    {
                        obj.FreeText = "Netlength: " + Math.Round(length, 2);
                    }
                }
            }
            parent.ShowFreeTextInfoOnAllLayer = true;
            parent.UpdateView();
        }