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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
include <gio.h>
include <gset.h>
include "wcslab.h"
include "wcs_desc.h"
# Define the memory structure for saving the graphics wcs.
define SAVE_BLOCK_SIZE 16
define OLD_NDC_VIEW Memr[P2R(wcs_save_block-1+$1)]
define OLD_NDC_WIND Memr[P2R(wcs_save_block+3+$1)]
define OLD_PLT_VIEW Memr[P2R(wcs_save_block+7+$1)]
define OLD_PLT_WIND Memr[P2R(wcs_save_block+11+$1)]
# WL_WCSLAB -- Label using a defined wcs.
#
# Description
# This routine uses the information in the WCSLAB descriptor to perform
# labelling.
#
# Before this routine can be called, several things must have already
# occured. They are as follows:
# 1 A call to wl_create must be made to create the WCSLAB descriptor.
# 2 The WCS_MW component must be set to the MWCS object of the
# desired transformations.
# 3 A call to wl_get_system_type must be made.
# 4 The graphics device must have been opened and the window defined.
# The WCS_GP component of the WCSLAB descriptor must be set to the
# graphics window descriptor.
#
# When done with this routine, the WL_GP and WL_MW components must be
# deallocated seperately. Then only wlab_destroy need be called to
# remove the WCSLAB descriptor.
#
#---------------------------------------------------------------------------
procedure wl_wcslab (wd)
pointer wd # I: the WCSLAB descriptor
int old_clip, old_pltype, old_txquality, old_wcs
pointer sp, wcs_save_block
real old_plwidth, old_txsize, old_txup
int gstati()
real gstatr()
begin
# Allocate working space.
call smark(sp)
call salloc(wcs_save_block, SAVE_BLOCK_SIZE, TY_STRUCT)
# Store certain graphics parameters.
old_plwidth = gstatr (WL_GP(wd), G_PLWIDTH)
old_txsize = gstatr (WL_GP(wd), G_TXSIZE)
old_txup = gstatr (WL_GP(wd), G_TXUP)
old_clip = gstati (WL_GP(wd), G_CLIP)
old_pltype = gstati (WL_GP(wd), G_PLTYPE)
old_txquality= gstati (WL_GP(wd), G_TXQUALITY)
old_wcs = gstati (WL_GP(wd), G_WCS)
# Choose two other graphics wcs' for internal use. Save the wcs for
# later restoration.
if( old_wcs < MAX_WCS - 2 ) {
WL_NDC_WCS(wd) = old_wcs + 1
WL_PLOT_WCS(wd) = WL_NDC_WCS(wd) + 1
} else {
WL_NDC_WCS(wd) = old_wcs - 1
WL_PLOT_WCS(wd) = WL_NDC_WCS(wd) - 1
}
call gseti(WL_GP(wd), G_WCS, WL_NDC_WCS(wd))
call ggview(WL_GP(wd), OLD_NDC_VIEW(LEFT), OLD_NDC_VIEW(RIGHT),
OLD_NDC_VIEW(BOTTOM), OLD_NDC_VIEW(TOP))
call ggwind(WL_GP(wd), OLD_NDC_WIND(LEFT), OLD_NDC_WIND(RIGHT),
OLD_NDC_WIND(BOTTOM), OLD_NDC_WIND(TOP))
call gseti(WL_GP(wd), G_WCS, WL_PLOT_WCS(wd))
call ggview(WL_GP(wd), OLD_PLT_VIEW(LEFT), OLD_PLT_VIEW(RIGHT),
OLD_PLT_VIEW(BOTTOM), OLD_PLT_VIEW(TOP))
call ggwind(WL_GP(wd), OLD_PLT_WIND(LEFT), OLD_PLT_WIND(RIGHT),
OLD_PLT_WIND(BOTTOM), OLD_PLT_WIND(TOP))
# Set the graphics device the way wcslab requires it.
call gseti (WL_GP(wd), G_WCS, old_wcs)
call wl_graphics (wd)
# Determine basic characteristics of the plot.
call wl_setup (wd)
# Plot the grid lines.
call wl_grid (wd)
# Put the grid labels on the lines.
if (WL_LABON(wd) == YES)
call wl_label (wd)
# Restore the original graphics wcs.
call gseti(WL_GP(wd), G_WCS, WL_NDC_WCS(wd))
call gsview(WL_GP(wd), OLD_NDC_VIEW(LEFT), OLD_NDC_VIEW(RIGHT),
OLD_NDC_VIEW(BOTTOM), OLD_NDC_VIEW(TOP))
call gswind(WL_GP(wd), OLD_NDC_WIND(LEFT), OLD_NDC_WIND(RIGHT),
OLD_NDC_WIND(BOTTOM), OLD_NDC_WIND(TOP))
call gseti(WL_GP(wd), G_WCS, WL_PLOT_WCS(wd))
call gsview(WL_GP(wd), OLD_PLT_VIEW(LEFT), OLD_PLT_VIEW(RIGHT),
OLD_PLT_VIEW(BOTTOM), OLD_PLT_VIEW(TOP))
call gswind(WL_GP(wd), OLD_PLT_WIND(LEFT), OLD_PLT_WIND(RIGHT),
OLD_PLT_WIND(BOTTOM), OLD_PLT_WIND(TOP))
# Restore original graphics state.
call gsetr (WL_GP(wd), G_PLWIDTH, old_plwidth)
call gsetr (WL_GP(wd), G_TXSIZE, old_txsize)
call gsetr (WL_GP(wd), G_TXUP, old_txup)
call gseti (WL_GP(wd), G_CLIP, old_clip)
call gseti (WL_GP(wd), G_PLTYPE, old_pltype)
call gseti (WL_GP(wd), G_TXQUALITY, old_txquality)
call gseti (WL_GP(wd), G_WCS, old_wcs)
call sfree (sp)
end
# WL_GRAPHICS -- Setup the graphics device appropriate for the occasion.
procedure wl_graphics (wd)
pointer wd # I: the WCSLAB descriptor
real relative_size, vl, vr, vb, vt
real ggetr()
begin
# Setup a graphics WCS that mimics the NDC coordinate WCS,
# but with clipping.
call ggview (WL_GP(wd), vl, vr, vb, vt)
call gseti (WL_GP(wd), G_WCS, WL_NDC_WCS(wd))
call gsview (WL_GP(wd), vl, vr, vb, vt)
call gswind (WL_GP(wd), vl, vr, vb, vt)
call gseti (WL_GP(wd), G_CLIP, YES)
# Setup the initial viewport.
WL_NEW_VIEW(wd,LEFT) = vl
WL_NEW_VIEW(wd,RIGHT) = vr
WL_NEW_VIEW(wd,BOTTOM) = vb
WL_NEW_VIEW(wd,TOP) = vt
# Setup some parameters.
call gseti (WL_GP(wd), G_PLTYPE, GL_SOLID)
call gsetr (WL_GP(wd), G_PLWIDTH, LINE_SIZE)
# Draw the edges of the viewport.
call gamove (WL_GP(wd), vl, vb)
call gadraw (WL_GP(wd), vr, vb)
call gadraw (WL_GP(wd), vr, vt)
call gadraw (WL_GP(wd), vl, vt)
call gadraw (WL_GP(wd), vl, vb)
# Determine the tick mark size.
relative_size = max (abs (vr - vl), abs (vt - vb ))
WL_MAJ_TICK_SIZE(wd) = relative_size * WL_MAJ_TICK_SIZE(wd)
WL_MIN_TICK_SIZE(wd) = relative_size * WL_MIN_TICK_SIZE(wd)
# Determine various character sizes.
WL_TITLE_SIZE(wd) = WL_TITLE_SIZE(wd) * relative_size
WL_AXIS_TITLE_SIZE(wd) = WL_AXIS_TITLE_SIZE(wd) * relative_size
WL_LABEL_SIZE(wd) = WL_LABEL_SIZE(wd) * relative_size
# Now setup the general plotting WCS.
call gseti (WL_GP(wd), G_WCS, WL_PLOT_WCS(WD))
call gsview (WL_GP(wd), vl, vr, vb, vt)
vl = real (WL_SCREEN_BOUNDARY(wd,LEFT))
vr = real (WL_SCREEN_BOUNDARY(wd,RIGHT))
vb = real (WL_SCREEN_BOUNDARY(wd,BOTTOM))
vt = real (WL_SCREEN_BOUNDARY(wd,TOP))
call gswind (WL_GP(wd), vl, vr, vb, vt)
call gseti (WL_GP(wd), G_CLIP, YES)
# Set some characteristics of the graphics device.
call gseti (WL_GP(wd), G_TXQUALITY, GT_HIGH)
call gseti (WL_GP(wd), G_CLIP, YES)
call gsetr (WL_GP(wd), G_PLWIDTH, LINE_SIZE)
# Determine the number of segments a "line" should consist of.
WL_LINE_SEGMENTS(wd) = int (min (ggetr (WL_GP(wd), "xr"),
ggetr (WL_GP(wd), "yr")) / 5)
end
|