Debian Codegraph @

texmf-dist/tex/generic/pstricks/pst-code-pspicture.tex

raw
1 %
2 % see pstricks.tex for license and copyright
3 %
4 % ----------- hv 20120219 -------------------
5 \newpsstyle{gridstyle}{subgriddiv=0,gridcolor=lightgray,griddots=10,gridlabels=8pt}
6 \newpsstyle{gridstyleA}{subgriddiv=5,gridcolor=red!30,subgridcolor=green!20!black!10,gridlabels=0pt}
7 \newif\ifshowgrid
8 \newdimen\sh@wgridXunit
9 \newdimen\sh@wgridYunit
10
11 \def\pst@@showgrid#1#2#3\@nil{% hv 20130403
12 \def\showgridp@s{0}%
13 \ifx#1b\showgridtrue\else% bottom
14 \ifx#1f\showgridfalse\else
15 \ifx#1t
16 \ifx#2r \showgridtrue\else% true->bottom
17 \showgridtrue\def\showgridp@s{1}\fi% top
18 \fi\fi\fi
19 \ifnum\showgridp@s>0\relax
20 \sh@wgridXunit=\psxunit
21 \sh@wgridYunit=\psyunit
22 \fi
23 }
24
25 \define@key[psset]{pstricks}{showgrid}[b]{\expandafter\pst@@showgrid#1!!\@nil}
26 \define@boolkey[psset]{pstricks}[Pst@]{showframe}[true]{}
27 \define@boolkey[psset]{pstricks}[Pst@]{calcframe}[true]{}
28 \psset[pstricks]{showgrid=f,showframe=false,calcframe=false}
29
30 \define@boolkey[psset]{pstricks}[Pst@]{pgffunctions}[true]{}
31 \psset[pstricks]{pgffunctions=false}
32 %
33 \newdimen\pst@shift
34 \newif\ifPst@shift@star
35 \define@key[psset]{pstricks}{shift}[0]{%
36 \ifx#1*
37 \global\Pst@shift@startrue
38 \pst@shift=\p@
39 \else
40 \global\Pst@shift@starfalse
41 \pssetlength\pst@dimg{#1}
42 \global\pst@shift\pst@dimg% only the outer pspicture env can have a shift
43 \fi}
44 \psset[pstricks]{shift=0}
45 %
46 % The main pspciture environment
47 %------------------------------- pspicture ------------------------------
48 %
49 \def\ps@readmargin#1,#2,#3,#4,#5\@nil{%
50 \ifx\\#2\\
51 % \typeout{>>> Case 1 para}%
52 \pst@getlength{#1}\ps@margin@left
53 \let\ps@margin@right\ps@margin@left
54 \let\ps@margin@top\ps@margin@left
55 \let\ps@margin@bottom\ps@margin@left
56 \else
57 \ifx\\#3\\%
58 % \typeout{>>> Case 2 para: #1,#2}%
59 \pst@getlength{#1}\ps@margin@left
60 \def\ps@margin@right{0}%
61 \pst@getlength{#2}\ps@margin@bottom
62 \def\ps@margin@top{0}
63 \else
64 % \typeout{>>> Case 4 para: #1,#2,#3,#4}%
65 \pst@getlength{#1}\ps@margin@left
66 \pst@getlength{#2}\ps@margin@bottom
67 \pst@getlength{#3}\ps@margin@right
68 \pst@getlength{#4}\ps@margin@top
69 \fi\fi
70 %\typeout{>>>>>>>>>\ps@margin@left,\ps@margin@bottom,\ps@margin@right,\ps@margin@top}%
71 }%
72 \define@key[psset]{pstricks}{margin}[0pt]{\ps@readmargin#1,,,,\@nil}
73 \psset[pstricks]{margin=0pt}
74 %
75
76 \ExplSyntaxOn
77 \define@key[psset]{pstricks}{alt}[]{\tl_set:Ne\l__tag_graphic_alt_tl{\text_purify:n{#1}}}
78 %\define@boolkey[psset]{pstricks}[]{artifact}[true]{}
79 \define@key[psset]{pstricks}{artifact}{%
80 \bool_set_true:N \l__tag_graphic_artifact_bool
81 \bool_set_false:N \l__tag_graphic_BBox_bool
82 }
83 \define@key[psset]{pstricks}{actualtext}[]{%
84 \tl_set:Ne\l__tag_graphic_actual_tl{\text_purify:n{#1}}
85 \bool_set_false:N \l__tag_graphic_BBox_bool
86 }
87 \define@key[psset]{pstricks}{correct-BBox}{%
88 \bool_set_true:N \l__tag_graphic_bboxcorr_bool
89 \seq_set_split:Nnn\l__tag_graphic_bboxcorr_seq{~}{#1~0pt~0pt~0pt~0pt}%
90 }
91 \define@key[psset]{pstricks}{tag}[]{%
92 \str_case:nnF {#1}{
93 {artifact}
94 {
95 \bool_set_true:N \l__tag_graphic_artifact_bool
96 \bool_set_false:N \l__tag_graphic_BBox_bool
97 }
98 {false}{\tag_stop:}
99 }
100 {\tl_set:Nn\l__tag_graphic_struct_tl{#1}}
101 }
102
103 \ExplSyntaxOff
104
105 \newcount\ps@imagectr
106 \ps@imagectr=0
107 %\newif\ifPst@findcoor
108 %\Pst@findcoorfalse
109 %
110
111 \def\pspicture{\begingroup\pst@ifstar\pst@picture}
112 \def\pst@picture{\@ifnextchar[{\pst@@picture}{\pst@@picture[]}}
113 \def\pst@@picture[#1]{%
114 % showgrid=false% for nested pspicture environemnets
115 \def\pst@tempA{showgrid=false,#1}% added 20250612 hv
116 \psset{#1}% sets the shift and grid option
117 \@ifnextchar({\pst@@picture@i[#1]}{\pst@@picture@@i[#1]}}%
118 \def\pst@@picture@@i[#1]{%
119 \def\pic@coor{(0,0)(0,0)}%
120 \gdef\pscoor{(10,10)}%
121 \ifPst@calcframe
122 \typeout{>>>Check for file \jobname-\the\numexpr\ps@imagectr+1.psaux}%
123 \IfFileExists{\jobname-\the\numexpr\ps@imagectr+1.psaux}
124 {\input{\jobname-\the\numexpr\ps@imagectr+1.psaux}%
125 \xdef\pic@coor{(0,0)\pscoor}%
126 \typeout{----->>\pic@coor}%
127 \typeout{----->>\pscoor}%
128 }
129 {%\gdef\pscoor{(10,10)}
130 %\def\pic@coor{(0,0)(0,0)(10,10)}
131 }%
132 % \typeout{>>>\pscoor}%
133 \fi
134 \edef\@temp{[\noexpand#1]\pscoor}%
135 \expandafter\pst@@picture@i\@temp}
136 %
137 \def\pst@@picture@i[#1]#2(#3,#4){\@ifnextchar(% ignore anything between [] and ()
138 {\pst@@@picture[#1](#3,#4)}%
139 {\pst@@@picture[#1](0,0)(#3,#4)}}
140 %
141 \def\pst@@@picture[#1](#2,#3)(#4,#5){%
142 \pssetxlength\pst@dima{#2}%
143 \pssetylength\pst@dimb{#3}%
144 \pssetxlength\pst@dimc{#4}%
145 \pssetylength\pst@dimd{#5}%
146 \pstVerb{/xCanvasLeft \pst@number\pst@dima def
147 /yCanvasLeft \pst@number\pst@dimb def
148 /xCanvasRight \pst@number\pst@dimc def
149 /yCanvasRight \pst@number\pst@dimd def
150 }%
151 \ifdim\pst@dima>\pst@dimc
152 \pst@dimg=\pst@dima
153 \pst@dima=\pst@dimc
154 \pst@dimc=\pst@dimg
155 \fi
156 \ifdim\pst@dimb>\pst@dimd
157 \pst@dimg=\pst@dimb
158 \pst@dimb=\pst@dimd
159 \pst@dimd=\pst@dimg
160 \fi
161 \setbox\pst@hbox=\hbox\bgroup
162 \begingroup\KillGlue
163 \@ifundefined{@latexerr}{}{\let\unitlength\psunit}%
164 \edef\pic@coor{(#2,#3)(#2,#3)(#4,#5)}%
165 % ----------- 1.10/12 beg hv -------------------
166 % \psset{showgrid=false}% % for nested pspicture environemnets
167 % \def\pst@tempA{#1}%
168 % \ifx\pst@tempA\@empty\else\psset{#1}\fi% sets the shift and grid option
169 \ifx\pst@bgcolor\@empty\else\psframe*[linecolor=\pst@bgcolor](#2,#3)(#4,#5)\fi
170 \ifshowgrid\ifnum\showgridp@s=0\psgrid[style=gridstyle]\fi\fi
171 % ----------- 1.10/12 end hv -------------------
172 \ignorespaces% % 2008-12-07
173 \ifPst@calcframe\pstVerb{ .trackbbox }\global\advance\ps@imagectr by 1 \fi
174 \ifPst@pgffunctions\pstVerb{ pgffunctions }\fi% hv 2013-04-17
175 }
176
177 %\def\pic@coor{(0,0)(0,0)(10,10)}
178 \def\endpspicture{%
179 \ifPst@calcframe
180 \ifPSTlualatex
181 \pstVerb{
182 .trackedbbox % xmin ymin xmax ymax
183 % Die Koordinaten sind relativ zur Seite, also verschieben wir sie
184 % zum aktuellen Punkt.
185 currentpoint matrix translate dup invertmatrix dup 4 1 roll
186 transform
187 /YMAX exch def /XMAX exch def
188 transform
189 /YMIN exch def /XMIN exch def
190 % Now we have all absolute coordinates
191 \ifPst@showframe
192 % Um jetzt an diesen Koordinaten zu zeichnen, ist das natürlich
193 % ungünstig und wir müssen zurück schieben... (Oder den Code
194 % umordnen, aber warum einfach wenns auch kompliziert geht ;P)
195 XMIN YMIN XMAX XMIN sub YMAX YMIN sub % lower left, width, height
196 4 copy
197 gsave
198 currentpoint translate newpath rectstroke
199 newpath 0 0 moveto % x0 y0 x1 y1
200 \ps@margin@top\space add \ps@margin@bottom\space add 4 1 roll % y1 x0 y0 x1
201 \ps@margin@right\space add \ps@margin@left\space add 4 1 roll % x1 y1 x0 y0
202 \ps@margin@bottom\space sub 4 1 roll % y0 x1 y1 x0
203 \ps@margin@left\space sub 4 1 roll % x0 y0 x1 y1
204 [3 3] 0 setdash rectstroke
205 grestore
206 \fi
207 (\jobname-\the\[email protected]) (w) file /CoorFile exch def
208 (\\gdef\\pscoor{\string\() CoorFile exch writestring
209 XMIN %\pst@number\psxunit div
210 \ps@margin@left\space sub 20 string cvs CoorFile exch writestring
211 (pt, ) CoorFile exch writestring
212 YMIN %\pst@number\psyunit div
213 \ps@margin@bottom\space sub 20 string cvs CoorFile exch writestring
214 (pt\string\)\string\() CoorFile exch writestring
215 XMAX %\pst@number\psxunit div
216 \ps@margin@right\space add 20 string cvs CoorFile exch writestring
217 (pt, ) CoorFile exch writestring
218 YMAX %\pst@number\psyunit div
219 \ps@margin@top\space add 20 string cvs CoorFile exch writestring
220 (pt\string\)}\% ) CoorFile exch writestring
221 %(Unit is \pst@number\psyunit/\pst@number\psyunit) 40 string cvs CoorFile exch writestring
222 CoorFile closefile
223 }%
224 \else
225 \global\Pst@calcframefalse
226 \PackageError{PSTricks}{You need to run lualatex for calculating the bounding box or set calcframe=false}{}%\@ehpa
227 \fi
228 \fi
229 \ifshowgrid\ifnum\showgridp@s>0
230 \psgrid[xunit=\sh@wgridXunit,yunit=\sh@wgridYunit,style=gridstyle]\fi\fi
231 \pst@killglue
232 \endgroup
233 \egroup
234 \ht\pst@hbox=\pst@dimd
235 \dp\pst@hbox=-\pst@dimb
236 \setbox\pst@hbox=\hbox{%
237 \kern-\pst@dima
238 \ifPst@shift@star%\typeout{==pstricks== old behaviour of the shift option}% shift=*
239 \advance\pst@dimd-\pst@dimb
240 \pst@dimd=0.5\pst@dimd
241 \else\pst@dimd-\pst@shift\fi
242 \advance\pst@dimd\pst@dimb
243 \lower\pst@dimd\box\pst@hbox
244 \kern\pst@dimc}%
245 \if@star\setbox\pst@hbox=\hbox{\psclipbox@@\z@}\fi
246 \leavevmode
247 \ifPst@draft
248 \expandafter\ifx\csname @latexerr\endcsname\relax
249 \box\pst@hbox
250 \else% do we have LaTeX?
251 \fboxsep=0pt
252 \fbox{\rule[-\pst@shift]{0pt}{\ht\pst@hbox}\rule{\wd\pst@hbox}{0pt}}%
253 \fi
254 \else
255 \box\pst@hbox
256 \fi
257 \endgroup
258 \psset[pstricks]{shift=0}% reset value
259 }
260 %
261 \@namedef{pspicture*}{\pspicture*}
262 \@namedef{endpspicture*}{\endpspicture}
263 %
264 %