public static void LayoutSymbol(SymbolLayout Sym, BjtType Type, Terminal C, Terminal B, Terminal E, Func <string> Name, Func <string> Part)
        {
            int bx = -5;

            Sym.AddTerminal(B, new Coord(-20, 0), new Coord(bx, 0));
            switch (Type)
            {
            case BjtType.NPN:
                Sym.AddTerminal(C, new Coord(10, 20), new Coord(10, 17));
                Sym.AddTerminal(E, new Coord(10, -20), new Coord(10, -17));
                Sym.DrawLine(EdgeType.Black, new Coord(10, 17), new Coord(bx, 8));
                Sym.DrawArrow(EdgeType.Black, new Coord(bx, -8), new Coord(10, -17), 0.2, 0.3);
                break;

            case BjtType.PNP:
                Sym.AddTerminal(E, new Coord(10, 20), new Coord(10, 17));
                Sym.AddTerminal(C, new Coord(10, -20), new Coord(10, -17));
                Sym.DrawArrow(EdgeType.Black, new Coord(10, 17), new Coord(bx, 8), 0.2, 0.3);
                Sym.DrawLine(EdgeType.Black, new Coord(bx, -8), new Coord(10, -17));
                break;

            default:
                throw new NotSupportedException("Unknown BJT type.");
            }
            Sym.DrawLine(EdgeType.Black, new Coord(bx, 12), new Coord(bx, -12));

            if (Part != null)
            {
                Sym.DrawText(Part, new Coord(8, 20), Alignment.Far, Alignment.Near);
            }
            Sym.DrawText(Name, new Point(8, -20), Alignment.Far, Alignment.Far);

            Sym.AddCircle(EdgeType.Black, new Coord(0, 0), 20);
        }
Esempio n. 2
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            int h = 20;

            Sym.AddTerminal(pa, new Coord(-10, h));
            Sym.AddTerminal(pc, new Coord(-10, -h));
            Sym.AddTerminal(sa, new Coord(10, h));
            Sym.AddTerminal(st, new Coord(10, 0));
            Sym.AddTerminal(sc, new Coord(10, -h));

            Sym.DrawText(() => Name, new Coord(-16, -h / 2), Alignment.Far, Alignment.Center);
            Sym.DrawText(() => Turns.ToString(), new Coord(-16, h / 2), Alignment.Far, Alignment.Center);

            h -= 4;

            Sym.AddWire(pa, new Coord(-10, h));
            Sym.AddWire(pc, new Coord(-10, -h));
            Sym.AddWire(sa, new Coord(10, h));
            Sym.AddWire(sc, new Coord(10, -h));
            Sym.InBounds(new Coord(-20, 0), new Coord(20, 0));

            Inductor.Draw(Sym, -10, -h, h, 4, 4.0);
            Sym.DrawLine(EdgeType.Black, new Coord(-2, h), new Coord(-2, -h));
            Sym.DrawLine(EdgeType.Black, new Coord(2, h), new Coord(2, -h));
            Inductor.Draw(Sym, 10, -h, 0.0, 2, -4.0);
            Inductor.Draw(Sym, 10, h, 0.0, 2, -4.0);
        }
        public static void LayoutSymbol(SymbolLayout Sym, JfetType Type, Terminal S, Terminal G, Terminal D, Func <string> Name, Func <string> Part)
        {
            int bx = 0;

            Sym.AddTerminal(S, new Coord(10, -20), new Coord(10, -10), new Coord(0, -10));
            Sym.AddTerminal(G, new Coord(-20, 0), new Coord(-10, 0));
            Sym.AddTerminal(D, new Coord(10, 20), new Coord(10, 10), new Coord(0, 10));

            Sym.DrawLine(EdgeType.Black, new Coord(bx, 12), new Coord(bx, -12));
            switch (Type)
            {
            case JfetType.N: Sym.DrawArrow(EdgeType.Black, new Coord(-10, 0), new Coord(0, 0), 0.2, 0.3); break;

            case JfetType.P: Sym.DrawArrow(EdgeType.Black, new Coord(0, 0), new Coord(-10, 0), 0.2, 0.3); break;

            default:
                throw new NotSupportedException("Unknown JFET type.");
            }

            if (Part != null)
            {
                Sym.DrawText(Part, new Coord(8, 20), Alignment.Far, Alignment.Near);
            }
            Sym.DrawText(Name, new Point(8, -20), Alignment.Far, Alignment.Far);

            Sym.AddCircle(EdgeType.Black, new Coord(0, 0), 20);
        }
