File: xssctplt.c

package info (click to toggle)
xlispstat 3.52.14-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 7,560 kB
  • ctags: 12,676
  • sloc: ansic: 91,357; lisp: 21,759; sh: 1,525; makefile: 521; csh: 1
file content (104 lines) | stat: -rw-r--r-- 2,903 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* xsscatterplot - XLISP interface to IVIEW dynamic graphics package.  */
/* XLISP-STAT 2.1 Copyright (c) 1990, by Luke Tierney                  */
/* Additions to Xlisp 2.1, Copyright (c) 1989 by David Michael Betz    */
/* You may give out copies of this software; for conditions see the    */
/* file COPYING included with this distribution.                       */

#include "xlisp.h"
#include "xlstat.h"

/* external variables */
extern LVAL sk_draw, sk_resize, sk_redraw, s_true;
extern LVAL s_scale_type;

static VOID adjust_variable P4C(IVIEW_WINDOW, w, int, var, int *, ticks, int *, labeled) 
{
  double low, high;
  char *label;
  
  IViewGetRange(w, var, &low, &high);
  GetNiceRange(&low, &high, ticks);
  IViewSetRange(w, var, low, high);
  label = IViewVariableLabel(w, var);
  *labeled = (label != NULL && strlen(label) != 0) ? TRUE : FALSE;
}

LVAL iview_plot2d_adjust_to_data(V)
{
  LVAL object;
  IVIEW_WINDOW w;
  StGWWinInfo *gwinfo;
  int x, y, ticks, labeled, scaled;
  LVAL arg;
  
  object = xlgaobject();
  w = (IVIEW_WINDOW) GETIVIEWADDRESS(object);
  gwinfo = StGWObWinInfo(object);
  
  if (! IVIEW_WINDOW_NULL(w)) {
    scaled = (slot_value(object, s_scale_type) != NIL) ? TRUE : FALSE;
    StGrGetContentVariables(gwinfo, &x, &y);
    StGrObAdjustToData(object, FALSE);
    ticks = 4;
    if (! scaled) adjust_variable(w, x, &ticks, &labeled);
    IViewSetXaxis(w, ! scaled, labeled, ticks);
    ticks = 4;
    if (! scaled) adjust_variable(w, y, &ticks, &labeled);
    IViewSetYaxis(w, ! scaled, labeled, ticks);

    if (! xlgetkeyarg(sk_draw, &arg)) arg = s_true;
    if (arg != NIL) send_message(object, sk_resize);
    if (arg != NIL) send_message(object, sk_redraw);  
  }
  return(NIL);
}

static LVAL plot2d_add_data P1C(int, which)
{
  IVIEW_WINDOW w;
  int old_n = 0, n = 0;
  LVAL x, y, data, object;
  
  object = xlgaobject();
  w = (IVIEW_WINDOW) GETIVIEWADDRESS(object);
  
  if (IVIEW_WINDOW_NULL(w)) return(NIL);
    
  xlsave1(data);
  x = xlgetarg();
  if (fixp(x) || (consp(x) && seqp(car(x)))) data = x;
  else {
    y = xlgetarg();
    data = list2(x, y);
  }
  switch (which) {
  case 'P':
    old_n = IViewNumPoints(w);
    internal_iview_add_points(w, object, data);
    n = IViewNumPoints(w);
    break;
  case 'L':
    old_n = IViewNumLines(w);
    internal_iview_add_lines(w, object, data);
    n = IViewNumLines(w);
    break;
#ifdef USESTRINGS
  case 'S':
    old_n = IViewNumStrings(w);
    internal_iview_add_strings(w, object, data);
    n = IViewNumStrings(w);
    break;
#endif /* USESTRINGS */
  } 
  xlpop();
  
  check_add_to_screen(object, which, old_n, n, FALSE);
  
  return(NIL);
}

LVAL iview_plot2d_add_points(V)   { return(plot2d_add_data('P')); }
LVAL iview_plot2d_add_lines(V)    { return(plot2d_add_data('L')); }
#ifdef USESTRINGS
LVAL iview_plot2d_add_strings(V)  { return(plot2d_add_data('S')); }
#endif /* USESTRINGS */