-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHOW
More file actions
86 lines (68 loc) · 2.66 KB
/
HOW
File metadata and controls
86 lines (68 loc) · 2.66 KB
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
How does it work?
main() and procXevent are co-routines. main() calls xwin::procXevent()
for input characters. procXevent() uses select() to read standard input
and to process X events without blocking.
main() reads lines and classifies them as either data or command.
Immediate commands are processed, but deferred commands are stored
in a linked list with data.
there can be up to 10 plots, organized in following array structure
(see: points.c, points.h)
#define MAXPLOTS 10
PLOTDAT plots[MAXPLOTS];
PLOTDAT is a structure that holds some globals for each plot
frame and a linked list of commands and data points.
typedef struct datum {
char *cmd; // either NULL or cmd string. If str, then x,y unused.
double x;
double y;
struct datum *next;
struct datum *prev;
} DATUM;
typedef struct plotdat {
DATUM *data;
double llx; // raw screen coords for this plot
double lly;
double urx;
double ury;
double xmin; // computed bounds
double xmax;
double ymin;
double ymax;
double xsetmin; // xset command
double xsetmax;
double ysetmin; // yset command
double ysetmax;
int xlogmode; // log/lin scale mode
int ylogmode;
double xscale; // xscale multiplying factor
double yscale; // yscale multiplying factor
char * title; // plot title (only stored in plots[0])
char * xaxis; // xscale label
char * yaxis; // yscale label
} PLOTDAT;
FILES:
main.c ; main routine, setup, readin of data and parse loop
xwin.c ; create X11 window and handle events, drawing routines
clip.c ; clip lines to fit within graph boundaries
label.c ; compute reasonable scales for the graph, draw ticks, grids
points.c ; storage of the 10 graphs, rendering of graph
postscript.c ; postscript output code
readfont.c ; read the font files and draw text/symbols
symbol.c ; a table to keep track of symbol names
Here's how we do graphical dumping:
given a routine like:
render(Display * dpy, Drawable d, int width, int height);
and a call such as
Display * dpy;
Window w;
render(dpy, w, width, height);
Pixmap pixmap = XCreatePixmap(
dpy, w, width, height, DefaultDepth(dpy, DefaultScreen(dpy)));
render(dpy, pixmap, width, height);
You can now splot copies of pixmap anywhere you want using XCopyArea(),
or create an XImage using code such as:
XImage * img = XGetImage(dpy, pixmap, 0, 0, width, height, ~0, ZPixMap);
Basically, we have a drawable pointed to by dd. Most of the time we draw
directly to the screen by pointing dd to our window. When we want to dump
the image, we change dd to point at a pixmap and then do render(). After
that we can use XGetImage to snarf the bits.