File: Prolog.ps

package info (click to toggle)
dstooltk 2.0-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,520 kB
  • ctags: 3,169
  • sloc: ansic: 27,185; tcl: 4,770; makefile: 588; sh: 81; csh: 7
file content (148 lines) | stat: -rw-r--r-- 7,139 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
% Prolog.ps
% Define plotting symbols.
% Symbols are defined in two parts: a "glyph" which is an absolute symbol, and the command 
% for plotting the glyph, which scales the glyph into user coordinates.
% To make symbols have different linewidths, uncomment the commands "linewidth setlinewidth" 
% and replace it with something like "0.1 setlinewidth".  
% Also, boxes and triangles can be filled in by adding the command
% "fill" instead of the "stroke" command.
% First, we define the glyphs...
/Boxglyph {newpath dup scale %linewidth setlinewidth
0.5 0.5 moveto -0.5 0.5 lineto -0.5 -0.5 lineto 0.5 -0.5 lineto 0.5 0.5 lineto
closepath stroke} def

/Triangleglyph {newpath dup scale %linewidth setlinewidth
0 1 moveto 0.866 -0.5 lineto -0.866 -0.5 lineto closepath stroke} def

/Circleglyph {newpath dup scale %linewidth setlinewidth
0 0 0.5 0 360 arc fill} def

/Crossglyph {newpath dup scale %linewidth setlinewidth
0.75 0 moveto -0.75 0 lineto 0 0.75 moveto 0 -0.75 lineto stroke} def

% Now define the symbol commands...
% procedure to draw a box.  Called as:  x y scalefactor Box --
/Box{3 1 roll moveto currentpoint gsave translate
xscalei yscalei scale Boxglyph grestore }def

% procedure to draw a triangle.  Called as:  x y scalefactor Triangle --
/Triangle{3 1 roll moveto currentpoint gsave translate
xscalei yscalei scale Triangleglyph grestore }def

% procedure to draw a cross.  Called as:  x y scalefactor Cross --
/Cross{3 1 roll moveto currentpoint gsave translate
xscalei yscalei scale Crossglyph grestore }def

% procedure to draw a dot.  Called as:  x y scalefactor Dot --
/Dot{3 1 roll moveto currentpoint gsave translate
xscalei yscalei scale Circleglyph grestore }def

% procedure to draw a line to a symbol.  Called as:  x y Line x y
/Line{linewidth 8 div setlinewidth lineto currentpoint stroke} def

% draws ticks on the bounding box. Called as: num_x_ticks num_y_ticks Ticks --
% For thicker tick marks, uncomment the end of the first line
/Ticks{ gsave % 1 setlinewidth
   1 add yBBoxSide exch div dup
   0 0        moveto   dup yBBoxSide{0 exch moveto TickSize 0 rlineto}for %left
   xBBoxSide 0 moveto  dup yBBoxSide{xBBoxSide exch moveto TickSize neg 0 rlineto}for %rt
   1 add xBBoxSide exch div dup
   0 0        moveto   dup xBBoxSide{0 moveto 0 TickSize rlineto}for %bottom
   0 yBBoxSide moveto  dup xBBoxSide{yBBoxSide moveto 0 TickSize neg rlineto}for %top
   stroke grestore 	}def
% draws grid on the bounding box. Called as: num_x_ticks num_y_ticks Grid --
% For thicker tick marks, uncomment the end of the first line
/Grid{ gsave % 1 setlinewidth
   1 add yBBoxSide exch div
   0 0        moveto   dup yBBoxSide{0 exch moveto xBBoxSide 0 rlineto}for % left to right
   1 add xBBoxSide exch div
   0 0        moveto   dup xBBoxSide{0 moveto 0 yBBoxSide rlineto}for % bottom to top
   stroke grestore 	}def
% draws box of sidelength (xBBoxSide, yBBoxSide) beginning at origin
/BoundingBox{ gsave 1 setlinewidth
	0 0 moveto xBBoxSide 0 rlineto 0 yBBoxSide rlineto xBBoxSide neg 0 rlineto
   	closepath stroke grestore }def
