1 %% $Id: pst-tools.tex 599 2011-11-03 19:38:28Z herbert $
3 %% This is file `pst-tools.tex',
7 %% Package `pst-tools.tex'
9 %% Herbert Voss <hvoss@tug.org>
11 %% This program can be redistributed and/or modified under the terms
12 %% of the LaTeX Project Public License Distributed from CTAN archives
13 %% in directory macros/latex/base/lppl.txt.
16 %% `pst-tools' is a PSTricks package for helper functions
19 \csname PSTtoolsLoaded
\endcsname
20 \let\PSTtoolsLoaded\endinput
22 \ifx\PSTricksLoaded\endinput\else\input pstricks.tex
\fi
23 \ifx\PSTXKeyLoaded\endinput\else \input pst-xkey.tex
\fi
25 \edef\PstAtCode{\the\catcode`\@
} \catcode`\@=
11\relax
26 % interface to the `xkeyval' package
27 \pst@addfams
{pst-tools
}
30 \def\filedate{2012/
01/
01}
31 \message{`PST-tools' v
\fileversion,
\filedate\space (hv)
}
33 \define@boolkey
[psset
]{pst-tools
}[Pst@
]{dot
}[true
]{}
34 \define@key
[psset
]{pst-tools
}{xShift
}[0]{\def\psk@xShift
{#1}}
35 \define@key
[psset
]{pst-tools
}{PSfont
}[Times-Roman
]{\def\psk@PSfont
{/
#1 }}
36 \define@key
[psset
]{pst-tools
}{valuewidth
}[10]{\pst@getint
{#1}\psk@valuewidth
}
37 \define@key
[psset
]{pst-tools
}{fontscale
}[10]{\pst@checknum
{#1}\psk@fontscale
}
38 \define@key
[psset
]{pst-tools
}{decimals
}[-
1]{\pst@getint
{#1}\psk@decimals
}
39 \psset[pst-tools
]{PSfont=Times-Roman,fontscale=
10,valuewidth=
10,decimals=-
1,xShift=
0,dot
}
41 \def\psPrintValue{\pst@object
{psPrintValue
}}
42 \def\psPrintValue@i
#1{\expandafter\psPrintValue@ii
#1,,\@nil
}
43 \def\psPrintValue@ii
#1,
#2,
#3\@nil
{% #1,#2 only for algebraic code
46 gsave
\psk@PSfont findfont
\psk@fontscale scalefont setfont
49 /Func (
#2) tx@AlgToPs begin AlgToPs end cvx def
52 \psk@decimals -
1 gt
{ 10 \psk@decimals exp dup
3 1 roll mul cvi exch div
} if
53 \psk@valuewidth string cvs
%/Output exch def % save output
54 \ifPst@dot dot2comma
\fi % do we have to change dot to comma
55 \psk@xShift
\space 0 moveto
%Output
61 \define@boolkey
[psset
]{pst-tools
}[Pst@
]{round
}[true
]{}%
62 \define@boolkey
[psset
]{pst-tools
}[Pst@
]{science
}[true
]{%
63 \ifPst@science
\def\psk@Scin
{true
}\else\def\psk@Scin
{false
}\fi}
64 \psset[pst-tools
]{science=false,round=false
}
65 \def\psPrintValueNew{\pst@object
{psPrintValueNew
}}
66 \def\psPrintValueNew@i
#1{\expandafter\psPrintValueNew@ii
#1,,\@nil
}
67 \def\psPrintValueNew@ii
#1,
#2,
#3\@nil
{% #1,#2 only for algebraic code
69 \addto@pscode
{ % thanks to Buddy Ledger
70 /mfont
{ \psk@PSfont findfont
\psk@fontscale scalefont setfont
} bind def
71 /mfontexp
{ \psk@PSfont findfont
\psk@fontscale
1.2 div scalefont setfont
} bind def
72 /s1
{ /Symbol findfont
\psk@fontscale scalefont setfont
} bind def
75 /Func (
#2) tx@AlgToPs begin AlgToPs end cvx def
80 value
0 ne
{ value log floor cvi /expon ED
}{ /expon
0 def
} ifelse
81 value
10 expon exp div
82 \psk@decimals -
1 gt
{ 10 \psk@decimals exp dup
3 1 roll mul
83 \ifPst@round round
\else cvi
\fi exch div
} if
84 \psk@decimals
0 eq
{ cvi
} if /numb ED
85 expon
\psk@valuewidth string cvs /expon exch def
86 numb
\psk@valuewidth string cvs
87 \ifPst@dot dot2comma
\fi % do we have to change dot to comma
89 /txspc
\psk@fontscale
4 div def
90 \psk@xShift
\space 0 moveto mfont Output show
91 txspc
0 rmoveto s1 (
\string\264) show
92 txspc
0 rmoveto mfont (
10) show
93 txspc
2 div txspc
1.5 mul rmoveto mfontexp expon show
}
95 \psk@decimals -
1 gt
{ 10 \psk@decimals exp dup
3 1 roll mul
96 \ifPst@round round
\else cvi
\fi exch div
} if
97 \psk@decimals
0 eq
{ cvi
} if
%inserted to handle decimals=0
98 \psk@valuewidth string cvs
99 \ifPst@dot dot2comma
\fi % do we have to change dot to comma
100 \psk@xShift
\space 0 moveto mfont
%Output
107 \catcode`\@=
\PstAtCode\relax
109 %% END: pst-tools.tex