Esempio n. 4
0
 public override void LayoutSymbol(SymbolLayout Sym)
 {
     Sym.DrawLine(EdgeType.Gray, new Point(-20, -10), new Point(20, -10));
     Sym.DrawLine(EdgeType.Gray, new Point(-20, -10), new Point(-20, 10));
     Sym.InBounds(new Coord(-20, -10), new Coord(20, 10));
     Sym.DrawText(() => text, new Point(-18, 0), Alignment.Near, Alignment.Center, Size.Large);
     Sym.DrawText(() => subtext, new Point(-18, -10), Alignment.Near, Alignment.Far, Size.Normal);
 }
Esempio n. 5
0
 public override void LayoutSymbol(SymbolLayout Sym)
 {
     Sym.DrawLine(EdgeType.Gray, new Point(-20, -10), new Point(20, -10));
     Sym.DrawLine(EdgeType.Gray, new Point(-20, -10), new Point(-20, 10));
     Sym.InBounds(new Coord(-20, -10), new Coord(20, 10));
     Sym.DrawText(() => text, new Point(-18, 0), Alignment.Near, Alignment.Center, Size.Large);
     Sym.DrawText(() => subtext, new Point(-18, -10), Alignment.Near, Alignment.Far, Size.Normal);
 }
Esempio n. 6
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

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

            Sym.AddLine(EdgeType.Black, new Coord(-10, 2), new Coord(10, 2));
            Sym.AddLine(EdgeType.Black, new Coord(-10, -2), new Coord(10, -2));

            Sym.DrawText(() => Name, new Coord(12, 0), Alignment.Near, Alignment.Center);
            Sym.DrawText(() => capacitance.ToString(), new Coord(-12, 0), Alignment.Far, Alignment.Center);
        }
Esempio n. 7
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            Sym.AddWire(Anode, new Coord(0, 16));
            Sym.AddWire(Cathode, new Coord(0, -16));
            Sym.InBounds(new Coord(-10, 0), new Coord(10, 0));

            Draw(Sym, 0.0, -16.0, 16.0, 4);

            Sym.DrawText(() => Name, new Coord(6, 0), Alignment.Near, Alignment.Center);
            Sym.DrawText(() => inductance.ToString(), new Coord(-6, 0), Alignment.Far, Alignment.Center);
        }
Esempio n. 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.DrawArrow(EdgeType.Black, new Coord(0, -7), new Coord(0, 7), 0.2f);

            Sym.DrawText(() => Current.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);
        }
Esempio n. 9
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.DrawArrow(EdgeType.Black, new Coord(0, -7), new Coord(0, 7), 0.2f);

            Sym.DrawText(() => Current.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);
        }
Esempio n. 10
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            Sym.AddWire(Anode, new Coord(0, 16));
            Sym.AddWire(Cathode, new Coord(0, -16));
            Sym.InBounds(new Coord(-10, 0), new Coord(10, 0));

            Resistor.Draw(Sym, 0, -16, 16, 7);

            Sym.DrawArrow(EdgeType.Black, new Coord(-6, -15), new Coord(6, 15), 0.1);

            Sym.DrawText(() => Resistance.ToString(), new Coord(-7, 0), Alignment.Far, Alignment.Center);
            Sym.DrawText(() => Wipe.ToString("G3"), new Coord(9, 3), Alignment.Near, Alignment.Near);
            Sym.DrawText(() => Name, new Coord(9, -3), Alignment.Near, Alignment.Far);
        }
Esempio n. 11
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            Sym.InBounds(new Coord(-20, 10), new Coord(20, 0));
            Sym.AddLine(EdgeType.Black, new Coord(-15, 0), new Coord(15, 0));
            Sym.DrawText(() => Voltage.ToString(), new Point(0, 2), Alignment.Center, Alignment.Near);
        }
Esempio n. 12
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            Sym.InBounds(new Coord(-20, 10), new Coord(20, 0));
            Sym.AddLine(EdgeType.Black, new Coord(-15, 0), new Coord(15, 0));
            Sym.DrawText(() => Voltage.ToString(), new Point(0, 2), Alignment.Center, Alignment.Near);
        }
Esempio n. 13
0
        public static void LayoutSymbol(SymbolLayout Sym, Terminal P, Terminal G, Terminal K, Func<string> Name, Func<string> Part)
        {
            Sym.AddTerminal(P, new Coord(0, 20), new Coord(0, 4));
            Sym.AddWire(new Coord(-10, 4), new Coord(10, 4));

            Sym.AddTerminal(G, new Coord(-20, 0), new Coord(-12, 0));
            for (int i = -8; i < 16; i += 8)
                Sym.AddWire(new Coord(i, 0), new Coord(i + 4, 0));

            Sym.AddTerminal(K, new Coord(-10, -20), new Coord(-10, -6), new Coord(-8, -4), new Coord(8, -4), new Coord(10, -6));

            Sym.AddCircle(EdgeType.Black, new Coord(0, 0), 20);

            if (Part != null)
                Sym.DrawText(Part, new Coord(-2, 20), Alignment.Far, Alignment.Near);
            Sym.DrawText(Name, new Point(-8, -20), Alignment.Near, Alignment.Far);
        }