% macros for string positioning and manipulation
/Display{0 Yp moveto show /Yp Yp HeadPtSize sub def }def	% display header info
% centers arbitrary string at current point. Called as: (str) CenterString (str)
/CenterString { dup stringwidth pop 2 div currentpoint 3 -2 roll exch sub exch moveto }def
% vertically centers string at current point. Called as:fontheight (str) VCenterString (str)
/VCenterString{dup length .5 add 2 div 3 -1 roll mul currentpoint 3 -1 roll add moveto }def
% prints figure titles centered at given pt
% requires: CenterString; TitlePtSize; TitleFont
% called as: x y (title) (caption) FigureTitle --
/FigureTitle { gsave TitleFont setfont 	4 2 roll moveto
   	gsave exch CenterString show grestore
   	currentpoint TitlePtSize sub moveto CenterString show grestore	}def
% prints x-axis label
% requires: CenterString; LabelPtSize; LabelFont
% called as: (label) XLabel --
/XLabel { gsave LabelFont setfont 
	xBBoxSide 2 div LabelPtSize -3 mul moveto CenterString show grestore }def
% prints y-axis label horizontally
% requires: CenterString; LabelFont
% called as: (label) HorYLabel --
/HorYLabel { gsave LabelFont setfont 
	dup stringwidth pop -2 div HorSpace 2 mul sub yBBoxSide 2 div moveto
   	CenterString show grestore }def
% prints list of n strings along x axis at evenly spaced intervals
% requires: LabelFont; LabelPtSize; CenterString
% called as: (s_1) (s_2) ... (s_n) n PlaceXLabels --
/PlaceXLabels { gsave LabelFont setfont 
	dup 1 le { % if n==1, center string
		pop xBBoxSide 2 div LabelPtSize -1.5 mul moveto CenterString show
		 } 
		{ % else place labels at intervals of length xBBoxSide/(n-1)
		1 sub xBBoxSide exch div      % set length
		-1 mul xBBoxSide exch 0{      % for i=xBBoxside to 0 step (-length)
			LabelPtSize -1.5 mul moveto CenterString show
			}for  
		} ifelse	grestore}def
% prints list of n strings along y axis at evenly spaced intervals
% requires: LabelFont; LabelPtSize;CenterString
% called as: (s_1) (s_2) ... (s_n) n PlaceYLabels --
/PlaceYLabels { gsave LabelFont setfont 
	dup 1 le { % if n==1, center string
		pop dup stringwidth pop -2 div HorSpace sub yBBoxSide 2 div moveto CenterString show
		 } 
		{ % else place labels at intervals of length yBBoxSide/(n-1)
		1 sub yBBoxSide exch div      % set length
		-1 mul yBBoxSide exch 0 {     % for i=yBBoxside to 0 step (-length)
			exch dup stringwidth pop -2 div HorSpace sub 3 -1 roll moveto CenterString show
			}for
		} ifelse	grestore}def
%
% The following macros are not explicitly used by dstool but may be useful
%
% prints y-axis label vertically
% requires: VCenterString; LabelPtSize; LabelFont
% called as: (label) VerYLabel --
/VerYLabel { gsave LabelFont setfont 
	LabelPtSize -1.5 mul yBBoxSide 2 div moveto
   	LabelPtSize exch VCenterString LabelPtSize exch vshow grestore }def
% The following proc is from PostScript Tutorial and Cookbook by Adobe Systems Inc., p. 165
/vshowdict 4 dict def
% called as: vert_space (string) vshow --
/vshow{ vshowdict begin 
	/thestring exch def  /lineskip exch def thestring
    	{ /charcode exch def /thechar ( ) dup 0 charcode put def 0 lineskip neg rmoveto gsave 
        thechar stringwidth pop 2 div neg 0 rmoveto  thechar show  grestore } forall end }def 
% prints annotations on graph. Called as: (label) xpos ypos Annotation --
% requires: CenterString; LabelPtSize; LabelFont
% xpos and ypos are between 0 and 1
/Annotation{ gsave LabelFont setfont
	yBBoxSide mul exch xBBoxSide mul exch moveto CenterString show grestore }def

% declare global constants (edit with care).  72 points = 1 inch
/x0 0 def /xf 1 def /y0 0 def /yf 1 def		% dstool scales output into [0,1] x [0,1]
/TickSize 5 def					% size (in pts) of tick marks
/linewidth 0.005 def				% width of line for plotting (smallest resolution=0)
/HeadPtSize 6 def 				% print the header in this font size
/HorSpace 8 def                                 % pts left of BBox for hor labels

/Sm 1 def 					% typical sizes of symbols
/Md 2 def 
/Lg 4 def 
/XL 6 def

% The below are model-specific definitions. Written by dstool.