summaryrefslogtreecommitdiff
path: root/graphics/circuit_macros/libcct.m4
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/circuit_macros/libcct.m4')
-rw-r--r--graphics/circuit_macros/libcct.m4209
1 files changed, 142 insertions, 67 deletions
diff --git a/graphics/circuit_macros/libcct.m4 b/graphics/circuit_macros/libcct.m4
index 0ae189ad17..81d36357c6 100644
--- a/graphics/circuit_macros/libcct.m4
+++ b/graphics/circuit_macros/libcct.m4
@@ -1,7 +1,7 @@
divert(-1)
libcct.m4
-* Circuit_macros Version 9.3, copyright (c) 2020 J. D. Aplevich under *
+* Circuit_macros Version 9.4, copyright (c) 2020 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
@@ -189,11 +189,12 @@ define(`capacitor',
line to rvec_(rp_len,0) invis ')')
`resistor( linespec, cycles, chars, cycle wid)
+ cycles: default 3
chars : E=ebox
ES=ebox with slash
Q=offset
- H=squared (default 3 cycles)
- N=IEEE (default 3 cycles)
+ H=squared
+ N=IEEE (default)
V=varistor variant
R=to right of drawing direction
arg4: cycle width, default dimen_/6'
@@ -845,56 +846,113 @@ define(`fuse',`eleminit_(`$1')
{[box invis ht_ m4ht wid_ m4wd] at rvec_(rp_len/2,0)}
line to rvec_(rp_len,0) invis ')
- `arrester( linespec, [G|E|S][D[L]], len, ht )
- G= spark gap (default)
- E= gas discharge
- S= surge
- D= double (creates 3-terminal element)
- DL= double, left orientation'
+ `arrester( linespec, [G|E|S][D[L|R]],
+ len[:arrowhead ht], ht[:arrowhead wid] )
+ arg2 chars:
+ G= spark gap (default)
+ g= general (dots)
+ E= gas discharge
+ S= box enclosure
+ C= carbon block
+ A= electrolytic cell
+ H= horn gap
+ P= protective gap
+ s= sphere gap
+ F= film element
+ M= multigap
+ modifiers:
+ R= right orientation
+ L= left orientation
+ D= 3-terminal element for S, E only with
+ terminals A, B, G'
define(`arrester',
- `define(`m4wd',ifelse(`$3',,`dimen_/2',`($3)'))dnl
- define(`m4ht',ifelse(`$4',,`dimen_/5',`($4)'))dnl
- define(`m4arm',ifinstr(`$2',L,,-))dnl
- define(`m4ardna',`patsubst(patsubst(`$2',L),D)')dnl
- define(`m4awd',arrowwid*4/3)define(`m4aht',arrowht*2/3)dnl
- define(`m4len',`ifinstr(`$2',D,`ifelse(`$1',,dimen_)',`$1')')dnl
- ifinstr(`$2',D,[)eleminit_(m4len)ifinstr(`$2',D,,`;{')dnl
- ifinstr( m4ardna,S,
- `line to rvec_(max(0,rp_len/2-m4wd/2),0)
- {lbox(m4wd,m4ht)}
- {arrow to rvec_(m4wd*0.4,0) wid m4awd ht m4aht}
- ifinstr(`$2',D,
- `A: 3rd last line.start; B: last line.end; C: 1/2 between A and B
- move to rvec_(m4wd/2,m4arm`'(-m4ht/2))
- Gb: line to rvec_(0,m4arm`'(m4ht*2))
- G: Here]',
- `line from rvec_(m4wd,0) to rvec_(max(0,rp_len/2+m4wd/2),0)}
- {[box invis ht_ m4ht wid_ m4wd] at rvec_(rp_len/2,0)}
- line to rvec_(rp_len,0) invis ') ',
- m4ardna,E,
- `arrow to rvec_(max(0,rp_len/2-m4wd/8),0) wid m4awd ht m4aht
- {dot(at rvec_(-m4aht/4,-m4wd/4),dotrad_*2/3)}
- {move to rvec_(m4wd/4,0)
- arrow <- to rvec_(max(0,rp_len/2-m4wd/8),0) wid m4awd ht m4aht }
- {circle diam m4wd at rvec_(m4wd/8,0)}
- ifinstr(`$2',D,
- `A: 2nd last arrow.start; B: last arrow.end; C: last circle.c
- move to rvec_(m4wd/8,m4arm`'(-m4ht/2))
- Gb: line to rvec_(0,m4arm`'ifelse(`$3',,`dimen_/2',`($3)'))
- G: Here]',
- `}; {[box invis ht_ m4wd wid_ m4wd] at rvec_(rp_len/2,0)}
- line to rvec_(rp_len,0) invis ')',
- `define(`m4wd',ifelse(`$3',,`dimen_/8',`($3)'))dnl
- arrow to rvec_(max(0,rp_len/2-m4wd/2),0) wid m4awd ht m4aht
- { move to rvec_(m4wd,0)
- arrow <- to rvec_(max(0,rp_len/2-m4wd/2),0) wid m4awd ht m4aht }
+ `define(`m4rdna',`patsubst(`$2',D\|L\|R)')dnl
+ ifelse(m4rdna,,`define(`m4rdna',G)')dnl
+ define(`m4rL',ifinstr(`$2',L,-))dnl
+ define(`m4rR',ifinstr(`$2',R,-))dnl
+
+ define(`m4aht',`m4Rightstr(`$3',arrowht*2/3)')dnl
+ define(`m4awd',`m4Rightstr(`$3',arrowwid*4/3)')dnl
+
+ define(`m4wd',
+ `ifinstr(m4rdna,C,`m4Leftstr(`$3',dimen_/3)',
+ m4rdna,F,`m4Leftstr(`$3',dimen_/3)',
+ m4rdna,s,`m4Leftstr(`$3',dimen_/4)',
+ m4rdna,E,`m4Leftstr(`$3',dimen_*5/8)',
+ `m4Leftstr(`$3',dimen_/2)')')dnl
+
+ define(`m4ht',
+ `ifinstr(Loopover_(`Z',`ifinstr(m4rdna,Z,T)',C,A,s),T,
+ `m4Leftstr(`$4',dimen_/4)',
+ ifinstr(m4rdna,F,T),T,`m4Leftstr(`$4',dimen_/3)',
+ `m4Leftstr(`$4',dimen_/5)')')dnl
+
ifinstr(`$2',D,
- `A: 2nd last arrow.start; B: last arrow.end; C: 1/2 between A and B
- move to rvec_(m4wd/2,m4arm`'(-m4awd))
- Gb: line to rvec_(0,m4arm`'ifelse(`$3',,`dimen_/2',`($3)'))
- G: Here]',
- `}; {[box invis ht_ m4ht wid_ m4wd+2*m4aht] at rvec_(rp_len/2,0)}
- line to rvec_(rp_len,0) invis ')')')
+ `[ define(`m4LL',m4rL)dnl
+ ifinstr(m4rdna,S,
+ `R: arrester(ifelse(`$1',,`to rvec_(dimen_,0)'),m4rdna,shift(shift($@)))
+ Gb: line from R.c+vec_(0,m4LL m4ht/2) to R.c+vec_(0,m4LL (-m4ht*3/2)) ',
+ m4rdna,E,
+ `R: arrester(ifelse(`$1',,`to rvec_(dimen_,0)'),m4rdna,shift(shift($@)))
+ Gb: line from R.c+vec_(0,m4LL m4wd/8) to R.c+vec_(0,m4LL (-m4wd*3/4)) ')
+ A: R.start; B: R.end; C: R.c; G: Here ]',
+
+ `eleminit_(`$1',elen_)
+ {line to rvec_(max(0,rp_len/2-m4wd/2),0)
+ {[ Orig: Here
+ ifinstr(m4rdna,G,
+ `{arrow to rvec_(m4aht,0) wid m4awd ht m4aht}
+ move to rvec_(m4wd,0)
+ arrow to rvec_(-m4aht,0) wid m4awd ht m4aht',
+ m4rdna,g,
+ `{dot(at rvec_(dotrad_,0))}; dot(at rvec_(m4wd-dotrad_,0))',
+ m4rdna,M,
+ `{dot(at rvec_(dotrad_,0))}
+ {dot(at rvec_(m4wd/2,0))}; dot(at rvec_(m4wd-dotrad_,0))',
+ m4rdna,C,
+ `lbox(m4wd/3,m4ht); move to rvec_(m4wd/3,0)
+ lbox(m4wd/3,m4ht)',
+ m4rdna,A,
+ `{line to rvec_(m4wd/4,0)}
+ for_(1,3,1,`line from rvec_(0,m4ht/2) to rvec_(m4wd/4,0) \
+ then to rvec_(0,-m4ht/2); move to rvec_(m4wd/4,m4ht/2)
+ ifelse(m4x,3,,move to rvec_(m4wd/8,0))') ',
+ m4rdna,H,
+ `line to rvec_(m4ht,0); round
+ {arc ifelse(m4rR,-,,c)cw from Here to rvec_(-m4ht,m4rR m4ht) \
+ with .c at rvec_(-m4ht,0)}
+ move to rvec_(m4wd-2*m4ht,0); round
+ {arc ifelse(m4rR,-,c)cw from Here to rvec_(m4ht,m4rR m4ht) \
+ with .c at rvec_(m4ht,0)}
+ line to rvec_(m4ht,0)',
+ m4rdna,P,
+ `{open_arrow(to rvec_(m4aht,0),m4awd,m4aht)}
+ move to rvec_(m4wd,0)
+ open_arrow(to rvec_(-m4aht,0),m4awd,m4aht)',
+ m4rdna,s,
+ `{line to rvec_(m4ht/2*(sqrt(2)-1),0)}
+ {arc from rvec_(0,-m4ht/2) to rvec_(0,m4ht/2) \
+ with .c at rvec_(-m4ht/2,0)}
+ move to rvec_(m4wd,0)
+ {arc from rvec_(0,m4ht/2) to rvec_(0,-m4ht/2) \
+ with .c at rvec_(m4ht/2,0)}
+ {line to rvec_(-m4ht/2*(sqrt(2)-1),0)}',
+ m4rdna,F,
+ `{line from rvec_(0,m4ht/2) to rvec_(0,-m4ht/2)}
+ {line from rvec_(m4wd/2,m4ht/2) to rvec_(m4wd/2,-m4ht/2)}
+ line from rvec_(m4wd,m4ht/2) to rvec_(m4wd,-m4ht/2)',
+ m4rdna,S,
+ `{lbox(m4wd,m4ht)}
+ arrow to rvec_(m4wd/2,0) wid m4awd ht m4aht',
+ m4rdna,E,
+ `{circle diam m4wd at rvec_(m4wd/2,0)}
+ {arrow to rvec_(m4wd*3/8,0) wid m4awd ht m4aht}
+ {arrow <- from rvec_(m4wd*5/8,0) to rvec_(m4wd,0) wid m4awd ht m4aht}
+ dot(at rvec_(m4wd*6/8,m4wd/4),dotrad_*2/3) ')
+ ] with .Orig at Here }
+ line from rvec_(m4wd,0) to rvec_(max(0,rp_len/2+m4wd/2),0) }
+ line invis to rvec_(rp_len,0)')
+ ')
`memristor( linespec, wid, ht )'
define(`memristor',`eleminit_(`$1')
@@ -1038,7 +1096,7 @@ define(`arrowline',`line ifelse(`$1',,`to rvec_(elen_,0)',`$1')
chop lin_leng(last line)/2-arrowht/2
[box invis ht_ arrowwid wid_ arrowht] at last line.c }')
- `ground( at position, T, N|F|S|L|P[A]|E,
+ `ground( at position, T|stem length, N|F|S|L|P[A]|E,
D|U|L|R|degrees)
T=truncated stem; N=normal ground,
F=frame, S=signal, L=low-noise, P=protective,
@@ -1047,7 +1105,8 @@ define(`arrowline',`line ifelse(`$1',,`to rvec_(elen_,0)',`$1')
define(`ground',`box invis ht 0 wid 0 with .c ifelse(`$1',,`at Here',`$1')
define(`m4v',`dimen_/6')define(`m4h',`dimen_/16')dnl
{setdir_(ifelse(`$4',,-90,`$4'))
- ifelse(`$2',,`line from last box.c to rvec_(dimen_/4,0)')
+ ifelse(`$2',,`line from last box.c to rvec_(dimen_/4,0)',
+ `$2',T,,`line from last box.c to rvec_(`$2',0)')
ifelse(`$3',F,
`{line from rvec_(dimen_/8,m4v-dimen_/12) \
to rvec_(0,m4v) \
@@ -1089,7 +1148,8 @@ define(`ground',`box invis ht 0 wid 0 with .c ifelse(`$1',,`at Here',`$1')
to rvec_(2*m4h,-dimen_/14)')
resetdir_} ')
- `antenna(at position, T, A|L|T|S|D|P|F, U|D|L|R|degrees)
+ `antenna(at position, T|stem length, A|L|T|S|D|P|F,
+ U|D|L|R|degrees)
arg2=T: truncate stem
arg3= A=aerial; L=loop, T=triangle, S=diamond,
D=dipole, P=phased, F=fork;
@@ -1101,7 +1161,7 @@ define(`antenna',`[ T: Here
ifelse(
m4atype,L,
`T1: rvec_(0,m4h); T2: rvec_(0,-m4h)
- ifelse(`$2',,`move to rvec_(m4h*2,0)')
+ ifelse(`$2',,`move to rvec_(m4h*2,0)', `$2',T,,`move to rvec_(`$2',0)')
line from T1 to rvec_(0,m4h) \
then to rvec_(0,m4v/2) \
then to rvec_(m4v-m4h,m4v/2) \
@@ -1114,7 +1174,7 @@ define(`antenna',`[ T: Here
then to rvec_(0,-m4h) \
then to T2',
m4atype,T,
- `ifelse(`$2',,`move to rvec_(m4h*2,0)')
+ `ifelse(`$2',,`move to rvec_(m4h*2,0)', `$2',T,,`move to rvec_(`$2',0)')
line to rvec_(m4v*3/4,m4v*sqrt(3)/4) \
then to rvec_(m4v*3/4,-m4v*sqrt(3)/4) \
then to Here
@@ -1122,7 +1182,7 @@ define(`antenna',`[ T: Here
to T',
m4atype,S,
`T1: rvec_(0,m4h); T2: rvec_(0,-m4h)
- ifelse(`$2',,`move to rvec_(m4h*2,0)')
+ ifelse(`$2',,`move to rvec_(m4h*2,0)', `$2',T,,`move to rvec_(`$2',0)')
line from T1 to rvec_(0,m4h) \
then to rvec_(m4v*3/4-m4h,m4v*3/4) \
then to rvec_(2*m4v*3/4-m4h,0) \
@@ -1131,20 +1191,20 @@ define(`antenna',`[ T: Here
then to T2',
m4atype,D,
`T1: rvec_(0,m4h); T2: rvec_(0,-m4h)
- ifelse(`$2',,`move to rvec_(m4v,0)')
+ ifelse(`$2',,`move to rvec_(m4v,0)', `$2',T,,`move to rvec_(`$2',0)')
{ line from T1 to rvec_(0,m4h) \
then to rvec_(0,m4h*3) }
{ line from T2 to rvec_(0,-m4h) \
then to rvec_(0,-m4h*3) }',
m4atype,P,
- `ifelse(`$2',,`move to rvec_(m4v*2/3,0)')
+ `ifelse(`$2',,`move to rvec_(m4h*2/3,0)', `$2',T,,`move to rvec_(`$2',0)')
line from T to Here
{ line from rvec_(0,-m4v/3) \
to rvec_(0,m4v/3) }
{ line from rvec_(m4h,-m4v*2/3) \
to rvec_(m4h,m4v*2/3) }',
m4atype,F,
- `ifelse(`$2',,`move to rvec_(m4h*2,0)')
+ `ifelse(`$2',,`move to rvec_(m4h*2,0)', `$2',T,,`move to rvec_(`$2',0)')
{ line from rvec_(m4v*3/4,m4v*sqrt(3)/4) \
to rvec_(0,m4v*sqrt(3)/4) \
then to rvec_(0,-m4v*sqrt(3)/4) \
@@ -1152,12 +1212,12 @@ define(`antenna',`[ T: Here
line from rvec_(m4v*3/4,0) \
to T',
m4atype,A,
- `ifelse(`$2',,`move to rvec_(m4h*2,0)')
- { line from rvec_(m4v*3/4, m4v*sqrt(3)/4) to Here \
- then to rvec_(m4v*3/4,-m4v*sqrt(3)/4) }
- line from rvec_(m4v*3/4,0) \
+ `ifelse(`$2',,`move to rvec_(m4h*2,0)', `$2',T,,`move to rvec_(`$2',0)')
+ { line from rvec_(m4v*3/4, m4v*sqrt(3)/4) to Here \
+ then to rvec_(m4v*3/4,-m4v*sqrt(3)/4) }
+ line from rvec_(m4v*3/4,0) \
to T')
- `$5'; resetdir_ ] with .T ifelse(`$1',,`at Here',`$1')')
+ `$5'; resetdir_ ] with .T ifelse(`$1',,`at Here',`$1')')
`switch( linespec,L|R,[O|C][D],L|B|D )
Wrapper for bswitch, lswitch, dswitch
@@ -1449,7 +1509,8 @@ define(`m4R',`ifelse(`$2',R,-)')define(`m4sc',`dimen_/24')dnl
}
line to rvec_(rp_len,0) invis ')
- `Amplifier amp( linespec,size )'
+ `amp( linespec,size )
+ Amplifier'
define(`amp',`eleminit_(`$1') define(`m4wd',`ifelse(`$2',,`dimen_',`($2)')')dnl
{line to rvec_(max(0,rp_len/2-m4wd/2),0)
line from rvec_(m4wd,0) \
@@ -2365,7 +2426,8 @@ define(`ta_xy',`vec_(vscal_(m4_xyU,`$1',ifelse(`$2',0,0,m4_xyS`($2)')))')
`Relative adjusted macro-internal coordinates'
define(`tr_xy',`M4_xyO+vec_(vscal_(m4_xyU,`$1',ifelse(`$2',0,0,m4_xyS`($2)')))')
`Initialize tr_xy_init(origin,unit,-)'
-define(`tr_xy_init',`M4_xyO: ifelse(`$1',,Here,`$1')
+define(`tr_xy_init',
+`M4_xyO: ifelse(`$1',,Here,`$1')
define(`m4_xyU',`$2')dnl
define(`m4_xyS',`$3')')
@@ -2388,8 +2450,10 @@ define(`sc_draw',`m4_dna(`$1',`$2')ifelse(m4I_,-1,`$4',`$3')')
we temporarily turn off comments for svg'
define(`rlabel',`ifsvg(`changecom(,)')dnl
m4label(`$1',`$2',`$3',.s_,below_,`$4')`'ifsvg(`changecom(`#',)')')
+
define(`llabel',`ifsvg(`changecom(,)')dnl
m4label(`$1',`$2',`$3',.n_,above_,`$4')`'ifsvg(`changecom(`#',)')')
+
define(`clabel',`ifsvg(`changecom(,)')dnl
m4label(`$1',`$2',`$3',,,`$4')`'ifsvg(`changecom(`#',)')')
labels at centre and both ends of an element `dimen_' long
@@ -3218,6 +3282,17 @@ define(`ACsymbol',`[ Origin: Here
with .Origin at Origin } ')
`$5'; resetdir_ ] with .Origin ifelse(`$1',,`at Here',`$1')')
+ `DCsymbol(at position, len, ht, U|D|L|R|degrees)
+ Arg4: drawing direction (default: current direction)'
+define(`DCsymbol',`[
+ define(`m4wid',`ifelse(`$2',,(dimen_/3),`($2)')')dnl
+ define(`m4ht',`ifelse(`$3',,`m4wid/5',`($3)')')
+ setdir_(ifelse(`$4',,`ifdef(`m4a_',rp_ang*rtod_,0)',`$4'))
+ Origin: rvec_(m4wid/2,-m4ht/2)
+ {line to rvec_(m4wid,0)}
+ dashline(from rvec_(0,-m4ht) to rvec_(m4wid,-m4ht),,m4wid/4)
+ `$5'; resetdir_ ] with .c ifelse(`$1',,`at Here',`$1')')
+
`n-terminal box
nterm(box specs; other commands,
nw,nn,ne,ns,