Esempio n. 14
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            Sym.InBounds(new Coord(-10, -10), new Coord(10, 10));

            Sym.AddRectangle(EdgeType.Black, new Coord(-5, -5), new Coord(5, 5));
            Sym.DrawText(() => Name, new Coord(0, 7), Alignment.Center, Alignment.Near);
        }
Esempio n. 15
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            Sym.InBounds(new Coord(-10, -10), new Coord(10, 10));

            Sym.AddRectangle(EdgeType.Black, new Coord(-5, -5), new Coord(5, 5));
            Sym.DrawText(() => Name, new Coord(0, 7), Alignment.Center, Alignment.Near);
        }
Esempio n. 16
0
        public override sealed void LayoutSymbol(SymbolLayout Sym)
        {
            Sym.InBounds(new Coord(-20, -20), new Coord(10, 20));

            Sym.AddTerminal(Anode, new Coord(-10, 20), new Coord(-10, 16));
            Sym.DrawPositive(EdgeType.Black, new Coord(-16, 16));

            Sym.AddTerminal(Cathode, new Coord(-10, -20), new Coord(-10, -16));
            Sym.DrawNegative(EdgeType.Black, new Coord(-16, -16));

            Sym.AddTerminal(Wiper, new Coord(10, 0));
            Sym.DrawArrow(EdgeType.Black, new Coord(10, 0), new Coord(-6, 0), 0.2);

            Resistor.Draw(Sym, -10, -16, 16, 7);

            Sym.DrawText(() => Resistance.ToString(), new Coord(-17, 0), Alignment.Far, Alignment.Center);
            Sym.DrawText(() => Wipe.ToString("G3"), new Coord(-4, 4), Alignment.Near, Alignment.Near);
            Sym.DrawText(() => Name, new Coord(-4, -4), Alignment.Near, Alignment.Far);
        }
Esempio n. 17
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);
            }
        }
Esempio n. 18
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

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

            Sym.DrawArrow(EdgeType.Black, new Coord(0, -7), new Coord(0, 7), 0.2f);

            Sym.DrawText(() => Name, new Point(5, 0), Alignment.Near, Alignment.Center);
        }
Esempio n. 19
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

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

            Sym.DrawArrow(EdgeType.Black, new Coord(0, -7), new Coord(0, 7), 0.2f);

            Sym.DrawText(() => Name, new Point(5, 0), Alignment.Near, Alignment.Center);
        }
Esempio n. 20
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            Sym.InBounds(new Coord(-10, -20), new Coord(10, 20));

            Sym.DrawPositive(EdgeType.Black, new Coord(0, 15));
            Sym.DrawNegative(EdgeType.Black, new Coord(0, -15));

            Sym.DrawText(() => Name.ToString(), new Point(0, 0), Alignment.Center, Alignment.Center);
        }
Esempio n. 21
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            Sym.InBounds(new Coord(-10, -20), new Coord(10, 20));

            Sym.DrawPositive(EdgeType.Black, new Coord(0, 15));
            Sym.DrawNegative(EdgeType.Black, new Coord(0, -15));

            Sym.DrawText(() => Name.ToString(), new Point(0, 0), Alignment.Center, Alignment.Center);
        }
Esempio n. 22
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            Sym.InBounds(new Coord(-10, 0), new Coord(10, 0));

            Sym.AddWire(Terminal, new Coord(0, -15));
            Sym.AddWire(new Coord(0, -19), new Coord(0, -22));
            Sym.AddWire(new Coord(0, -27), new Coord(0, -30));

            Sym.DrawText(() => WireName, new Coord(2, -15), Alignment.Near, Alignment.Center);
        }
Esempio n. 23
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            int w = 10;
            Sym.AddLine(EdgeType.Black, new Coord(-w, 20), new Coord(w, 20));
            Sym.DrawPositive(EdgeType.Black, new Coord(0, 15));
            Sym.AddLine(EdgeType.Black, new Coord(-w, -20), new Coord(w, -20));
            Sym.DrawNegative(EdgeType.Black, new Coord(0, -15));

            Sym.DrawText(() => Name, new Point(0, 0), Alignment.Center, Alignment.Center);
        }
