%!PS-Adobe-3.0
%%Title: outil.ps
%%Creator: Pierre Juillot, IPHC, Strasbourg (France)
%%CreationDate: vendredi, 25 septembre 2009 23:19:54
%%EndComments
initgraphics                    % remove for EPS
clippath                        % default printable zone
pathbbox                        % corresponding rectangle
% the names correspond to AFTER transl. + rot.
/urx exch def                   % Xmin [or /urx 862 def ]
/ury exch def                   % Xmax [or /ury 562 def ]
/llx exch def                   % Ymin [or /lly 0 def ]
/lly exch def                   % Ymax [or /llx 0 def ]
0 urx translate                 % translate origin
-90 rotate                      % and rotate it
true setstrokeadjust            % automatic stroke adjustment
/cm { 72 mul 2.54 div } def     % define centimeters in PS units
/Center                         % pile: (string) x y
 { moveto dup stringwidth pop 2 div neg 0 rmoveto } def
/reEncode                        % pile : font, encoding array
{ exch findfont                  % retrieve the font dictionnary
 dup length dict begin           % make a writable copy (read-only!)
 { 1 index /FID eq               % remove the FID key, if any
  {pop pop} {def} ifelse } forall
 /Encoding exch def
 currentdict end                 % reEncoding only: leave UniqueID and XUID
 dup /FontName get exch          % get FontName entry
 definefont pop                  % save the new encoded font in FontName
} def
/Alignr                          % pile: (toto) x y Alignr
   {moveto dup stringwidth pop neg 0 rmoveto} def
%   -- end of procedures --

% define width L and height l from hardware values
urx llx sub /L exch def          % total width
ury lly sub /l exch def          % total height
/fn /Times-Roman def             % font name
/chhe l 43 div def               % font size = f(l)
fn ISOLatin1Encoding reEncode    % ISOLatin1 encoding
fn chhe selectfont               % font for numbers printing
/car 6 string def                % string to print numbers
/thick 0.75 def                  % line width for thick lines
/middle 0.25 def                 % line width for middle lines
/thin 0 def                      % line width for thin lines
/tick_5 0.2 def                  % length of all ticks
/tick_1 0.05 def                 % length of ticks at 5°
% there are four quantities on which one can play:
% two on the planchette A,
% yc= fa1*l % the y-coordinate of the center of the circle
% r = fa2*l % the radius of the circle on pl. A
 /fa1 0.20 def
 /fa2 0.40 def
% two on the planchette B,
% cn = fb1*l % the y-size of the 1/2 circle on pl. B
% r = fb2*l % the radius of the 1/2 circle as a fraction of cn
  /fb1 0.55 def
  /fb2 0.85 def
  /cn fb1 l mul def                % compute cn used on both pl.
% planchette A ---------------------------------------------
/xc llx urx add 2 div def          % x of center of circle on pl. A
/yc l fa1 mul def                  % y of center of circle on pl. A
/r l fa2 mul def                   % radius of circle on pl.A
newpath xc 0 moveto 0 ury rlineto stroke % vertical line at middle
newpath 0 yc moveto urx 0 rlineto stroke % horizontal line at middle
xc yc translate                          % xc,yc space
thick setlinewidth                       % thick circle
newpath 0 0 r 0 360 arc stroke           % draw circle
/rb r 1.10 mul def                       % r of print angle value
0 1 180 {                                % loop on all angles in 1/2 circle
 /ang exch def                           % capture loop index in ang
 gsave                                   % save graphical state
  ang rotate                             % rotate by ang degrees
% 1. thin line on all degrees
thin setlinewidth
newpath r 0 moveto r tick_1 mul neg 0 rlineto stroke % small tick
newpath r neg 0 moveto r tick_1 mul 0 rlineto stroke % opposite small tick
% 2. multiple of 5°
  ang 5 mod 0 eq {                       % we are on multiple of 5°
  middle setlinewidth
  newpath r 0 moveto r tick_5 mul neg 0 rlineto stroke % middle tick
  newpath r neg 0 moveto r tick_5 mul 0 rlineto stroke % opposite middle tick
  }if
% 3. genuine hours: draw diameter
 ang 15 mod 0 eq {                       % we on a genuine hour
  newpath r neg 0 moveto r 2 mul 0 rlineto stroke % draw diameter
% print angle value and W/E
 ang 90 lt { /barat ang car cvs def /we (W) def
 }{ /barat 180 ang sub car cvs def /we (E) def
 } ifelse
 ang 90 mod 0 eq {/we () def} if            % no W/E for 90,180,270,360
 barat rb 0 Alignr show (\232) show we show % print
 ang 0 ne ang 180 ne and                    % except 0° and 180°
 {barat rb neg 0 Alignr show (\232) show we show} if % print at opposite point
 }if
grestore
} for                                        % end of loop on all angles
% now draw latitude lines
 44 1 50 {                                   % loop on latitudes
  /latitude exch def                         % capture latitude
  /rl cn latitude sin div def                % radius of latitude circle
  newpath 0 0 rl 0 360 arc stroke            % draw circle of latitude
 % print latitude
 /barat latitude car cvs def
  barat
  2                                          % even
  latitude 2 mod 0 eq {neg}if                % off
  sin rl mul rl chhe 2 div sub Center show (\232) show
   } for                                     % end of loop on latitudes
showpage
% planchette B ---------------------------------------------
%xc % xc = x of center of circle = same
/r cn fb2 mul def                            % radius of 1/2 cercle
/hiver_ete {                                 % assume 1=ete, 2 = hiver
 /he exch def                                % capture argument
 newpath 0 cn moveto urx 0 rlineto stroke    % horizontal middle line
 newpath xc 0 moveto xc ury lineto stroke    % vertical middle line
 newpath xc cn r 0 180 arcn stroke           % draw the 1/2 cercle
 xc cn translate                             % work in xc cn space
 fn chhe 2 mul selectfont                    % font for title
 he 1 eq {/title (\311T\311) def }{/title (HIVER) def} ifelse % title
 title 0 cn 0.05 mul Center show             % print title
 fn chhe selectfont                          % font for numbers
 /rb r 0.80 mul def                          % r of hours
-144 1 0 {                                   % loop on 5 min values
 /i exch def                                 % capture index
 /ang i 1.25 mul def                         % compute angle
 gsave
 ang rotate
 % 1. draw 3 min. ticks
 thin setlinewidth
 newpath r 0 moveto 1.05 r mul 0 lineto stroke
% 2. draw 1/4 hour ticks
 i 3 mod 0 eq {                              % we are on multiple of 1/4 hour
   middle setlinewidth
   newpath r 0 moveto 2 r mul 0 lineto stroke
  } if
% 3. draw hour radiuses
 i 12 mod 0 eq {                             % we are on hours
 thick setlinewidth
 newpath r 0 moveto 0 0 lineto stroke
 /barat                                     % numbering depend on hiver/ete
 he 1 eq {i 12 div neg 6 add}{i 12 div 18 add} ifelse %
 cvi car cvs def 
 r 0.9 mul r 0.01 mul moveto
 barat show ( h) show
  } if
grestore
 } for                                       % end of loop on 5 min. values
showpage
} def
initgraphics    % remove for EPS
clippath        % default printable zone
pathbbox        % corresponding rectangle
/urx exch def   % Xmin [or /urx 862 def ]
0 urx translate % translate origin
-90 rotate      % and rotate it
gsave
 1 hiver_ete    % execute for ete
grestore
 2 hiver_ete    % execute for hiver