-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinitialize.c
148 lines (135 loc) · 4.9 KB
/
initialize.c
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* initialize.c */
/************************************************************
* *
* Permission is hereby granted to any individual or *
* institution for use, copying, or redistribution of *
* the xgobi code and associated documentation, provided *
* that such code and documentation are not sold for *
* profit and the following copyright notice is retained *
* in the code and documentation: *
* Copyright (c) 1990, ..., 1996 Bellcore *
* *
* We welcome your questions and comments, and request *
* that you share any modifications with us. *
* *
* Deborah F. Swayne Dianne Cook *
* dfs@research.att.com dicook@iastate.edu *
* (973) 360-8423 www.public.iastate.edu/~dicook/ *
* *
* Andreas Buja *
* andreas@research.att.com *
* www.research.att.com/~andreas/ *
* *
************************************************************/
#include <stdio.h>
#include "xincludes.h"
#include "xgobitypes.h"
#include "xgobivars.h"
#include "xgobiexterns.h"
void
init_brush_colors(AppData *appdat)
{
XColor exact;
register int j;
Colormap cmap = DefaultColormap(display, DefaultScreen(display));
ncolors = NCOLORS;
color_names[0] = (char *) appdat->brushColor0;
color_names[1] = (char *) appdat->brushColor1;
color_names[2] = (char *) appdat->brushColor2;
color_names[3] = (char *) appdat->brushColor3;
color_names[4] = (char *) appdat->brushColor4;
color_names[5] = (char *) appdat->brushColor5;
color_names[6] = (char *) appdat->brushColor6;
color_names[7] = (char *) appdat->brushColor7;
color_names[8] = (char *) appdat->brushColor8;
color_names[9] = (char *) appdat->brushColor9;
for (j=0; j<ncolors; j++) {
if (XParseColor(display, cmap, color_names[j], &exact)) {
if (XAllocColor(display, cmap, &exact)) {
color_nums[j] = exact.pixel;
}
}
else
(void) fprintf(stderr, "finding %s failed\n", color_names[j]);
}
}
void
init_GCs(xgobidata *xg)
{
unsigned long bg, fg;
Window root_window = RootWindowOfScreen(XtScreen(xg->shell));
XGCValues gcv;
unsigned long mask =
GCForeground | GCBackground | GCFunction ;
/*
* Some documentation suggests that this might result
* in some speedup; I see no difference. dfs 3/93
*/
gcv.graphics_exposures = False;
if (mono) {
plotcolors.fg = appdata.fg;
plotcolors.bg = appdata.bg;
}
XtVaGetValues(xg->vardraww[0],
XtNbackground, &bg,
XtNforeground, &fg,
NULL);
/*
* Create a Graphics Context with copy drawing logic. It's used
* for drawing the bull's eye or target circle in the middle of
* the variable circles as well as the circles and variable bars.
*/
gcv.foreground = fg;
gcv.background = bg;
gcv.function = GXcopy;
varpanel_copy_GC = XCreateGC(display, root_window, mask, &gcv);
/*
* Create a Graphics Context and give it xor drawing logic.
* This GC is used in drawing the variable circles, and its
* foreground and background colors come from xor-ing the colors
* of the form widget with a 1, I think. The reason for using
* xor logic here is the need for rapid redrawing of lines during
* rotation and touring.
*/
gcv.foreground = (unsigned long) 0xffffffff;
gcv.background = bg;
gcv.function = GXxor;
varpanel_xor_GC = XCreateGC(display, root_window, mask, &gcv);
XSetPlaneMask(display, varpanel_xor_GC, fg ^ bg);
/*
* Create a Graphics Context and give it copy drawing logic.
* The copy_GC and the clear_GC are used for drawing inside the
* plot window. Their fg and bg colors come from the resource
* values of PlotWorkspace.
*/
gcv.foreground = plotcolors.fg;
gcv.background = plotcolors.bg;
gcv.function = GXcopy;
copy_GC = XCreateGC(display, root_window, mask, &gcv);
/*
* Create another Graphics Context and give it copy drawing logic.
*/
gcv.foreground = plotcolors.bg;
gcv.background = plotcolors.fg;
gcv.function = GXcopy;
clear_GC = XCreateGC(display, root_window, mask, &gcv);
/*
* Set font for drawing labels; needed for axis label computations.
*/
XSetFont(display, copy_GC, appdata.plotFont->fid);
XSetFont(display, clear_GC, appdata.plotFont->fid);
}
void
init_plotwindow_vars(xgobidata *xg, int firsttime)
{
if (firsttime)
{
xg->max.x = (int) xg->plotsize.width;
xg->max.y = (int) xg->plotsize.height;
xg->minxy = MIN(xg->max.x, xg->max.y);
xg->mid.x = xg->max.x / 2;
xg->mid.y = xg->max.y / 2;
}
if (!mono)
xg->color_id = plotcolors.fg;
}