Esempio n. 24
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            Sym.AddTerminal(common, new Coord(0, -20), new Coord(0, -12));
            Sym.AddCircle(EdgeType.Black, new Coord(0, -12), 2);

            for (int i = 0; i < Throws.Length; ++i)
            {
                int x = (i - Throws.Length / 2) * 20 + (Throws.Length % 2 == 0 ? 10 : 0);
                Sym.AddTerminal(throws[i], new Coord(x, 20), new Coord(x, 12));
                Sym.DrawEllipse(EdgeType.Black, new Coord(x - 2, 10), new Coord(x + 2, 14));
                //Sym.DrawText(i.ToString(), new Coord(x, 12), Alignment.Near, Alignment.Near);

                if (i == Position)
                {
                    Sym.AddWire(new Coord(0, -12), new Coord(x, 12));
                }
            }

            Sym.DrawText(() => Group, new Coord(-2, -12), Alignment.Far, Alignment.Far);
            Sym.DrawText(() => Name, new Coord(2, -12), Alignment.Near, Alignment.Far);
        }
Esempio n. 25
0
        public static void LayoutSymbol(SymbolLayout Sym, Terminal P, Terminal G, Terminal K, Func <string> Name, Func <string> Part)
        {
            Sym.AddTerminal(P, new Coord(0, 20), new Coord(0, 4));
            Sym.AddWire(new Coord(-10, 4), new Coord(10, 4));

            Sym.AddTerminal(G, new Coord(-20, 0), new Coord(-12, 0));
            for (int i = -8; i < 16; i += 8)
            {
                Sym.AddWire(new Coord(i, 0), new Coord(i + 4, 0));
            }

            Sym.AddTerminal(K, new Coord(-10, -20), new Coord(-10, -6), new Coord(-8, -4), new Coord(8, -4), new Coord(10, -6));

            Sym.AddCircle(EdgeType.Black, new Coord(0, 0), 20);

            if (Part != null)
            {
                Sym.DrawText(Part, new Coord(-2, 20), Alignment.Far, Alignment.Near);
            }
            Sym.DrawText(Name, new Point(-8, -20), Alignment.Near, Alignment.Far);
        }
Esempio n. 26
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            Sym.AddTerminal(pa, new Coord(-10, 20));
            Sym.AddTerminal(pc, new Coord(-10, -20));
            Sym.AddTerminal(sa, new Coord(10, 20));
            Sym.AddTerminal(sc, new Coord(10, -20));

            Sym.AddWire(pa, new Coord(-10, 16));
            Sym.AddWire(pc, new Coord(-10, -16));
            Sym.AddWire(sa, new Coord(10, 16));
            Sym.AddWire(sc, new Coord(10, -16));
            Sym.InBounds(new Coord(-20, 0), new Coord(20, 0));

            Inductor.Draw(Sym, -10, -16.0, 16.0, 4, 4.0);
            Sym.DrawLine(EdgeType.Black, new Coord(-2, 16), new Coord(-2, -16));
            Sym.DrawLine(EdgeType.Black, new Coord(2, 16), new Coord(2, -16));
            Inductor.Draw(Sym, 10, -16.0, 16.0, 4, -4.0);

            Sym.DrawText(() => Name, new Coord(-16, 0), Alignment.Far, Alignment.Center);
            Sym.DrawText(() => Turns.ToString(), new Coord(16, 0), Alignment.Near, Alignment.Center);
        }
Esempio n. 27
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            Sym.InBounds(new Coord(-10, 0), new Coord(10, 0));

            Sym.AddWire(Terminal, new Coord(0, -15));
            Sym.AddWire(new Coord(0, -19), new Coord(0, -22));
            Sym.AddWire(new Coord(0, -27), new Coord(0, -30));

            Sym.DrawText(() => WireName, new Coord(2, -15), Alignment.Near, Alignment.Center);
        }
Esempio n. 28
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            int w = 10;

            Sym.AddLine(EdgeType.Black, new Coord(-w, 20), new Coord(w, 20));
            Sym.DrawPositive(EdgeType.Black, new Coord(0, 15));
            Sym.AddLine(EdgeType.Black, new Coord(-w, -20), new Coord(w, -20));
            Sym.DrawNegative(EdgeType.Black, new Coord(0, -15));

            Sym.DrawText(() => Name, new Point(0, 0), Alignment.Center, Alignment.Center);
        }
Esempio n. 29
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

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

            Sym.AddLoop(EdgeType.Black,
                new Coord(-10, 10),
                new Coord(10, 10),
                new Coord(0, -10));

            Sym.DrawText(() => Name, new Coord(10, 0), Alignment.Near, Alignment.Center);
        }
