1 #include <../../nrnconf.h> 4 #if defined(__TURBOC__) || defined(__linux__) 16 #if defined(IVX11_DYNAM) 17 #include <IV-X11/ivx11_declare.h> 18 #include <IV-X11/ivx11_redef.h> 20 #define return_if_no_x {if(!hoc_usegui) { return; }} 23 #include <X11/Xutil.h> 25 #define return_if_no_x {;} 41 #define Plot(x,y) XDrawPoint(display,win,gc,(x),(y)) 42 #define Line(x1,y1,x2,y2) XDrawLine(display,win,gc,(x1),(y1),(x2),(y2)) 43 #define LAST xold=xnew; yold=ynew 47 static XPoint polyline[200];
48 static int maxnlinept=200;
61 static unsigned long colors[Ncolors];
63 extern void x11_open_window();
64 extern void x11_draw_vec();
66 static int xnew, ynew;
67 static int xold, yold;
72 static void set_colors(
void);
74 void x11_fast(
int mode)
81 if (fast && nlinept) {
87 static void getscale(
void) {
89 unsigned int width, height, border_width, depth;
92 XGetGeometry(
display, win, &root, &x, &y, & width,
93 &height, &border_width, &depth);
94 xscale = ((double)width)/TEKX;
95 yscale = ((double)height)/TEKY;
98 void x11_coord(
double x,
double y) {
103 void x11_draw_vec(
void) {
106 XDrawLines(
display, win, gc, polyline, nlinept, CoordModeOrigin);
111 void x11_vector(
void)
116 polyline[0].x = xold;
117 polyline[0].y = yold;
120 if (nlinept >= maxnlinept) {
123 polyline[nlinept].x = xnew;
124 polyline[nlinept].y = ynew;
127 Line(xold, yold, xnew, ynew);
146 if (nlinept && (xnew != xold || ynew != yold)) {
152 void x11_clear(
void){
159 void x11_cleararea(
void){
176 XClearArea(
display, win, x, y, w, h, False);
182 void x11_put_text(
const char*
s)
185 if(fast && nlinept) {
188 XDrawString(
display, win, gc, xold, yold, s, strlen(s));
193 void x11_setcolor(
int c)
196 if (!x11_init_done) {
212 void x11_open_window(
void)
214 char *window_name =
"Xhocplot";
215 char *display_name =
NULL;
216 XSizeHints size_hints;
217 XWindowAttributes attr;
223 if ((
display = XOpenDisplay(display_name)) ==
NULL)
225 (
void)
fprintf(stderr,
"cannot connect to X server %s\n",
226 XDisplayName(display_name));
229 screen = DefaultScreen(
display);
236 XGetWindowAttributes(
display, win, &attr);
238 if (
Color) set_colors();
240 size_hints.flags = USPosition|USSize;
241 size_hints.x = WX; size_hints.y = WY;
242 size_hints.width =
WIDTH; size_hints.height =
HEIGHT;
243 XSetStandardProperties(
display, win, window_name,
NULL,
244 0,
NULL, 0, &size_hints);
257 XSelectInput(
display, win, ExposureMask);
259 XSelectInput(
display, win, 0L);
264 void x11_close_window(
void)
275 char *color_names[Ncolors] = {
"black",
"white",
"yellow",
276 "red",
"green",
"blue",
"magenta",
"cyan",
"sienna",
"orange",
"coral" };
278 static void set_colors(
void) {
283 for(n=0; n<Ncolors; n++) {
285 color_names[n], &used, &exact)){
289 fprintf(stderr,
"xhocplot: assuming %s:white\n", color_names[n]);
int const size_t const size_t n
fprintf(stderr, "Don't know the location of params at %p\, pp)