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 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <mach.h>
include <gset.h>
include <gio.h>
# GRESET -- Initialize the internal state variables of GIO to their default
# values. Called upon startup and by GCANCEL and GCLEAR.
procedure greset (gp, flags)
pointer gp #I graphics descriptor
int flags #I flags indicating what to reset
int color, ch, i
real char_height, aspect
bool reset_wcs, reset_gio, reset_glabax
pointer sp, glbcolor, param, w, ap, ax, ax1, ax2, ip, op
bool streq()
real ggetr()
int envfind(), ctoi(), strncmp()
define next_ 91
errchk ggetr
begin
call smark (sp)
call salloc (glbcolor, SZ_LINE, TY_CHAR)
call salloc (param, SZ_FNAME, TY_CHAR)
# Initialize for a new frame; this is always done.
call gfrinit (gp)
reset_glabax = (and (flags, GR_RESETGLABAX) != 0)
reset_wcs = (and (flags, GR_RESETWCS) != 0)
reset_gio = (and (flags, GR_RESETGIO) != 0)
# Reset general GIO device and drawing parameters?
if (reset_gio) {
GP_CURSOR(gp) = 1
# All default sizes in NDC units are scaled to the height of a
# device character.
char_height = ggetr (gp, "ch")
if (char_height < EPSILON)
char_height = DEF_CHARHEIGHT
aspect = ggetr (gp, "ar")
if (aspect < EPSILON)
aspect = 1.0
GP_DEVASPECT(gp) = aspect
# Set default marker sizes.
do i = 1, 4
GP_SZMARKER(gp,i) = (char_height * i) / 4.0
# Set polyline attributes.
ap = GP_PLAP(gp)
PL_LTYPE(ap) = 1
PL_WIDTH(ap) = 1.0
PL_COLOR(ap) = 1
# Set polymarker attributes.
ap = GP_PMAP(gp)
PM_LTYPE(ap) = 1
PM_WIDTH(ap) = 1.0
PM_COLOR(ap) = 1
# Set fill area attributes.
ap = GP_FAAP(gp)
FA_STYLE(ap) = 1
FA_COLOR(ap) = 1
# Set default text attributes.
ap = GP_TXAP(gp)
TX_UP(ap) = 90
TX_SIZE(ap) = 1.0
TX_PATH(ap) = GT_RIGHT
TX_SPACING(ap) = 0.0
TX_HJUSTIFY(ap) = GT_LEFT
TX_VJUSTIFY(ap) = GT_DOWN
TX_FONT(ap) = GT_ROMAN
TX_QUALITY(ap) = GT_NORMAL
TX_COLOR(ap) = 1
}
# Reset GLABAX parameters?
if (reset_glabax) {
# Set general GLABAX parameters.
GP_DRAWTITLE(gp) = YES
GP_TITLESIZE(gp) = 1.0
GP_TITLECOLOR(gp) = 1
GP_TITLEJUST(gp) = GT_CENTER
GP_NTITLELINES(gp) = 0
GP_FRAMECOLOR(gp) = 0
GP_FRAMEDRAWN(gp) = 0
# Set GLABAX parameters for the X and Y axes.
do i = 1, 2 {
if (i == 1)
ax = GP_XAP(gp)
else
ax = GP_YAP(gp)
GL_DRAWAXES(ax) = 3
GL_SETAXISPOS(ax) = NO
GL_AXISPOS1(ax) = 0.0
GL_AXISPOS2(ax) = 0.0
GL_DRAWGRID(ax) = NO
GL_GRIDCOLOR(ax) = 1
GL_ROUND(ax) = NO
GL_LABELAXIS(ax) = YES
GL_AXISLABELSIZE(ax) = 1.0
GL_AXISLABELCOLOR(ax) = 1
GL_DRAWTICKS(ax) = YES
GL_LABELTICKS(ax) = YES
GL_NMAJOR(ax) = 6
GL_NMINOR(ax) = 4
GL_MAJORLENGTH(ax) = 0.6 * char_height
GL_MINORLENGTH(ax) = 0.3 * char_height
GL_MAJORWIDTH(ax) = 2.0
GL_MINORWIDTH(ax) = 2.0
GL_AXISWIDTH(ax) = 2.0
GL_AXISCOLOR(ax) = 1
GL_TICKLABELSIZE(ax) = 1.0
GL_TICKLABELCOLOR(ax) = 1
GL_TICKCOLOR(ax) = 1
GL_TICKFORMAT(ax) = EOS
}
# Correct the default tick length for the aspect ratio.
ax = GP_XAP(gp)
GL_MAJORLENGTH(ax) = GL_MAJORLENGTH(ax) / aspect
GL_MINORLENGTH(ax) = GL_MINORLENGTH(ax) / aspect
# Set user color defaults if specified. This is a simple string
# parameter of the form "pt=i,fr=i,ax=i,..." where I is the color
# index. The actual color corresponding to this index is defined
# externally, e.g. by the graphics server.
if (envfind ("glbcolor", Memc[glbcolor], SZ_LINE) > 0) {
ax1 = GP_XAP(gp)
ax2 = GP_YAP(gp)
for (ip=glbcolor; Memc[ip] != EOS; ) {
# Get color parameter code.
for (op=param; Memc[ip] != EOS &&
Memc[ip] != '=' && Memc[ip] != ':'; ip=ip+1) {
Memc[op] = Memc[ip]
op = op + 1
}
Memc[op] = EOS
ch = Memc[param+2]
# Get color index.
if (Memc[ip] == '=' || Memc[ip] == ':')
ip = ip + 1
if (ctoi (Memc, ip, color) <= 0)
goto next_
# Set parameter. The two character parameter name may
# have an "x" or "y" appended to set only one axis. For
# example, "pt=4,fr=3,ax=1,tk=1,al=5,tl=6". The color
# parameter code names are as follows:
#
# pt plot title
# fr viewport frame
# gr[xy] grid between tick marks
# ax[xy] axis
# al[xy] axis label
# tk[xy] tick
# tl[xy] tick label
#
# The color codes are simple integers corresponding to
# graphics device color codes, e.g. 0, 1, 2, and so on.
if (streq (Memc[param], "pt")) {
GP_TITLECOLOR(gp) = color
} else if (streq (Memc[param], "fr")) {
GP_FRAMECOLOR(gp) = color
} else if (strncmp (Memc[param], "gr", 2) == 0) {
if (ch == EOS || ch == 'x')
GL_GRIDCOLOR(ax1) = color
if (ch == EOS || ch == 'y')
GL_GRIDCOLOR(ax2) = color
} else if (strncmp (Memc[param], "ax", 2) == 0) {
if (ch == EOS || ch == 'x')
GL_AXISCOLOR(ax1) = color
if (ch == EOS || ch == 'y')
GL_AXISCOLOR(ax2) = color
} else if (strncmp (Memc[param], "al", 2) == 0) {
if (ch == EOS || ch == 'x')
GL_AXISLABELCOLOR(ax1) = color
if (ch == EOS || ch == 'y')
GL_AXISLABELCOLOR(ax2) = color
} else if (strncmp (Memc[param], "tk", 2) == 0) {
if (ch == EOS || ch == 'x')
GL_TICKCOLOR(ax1) = color
if (ch == EOS || ch == 'y')
GL_TICKCOLOR(ax2) = color
} else if (strncmp (Memc[param], "tl", 2) == 0) {
if (ch == EOS || ch == 'x')
GL_TICKLABELCOLOR(ax1) = color
if (ch == EOS || ch == 'y')
GL_TICKLABELCOLOR(ax2) = color
}
next_
while (Memc[ip] != EOS && Memc[ip] != ',')
ip = ip + 1
if (Memc[ip] == ',')
ip = ip + 1
}
}
}
# Reset the WCS?
if (reset_wcs) {
GP_WCS(gp) = 1
# Initialize the WCS to NDC coordinates.
do i = 0, MAX_WCS {
w = GP_WCSPTR(gp,i)
WCS_WX1(w) = 0.0
WCS_WX2(w) = 1.0
WCS_WY1(w) = 0.0
WCS_WY2(w) = 1.0
WCS_SX1(w) = 0.0
WCS_SX2(w) = 1.0
WCS_SY1(w) = 0.0
WCS_SY2(w) = 1.0
WCS_XTRAN(w) = LINEAR
WCS_YTRAN(w) = LINEAR
WCS_FLAGS(w) = WF_NEWFORMAT+WF_CLIP
}
}
call sfree (sp)
end
|