Esempio n. 30
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

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

            Sym.AddLoop(EdgeType.Black,
                        new Coord(-10, 10),
                        new Coord(10, 10),
                        new Coord(0, -10));

            Sym.DrawText(() => Name, new Coord(10, 0), Alignment.Near, Alignment.Center);
        }
Esempio n. 31
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);
        }
Esempio n. 32
0
        public static void LayoutSymbol(SymbolLayout Sym, Terminal A, Terminal C, DiodeType Type, Func <string> Name, Func <string> Part)
        {
            Sym.AddTerminal(A, new Coord(0, 20));
            Sym.AddWire(A, new Coord(0, 10));

            Sym.AddTerminal(C, new Coord(0, -20));
            Sym.AddWire(C, new Coord(0, -10));

            Sym.AddLoop(EdgeType.Black,
                        new Coord(-10, 10),
                        new Coord(10, 10),
                        new Coord(0, -10));
            Sym.AddLine(EdgeType.Black, new Coord(-10, -10), new Coord(10, -10));

            switch (Type)
            {
            case DiodeType.LED:
                Sym.DrawArrow(EdgeType.Black, new Coord(-12, 5), new Coord(-20, -3), 0.2);
                Sym.DrawArrow(EdgeType.Black, new Coord(-8, -2), new Coord(-16, -10), 0.2);
                break;

            case DiodeType.Zener:
                Sym.AddLine(EdgeType.Black, new Coord(-10, -10), new Coord(-10, -5));
                Sym.AddLine(EdgeType.Black, new Coord(10, -10), new Coord(10, -15));
                break;

            default:
                break;
            }

            if (Part != null)
            {
                Sym.DrawText(Part, new Coord(12, 4), Alignment.Near, Alignment.Near);
            }
            Sym.DrawText(Name, new Coord(12, -4), Alignment.Near, Alignment.Far);
        }
Esempio n. 33
0
        public static void LayoutSymbol(SymbolLayout Sym, Terminal p, Terminal n, Terminal o, Terminal vp, Terminal vn, Func <string> Name, Func <string> Part)
        {
            IdealOpAmp.LayoutSymbol(Sym, p, n, o, Name);

            Sym.AddTerminal(vn, new Coord(0, -20), new Coord(0, -10));
            Sym.DrawNegative(EdgeType.Black, new Coord(5, -13));

            Sym.AddTerminal(vp, new Coord(0, 20), new Coord(0, 10));
            Sym.DrawPositive(EdgeType.Black, new Coord(5, 13));

            if (Part != null)
            {
                Sym.DrawText(Part, new Coord(12, 4), Alignment.Near, Alignment.Near);
            }
        }
Esempio n. 34
0
        public static void LayoutSymbol(SymbolLayout Sym, Terminal p, Terminal n, Terminal o, Func <string> Name)
        {
            Sym.AddTerminal(p, new Coord(-20, -10));
            Sym.DrawPositive(EdgeType.Black, new Coord(-15, -10));

            Sym.AddTerminal(n, new Coord(-20, 10));
            Sym.DrawNegative(EdgeType.Black, new Coord(-15, 10));

            Sym.AddTerminal(o, new Coord(20, 0));
            Sym.AddWire(o, new Coord(20, 0));

            Sym.AddLoop(EdgeType.Black,
                        new Coord(-20, 20),
                        new Coord(-20, -20),
                        new Coord(20, 0));

            Sym.DrawText(Name, new Coord(12, -4), Alignment.Near, Alignment.Far);
        }
Esempio n. 35
0
        public static void LayoutSymbol(SymbolLayout Sym, Terminal p, Terminal n, Terminal o, Func<string> Name)
        {
            Sym.AddTerminal(p, new Coord(-20, -10));
            Sym.DrawPositive(EdgeType.Black, new Coord(-15, -10));

            Sym.AddTerminal(n, new Coord(-20, 10));
            Sym.DrawNegative(EdgeType.Black, new Coord(-15, 10));

            Sym.AddTerminal(o, new Coord(20, 0));
            Sym.AddWire(o, new Coord(20, 0));

            Sym.AddLoop(EdgeType.Black,
                new Coord(-20, 20),
                new Coord(-20, -20),
                new Coord(20, 0));

            Sym.DrawText(Name, new Coord(12, -4), Alignment.Near, Alignment.Far);
        }
