Пример #1
0
        public bool CheckBorders()
        {
            bool result = true;

            for (int index = 0; index < Borders.Count; index++)
            {
                fp_line line0 = Borders[index] as fp_line;
                fp_line line1 = Borders[(index + 1) % Borders.Count] as fp_line;

                line0.end.X = (float)Math.Round(line0.end.X, 1);
                line0.end.Y = (float)Math.Round(line0.end.Y, 1);

                line1.start.X = line0.end.X;
                line1.start.Y = line0.end.Y;

                if ((line0.end.X == line1.start.X) &&
                    (line0.end.Y == line1.start.Y)
                    )
                {
                    // ok
                }
                else
                {
                    result = false;
                    Console.WriteLine(string.Format("mismatch {0},{1}  {2},{3}", line0.end.X, line0.end.Y, line1.start.X, line1.start.Y));
                }
            }
            return(result);
        }
Пример #2
0
        public RectangleF GetExtent(String layer)
        {
            PointF min = new PointF(0, 0);
            PointF max = new PointF(0, 0);

            if (Borders != null)
            {
                foreach (fp_shape shape in Borders)
                {
                    if (shape.layer.Contains(layer))
                    {
                        if (shape is fp_line)
                        {
                            fp_line line = shape as fp_line;
                            addToExtent(ref min, ref max, line.start);
                            addToExtent(ref min, ref max, line.end);
                        }
                    }
                }
            }

            if (Pads != null)
            {
                foreach (pad a_pad in Pads)
                {
                    if (a_pad._layers.Contains(layer))
                    {
                        PointF pos = new PointF(a_pad.position.At.X - a_pad.size.Width / 2,
                                                a_pad.position.At.Y - a_pad.size.Height / 2);

                        addToExtent(ref min, ref max, pos);

                        pos = new PointF(a_pad.position.At.X + a_pad.size.Width / 2,
                                         a_pad.position.At.Y + a_pad.size.Height / 2);

                        addToExtent(ref min, ref max, pos);
                    }
                }
            }

            if ((max.X - min.X == 0) && (max.Y - min.Y == 0))
            {
                return(RectangleF.Empty);
            }
            else
            {
                return(new RectangleF(min.X, min.Y, max.X - min.X, max.Y - min.Y));
            }
        }
Пример #3
0
        public static fp_line Parse(SNodeBase node)
        {
            fp_line result = new fp_line();

            if ((node is SExpression) && ((node as SExpression).Name == "fp_line"))
            {
                SExpression expr = node as SExpression;

                result.start = (expr.Items[0] as SExpression).GetPointF();
                result.end   = (expr.Items[1] as SExpression).GetPointF();

                result.layer = Layer.ParseLayer(expr.Items[2]);
                result.width = (expr.Items[3] as SExpression).GetFloat();

                return(result);
            }
            else
            {
                return(null);  // error
            }
        }