Beispiel #1
0
        public static void Draw(SymbolLayout Sym, double x, double y1, double y2, int N, double Scale)
        {
            double h = y2 - y1;

            Sym.DrawFunction(
                EdgeType.Black,
                (t) => x - Scale * (Math.Abs((t + 0.5) % 2 - 1) * 2 - 1),
                (t) => t * h / N + y1,
                0, N, N * 2);
        }
Beispiel #2
0
        public static void Draw(SymbolLayout Sym, double x, double y1, double y2, int N, double Scale)
        {
            double h = y2 - y1;

            Sym.DrawFunction(
                EdgeType.Black,
                (t) => x - Scale * (Math.Abs((t + 0.5) % 2 - 1) * 2 - 1),
                (t) => t * h / N + y1,
                0, N, N * 2);
        }
Beispiel #3
0
        public static void Draw(SymbolLayout Sym, double x, double y1, double y2, int Turns, double Scale)
        {
            double t1   = -Math.PI;
            double t2   = 2 * (Turns - 1) * Math.PI;
            double coil = 1.5;

            double min    = t1 + coil * Math.Cos(t1);
            double max    = t2 + coil * Math.Cos(t2);
            double length = max - min;

            Sym.DrawFunction(
                EdgeType.Black,
                (t) => x - Scale * Math.Sin(t),
                (t) => (t + coil * Math.Cos(t) - min) / length * (y2 - y1) + y1,
                t1, t2, Turns * 16);
        }
Beispiel #4
0
        public static void Draw(SymbolLayout Sym, double x, double y1, double y2, int Turns, double Scale)
        {
            double t1 = -3.141592;
            double t2 = 2 * (Turns - 1) * 3.141592;
            double coil = 1.5;

            double min = t1 + coil * Math.Cos(t1);
            double max = t2 + coil * Math.Cos(t2);
            double length = max - min;

            Sym.DrawFunction(
                EdgeType.Black,
                (t) => x - Scale * Math.Sin(t),
                (t) => (t + coil * Math.Cos(t) - min) / length * (y2 - y1) + y1,
                t1, t2, Turns * 16);
        }
Beispiel #5
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            // Get the ports to add to the symbol.
            List <Port> ports = Components.OfType <Port>().OrderBy(i => i.Name).ToList();

            int number = (Math.Max(ports.Max(i => i.Number, 0), ports.Count()) + 1) & ~1;

            int w = 40;
            int h = (number / 2) * 10;

            Sym.DrawText(() => PartNumber, new Coord(0, h + 2), Alignment.Center, Alignment.Near);
            Sym.AddRectangle(EdgeType.Black, new Coord(-w, -h), new Coord(w, h));
            Sym.DrawText(() => Name, new Coord(0, -h - 2), Alignment.Center, Alignment.Far);

            // Draw a notch at the top of the IC. Port slots are numbered counter-clockwise from here.
            int r = 5;

            Sym.DrawFunction(EdgeType.Black, t => t, t => h - Math.Sqrt(r * r - t * t), -r, r, 12);

            // Remember which port slots are open for the unnumbered terminals.
            List <int> open = Enumerable.Range(1, number + 1).ToList();

            foreach (Port i in ports.OrderBy(i => i.Number > 0 ? 0 : 1))
            {
                int n = i.Number > 0 ? i.Number : open.First();

                Terminal t = i.External;
                Coord    x;
                if (n <= number / 2)
                {
                    x = new Coord(-w, h - n * 20 + 10);
                }
                else
                {
                    x = new Coord(w, n * 20 - 3 * h - 10);
                }

                Sym.AddTerminal(t, x);
                Sym.DrawText(() => t.Name, new Coord(x.x - Math.Sign(x.x) * 3, x.y), x.x < 0 ? Alignment.Near : Alignment.Far, Alignment.Center);

                open.Remove(n);
            }
        }
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            int r = 10;

            Sym.AddWire(Anode, new Coord(0, r));
            Sym.AddWire(Cathode, new Coord(0, -r));

            Sym.AddCircle(EdgeType.Black, new Coord(0, 0), r);
            Sym.DrawPositive(EdgeType.Black, new Coord(0, 7));
            Sym.DrawNegative(EdgeType.Black, new Coord(0, -7));
            if (!((Expression)Voltage is Constant))
            {
                Sym.DrawFunction(
                    EdgeType.Black,
                    (t) => t * r * 0.75,
                    (t) => Math.Sin(t * 3.1415) * r * 0.5, -1, 1);
            }

            Sym.DrawText(() => Voltage.ToString(), new Point(r * 0.7, r * 0.7), Alignment.Near, Alignment.Near);
            Sym.DrawText(() => Name, new Point(r * 0.7, r * -0.7), Alignment.Near, Alignment.Far);
        }
Beispiel #7
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            // Get the ports to add to the symbol.
            List<Port> ports = Components.OfType<Port>().OrderBy(i => i.Name).ToList();

            int number = (Math.Max(ports.Max(i => i.Number, 0), ports.Count()) + 1) & ~1;

            int w = 40;
            int h = (number / 2) * 10;

            Sym.DrawText(() => PartNumber, new Coord(0, h + 2), Alignment.Center, Alignment.Near);
            Sym.AddRectangle(EdgeType.Black, new Coord(-w, -h), new Coord(w, h));
            Sym.DrawText(() => Name, new Coord(0, -h - 2), Alignment.Center, Alignment.Far);

            // Draw a notch at the top of the IC. Port slots are numbered counter-clockwise from here.
            int r = 5;
            Sym.DrawFunction(EdgeType.Black, t => t, t => h - Math.Sqrt(r * r - t * t), -r, r, 12);

            // Remember which port slots are open for the unnumbered terminals.
            List<int> open = Enumerable.Range(1, number + 1).ToList();
            foreach (Port i in ports.OrderBy(i => i.Number > 0 ? 0 : 1))
            {
                int n = i.Number > 0 ? i.Number : open.First();

                Terminal t = i.External;
                Coord x;
                if (n <= number / 2)
                    x = new Coord(-w, h - n * 20 + 10);
                else
                    x = new Coord(w, n * 20 - 3 * h - 10);

                Sym.AddTerminal(t, x);
                Sym.DrawText(() => t.Name, new Coord(x.x - Math.Sign(x.x) * 3, x.y), x.x < 0 ? Alignment.Near : Alignment.Far, Alignment.Center);

                open.Remove(n);
            }
        }
Beispiel #8
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            int r = 10;

            Sym.AddWire(Anode, new Coord(0, r));
            Sym.AddWire(Cathode, new Coord(0, -r));

            Sym.AddCircle(EdgeType.Black, new Coord(0, 0), r);
            Sym.DrawPositive(EdgeType.Black, new Coord(0, 7));
            Sym.DrawNegative(EdgeType.Black, new Coord(0, -7));
            if (!((Expression)Voltage is Constant))
                Sym.DrawFunction(
                    EdgeType.Black,
                    (t) => t * r * 0.75,
                    (t) => Math.Sin(t * 3.1415) * r * 0.5, -1, 1);

            Sym.DrawText(() => Voltage.ToString(), new Point(r * 0.7, r * 0.7), Alignment.Near, Alignment.Near);
            Sym.DrawText(() => Name, new Point(r * 0.7, r * -0.7), Alignment.Near, Alignment.Far);
        }