Esempio n. 36
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            Sym.AddWire(Anode, new Coord(0, 12));
            Sym.AddWire(Cathode, new Coord(0, -12));
            Sym.AddCircle(EdgeType.Black, new Coord(0, 12), 2);
            Sym.AddCircle(EdgeType.Black, new Coord(0, -12), 2);
            Sym.InBounds(new Coord(-10, 0), new Coord(10, 0));

            if (closed)
            {
                Sym.AddWire(new Coord(0, -12), new Coord(0, 12));
            }
            else
            {
                Sym.AddWire(new Coord(0, -12), new Coord(-8, 10));
            }

            Sym.DrawText(() => Name, new Coord(2, 0), Alignment.Near, Alignment.Center);
        }
Esempio n. 37
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);
        }
Esempio n. 38
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            int h = 20;

            Sym.AddTerminal(pa, new Coord(-10, h));
            Sym.AddTerminal(pc, new Coord(-10, -h));
            Sym.AddTerminal(sa, new Coord(10, h));
            Sym.AddTerminal(st, new Coord(10, 0));
            Sym.AddTerminal(sc, new Coord(10, -h));

            Sym.DrawText(() => Name, new Coord(-16, -h / 2), Alignment.Far, Alignment.Center);
            Sym.DrawText(() => Turns.ToString(), new Coord(-16, h / 2), Alignment.Far, Alignment.Center);

            h -= 4;

            Sym.AddWire(pa, new Coord(-10, h));
            Sym.AddWire(pc, new Coord(-10, -h));
            Sym.AddWire(sa, new Coord(10, h));
            Sym.AddWire(sc, new Coord(10, -h));
            Sym.InBounds(new Coord(-20, 0), new Coord(20, 0));

            Inductor.Draw(Sym, -10, -h, h, 4, 4.0);
            Sym.DrawLine(EdgeType.Black, new Coord(-2, h), new Coord(-2, -h));
            Sym.DrawLine(EdgeType.Black, new Coord(2, h), new Coord(2, -h));
            Inductor.Draw(Sym, 10, -h, 0.0, 2, -4.0);
            Inductor.Draw(Sym, 10, h, 0.0, 2, -4.0);
        }
Esempio n. 39
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            Sym.AddTerminal(common, new Coord(0, -20), new Coord(0, -12));
            Sym.AddCircle(EdgeType.Black, new Coord(0, -12), 2);

            for (int i = 0; i < Throws.Length; ++i)
            {
                int x = (i - Throws.Length / 2) * 20 + (Throws.Length % 2 == 0 ? 10 : 0);
                Sym.AddTerminal(throws[i], new Coord(x, 20), new Coord(x, 12));
                Sym.DrawEllipse(EdgeType.Black, new Coord(x - 2, 10), new Coord(x + 2, 14));
                //Sym.DrawText(i.ToString(), new Coord(x, 12), Alignment.Near, Alignment.Near);

                if (i == Position)
                    Sym.AddWire(new Coord(0, -12), new Coord(x, 12));
            }

            Sym.DrawText(() => Group, new Coord(-2, -12), Alignment.Far, Alignment.Far);
            Sym.DrawText(() => Name, new Coord(2, -12), Alignment.Near, Alignment.Far);
        }
Esempio n. 40
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            Sym.AddWire(Anode, new Coord(0, 12));
            Sym.AddWire(Cathode, new Coord(0, -12));
            Sym.AddCircle(EdgeType.Black, new Coord(0, 12), 2);
            Sym.AddCircle(EdgeType.Black, new Coord(0, -12), 2);
            Sym.InBounds(new Coord(-10, 0), new Coord(10, 0));

            if (closed)
                Sym.AddWire(new Coord(0, -12), new Coord(0, 12));
            else
                Sym.AddWire(new Coord(0, -12), new Coord(-8, 10));

            Sym.DrawText(() => Name, new Coord(2, 0), Alignment.Near, Alignment.Center);
        }
Esempio n. 41
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            Coord w = new Coord(0, 0);
            Sym.AddTerminal(Terminal, w);

            Coord dw = new Coord(1, 1);
            Coord pw = new Coord(dw.y, -dw.x);

            w += dw * 10;
            Sym.AddWire(Terminal, w);

            Sym.AddLine(color, w - pw * 4, w + pw * 4);
            Sym.AddLoop(color,
                w + pw * 2,
                w + pw * 2 + dw * 10,
                w + dw * 12,
                w - pw * 2 + dw * 10,
                w - pw * 2);

            if (ConnectedTo != null)
                Sym.DrawText(() => V.ToString(), new Point(0, 6), Alignment.Far, Alignment.Near);
        }
Esempio n. 42
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);
            }
        }
