Debian Codegraph @

packages/seacas/libraries/svdi/cgi/vdicgi.c

raw
1 /*
2 * Copyright(C) 1999-2022 National Technology & Engineering Solutions
3 * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
4 * NTESS, the U.S. Government retains certain rights in this software.
5 *
6 * See packages/seacas/LICENSE for details
7 */
8 /*
9 SVDI CGI driver
10 Implemented in C, callable by Fortran
11 Debbie Campbell JAN 1989
12 Modifications: (mods marked by mod###)
13 vbinq vdwait 13-jul-90 kcole
14 vdstcs 15-aug-90 kcole
15 */
16
17 #include "cgidef.h"
18 #include <stdio.h>
19 #include <string.h>
20 #include <time.h>
21 #define NO_GET_DEVID_CHAR
22 #include "devid.h"
23 #undef NO_GET_DEVID_CHAR
24
25 static float get_devid_num(char *string)
26 {
27 int i;
28
29 for (i = 0; i < MAX_DEVID; i++) {
30 if (*(device_values[i].devid_char) == string[0] &&
31 *(device_values[i].devid_char + 1) == string[1] &&
32 *(device_values[i].devid_char + 2) == string[2]) {
33 return (device_values[i].devid_num);
34 }
35 }
36
37 /* return a zero if there is no character string match */
38 return (0.);
39 }
40
41 /* ifdefv.h - ifdef file for svdi routines
42 * This file is used to define the system dependent ways C is
43 * called from FORTRAN. Underscores are used by default.
44 *
45 * SUN DEC/ULTRIX ALLIANT : C routines must have underscores
46 * SGI CONVEX : C routines must have underscores
47 *
48 * VAX HP IBM/aix : C routines do not have underscores
49 *
50 * CRAY/UNICOS : C routines must be capitalized,
51 * and no underscores
52 *
53 * This include file is used by VDICGI.C
54 */
55
56 #if defined(ADDC_)
57 #endif
58 #if !defined(CRA) && !defined(ADDC_) && !defined(COUGAR)
59 #define vdinit_ vdinit
60 #define vdterm_ vdterm
61 #define vdfram_ vdfram
62 #define vdiqdc_ vdiqdc
63 #define vdnwpg_ vdnwpg
64 #define vdbell_ vdbell
65 #define vdwait_ vdwait
66 #define vdbufl_ vdbufl
67 #define vdstco_ vdstco
68 #define vdiqco_ vdiqco
69 #define vdescp_ vdescp
70 #define vdiqes_ vdiqes
71 #define vdiqnd_ vdiqnd
72 #define vdmova_ vdmova
73 #define vdlina_ vdlina
74 #define vdpnta_ vdpnta
75 #define vdtext_ vdtext
76 #define vdpoly_ vdpoly
77 #define vdiqcp_ vdiqcp
78 #define vdiqos_ vdiqos
79 #define vdstos_ vdstos
80 #define vdstfc_ vdstfc
81 #define vdstbc_ vdstbc
82 #define vdstin_ vdstin
83 #define vdstls_ vdstls
84 #define vdstlw_ vdstlw
85 #define vdstcs_ vdstcs
86 #define vdaabu_ vdaabu
87 #define vdaloc_ vdaloc
88 #define vdabgl_ vdabgl
89 #define vdakgl_ vdakgl
90 #define vdstla_ vdstla
91 #define vdloge_ vdloge
92 #define vdmoni_ vdmoni
93 #define vbpkg _vbpkg
94 #define vberrh_ vberrh
95 #define vbiqpk_ vbiqpk
96 #define vbiqdv_ vbiqdv
97 #define vbdev _vbdev
98 #define cdrofs_ cdrofs
99 #define cdrrfs_ cdrrfs
100 #define cdrwfs_ cdrwfs
101 #define cdrcfs_ cdrcfs
102 #define cdroab_ cdroab
103 #define bgpbuf_ bgpbuf
104 #endif
105 #if defined(CRA)
106 #define vdinit_ VDINIT
107 #define vdterm_ VDTERM
108 #define vdfram_ VDFRAM
109 #define vdiqdc_ VDIQDC
110 #define vdnwpg_ VDNWPG
111 #define vdbell_ VDBELL
112 #define vdwait_ VDWAIT
113 #define vdbufl_ VDBUFL
114 #define vdstco_ VDSTCO
115 #define vdiqco_ VDIQCO
116 #define vdescp_ VDESCP
117 #define vdiqes_ VDIQES
118 #define vdiqnd_ VDIQND
119 #define vdmova_ VDMOVA
120 #define vdlina_ VDLINA
121 #define vdpnta_ VDPNTA
122 #define vdtext_ VDTEXT
123 #define vdpoly_ VDPOLY
124 #define vdiqcp_ VDIQCP
125 #define vdiqos_ VDIQOS
126 #define vdstos_ VDSTOS
127 #define vdstfc_ VDSTFC
128 #define vdstbc_ VDSTBC
129 #define vdstin_ VDSTIN
130 #define vdstls_ VDSTLS
131 #define vdstlw_ VDSTLW
132 #define vdstcs_ VDSTCS
133 #define vdaabu_ VDAABU
134 #define vdaloc_ VDALOC
135 #define vdabgl_ VDABGL
136 #define vdakgl_ VDAKGL
137 #define vdstla_ VDSTLA
138 #define vdloge_ VDLOGE
139 #define vdmoni_ VDMONI
140 #define vbpkg_ VBPKG
141 #define vberrh_ VBERRH
142 #define vbiqpk_ VBIQPK
143 #define vbiqdv_ VBIQDV
144 #define vbdev_ VBDEV
145 #define cdrofs_ CDROFS
146 #define cdrrfs_ CDRRFS
147 #define cdrwfs_ CDRWFS
148 #define cdrcfs_ CDRCFS
149 #define cdroab_ CDROAB
150 #define bgpbuf_ BGPBUF
151 #endif
152 #ifdef Build64
153 #if !defined(ADDC_)
154 #define vdinit vdinit4
155 #define vdiqdc vdiqdc4
156 #define vdstco vdstco4
157 #define vdiqco vdiqco4
158 #define vdescp vdescp4
159 #define vdiqes vdiqes4
160 #define vdiqnd vdiqnd4
161 #define vdmova vdmova4
162 #define vdlina vdlina4
163 #define vdpnta vdpnta4
164 #define vdtext vdtext4
165 #define vdpoly vdpoly4
166 #define vdiqcp vdiqcp4
167 #define vdiqos vdiqos4
168 #define vdstfc vdstfc4
169 #define vdstbc vdstbc4
170 #define vdstin vdstin4
171 #define vdstls vdstls4
172 #define vdstlw vdstlw4
173 #define vdstcs vdstcs4
174 #define vdaabu vdaabu4
175 #define vdaloc vdaloc4
176 #define vdabgl vdabgl4
177 #define vdakgl vdakgl4
178 #define vdstla vdstla4
179 #define vdstos vdstos4
180 #define vdfram vdfram4
181 #else
182 #define vdinit_ vdinit4_
183 #define vdiqdc_ vdiqdc4_
184 #define vdstco_ vdstco4_
185 #define vdiqco_ vdiqco4_
186 #define vdescp_ vdescp4_
187 #define vdiqes_ vdiqes4_
188 #define vdiqnd_ vdiqnd4_
189 #define vdmova_ vdmova4_
190 #define vdlina_ vdlina4_
191 #define vdpnta_ vdpnta4_
192 #define vdtext_ vdtext4_
193 #define vdpoly_ vdpoly4_
194 #define vdiqcp_ vdiqcp4_
195 #define vdiqos_ vdiqos4_
196 #define vdstfc_ vdstfc4_
197 #define vdstbc_ vdstbc4_
198 #define vdstin_ vdstin4_
199 #define vdstls_ vdstls4_
200 #define vdstlw_ vdstlw4_
201 #define vdstcs_ vdstcs4_
202 #define vdaabu_ vdaabu4_
203 #define vdaloc_ vdaloc4_
204 #define vdabgl_ vdabgl4_
205 #define vdakgl_ vdakgl4_
206 #define vdstla_ vdstla4_
207 #define vdstos_ vdstos4_
208 #define vdfram_ vdfram4_
209 #endif
210 #endif
211
212 /* end ifdefv.h */
213 /* ifdefc.h - ifdef file for cgi routines
214 * This file is used to define the system dependent ways C is
215 * called from FORTRAN. Underscores are used by default.
216 *
217 * SUN DEC/ULTRIX ALLIANT : C routines must have underscores
218 * SGI CONVEX : C routines must have underscores
219 *
220 * VAX HP IBM/aix : C routines do not have underscores
221 *
222 * CRAY/UNICOS : C routines must be capitalized,
223 * and no underscores
224 *
225 * This file also defines the system dependent macro "f2cchar".
226 *
227 * This include file is used by SDCGI.C and VDICGI.C
228 */
229
230 #if defined(ADDC_)
231 #endif
232 #if !defined(CRA) && !defined(ADDC_) && !defined(COUGAR)
233 #define ci_ ci
234 #define ct_ ct
235 #define cxdfac_ cxdfac
236 #define cpds_ cpds
237 #define cendpg_ cendpg
238 #define cbc_ cbc
239 #define cvdcx_ cvdcx
240 #define cv_ cv
241 #define ccl_ ccl
242 #define cdqerr_ cdqerr
243 #define cerhct_ cerhct
244 #define ccixp_ ccixp
245 #define cesc1_ cesc1
246 #define cesc2_ cesc2
247 #define cqid_ cqid
248 #define cqd_ cqd
249 #define clf_ clf
250 #define clpr_ clpr
251 #define cqsp_ cqsp
252 #define clesc_ clesc
253 #define cqp_ cqp
254 #define cpl_ cpl
255 #define cdjpl_ cdjpl
256 #define cdscl_ cdscl
257 #define cqcl_ cqcl
258 #define cpm_ cpm
259 #define ctx1_ ctx1
260 #define ctx2_ ctx2
261 #define cpg_ cpg
262 #define cca_ cca
263 #define clnt_ clnt
264 #define clnw_ clnw
265 #define clnc_ clnc
266 #define cmkt_ cmkt
267 #define cmkc_ cmkc
268 #define ctxp_ ctxp
269 #define ctxc_ ctxc
270 #define cchh_ cchh
271 #define ccho_ ccho
272 #define cis_ cis
273 #define cflc_ cflc
274 #define ccsm_ ccsm
275 #define cct_ cct
276 #define cgtxx1_ cgtxx1
277 #define cgtxx2_ cgtxx2
278 #define cqprl_ cqprl
279 #define cqln_ cqln
280 #define cqlnt_ cqlnt
281 #define cqchh1_ cqchh1
282 #define cqchh2_ cqchh2
283 #define cqfl_ cqfl
284 #define cqc_ cqc
285 #define cqlna_ cqlna
286 #define cqtxa_ cqtxa
287 #define cqcte_ cqcte
288 #define cili_ cili
289 #define crqlc_ crqlc
290 #define cpxa_ cpxa
291 #endif
292 #if defined(CRA)
293 #define ci_ CI
294 #define ct_ CT
295 #define cxdfac_ CXDFAC
296 #define cpds_ CPDS
297 #define cendpg_ CENDPG
298 #define cbc_ CBC
299 #define cvdcx_ CVDCX
300 #define cv_ CV
301 #define ccl_ CCL
302 #define cdqerr_ CDQERR
303 #define cerhct_ CERHCT
304 #define ccixp_ CCIXP
305 #define cesc1_ CESC1
306 #define cesc2_ CESC2
307 #define cqid_ CQID
308 #define cqd_ CQD
309 #define clf_ CLF
310 #define clpr_ CLPR
311 #define cqsp_ CQSP
312 #define clesc_ CLESC
313 #define cqp_ CQP
314 #define cpl_ CPL
315 #define cdjpl_ CDJPL
316 #define cdscl_ CDSCL
317 #define cqcl_ CQCL
318 #define cpm_ CPM
319 #define ctx1_ CTX1
320 #define ctx2_ CTX2
321 #define cpg_ CPG
322 #define cca_ CCA
323 #define clnt_ CLNT
324 #define clnw_ CLNW
325 #define clnc_ CLNC
326 #define cmkt_ CMKT
327 #define cmkc_ CMKC
328 #define ctxp_ CTXP
329 #define ctxc_ CTXC
330 #define cchh_ CCHH
331 #define ccho_ CCHO
332 #define cis_ CIS
333 #define cflc_ CFLC
334 #define ccsm_ CCSM
335 #define cct_ CCT
336 #define cgtxx1_ CGTXX1
337 #define cgtxx2_ CGTXX2
338 #define cqprl_ CQPRL
339 #define cqln_ CQLN
340 #define cqlnt_ CQLNT
341 #define cqchh1_ CQCHH1
342 #define cqchh2_ CQCHH2
343 #define cqfl_ CQFL
344 #define cqc_ CQC
345 #define cqlna_ CQLNA
346 #define cqtxa_ CQTXA
347 #define cqcte_ CQCTE
348 #define cili_ CILI
349 #define crqlc_ CRQLC
350 #define cpxa_ CPXA
351 #endif
352 #ifdef Build64
353 #if !defined(ADDC_)
354 #define cesc cesc4
355 #define ctx ctx4
356 #define cgtxx cgtxx4
357 #define cqchh cqchh4
358 #define cesc2 cesc24
359 #define ctx2 ctx24
360 #define cgtxx2 cgtxx24
361 #define cqchh2 cqchh24
362 #else
363 #define cesc_ cesc4_
364 #define ctx_ ctx4_
365 #define cgtxx_ cgtxx4_
366 #define cqchh_ cqchh4_
367 #define cesc2_ cesc24_
368 #define ctx2_ ctx24_
369 #define cgtxx2_ cgtxx24_
370 #define cqchh2_ cqchh24_
371 #endif
372 #endif
373
374 /* f2cchar macro definition */
375 #if !defined(CRA) && !defined(ardent)
376 #define f2cchar(fptr) (fptr)
377 #endif /* default, CRA and ardent are exceptions */
378 #if defined(CRA) && !defined(ardent)
379 #include <fortran.h>
380 #define f2cchar(fptr) (_fcdtocp((_fcd)fptr))
381 #endif
382
383 #include "sdcgi.h"
384
385 /* current position */
386 static float xcp = 0.;
387 static float ycp = 0.;
388
389 /* internal buffer for polylines, polygons */
390 #define VBUF_SIZE 2000
391 static float vlist_x[VBUF_SIZE];
392 static float vlist_y[VBUF_SIZE];
393 static int nvert = 0;
394
395 /* transformation parameters*/
396 static float scale;
397
398 #define MAX_VECTOR 7
399 static float vector[MAX_VECTOR] = {7., 0., 1., 0., .01, 0., 0.};
400
401 #define MAX_DEV_CAP 33
402 static float dev_cap[MAX_DEV_CAP] = {0., 1., 1., 255., 0., 15., 2., 1., 1., 1., 1.,
403 1., 1., 0., 32767., 32767., 0., 0., 1., 1., 1., 0.,
404 0., 3., 2000., 1., 0., 0., 0., 1., 1., 1., 1.};
405 static float linewidth_nominal;
406
407 /* Maximum NDC Values */
408 static float ndc_xmax = 1.;
409 static float ndc_ymax = 1.;
410 static int alpha_mode;
411
412 static float color_scale;
413
414 /* Logical Color Table */
415 static int init_colors[24] = {0, 0, 0, 255, 0, 0, 0, 255, 0, 255, 255, 0,
416 0, 0, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255};
417
418 #ifndef TRUE
419 #define TRUE 1
420 #define FALSE 0
421 #endif
422
423 /* macro to convert ascii(integer) to char (note: machine dependent) */
424 #define a_to_c(ain) ((char)ain) /* for ascii machine */
425
426 /* macros which map ndc into CGI coords. */
427 #define map_x(xin) ((float)(scale * (xin)))
428 #define map_y(yin) ((float)(scale * (yin)))
429
430 /* macros which map CGI coords. into ndc */
431 #define ndc_map_x(xin) ((float)((xin) / scale))
432 #define ndc_map_y(yin) ((float)((yin) / scale))
433
434 #define min(p1, p2) ((p1) < (p2) ? p1 : p2)
435 #define max(p1, p2) ((p1) > (p2) ? p1 : p2)
436
437 void vdicgi_errh(char errmsg[])
438 {
439 int temp1, temp2;
440 float temp3;
441
442 temp1 = XEAGMD;
443 temp2 = 1;
444 temp3 = 0.; /* alpha */
445 cesc2_(&temp1, &temp2, &temp3);
446 alpha_mode = TRUE;
447 fprintf(stderr, " %s\n", errmsg);
448 }
449
450 void vbinq(void)
451 /* -- THIS IS WHERE CHANGES TO DEV_CAP OCCUR -- */
452 {
453 int vstat, hscopy, disp, bcolor, dynbc, dynvdm, dx1, dy1, dx2, dy2, pixloc;
454 int maxpl, maxdpl, maxpg, maxpgs, maxpm, maxcf, maxchr, maxcel;
455 int celfil, celaln, comptx, clofig, dclass;
456 int npdefb, nsetb, maxbi, dynmod, nomwid, minwid, maxwid;
457 int nreq, first, ntotal, lntyp[6], nlist;
458 int nsimul, navail, nint, cmode, overit, monoc, txp, chhit, i;
459 float width, height;
460 char devid[4];
461
462 /* INQUIRE DEVICE IDENTIFICATION */
463 maxchr = 3;
464 cqid_(&maxchr, &vstat, &dclass, devid);
465 if (vstat == CVAL) {
466 dev_cap[22] = get_devid_num(devid);
467 }
468 else {
469 vdicgi_errh(" SVDI Shell (VBINQ) invalid inquire for cqid ");
470 }
471
472 /* INQUIRE DEVICE DESCRIPTION */
473 cqd_(&vstat, &hscopy, &disp, &bcolor, &dynbc, &dynvdm, &dx1, &dy1, &dx2, &dy2, &width, &height,
474 &pixloc);
475 if (vstat == CVAL) {
476 dev_cap[0] = (float)hscopy; /* Erasibility */
477 dev_cap[1] = (float)disp; /* Scan type (vector, raster) */
478 /* the next two may be wrong, want view surface instead of device surface
479 : also note, the next 2 items may change if surface is window--later */
480 if (!((dx1 == 0) && (dx2 == 0))) { /* X dimension view surface */
481 dev_cap[14] = (float)(dx2 - dx1);
482 }
483 if (!((dy1 == 0) && (dy2 == 0))) { /* Y dimension view surface */
484 dev_cap[15] = (float)(dy2 - dy1);
485 }
486 dev_cap[16] = width; /* X dimension physical units */
487 dev_cap[17] = height; /* Y dimension physical units */
488 }
489 else {
490 vdicgi_errh(" SVDI Shell (VBINQ) invalid inquire for cqd ");
491 }
492
493 /* input inquiries to zeros - for non-interactive devices */
494 /* mod### set these based on dclass not hscopy */
495 if (dclass == 0) /* dclass = dev(13) value */
496 {
497 for (i = 7; i < 13; i++) {
498 dev_cap[i] = 0.;
499 }
500 }
501
502 /* INQUIRE PRIMITIVE SUPPORT LEVELS */
503 cqprl_(&vstat, &maxpl, &maxdpl, &maxpg, &maxpgs, &maxpm, &maxcf, &maxchr, &maxcel, &celfil,
504 &celaln, &comptx, &clofig);
505 if (vstat == CVAL) {
506 if (maxpg == -1) {
507 maxpg = VBUF_SIZE;
508 }
509 dev_cap[24] = min(maxpg, VBUF_SIZE); /* Maximum polygon points */
510 }
511 else {
512 vdicgi_errh(" SVDI Shell (VBINQ) invalid inquire for cqprl ");
513 }
514
515 /* INQUIRE LINE CAPABILITY */
516 cqln_(&vstat, &npdefb, &nsetb, &maxbi, &dynmod, &nomwid, &minwid, &maxwid);
517 if (vstat == CVAL) {
518 dev_cap[18] = (float)minwid; /* Minimum line width */
519
520 /* Due to the fact that cgi device coordinates have to be integer, the
521 linewidth numbers may come back zero, enforce a minimum for nominal
522 since we use it later in vdstlw for calculations */
523 linewidth_nominal = (nomwid == 0) /* Nominal line width */
524 ? .001
525 : (float)nomwid / dev_cap[14];
526 dev_cap[30] = (float)maxwid; /* Maximum line width */
527
528 /* Could inquire marker capability, but this will be close enough*/
529 dev_cap[19] = dev_cap[18]; /* Minimum pointsize */
530 }
531 else {
532 vdicgi_errh(" SVDI Shell (VBINQ) invalid inquire for cqln ");
533 }
534
535 /* INQUIRE LIST OF AVAILABLE LINE TYPES */
536 nreq = 6;
537 first = 1;
538 cqlnt_(&nreq, &first, &vstat, &ntotal, &nlist, lntyp);
539 if (vstat == CVAL) {
540 /* map CGI to VDI linestyles */
541 /* cgi linestyles: 1 - solid 2 - dash 3 - dot,
542 * 4 - dashdot 5 - dash dot dot
543 * vdi linestyles: 0 - solid 1 - dotted 2 - dot dash
544 * 3 - short dash 4 - long dash 5 - medium dash
545 */
546 dev_cap[5] = 0.;
547 for (i = 0; i < nlist; i++) {
548 switch (lntyp[i]) {
549 case 1: break;
550 case 2: dev_cap[5] += 16.; break;
551 case 3: dev_cap[5] += 1.; break;
552 case 4: dev_cap[5] += 2.; break;
553 case 5: dev_cap[5] += 4.; break;
554 default: break;
555 } /* end switch */
556 }
557 }
558 else {
559 vdicgi_errh(" SVDI Shell (VBINQ) invalid inquire for cqlnt ");
560 }
561
562 /* INQUIRE COLOR CAPABILITIES */
563 cqc_(&vstat, &nsimul, &navail, &nint, &cmode, &dynmod, &overit, &monoc);
564 if (vstat == CVAL) {
565 dev_cap[3] = (float)nsimul - 2; /* Simultaneous colors */
566 dev_cap[26] = (float)navail - 2; /* Available colors */
567 dev_cap[2] = (float)nint; /* Available intensities */
568 dev_cap[31] = 1.; /* Color or monochrome */
569 if (monoc == CYES) {
570 dev_cap[31] = 0.;
571 }
572 }
573 else {
574 vdicgi_errh(" SVDI Shell (VBINQ) invalid inquire for cqc ");
575 }
576
577 /* INQUIRE LIST OF AVAILABLE CHARACTER HEIGHTS */
578 txp = CSTRNG;
579 nreq = 1;
580 first = 1;
581 cqchh2_(&txp, &nreq, &first, &vstat, &ntotal, &nlist, &chhit);
582 if (vstat == CVAL) {
583 dev_cap[6] = (nlist == 0) ? 0. : (float)ntotal;
584 }
585 else {
586 vdicgi_errh(" SVDI Shell (VBINQ) invalid inquire for cqchh ");
587 }
588 }
589
590 void vdinit_(float *aspect, int *justif)
591 {
592 float asp;
593 int temp, temp2, vstat, vconc;
594 float xconc, yconc, x1, y1, x2, y2, x3, y3, x4, y4, temp_xcp, temp_ycp;
595 float scaled_ndc_xmax, scaled_ndc_ymax;
596 float rtemp = 0.0;
597 xconc = 0.0;
598 yconc = 0.0;
599 x1 = 0.0;
600 y1 = 0.0;
601 x2 = 0.0;
602 y2 = 0.0;
603 x3 = 0.0;
604 y3 = 0.0;
605 x4 = 0.0;
606 y4 = 0.0;
607
608 asp = *aspect;
609
610 if (asp < 0.) {
611 vdicgi_errh(" SVDI Shell (VDINIT) Error Number 721 Severity 5: ");
612 asp = 0.;
613 }
614
615 /* Initialize CGI */
616 temp = CACT;
617 alpha_mode = FALSE;
618 ci_(&temp);
619
620 /* Inquire everything you always wanted to know about */
621 vbinq();
622
623 /* Turn off clip indicators */
624 temp = CDCOFF;
625 cdscl_(&temp);
626 temp = COFF;
627 ccl_(&temp);
628
629 /* Set up proper scaling to take advantage of whole device (not just square) */
630 if (asp == 0.) {
631 asp = dev_cap[14] / dev_cap[15];
632 }
633 if (asp > 1.) {
634 ndc_xmax = 1.;
635 ndc_ymax = 1. / asp;
636 }
637 else {
638 ndc_xmax = asp;
639 ndc_ymax = 1.;
640 }
641 scale = 32767.;
642 scaled_ndc_xmax = map_x(ndc_xmax);
643 scaled_ndc_ymax = map_y(ndc_ymax);
644 rtemp = 0.0;
645 cvdcx_(&rtemp, &rtemp, &scaled_ndc_xmax, &scaled_ndc_ymax);
646
647 /* Set color mode to index, and set color index precision to 8 bits */
648 temp = CINDEX;
649 ccsm_(&temp);
650 temp = 8;
651 ccixp_(&temp);
652 color_scale = 255.;
653
654 /* set up the standard 8 colors in indices 2 - 9 (0 reserved for background,
655 1 reserved for default foreground) */
656 temp = 2;
657 temp2 = 8;
658 cct_(&temp, &temp2, init_colors);
659
660 /* Set default marker type to dot */
661 temp = 1;
662 cmkt_(&temp);
663
664 /* Set default interior style to solid */
665 temp = CSOLID;
666 cis_(&temp);
667
668 /* Inquire what the default character size is - use cgtxx instead of
669 cqtxa because need both x and y size (may have to adjust for inter
670 character/line spacing later */
671 temp_xcp = map_x(xcp);
672 temp_ycp = map_y(ycp);
673 cgtxx2_(&temp_xcp, &temp_ycp, &vstat, &vconc, &xconc, &yconc, &x1, &y1, &x2, &y2, &x3, &y3, &x4,
674 &y4);
675 if (vstat == CVAL) {
676 vector[5] = ndc_map_x(x2 - x1);
677 vector[6] = ndc_map_y(y4 - y1);
678 }
679 else {
680 vdicgi_errh(" SVDI Shell (VDINIT) inquire error from cgtxx ");
681 }
682
683 /* Initialize locator device */
684 temp = CLOCAT;
685 temp2 = 1;
686 cili_(&temp, &temp2);
687 }
688
689 void vflush(void)
690 /* flush polyline buffer */
691 {
692 if (alpha_mode) {
693 int temp1 = XEAGMD;
694 int temp2 = 1;
695 float temp3 = 1.; /* graphics */
696 cesc2_(&temp1, &temp2, &temp3);
697 alpha_mode = FALSE;
698 }
699
700 if (nvert > 0) {
701 cpl_(&nvert, vlist_x, vlist_y);
702 nvert = 0;
703 }
704 }
705
706 void vdterm_(void)
707 {
708 vflush();
709 ct_();
710 }
711
712 void vdiqdc_(int *index, float *value)
713 {
714 if (*index < 1 || *index > MAX_DEV_CAP) {
715 vdicgi_errh(" SVDI Shell (VDIQDC) Error Number 726, Severity Code 5 ");
716 return;
717 }
718 {
719 *value = dev_cap[*index - 1];
720 }
721 }
722
723 void vdnwpg_(void)
724 {
725 int temp, nreq, first, vstat, ntotal, colors[3], nlist;
726
727 vflush(); /* flush polyline buffer */
728
729 /* execute deferred actions */
730 cxdfac_();
731
732 /* inquire the rgb values of color_index. Set index 0 to those values */
733
734 nreq = 1;
735
736 /* the 3 below is because you asking for the 3rd index -- which happens
737 to be logical index 0 */
738
739 first = vector[1] + 3;
740 cqcte_(&nreq, &first, &vstat, &ntotal, &nlist, colors);
741 if (vstat == CVAL) {
742 cbc_(&colors[0], &colors[1], &colors[2]);
743 }
744 else {
745 vdicgi_errh(" SVDI Shell (VDNWPG) invalid inquire for cqcte ");
746 }
747
748 /* prepare drawing surface - do background color */
749 temp = CCONDC;
750 cpds_(&temp);
751 }
752
753 void vdbell_(void) {}
754
755 void vdwait_(void)
756 {
757 int temp, vstat, rstat, mvalid, trigger;
758 float xpos, ypos, timeout;
759
760 /* make picture current - flush output buffers */
761 vflush(); /* flush polyline buffer */
762 cxdfac_();
763
764 /* do read waiting for viewing for interactive devices only */
765 /* mod### changed from 0(erasibility) to 12(input) */
766 if (dev_cap[12] != 0.) {
767 temp = 1;
768 timeout = 1.;
769 crqlc_(&temp, &timeout, &vstat, &rstat, &mvalid, &trigger, &xpos, &ypos);
770 if (vstat != CVAL) {
771 vdicgi_errh(" SVDI Shell (VDWAIT) invalid request for crqlc ");
772 }
773 }
774 }
775
776 void vdbufl_(void)
777 {
778 int temp1, temp2;
779 float temp3;
780
781 vflush(); /* flush polyline buffer */
782 cxdfac_();
783
784 /* set the device into alpha mode - 0. */
785 temp1 = XEAGMD;
786 temp2 = 1;
787 temp3 = 0.; /* alpha */
788 cesc2_(&temp1, &temp2, &temp3);
789 alpha_mode = TRUE;
790 }
791
792 void vdstco_(int *num, int index_array[], float color_array[][3], int *color_mod)
793 {
794 int i = 0;
795 int start_index = 0;
796 int hld_colors_ptr = 0;
797 int first = 0;
798 int count = 0;
799 int hld_colors[768];
800
801 if (*num < 1 || *num > dev_cap[3]) {
802 vdicgi_errh(" SVDI Shell (VDSTCO) Error Number 723, Severity Code 5 ");
803 return;
804 }
805
806 if (*color_mod != 0 && *color_mod != 1) {
807 vdicgi_errh(" SVDI Shell (VDSTCO) Error Number 725, Severity Code 5 ");
808 return;
809 }
810
811 vflush(); /* flush polyline buffer */
812 first = TRUE;
813
814 for (i = 0; i < *num; i++) {
815 if (index_array[i] < 0 || index_array[i] > 255) {
816 vdicgi_errh(" SVDI Shell (VDSTCO) Error Number 724, Severity Code 5 ");
817
818 /* Set RGB color */
819 }
820 else if (*color_mod == 0) {
821 if (color_array[i][0] < 0. || color_array[i][0] > 1. || color_array[i][1] < 0. ||
822 color_array[i][1] > 1. || color_array[i][2] < 0. || color_array[i][2] > 1.) {
823 vdicgi_errh(" SVDI Shell (VDSTCO) Error Number 727, Severity Code 5 ");
824 }
825 else
826 /* Check to see if indices are consecutive (buffer up if they are) */
827 {
828
829 if (first) {
830
831 /* set color table from index requested + 2 (0 reserved for background) */
832
833 start_index = index_array[i] + 2;
834 hld_colors_ptr = 0;
835 first = FALSE;
836 }
837
838 hld_colors[hld_colors_ptr++] = (int)(color_array[i][0] * color_scale);
839 hld_colors[hld_colors_ptr++] = (int)(color_array[i][1] * color_scale);
840 hld_colors[hld_colors_ptr++] = (int)(color_array[i][2] * color_scale);
841
842 if (i < *num - 1) {
843 if (index_array[i] != (index_array[i + 1] - 1)) {
844 count = hld_colors_ptr / 3;
845 cct_(&start_index, &count, hld_colors);
846 first = TRUE;
847 }
848 }
849 }
850 }
851
852 /* Set HLS color (HLS not supported) */
853 else {
854 vdicgi_errh(" SVDI Shell (VDSTCO) HLS option being phased out - ignored ");
855 vdicgi_errh(" Contact Computer Graphics Group - Div. 2644 ");
856 }
857 }
858
859 count = hld_colors_ptr / 3;
860 if (count > 0) {
861 cct_(&start_index, &count, hld_colors);
862 }
863 }
864
865 void vdiqco_(int *num, int index_array[], float color_array[][3], int *color_mod)
866 {
867 int i, ntotal, colors[3], first, nreq, vstat, nlist;
868 int temp1, temp2;
869 float temp3;
870
871 if (*num < 1 || *num > dev_cap[3]) {
872 vdicgi_errh(" SVDI Shell (VDIQCO) Error Number 723, Severity Code 5 ");
873 return;
874 }
875
876 if (*color_mod != 0 && *color_mod != 1) {
877 vdicgi_errh(" SVDI Shell (VDIQCO) Error Number 725, Severity Code 5 ");
878 return;
879 }
880
881 if (alpha_mode) {
882 temp1 = XEAGMD;
883 temp2 = 1;
884 temp3 = 1.; /* "graphics" */
885 cesc2_(&temp1, &temp2, &temp3);
886 alpha_mode = FALSE;
887 }
888
889 for (i = 0; i < *num; i++) {
890 if (index_array[i] < 0 || index_array[i] > 255) {
891 vdicgi_errh(" SVDI Shell (VDIQCO) Error Number 724, Severity Code 5 ");
892 }
893 else {
894 if (*color_mod == 1) {
895 vdicgi_errh(" HLS option being phased out - returning RGB values ");
896 vdicgi_errh(" Contact Computer Graphics Group - Div. 2644 ");
897 }
898
899 /* find out from cgi what the color table is */
900 nreq = 1;
901 first = index_array[i] + 3;
902 cqcte_(&nreq, &first, &vstat, &ntotal, &nlist, colors);
903 if (vstat == CVAL) {
904 color_array[i][0] = (float)colors[0] / color_scale;
905 color_array[i][1] = (float)colors[1] / color_scale;
906 color_array[i][2] = (float)colors[2] / color_scale;
907 }
908 else {
909 vdicgi_errh(" SVDI Shell (VDIQCO) invalid inquire for cqcte ");
910 color_array[i][0] = -1.;
911 }
912 }
913 }
914 }
915
916 void vdescp_(int *escape_code, int *n, float args)
917 {
918 if (*n < 0) {
919 vdicgi_errh(" SVDI Shell (VDESCP) Error Number 802, Severity Code 5 ");
920 return;
921 }
922 }
923
924 void vdiqes_(int *escape_code, int *support) { *support = 0; }
925
926 void vdiqnd_(float *x_ndc, float *y_ndc)
927 {
928 *x_ndc = ndc_xmax;
929 *y_ndc = ndc_ymax;
930 }
931
932 void vdmova_(float *x, float *y)
933 {
934 vflush();
935 vlist_x[nvert] = map_x(*x);
936 vlist_y[nvert] = map_y(*y);
937 nvert++;
938
939 xcp = *x;
940 ycp = *y;
941 }
942
943 void vdlina_(float *x, float *y)
944 {
945
946 /* if a move hasn't already been done, doit it now */
947 if (nvert == 0) {
948 vlist_x[nvert] = map_x(xcp);
949 vlist_y[nvert] = map_y(ycp);
950 nvert++;
951 }
952
953 /* append to polyline buffer (if full, flush it first) */
954 if (nvert >= VBUF_SIZE) {
955 vflush();
956 nvert = 0; /* vflush sets this, but static analysis still warns. */
957 }
958 vlist_x[nvert] = map_x(*x);
959 vlist_y[nvert] = map_y(*y);
960 nvert++;
961
962 xcp = *x;
963 ycp = *y;
964 }
965
966 void vdpnta_(float *x, float *y)
967 {
968 float new_x, new_y;
969 int temp;
970
971 new_x = map_x(*x);
972 new_y = map_y(*y);
973 temp = 1;
974
975 vflush();
976 vlist_x[nvert] = new_x;
977 vlist_y[nvert] = new_y;
978 nvert++;
979
980 cpm_(&temp, &new_x, &new_y);
981
982 xcp = *x;
983 ycp = *y;
984 }
985
986 void vdtext_(int *length, int char_array[])
987 {
988 int i, lenout, len, temp1, temp2;
989 float dx, dy, temp_xcp, temp_ycp, temp3;
990 int strout[150];
991
992 len = *length;
993
994 if (len < 1) {
995 vdicgi_errh(" SVDI Shell (VDTEXT) Error Number 212, Severity Code 5 ");
996 return;
997 }
998
999 if (len > 136) {
1000 vdicgi_errh(" SVDI Shell (VDTEXT) Error Number 213, Severity Code 5 ");
1001 len = 136;
1002 }
1003
1004 if (alpha_mode) {
1005 temp1 = XEAGMD;
1006 temp2 = 1;
1007 temp3 = 1.; /* graphics */
1008 cesc2_(&temp1, &temp2, &temp3);
1009 alpha_mode = FALSE;
1010 }
1011
1012 lenout = 0; /*count characters in string output buffer "strout" */
1013
1014 for (i = 0; i < len; i++) {
1015 if (char_array[i] < 32 || char_array[i] > 126) {
1016 switch (char_array[i]) {
1017 case 8:
1018 dx = -vector[6];
1019 dy = 0.;
1020 break;
1021 case 10:
1022 dx = 0.;
1023 dy = -vector[5];
1024 break;
1025 case 13:
1026 dx = -xcp;
1027 dy = 0.;
1028 break;
1029 default:
1030 dx = 0.;
1031 dy = 0.;
1032 vdicgi_errh(" SVDI Shell (VDTEXT) Error Number 208, Severity Code 5 ");
1033 break;
1034 }
1035 /* Stuff to send, finish the string */
1036
1037 if (lenout != 0) {
1038 temp_xcp = map_x(xcp);
1039 temp_ycp = map_y(ycp);
1040 ctx2_(&temp_xcp, &temp_ycp, strout, &lenout);
1041 xcp += lenout * vector[6];
1042 lenout = 0;
1043 }
1044 xcp += dx;
1045 ycp += dy;
1046 vdmova_(&xcp, &ycp);
1047 }
1048
1049 else {
1050
1051 strout[lenout++] = char_array[i];
1052 }
1053 }
1054
1055 /* All done, get rid of them */
1056 if (lenout != 0) {
1057 temp_xcp = map_x(xcp);
1058 temp_ycp = map_y(ycp);
1059 ctx2_(&temp_xcp, &temp_ycp, strout, &lenout);
1060 xcp += lenout * vector[6];
1061 lenout = 0;
1062 }
1063 }
1064
1065 void vdpoly_(float x_array[], float y_array[], int *npts)
1066 {
1067 int i, iend;
1068
1069 vflush();
1070
1071 if (*npts > (int)dev_cap[24]) {
1072 vdicgi_errh(" SVDI Shell (VDPOLY) exceeded max points for - device limit ");
1073 iend = (int)dev_cap[24];
1074 }
1075
1076 else if (*npts > VBUF_SIZE) {
1077 vdicgi_errh(" SVDI Shell (VDPOLY) exceeded max points - internal buffer limit ");
1078 iend = VBUF_SIZE;
1079 }
1080 else {
1081 iend = *npts;
1082 }
1083
1084 for (i = 0; i < iend; i++) {
1085 vlist_x[nvert] = map_x(x_array[i]);
1086 vlist_y[nvert] = map_y(y_array[i]);
1087 nvert++;
1088 }
1089
1090 cpg_(&nvert, vlist_x, vlist_y);
1091 nvert = 0;
1092
1093 xcp = x_array[0];
1094 ycp = y_array[0];
1095 }
1096
1097 void vdiqcp_(float *x, float *y)
1098 {
1099 *x = xcp;
1100 *y = ycp;
1101 }
1102
1103 void vdiqos_(float attr_array[])
1104 {
1105 int i;
1106
1107 for (i = 0; i < MAX_VECTOR; i++) {
1108 attr_array[i] = vector[i];
1109 }
1110 }
1111
1112 void vdstfc_(int *color_index)
1113 {
1114 int new_color;
1115
1116 if (*color_index < 0 || *color_index > 255) {
1117 vdicgi_errh(" SVDI Shell (VDSTFC) Error Number 724 Severity 5: ");
1118 return;
1119 }
1120
1121 vector[0] = (float)*color_index;
1122
1123 /* map foreground color into indices 2-n since 0 is reserved for background,
1124 and 1 is default foreground */
1125 new_color = *color_index + 2;
1126
1127 vflush();
1128
1129 clnc_(&new_color);
1130 cmkc_(&new_color);
1131 ctxc_(&new_color);
1132 cflc_(&new_color);
1133 }
1134
1135 void vdstbc_(int *color_index)
1136 {
1137 if (*color_index < 0 || *color_index > 255) {
1138 vdicgi_errh(" SVDI Shell (VDSTBC) Error Number 724 Severity 5: ");
1139 return;
1140 }
1141 vector[1] = (float)*color_index;
1142 }
1143
1144 void vdstin_(float *intensity)
1145 {
1146 if (*intensity < 0. || *intensity > 1.) {
1147 vdicgi_errh(" SVDI Shell (VDSTIN) Error Number 401 Severity 5: ");
1148 return;
1149 }
1150 }
1151
1152 void vdstls_(int *line_style)
1153 {
1154 int temp;
1155
1156 if (*line_style < 0 || *line_style > 5) {
1157 vdicgi_errh(" SVDI Shell (VDSTLS) Error Number 401 Severity 5: ");
1158 return;
1159 }
1160
1161 vector[3] = (float)*line_style;
1162 vflush();
1163 switch (*line_style) {
1164 /* cgi linestyles are: 1 - solid, 2 - dash, 3 - dot, 4 - dashdot 5 - dash dot dot
1165 vdi linestyles are: 0 - solid, 1 - dotted, 2 - dot dash
1166 3 - short dash, 4 - long dash, 5 - medium dash */
1167 case 0:
1168 temp = 1;
1169 clnt_(&temp);
1170 break;
1171 case 1:
1172 temp = 3;
1173 clnt_(&temp);
1174 break;
1175 case 2:
1176 temp = 4;
1177 clnt_(&temp);
1178 break;
1179 case 3:
1180 temp = 2;
1181 clnt_(&temp);
1182 break;
1183 case 4:
1184 temp = 5;
1185 clnt_(&temp);
1186 break;
1187 case 5:
1188 temp = 2;
1189 clnt_(&temp);
1190 break;
1191 default: vector[3] = 0.; break;
1192 }
1193 }
1194
1195 void vdstlw_(float *line_width)
1196 {
1197 float new_size;
1198
1199 if (*line_width < 0. || *line_width > 1.) {
1200 vdicgi_errh(" SVDI Shell (VDSTLW) Error Number 401 Severity 5: ");
1201 return;
1202 }
1203
1204 vector[4] = *line_width;
1205
1206 /* cgi default state is scaled linewidth - not expressed in VDC */
1207 new_size = *line_width / linewidth_nominal;
1208 vflush();
1209 clnw_(&new_size);
1210 }
1211
1212 void vdstcs_(float *y_size)
1213 {
1214 float new_size, x, y, xconc, yconc, x1, y1, x2, y2, x3, y3, x4, y4;
1215 float temp3;
1216 int vstat, vconc, temp1, temp2;
1217
1218 xconc = 0.0;
1219 yconc = 0.0;
1220 x1 = 0.0;
1221 y1 = 0.0;
1222 x2 = 0.0;
1223 y2 = 0.0;
1224 x3 = 0.0;
1225 y3 = 0.0;
1226 x4 = 0.0;
1227 y4 = 0.0;
1228
1229 new_size = map_x(*y_size);
1230
1231 if (alpha_mode) {
1232 temp1 = XEAGMD;
1233 temp2 = 1;
1234 temp3 = 1.; /* graphics */
1235 cesc2_(&temp1, &temp2, &temp3);
1236 alpha_mode = FALSE;
1237 }
1238
1239 cchh_(&new_size);
1240
1241 /* inquire what the realized size is and stuff it here */
1242 x = map_x(xcp);
1243 y = map_y(ycp);
1244 cgtxx2_(&x, &y, &vstat, &vconc, &xconc, &yconc, &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
1245 if (vstat == CVAL) {
1246 /* mod## y value being stored incorrectyl; swapped x & y */
1247 vector[5] = ndc_map_y(y4 - y1);
1248 vector[6] = ndc_map_x(x2 - x1);
1249 }
1250 else {
1251 vdicgi_errh(" SVDI Shell (VDSTCS) inquire error from cgtxx ");
1252 }
1253 }
1254
1255 void vdaabu_(int *button)
1256 {
1257 int temp, vstat, rstat, mvalid, trigger;
1258 float xpos, ypos, timeout;
1259
1260 if (dev_cap[0] != 0.) {
1261 vflush(); /* flush polyline buffer */
1262 temp = 1;
1263 timeout = 1.;
1264 crqlc_(&temp, &timeout, &vstat, &rstat, &mvalid, &trigger, &xpos, &ypos);
1265 if (vstat == CVAL) {
1266 *button = trigger;
1267 }
1268 else {
1269 vdicgi_errh(" SVDI Shell (VDAABU) invalid request for crqlc ");
1270 }
1271 }
1272 }
1273
1274 void vdaloc_(float *x, float *y)
1275 {
1276 int temp, vstat, rstat, mvalid, trigger;
1277 float xpos, ypos, timeout;
1278
1279 if (dev_cap[0] != 0.) {
1280 vflush(); /* flush polyline buffer */
1281 temp = 1;
1282 timeout = 1.;
1283 crqlc_(&temp, &timeout, &vstat, &rstat, &mvalid, &trigger, &xpos, &ypos);
1284 if (vstat == CVAL) {
1285 *x = ndc_map_x(xpos);
1286 *y = ndc_map_y(ypos);
1287 }
1288 else {
1289 vdicgi_errh(" SVDI Shell (VDALOC) invalid request for crqlc ");
1290 }
1291 }
1292 }
1293
1294 void vdabgl_(int *button, float *x, float *y)
1295 {
1296 int temp, vstat, rstat, mvalid, trigger;
1297 float xpos, ypos, timeout;
1298
1299 if (dev_cap[0] != 0.) {
1300 vflush(); /* flush polyline buffer */
1301 temp = 1;
1302 timeout = 1.;
1303 crqlc_(&temp, &timeout, &vstat, &rstat, &mvalid, &trigger, &xpos, &ypos);
1304 if (vstat == CVAL) {
1305 *x = ndc_map_x(xpos);
1306 *y = ndc_map_y(ypos);
1307 *button = trigger;
1308 }
1309 else {
1310 vdicgi_errh(" SVDI Shell (VDABGL) invalid request for crqlc ");
1311 }
1312 }
1313 }
1314
1315 void vdakgl_(int *charac, float *x, float *y)
1316 {
1317 int temp, vstat, rstat, mvalid, trigger;
1318 float xpos, ypos, timeout;
1319
1320 if (dev_cap[0] != 0.) {
1321 vflush(); /* flush polyline buffer */
1322 temp = 1;
1323 timeout = 1.;
1324 crqlc_(&temp, &timeout, &vstat, &rstat, &mvalid, &trigger, &xpos, &ypos);
1325 if (vstat == CVAL) {
1326 *x = ndc_map_x(xpos);
1327 *y = ndc_map_y(ypos);
1328 *charac = trigger;
1329 }
1330 else {
1331 vdicgi_errh(" SVDI Shell (VDAKGL) invalid request for crqlc ");
1332 }
1333 }
1334 }
1335
1336 void vdstla_(float *x, float *y)
1337 {
1338 int temp, vstat, rstat, mvalid, trigger;
1339 float xpos, ypos, timeout;
1340
1341 if (dev_cap[0] != 0.) {
1342 vflush(); /* flush polyline buffer */
1343 temp = 1;
1344 timeout = 1.;
1345 crqlc_(&temp, &timeout, &vstat, &rstat, &mvalid, &trigger, &xpos, &ypos);
1346 if (vstat == CVAL) {
1347 *x = ndc_map_x(xpos);
1348 *y = ndc_map_y(ypos);
1349 }
1350 else {
1351 vdicgi_errh(" SVDI Shell (VDSTLA) invalid request for crqlc ");
1352 }
1353 }
1354 }
1355
1356 void vdstos_(float attr_array[])
1357 {
1358 int temp;
1359
1360 temp = (int)attr_array[0];
1361 vdstfc_(&temp);
1362 temp = (int)attr_array[1];
1363 vdstbc_(&temp);
1364 vdstin_(attr_array + 2);
1365 temp = (int)attr_array[3];
1366 vdstls_(&temp);
1367 vdstlw_(attr_array + 4);
1368 vdstcs_(attr_array + 5);
1369 }
1370
1371 void vdfram_(int itype) {}
1372
1373 void vbiqpk_(void) {}
1374 void vberrh_(void) {}