source: osm/applications/editors/josm/plugins/smed2/src/seamap/Signals.java@ 30028

Last change on this file since 30028 was 30026, checked in by malcolmh, 11 years ago

save

File size: 23.6 KB
Line 
1/* Copyright 2013 Malcolm Herring
2 *
3 * This is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License.
6 *
7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.
8 */
9
10package seamap;
11
12import java.awt.Color;
13import java.awt.Font;
14import java.awt.geom.*;
15import java.util.ArrayList;
16
17import s57.S57att.Att;
18import s57.S57obj.Obj;
19import s57.S57val.CatROS;
20import seamap.Renderer.LabelStyle;
21import seamap.SeaMap.*;
22import symbols.Beacons;
23import symbols.Topmarks;
24import symbols.Symbols.Delta;
25import symbols.Symbols.Handle;
26
27public class Signals {
28
29 public static void addSignals(Feature feature) {
30 if (feature.objs.containsKey(Obj.FOGSIG)) Signals.fogSignals(feature);
31 if (feature.objs.containsKey(Obj.RTPBCN)) Signals.radarStations(feature);
32 if (feature.objs.containsKey(Obj.RADSTA)) Signals.radarStations(feature);
33 if (feature.objs.containsKey(Obj.RDOSTA)) Signals.radioStations(feature);
34 if (feature.objs.containsKey(Obj.LIGHTS)) Signals.lights(feature);
35 }
36
37 public static void fogSignals(Feature feature) {
38
39 }
40
41 public static void radarStations(Feature feature) {
42 Renderer.symbol(feature, Beacons.RadarStation, null, null, null);
43 ArrayList<CatROS> cats = (ArrayList<CatROS>)Renderer.getAttVal(feature, Obj.RDOSTA, 0, Att.CATROS);
44 String str = "";
45 for (CatROS ros : cats) {
46 switch (ros) {
47 case ROS_OMNI:
48 str += " RC";
49 break;
50 case ROS_DIRL:
51 str += " RD";
52 break;
53 case ROS_ROTP:
54 str += " RW";
55 break;
56 case ROS_CNSL:
57 str += " Consol";
58 break;
59 case ROS_RDF:
60 str += " RG";
61 break;
62 case ROS_QTA:
63 str += " R";
64 break;
65 case ROS_AERO:
66 str += " AeroRC";
67 break;
68 case ROS_DECA:
69 str += " Decca";
70 break;
71 case ROS_LORN:
72 str += " Loran";
73 break;
74 case ROS_DGPS:
75 str += " DGPS";
76 break;
77 case ROS_TORN:
78 str += " Toran";
79 break;
80 case ROS_OMGA:
81 str += " Omega";
82 break;
83 case ROS_SYLD:
84 str += " Syledis";
85 break;
86 case ROS_CHKA:
87 str += " Chiaka";
88 break;
89 case ROS_PCOM:
90 case ROS_COMB:
91 case ROS_FACS:
92 case ROS_TIME:
93 break;
94 case ROS_PAIS:
95 case ROS_SAIS:
96 str += " AIS";
97 break;
98 case ROS_VAIS:
99 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
100 break;
101 case ROS_VANC:
102 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
103 Renderer.symbol(feature, Topmarks.TopNorth, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
104 break;
105 case ROS_VASC:
106 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
107 Renderer.symbol(feature, Topmarks.TopSouth, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
108 break;
109 case ROS_VAEC:
110 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
111 Renderer.symbol(feature, Topmarks.TopEast, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
112 break;
113 case ROS_VAWC:
114 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
115 Renderer.symbol(feature, Topmarks.TopWest, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
116 break;
117 case ROS_VAPL:
118 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
119 Renderer.symbol(feature, Topmarks.TopCan, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
120 break;
121 case ROS_VASL:
122 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
123 Renderer.symbol(feature, Topmarks.TopCone, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
124 break;
125 case ROS_VAID:
126 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
127 Renderer.symbol(feature, Topmarks.TopIsol, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
128 break;
129 case ROS_VASW:
130 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
131 Renderer.symbol(feature, Topmarks.TopSphere, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
132 break;
133 case ROS_VASP:
134 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
135 Renderer.symbol(feature, Topmarks.TopX, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
136 break;
137 case ROS_VAWK:
138 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
139 Renderer.symbol(feature, Topmarks.TopCross, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
140 break;
141 }
142 }
143 if (!str.isEmpty()) Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BR, AffineTransform.getTranslateInstance(-30, -70)));
144 }
145
146 public static void radioStations(Feature feature) {
147
148 }
149
150 public static void lights(Feature feature) {
151
152 }
153
154 private static Point2D.Double radial(Snode centre, double radius, double angle) {
155 Point2D origin = Renderer.context.getPoint(centre);
156 double mile = Renderer.context.getPoint(Renderer.map.new Snode((centre.lat + Math.toRadians(1/60)), centre.lon)).getY() - origin.getY();
157 return new Point2D.Double(origin.getX() - (radius * mile * Math.sin(angle)), origin.getY() - (radius * mile * Math.cos(angle)));
158 }
159/*
160void renderFlare(Item_t *item) {
161 char *col = light_colours[COL_MAG];
162 Obj_t *obj = getObj(item, LIGHTS, 0);
163 Att_t *att;
164 if (((att = getAtt(obj, COLOUR)) != NULL) && (att->val.val.l->next == NULL)) {
165 col = light_colours[att->val.val.l->val];
166 }
167 renderSymbol(item, LIGHTS, "light", "", col, CC, 0, 0, 120);
168}
169
170void renderSector(Item_t *item, int s, char *text, char *style, double offset, int dy) {
171 Obj_t *sector;
172 double start, end;
173 Att_t *att;
174 XY_t p0, p1;
175 double r0, r1;
176 double b0, b1, span;
177 char *col;
178 XY_t pos = findCentroid(item);
179 if ((sector = getObj(item, LIGHTS, s)) != NULL) {
180 strcpy(string1, (att = getAtt(sector, LITRAD)) != NULL ? att->val.val.a : "0.2");
181 if (((att = getAtt(sector, CATLIT)) != NULL) && (testAtt(att, LIT_DIR)) && ((att = getAtt(sector, ORIENT)) != NULL)) {
182 b0 = fmod(540.0 - att->val.val.f, 360.0);
183 if ((att = getAtt(sector, COLOUR)) != NULL) {
184 col = light_colours[att->val.val.l->val];
185 r0 = atof(string1);
186 p0 = radial(pos, r0, b0);
187 printf("<path d=\"M %g,%g L %g,%g\" style=\"fill:none;stroke:#808080;stroke-width:%g;stroke-dasharray:%g\"/>\n",
188 pos.x, pos.y, p0.x, p0.y, (4 * symbolScale[zoom]), (20 * symbolScale[zoom]));
189 start = fmod(b0 + 2.0, 360.0);
190 end = fmod(360.0 + b0 - 2.0, 360.0);
191 Obj_t *adj;
192 for (int i = s-1; i <= s+1; i++) {
193 if (i == s) continue;
194 if ((adj = getObj(item, LIGHTS, i)) == NULL) continue;
195 Att_t *att;
196 if (((att = getAtt(adj, CATLIT)) != NULL) && (testAtt(att, LIT_DIR)) && ((att = getAtt(adj, ORIENT)) != NULL)) {
197 b1 = fmod(540.0 - att->val.val.f, 360.0);
198 if (fabs(b0 - b1) > 180.0) {
199 if (b0 < b1) b0 += 360.0;
200 else b1 += 360.0;
201 }
202 if (fabs(b0 - b1) < 4.0) {
203 if (b1 > b0) start = fmod((720.0 + b0 + b1) / 2.0, 360.0);
204 else end = fmod((720.0 + b0 + b1) / 2.0, 360.0);
205 }
206 }
207 }
208 p0 = radial(pos, r0, start);
209 p1 = radial(pos, r0, end);
210 printf("<path id=\"%d\" d=\"M %g,%g A %g,%g,0,0,1,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g\"/>\n",
211 ++ref, p0.x, p0.y, r0*mile, r0*mile, p1.x, p1.y, col, (20 * symbolScale[zoom]));
212 if (att->val.val.l->next != NULL) {
213 char *col = light_colours[att->val.val.l->next->val];
214 r1 = r0 - (20 * symbolScale[zoom]/mile);
215 p0 = radial(pos, r1, start);
216 p1 = radial(pos, r1, end);
217 printf("<path d=\"M %g,%g A %g,%g,0,0,1,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g\"/>\n",
218 p0.x, p0.y, r1*mile, r1*mile, p1.x, p1.y, col, (20 * symbolScale[zoom]));
219 }
220 }
221 } else if ((att = getAtt(sector, SECTR1)) != NULL) {
222 start = fmod(540.0 - att->val.val.f, 360.0);
223 if ((att = getAtt(sector, SECTR2)) != NULL) {
224 end = fmod(540.0 - att->val.val.f, 360.0);
225 start += start < end ? 360.0 : 0.0;
226 if ((att = getAtt(sector, COLOUR)) != NULL) {
227 char *ttok, *etok;
228 char *radstr = strdup(string1);
229 int arc = 0;
230 col = light_colours[att->val.val.l->val];
231 r0 = 0.0;
232 b0 = b1 = start;
233 for (char *tpl = strtok_r(radstr, ";", &ttok); tpl != NULL; tpl = strtok_r(NULL, ";", &ttok)) {
234 p0 = radial(pos, r0, b0);
235 span = 0.0;
236 char *ele = strtok_r(tpl, ":", &etok);
237 if ((*tpl == ':') && (r0 == 0.0)) {
238 r1 = 0.2;
239 } else if (*tpl != ':') {
240 r1 = atof(tpl);
241 ele = strtok_r(NULL, ":", &etok);
242 }
243 while (ele != NULL) {
244 if (isalpha(*ele)) {
245 if (strcmp(ele, "suppress") == 0) arc = 2;
246 else if (strcmp(ele, "dashed") == 0) arc = 1;
247 else arc = 0;
248 } else {
249 span = atof(ele);
250 }
251 ele = strtok_r(NULL, ":", &etok);
252 }
253 if (span == 0.0) {
254 char *back = (ttok != NULL) ? strstr(ttok, "-") : NULL;
255 if (back != NULL) {
256 span = b0 - end + atof(back);
257 } else {
258 span = b0 - end;
259 }
260 }
261 if (r1 != r0) {
262 p1 = radial(pos, r1, b0);
263 if (!((start == 180.0) && (end == 180.0)))
264 printf("<path d=\"M %g,%g L %g,%g\" style=\"fill:none;stroke:#808080;stroke-width:%g;stroke-dasharray:%g\"/>\n",
265 p0.x, p0.y, p1.x, p1.y, (4 * symbolScale[zoom]), (20 * symbolScale[zoom]));
266 r0 = r1;
267 p0 = p1;
268 }
269 if (span < 0.0) {
270 b1 = end - span;
271 b1 = b1 > b0 ? b0 : b1;
272 b0 = b1;
273 b1 = end;
274 p0 = radial(pos, r0, b0);
275 } else {
276 b1 = b0 - span;
277 b1 = b1 < end ? end : b1;
278 }
279 p1 = radial(pos, r1, b1);
280 if ((b0 == 180.0) && (b1 == 180.0)) {
281 span = 360.0;
282 p1 = radial(pos, r1, b1+0.01);
283 }
284 if (arc == 0) {
285 if (p0.x < p1.x)
286 printf("<path id=\"%d\" d=\"M %g,%g A %g,%g,0,%d,1,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g\"/>\n",
287 ++ref, p0.x, p0.y, r1*mile, r1*mile, span>180.0, p1.x, p1.y, col, (20 * symbolScale[zoom]));
288 else
289 printf("<path id=\"%d\" d=\"M %g,%g A %g,%g,0,%d,0,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g\"/>\n",
290 ++ref, p1.x, p1.y, r1*mile, r1*mile, span>180.0, p0.x, p0.y, col, (20 * symbolScale[zoom]));
291 if (text != NULL) {
292 double chord = sqrt(pow((p0.x - p1.x), 2) + pow((p0.y - p1.y), 2));
293 if ((chord > (strlen(text) * textScale[zoom] * 50)) || ((b0 == 180.0) && (b1 == 180.0)))
294 drawLineText(item, text, style, offset, dy, ref);
295 }
296 } else if (arc == 1) {
297 printf("<path d=\"M %g,%g A %g,%g,0,%d,1,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g;stroke-opacity:0.5;stroke-dasharray:%g\"/>\n",
298 p0.x, p0.y, r1*mile, r1*mile, span>180.0, p1.x, p1.y, col, (10 * symbolScale[zoom]), (30 * symbolScale[zoom]));
299 }
300 if ((arc == 0) && (att->val.val.l->next != NULL)) {
301 char *col = light_colours[att->val.val.l->next->val];
302 double r2 = r1 - (20 * symbolScale[zoom]/mile);
303 XY_t p2 = radial(pos, r2, b0);
304 XY_t p3 = radial(pos, r2, b1);
305 printf("<path d=\"M %g,%g A %g,%g,0,%d,1,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g\"/>\n",
306 p2.x, p2.y, r1*mile, r1*mile, span>180.0, p3.x, p3.y, col, (20 * symbolScale[zoom]));
307 }
308 b0 = b1;
309 if (b0 == end) break;
310 }
311 if (!((start == 180.0) && (end == 180.0)))
312 printf("<path d=\"M %g,%g L %g,%g\" style=\"fill:none;stroke:#808080;stroke-width:%g;stroke-dasharray:%g\"/>\n",
313 pos.x, pos.y, p1.x, p1.y, (4 * symbolScale[zoom]), (20 * symbolScale[zoom]));
314 free(radstr);
315 }
316 }
317 }
318 }
319}
320char *charString(Item_t *item, char *type, int idx) {
321 strcpy(string1, "");
322 Att_t *att = NULL;
323 Obj_t *obj = getObj(item, enumType(type), idx);
324 switch (enumType(type)) {
325 case CGUSTA:
326 strcpy(string1, "CG");
327 if ((obj != NULL) && (att = getAtt(obj, COMCHA)) != NULL)
328 sprintf(strchr(string1, 0), " Ch.%s", stringValue(att->val));
329 break;
330 case FOGSIG:
331 if (obj != NULL) {
332 if ((att = getAtt(obj, CATFOG)) != NULL)
333 strcat(string1, fog_signals[att->val.val.e]);
334 if ((att = getAtt(obj, SIGGRP)) != NULL)
335 sprintf(strchr(string1, 0), "(%s)", stringValue(att->val));
336 else
337 strcat(string1, " ");
338 if ((att = getAtt(obj, SIGPER)) != NULL)
339 sprintf(strchr(string1, 0), "%ss ", stringValue(att->val));
340 if ((att = getAtt(obj, VALMXR)) != NULL)
341 sprintf(strchr(string1, 0), "%sM", stringValue(att->val));
342 }
343 break;
344 case RTPBCN:
345 if (obj != NULL) {
346 if ((att = getAtt(obj, CATRTB)) != NULL)
347 strcat(string1, rtb_map[att->val.val.e]);
348 if ((att = getAtt(obj, SIGGRP)) != NULL)
349 sprintf(strchr(string1, 0), "(%s)", stringValue(att->val));
350 else
351 strcat(string1, " ");
352 if ((att = getAtt(obj, SIGPER)) != NULL)
353 sprintf(strchr(string1, 0), "%ss ", stringValue(att->val));
354 if ((att = getAtt(obj, VALMXR)) != NULL)
355 sprintf(strchr(string1, 0), "%sM", stringValue(att->val));
356 }
357 break;
358 case SISTAT:
359 strcpy(string1, "SS");
360 if (obj != NULL) {
361 if ((att = getAtt(obj, CATSIT)) != NULL)
362 strcat(string1, sit_map[att->val.val.l->val]);
363 if ((att = getAtt(obj, COMCHA)) != NULL)
364 sprintf(strchr(string1, 0), "\nCh.%s", stringValue(att->val));
365 }
366 break;
367 case SISTAW:
368 strcpy(string1, "SS");
369 if (obj != NULL) {
370 if ((att = getAtt(obj, CATSIW)) != NULL)
371 strcat(string1, siw_map[att->val.val.l->val]);
372 if ((att = getAtt(obj, COMCHA)) != NULL)
373 sprintf(strchr(string1, 0), "\nCh.%s", stringValue(att->val));
374 }
375 break;
376 case LIGHTS:
377 {
378 int secmax = countObjects(item, "light");
379 if ((idx == 0) && (secmax > 0)) {
380 struct SECT {
381 struct SECT *next;
382 int dir;
383 LitCHR_t chr;
384 ColCOL_t col;
385 ColCOL_t alt;
386 char *grp;
387 double per;
388 double rng;
389 } *lights = NULL;
390 for (int i = secmax; i > 0; i--) {
391 struct SECT *tmp = calloc(1, sizeof(struct SECT));
392 tmp->next = lights;
393 lights = tmp;
394 obj = getObj(item, LIGHTS, i);
395 if ((att = getAtt(obj, CATLIT)) != NULL) {
396 lights->dir = testAtt(att, LIT_DIR);
397 }
398 if ((att = getAtt(obj, LITCHR)) != NULL) {
399 lights->chr = att->val.val.e;
400 switch (lights->chr) {
401 case CHR_AL:
402 lights->chr = CHR_F;
403 break;
404 case CHR_ALOC:
405 lights->chr = CHR_OC;
406 break;
407 case CHR_ALLFL:
408 lights->chr = CHR_LFL;
409 break;
410 case CHR_ALFL:
411 lights->chr = CHR_FL;
412 break;
413 case CHR_ALFFL:
414 lights->chr = CHR_FFL;
415 break;
416 default:
417 break;
418 }
419 }
420 if ((att = getAtt(obj, SIGGRP)) != NULL) {
421 lights->grp = att->val.val.a;
422 } else {
423 lights->grp = "";
424 }
425 if ((att = getAtt(obj, SIGPER)) != NULL) {
426 lights->per = att->val.val.f;
427 }
428 if ((att = getAtt(obj, VALNMR)) != NULL) {
429 lights->rng = att->val.val.f;
430 }
431 if ((att = getAtt(obj, COLOUR)) != NULL) {
432 lights->col = att->val.val.l->val;
433 if (att->val.val.l->next != NULL)
434 lights->alt = att->val.val.l->next->val;
435 }
436 }
437 struct COLRNG {
438 int col;
439 double rng;
440 } colrng[14];
441 while (lights != NULL) {
442 strcpy(string2, "");
443 bzero(colrng, 14*sizeof(struct COLRNG));
444 colrng[lights->col].col = 1;
445 colrng[lights->col].rng = lights->rng;
446 struct SECT *this = lights;
447 struct SECT *next = lights->next;
448 while (next != NULL) {
449 if ((this->dir == next->dir) && (this->chr == next->chr) &&
450 (strcmp(this->grp, next->grp) == 0) && (this->per == next->per)) {
451 colrng[next->col].col = 1;
452 if (next->rng > colrng[next->col].rng)
453 colrng[next->col].rng = next->rng;
454 struct SECT *tmp = lights;
455 while (tmp->next != next) tmp = tmp->next;
456 tmp->next = next->next;
457 free(next);
458 next = tmp->next;
459 } else {
460 next = next->next;
461 }
462 }
463 if (this->chr != CHR_UNKN) {
464 if (this->dir) strcpy(string2, "Dir.");
465 strcat(string2, light_characters[this->chr]);
466 if (strcmp(this->grp, "") != 0) {
467 if (this->grp[0] == '(')
468 sprintf(strchr(string2, 0), "%s", this->grp);
469 else
470 sprintf(strchr(string2, 0), "(%s)", this->grp);
471 } else {
472 if (strlen(string2) > 0) strcat(string2, ".");
473 }
474 int n = 0;
475 for (int i = 0; i < 14; i++) if (colrng[i].col) n++;
476 double max = 0.0;
477 for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng > max)) max = colrng[i].rng;
478 double min = max;
479 for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng > 0.0) && (colrng[i].rng < min)) min = colrng[i].rng;
480 if (min == max) {
481 for (int i = 0; i < 14; i++) if (colrng[i].col) strcat(string2, light_letters[i]);
482 } else {
483 for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng == max)) strcat(string2, light_letters[i]);
484 for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng < max) && (colrng[i].rng > min)) strcat(string2, light_letters[i]);
485 for (int i = 0; i < 14; i++) if (colrng[i].col && colrng[i].rng == min) strcat(string2, light_letters[i]);
486 }
487 strcat(string2, ".");
488 if (this->per > 0.0) sprintf(strchr(string2, 0), "%gs", this->per);
489 if (max > 0.0) {
490 sprintf(strchr(string2, 0), "%g", max);
491 if (min != max) {
492 if (n == 2) strcat(string2, "/");
493 else if (n > 2) strcat(string2, "-");
494 if (min < max) sprintf(strchr(string2, 0), "%g", min);
495 }
496 strcat(string2, "M");
497 }
498 if (strlen(string1) > 0) strcat(string1, "\n");
499 strcat(string1, string2);
500 }
501 lights = this->next;
502 free(this);
503 this = lights;
504 }
505 } else {
506 if ((att = getAtt(obj, CATLIT)) != NULL) {
507 if (testAtt(att, LIT_DIR))
508 strcat(string1, "Dir");
509 }
510 if ((att = getAtt(obj, MLTYLT)) != NULL)
511 sprintf(strchr(string1, 0), "%s", stringValue(att->val));
512 if ((att = getAtt(obj, LITCHR)) != NULL) {
513 char *chrstr = strdup(stringValue(att->val));
514 Att_t *grp = getAtt(obj, SIGGRP);
515 if (grp != NULL) {
516 char *strgrp = strdup(stringValue(grp->val));
517 char *grpstr = strtok(strgrp, "()");
518 switch (att->val.val.e) {
519 case CHR_QLFL:
520 sprintf(strchr(string1, 0), "Q(%s)+LFl", grpstr);
521 break;
522 case CHR_VQLFL:
523 sprintf(strchr(string1, 0), "VQ(%s)+LFl", grpstr);
524 break;
525 case CHR_UQLFL:
526 sprintf(strchr(string1, 0), "UQ(%s)+LFl", grpstr);
527 break;
528 default:
529 sprintf(strchr(string1, 0), "%s(%s)", chrstr, grpstr);
530 break;
531 }
532 free(strgrp);
533 } else {
534 sprintf(strchr(string1, 0), "%s", chrstr);
535 }
536 free(chrstr);
537 }
538 if ((att = getAtt(obj, COLOUR)) != NULL) {
539 int n = countValues(att);
540 if (!((n == 1) && (idx == 0) && (testAtt(att, COL_WHT)))) {
541 if ((strlen(string1) > 0) && ((string1[strlen(string1)-1] != ')')))
542 strcat(string1, ".");
543 Lst_t *lst = att->val.val.l;
544 while (lst != NULL) {
545 strcat(string1, light_letters[lst->val]);
546 lst = lst->next;
547 }
548 }
549 }
550 if ((idx == 0) && (att = getAtt(obj, CATLIT)) != NULL) {
551 if (testAtt(att, LIT_VERT))
552 strcat(string1, "(vert)");
553 if (testAtt(att, LIT_HORI))
554 strcat(string1, "(hor)");
555 }
556 if ((strlen(string1) > 0) &&
557 ((getAtt(obj, SIGPER) != NULL) ||
558 (getAtt(obj, HEIGHT) != NULL) ||
559 (getAtt(obj, VALMXR) != NULL)) &&
560 (string1[strlen(string1)-1] != ')'))
561 strcat(string1, ".");
562 if ((att = getAtt(obj, SIGPER)) != NULL)
563 sprintf(strchr(string1, 0), "%ss", stringValue(att->val));
564 if ((idx == 0) && (item->objs.obj != LITMIN)) {
565 if ((att = getAtt(obj, HEIGHT)) != NULL)
566 sprintf(strchr(string1, 0), "%sm", stringValue(att->val));
567 if ((att = getAtt(obj, VALNMR)) != NULL)
568 sprintf(strchr(string1, 0), "%sM", stringValue(att->val));
569 }
570 if ((idx == 0) && (att = getAtt(obj, CATLIT)) != NULL) {
571 if (testAtt(att, LIT_FRNT))
572 strcat(string1, "(Front)");
573 if (testAtt(att, LIT_REAR))
574 strcat(string1, "(Rear)");
575 if (testAtt(att, LIT_UPPR))
576 strcat(string1, "(Upper)");
577 if (testAtt(att, LIT_LOWR))
578 strcat(string1, "(Lower)");
579 }
580 }
581 }
582 break;
583 default: break;
584 }
585 return string1;
586}
587*/
588
589}
Note: See TracBrowser for help on using the repository browser.