Esempio n. 43
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            Sym.AddTerminal(pa, new Coord(-10, 20));
            Sym.AddTerminal(pc, new Coord(-10, -20));
            Sym.AddTerminal(sa, new Coord(10, 20));
            Sym.AddTerminal(sc, new Coord(10, -20));

            Sym.AddWire(pa, new Coord(-10, 16));
            Sym.AddWire(pc, new Coord(-10, -16));
            Sym.AddWire(sa, new Coord(10, 16));
            Sym.AddWire(sc, new Coord(10, -16));
            Sym.InBounds(new Coord(-20, 0), new Coord(20, 0));

            Inductor.Draw(Sym, -10, -16.0, 16.0, 4, 4.0);
            Sym.DrawLine(EdgeType.Black, new Coord(-2, 16), new Coord(-2, -16));
            Sym.DrawLine(EdgeType.Black, new Coord(2, 16), new Coord(2, -16));
            Inductor.Draw(Sym, 10, -16.0, 16.0, 4, -4.0);

            Sym.DrawText(() => Name, new Coord(-16, 0), Alignment.Far, Alignment.Center);
            Sym.DrawText(() => Turns.ToString(), new Coord(16, 0), Alignment.Near, Alignment.Center);
        }
Esempio n. 44
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            Sym.AddWire(Anode, new Coord(0, 16));
            Sym.AddWire(Cathode, new Coord(0, -16));
            Sym.InBounds(new Coord(-10, 0), new Coord(10, 0));

            Draw(Sym, 0, -16, 16, 7);

            Sym.DrawText(() => Name, new Coord(6, 0), Alignment.Near, Alignment.Center);
            Sym.DrawText(() => resistance.ToString(), new Coord(-6, 0), Alignment.Far, Alignment.Center);
        }
Esempio n. 45
0
        public override sealed void LayoutSymbol(SymbolLayout Sym)
        {
            Sym.InBounds(new Coord(-20, -20), new Coord(10, 20));

            Sym.AddTerminal(Anode, new Coord(-10, 20), new Coord(-10, 16));
            Sym.DrawPositive(EdgeType.Black, new Coord(-16, 16));

            Sym.AddTerminal(Cathode, new Coord(-10, -20), new Coord(-10, -16));
            Sym.DrawNegative(EdgeType.Black, new Coord(-16, -16));

            Sym.AddTerminal(Wiper, new Coord(10, 0));
            Sym.DrawArrow(EdgeType.Black, new Coord(10, 0), new Coord(-6, 0), 0.2);

            Resistor.Draw(Sym, -10, -16, 16, 7);

            Sym.DrawText(() => Resistance.ToString(), new Coord(-17, 0), Alignment.Far, Alignment.Center);
            Sym.DrawText(() => Wipe.ToString("G3"), new Coord(-4, 4), Alignment.Near, Alignment.Near);
            Sym.DrawText(() => Name, new Coord(-4, -4), Alignment.Near, Alignment.Far);
        }
Esempio n. 46
0
        public static void LayoutSymbol(SymbolLayout Sym, Terminal A, Terminal C, DiodeType Type, Func<string> Name, Func<string> Part)
        {
            Sym.AddTerminal(A, new Coord(0, 20));
            Sym.AddWire(A, new Coord(0, 10));

            Sym.AddTerminal(C, new Coord(0, -20));
            Sym.AddWire(C, new Coord(0, -10));

            Sym.AddLoop(EdgeType.Black,
                new Coord(-10, 10),
                new Coord(10, 10),
                new Coord(0, -10));
            Sym.AddLine(EdgeType.Black, new Coord(-10, -10), new Coord(10, -10));

            switch (Type)
            {
                case DiodeType.LED:
                    Sym.DrawArrow(EdgeType.Black, new Coord(-12, 5), new Coord(-20, -3), 0.2);
                    Sym.DrawArrow(EdgeType.Black, new Coord(-8, -2), new Coord(-16, -10), 0.2);
                    break;
                case DiodeType.Zener:
                    Sym.AddLine(EdgeType.Black, new Coord(-10, -10), new Coord(-10, -5));
                    Sym.AddLine(EdgeType.Black, new Coord(10, -10), new Coord(10, -15));
                    break;
                default:
                    break;
            }

            if (Part != null)
                Sym.DrawText(Part, new Coord(12, 4), Alignment.Near, Alignment.Near);
            Sym.DrawText(Name, new Coord(12, -4), Alignment.Near, Alignment.Far);
        }
        public static void LayoutSymbol(SymbolLayout Sym, JfetType Type, Terminal S, Terminal G, Terminal D, Func<string> Name, Func<string> Part)
        {
            int bx = 0;
            Sym.AddTerminal(S, new Coord(10, -20), new Coord(10, -10), new Coord(0, -10));
            Sym.AddTerminal(G, new Coord(-20, 0), new Coord(-10, 0));
            Sym.AddTerminal(D, new Coord(10, 20), new Coord(10, 10), new Coord(0, 10));

            Sym.DrawLine(EdgeType.Black, new Coord(bx, 12), new Coord(bx, -12));
            switch (Type)
            {
                case JfetType.N: Sym.DrawArrow(EdgeType.Black, new Coord(-10, 0), new Coord(0, 0), 0.2, 0.3); break;
                case JfetType.P: Sym.DrawArrow(EdgeType.Black, new Coord(0, 0), new Coord(-10, 0), 0.2, 0.3); break;
                default:
                    throw new NotSupportedException("Unknown JFET type.");
            }

            if (Part != null)
                Sym.DrawText(Part, new Coord(8, 20), Alignment.Far, Alignment.Near);
            Sym.DrawText(Name, new Point(8, -20), Alignment.Far, Alignment.Far);

            Sym.AddCircle(EdgeType.Black, new Coord(0, 0), 20);
        }
