1
2
3
4
5
6
7
8
9
10
11
12
13
14\registerctxluafile{metanod}{}
15
16\unprotect
17
18\defineMPinstance
19 [nodes]
20 [\s!format=metafun,
21 \s!extensions=\v!yes,
22 \s!initializations=\v!yes,
23 \c!method=\s!double]
24
25\defineframed
26 [node]
27 [\c!frame=\v!off]
28
29\defineframed
30 [smallnode]
31 [node]
32 [\c!foregroundstyle=\small]
33
34
35
36
37
38\protect
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\unprotect
82
83\installcorenamespace{metanodes}
84\installcorenamespace{metanodesoption}
85\installcorenamespace{metanodesalternative}
86\installcorenamespace{metanodesposition}
87
88
89
90\installparameterhandler \??metanodes {metanodes}
91\installsetuphandler \??metanodes {metanodes}
92
93\setupmetanodes
94 [\c!option =,
95 \c!alternative =,
96 \c!offset =0,
97 \c!position =,
98 \c!label =,
99 \c!dx =2\emwidth,
100 \c!dy =2\emwidth,
101 \c!rotation =90,
102 \c!rulethickness =.5pt,
103 \c!command =]
104
105\newtoks\t_every_meta_nodes
106\newtoks\t_meta_nodes
107
108\let\stopnodes\relax
109
110
111
112
113\newcount\c_meta_nodes_n
114
115\unexpanded\def\startnodes
116 {\dosingleempty\meta_nodes_start}
117
118\def\meta_nodes_start[#1]#2\stopnodes
119 {\hpack\bgroup
120 \iffirstargument
121 \setupcurrentmetanodes[#1]
122 \fi
123 \edef\p_meta_option{\metanodesparameter\c!option}
124 \edef\p_meta_alternative{\metanodesparameter\c!alternative}
125 \the\t_every_meta_nodes
126 \c_meta_nodes_n\zerocount
127 \t_meta_nodes\emptytoks
128 #2\removeunwantedspaces
129
130 \writestatus{metanodes}{\detokenize\expandafter{\the\t_meta_nodes}}
131 \clf_grph_nodes_initialize
132 \startMPcode
133 mfun_node_init(
134 \the\dimexpr\metanodesparameter\c!dx\relax,
135 \the\dimexpr\metanodesparameter\c!dy\relax,
136 \metanodesparameter\c!rotation
137 ) ;
138 \the\t_meta_nodes ;
139 mfun_node_flush ;
140 \stopMPcode
141 \clf_grph_nodes_reset
142 \egroup}
143
144\unexpanded\def\grph_nodes_node
145 {\dodoubleempty\grph_nodes_node_two}
146
147\def\grph_nodes_node_two[#1][#2]
148 {\grph_nodes_node_two_indeed[#1][#2]}
149
150\def\grph_nodes_node_two_indeed[#1,#2][#3]#4
151 {\begingroup
152 \ifsecondargument
153 \setupcurrentmetanodes[#3]
154 \fi
155 \edef\p_label{#4}
156 \edef\p_reference{\metanodesparameter\c!reference}
157 \ifx\p_reference\empty\else
158 \clf_grph_nodes_register{\p_reference}\c_meta_nodes_n\relax
159 \fi
160 \normalexpanded{\endgroup\noexpand\etoksapp\t_meta_nodes{
161 mfunnodemake(\number#1,\number#2
162 \ifx\p_label\empty
163 ,""
164 \else
165 ,"\metanodesparameter\c!command{\p_label}"
166 \fi
167 );
168 }}
169 \advance\c_meta_nodes_n\plusone}
170
171\appendtoks
172 \let\placenode\grph_nodes_node
173\to \t_every_meta_nodes
174
175\unexpanded\def\grph_nodes_fromto
176 {\dodoubleempty\grph_nodes_fromto_two}
177
178\def\grph_nodes_fromto_two[#1][#2]
179 {\grph_nodes_fromto_two_indeed[#1][#2]}
180
181\letvalue{\??metanodesposition }\empty
182\setvalue{\??metanodesposition top}{.top}
183\setvalue{\??metanodesposition bottom}{.bot}
184\setvalue{\??metanodesposition left}{.lft}
185\setvalue{\??metanodesposition right}{.rt}
186\setvalue{\??metanodesposition upperleft}{.ulft}
187\setvalue{\??metanodesposition topleft}{.ulft}
188\setvalue{\??metanodesposition lefttop}{.ulft}
189\setvalue{\??metanodesposition upperright}{.urt}
190\setvalue{\??metanodesposition topright}{.urt}
191\setvalue{\??metanodesposition righttop}{.urt}
192\setvalue{\??metanodesposition lowerleft}{.llft}
193\setvalue{\??metanodesposition bottomleft}{.llft}
194\setvalue{\??metanodesposition leftbottom}{.llft}
195\setvalue{\??metanodesposition lowerright}{.lrt}
196\setvalue{\??metanodesposition bottomright}{.lrt}
197\setvalue{\??metanodesposition rightbottom}{.lrt}
198
199\def\grph_nodes_fromto_two_indeed[#1,#2][#3]
200 {\begingroup
201 \ifsecondargument
202 \setupcurrentmetanodes[#3]
203 \fi
204 \edef\p_label {\metanodesparameter\c!label}
205 \edef\p_rulethickness{\metanodesparameter\c!rulethickness}
206 \edef\p_command {\metanodesparameter\c!command}
207 \normalexpanded{\endgroup\noexpand\etoksapp\t_meta_nodes{
208 \ifcsname\??metanodesalternative\metanodesparameter\c!alternative\endcsname
209 \lastnamedcs
210 \else
211 \csname\??metanodesalternative\endcsname
212 \fi
213 \space
214 mfunnodesfromto\begincsname\??metanodesposition\metanodesparameter\c!position\endcsname(
215 \metanodesparameter\c!offset,
216
217 \clf_grph_nodes_resolve{#1},\clf_grph_nodes_resolve{#2}
218 \ifx\p_label\empty
219 ,""
220 \else
221 ,"\ifx\p_command\empty\p_label\else\p_command{\p_label}\fi"
222 \fi
223 )
224 \space
225 \ifcsname\??metanodesoption\metanodesparameter\c!option\endcsname
226 \lastnamedcs
227 \else
228 \csname\??metanodesoption\endcsname
229 \fi
230 \space
231 \ifx\p_rulethickness\empty \else
232 withpen pencircle scaled \the\dimexpr\p_rulethickness\relax
233 \fi
234 ;
235 }}}
236
237\setvalue{\??metanodesalternative }{draw}
238\setvalue{\??metanodesalternative arrow}{drawarrow}
239\setvalue{\??metanodesalternative doublearrow}{drawdblarrow}
240\setvalue{\??metanodesalternative doublearrows}{drawdoublearrows}
241
242\setvalue{\??metanodesoption }{}
243\setvalue{\??metanodesoption dashed}{dashed evenly}
244\setvalue{\??metanodesoption dotted}{dashed withdots scaled .5}
245
246\appendtoks
247 \let\connectnodes\grph_nodes_fromto
248\to \t_every_meta_nodes
249
250\unexpanded\def\grph_nodes_code#1
251 {\etoksapp\t_meta_nodes{#1}}
252
253\appendtoks
254 \let\nodeMPcode\grph_nodes_code
255 \let\mpcode\grph_nodes_code
256\to \t_every_meta_nodes
257
258\protect \endinput
259 |