ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/macplot.c
Revision: 1.1
Committed: Sat Feb 22 02:07:26 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R6P1, rad3R5, rad3R6
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id$";
3 #endif
4 /*
5 * Plotting routines for MacIntosh
6 */
7
8
9 #include "meta.h"
10
11 #include "macplot.h"
12
13
14 #define NPATS 9 /* number of fill patterns */
15
16
17 int pati[4] = {0, 1, 2, 3}; /* pattern indices */
18
19 /*
20 * Patterns are 8 X 8, ordered left column to right, one byte per column.
21 */
22
23 Pattern macpat[NPATS+4] = {
24 {0377,0377,0377,0377,0377,0377,0377,0377}, /* solid */
25 {0217,0307,0343,0361,0370,0174,076,037}, /* thick \\\ (dashed) */
26 {0231,0314,0146,063,0231,0314,0146,063}, /* thin \\\ (dotted) */
27 {0201,0300,0140,060,030,014,06,03}, /* sparse \\\ */
28 {037,076,0174,0370,0361,0343,0307,0217}, /* thick /// (dashed) */
29 {063,0146,0314,0231,063,0146,0314,0231}, /* thin /// (dotted) */
30 {03,06,014,030,060,0140,0300,0201}, /* sparse /// */
31 {0201,0102,044,030,030,044,0102,0201}, /* crisscross */
32 {0201,0101,041,021,011,05,03,0377} /* web */
33 };
34
35 static int context = 0;
36
37 struct setting {
38 int cnx; /* setting context */
39 char *val; /* attribute value */
40 struct setting *snext; /* next setting in list */
41 };
42
43 static struct setting *sets[0200];
44
45
46
47
48 set(attrib, value) /* set attribute to value */
49
50 int attrib;
51 char *value;
52
53 {
54 struct setting *newset;
55
56 switch (attrib) {
57 case SALL:
58 context++;
59 return;
60 case SPAT0:
61 case SPAT1:
62 case SPAT2:
63 case SPAT3:
64 if (!spat(attrib, value)) {
65 sprintf(errmsg, "Bad pattern set value: %s", value);
66 error(WARNING, errmsg);
67 return;
68 }
69 break;
70 default:
71 sprintf(errmsg, "Can't set attribute: %o", attrib);
72 error(WARNING, errmsg);
73 return;
74 }
75 newset = (struct setting *)malloc(sizeof(struct setting));
76 newset->cnx = context;
77 newset->val = savestr(value);
78 newset->snext = sets[attrib];
79 sets[attrib] = newset;
80 }
81
82
83
84
85 unset(attrib) /* return attribute to previous setting */
86
87 int attrib;
88
89 {
90 register int i;
91
92 if (attrib == SALL) {
93 if (context == 0)
94 reset(SALL);
95 else {
96 context--;
97 for (i = 0; i < 0200; i++)
98 while (sets[i] != NULL && sets[i]->cnx > context)
99 spop(i);
100 }
101 return;
102 }
103 spop(attrib);
104 if (sets[attrib] == NULL)
105 reset(attrib);
106
107 switch (attrib) {
108 case SPAT0:
109 case SPAT1:
110 case SPAT2:
111 case SPAT3:
112 spat(attrib, sets[attrib]->val);
113 break;
114 default:
115 sprintf(errmsg, "Can't unset attribute: %o", attrib);
116 error(WARNING, errmsg);
117 return;
118 }
119 }
120
121
122
123
124
125 reset(attrib) /* return attribute to default setting */
126
127 int attrib;
128
129 {
130 switch (attrib) {
131 case SALL:
132 reset(SPAT0);
133 reset(SPAT1);
134 reset(SPAT2);
135 reset(SPAT3);
136 context = 0;
137 return;
138 case SPAT0:
139 spat(SPAT0, "P0");
140 break;
141 case SPAT1:
142 spat(SPAT1, "P1");
143 break;
144 case SPAT2:
145 spat(SPAT2, "P2");
146 break;
147 case SPAT3:
148 spat(SPAT3, "P3");
149 break;
150 default:
151 sprintf(errmsg, "Can't reset attribute: %o", attrib);
152 error(WARNING, errmsg);
153 return;
154 }
155 while (sets[attrib] != NULL)
156 spop(attrib);
157 }
158
159
160
161
162 static
163 spop(attrib) /* pop top off attrib settings list */
164
165 int attrib;
166
167 {
168
169 if (sets[attrib] != NULL) {
170 if (sets[attrib]->val != NULL)
171 free(sets[attrib]->val);
172 free((char *)sets[attrib]);
173 sets[attrib] = sets[attrib]->snext;
174 }
175
176 }
177
178
179
180
181 static int
182 spat(pat, patval) /* set a pattern */
183
184 int pat;
185 char *patval;
186
187 {
188 int n, v;
189 char *nextscan();
190 register char *cp;
191 register int j;
192
193 if (patval == NULL) return(FALSE);
194
195 if (patval[0] == 'P' || patval[0] == 'p') {
196 if (nextscan(patval+1, "%d", &n) == NULL || n < 0 || n >= NPATS)
197 return(FALSE);
198 } else {
199 n = NPATS + pat - SPAT0;
200 cp = patval;
201 for (j = 0; j < 8; j++) {
202 if ((cp = nextscan(cp, "%o", &v)) == NULL || v < 0 || v > 0377)
203 return(FALSE);
204 macpat[n][j] = v;
205 }
206 }
207 pati[pat-SPAT0] = n;
208 return(TRUE);
209 }