Esempio n. 48
0
        public override void LayoutSymbol(SymbolLayout Sym)
        {
            base.LayoutSymbol(Sym);

            Sym.AddWire(Anode, new Coord(0, 16));
            Sym.AddWire(Cathode, new Coord(0, -16));
            Sym.InBounds(new Coord(-10, 0), new Coord(10, 0));

            Resistor.Draw(Sym, 0, -16, 16, 7);

            Sym.DrawArrow(EdgeType.Black, new Coord(-6, -15), new Coord(6, 15), 0.1);

            Sym.DrawText(() => Resistance.ToString(), new Coord(-7, 0), Alignment.Far, Alignment.Center);
            Sym.DrawText(() => Wipe.ToString("G3"), new Coord(9, 3), Alignment.Near, Alignment.Near);
            Sym.DrawText(() => Name, new Coord(9, -3), Alignment.Near, Alignment.Far);
        }
        public static void LayoutSymbol(SymbolLayout Sym, BjtType Type, Terminal C, Terminal B, Terminal E, Func<string> Name, Func<string> Part)
        {
            int bx = -5;
            Sym.AddTerminal(B, new Coord(-20, 0), new Coord(bx, 0));
            switch (Type)
            {
                case BjtType.NPN:
                    Sym.AddTerminal(C, new Coord(10, 20), new Coord(10, 17));
                    Sym.AddTerminal(E, new Coord(10, -20), new Coord(10, -17));
                    Sym.DrawLine(EdgeType.Black, new Coord(10, 17), new Coord(bx, 8));
                    Sym.DrawArrow(EdgeType.Black, new Coord(bx, -8), new Coord(10, -17), 0.2, 0.3);
                    break;
                case BjtType.PNP:
                    Sym.AddTerminal(E, new Coord(10, 20), new Coord(10, 17));
                    Sym.AddTerminal(C, new Coord(10, -20), new Coord(10, -17));
                    Sym.DrawArrow(EdgeType.Black, new Coord(10, 17), new Coord(bx, 8), 0.2, 0.3);
                    Sym.DrawLine(EdgeType.Black, new Coord(bx, -8), new Coord(10, -17));
                    break;
                default:
                    throw new NotSupportedException("Unknown BJT type.");
            }
            Sym.DrawLine(EdgeType.Black, new Coord(bx, 12), new Coord(bx, -12));

            if (Part != null)
                Sym.DrawText(Part, new Coord(8, 20), Alignment.Far, Alignment.Near);
            Sym.DrawText(Name, new Point(8, -20), Alignment.Far, Alignment.Far);

            Sym.AddCircle(EdgeType.Black, new Coord(0, 0), 20);
        }
Esempio n. 50
0
        public static void LayoutSymbol(SymbolLayout Sym, Terminal p, Terminal n, Terminal o, Terminal vp, Terminal vn, Func<string> Name, Func<string> Part)
        {
            IdealOpAmp.LayoutSymbol(Sym, p, n, o, Name);

            Sym.AddTerminal(vn, new Coord(0, -20), new Coord(0, -10));
            Sym.DrawNegative(EdgeType.Black, new Coord(5, -13));

            Sym.AddTerminal(vp, new Coord(0, 20), new Coord(0, 10));
            Sym.DrawPositive(EdgeType.Black, new Coord(5, 13));

            if (Part != null)
                Sym.DrawText(Part, new Coord(12, 4), Alignment.Near, Alignment.Near);
        }