home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / plotting / imagetoo / imagetl1.lha / Imagetool / src+obj / plot.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-11  |  32.4 KB  |  1,213 lines

  1. /* cat > headers/plot.h << "EOF" */
  2. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  3. /* plot.h: header for plot.c file            */
  4. /*       plot.c includes routines that do        */
  5. /*       quantitative analysis of images, scaling    */
  6. /*       information set, line graph plotting,    */
  7. /*       laserwriter hard copy. 2-D, 3-D and        */
  8. /*       laserwriter related routines added.        */
  9. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  10. /* SCCS information: %W%    %G% - NCSA */
  11.  
  12. #define plot_h        1
  13.  
  14. #include "all.h"
  15. #include "icons.h"
  16. #include "newext.h"
  17.  
  18.     static Panel_item stats_xmin_obj,stats_xmax_obj;
  19.     static Panel_item stats_ymin_obj,stats_ymax_obj;
  20.     static Panel_item stats_gmin_obj,stats_gmax_obj;
  21.     static Panel_item scale_but;
  22.  
  23.     static FILE *pf = NULL;
  24.  
  25.     static int save_gmode;
  26.     static int flip_flop;
  27.  
  28.     static char *jerk;
  29.  
  30.     static bool print_true = FALSE;
  31.  
  32.     static Frame create_stats();
  33.     static void done_plot();
  34.     static void dump_plot();
  35.     static void draw_proc();
  36.     static void get_scaling();
  37.     static void hide_stats();
  38.     static Notify_value my_destroy_interposer();
  39.     static Notify_value my_notice_interposer();
  40.     static void pcan_controller();
  41.  
  42. /* EOF */
  43. /* cat > src+obj/plot/clear_plot.c << "EOF" */
  44. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  45. /* clear_plot: clear the plot                */
  46. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  47. /* SCCS information: %W%    %G% - NCSA */
  48.  
  49. /* #include "plot.h" */
  50.  
  51. void
  52. clear_plot (item, event)
  53.     Panel_item      item;
  54.     Event          *event;
  55. {
  56.     last_dir = 0;
  57.     last_xscale = last_yscale = (float) 0;
  58.     pw_writebackground ((Pixwin *) canvas_pixwin (pcanvas), 0, 0,
  59.                 (int) window_get (pcanvas, CANVAS_WIDTH),
  60.                 (int) window_get (pcanvas, CANVAS_HEIGHT), PIX_CLR);
  61.     if (pf != NULL)
  62.     {
  63.         rewind (pf);
  64.         ftruncate (fileno (pf), 0);
  65.     }
  66.     pwInit ();
  67. }
  68. /* EOF */
  69. /* cat > src+obj/plot/create_graph_menu.c << "EOF" */
  70. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  71. /* create_graph_menu: create menu for 'GRAPH'        */
  72. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  73. /* SCCS information: %W%    %G% - NCSA */
  74.  
  75. /* #include "plot.h" */
  76.  
  77. create_graph_menu ()
  78. {
  79.     graph_menu = menu_create (
  80.                   MENU_FONT, font_menu,
  81.                   MENU_STRINGS, "XY", "Contour", "3D", 0,
  82.                   MENU_NOTIFY_PROC, plot_action,
  83.                   0);
  84. }
  85. /* EOF */
  86. /* cat > src+obj/plot/create_plot_window.c << "EOF" */
  87. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  88. /* create_plot_window: create plot window        */
  89. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  90. /* SCCS information: %W%    %G% - NCSA */
  91.  
  92. /* #include "plot.h" */
  93.  
  94. create_plot_window ()
  95. {
  96.     Panel           panel;
  97.     int             top, left, width, height, l, t, i;
  98.  
  99.     left = (int) window_get (base, WIN_X);
  100.     top = (int) window_get (base, WIN_Y);
  101.     width = (int) window_get (base, WIN_WIDTH);
  102.     height = (int) window_get (base, WIN_HEIGHT);
  103.     if ((l = left + width / 2) + 650 > 1150)
  104.         l = 1150 - 650;
  105.     if ((t = top + height / 2) - 600 < 0)
  106.         t = 0;
  107.  
  108.     plot_window = window_create (0, FRAME,
  109.                      FRAME_ICON, &plot_icon,
  110.                      FRAME_SHOW_LABEL, TRUE,
  111.                      FRAME_LABEL, "Graph_window, ImageTool",
  112.                      FRAME_INHERIT_COLORS, TRUE,
  113.                      WIN_WIDTH, 650,
  114.                      WIN_HEIGHT, 600,
  115.                      WIN_X, 1150 - 650,
  116.                      WIN_Y, 900 - 600,
  117.                      WIN_SHOW, FALSE,
  118.                      0);
  119.     panel = window_create (plot_window, PANEL, 0);
  120.     title_item = panel_create_item (panel, PANEL_TEXT,
  121.                     PANEL_ITEM_X, ATTR_COL (1),
  122.                     PANEL_ITEM_Y, ATTR_ROW (0),
  123.                     PANEL_VALUE_STORED_LENGTH, MAXNAMELEN - 1,
  124.                     PANEL_VALUE_DISPLAY_LENGTH, 30,
  125.                     PANEL_LABEL_STRING, "Title:",
  126.                     PANEL_LABEL_BOLD, TRUE,
  127.                     0);
  128.     level_item = panel_create_item (panel, PANEL_TEXT,
  129.                     PANEL_ITEM_X, ATTR_COL (1),
  130.                     PANEL_ITEM_Y, ATTR_ROW (0),
  131.                     PANEL_VALUE_STORED_LENGTH, 256,
  132.                     PANEL_VALUE_DISPLAY_LENGTH, 30,
  133.                     PANEL_LABEL_STRING, "Contour levels:",
  134.                     PANEL_LABEL_BOLD, TRUE,
  135.                     0);
  136.     yaw_item = panel_create_item (panel, PANEL_TEXT,
  137.                       PANEL_ITEM_X, ATTR_COL (1),
  138.                       PANEL_ITEM_Y, ATTR_ROW (0),
  139.                       PANEL_VALUE_STORED_LENGTH, 4,
  140.                       PANEL_VALUE_DISPLAY_LENGTH, 4,
  141.                       PANEL_LABEL_STRING, "Yaw:",
  142.                       PANEL_VALUE, "10",
  143.                       PANEL_SHOW_ITEM, FALSE,
  144.                       PANEL_LABEL_BOLD, TRUE,
  145.                       0);
  146.     pitch_item = panel_create_item (panel, PANEL_TEXT,
  147.                     PANEL_ITEM_X, ATTR_COL (13),
  148.                     PANEL_ITEM_Y, ATTR_ROW (0),
  149.                     PANEL_VALUE_STORED_LENGTH, 4,
  150.                     PANEL_VALUE_DISPLAY_LENGTH, 4,
  151.                     PANEL_LABEL_STRING, "Pitch:",
  152.                     PANEL_VALUE, "40",
  153.                     PANEL_SHOW_ITEM, FALSE,
  154.                     PANEL_LABEL_BOLD, TRUE,
  155.                     0);
  156.     roll_item = panel_create_item (panel, PANEL_TEXT,
  157.                        PANEL_ITEM_X, ATTR_COL (27),
  158.                        PANEL_ITEM_Y, ATTR_ROW (0),
  159.                        PANEL_VALUE_STORED_LENGTH, 4,
  160.                        PANEL_VALUE_DISPLAY_LENGTH, 4,
  161.                        PANEL_LABEL_STRING, "Roll:",
  162.                        PANEL_VALUE, "5",
  163.                        PANEL_SHOW_ITEM, FALSE,
  164.                        PANEL_LABEL_BOLD, TRUE,
  165.                        0);
  166.     scale_but = panel_create_item (panel, PANEL_BUTTON,
  167.                        PANEL_ITEM_X, ATTR_COL (40),
  168.                        PANEL_ITEM_Y, ATTR_ROW (0),
  169.                        PANEL_LABEL_IMAGE, panel_button_image (panel, "Scale", 5, 0),
  170.                        PANEL_LABEL_BOLD, TRUE,
  171.                        PANEL_NOTIFY_PROC, show_stats,
  172.                        0);
  173.     panel_create_item (panel, PANEL_BUTTON,
  174.                PANEL_ITEM_X, ATTR_COL (48),
  175.                PANEL_ITEM_Y, ATTR_ROW (0),
  176.                PANEL_LABEL_IMAGE, panel_button_image (panel, "Draw", 5, 0),
  177.                PANEL_LABEL_BOLD, TRUE,
  178.                PANEL_NOTIFY_PROC, draw_proc,
  179.                0);
  180.     panel_create_item (panel, PANEL_BUTTON,
  181.                PANEL_ITEM_X, ATTR_COL (56),
  182.                PANEL_ITEM_Y, ATTR_ROW (0),
  183.                PANEL_LABEL_IMAGE, panel_button_image (panel, "Clear", 5, 0),
  184.                PANEL_LABEL_BOLD, TRUE,
  185.                PANEL_NOTIFY_PROC, clear_plot,
  186.                0);
  187.     panel_create_item (panel, PANEL_BUTTON,
  188.                PANEL_ITEM_X, ATTR_COL (64),
  189.                PANEL_ITEM_Y, ATTR_ROW (0),
  190.                PANEL_LABEL_IMAGE, panel_button_image (panel, "Print", 5, 0),
  191.                PANEL_LABEL_BOLD, TRUE,
  192.                PANEL_NOTIFY_PROC, dump_plot,
  193.                0);
  194.     panel_create_item (panel, PANEL_BUTTON,
  195.                PANEL_ITEM_X, ATTR_COL (72),
  196.                PANEL_ITEM_Y, ATTR_ROW (0),
  197.                PANEL_LABEL_IMAGE, panel_button_image (panel, "Done", 5, 0),
  198.                PANEL_LABEL_BOLD, TRUE,
  199.                PANEL_NOTIFY_PROC, done_plot,
  200.                0);
  201.     window_fit_height (panel);
  202.  
  203.     pcanvas = window_create (plot_window, CANVAS,
  204.                  CANVAS_AUTO_SHRINK, FALSE,
  205.                  CANVAS_FIXED_IMAGE, TRUE,
  206.                  CANVAS_RETAINED, TRUE,
  207.                  CANVAS_WIDTH, 600,
  208.                  CANVAS_HEIGHT, 600,
  209.                  WIN_BELOW, panel,
  210.                  WIN_X, 0,
  211.                  WIN_EVENT_PROC, pcan_controller,
  212.                  0);
  213.     window_fit (pcanvas);
  214.     window_fit (plot_window);
  215.  
  216.         /* set color map same as imagetool window */
  217.     init_same_colormap ((Pixwin *) window_get (plot_window, WIN_PIXWIN));
  218.     init_same_colormap ((Pixwin *) window_get (panel, WIN_PIXWIN));
  219.     init_same_colormap ((Pixwin *) canvas_pixwin (pcanvas));
  220.  
  221.         /* enable my own destroy and event interposer */
  222.     (void) notify_interpose_destroy_func (plot_window, my_destroy_interposer);
  223.     (void) notify_interpose_event_func (plot_window, my_notice_interposer,
  224.                         NOTIFY_SAFE);
  225. }
  226. /* EOF */
  227. /* cat > src+obj/plot/create_stats.c << "EOF" */
  228. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  229. /* create_stats: (static) create stats            */
  230. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  231. /* SCCS information: %W%    %G% - NCSA */
  232.  
  233. /* #include "plot.h" */
  234.  
  235. static          Frame
  236. create_stats ()
  237. {
  238.     Panel           panel;
  239.     int             left, top, width, height, w, h;
  240.  
  241.     scale_box = window_create (base, FRAME,
  242.                    FRAME_SHOW_LABEL, FALSE,
  243.                    FRAME_INHERIT_COLORS, TRUE,
  244.                    WIN_SHOW, FALSE,
  245.                    0);
  246.     panel = window_create (scale_box, PANEL, 0);
  247.     panel_create_item (panel, PANEL_MESSAGE,
  248.                PANEL_ITEM_X, ATTR_COL (1),
  249.                PANEL_ITEM_Y, ATTR_ROW (0),
  250.                PANEL_LABEL_STRING, "Please enter scaling information: ",
  251.                PANEL_LABEL_BOLD, TRUE,
  252.                0);
  253.     stats_xmin_obj = panel_create_item (panel, PANEL_TEXT,
  254.                         PANEL_ITEM_X, ATTR_COL (4),
  255.                         PANEL_ITEM_Y, ATTR_ROW (1),
  256.                         PANEL_VALUE_STORED_LENGTH, 10,
  257.                         PANEL_VALUE_DISPLAY_LENGTH, 10,
  258.                         PANEL_LABEL_STRING, "Xmin: ",
  259.                         PANEL_LABEL_BOLD, FALSE,
  260.                         0);
  261.     stats_xmax_obj = panel_create_item (panel, PANEL_TEXT,
  262.                         PANEL_ITEM_X, ATTR_COL (24),
  263.                         PANEL_ITEM_Y, ATTR_ROW (1),
  264.                         PANEL_VALUE_STORED_LENGTH, 10,
  265.                         PANEL_VALUE_DISPLAY_LENGTH, 10,
  266.                         PANEL_LABEL_STRING, "Xmax: ",
  267.                         PANEL_LABEL_BOLD, FALSE,
  268.                         0);
  269.     stats_ymin_obj = panel_create_item (panel, PANEL_TEXT,
  270.                         PANEL_ITEM_X, ATTR_COL (4),
  271.                         PANEL_ITEM_Y, ATTR_ROW (2),
  272.                         PANEL_VALUE_STORED_LENGTH, 10,
  273.                         PANEL_VALUE_DISPLAY_LENGTH, 10,
  274.                         PANEL_LABEL_STRING, "Ymin: ",
  275.                         PANEL_LABEL_BOLD, FALSE,
  276.                         0);
  277.     stats_ymax_obj = panel_create_item (panel, PANEL_TEXT,
  278.                         PANEL_ITEM_X, ATTR_COL (24),
  279.                         PANEL_ITEM_Y, ATTR_ROW (2),
  280.                         PANEL_VALUE_STORED_LENGTH, 10,
  281.                         PANEL_VALUE_DISPLAY_LENGTH, 10,
  282.                         PANEL_LABEL_STRING, "Ymax: ",
  283.                         PANEL_LABEL_BOLD, FALSE,
  284.                         0);
  285.     stats_gmin_obj = panel_create_item (panel, PANEL_TEXT,
  286.                         PANEL_ITEM_X, ATTR_COL (4),
  287.                         PANEL_ITEM_Y, ATTR_ROW (3),
  288.                         PANEL_VALUE_STORED_LENGTH, 10,
  289.                         PANEL_VALUE_DISPLAY_LENGTH, 10,
  290.                         PANEL_LABEL_STRING, "Gmin: ",
  291.                         PANEL_LABEL_BOLD, FALSE,
  292.                         0);
  293.     stats_gmax_obj = panel_create_item (panel, PANEL_TEXT,
  294.                         PANEL_ITEM_X, ATTR_COL (24),
  295.                         PANEL_ITEM_Y, ATTR_ROW (3),
  296.                         PANEL_VALUE_STORED_LENGTH, 10,
  297.                         PANEL_VALUE_DISPLAY_LENGTH, 10,
  298.                         PANEL_LABEL_STRING, "Gmax: ",
  299.                         PANEL_LABEL_BOLD, FALSE,
  300.                         0);
  301.     panel_create_item (panel, PANEL_CYCLE,
  302.                PANEL_ITEM_X, ATTR_COL (2),
  303.                PANEL_ITEM_Y, ATTR_ROW (4),
  304.                PANEL_LABEL_STRING, "Scaling type: ",
  305.                PANEL_CHOICE_STRINGS, "Logarithmic", "Linear", 0,
  306.                PANEL_VALUE, 1,
  307.                PANEL_LABEL_BOLD, FALSE,
  308.                PANEL_NOTIFY_PROC, get_scaling,
  309.                0);
  310.     panel_create_item (panel, PANEL_BUTTON,
  311.                PANEL_ITEM_X, ATTR_COL (38),
  312.                PANEL_ITEM_Y, ATTR_ROW (4),
  313.                PANEL_LABEL_IMAGE, panel_button_image (panel, "Ok", 3, NULL),
  314.                PANEL_CLIENT_DATA, 1,
  315.                PANEL_NOTIFY_PROC, hide_stats,
  316.                0);
  317.     panel_create_item (panel, PANEL_BUTTON,
  318.                PANEL_ITEM_X, ATTR_COL (44),
  319.                PANEL_ITEM_Y, ATTR_ROW (4),
  320.                PANEL_LABEL_IMAGE, panel_button_image (panel, "Cancel", 5, NULL),
  321.                PANEL_CLIENT_DATA, 0,
  322.                PANEL_NOTIFY_PROC, hide_stats,
  323.                0);
  324.     window_fit (panel);
  325.     window_fit (scale_box);
  326.  
  327.     left = (int) window_get (base, WIN_X);
  328.     top = (int) window_get (base, WIN_Y);
  329.     width = (int) window_get (base, WIN_WIDTH);
  330.     height = (int) window_get (base, WIN_HEIGHT);
  331.     w = (int) window_get (scale_box, WIN_WIDTH);
  332.     h = (int) window_get (scale_box, WIN_HEIGHT);
  333.     window_set (scale_box,
  334.             WIN_X, left + width / 2 - w / 2,
  335.             WIN_Y, top + height / 2 - h / 2,
  336.             0);
  337.  
  338.          /* set color of plot window same as imagetool window */
  339.     init_same_colormap ((Pixwin *) window_get (panel, WIN_PIXWIN));
  340.     init_same_colormap ((Pixwin *) window_get (scale_box, WIN_PIXWIN));
  341.  
  342.     return scale_box;
  343. }
  344. /* EOF */
  345. /* cat > src+obj/plot/done_plot.c << "EOF" */
  346. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  347. /* done_plot: (static) finished plotting        */
  348. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  349. /* SCCS information: %W%    %G% - NCSA */
  350.  
  351. /* #include "plot.h" */
  352. static void
  353. done_plot (item, event)
  354.     Panel_item      item;
  355.     Event          *event;
  356. {
  357.     window_set (plot_window, FRAME_NO_CONFIRM, TRUE, 0);
  358.     window_destroy (plot_window);
  359. }
  360. /* EOF */
  361. /* cat > src+obj/plot/draw_proc.c << "EOF" */
  362. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  363. /* draw_proc: (static) draw procedure            */
  364. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  365. /* SCCS information: %W%    %G% - NCSA */
  366.  
  367. /* #include "plot.h" */
  368.  
  369. static void
  370. draw_proc (item, event)
  371.     Panel_item      item;
  372.     Event          *event;
  373. {
  374.     switch (graph_mode)
  375.     {
  376.         case PLOT_XY:
  377.             plot_linear ();
  378.             break;
  379.         case PLOT_CON:
  380.             plot_twod ();
  381.             break;
  382.         case PLOT_3D:
  383.             plot_threed ();
  384.             break;
  385.     }
  386. }
  387. /* EOF */
  388. /* cat > src+obj/plot/dump_plot.c << "EOF" */
  389. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  390. /* dump_plot: (static) simple plot            */
  391. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  392. /* SCCS information: %W%    %G% - NCSA */
  393.  
  394. /* #include "plot.h" */
  395.  
  396. static void
  397. dump_plot (item, event)
  398.     Panel_item      item;
  399.     Event          *event;
  400. {
  401.     if (strlen (printer) == 0)
  402.         set_printer ();
  403.  
  404.     if (!print_true)
  405.     {
  406.         print_true = TRUE;
  407.         draw_proc ();
  408.         print_true = FALSE;
  409.     }
  410.  
  411.     if (flip_flop)
  412.     {
  413.         fprintf (pf, "stroke\n");
  414.         flip_flop = 0;
  415.     }
  416.     fprintf (pf, "showpage\n");
  417.     fflush (pf);
  418.  
  419.     if (strlen (printer) == 0)
  420.         sprintf (msgstr, "lpr %s\n", jerk);
  421.     else
  422.         sprintf (msgstr, "lpr -P%s %s\n", printer, jerk);
  423.     tty_write (msgstr);
  424.         /* ttysw_input(ttysw,msgstr,strlen(msgstr)); */
  425.  
  426.     if (print_true)
  427.         fseek (pf, -9, 1);    /* chop off "showpage\n" */
  428. }
  429. /* EOF */
  430. /* cat > src+obj/plot/erase_line.c << "EOF" */
  431. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  432. /* erase_line: erase line                */
  433. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  434. /* SCCS information: %W%    %G% - NCSA */
  435.  
  436. /* #include "plot.h" */
  437.  
  438. erase_line ()
  439. {
  440.     if (line_drawn)
  441.     {        
  442.             /* erase line */
  443.         pw_vector (pw, line_rec.x1, line_rec.y1, line_rec.x2, line_rec.y2,
  444.                PIX_NOT (PIX_DST), 255);
  445.         line_drawn = 0;
  446.     }
  447. }
  448. /* EOF */
  449. /* cat > src+obj/plot/erase_square.c << "EOF" */
  450. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  451. /* erase_square: erase square                */
  452. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  453. /* SCCS information: %W%    %G% - NCSA */
  454.  
  455. /* #include "plot.h" */
  456.  
  457. erase_square ()
  458. {
  459.     if (square_drawn)
  460.     {
  461.             /* erase square */
  462.         draw_square (&square);
  463.         square_drawn = 0;
  464.     }
  465. }
  466. /* EOF */
  467. /* cat > src+obj/plot/get_eqn.c << "EOF" */
  468. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  469. /* get_eqn: get equation                */
  470. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  471. /* SCCS information: %W%    %G% - NCSA */
  472.  
  473. /* #include "plot.h" */
  474.  
  475. get_eqn (x1, y1, x2, y2, a, b)
  476.     float          *a, *b;
  477. {
  478.     float           x, y;
  479.  
  480.     x = (float) (x2 - x1);
  481.     y = (float) (y2 - y1);
  482.     *a = y / x;
  483.     *b = (float) (y1 * x2 - y2 * x1) / x;
  484. }
  485. /* EOF */
  486. /* cat > src+obj/plot/get_gvalue.c << "EOF" */
  487. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  488. /* get_gvalue: get g value                */
  489. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  490. /* SCCS information: %W%    %G% - NCSA */
  491.  
  492. /* #include "plot.h" */
  493.  
  494. float
  495. get_gvalue (cindex)
  496. {
  497.     double          gg;
  498.     float           g = stats_gmax - stats_gmin;
  499.     float           result;
  500.  
  501.     if (linear_scaling)
  502.         result = g * cindex / 255.0 + stats_gmin;
  503.     else
  504.     {
  505.         gg = log10 ((double) stats_gmax) - log10 ((double) stats_gmin);
  506.         result = (float) (gg * ((double) cindex / 255) + log10 ((double) stats_gmin));
  507.     }
  508.     return (result);
  509. }
  510. /* EOF */
  511. /* cat > src+obj/plot/get_matrix.c << "EOF" */
  512. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  513. /* get_matrix: get matrix                */
  514. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  515. /* SCCS information: %W%    %G% - NCSA */
  516.  
  517. /* #include "plot.h" */
  518.  
  519. get_matrix (data, xdim, ydim, xpos, ypos)
  520.     Point          *data;
  521.     int             xdim, ydim, xpos, ypos;
  522. {
  523.     Point          *pt = data;
  524.     struct pixrect *pr;
  525.     struct mpr_data *mpr;
  526.     int             i, j, tmp, npad;
  527.     unsigned char  *s;
  528.  
  529.     if ((pr = mem_create (xdim, ydim, 8)) == NULL)
  530.     {
  531.         msg_write ("Error: Not enough memory to create copy of canvas for building plot data .");
  532.         return (-1);
  533.     }
  534.     pw_read (pr, 0, 0, xdim, ydim, PIX_SRC, pw, xpos, ypos);
  535.     mpr = mpr_d (pr);
  536.     s = (unsigned char *) mpr->md_image;
  537.     npad = pixrect_pad (xdim);
  538.     for (j = 0; j < ydim; j++)
  539.     {
  540.         tmp = ypos + j;
  541.         for (i = 0; i < xdim; pt++, i += 2)
  542.         {
  543.             pt->x = xpos + i;
  544.             pt->y = tmp;
  545.             pt->z = ((int) *(s++) + (int) *(s++)) >> 1;
  546.         }
  547.         s += npad;
  548.     }
  549.     pr_close (pr);
  550.     return (0);
  551. }
  552. /* EOF */
  553. /* cat > src+obj/plot/get_scaling.c << "EOF" */
  554. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  555. /* get_scaling: (static) get scaling            */
  556. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  557. /* SCCS information: %W%    %G% - NCSA */
  558.  
  559. /* #include "plot.h" */
  560.  
  561. static void
  562. get_scaling (item, value, event)
  563.     Panel_item      item;
  564.     int             value;
  565.     Event          *event;
  566. {
  567.         /* linear = 1, logarithmic = 0 */
  568.     linear_scaling = value;
  569. }
  570. /* EOF */
  571. /* cat > src+obj/plot/hide_stats.c << "EOF" */
  572. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  573. /* hide_stats: (static)    hide stats            */
  574. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  575. /* SCCS information: %W%    %G% - NCSA */
  576.  
  577. /* #include "plot.h" */
  578.  
  579. static void
  580. hide_stats (item, event)
  581.     Panel_item      item;
  582.     Event          *event;
  583. {
  584.     char            tmp[20];
  585.     int             lastw = curr_image.xdim, lasth = curr_image.ydim;
  586.     int             answer;
  587.  
  588.     pwInit ();
  589.     answer = (int) panel_get (item, PANEL_CLIENT_DATA);
  590.  
  591.     strncpy (tmp, (char *) panel_get_value (stats_xmin_obj), 19);
  592.     stats_xmin = (float) atof (tmp);
  593.     strncpy (tmp, (char *) panel_get_value (stats_xmax_obj), 19);
  594.     stats_xmax = (float) atof (tmp);
  595.     strncpy (tmp, (char *) panel_get_value (stats_ymin_obj), 19);
  596.     stats_ymin = (float) atof (tmp);
  597.     strncpy (tmp, (char *) panel_get_value (stats_ymax_obj), 19);
  598.     stats_ymax = (float) atof (tmp);
  599.     strncpy (tmp, (char *) panel_get_value (stats_gmin_obj), 19);
  600.     stats_gmin = (float) atof (tmp);
  601.     strncpy (tmp, (char *) panel_get_value (stats_gmax_obj), 19);
  602.     stats_gmax = (float) atof (tmp);
  603.  
  604.     if (!answer || stats_xmin == stats_xmax)
  605.     {
  606.         stats_xmin = 0.;
  607.         stats_xmax = (float) lastw;
  608.         has_xscale = 0;
  609.     }
  610.     else
  611.         has_xscale = 1;
  612.  
  613.     if (!answer || stats_ymin == stats_ymax)
  614.     {
  615.         stats_ymin = 0.;
  616.         stats_ymax = (float) lasth;
  617.         has_yscale = 0;
  618.     }
  619.     else
  620.         has_yscale = 1;
  621.  
  622.     if (!answer || stats_gmin == stats_gmax)
  623.     {
  624.         if (linear_scaling)
  625.         {
  626.             stats_gmin = 0.;
  627.             stats_gmax = 255.;
  628.         }
  629.         else
  630.         {
  631.             stats_gmin = 1.0;
  632.             stats_gmax = 1e5;
  633.         }
  634.     }
  635.  
  636.     sprintf (msgstr, "Note: Scales - xmin=%.2f, xmax=%.2f, ymin=%.2f, ymax=%.2f,",
  637.          stats_xmin, stats_xmax, stats_ymin, stats_ymax);
  638.     msg_write (msgstr);
  639.     if (linear_scaling)
  640.         sprintf (msgstr, "               gmin=%.2f, gmax=%.2f, scaling_type=linear",
  641.              stats_gmin, stats_gmax);
  642.     else
  643.         sprintf (msgstr, "               gmin=%e, gmax=%e, scaling_type=logarithmic",
  644.              stats_gmin, stats_gmax);
  645.     msg_write (msgstr);
  646.  
  647.     window_set (scale_box, WIN_SHOW, FALSE, 0);
  648.     window_return (1);
  649. }
  650. /* EOF */
  651. /* cat > src+obj/plot/lw_line.c << "EOF" */
  652. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  653. /* lw_line: lw line                    */
  654. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  655. /* SCCS information: %W%    %G% - NCSA */
  656.  
  657. /* #include "plot.h" */
  658.  
  659. void 
  660. lw_line (x1, y1, x2, y2)
  661.     float           x1, y1, x2, y2;
  662. {
  663.     static float    last_x, last_y;
  664.     static int      count;
  665.  
  666.     if (!flip_flop)
  667.     {
  668.         fprintf (pf, "newpath\n");
  669.         flip_flop = 1;
  670.         count = 0;
  671.         last_x = 0;
  672.         last_y = 0;
  673.     }
  674.     if (last_x != x1 || last_y != y1)
  675.     {
  676.         if (count > LW_STROKE)
  677.         {
  678.             fprintf (pf, "stroke\n");
  679.             count = 0;
  680.         }
  681.         fprintf (pf, "%.2f %.2f moveto\n", x1, LW_HEIGHT - y1);
  682.     }
  683.     fprintf (pf, "%.2f %.2f lineto\n", x2, LW_HEIGHT - y2);
  684.     last_x = x2;
  685.     last_y = y2;
  686.     count++;
  687. }
  688. /* EOF */
  689. /* cat > src+obj/plot/lw_text.c << "EOF" */
  690. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  691. /* lw_text: lw text                    */
  692. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  693. /* SCCS information: %W%    %G% - NCSA */
  694.  
  695. /* #include "plot.h" */
  696.  
  697. void 
  698. lw_text (x0, y0, font, string)
  699.     int             x0, y0, font;
  700.     char           *string;
  701. {
  702.     static int      last_font;
  703.  
  704.     if (flip_flop)
  705.     {
  706.         fprintf (pf, "stroke\n");
  707.         flip_flop = 0;
  708.     }
  709.     if (font != last_font)
  710.     {
  711.         fprintf (pf, "/Times-Roman findfont %2d scalefont\n", font);
  712.         fprintf (pf, "setfont\n");
  713.         last_font = font;
  714.     }
  715.     fprintf (pf, "%d %d moveto\n", x0, LW_HEIGHT - y0);
  716.     fprintf (pf, "(%s) show\n", string);
  717. }
  718. /* EOF */
  719. /* cat > src+obj/plot/my_destroy_interposer.c << "EOF" */
  720. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  721. /* my_destroy_interposer: (static) destroy window    */
  722. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  723. /* SCCS information: %W%    %G% - NCSA */
  724.  
  725. /* #include "plot.h" */
  726.  
  727. static          Notify_value
  728. my_destroy_interposer (frame, status)
  729.     Frame           frame;
  730.     Destroy_status  status;
  731. {
  732.  
  733.     if (status != DESTROY_CHECKING)
  734.     {
  735.         plot_win_done ();
  736.     }
  737.     return (notify_next_destroy_func (frame, status));
  738. }
  739. /* EOF */
  740. /* cat > src+obj/plot/my_notice_interposer.c << "EOF" */
  741. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  742. /* my_notice_interposer: (static) interposer to handler    */
  743. /*             graph window closing and    */
  744. /*             opening            */
  745. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  746. /* SCCS information: %W%    %G% - NCSA */
  747.  
  748. /* #include "plot.h" */
  749.  
  750. static          Notify_value
  751. my_notice_interposer (frame, event, arg, type)
  752.     Frame           frame;
  753.     Event          *event;
  754.     Notify_arg      arg;
  755.     Notify_event_type type;
  756. {
  757.     int             closed_initial, closed_current;
  758.     Notify_value    value;
  759.  
  760.         /* determine initial state of frame */
  761.     closed_initial = (int) window_get (frame, FRAME_CLOSED);
  762.  
  763.         /* let frame operate on the event */
  764.     value = notify_next_event_func (frame, event, arg, type);
  765.  
  766.         /* determine initail state of frame */
  767.     closed_current = (int) window_get (frame, FRAME_CLOSED);
  768.  
  769.         /* action */
  770.     if (closed_initial != closed_current)
  771.     {
  772.         if (closed_current)
  773.         {
  774.                 /* turn off plotting mode since closed */
  775.             plot_win_close ();
  776.         }
  777.         else
  778.         {
  779.                 /* turn on plotting mode since opened */
  780.             graph_mode = save_gmode;
  781.         }
  782.     }
  783.     return (value);
  784. }
  785. /* EOF */
  786. /* cat > src+obj/plot/pcan_controller.c << "EOF" */
  787. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  788. /* pcan_controller: (static) clear plot controller    */
  789. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  790. /* SCCS information: %W%    %G% - NCSA */
  791.  
  792. /* #include "plot.h" */
  793.  
  794. static void
  795. pcan_controller (can, event)
  796.     Canvas          can;
  797.     Event          *event;
  798. {
  799. /*
  800.     int eid = event_id(event);
  801.     if(eid == MS_MIDDLE && event_is_down(event))
  802.        clear_plot();
  803. */
  804. }
  805. /* EOF */
  806. /* cat > src+obj/plot/plot_action.c << "EOF" */
  807. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  808. /* plot_action: handler for menu items under 'GRAPH'    */
  809. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  810. /* SCCS information: %W%    %G% - NCSA */
  811.  
  812. /* #include "plot.h" */
  813.  
  814. void
  815. plot_action (m, mi)
  816.     Menu            m;
  817.     Menu_item       mi;
  818. {
  819.     char            str[MAXNAMELEN];
  820.  
  821.     strcpy (str, (char *) menu_get (mi, MENU_STRING));
  822.     if (graph_mode == PLOT_NONE)
  823.     {
  824.         if (plot_window == NULL)
  825.             create_plot_window ();
  826.         window_set (plot_window, WIN_SHOW, TRUE, 0);
  827.     }
  828.  
  829.     if (!strcmp ("XY", str))
  830.     {
  831.         clear_plot ();
  832.         valid_xy ();
  833.         if (graph_mode != PLOT_XY)
  834.             erase_square ();
  835.         show_stats ();
  836.         graph_mode = PLOT_XY;
  837.         print_true = TRUE;
  838.     }
  839.     else if (!strcmp ("Contour", str))
  840.     {
  841.         valid_2d ();
  842.         clear_plot ();
  843.         if (graph_mode == PLOT_XY)
  844.             erase_line ();
  845.         graph_mode = PLOT_CON;
  846.         print_true = FALSE;
  847.     }
  848.     else if (!strcmp ("3D", str))
  849.     {
  850.         valid_3d ();
  851.         clear_plot ();
  852.         if (graph_mode == PLOT_XY)
  853.             erase_line ();
  854.         graph_mode = PLOT_3D;
  855.         print_true = FALSE;
  856.     }
  857.  
  858.     save_gmode = graph_mode;
  859. }
  860. /* EOF */
  861. /* cat > src+obj/plot/plot_axes.c << "EOF" */
  862. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  863. /* plot_axes: routine to plot axes, tickmarks, labels    */
  864. /*          for xy plot                */
  865. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  866. /* SCCS information: %W%    %G% - NCSA */
  867.  
  868. /* #include "plot.h" */
  869.  
  870. plot_axes (label, end1, end2)
  871.     char           *label;
  872.     float           end1, end2;
  873. {
  874.     Pixwin         *plotpw = canvas_pixwin (pcanvas);
  875.     char            str[10], title[MAXNAMELEN];
  876.     int             xpmin = XPLOT_MIN, xpmax = XPLOT_MAX;
  877.     int             ypmin = YPLOT_MIN, ypmax = YPLOT_MAX;
  878.     int             xmargin = XPLOT_MARGIN, ymargin = YPLOT_MARGIN;
  879.     int             length = MARKER_LENGTH;
  880.     int             ll = strlen (label) / 2;
  881.     int             i, nm, tmp, xmarker, ymarker;
  882.     float           xlabel, ylabel;
  883.  
  884.     xmarker = (int) ((xpmax - xpmin) / (float) NMARKERS);
  885.     xlabel = (end2 - end1) / NMARKERS;
  886.     if (linear_scaling)
  887.     {
  888.         ylabel = (float) (stats_gmax - stats_gmin) / NMARKERS;
  889.         nm = NMARKERS;
  890.     }
  891.     else
  892.     {
  893.             /* log scale */
  894.         nm = ntix;
  895.     }
  896.     ymarker = (int) ((ypmax - ypmin) / (float) nm);
  897.  
  898.     strcpy (title, (char *) panel_get_value (title_item));
  899.     if (strlen (title) == 0)
  900.     {
  901.         if (linear_scaling)
  902.             strcpy (title, "Linear Plotting");
  903.         else
  904.             strcpy (title, "Logarithmic Plotting");
  905.     }
  906.  
  907.         /* plot labels, draw axes */
  908.     pwText (plotpw, (xpmin + xpmax) / 2 - strlen (title) * 4, ypmin / 2, PIX_SRC, 14, title);
  909.     pwText (plotpw, xmargin, ypmin / 2, PIX_SRC, 12, "Gvalue");
  910.  
  911.     pwSetlinewidth (1.0);
  912.     pwVector (plotpw, xpmin, ypmin, xpmin, ypmax, PIX_SRC, 255);
  913.     pwVector (plotpw, xpmin, ypmax, xpmax, ypmax, PIX_SRC, 255);
  914.     pwText (plotpw, (xpmin + xpmax) / 2 - ll * 6, ypmax + 2 * ymargin + 10, PIX_SRC, 12, label);
  915.     pwSetlinewidth (0.2);
  916.  
  917.         /* x-axis markers */
  918.     for (i = 0; i < NMARKERS + 1; i++)
  919.     {
  920.         pwVector (plotpw, xpmin + i * xmarker, ypmax - length, xpmin + i * xmarker,
  921.               ypmax + length, PIX_SRC, 255);
  922.         sprintf (str, "%.2f", end1 + i * xlabel);
  923.         pwText (plotpw, xpmin + i * xmarker - 10, ypmax + ymargin, PIX_SRC, 10, str);
  924.     }
  925.  
  926.         /* y-axis markers */
  927.     for (i = 0; i < nm + 1; i++)
  928.     {
  929.         pwVector (plotpw, xpmin - length, ypmin + i * ymarker, xpmin + length,
  930.               ypmin + i * ymarker, PIX_SRC, 255);
  931.         if (linear_scaling)
  932.         {
  933.             sprintf (str, "%.2f", stats_gmin + i * ylabel);
  934.             pwText (plotpw, xmargin - 15, ypmax - i * ymarker, PIX_SRC, 10, str);
  935.         }
  936.         else
  937.         {
  938.             sprintf (str, "%d", gminexp + i * pintv);
  939.             pwText (plotpw, xmargin + 15, ypmax - i * ymarker - 4, PIX_SRC, 8, str);
  940.             pwText (plotpw, xmargin, ypmax - i * ymarker + 2, PIX_SRC, 10, "10");
  941.         }
  942.     }
  943. }
  944. /* EOF */
  945. /* cat > src+obj/plot/plot_handler.c << "EOF" */
  946. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  947. /* plot_handler: plot handler                */
  948. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  949. /* SCCS information: %W%    %G% - NCSA */
  950.  
  951. /* #include "plot.h" */
  952.  
  953. plot_handler (item, event)
  954.     Panel_item      item;
  955.     Event          *event;
  956. {
  957.     if (display_panel_menu (item, event, menu_panel, graph_menu))
  958.         plot_action (graph_menu, menu_get (graph_menu, MENU_NTH_ITEM, 1));
  959. }
  960. /* EOF */
  961. /* cat > src+obj/plot/plot_proc.c << "EOF" */
  962. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  963. /* plot_proc: plotting procedure- canvas event handler    */
  964. /*          under graphing mode xy plot mode: left    */
  965. /*          button dragging to draw a cross section    */
  966. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  967. /* SCCS information: %W%    %G% - NCSA */
  968.  
  969. /* #include "plot.h" */
  970.  
  971. plot_proc (eid, event)
  972.     int             eid;
  973.     Event          *event;
  974. {
  975.     switch (eid)
  976.     {
  977.         case MS_LEFT:    /* left button draw line section */
  978.             if (line_drawn)
  979.             {
  980.                     /* line exists */
  981.                 line_drawn = 0;
  982.                 first_point = 0;
  983.                 pw_vector (pw, line_rec.x1, line_rec.y1, line_rec.x2,
  984.                        line_rec.y2, PIX_NOT (PIX_DST), 255);
  985.             }
  986.  
  987.             draw_line (eid, event);
  988.             break;
  989.         case MS_MIDDLE:    /* middle button selects region to zoom */
  990.             if (event_is_down (event))
  991.                 plot_linear ();
  992.             break;
  993.         case LOC_DRAG:
  994.             if (first_point)
  995.                 draw_line (eid, event);
  996.             break;
  997.         default:
  998.             break;
  999.     }
  1000.     return;
  1001. }
  1002. /* EOF */
  1003. /* cat > src+obj/plot/plot_win_close.c << "EOF" */
  1004. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1005. /* plot_win_close: close plot window            */
  1006. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1007. /* SCCS information: %W%    %G% - NCSA */
  1008.  
  1009. /* #include "plot.h" */
  1010.  
  1011. plot_win_close ()
  1012. {
  1013.     erase_line ();
  1014.     erase_square ();
  1015.     save_gmode = graph_mode;
  1016.     graph_mode = PLOT_NONE;
  1017.     last_dir = 0;
  1018.     first_middle_down = 0;
  1019. }
  1020. /* EOF */
  1021. /* cat > src+obj/plot/plot_win_done.c << "EOF" */
  1022. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1023. /* plot_win_done: finished plot window            */
  1024. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1025. /* SCCS information: %W%    %G% - NCSA */
  1026.  
  1027. /* #include "plot.h" */
  1028.  
  1029. plot_win_done ()
  1030. {
  1031.     fclose (pf);
  1032.     pf = NULL;
  1033.     unlink (jerk);
  1034.     plot_window = NULL;
  1035.     if (!main_quit)
  1036.         plot_win_close ();
  1037. }
  1038. /* EOF */
  1039. /* cat > src+obj/plot/process_gexp.c << "EOF" */
  1040. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1041. /* process_gexp: process g expression            */
  1042. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1043. /* SCCS information: %W%    %G% - NCSA */
  1044.  
  1045. /* #include "plot.h" */
  1046.  
  1047. process_gexp (prexpi, prexpx)
  1048.     int            *prexpi, *prexpx;
  1049. {
  1050.     int             diffexp = *prexpx - *prexpi;
  1051.  
  1052.     pintv = (int) ceil ((double) diffexp / NMARKERS);
  1053.     ntix = (int) ceil ((double) diffexp / pintv);
  1054.     *prexpx = *prexpi + pintv * ntix;
  1055. }
  1056. /* EOF */
  1057. /* cat > src+obj/plot/pwInit.c << "EOF" */
  1058. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1059. /* pwInit: pw initialization                */
  1060. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1061. /* SCCS information: %W%    %G% - NCSA */
  1062.  
  1063. /* #include "plot.h" */
  1064.  
  1065. void 
  1066. pwInit ()
  1067. {
  1068.     if (pf == NULL)
  1069.     {
  1070.             /* tempnam(3) is a library function */
  1071.         if ((jerk = tempnam (NULL, "imgtl.1")) == NULL)
  1072.         {
  1073.             msg_write ("Error: Temporary plot file name cannot be generated.");
  1074.             exit (0);
  1075.         }
  1076.         if ((pf = fopen (jerk, "w")) == NULL)
  1077.         {
  1078.             sprintf (wkstr, "Error: Cannot open temporary plot filename %s.", jerk);
  1079.             msg_write (wkstr);
  1080. /*                sleep (10); */
  1081.             exit (0);
  1082.         }
  1083.     }
  1084.  
  1085.     fprintf (pf, "%%! The Hard Copy of the Imagetool Graph Window\n");
  1086.     pwSetlinewidth (0.2);
  1087.     flip_flop = 0;
  1088. }
  1089. /* EOF */
  1090. /* cat > src+obj/plot/pwSetlinewidth.c << "EOF" */
  1091. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1092. /* pwSetlinewidth: pw Setlinewidth            */
  1093. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1094. /* SCCS information: %W%    %G% - NCSA */
  1095.  
  1096. /* #include "plot.h" */
  1097.  
  1098. void 
  1099. pwSetlinewidth (width)
  1100.     float           width;
  1101. {
  1102.     fprintf (pf, "%.2f setlinewidth\n", width);
  1103. }
  1104. /* EOF */
  1105. /* cat > src+obj/plot/pwText.c << "EOF" */
  1106. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1107. /* pwText: pw Text                    */
  1108. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1109. /* SCCS information: %W%    %G% - NCSA */
  1110.  
  1111. /* #include "plot.h" */
  1112.  
  1113. void 
  1114. pwText (pw, x0, y0, op, font, string)
  1115.     Pixwin         *pw;
  1116.     int             x0, y0, op, font;
  1117.     char           *string;
  1118. {
  1119.     pw_text (pw, x0, y0, op, NULL, string);
  1120.     if (print_true)
  1121.         lw_text (x0, y0 + 100, font, string);
  1122. }
  1123. /* EOF */
  1124. /* cat > src+obj/plot/pwVector.c << "EOF" */
  1125. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1126. /* pwVector: pw Vector                    */
  1127. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1128. /* SCCS information: %W%    %G% - NCSA */
  1129.  
  1130. /* #include "plot.h" */
  1131.  
  1132. void 
  1133. pwVector (pw, x1, y1, x2, y2, op, value)
  1134.     Pixwin         *pw;
  1135.     int             x1, y1, x2, y2, op, value;
  1136. {
  1137.     pw_vector (pw, x1, y1, x2, y2, op, value);
  1138.     if (print_true)
  1139.         lw_line ((float) x1, (float) (y1 + 100), (float) x2, (float) (y2 + 100));
  1140. }
  1141. /* EOF */
  1142. /* cat > src+obj/plot/show_stats.c << "EOF" */
  1143. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1144. /* show_stats: display info box for stats        */
  1145. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1146. /* SCCS information: %W%    %G% - NCSA */
  1147.  
  1148. /* #include "plot.h" */
  1149.  
  1150. show_stats ()
  1151. {
  1152.         /* create and display scale box */
  1153.     if (scale_box == NULL)
  1154.         create_stats ();
  1155.     window_set (scale_box, WIN_SHOW, TRUE, 0);
  1156. }
  1157. /* EOF */
  1158. /* cat > src+obj/plot/valid_2d.c << "EOF" */
  1159. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1160. /* valid_2d: valid 2d                    */
  1161. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1162. /* SCCS information: %W%    %G% - NCSA */
  1163.  
  1164. /* #include "plot.h" */
  1165.  
  1166. valid_2d ()
  1167. {
  1168.     panel_set (title_item, PANEL_SHOW_ITEM, FALSE, 0);
  1169.     panel_set (scale_but, PANEL_SHOW_ITEM, FALSE, 0);
  1170.     panel_set (roll_item, PANEL_SHOW_ITEM, FALSE, 0);
  1171.     panel_set (pitch_item, PANEL_SHOW_ITEM, FALSE, 0);
  1172.     panel_set (yaw_item, PANEL_SHOW_ITEM, FALSE, 0);
  1173.     panel_set (level_item, PANEL_SHOW_ITEM, TRUE, 0);
  1174. }
  1175. /* EOF */
  1176. /* cat > src+obj/plot/valid_3d.c << "EOF" */
  1177. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1178. /* valid_3d: valid 3d                    */
  1179. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1180. /* SCCS information: %W%    %G% - NCSA */
  1181.  
  1182. /* #include "plot.h" */
  1183.  
  1184. valid_3d ()
  1185. {
  1186.     panel_set (title_item, PANEL_SHOW_ITEM, FALSE, 0);
  1187.     panel_set (level_item, PANEL_SHOW_ITEM, FALSE, 0);
  1188.     panel_set (scale_but, PANEL_SHOW_ITEM, FALSE, 0);
  1189.     panel_set (roll_item, PANEL_SHOW_ITEM, TRUE, 0);
  1190.     panel_set (pitch_item, PANEL_SHOW_ITEM, TRUE, 0);
  1191.     panel_set (yaw_item, PANEL_SHOW_ITEM, TRUE, 0);
  1192. }
  1193. /* EOF */
  1194. /* cat > src+obj/plot/valid_xy.c << "EOF" */
  1195. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1196. /* valid_xy: validation routine for different graphing    */
  1197. /*         modes                    */
  1198. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  1199. /* SCCS information: %W%    %G% - NCSA */
  1200.  
  1201. /* #include "plot.h" */
  1202.  
  1203. valid_xy ()
  1204. {
  1205.     panel_set (level_item, PANEL_SHOW_ITEM, FALSE, 0);
  1206.     panel_set (roll_item, PANEL_SHOW_ITEM, FALSE, 0);
  1207.     panel_set (pitch_item, PANEL_SHOW_ITEM, FALSE, 0);
  1208.     panel_set (yaw_item, PANEL_SHOW_ITEM, FALSE, 0);
  1209.     panel_set (title_item, PANEL_SHOW_ITEM, TRUE, 0);
  1210.     panel_set (scale_but, PANEL_SHOW_ITEM, TRUE, 0);
  1211. }
  1212. /* EOF */
  1213.