root/trunk/jps2ps/pps/arrowhead.pps

Revision 4, 16.9 kB (checked in by jms, 8 months ago)

Chargement de jps2ps dans le SVN.

Line 
1 /lisere_arrow false def
2
3 %% 18-06-06 %% %% syntaxe : A B C D (-) gere_arrowhead
4 %% 18-06-06 %% /gere_arrowhead {
5 %% 18-06-06 %% 7 dict begin
6 %% 18-06-06 %%    /option exch def
7 %% 18-06-06 %%    /D defpoint
8 %% 18-06-06 %%    /C defpoint
9 %% 18-06-06 %%    /B defpoint
10 %% 18-06-06 %%    /A defpoint
11 %% 18-06-06 %%    /i option length 1 sub def
12 %% 18-06-06 %%    option length 1 gt
13 %% 18-06-06 %%       {
14 %% 18-06-06 %%          %% on separe l'option pour l'extremite gauche de l'option
15 %% 18-06-06 %%          %% pour l'extremite droite
16 %% 18-06-06 %%          option 0 get
17 %% 18-06-06 %%          dup 45 eq                %% c'est le '-'
18 %% 18-06-06 %%          exch 61 eq                %% c'est le '='
19 %% 18-06-06 %%          or
20 %% 18-06-06 %%             {
21 %% 18-06-06 %%                /option_gauche () def
22 %% 18-06-06 %%             }
23 %% 18-06-06 %%             {
24 %% 18-06-06 %%                /option_gauche 1 string def
25 %% 18-06-06 %%                option_gauche 0 option 0 get put
26 %% 18-06-06 %%             }
27 %% 18-06-06 %%          ifelse
28 %% 18-06-06 %%
29 %% 18-06-06 %%          option i get
30 %% 18-06-06 %%          45 eq                %% c'est le '-'
31 %% 18-06-06 %%             {
32 %% 18-06-06 %%                /option_droite () def
33 %% 18-06-06 %%             }
34 %% 18-06-06 %%             {
35 %% 18-06-06 %%                /option_droite 1 string def
36 %% 18-06-06 %%                option_droite 0
37 %% 18-06-06 %%                option i get
38 %% 18-06-06 %%                dup 60 eq
39 %% 18-06-06 %%                   {pop 62}
40 %% 18-06-06 %%                   {
41 %% 18-06-06 %%                      dup 62 eq
42 %% 18-06-06 %%                         {pop 60}
43 %% 18-06-06 %%                         {
44 %% 18-06-06 %%                            dup 40 eq
45 %% 18-06-06 %%                               {pop 41}
46 %% 18-06-06 %%                               {
47 %% 18-06-06 %%                                  dup 41 eq
48 %% 18-06-06 %%                                     {pop 40}
49 %% 18-06-06 %%                                     {
50 %% 18-06-06 %%                                        dup 91 eq
51 %% 18-06-06 %%                                           {pop 93}
52 %% 18-06-06 %%                                           {
53 %% 18-06-06 %%                                              dup 93 eq
54 %% 18-06-06 %%                                                 {pop 91}
55 %% 18-06-06 %%                                              if
56 %% 18-06-06 %%                                           }
57 %% 18-06-06 %%                                       ifelse
58 %% 18-06-06 %%                                     }
59 %% 18-06-06 %%                                  ifelse
60 %% 18-06-06 %%                               }
61 %% 18-06-06 %%                            ifelse
62 %% 18-06-06 %%                         }
63 %% 18-06-06 %%                      ifelse
64 %% 18-06-06 %%                   }
65 %% 18-06-06 %%                ifelse
66 %% 18-06-06 %%             put
67 %% 18-06-06 %%             }
68 %% 18-06-06 %%          ifelse
69 %% 18-06-06 %%          A B option_gauche arrowhead
70 %% 18-06-06 %%          C D option_droite arrowhead
71 %% 18-06-06 %%       }
72 %% 18-06-06 %%    if
73 %% 18-06-06 %%
74 %% 18-06-06 %% end
75 %% 18-06-06 %% } def
76 %% 18-06-06 %%
77 %% 18-06-06 %% %% le dessin se fait en A, le segment venant de B
78 %% 18-06-06 %% %% syntaxe : B A (option) arrowhead
79 %% 18-06-06 %% /arrowhead {
80 %% 18-06-06 %% 3 dict begin
81 %% 18-06-06 %%    /option exch def
82 %% 18-06-06 %%    /A defpoint
83 %% 18-06-06 %%    /B defpoint
84 %% 18-06-06 %%    option () eq
85 %% 18-06-06 %%       {}
86 %% 18-06-06 %%    if
87 %% 18-06-06 %%    option (<) eq
88 %% 18-06-06 %%       {
89 %% 18-06-06 %%          gsave
90 %% 18-06-06 %%             A stranslate
91 %% 18-06-06 %%             A B pangle 180 add rotate
92 %% 18-06-06 %%             .5 .5 scale
93 %% 18-06-06 %%             lisere_arrow {
94 %% 18-06-06 %%                %% on fait un masquage (la couleur du fond est supposee
95 %% 18-06-06 %%                %% blanche), de facon a effacer les fins de traits sous
96 %% 18-06-06 %%                %% les fleches
97 %% 18-06-06 %%                gsave
98 %% 18-06-06 %%                   currentlinewidth arrowlength arrowscale pop mul mul
99 %% 18-06-06 %%                   arrowsize arrowscale exch pop mul div 2 mul
100 %% 18-06-06 %%                   0 translate
101 %% 18-06-06 %%                   1 1 1 setrgbcolor
102 %% 18-06-06 %%                   arrow
103 %% 18-06-06 %%                grestore
104 %% 18-06-06 %%             }
105 %% 18-06-06 %%             if
106 %% 18-06-06 %%             arrow
107 %% 18-06-06 %%          grestore
108 %% 18-06-06 %%       }
109 %% 18-06-06 %%    if
110 %% 18-06-06 %%    option (>) eq
111 %% 18-06-06 %%       {
112 %% 18-06-06 %%          gsave
113 %% 18-06-06 %%             A stranslate
114 %% 18-06-06 %%             A B pangle rotate
115 %% 18-06-06 %%             .5 .5 scale
116 %% 18-06-06 %%             arrow
117 %% 18-06-06 %%          grestore
118 %% 18-06-06 %%       }
119 %% 18-06-06 %%    if
120 %% 18-06-06 %%    option (\() eq
121 %% 18-06-06 %%       {
122 %% 18-06-06 %%          gsave
123 %% 18-06-06 %%             A stranslate
124 %% 18-06-06 %%             A B pangle rotate
125 %% 18-06-06 %%             O exclu
126 %% 18-06-06 %%          grestore
127 %% 18-06-06 %%       }
128 %% 18-06-06 %%    if
129 %% 18-06-06 %%    option (\)) eq
130 %% 18-06-06 %%       {
131 %% 18-06-06 %%          gsave
132 %% 18-06-06 %%             A stranslate
133 %% 18-06-06 %%             A B pangle 180 add rotate
134 %% 18-06-06 %%             O exclu
135 %% 18-06-06 %%          grestore
136 %% 18-06-06 %%       }
137 %% 18-06-06 %%    if
138 %% 18-06-06 %%    option (]) eq
139 %% 18-06-06 %%       {
140 %% 18-06-06 %%          gsave
141 %% 18-06-06 %%             A stranslate
142 %% 18-06-06 %%             A B pangle rotate
143 %% 18-06-06 %%             cr@chet
144 %% 18-06-06 %%          grestore
145 %% 18-06-06 %%       }
146 %% 18-06-06 %%    if
147 %% 18-06-06 %%    option ([) eq
148 %% 18-06-06 %%       {
149 %% 18-06-06 %%          gsave
150 %% 18-06-06 %%             A stranslate
151 %% 18-06-06 %%             A B pangle 180 add rotate
152 %% 18-06-06 %%             cr@chet
153 %% 18-06-06 %%          grestore
154 %% 18-06-06 %%       }
155 %% 18-06-06 %%    if
156 %% 18-06-06 %%    option (o) eq
157 %% 18-06-06 %%       {
158 %% 18-06-06 %%          gsave
159 %% 18-06-06 %%             A circ
160 %% 18-06-06 %%          grestore
161 %% 18-06-06 %%       }
162 %% 18-06-06 %%    if
163 %% 18-06-06 %%    option (*) eq
164 %% 18-06-06 %%       {
165 %% 18-06-06 %%          gsave
166 %% 18-06-06 %%             A dot
167 %% 18-06-06 %%          grestore
168 %% 18-06-06 %%       }
169 %% 18-06-06 %%    if
170 %% 18-06-06 %% end
171 %% 18-06-06 %% } def
172
173 %% 23_06-06 %% %% syntaxe : A A' B C C' D (-) gere_arrowhead
174 %% 23_06-06 %% /gere_arrowhead {
175 %% 23_06-06 %% 7 dict begin
176 %% 23_06-06 %%    /option exch def
177 %% 23_06-06 %%    /D defpoint
178 %% 23_06-06 %%    /C' defpoint
179 %% 23_06-06 %%    /C defpoint
180 %% 23_06-06 %%    /B defpoint
181 %% 23_06-06 %%    /A' defpoint
182 %% 23_06-06 %%    /A defpoint
183 %% 23_06-06 %%    /i option length 1 sub def
184 %% 23_06-06 %%    option length 1 gt
185 %% 23_06-06 %%       {
186 %% 23_06-06 %%          %% on separe l'option pour l'extremite gauche de l'option
187 %% 23_06-06 %%          %% pour l'extremite droite
188 %% 23_06-06 %%          option 0 get
189 %% 23_06-06 %%          dup 45 eq                %% c'est le '-'
190 %% 23_06-06 %%          exch 61 eq                %% c'est le '='
191 %% 23_06-06 %%          or
192 %% 23_06-06 %%             {
193 %% 23_06-06 %%                /option_gauche () def
194 %% 23_06-06 %%             }
195 %% 23_06-06 %%             {
196 %% 23_06-06 %%                /option_gauche 1 string def
197 %% 23_06-06 %%                option_gauche 0 option 0 get put
198 %% 23_06-06 %%             }
199 %% 23_06-06 %%          ifelse
200 %% 23_06-06 %%
201 %% 23_06-06 %%          option i get
202 %% 23_06-06 %%          45 eq                %% c'est le '-'
203 %% 23_06-06 %%             {
204 %% 23_06-06 %%                /option_droite () def
205 %% 23_06-06 %%             }
206 %% 23_06-06 %%             {
207 %% 23_06-06 %%                /option_droite 1 string def
208 %% 23_06-06 %%                option_droite 0
209 %% 23_06-06 %%                option i get
210 %% 23_06-06 %%                dup 60 eq
211 %% 23_06-06 %%                   {pop 62}
212 %% 23_06-06 %%                   {
213 %% 23_06-06 %%                      dup 62 eq
214 %% 23_06-06 %%                         {pop 60}
215 %% 23_06-06 %%                         {
216 %% 23_06-06 %%                            dup 40 eq
217 %% 23_06-06 %%                               {pop 41}
218 %% 23_06-06 %%                               {
219 %% 23_06-06 %%                                  dup 41 eq
220 %% 23_06-06 %%                                     {pop 40}
221 %% 23_06-06 %%                                     {
222 %% 23_06-06 %%                                        dup 91 eq
223 %% 23_06-06 %%                                           {pop 93}
224 %% 23_06-06 %%                                           {
225 %% 23_06-06 %%                                              dup 93 eq
226 %% 23_06-06 %%                                                 {pop 91}
227 %% 23_06-06 %%                                              if
228 %% 23_06-06 %%                                           }
229 %% 23_06-06 %%                                       ifelse
230 %% 23_06-06 %%                                     }
231 %% 23_06-06 %%                                  ifelse
232 %% 23_06-06 %%                               }
233 %% 23_06-06 %%                            ifelse
234 %% 23_06-06 %%                         }
235 %% 23_06-06 %%                      ifelse
236 %% 23_06-06 %%                   }
237 %% 23_06-06 %%                ifelse
238 %% 23_06-06 %%             put
239 %% 23_06-06 %%             }
240 %% 23_06-06 %%          ifelse
241 %% 23_06-06 %%          A A' B option_gauche arrowhead
242 %% 23_06-06 %%          C C' D option_droite arrowhead
243 %% 23_06-06 %%       }
244 %% 23_06-06 %%    if
245 %% 23_06-06 %%
246 %% 23_06-06 %% end
247 %% 23_06-06 %% } def
248 %% 23_06-06 %%
249 %% 23_06-06 %% %% le dessin se fait en A, le segment venant de B
250 %% 23_06-06 %% %% syntaxe : B A' A (option) arrowhead
251 %% 23_06-06 %% /arrowhead {
252 %% 23_06-06 %% 3 dict begin
253 %% 23_06-06 %%    /option exch def
254 %% 23_06-06 %%    /A defpoint
255 %% 23_06-06 %%    /A' defpoint
256 %% 23_06-06 %%    /B defpoint
257 %% 23_06-06 %%    option () eq
258 %% 23_06-06 %%       {}
259 %% 23_06-06 %%    if
260 %% 23_06-06 %%    option (<) eq
261 %% 23_06-06 %%       {
262 %% 23_06-06 %%          gsave
263 %% 23_06-06 %% %%              A stranslate
264 %% 23_06-06 %% %%              A B pangle 180 add rotate
265 %% 23_06-06 %% %%              .5 .5 scale
266 %% 23_06-06 %% %%              lisere_arrow {
267 %% 23_06-06 %% %%                 %% on fait un masquage (la couleur du fond est supposee
268 %% 23_06-06 %% %%                 %% blanche), de facon a effacer les fins de traits sous
269 %% 23_06-06 %% %%                 %% les fleches
270 %% 23_06-06 %% %%                 gsave
271 %% 23_06-06 %% %%                    currentlinewidth arrowlength arrowscale pop mul mul
272 %% 23_06-06 %% %%                    arrowsize arrowscale exch pop mul div 2 mul
273 %% 23_06-06 %% %%                    0 translate
274 %% 23_06-06 %% %%                    1 1 1 setrgbcolor
275 %% 23_06-06 %% %%                    arrow
276 %% 23_06-06 %% %%                 grestore
277 %% 23_06-06 %% %%              }
278 %% 23_06-06 %% %%              if
279 %% 23_06-06 %%             B A' A Arrow
280 %% 23_06-06 %%          grestore
281 %% 23_06-06 %%       }
282 %% 23_06-06 %%    if
283 %% 23_06-06 %%    option (>) eq
284 %% 23_06-06 %%       {
285 %% 23_06-06 %% %%           gsave
286 %% 23_06-06 %% %%              A stranslate
287 %% 23_06-06 %% %%              A B pangle rotate
288 %% 23_06-06 %% %%              .5 .5 scale
289 %% 23_06-06 %% %%              arrow
290 %% 23_06-06 %% %%           grestore
291 %% 23_06-06 %%          A A' B Arrow
292 %% 23_06-06 %%       }
293 %% 23_06-06 %%    if
294 %% 23_06-06 %%    option (\() eq
295 %% 23_06-06 %%       {
296 %% 23_06-06 %%          gsave
297 %% 23_06-06 %%             A stranslate
298 %% 23_06-06 %%             A B pangle rotate
299 %% 23_06-06 %%             O exclu
300 %% 23_06-06 %%          grestore
301 %% 23_06-06 %%       }
302 %% 23_06-06 %%    if
303 %% 23_06-06 %%    option (\)) eq
304 %% 23_06-06 %%       {
305 %% 23_06-06 %%          gsave
306 %% 23_06-06 %%             A stranslate
307 %% 23_06-06 %%             A B pangle 180 add rotate
308 %% 23_06-06 %%             O exclu
309 %% 23_06-06 %%          grestore
310 %% 23_06-06 %%       }
311 %% 23_06-06 %%    if
312 %% 23_06-06 %%    option (]) eq
313 %% 23_06-06 %%       {
314 %% 23_06-06 %%          gsave
315 %% 23_06-06 %%             A stranslate
316 %% 23_06-06 %%             A B pangle rotate
317 %% 23_06-06 %%             cr@chet
318 %% 23_06-06 %%          grestore
319 %% 23_06-06 %%       }
320 %% 23_06-06 %%    if
321 %% 23_06-06 %%    option ([) eq
322 %% 23_06-06 %%       {
323 %% 23_06-06 %%          gsave
324 %% 23_06-06 %%             A stranslate
325 %% 23_06-06 %%             A B pangle 180 add rotate
326 %% 23_06-06 %%             cr@chet
327 %% 23_06-06 %%          grestore
328 %% 23_06-06 %%       }
329 %% 23_06-06 %%    if
330 %% 23_06-06 %%    option (o) eq
331 %% 23_06-06 %%       {
332 %% 23_06-06 %%          gsave
333 %% 23_06-06 %%             A circ
334 %% 23_06-06 %%          grestore
335 %% 23_06-06 %%       }
336 %% 23_06-06 %%    if
337 %% 23_06-06 %%    option (*) eq
338 %% 23_06-06 %%       {
339 %% 23_06-06 %%          gsave
340 %% 23_06-06 %%             A dot
341 %% 23_06-06 %%          grestore
342 %% 23_06-06 %%       }
343 %% 23_06-06 %%    if
344 %% 23_06-06 %% end
345 %% 23_06-06 %% } def
346 %% 23_06-06 %%
347 %% 23_06-06 %% %% Pour le moment, rien n'est prevu dans le format jps pour faire le
348 %% 23_06-06 %% %% symbole d'exclusion d'un point sur une courbe. En attendant, on peut
349 %% 23_06-06 %% %% faire un petit bricolage adapte au cas particulier voulu.
350 %% 23_06-06 %%
351 %% 23_06-06 %%  /cr@chet {
352 %% 23_06-06 %% gsave
353 %% 23_06-06 %%    [] 0 setdash
354 %% 23_06-06 %%    dotscale scale
355 %% 23_06-06 %%    dotangle rotate
356 %% 23_06-06 %%    newpath
357 %% 23_06-06 %%       -4 5 moveto
358 %% 23_06-06 %%       4 0 rlineto
359 %% 23_06-06 %%       0 -10 rlineto
360 %% 23_06-06 %%       -4 0 rlineto
361 %% 23_06-06 %%    stroke
362 %% 23_06-06 %% grestore
363 %% 23_06-06 %% } def
364 %% 23_06-06 %%
365 %% 23_06-06 %% %% syntaxe : x y exclu
366 %% 23_06-06 %% /exclu {
367 %% 23_06-06 %%    gsave                                %% on encapsule les changements d'etat graphique
368 %% 23_06-06 %%    [] 0 setdash                         
369 %% 23_06-06 %%    1 dict begin                         %% on rend locale la variable 'rayon'
370 %% 23_06-06 %%                                         %% en ouvrant un nouveau dictionnaire
371 %% 23_06-06 %%       stranslate                        %% on translate dans le repere jps pour
372 %% 23_06-06 %%                                         %%  se mettre au point (x, y)
373 %% 23_06-06 %%       dotscale scale
374 %% 23_06-06 %%       newpath                           %% nouveau chemin
375 %% 23_06-06 %%          dotsize 2 div 0 dotsize .7 mul 90 -90 arc   %% arc de cercle, centre (dotsize, 0)
376 %% 23_06-06 %%       stroke                            %% on encre le chemin
377 %% 23_06-06 %%    end                                  %% on jette le dictionnaire
378 %% 23_06-06 %%    grestore                             %% on restore l'etat graphique
379 %% 23_06-06 %% } def
380
381 /lisere_arrow false def
382
383 %% syntaxe : A B C D (-) gere_arrowhead
384 /gere_arrowhead {
385 9 dict begin
386    /option exch def
387    /arrowpathend exch def
388    /D defpoint
389    /C defpoint
390    /arrowpathstart exch def
391    /B defpoint
392    /A defpoint
393    /i option length 1 sub def
394    option length 1 gt
395       {
396          %% on separe l'option pour l'extremite gauche de l'option
397          %% pour l'extremite droite
398          option 0 get
399          dup 45 eq                 %% c'est le '-'
400          exch 61 eq                %% c'est le '='
401          or
402             {
403                /option_gauche () def
404             }
405             {
406                /option_gauche 1 string def
407                option_gauche 0 option 0 get put
408             }
409          ifelse
410
411          option i get
412          dup 45 eq                 %% c'est le '-'
413          exch 61 eq                %% c'est le '='
414          or
415             {
416                /option_droite () def
417             }
418             {
419                /option_droite 1 string def
420                option_droite 0
421                option i get
422                dup 60 eq
423                   {pop 62}
424                   {
425                      dup 62 eq
426                         {pop 60}
427                         {
428                            dup 40 eq
429                               {pop 41}
430                               {
431                                  dup 41 eq
432                                     {pop 40}
433                                     {
434                                        dup 91 eq
435                                           {pop 93}
436                                           {
437                                              dup 93 eq
438                                                 {pop 91}
439                                              if
440                                           }
441                                       ifelse
442                                     }
443                                  ifelse
444                               }
445                            ifelse
446                         }
447                      ifelse
448                   }
449                ifelse
450             put
451             }
452          ifelse
453          A B arrowpathstart option_gauche arrowhead
454          C D arrowpathend   option_droite arrowhead
455       }
456    if
457
458 end
459 } def
460
461 %% le dessin se fait en A, le segment venant de B
462 %% syntaxe : B A (option) arrowhead
463 /arrowhead {
464 4 dict begin
465    /option exch def
466    /arrowpathstart exch def
467    /A defpoint
468    /B defpoint
469    option () eq
470       {}
471    if
472    option (<) eq
473       {
474          gsave
475             arrowpathstart draw_arrow  % B 0 0 A Arrow
476          grestore
477       }
478    if
479    option (>) eq
480       {
481          arrowpathstart reversecpathobj
482          gsave
483          2 dict begin
484             dup cpathstartpoint /A defpoint
485             dup cpathendpoint /B defpoint
486             B A vecteur stranslate
487             draw_arrow %% A 0 0 B Arrow
488          end
489          grestore
490       }
491    if
492    option (\() eq
493       {
494          gsave
495             A stranslate
496             A B pangle rotate
497             O exclu
498          grestore
499       }
500    if
501    option (\)) eq
502       {
503          gsave
504             A stranslate
505             A B pangle 180 add rotate
506             O exclu
507          grestore
508       }
509    if
510    option (]) eq
511       {
512          gsave
513             A stranslate
514             A B pangle rotate
515             cr@chet
516          grestore
517       }
518    if
519    option ([) eq
520       {
521          gsave
522             A stranslate
523             A B pangle 180 add rotate
524             cr@chet
525          grestore
526       }
527    if
528    option (o) eq
529       {
530          gsave
531             A circ
532          grestore
533       }
534    if
535    option (*) eq
536       {
537          gsave
538             A dot
539          grestore
540       }
541    if
542 end
543 } def
544
545 %% Pour le moment, rien n'est prevu dans le format jps pour faire le
546 %% symbole d'exclusion d'un point sur une courbe. En attendant, on peut
547 %% faire un petit bricolage adapte au cas particulier voulu.
548
549  /cr@chet {
550 gsave
551    [] 0 setdash
552    dotscale scale
553    dotangle rotate
554    newpath
555       -4 5 moveto
556       4 0 rlineto
557       0 -10 rlineto
558       -4 0 rlineto
559    stroke
560 grestore
561 } def
562
563 %% syntaxe : x y exclu
564 /exclu {
565    gsave                                %% on encapsule les changements d'etat graphique
566    [] 0 setdash                         
567    1 dict begin                         %% on rend locale la variable 'rayon'
568                                         %% en ouvrant un nouveau dictionnaire
569       stranslate                        %% on translate dans le repere jps pour
570                                         %%  se mettre au point (x, y)
571       dotscale scale
572       newpath                           %% nouveau chemin
573          dotsize 2 div 0 dotsize .7 mul 90 -90 arc   %% arc de cercle, centre (dotsize, 0)
574       stroke                            %% on encre le chemin
575    end                                  %% on jette le dictionnaire
576    grestore                             %% on restore l'etat graphique
577 } def
578
579
Note: See TracBrowser for help on using the browser.