1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16if known context_asnc : endinput ; fi ;
17
18boolean context_asnc ; context_asnc := true ;
19
20newscriptindex mfid_asnc_collect ; mfid_asnc_collect := scriptindex "asnc_collect" ; def asnc_collect (expr category,realpage,region) = runscript mfid_asnc_collect (category) (realpage) (region) enddef ;
21
22newscriptindex mfid_asnc_extend ; mfid_asnc_extend := scriptindex "asnc_extend" ; def asnc_extend = runscript mfid_asnc_extend enddef ;
23newscriptindex mfid_asnc_prune ; mfid_asnc_prune := scriptindex "asnc_prune" ; def asnc_prune = runscript mfid_asnc_prune enddef ;
24newscriptindex mfid_asnc_collapse ; mfid_asnc_collapse := scriptindex "asnc_collapse" ; def asnc_collapse = runscript mfid_asnc_collapse enddef ;
25newscriptindex mfid_asnc_getsize ; mfid_asnc_getsize := scriptindex "asnc_getsize" ; def asnc_getsize = runscript mfid_asnc_getsize enddef ;
26newscriptindex mfid_asnc_getx ; mfid_asnc_getx := scriptindex "asnc_getx" ; def asnc_getx = runscript mfid_asnc_getx enddef ;
27newscriptindex mfid_asnc_gety ; mfid_asnc_gety := scriptindex "asnc_gety" ; def asnc_gety = runscript mfid_asnc_gety enddef ;
28newscriptindex mfid_asnc_getw ; mfid_asnc_getw := scriptindex "asnc_getw" ; def asnc_getw = runscript mfid_asnc_getw enddef ;
29newscriptindex mfid_asnc_geth ; mfid_asnc_geth := scriptindex "asnc_geth" ; def asnc_geth = runscript mfid_asnc_geth enddef ;
30newscriptindex mfid_asnc_getd ; mfid_asnc_getd := scriptindex "asnc_getd" ; def asnc_getd = runscript mfid_asnc_getd enddef ;
31
32newscriptindex mfid_asnc_gettop ; mfid_asnc_gettop := scriptindex "asnc_gettop" ; def asnc_gettop (expr n) = (runscript mfid_asnc_gettop n) enddef ;
33newscriptindex mfid_asnc_getbottom ; mfid_asnc_getbottom := scriptindex "asnc_getbottom"; def asnc_getbottom(expr n) = (runscript mfid_asnc_getbottom n) enddef ;
34newscriptindex mfid_asnc_getkind ; mfid_asnc_getkind := scriptindex "asnc_getkind" ; def asnc_getkind (expr n) = (runscript mfid_asnc_getkind n) enddef ;
35newscriptindex mfid_asnc_gettask ; mfid_asnc_gettask := scriptindex "asnc_gettask" ; def asnc_gettask (expr n) = (runscript mfid_asnc_gettask n) enddef ;
36
37presetparameters "synchronizer" [
38 color = "darkgray",
39 colors = {
40 "darkred"
41 "darkgreen"
42 "darkblue",
43 "darkyellow",
44 "darkmagenta",
45 "darkcyan",
46 "darkgray"
47 },
48 index = 1,
49 hoffset = 0,
50 voffset = 0,
51 region = "",
52 width = 1cm,
53 extend = false,
54 prune = true,
55 collapse = true,
56 draw = true,
57 fill = true,
58 page = "auto",
59] ;
60
61def lmt_synchronizer = applyparameters "synchronizer" "lmt_do_synchronizer" enddef ;
62
63
64
65vardef lmt_do_synchronizer =
66 pushparameters "synchronizer" ;
67 begingroup ;
68 save index, dx, dy, width, count, page, region, paths, tasks, kinds ;
69 path paths[] ; numeric tasks[] ; numeric kinds[] ;
70
71 numeric index ; index := getparameter "index" ;
72 numeric dx ; dx := getparameter "hoffset" ;
73 numeric dy ; dy := getparameter "voffset" ;
74 numeric width ; width := getparameter "width" ;
75 numeric count ; count := 0 ;
76 string page ; page := getparameter "page" ;
77 string region ; region := getparameter "region" ;
78
79 count := asnc_collect(index,RealPageNumber,region) ;
80 if getparameter "extend" :
81 count := asnc_extend ;
82 fi ;
83 if getparameter "prune" :
84 count := asnc_prune ;
85 fi ;
86 if getparameter "collapse" :
87 count := asnc_collapse ;
88 fi ;
89 if count > 0 :
90 save k, t, b, l, r, y ;
91 numeric l ; l := dx ;
92 numeric r ; r := dx width ;
93 numeric y ; y := asnc_gety dy ;
94 for i=1 upto count :
95 k := asnc_getkind(i) ;
96 t := asnc_gettop(i) y ;
97 b := asnc_getbottom(i) y ;
98 paths[i] = ((l,t) -- (r,t) -- (r,b) -- (l,b) -- cycle) ;
99 tasks[i] = asnc_gettask(i) ;
100 kinds[i] = k ;
101 endfor ;
102 if page = "auto" :
103 page := if region == "" : "clip" else : "no" fi ;
104 fi ;
105 if (page = "clip") or (page = "yes") :
106 StartPage ;
107 fi ;
108 if getparameter "fill" :
109 for i=1 upto count :
110 fill paths[i]
111 withcolor getparameterdefault "colors" i (getparameter "color") ;
112 ;
113 endfor ;
114 fi ;
115 if getparameter "draw" :
116 for i=1 upto count :
117 draw paths[i]
118 withcolor getparameterdefault "colors" i (getparameter "color") ;
119 ;
120 endfor ;
121 fi ;
122 if page = "clip" :
123 clip currentpicture to Page ;
124 setbounds currentpicture to Page ;
125 fi ;
126 if (page = "clip") or (page = "yes") :
127 StopPage ;
128 fi ;
129 fi ;
130 endgroup ;
131 popparameters ;
132enddef ;
133
134 |