home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2008 < prev    next >
Internet Message Format  |  1990-12-28  |  26KB

  1. From: hot@integow.uucp (Roland van Hout)
  2. Newsgroups: alt.sources
  3. Subject: PD plot(4) librarys (and hercules driver for interactive 386) part 6 of 9
  4. Message-ID: <1393@integow.uucp>
  5. Date: 28 Oct 90 03:56:28 GMT
  6.  
  7.  
  8. #!/bin/sh
  9. # This is part 06 of a multipart archive
  10. if touch 2>&1 | fgrep '[-amc]' > /dev/null
  11.  then TOUCH=touch
  12.  else TOUCH=true
  13. fi
  14. # ============= libplot/sun/sunplot.c ==============
  15. echo "x - extracting libplot/sun/sunplot.c (Text)"
  16. sed 's/^X//' << 'SHAR_EOF' > libplot/sun/sunplot.c &&
  17. X/*
  18. X * Sunplot - plotter backend for Sun workstation
  19. X *
  20. X * Copyright (c) 1987 by Sjoerd Mullender, Vrije Universiteit, Amsterdam.
  21. X *
  22. X * This program may be redistributed without fee as long as this copyright
  23. X * notice is in tact.
  24. X * Any commercial use is strictly prohibited.
  25. X */
  26. X
  27. X#include <stdio.h>
  28. X#include <suntool/sunview.h>
  29. X#include <suntool/scrollbar.h>
  30. X#include <suntool/panel.h>
  31. X#include <suntool/canvas.h>
  32. X
  33. X/*
  34. X * Configurable definitions
  35. X */
  36. X#define INIT_CANVAS_SIZE    512
  37. X#define DEFAULT_SPACE        4096
  38. X#define MAX_NAME_LENGTH        128
  39. X
  40. X/*
  41. X * Unconfigurable definitions
  42. X */
  43. X#define BIG            0x7FFFFFFF
  44. X
  45. X#define FORMAT_RASTER        0
  46. X#define FORMAT_ICON        1
  47. X
  48. X#define LABEL            0
  49. X#define SQUARE            1
  50. X#define REVERSE            2
  51. X
  52. Xint client_object;        /* used for notifier */
  53. Xint *me = &client_object;    /* idem */
  54. X
  55. Xint curx, cury;            /* current position on plot */
  56. Xint lox, loy, hix = DEFAULT_SPACE, hiy = DEFAULT_SPACE;    /* current space */
  57. Xint slox, shix, sloy, shiy;    /* saved space settings for zooming */
  58. Xint minx, maxx, miny, maxy;    /* minimum and maximum values encountered */
  59. Xint hor_size, ver_size;        /* canvas size */
  60. Xint turned, xmirror, ymirror;    /* orientation of plot */
  61. Xint zooming;
  62. Xint make_label = TRUE;        /* print labels */
  63. Xint square = TRUE;        /* canvas is square */
  64. Xint reverse = FALSE;        /* reverse video */
  65. XFrame frame, dump_frame, options_frame;
  66. XPanel panel, dump_panel, options_panel;
  67. XPanel_item next_page_item;
  68. XPanel_item hor_size_item, ver_size_item, toggle_item, font_item;
  69. XPanel_item dump_format, dump_file_item;
  70. XCanvas canvas;
  71. XPixwin *pw;
  72. XPixfont *font;
  73. Xchar font_name[MAX_NAME_LENGTH];
  74. Xchar font_dir[] = "/usr/lib/fonts/fixedwidthfonts/";
  75. X
  76. Xshort sunplot_icon_image[] = {
  77. X#include "sunplot.icon"
  78. X};
  79. Xmpr_static(sunplot_icon, 64, 64, 1, sunplot_icon_image);
  80. X
  81. Xchar *malloc(), *realloc();
  82. X
  83. X/*
  84. X *  input module
  85. X */
  86. X
  87. Xstatic char *plotcommands, *plptr;
  88. Xstatic int plotlength;
  89. Xstatic int maxplotlength;
  90. Xstatic int eof_seen;
  91. X
  92. Xgetchr()
  93. X{
  94. X    register c;
  95. X
  96. X    if (plptr < plotcommands + plotlength)
  97. X        return *plptr++ & 0xFF;
  98. X    if (eof_seen || (c = getchar()) == EOF) {
  99. X        eof_seen = 1;
  100. X        return EOF;
  101. X    }
  102. X    if (plotlength >= maxplotlength) {
  103. X        plotcommands = realloc(plotcommands, maxplotlength *= 2);
  104. X        plptr = plotcommands + plotlength;
  105. X    }
  106. X    *plptr++ = c;
  107. X    plotlength++;
  108. X    return c;
  109. X}
  110. X
  111. Xgetint()
  112. X{
  113. X    register n;
  114. X
  115. X    n = getchr();
  116. X    n = n | getchr() << 8;
  117. X    if (n & 0x8000)            /* sign extend */
  118. X        n |= ~0x7FFF;
  119. X    return n;
  120. X}
  121. X
  122. Xchar *getstr()
  123. X{
  124. X    register i = plptr - plotcommands;
  125. X    register c;
  126. X
  127. X    while ((c = getchr()) != EOF && c != '\0' && c != '\n')
  128. X        ;
  129. X    plptr[-1] = 0;
  130. X    return plotcommands + i;
  131. X}
  132. X
  133. X/*
  134. X * plot module
  135. X */
  136. X
  137. X#define point(x,y)    pw_put(pw, plotx(x, y), ploty(x, y), !reverse)
  138. X
  139. X#define line(x0,y0,x1,y1)    pw_vector(pw,plotx(x0,y0),ploty(x0,y0),plotx(x1,y1),ploty(x1,y1),PIX_SRC,!reverse)
  140. X
  141. X#define convx(x,s)    (((x) - lox) * (s) / (hix - lox))
  142. X#define convy(y,s)    (((y) - loy) * (s) / (hiy - loy))
  143. X
  144. Xinitplot()
  145. X{
  146. X    plptr = plotcommands = malloc(maxplotlength = 1024);
  147. X    plotlength = 0;
  148. X}
  149. X
  150. Xplotx(x, y)
  151. X{
  152. X    register a;
  153. X
  154. X    switch (turned) {
  155. X    case 0: a = convx(x, hor_size); break;
  156. X    case 1: a = hor_size - 1 - convy(y, hor_size); break;
  157. X    case 2: a = hor_size - 1 - convx(x, hor_size); break;
  158. X    case 3: a = convy(y, hor_size); break;
  159. X    }
  160. X    return xmirror ? hor_size - 1 - a : a;
  161. X}
  162. X
  163. Xploty(x, y)
  164. X{
  165. X    register a;
  166. X
  167. X    switch (turned) {
  168. X    case 0: a = ver_size - 1 - convy(y, ver_size); break;
  169. X    case 1: a = ver_size - 1 - convx(x, ver_size); break;
  170. X    case 2: a = convy(y, ver_size); break;
  171. X    case 3: a = convx(x, ver_size); break;
  172. X    }
  173. X    a = ymirror ? ver_size - 1 - a : a;
  174. X    return zooming ? a+1 : a;
  175. X}
  176. X
  177. Xlabel(s)
  178. Xchar *s;
  179. X{
  180. X    struct pr_size pr_size;
  181. X
  182. X    if (!make_label)
  183. X        return 0;
  184. X    pw_text(pw, plotx(curx, cury), ploty(curx, cury), reverse ? PIX_NOT(PIX_SRC)&PIX_DST : PIX_SRC|PIX_DST, font, s);
  185. X    pr_size = pf_textwidth(strlen(s), font, s);
  186. X    return pr_size.x * (hix - lox) / hor_size;
  187. X}
  188. X
  189. Xisqrt(n)
  190. X{
  191. X    int a, b, c;
  192. X
  193. X    a = n;
  194. X    b = n;
  195. X    if (n > 1) {
  196. X        while (a > 0) {
  197. X            a = a >> 2;
  198. X            b = b >> 1;
  199. X        }
  200. X        do {
  201. X            a = b;
  202. X            c = n / b;
  203. X            b = (c + a) >> 1;
  204. X        } while ((a - c) < -1 || (a - c) > 1);
  205. X    }
  206. X    return b;
  207. X}
  208. X
  209. Xstatic setcir(x, y, a1, b1, c1, a2, b2, c2)
  210. X{
  211. X    if (a1 * y - b1 * x >= c1 && a2 * y - b2 * x <= c2)
  212. X        point(x, y);
  213. X}
  214. X
  215. Xarc(x, y, x1, y1, x2, y2)
  216. X{
  217. X    register a1 = x1 - x, b1 = y1 - y, a2 = x2 - x, b2 = y2 - y;
  218. X    register c1 = a1 * y - b1 * x, c2 = a2 * y - b2 * x;
  219. X    register r2 = a1 * a1 + b1 * b1;
  220. X    register i, di, sqrt, dx, dy;
  221. X
  222. X    dx = (hix - lox) / hor_size;
  223. X    dy = (hiy - loy) / ver_size;
  224. X    di = dx < dy ? dx : dy;
  225. X    if (di <= 0)
  226. X        di = 1;
  227. X    for (i = isqrt(r2 >> 1); i >= 0; i -= di) {
  228. X        sqrt = isqrt(r2 - i * i);
  229. X        setcir(x + i, y + sqrt, a1, b1, c1, a2, b2, c2);
  230. X        setcir(x + i, y - sqrt, a1, b1, c1, a2, b2, c2);
  231. X        setcir(x - i, y + sqrt, a1, b1, c1, a2, b2, c2);
  232. X        setcir(x - i, y - sqrt, a1, b1, c1, a2, b2, c2);
  233. X        setcir(x + sqrt, y + i, a1, b1, c1, a2, b2, c2);
  234. X        setcir(x + sqrt, y - i, a1, b1, c1, a2, b2, c2);
  235. X        setcir(x - sqrt, y + i, a1, b1, c1, a2, b2, c2);
  236. X        setcir(x - sqrt, y - i, a1, b1, c1, a2, b2, c2);
  237. X    }
  238. X}
  239. X
  240. Xcircle(x, y, r)
  241. X{
  242. X    arc(x, y, x + r, y, x - r, y);
  243. X    arc(x, y, x - r, y, x + r, y);
  244. X}
  245. X
  246. XNotify_value input_reader(me, fd)
  247. Xint *me;
  248. Xint fd;
  249. X{
  250. X    int newx, newy, x, y, r;
  251. X    register char *p;
  252. X
  253. X    do {
  254. X        switch (getchr()) {
  255. X        case 'm':                /* move */
  256. X            curx = getint();
  257. X            cury = getint();
  258. X            if (curx < minx) minx = curx;
  259. X            if (curx > maxx) maxx = curx;
  260. X            if (cury < miny) miny = cury;
  261. X            if (cury > maxy) maxy = cury;
  262. X            break;
  263. X        case 'n':                /* cont */
  264. X            newx = getint();
  265. X            newy = getint();
  266. X            line(curx, cury, newx, newy);
  267. X            curx = newx;
  268. X            cury = newy;
  269. X            if (curx < minx) minx = curx;
  270. X            if (curx > maxx) maxx = curx;
  271. X            if (cury < miny) miny = cury;
  272. X            if (cury > maxy) maxy = cury;
  273. X            break;
  274. X        case 'p':                /* point */
  275. X            curx = getint();
  276. X            cury = getint();
  277. X            point(curx, cury);
  278. X            if (curx < minx) minx = curx;
  279. X            if (curx > maxx) maxx = curx;
  280. X            if (cury < miny) miny = cury;
  281. X            if (cury > maxy) maxy = cury;
  282. X            break;
  283. X        case 'l':                /* line */
  284. X            newx = getint();
  285. X            newy = getint();
  286. X            curx = getint();
  287. X            cury = getint();
  288. X            line(newx, newy, curx, cury);
  289. X            if (newx < minx) minx = newx;
  290. X            if (newx > maxx) maxx = newx;
  291. X            if (newy < miny) miny = newy;
  292. X            if (newy > maxy) maxy = newy;
  293. X            if (curx < minx) minx = curx;
  294. X            if (curx > maxx) maxx = curx;
  295. X            if (cury < miny) miny = cury;
  296. X            if (cury > maxy) maxy = cury;
  297. X            break;
  298. X        case 't':                /* label */
  299. X            p = getstr();
  300. X            curx += label(p);
  301. X            if (curx < minx) minx = curx;
  302. X            if (curx > maxx) maxx = curx;
  303. X            break;
  304. X        case 'a':                /* arc */
  305. X            x = getint();
  306. X            y = getint();
  307. X            newx = getint();
  308. X            newy = getint();
  309. X            curx = getint();
  310. X            cury = getint();
  311. X            arc(x, y, newx, newy, curx, cury);
  312. X            if (x < minx) minx = x;
  313. X            if (x > maxx) maxx = x;
  314. X            if (y < miny) miny = y;
  315. X            if (y > maxy) maxy = y;
  316. X            if (newx < minx) minx = newx;
  317. X            if (newx > maxx) maxx = newx;
  318. X            if (newy < miny) miny = newy;
  319. X            if (newy > maxy) maxy = newy;
  320. X            if (curx < minx) minx = curx;
  321. X            if (curx > maxx) maxx = curx;
  322. X            if (cury < miny) miny = cury;
  323. X            if (cury > maxy) maxy = cury;
  324. X            break;
  325. X        case 'c':                /* circle */
  326. X            curx = getint();
  327. X            cury = getint();
  328. X            r = getint();
  329. X            circle(curx, cury, r);
  330. X            if (curx - r < minx) minx = curx - r;
  331. X            if (curx + r > maxx) maxx = curx + r;
  332. X            if (cury - r < miny) miny = cury - r;
  333. X            if (cury + r > maxy) maxy = cury + r;
  334. X            break;
  335. X        case 'e':                /* erase */
  336. X            panel_set(next_page_item, PANEL_SHOW_ITEM, TRUE, 0);
  337. X            /* fall through */
  338. X        case EOF:
  339. X            notify_set_input_func(me, NOTIFY_FUNC_NULL, fd);
  340. X            if (zooming) {
  341. X                lox = slox;
  342. X                hix = shix;
  343. X                loy = sloy;
  344. X                hiy = shiy;
  345. X                zooming = 0;
  346. X            }
  347. X            return NOTIFY_DONE;
  348. X        case 'f':                /* linemod */
  349. X            getstr();
  350. X            break;
  351. X        case 's':                /* space */
  352. X            if (zooming) {
  353. X                slox = getint();
  354. X                sloy = getint();
  355. X                shix = getint();
  356. X                shiy = getint();
  357. X            } else {
  358. X                lox = getint();
  359. X                loy = getint();
  360. X                hix = getint();
  361. X                hiy = getint();
  362. X            }
  363. X            break;
  364. X        }
  365. X    } while (plptr < plotcommands + plotlength || stdin->_cnt > 0);
  366. X    return NOTIFY_DONE;
  367. X}
  368. X
  369. X/*
  370. X * button routines
  371. X */
  372. X
  373. Xrestartplot()
  374. X{
  375. X    minx = BIG;
  376. X    maxx = -BIG;
  377. X    miny = BIG;
  378. X    maxy = -BIG;
  379. X    plptr = plotcommands;
  380. X
  381. X    /* clear the canvas */
  382. X    pw_writebackground(pw, 0, 0, (int) window_get(canvas, CANVAS_WIDTH),
  383. X                (int) window_get(canvas, CANVAS_HEIGHT),
  384. X                reverse ? PIX_SET : PIX_CLR);
  385. X}
  386. X
  387. Xresetplot()
  388. X{
  389. X    restartplot();
  390. X    plotlength = 0;
  391. X}
  392. X
  393. Xvoid redraw()
  394. X{
  395. X    if (zooming) {
  396. X        lox = slox;
  397. X        hix = shix;
  398. X        loy = sloy;
  399. X        hiy = shiy;
  400. X        zooming = 0;
  401. X    }
  402. X    restartplot();
  403. X    input_reader(me, fileno(stdin));
  404. X}
  405. X
  406. Xvoid nextpage()
  407. X{
  408. X    resetplot();
  409. X    panel_set(next_page_item, PANEL_SHOW_ITEM, FALSE, 0);
  410. X    notify_set_input_func(me, input_reader, fileno(stdin));
  411. X    if (stdin->_cnt > 0)
  412. X        input_reader(me, fileno(stdin));
  413. X}
  414. X
  415. Xvoid zoom()
  416. X{
  417. X    int a;
  418. X
  419. X    if (!zooming) {
  420. X        slox = lox;
  421. X        shix = hix;
  422. X        sloy = loy;
  423. X        shiy = hiy;
  424. X        zooming = 1;
  425. X    }
  426. X    if (maxx == minx) {
  427. X        maxx++;
  428. X        minx--;
  429. X    }
  430. X    if (maxy == miny) {
  431. X        maxy++;
  432. X        miny--;
  433. X    }
  434. X    if ((a = (maxx-minx) * (shiy-sloy) / (shix-slox)) >= maxy-miny) {
  435. X        loy = miny - (a - maxy + miny) / 2;
  436. X        hiy = loy + a;
  437. X        lox = minx;
  438. X        hix = maxx;
  439. X    } else {
  440. X        a = (maxy - miny) * (shix - slox) / (shiy - sloy);
  441. X        lox = minx - (a - maxx + minx) / 2;
  442. X        hix = lox + a;
  443. X        loy = miny;
  444. X        hiy = maxy;
  445. X    }
  446. X    hix++;
  447. X    hiy++;
  448. X    restartplot();
  449. X    input_reader(me, fileno(stdin));
  450. X}
  451. X
  452. Xvoid quit()
  453. X{
  454. X    /* don't ask for confirmation */
  455. X    if (font)
  456. X        pf_close(font);
  457. X    window_set(frame, FRAME_NO_CONFIRM, TRUE, 0);
  458. X    window_destroy(frame);
  459. X}
  460. X
  461. Xvoid turn()
  462. X{
  463. X    int tmp;
  464. X
  465. X    turned = (turned + 1) & 3;
  466. X    tmp = xmirror;
  467. X    xmirror = ymirror;
  468. X    ymirror = tmp;
  469. X}
  470. X
  471. Xvoid mirrorx()
  472. X{
  473. X    xmirror ^= 1;
  474. X}
  475. X
  476. Xvoid mirrory()
  477. X{
  478. X    ymirror ^= 1;
  479. X}
  480. X
  481. Xvoid toggle_proc()
  482. X{
  483. X    if ((int) panel_get(toggle_item, PANEL_TOGGLE_VALUE, SQUARE)) {
  484. X        panel_set(ver_size_item,
  485. X            PANEL_SHOW_ITEM,    FALSE,
  486. X            0);
  487. X        panel_set(hor_size_item,
  488. X            PANEL_LABEL_STRING,    "Canvas size:     ",
  489. X            0);
  490. X    } else {
  491. X        panel_set(ver_size_item,
  492. X            PANEL_SHOW_ITEM,    TRUE,
  493. X            0);
  494. X        panel_set(hor_size_item,
  495. X            PANEL_LABEL_STRING,    "Horizontal size: ",
  496. X            0);
  497. X    }
  498. X}
  499. X
  500. Xvoid options()
  501. X{
  502. X    window_set(options_frame, WIN_SHOW, TRUE, 0);
  503. X}
  504. X
  505. Xvoid options_done()
  506. X{
  507. X    register int r;
  508. X    char *f;
  509. X    Cursor cursor;
  510. X
  511. X    window_set(options_frame, WIN_SHOW, FALSE, 0);
  512. X    r = (int) panel_get(hor_size_item, PANEL_VALUE);
  513. X    if (r != hor_size) {
  514. X        window_set(canvas, CANVAS_WIDTH, r, 0);
  515. X        hor_size = r;
  516. X    }
  517. X    if (square)
  518. X        r = hor_size;
  519. X    else
  520. X        r = (int) panel_get(ver_size_item, PANEL_VALUE);
  521. X    if (r != ver_size) {
  522. X        window_set(canvas, CANVAS_HEIGHT, r, 0);
  523. X        ver_size = r;
  524. X    }
  525. X    f = (char *) panel_get_value(font_item);
  526. X    if (f == 0 || *f == 0) {
  527. X        if (font_name[0] != 0) {
  528. X            font_name[0] = 0;
  529. X            if (font)
  530. X                pf_close(font);
  531. X            font = pf_default();
  532. X        }
  533. X    } else {
  534. X        if (font_name[0] == 0 || strcmp(f, font_name) != 0) {
  535. X            strcpy(font_name, f);
  536. X            f = font_name;
  537. X            if (*f != '/') {
  538. X                f = malloc(strlen(font_dir)+strlen(font_name)+1);
  539. X                strcpy(f, font_dir);
  540. X                strcat(f, font_name);
  541. X            }
  542. X            if (font)
  543. X                pf_close(font);
  544. X            font = pf_open(f);
  545. X            if (f != font_name)
  546. X                free(f);
  547. X        }
  548. X    }
  549. X    if (font == 0) {
  550. X        font_name[0] = 0;
  551. X        font = pf_default();
  552. X    }
  553. X    make_label = (int) panel_get(toggle_item, PANEL_TOGGLE_VALUE, LABEL);
  554. X    square = (int) panel_get(toggle_item, PANEL_TOGGLE_VALUE, SQUARE);
  555. X    reverse = (int) panel_get(toggle_item, PANEL_TOGGLE_VALUE, REVERSE);
  556. X    cursor = (Cursor) window_get(canvas, WIN_CURSOR);
  557. X    cursor_set(cursor,
  558. X            CURSOR_OP, reverse ? PIX_SRC^PIX_DST : PIX_SRC|PIX_DST,
  559. X            0);
  560. X    window_set(canvas, WIN_CURSOR, cursor, 0);
  561. X    redraw();
  562. X}
  563. X
  564. Xvoid dump()
  565. X{
  566. X    window_set(dump_frame, WIN_SHOW, TRUE, 0);
  567. X}
  568. X
  569. Xvoid dump_done()
  570. X{
  571. X    char *file;
  572. X    int width, height;
  573. X    register int x, y;
  574. X    register char *s;
  575. X    register short *p;
  576. X    FILE *f;
  577. X
  578. X    /* we use the fact that the canvas is retained */
  579. X    file = (char *) panel_get_value(dump_file_item);
  580. X    if (file != 0 && *file != 0 && (f = fopen(file, "w")) != 0) {
  581. X        width = (int) window_get(canvas, CANVAS_WIDTH);
  582. X        height = (int) window_get(canvas, CANVAS_HEIGHT);
  583. X        switch ((int) panel_get_value(dump_format)) {
  584. X        case FORMAT_RASTER:
  585. X            pr_dump(pw->pw_prretained, f, (colormap_t *) 0,
  586. X                            RT_STANDARD, 0);
  587. X            break;
  588. X        case FORMAT_ICON:
  589. X            p = mpr_d(pw->pw_prretained)->md_image;
  590. X            fprintf(f, "\
  591. X/* Format_version=1, Width=%d, Height=%d, Depth=1, Valid_bits_per_item=16\n\
  592. X */\n", (width+15) & ~15, height);
  593. X            for (y = 0; y < height; y++) {
  594. X                s = "\t";
  595. X                for (x = 0; x < width; x += 16) {
  596. X                    fprintf(f, "%s0x%04x,", s, *p & 0xFFFF);
  597. X                    p++;
  598. X                    s = "";
  599. X                }
  600. X                fprintf(f, "\n");
  601. X            }
  602. X            break;
  603. X        }
  604. X        fclose(f);
  605. X    }
  606. X    window_set(dump_frame, WIN_SHOW, FALSE, 0);
  607. X}
  608. X
  609. Xvoid fit_screen()
  610. X{
  611. X    register int w, h;
  612. X    
  613. X    w = hor_size + (int) scrollbar_get((Scrollbar) window_get(canvas, WIN_VERTICAL_SCROLLBAR), SCROLL_THICKNESS);
  614. X    h = ver_size + (int) scrollbar_get((Scrollbar) window_get(canvas, WIN_HORIZONTAL_SCROLLBAR), SCROLL_THICKNESS);
  615. X    window_set(canvas, WIN_WIDTH, w, WIN_HEIGHT, h, 0);
  616. X    window_set(canvas, CANVAS_WIDTH, hor_size, CANVAS_HEIGHT, ver_size, 0);
  617. X    window_set(panel, WIN_WIDTH, w, 0);
  618. X    window_fit(frame);
  619. X}
  620. X
  621. X/*
  622. X * initialization
  623. X */
  624. X
  625. Xvoid dump_init()
  626. X{
  627. X    register Pixrect *pr;
  628. X
  629. X    dump_frame = window_create(frame, FRAME,
  630. X            FRAME_DONE_PROC,    dump_done,
  631. X            0);
  632. X    dump_panel = window_create(dump_frame, PANEL, 0);
  633. X    pr = panel_button_image(dump_panel, "Done", 0, (Pixfont *) 0);
  634. X    (void) panel_create_item(dump_panel, PANEL_BUTTON,
  635. X            PANEL_LABEL_IMAGE,    pr,
  636. X            PANEL_NOTIFY_PROC,    dump_done,
  637. X            0);
  638. X    /* order of strings is important (see definitions of FORMAT_*) */
  639. X    dump_format = panel_create_item(dump_panel, PANEL_CYCLE,
  640. X            PANEL_LABEL_STRING,    "Dump format:",
  641. X            PANEL_CHOICE_STRINGS,    "Rasterfile format",
  642. X                        "Icon format",
  643. X                        (char *) 0,
  644. X            0);
  645. X    dump_file_item = panel_create_item(dump_panel, PANEL_TEXT,
  646. X            PANEL_LABEL_X,        ATTR_COL(0),
  647. X            PANEL_LABEL_Y,        ATTR_ROW(1),
  648. X            PANEL_VALUE_DISPLAY_LENGTH, 25,
  649. X            PANEL_LABEL_STRING,    "Dump to file:",
  650. X            0);
  651. X    window_fit(dump_panel);
  652. X    window_fit(dump_frame);
  653. X}
  654. X
  655. Xvoid options_init()
  656. X{
  657. X    register Pixrect *pr;
  658. X
  659. X    options_frame = window_create(frame, FRAME,
  660. X            FRAME_DONE_PROC,    options_done,
  661. X            0);
  662. X    options_panel = window_create(options_frame, PANEL, 0);
  663. X
  664. X    pr = panel_button_image(options_panel, "Done", 0, (Pixfont *) 0);
  665. X    (void) panel_create_item(options_panel, PANEL_BUTTON,
  666. X            PANEL_LABEL_IMAGE,    pr,
  667. X            PANEL_NOTIFY_PROC,    options_done,
  668. X            0);
  669. X    pr = panel_button_image(options_panel, "Rotate", 0, (Pixfont*) 0);
  670. X    (void) panel_create_item(options_panel, PANEL_BUTTON,
  671. X            PANEL_NOTIFY_PROC,    turn,
  672. X            PANEL_LABEL_IMAGE,    pr,
  673. X            0);
  674. X    pr = panel_button_image(options_panel, "X Mirror", 0, (Pixfont*) 0);
  675. X    (void) panel_create_item(options_panel, PANEL_BUTTON,
  676. X            PANEL_NOTIFY_PROC,    mirrorx,
  677. X            PANEL_LABEL_IMAGE,    pr,
  678. X            0);
  679. X    pr = panel_button_image(options_panel, "Y Mirror", 0, (Pixfont*) 0);
  680. X    (void) panel_create_item(options_panel, PANEL_BUTTON,
  681. X            PANEL_NOTIFY_PROC,    mirrory,
  682. X            PANEL_LABEL_IMAGE,    pr,
  683. X            0);
  684. X    toggle_item = panel_create_item(options_panel, PANEL_TOGGLE,
  685. X            PANEL_LAYOUT,        PANEL_HORIZONTAL,
  686. X            PANEL_CHOICE_STRINGS,    "Label",
  687. X                        "Square",
  688. X                        "Reverse",
  689. X                        (char *) 0,
  690. X            PANEL_TOGGLE_VALUE,    LABEL, make_label,
  691. X            PANEL_TOGGLE_VALUE,    SQUARE, square,
  692. X            PANEL_TOGGLE_VALUE,    REVERSE, reverse,
  693. X            PANEL_NOTIFY_PROC,    toggle_proc,
  694. X            0);
  695. X    font_item = panel_create_item(options_panel, PANEL_TEXT,
  696. X            PANEL_VALUE_DISPLAY_LENGTH, 51,
  697. X            PANEL_VALUE_STORED_LENGTH, MAX_NAME_LENGTH,
  698. X            PANEL_LABEL_STRING,    "Font name:",
  699. X            PANEL_VALUE,        font_name,
  700. X            0);
  701. X    hor_size_item = panel_create_item(options_panel, PANEL_SLIDER,
  702. X            PANEL_LABEL_STRING,    "Horizontal size: ",
  703. X            PANEL_VALUE,        hor_size,
  704. X            PANEL_MIN_VALUE,    64,
  705. X            PANEL_MAX_VALUE,    2048,
  706. X            PANEL_SLIDER_WIDTH,    200,
  707. X            0);
  708. X    ver_size_item = panel_create_item(options_panel, PANEL_SLIDER,
  709. X            PANEL_LABEL_STRING,    "Vertical size:   ",
  710. X            PANEL_VALUE,        ver_size,
  711. X            PANEL_MIN_VALUE,    64,
  712. X            PANEL_MAX_VALUE,    2048,
  713. X            PANEL_SLIDER_WIDTH,    200,
  714. X            0);
  715. X    window_fit(options_panel);
  716. X    window_fit(options_frame);
  717. X    if (square) {
  718. X        panel_set(ver_size_item,
  719. X            PANEL_SHOW_ITEM,    FALSE,
  720. X            0);
  721. X        panel_set(hor_size_item,
  722. X            PANEL_LABEL_STRING,    "Canvas size:     ",
  723. X            0);
  724. X    }
  725. X}
  726. X
  727. Xvoid panel_init()
  728. X{
  729. X    register Pixrect *pr;
  730. X
  731. X    panel = window_create(frame, PANEL, 0);
  732. X    pr = panel_button_image(panel, "Next Page", 0, (Pixfont *) 0);
  733. X    next_page_item = panel_create_item(panel, PANEL_BUTTON,
  734. X            PANEL_NOTIFY_PROC,    nextpage,
  735. X            PANEL_LABEL_IMAGE,    pr,
  736. X            0);
  737. X    pr = panel_button_image(panel, "Redraw", 0, (Pixfont *) 0);
  738. X    (void) panel_create_item(panel, PANEL_BUTTON,
  739. X            PANEL_NOTIFY_PROC,    redraw,
  740. X            PANEL_LABEL_IMAGE,    pr,
  741. X            0);
  742. X    pr = panel_button_image(panel, "Zoom", 0, (Pixfont *) 0);
  743. X    (void) panel_create_item(panel, PANEL_BUTTON,
  744. X            PANEL_NOTIFY_PROC,    zoom,
  745. X            PANEL_LABEL_IMAGE,    pr,
  746. X            0);
  747. X    pr = panel_button_image(panel, "Options", 0, (Pixfont *) 0);
  748. X    (void) panel_create_item(panel, PANEL_BUTTON,
  749. X            PANEL_NOTIFY_PROC,    options,
  750. X            PANEL_LABEL_IMAGE,    pr,
  751. X            0);
  752. X    pr = panel_button_image(panel, "Dump", 0, (Pixfont *) 0);
  753. X    (void) panel_create_item(panel, PANEL_BUTTON,
  754. X            PANEL_NOTIFY_PROC,    dump,
  755. X            PANEL_LABEL_IMAGE,    pr,
  756. X            0);
  757. X    pr = panel_button_image(panel, "Fit Screen", 0, (Pixfont *) 0);
  758. X    (void) panel_create_item(panel, PANEL_BUTTON,
  759. X            PANEL_NOTIFY_PROC,    fit_screen,
  760. X            PANEL_LABEL_IMAGE,    pr,
  761. X            0);
  762. X    pr = panel_button_image(panel, "Quit", 0, (Pixfont *) 0);
  763. X    (void) panel_create_item(panel, PANEL_BUTTON,
  764. X            PANEL_NOTIFY_PROC,    quit,
  765. X            PANEL_LABEL_IMAGE,    pr,
  766. X            0);
  767. X    window_fit_height(panel);
  768. X}
  769. X
  770. Xcanvas_init()
  771. X{
  772. X    canvas = window_create(frame, CANVAS,
  773. X            CANVAS_AUTO_SHRINK,    FALSE,
  774. X            CANVAS_WIDTH,        hor_size,
  775. X            CANVAS_HEIGHT,        ver_size,
  776. X            CANVAS_RETAINED,    TRUE,
  777. X            WIN_VERTICAL_SCROLLBAR,    scrollbar_create(0),
  778. X            WIN_HORIZONTAL_SCROLLBAR, scrollbar_create(0),
  779. X            0);
  780. X    pw = canvas_pixwin(canvas);
  781. X}
  782. X
  783. Xmain(argc, argv)
  784. Xchar **argv;
  785. X{
  786. X    initplot();
  787. X
  788. X    hor_size = ver_size = INIT_CANVAS_SIZE;
  789. X    frame = window_create(NULL, FRAME,
  790. X            FRAME_LABEL,        "Sunplot",
  791. X            FRAME_SUBWINDOWS_ADJUSTABLE, FALSE,
  792. X            FRAME_ICON, icon_create(ICON_IMAGE, &sunplot_icon, 0),
  793. X            FRAME_ARGC_PTR_ARGV,    &argc, argv,
  794. X            0);
  795. X    while (argc > 1 && argv[1][0] == '-') {
  796. X        switch (argv[1][1]) {
  797. X        case 'c':
  798. X            if (argv[1][2])
  799. X                hor_size = atoi(&argv[1][2]);
  800. X            else if (argc > 2) {
  801. X                hor_size = atoi(argv[2]);
  802. X                argv[1] = argv[0];
  803. X                argv++;
  804. X                argc--;
  805. X            }
  806. X            if (hor_size < 64)
  807. X                hor_size = 64;
  808. X            ver_size = hor_size;
  809. X            square = TRUE;
  810. X            break;
  811. X        case 'h':
  812. X            if (argv[1][2])
  813. X                hor_size = atoi(&argv[1][2]);
  814. X            else if (argc > 2) {
  815. X                hor_size = atoi(argv[2]);
  816. X                argv[1] = argv[0];
  817. X                argv++;
  818. X                argc--;
  819. X            }
  820. X            if (hor_size < 64)
  821. X                hor_size = 64;
  822. X            square = FALSE;
  823. X            break;
  824. X        case 'v':
  825. X            if (argv[1][2])
  826. X                ver_size = atoi(&argv[1][2]);
  827. X            else if (argc > 2) {
  828. X                ver_size = atoi(argv[2]);
  829. X                argv[1] = argv[0];
  830. X                argv++;
  831. X                argc--;
  832. X            }
  833. X            if (ver_size < 64)
  834. X                ver_size = 64;
  835. X            square = FALSE;
  836. X            break;
  837. X        case 'l':
  838. X            make_label = !make_label;
  839. X            break;
  840. X        case 's':
  841. X            square = !square;
  842. X            break;
  843. X        case 'r':
  844. X            turn();
  845. X            break;
  846. X        case 'x':
  847. X            mirrorx();
  848. X            break;
  849. X        case 'y':
  850. X            mirrory();
  851. X            break;
  852. X        case 'f':
  853. X            if (argv[1][2])
  854. X                strcpy(font_name, &argv[1][2]);
  855. X            else if (argc > 2) {
  856. X                strcpy(font_name, argv[2]);
  857. X                argv[1] = argv[0];
  858. X                argv++;
  859. X                argc--;
  860. X            }
  861. X            break;
  862. X        }
  863. X        argc--;
  864. X        argv[1] = argv[0];
  865. X        argv++;
  866. X    }
  867. X    dump_init();
  868. X    options_init();
  869. X    panel_init();
  870. X    canvas_init();
  871. X    if (font_name[0]) {
  872. X        register char *f = font_name;
  873. X
  874. X        if (*f != '/') {
  875. X            f = malloc(strlen(font_dir)+strlen(font_name)+1);
  876. X            strcpy(f, font_dir);
  877. X            strcat(f, font_name);
  878. X        }
  879. X        font = pf_open(f);
  880. X        if (f != font_name)
  881. X            free(f);
  882. X    }
  883. X    if (font == 0) {
  884. X        font = pf_default();
  885. X        font_name[0] = 0;
  886. X    }
  887. X
  888. X    fit_screen();
  889. X
  890. X    notify_set_input_func(me, input_reader, fileno(stdin));
  891. X
  892. X    window_main_loop(frame);
  893. X
  894. X    exit(0);
  895. X}
  896. SHAR_EOF
  897. $TOUCH -am 1225041788 libplot/sun/sunplot.c &&
  898. chmod 0644 libplot/sun/sunplot.c ||
  899. echo "restore of libplot/sun/sunplot.c failed"
  900. set `wc -c libplot/sun/sunplot.c`;Wc_c=$1
  901. if test "$Wc_c" != "19634"; then
  902.     echo original size 19634, current size $Wc_c
  903. fi
  904. # ============= libplot/sun/sunplot.icon ==============
  905. echo "x - extracting libplot/sun/sunplot.icon (Text)"
  906. sed 's/^X//' << 'SHAR_EOF' > libplot/sun/sunplot.icon &&
  907. X/* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
  908. X */
  909. X    0x0000,0x0000,0x0000,0x0400,0x0000,0x0000,0x0000,0x0400,
  910. X    0x0000,0x0000,0x0000,0x0800,0x0000,0x0000,0x0000,0x0800,
  911. X    0x0000,0x0000,0x0000,0x1000,0x0000,0x0000,0x7FF0,0x1000,
  912. X    0x0000,0x0007,0x800F,0x1000,0x0000,0x0038,0x0000,0xE000,
  913. X    0x0000,0x00C0,0x0000,0x3800,0x2000,0x0300,0x0000,0x4600,
  914. X    0x1800,0x0400,0x0000,0x4100,0x07FF,0x0800,0x0000,0x8080,
  915. X    0x03FF,0xFFFC,0x0000,0x8060,0x01C1,0xFFFF,0xFFF0,0x8010,
  916. X    0x00E0,0x8037,0xFFFF,0xF008,0x0071,0x0030,0x001F,0xFE04,
  917. X    0x003A,0x0030,0x0002,0x0002,0x001E,0x0060,0x0002,0x0002,
  918. X    0x000F,0x0060,0x0002,0x0001,0x000F,0x8060,0x0004,0x0000,
  919. X    0x0011,0xC0C0,0x0004,0x0000,0x0010,0xE0C0,0x0008,0x0000,
  920. X    0x0020,0x7180,0x0008,0x0000,0x0020,0x3B80,0x0008,0x0000,
  921. X    0x0040,0x1F00,0x0010,0x0000,0x0040,0x0E00,0x0010,0x0000,
  922. X    0x0040,0x1F80,0x0020,0x0000,0x0080,0x3BC0,0x0020,0x0000,
  923. X    0x0080,0x70E0,0x0040,0x0000,0x0081,0xE070,0x0040,0x0000,
  924. X    0x0081,0xC038,0x0040,0x0000,0x0100,0x001C,0x0080,0x0000,
  925. X    0x0100,0x000E,0x0080,0x0000,0x0100,0x0007,0x0100,0x0000,
  926. X    0x0100,0x0003,0x8100,0x0000,0x0100,0x0001,0xE100,0x0000,
  927. X    0x0100,0x0000,0xF200,0x0000,0x0100,0x0000,0x3A00,0x0000,
  928. X    0x0100,0x0000,0x1C00,0x0000,0x0100,0x0000,0x0E00,0x0000,
  929. X    0x0100,0x0000,0x0F00,0x0000,0x0100,0x0000,0x0B80,0x0000,
  930. X    0x0080,0x0000,0x0980,0x0000,0x0080,0x0000,0x1040,0x0000,
  931. X    0x0080,0x0000,0x1020,0x0000,0x0080,0x0000,0x2000,0x0000,
  932. X    0x0040,0x0000,0x2000,0x0000,0x0040,0x0000,0x2000,0x0000,
  933. X    0x0FFF,0xFFFF,0xFFFF,0xFFE0,0x0924,0x9249,0x2492,0x4920,
  934. X    0x0924,0x9249,0x2492,0x4920,0x0924,0x9249,0x2492,0x4920,
  935. X    0x0800,0x0000,0x0000,0x0020,0x0800,0x0000,0x0000,0x0020,
  936. X    0x0800,0x0000,0x0000,0x0021,0x0800,0x0000,0x0000,0x0022,
  937. X    0x0800,0x0000,0x0000,0x0022,0x0800,0x0000,0x0000,0x0024,
  938. X    0x0FFF,0xFFFF,0xFFFF,0xFFE8,0x0000,0x4004,0x0000,0x0010,
  939. X    0x0000,0x3008,0x0000,0x0060,0x0000,0x0808,0x0000,0x0080,
  940. X    0x0000,0x0410,0x0000,0x0100,0x0000,0x0310,0x0000,0x0600
  941. SHAR_EOF
  942. $TOUCH -am 1225041788 libplot/sun/sunplot.icon &&
  943. chmod 0644 libplot/sun/sunplot.icon ||
  944. echo "restore of libplot/sun/sunplot.icon failed"
  945. set `wc -c libplot/sun/sunplot.icon`;Wc_c=$1
  946. if test "$Wc_c" != "1933"; then
  947.     echo original size 1933, current size $Wc_c
  948. fi
  949. # ============= libplot/cgi/CGI.h ==============
  950. if test ! -d 'libplot/cgi'; then
  951.     echo "x - creating directory libplot/cgi"
  952.     mkdir 'libplot/cgi'
  953. fi
  954. echo "x - extracting libplot/cgi/CGI.h (Text)"
  955. sed 's/^X//' << 'SHAR_EOF' > libplot/cgi/CGI.h &&
  956. X
  957. Xtypedef    struct
  958. X{
  959. X    int    x1, y1, x2, y2;
  960. X    int    c;        /* || ascii code || strlen    */
  961. X    char    *str;        /* String            */
  962. X} herc_args;
  963. SHAR_EOF
  964. $TOUCH -am 0511125390 libplot/cgi/CGI.h &&
  965. chmod 0666 libplot/cgi/CGI.h ||
  966. echo "restore of libplot/cgi/CGI.h failed"
  967. set `wc -c libplot/cgi/CGI.h`;Wc_c=$1
  968. if test "$Wc_c" != "119"; then
  969.     echo original size 119, current size $Wc_c
  970. fi
  971. # ============= libplot/cgi/CGI.mk ==============
  972. echo "x - extracting libplot/cgi/CGI.mk (Text)"
  973. sed 's/^X//' << 'SHAR_EOF' > libplot/cgi/CGI.mk &&
  974. X#    SCCS:    @(#)tCGI.mk    5.1 
  975. X
  976. XOWN=    bin        #file owner
  977. XGRP=    bin        #file group
  978. XPROT=    664        #protections
  979. X
  980. XINSDIR = /usr/lib/386
  981. XTESTDIR = .
  982. X#    c compile flags and system libraries to link with
  983. X#    DEBUG can be defined on the make command line e.g.:
  984. X#    $ make -DDEBUG=-Zi
  985. X
  986. XCFLAGS = -O $(DEBUG)
  987. XLINK_LIBS    =    -lx -lm -lccgi
  988. XSOURCE = libCGI.c cgistart.c cgistuff.c gtexttests.c
  989. XOFILES = libCGI.o cgistart.o cgistuff.o gtexttests.o
  990. XMAKE = make
  991. X
  992. Xall:    $(SOURCE)
  993. X    cc $(CFLAGS) $(MODEL) -c $(SOURCE)
  994. X    :
  995. X
  996. XlibCGI.a:    $(OFILES)
  997. X    chmod $(PROT) $(OFILES)
  998. X    chgrp $(GRP)  $(OFILES)
  999. X    chown $(OWN)  $(OFILES)
  1000. X    -rm libCGI.a
  1001. X    ar r $(TESTDIR)/libCGI.a $(OFILES)
  1002. X    ranlib libCGI.a
  1003. X    @echo "Done building $(libCGI.a)"
  1004. X
  1005. X
  1006. Xinstall: all save move
  1007. X
  1008. Xclean:
  1009. X    -rm -f $(OFILES)
  1010. X
  1011. Xclobber: clean
  1012. X    -rm -f $(TESTDIR)/libCGI.a
  1013. X
  1014. Xdelete:    clobber
  1015. X    rm -f $(SOURCE)
  1016. X
  1017. Xmove:
  1018. X    -rm -f $(INSDIR)/SlibCGI.a
  1019. X    cp $(TESTDIR)/libCGI.a $(INSDIR)/SlibCGI.a
  1020. X    chmod $(PROT) $(INSDIR)/SlibCGI.a
  1021. X    chmod -x $(INSDIR)/SlibCGI.a    # not executable
  1022. X    chgrp $(GRP) $(INSDIR)/SlibCGI.a
  1023. X    chown $(OWN) $(INSDIR)/SlibCGI.a
  1024. X
  1025. Xsave:        
  1026. X    -if test -f $(INSDIR)/SlibCGI.a ; \
  1027. X    then \
  1028. X        rm -f $(INSDIR)/OLDlibCGI.a ; \
  1029. X        cp $(INSDIR)/SlibCGI.a $(INSDIR)/OLDlibCGI.a ; \
  1030. X        chmod $(PROT) $(INSDIR)/OLDlibCGI.a ; \
  1031. X        chmod -x $(INSDIR)/OLDlibCGI.a ; \
  1032. X        chgrp $(GRP) $(INSDIR)/OLDlibCGI.a ; \
  1033. X        chown $(OWN) $(INSDIR)/OLDlibCGI.a ; \
  1034. X    fi
  1035. X
  1036. X
  1037. X    
  1038. SHAR_EOF
  1039. $TOUCH -am 1014212290 libplot/cgi/CGI.mk &&
  1040. chmod 0666 libplot/cgi/CGI.mk ||
  1041. echo "restore of libplot/cgi/CGI.mk failed"
  1042. set `wc -c libplot/cgi/CGI.mk`;Wc_c=$1
  1043. if test "$Wc_c" != "1343"; then
  1044.     echo original size 1343, current size $Wc_c
  1045. fi
  1046. echo "End of part 6, continue with part 7"
  1047. exit 0
  1048.  
  1049.  
  1050.  
  1051.  
  1052. -- 
  1053. UUCP: ..!uunet!mcsun!hp4nl!integow!hot    or  hot@integow.UUCP or hot@hot.mug
  1054. Roland van Hout, Sr. software engineer, Integrity software consultants, 
  1055.          Pelmolenlaan 16, 3447 GW Woerden, Netherlands,
  1056.             tel +31 3480-30131, fax +31 3480-30182
  1057.