summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkxl/m-circuitikz.mkxl
blob: 27ef72642c30f934b3f8526901180d12ce5db3f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
%D \module
%D   [       file=m-circuitikz,
%D        version=2021.12.03,
%D          title=\CONTEXT\ Extra Modules,
%D       subtitle=CURCUITIKZ support,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D A fixed variant of the t-curcuitikz module distributed with tikz. This one
%D is for \LMTX.

\usemodule[m][tikz]

\startmodule[circuitikz]

\usetikzlibrary[calc]
\usetikzlibrary[arrows.meta]
\usetikzlibrary[bending]
\usetikzlibrary[fpu] % may be needed for use fpu reciprocal (v1.0.1)

\tikzinputfile{pgfcirc.defines.tex}
\tikzinputfile{pgfcircutils.tex}
\tikzinputfile{pgfcircpath.tex}

\tikzinputfile{pgfcircshapes.tex}
\tikzinputfile{pgfcircmonopoles.tex}
\tikzinputfile{pgfcircbipoles.tex}
\tikzinputfile{pgfcirctripoles.tex}
\tikzinputfile{pgfcircquadpoles.tex}
\tikzinputfile{pgfcircmultipoles.tex}

\tikzinputfile{pgfcirclabel.tex}
\tikzinputfile{pgfcircvoltage.tex}
\tikzinputfile{pgfcirccurrent.tex}
\tikzinputfile{pgfcircflow.tex}

\ifdefined\pgfcircversion     \else \def\pgfcircversion     {0.0.0}      \fi
\ifdefined\pgfcircversiondate \else \def\pgfcircversiondate {1010/01/01} \fi

% defaults

\setupmodule
  [current=european,
   voltage=european,
   resistor=american,
   inductor=cute,
   logic=american,
  %siunitx=true,
   arrowmos=false]

% can be done nicer ... todo

\processaction
  [\currentmoduleparameter{voltage}]
  [european=>\ctikzset{voltage=european},
   american=>\ctikzset{voltage=american}]

\processaction
  [\currentmoduleparameter{current}]
  [european=>\ctikzset{current=european},
   american=>\ctikzset{current=american}]

\processaction
  [\currentmoduleparameter{label}]
  [straight=>\ctikzset{label/align=straight},
      align=>\ctikzset{label/align=rotate},
      smart=>\ctikzset{label/align=smart}]

\processaction
  [\currentmoduleparameter{resistor}]
  [european=>\ctikzset{resistor=european},
   american=>\ctikzset{resistor=american}]

\processaction
  [\currentmoduleparameter{inductor}]
  [european=>\ctikzset{inductor=european},
   american=>\ctikzset{inductor=american},
       cute=>\ctikzset{inductor=cute}]

\processaction
  [\currentmoduleparameter{diode}]
  [ full=>\ctikzset{diode=full},
   empty=>\ctikzset{diode=empty}]

\processaction
  [\currentmoduleparameter{logic}]
  [european=>\ctikzset{logic ports=european},
   american=>\ctikzset{logic ports=american}]

% hm, we have units since '97 so one can load the units module in mkii or
% assume it is present (mkiv and therefore lmtx)
%
% \processaction
%   [\currentmoduleparameter{siunitx}]
%   [true=>\def\SI    #1#2{#1\,#2}
%          \def\ampere    {\rm{A}}
%          \def\volt      {\rm{V}}
%          \def\ohm       {\Omega}
%          \def\siemens   {\rm{S}}
%          \def\farad     {\rm{F}}
%          \def\henry     {\rm{H}}
%          \def\second    {\rm{s}}
%          \def\coulomb   {\rm{C}}
%          \def\siemens   {\rm{S}}
%          \def\radians   {\rm{rad}}
%          \def\milli     {\rm{m}}
%          \def\micro     {\mu}
%          \def\nano      {\rm{n}}
%          \def\pico      {\rm{p}}
%          \def\kilo      {\rm{k}}
%          \def\mega      {\rm{M}}
%          \def\giga      {\rm{G}}
%          \def\tera      {\rm{T}}]

\unprotect

\processaction
  [\currentmoduleparameter{arrowmos}]
  [true=>\pgf@circuit@mos@arrowstrue,
   false=>\pgf@circuit@mos@arrowsfalse]

\protect

\ctikzset{tripoles/op amp/font/.initial=\switchtobodyfont[small]}

\aliased\let\stopcircuitikz\relax

\permanent\protected\def\startcircuitikz#1\stopcircuitikz
  {\starttikzpicture#1\stoptikzpicture}

\stopmodule

\endinput