#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "util.h"
#include "graphics.h"
#include "vpr_types.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>
Go to the source code of this file.
Data Structures | |
struct | t_button |
Defines | |
#define | XPOST(worldx) (((worldx)-xleft)*ps_xmult + ps_left) |
#define | YPOST(worldy) (((worldy)-ybot)*ps_ymult + ps_bot) |
#define | XTOWORLD(x) (((float) x)/xmult + xleft) |
#define | YTOWORLD(y) (((float) y)/ymult + ytop) |
#define | max(a, b) (((a) > (b))? (a) : (b)) |
#define | min(a, b) ((a) > (b)? (b) : (a)) |
#define | MWIDTH 104 |
#define | T_AREA_HEIGHT 24 |
#define | MAX_FONT_SIZE 40 |
#define | PI 3.141592654 |
#define | BUTTON_TEXT_LEN 20 |
#define | MAXPIXEL 15000 |
#define | MINPIXEL -15000 |
#define | OFF 1 |
#define | ON 0 |
Functions | |
static void | translate_up (void(*drawscreen)(void)) |
static void | translate_left (void(*drawscreen)(void)) |
static void | translate_right (void(*drawscreen)(void)) |
static void | translate_down (void(*drawscreen)(void)) |
static void | zoom_in (void(*drawscreen)(void)) |
static void | zoom_out (void(*drawscreen)(void)) |
static void | zoom_fit (void(*drawscreen)(void)) |
static void | adjustwin (void(*drawscreen)(void)) |
static void | postscript (void(*drawscreen)(void)) |
static void | proceed (void(*drawscreen)(void)) |
static void | quit (void(*drawscreen)(void)) |
static Bool | test_if_exposed (Display *disp, XEvent *event_ptr, XPointer dummy) |
static void | map_button (int bnum) |
static void | unmap_button (int bnum) |
static int | xcoord (float worldx) |
static int | ycoord (float worldy) |
static void | load_font (int pointsize) |
static void | force_setcolor (int cindex) |
void | setcolor (int cindex) |
static void | force_setlinestyle (int linestyle) |
void | setlinestyle (int linestyle) |
static void | force_setlinewidth (int linewidth) |
void | setlinewidth (int linewidth) |
static void | force_setfontsize (int pointsize) |
void | setfontsize (int pointsize) |
static void | build_textarea (void) |
static void | setpoly (int bnum, int xc, int yc, int r, float theta) |
static void | build_default_menu (void) |
void | create_button (char *prev_button_text, char *button_text, void(*button_func)(void(*drawscreen)(void))) |
void | destroy_button (char *button_text) |
void | init_graphics (char *window_name) |
static void | menutext (Window win, int xc, int yc, char *text) |
static void | drawbut (int bnum) |
static void | turn_on_off (int pressed) |
static int | which_button (Window win) |
static void | drawmenu (void) |
static void | update_transform (void) |
static void | update_ps_transform (void) |
void | event_loop (void(*act_on_button)(float x, float y), void(*drawscreen)(void)) |
void | clearscreen (void) |
static int | rect_off_screen (float x1, float y1, float x2, float y2) |
void | drawline (float x1, float y1, float x2, float y2) |
void | drawrect (float x1, float y1, float x2, float y2) |
void | fillrect (float x1, float y1, float x2, float y2) |
static float | angnorm (float ang) |
void | drawarc (float xc, float yc, float rad, float startang, float angextent) |
void | fillarc (float xc, float yc, float rad, float startang, float angextent) |
void | fillpoly (t_point *points, int npoints) |
void | drawtext (float xc, float yc, const char *text, float boundx) |
void | flushinput (void) |
void | init_world (float x1, float y1, float x2, float y2) |
void | draw_message (void) |
void | update_message (char *msg) |
static void | update_win (int x[2], int y[2], void(*drawscreen)(void)) |
void | close_graphics (void) |
int | init_postscript (char *fname) |
void | close_postscript (void) |
Variables | |
static const int | menu_font_size = 14 |
static t_button * | button |
static int | num_buttons |
static int | disp_type |
static Display * | display |
static int | screen_num |
static GC | gc |
static GC | gcxor |
static GC | gc_menus |
static XFontStruct * | font_info [MAX_FONT_SIZE+1] |
static int | font_is_loaded [MAX_FONT_SIZE+1] |
static unsigned int | display_width |
static unsigned int | display_height |
static unsigned int | top_width |
static unsigned int | top_height |
static Window | toplevel |
static Window | menu |
static Window | textarea |
static float | xleft |
static float | xright |
static float | ytop |
static float | ybot |
static float | saved_xleft |
static float | saved_xright |
static float | saved_ytop |
static float | saved_ybot |
static float | ps_left |
static float | ps_right |
static float | ps_top |
static float | ps_bot |
static float | ps_xmult |
static float | ps_ymult |
static float | xmult |
static float | ymult |
static Colormap | private_cmap |
static int | currentcolor = BLACK |
static int | currentlinestyle = SOLID |
static int | currentlinewidth = 0 |
static int | currentfontsize = 10 |
static char | message [BUFSIZE] = "\0" |
static int | colors [NUM_COLOR] |
static FILE * | ps |
#define BUTTON_TEXT_LEN 20 |
Definition at line 92 of file graphics.c.
#define max | ( | a, | |||
b | ) | (((a) > (b))? (a) : (b)) |
Definition at line 84 of file graphics.c.
#define MAX_FONT_SIZE 40 |
Definition at line 89 of file graphics.c.
#define MAXPIXEL 15000 |
Definition at line 157 of file graphics.c.
#define min | ( | a, | |||
b | ) | ((a) > (b)? (b) : (a)) |
Definition at line 85 of file graphics.c.
#define MINPIXEL -15000 |
Definition at line 158 of file graphics.c.
#define MWIDTH 104 |
Definition at line 87 of file graphics.c.
#define OFF 1 |
#define ON 0 |
#define PI 3.141592654 |
Definition at line 90 of file graphics.c.
#define T_AREA_HEIGHT 24 |
Definition at line 88 of file graphics.c.
Definition at line 75 of file graphics.c.
Definition at line 81 of file graphics.c.
Definition at line 76 of file graphics.c.
Definition at line 82 of file graphics.c.
static void adjustwin | ( | void(*)(void) | drawscreen | ) | [static] |
Definition at line 1821 of file graphics.c.
01822 { 01823 /* The window button was pressed. Let the user click on the two * 01824 * diagonally opposed corners, and zoom in on this area. */ 01825 01826 XEvent report; 01827 int corner, xold, yold, x[2], y[2]; 01828 01829 corner = 0; 01830 xold = -1; 01831 yold = -1; /* Don't need to init yold, but stops compiler warning. */ 01832 01833 while(corner < 2) 01834 { 01835 XNextEvent(display, &report); 01836 switch (report.type) 01837 { 01838 case Expose: 01839 #ifdef VERBOSE 01840 printf("Got an expose event.\n"); 01841 printf("Count is: %d.\n", report.xexpose.count); 01842 printf("Window ID is: %d.\n", report.xexpose.window); 01843 #endif 01844 if(report.xexpose.count != 0) 01845 break; 01846 if(report.xexpose.window == menu) 01847 drawmenu(); 01848 else if(report.xexpose.window == toplevel) 01849 { 01850 drawscreen(); 01851 xold = -1; /* No rubber band on screen */ 01852 } 01853 else if(report.xexpose.window == textarea) 01854 draw_message(); 01855 break; 01856 case ConfigureNotify: 01857 top_width = report.xconfigure.width; 01858 top_height = report.xconfigure.height; 01859 update_transform(); 01860 #ifdef VERBOSE 01861 printf("Got a ConfigureNotify.\n"); 01862 printf("New width: %d New height: %d.\n", top_width, 01863 top_height); 01864 #endif 01865 break; 01866 case ButtonPress: 01867 #ifdef VERBOSE 01868 printf("Got a buttonpress.\n"); 01869 printf("Window ID is: %d.\n", report.xbutton.window); 01870 printf("Location (%d, %d).\n", report.xbutton.x, 01871 report.xbutton.y); 01872 #endif 01873 if(report.xbutton.window != toplevel) 01874 break; 01875 x[corner] = report.xbutton.x; 01876 y[corner] = report.xbutton.y; 01877 if(corner == 0) 01878 { 01879 XSelectInput(display, toplevel, ExposureMask | 01880 StructureNotifyMask | ButtonPressMask 01881 | PointerMotionMask); 01882 } 01883 else 01884 { 01885 update_win(x, y, drawscreen); 01886 } 01887 corner++; 01888 break; 01889 case MotionNotify: 01890 #ifdef VERBOSE 01891 printf("Got a MotionNotify Event.\n"); 01892 printf("x: %d y: %d\n", report.xmotion.x, 01893 report.xmotion.y); 01894 #endif 01895 if(xold >= 0) 01896 { /* xold set -ve before we draw first box */ 01897 XDrawRectangle(display, toplevel, gcxor, 01898 min(x[0], xold), min(y[0], yold), 01899 abs(x[0] - xold), 01900 abs(y[0] - yold)); 01901 } 01902 /* Don't allow user to window under menu region */ 01903 xold = min(report.xmotion.x, top_width - 1 - MWIDTH); 01904 yold = report.xmotion.y; 01905 XDrawRectangle(display, toplevel, gcxor, min(x[0], xold), 01906 min(y[0], yold), abs(x[0] - xold), 01907 abs(y[0] - yold)); 01908 break; 01909 } 01910 } 01911 XSelectInput(display, toplevel, ExposureMask | StructureNotifyMask 01912 | ButtonPressMask); 01913 }
static float angnorm | ( | float | ang | ) | [static] |
Definition at line 1360 of file graphics.c.
01361 { 01362 /* Normalizes an angle to be between 0 and 360 degrees. */ 01363 01364 int scale; 01365 01366 if(ang < 0) 01367 { 01368 scale = (int)(ang / 360. - 1); 01369 } 01370 else 01371 { 01372 scale = (int)(ang / 360.); 01373 } 01374 ang = ang - scale * 360.; 01375 return (ang); 01376 }
static void build_default_menu | ( | void | ) | [static] |
Definition at line 454 of file graphics.c.
00455 { 00456 00457 /* Sets up the default menu buttons on the right hand side of the window. */ 00458 00459 XSetWindowAttributes menu_attributes; 00460 unsigned long valuemask; 00461 int i, xcen, x1, y1, bwid, bheight, space; 00462 00463 00464 menu = XCreateSimpleWindow(display, toplevel, 00465 top_width - MWIDTH, 0, MWIDTH - 4, 00466 display_height, 2, colors[BLACK], 00467 colors[LIGHTGREY]); 00468 menu_attributes.event_mask = ExposureMask; 00469 /* Ignore button presses on the menu background. */ 00470 menu_attributes.do_not_propagate_mask = ButtonPressMask; 00471 /* Keep menu on top right */ 00472 menu_attributes.win_gravity = NorthEastGravity; 00473 valuemask = CWWinGravity | CWEventMask | CWDontPropagate; 00474 XChangeWindowAttributes(display, menu, valuemask, &menu_attributes); 00475 XMapWindow(display, menu); 00476 00477 num_buttons = 11; 00478 button = (t_button *) my_malloc(num_buttons * sizeof(t_button)); 00479 00480 /* Now do the arrow buttons */ 00481 bwid = 28; 00482 space = 3; 00483 y1 = 10; 00484 xcen = 51; 00485 x1 = xcen - bwid / 2; 00486 button[0].xleft = x1; 00487 button[0].ytop = y1; 00488 setpoly(0, bwid / 2, bwid / 2, bwid / 3, -PI / 2.); /* Up */ 00489 button[0].fcn = translate_up; 00490 00491 y1 += bwid + space; 00492 x1 = xcen - 3 * bwid / 2 - space; 00493 button[1].xleft = x1; 00494 button[1].ytop = y1; 00495 setpoly(1, bwid / 2, bwid / 2, bwid / 3, PI); /* Left */ 00496 button[1].fcn = translate_left; 00497 00498 x1 = xcen + bwid / 2 + space; 00499 button[2].xleft = x1; 00500 button[2].ytop = y1; 00501 setpoly(2, bwid / 2, bwid / 2, bwid / 3, 0); /* Right */ 00502 button[2].fcn = translate_right; 00503 00504 y1 += bwid + space; 00505 x1 = xcen - bwid / 2; 00506 button[3].xleft = x1; 00507 button[3].ytop = y1; 00508 setpoly(3, bwid / 2, bwid / 2, bwid / 3, +PI / 2.); /* Down */ 00509 button[3].fcn = translate_down; 00510 00511 for(i = 0; i < 4; i++) 00512 { 00513 button[i].width = bwid; 00514 button[i].height = bwid; 00515 } 00516 00517 /* Rectangular buttons */ 00518 00519 y1 += bwid + space + 6; 00520 space = 8; 00521 bwid = 90; 00522 bheight = 26; 00523 x1 = xcen - bwid / 2; 00524 for(i = 4; i < num_buttons; i++) 00525 { 00526 button[i].xleft = x1; 00527 button[i].ytop = y1; 00528 y1 += bheight + space; 00529 button[i].istext = 1; 00530 button[i].ispoly = 0; 00531 button[i].width = bwid; 00532 button[i].height = bheight; 00533 } 00534 00535 strcpy(button[4].text, "Zoom In"); 00536 strcpy(button[5].text, "Zoom Out"); 00537 strcpy(button[6].text, "Zoom Fit"); 00538 strcpy(button[7].text, "Window"); 00539 strcpy(button[8].text, "PostScript"); 00540 strcpy(button[9].text, "Proceed"); 00541 strcpy(button[10].text, "Exit"); 00542 00543 button[4].fcn = zoom_in; 00544 button[5].fcn = zoom_out; 00545 button[6].fcn = zoom_fit; 00546 button[7].fcn = adjustwin; 00547 button[8].fcn = postscript; 00548 button[9].fcn = proceed; 00549 button[10].fcn = quit; 00550 00551 for(i = 0; i < num_buttons; i++) 00552 map_button(i); 00553 }
static void build_textarea | ( | void | ) | [static] |
Definition at line 407 of file graphics.c.
00408 { 00409 00410 /* Creates a small window at the top of the graphics area for text messages */ 00411 00412 XSetWindowAttributes menu_attributes; 00413 unsigned long valuemask; 00414 00415 textarea = XCreateSimpleWindow(display, toplevel, 00416 0, top_height - T_AREA_HEIGHT, 00417 display_width, T_AREA_HEIGHT - 4, 2, 00418 colors[BLACK], colors[LIGHTGREY]); 00419 menu_attributes.event_mask = ExposureMask; 00420 /* ButtonPresses in this area are ignored. */ 00421 menu_attributes.do_not_propagate_mask = ButtonPressMask; 00422 /* Keep text area on bottom left */ 00423 menu_attributes.win_gravity = SouthWestGravity; 00424 valuemask = CWWinGravity | CWEventMask | CWDontPropagate; 00425 XChangeWindowAttributes(display, textarea, valuemask, &menu_attributes); 00426 XMapWindow(display, textarea); 00427 }
void clearscreen | ( | void | ) |
Definition at line 1205 of file graphics.c.
01206 { 01207 int savecolor; 01208 01209 if(disp_type == SCREEN) 01210 { 01211 XClearWindow(display, toplevel); 01212 } 01213 else 01214 { 01215 /* erases current page. Don't use erasepage, since this will erase * 01216 * everything, (even stuff outside the clipping path) causing * 01217 * problems if this picture is incorporated into a larger document. */ 01218 savecolor = currentcolor; 01219 setcolor(WHITE); 01220 fprintf(ps, "clippath fill\n\n"); 01221 setcolor(savecolor); 01222 } 01223 }
void close_graphics | ( | void | ) |
Definition at line 1958 of file graphics.c.
01959 { 01960 01961 /* Release all my drawing structures (through the X server) and * 01962 * close down the connection. */ 01963 01964 int i; 01965 01966 for(i = 1; i <= MAX_FONT_SIZE; i++) 01967 if(font_is_loaded[i]) 01968 XFreeFont(display, font_info[i]); 01969 01970 XFreeGC(display, gc); 01971 XFreeGC(display, gcxor); 01972 XFreeGC(display, gc_menus); 01973 01974 if(private_cmap != None) 01975 XFreeColormap(display, private_cmap); 01976 01977 XCloseDisplay(display); 01978 free(button); 01979 }
void close_postscript | ( | void | ) |
Definition at line 2118 of file graphics.c.
02119 { 02120 02121 /* Properly ends postscript output and redirects output to screen. */ 02122 02123 fprintf(ps, "showpage\n"); 02124 fprintf(ps, "\n%%%%Trailer\n"); 02125 fclose(ps); 02126 disp_type = SCREEN; 02127 update_transform(); /* Ensure screen world reflects any changes * 02128 * made while printing. */ 02129 02130 /* Need to make sure that we really set up the graphics context -- * 02131 * don't want the change requested to match the current setting and * 02132 * do nothing -> force the changes. */ 02133 02134 force_setcolor(currentcolor); 02135 force_setlinestyle(currentlinestyle); 02136 force_setlinewidth(currentlinewidth); 02137 force_setfontsize(currentfontsize); 02138 }
void create_button | ( | char * | prev_button_text, | |
char * | button_text, | |||
void(*)(void(*drawscreen)(void)) | button_func | |||
) |
Definition at line 585 of file graphics.c.
00588 { 00589 00590 /* Creates a new button below the button containing prev_button_text. * 00591 * The text and button function are set according to button_text and * 00592 * button_func, respectively. */ 00593 00594 int i, bnum, space; 00595 00596 space = 8; 00597 00598 /* Only allow new buttons that are text (not poly) types. */ 00599 00600 bnum = -1; 00601 for(i = 4; i < num_buttons; i++) 00602 { 00603 if(button[i].istext == 1 && 00604 strcmp(button[i].text, prev_button_text) == 0) 00605 { 00606 bnum = i + 1; 00607 break; 00608 } 00609 } 00610 00611 if(bnum == -1) 00612 { 00613 printf 00614 ("Error in create_button: button with text %s not found.\n", 00615 prev_button_text); 00616 exit(1); 00617 } 00618 00619 num_buttons++; 00620 button = (t_button *) my_realloc(button, num_buttons * sizeof(t_button)); 00621 00622 /* NB: Requirement that you specify the button that this button goes under * 00623 * guarantees that button[num_buttons-2] exists and is a text button. */ 00624 00625 button[num_buttons - 1].xleft = button[num_buttons - 2].xleft; 00626 button[num_buttons - 1].ytop = button[num_buttons - 2].ytop + 00627 button[num_buttons - 2].height + space; 00628 button[num_buttons - 1].height = button[num_buttons - 2].height; 00629 button[num_buttons - 1].width = button[num_buttons - 2].width; 00630 map_button(num_buttons - 1); 00631 00632 00633 for(i = num_buttons - 1; i > bnum; i--) 00634 { 00635 button[i].ispoly = button[i - 1].ispoly; 00636 /* No poly copy for now, as I'm only providing the ability to create text * 00637 * buttons. */ 00638 00639 button[i].istext = button[i - 1].istext; 00640 strcpy(button[i].text, button[i - 1].text); 00641 button[i].fcn = button[i - 1].fcn; 00642 button[i].ispressed = button[i - 1].ispressed; 00643 } 00644 00645 button[bnum].istext = 1; 00646 button[bnum].ispoly = 0; 00647 my_strncpy(button[bnum].text, button_text, BUTTON_TEXT_LEN); 00648 button[bnum].fcn = button_func; 00649 button[bnum].ispressed = 1; 00650 }
void destroy_button | ( | char * | button_text | ) |
Definition at line 654 of file graphics.c.
00655 { 00656 00657 /* Destroys the button with text button_text. */ 00658 00659 int i, bnum; 00660 00661 bnum = -1; 00662 for(i = 4; i < num_buttons; i++) 00663 { 00664 if(button[i].istext == 1 && 00665 strcmp(button[i].text, button_text) == 0) 00666 { 00667 bnum = i; 00668 break; 00669 } 00670 } 00671 00672 if(bnum == -1) 00673 { 00674 printf 00675 ("Error in destroy_button: button with text %s not found.\n", 00676 button_text); 00677 exit(1); 00678 } 00679 00680 for(i = bnum + 1; i < num_buttons; i++) 00681 { 00682 button[i - 1].ispoly = button[i].ispoly; 00683 /* No poly copy for now, as I'm only providing the ability to create text * 00684 * buttons. */ 00685 00686 button[i - 1].istext = button[i].istext; 00687 strcpy(button[i - 1].text, button[i].text); 00688 button[i - 1].fcn = button[i].fcn; 00689 button[i - 1].ispressed = button[i].ispressed; 00690 } 00691 00692 unmap_button(num_buttons - 1); 00693 num_buttons--; 00694 button = (t_button *) my_realloc(button, num_buttons * sizeof(t_button)); 00695 }
void draw_message | ( | void | ) |
Definition at line 1617 of file graphics.c.
01618 { 01619 01620 /* Draw the current message in the text area at the screen bottom. */ 01621 01622 int len, width, savefontsize, savecolor; 01623 float ylow; 01624 01625 if(disp_type == SCREEN) 01626 { 01627 XClearWindow(display, textarea); 01628 len = strlen(message); 01629 width = XTextWidth(font_info[menu_font_size], message, len); 01630 01631 XSetForeground(display, gc_menus, colors[BLACK]); 01632 XDrawString(display, textarea, gc_menus, 01633 (top_width - MWIDTH - width) / 2, 01634 (T_AREA_HEIGHT - 4) / 2 + 01635 (font_info[menu_font_size]->ascent - 01636 font_info[menu_font_size]->descent) / 2, message, 01637 len); 01638 } 01639 01640 else 01641 { 01642 /* Draw the message in the bottom margin. Printer's generally can't * 01643 * print on the bottom 1/4" (area with y < 18 in PostScript coords.) */ 01644 01645 savecolor = currentcolor; 01646 setcolor(BLACK); 01647 savefontsize = currentfontsize; 01648 setfontsize(menu_font_size - 2); /* Smaller OK on paper */ 01649 ylow = ps_bot - 8.; 01650 fprintf(ps, "(%s) %.2f %.2f censhow\n", message, 01651 (ps_left + ps_right) / 2., ylow); 01652 setcolor(savecolor); 01653 setfontsize(savefontsize); 01654 } 01655 }
void drawarc | ( | float | xc, | |
float | yc, | |||
float | rad, | |||
float | startang, | |||
float | angextent | |||
) |
Definition at line 1380 of file graphics.c.
01385 { 01386 01387 /* Draws a circular arc. X11 can do elliptical arcs quite simply, and * 01388 * PostScript could do them by scaling the coordinate axes. Too much * 01389 * work for now, and probably too complex an object for users to draw * 01390 * much, so I'm just doing circular arcs. Startang is relative to the * 01391 * Window's positive x direction. Angles in degrees. */ 01392 01393 int xl, yt; 01394 unsigned int width, height; 01395 01396 /* Conservative (but fast) clip test -- check containing rectangle of * 01397 * a circle. */ 01398 01399 if(rect_off_screen(xc - rad, yc - rad, xc + rad, yc + rad)) 01400 return; 01401 01402 /* X Windows has trouble with very large angles. (Over 360). * 01403 * Do following to prevent its inaccurate (overflow?) problems. */ 01404 if(fabs(angextent) > 360.) 01405 angextent = 360.; 01406 01407 startang = angnorm(startang); 01408 01409 if(disp_type == SCREEN) 01410 { 01411 xl = (int)(xcoord(xc) - fabs(xmult * rad)); 01412 yt = (int)(ycoord(yc) - fabs(ymult * rad)); 01413 width = (unsigned int)(2 * fabs(xmult * rad)); 01414 height = width; 01415 XDrawArc(display, toplevel, gc, xl, yt, width, height, 01416 (int)(startang * 64), (int)(angextent * 64)); 01417 } 01418 else 01419 { 01420 fprintf(ps, "%.2f %.2f %.2f %.2f %.2f %s stroke\n", XPOST(xc), 01421 YPOST(yc), fabs(rad * ps_xmult), startang, 01422 startang + angextent, 01423 (angextent < 0) ? "drawarcn" : "drawarc"); 01424 } 01425 }
static void drawbut | ( | int | bnum | ) | [static] |
Definition at line 897 of file graphics.c.
00898 { 00899 00900 /* Draws button bnum in either its pressed or unpressed state. */ 00901 00902 int width, height, thick, i, ispressed; 00903 XPoint mypoly[6]; 00904 00905 ispressed = button[bnum].ispressed; 00906 thick = 2; 00907 width = button[bnum].width; 00908 height = button[bnum].height; 00909 /* Draw top and left edges of 3D box. */ 00910 if(ispressed) 00911 { 00912 XSetForeground(display, gc_menus, colors[BLACK]); 00913 } 00914 else 00915 { 00916 XSetForeground(display, gc_menus, colors[WHITE]); 00917 } 00918 00919 /* Note: X Windows doesn't appear to draw the bottom pixel of * 00920 * a polygon with XFillPolygon, so I make this 1 pixel thicker * 00921 * to compensate. */ 00922 mypoly[0].x = 0; 00923 mypoly[0].y = height; 00924 mypoly[1].x = 0; 00925 mypoly[1].y = 0; 00926 mypoly[2].x = width; 00927 mypoly[2].y = 0; 00928 mypoly[3].x = width - thick; 00929 mypoly[3].y = thick; 00930 mypoly[4].x = thick; 00931 mypoly[4].y = thick; 00932 mypoly[5].x = thick; 00933 mypoly[5].y = height - thick; 00934 XFillPolygon(display, button[bnum].win, gc_menus, mypoly, 6, Convex, 00935 CoordModeOrigin); 00936 00937 /* Draw bottom and right edges of 3D box. */ 00938 if(ispressed) 00939 { 00940 XSetForeground(display, gc_menus, colors[WHITE]); 00941 } 00942 else 00943 { 00944 XSetForeground(display, gc_menus, colors[BLACK]); 00945 } 00946 mypoly[0].x = 0; 00947 mypoly[0].y = height; 00948 mypoly[1].x = width; 00949 mypoly[1].y = height; 00950 mypoly[2].x = width; 00951 mypoly[2].y = 0; 00952 mypoly[3].x = width - thick; 00953 mypoly[3].y = thick; 00954 mypoly[4].x = width - thick; 00955 mypoly[4].y = height - thick; 00956 mypoly[5].x = thick; 00957 mypoly[5].y = height - thick; 00958 XFillPolygon(display, button[bnum].win, gc_menus, mypoly, 6, Convex, 00959 CoordModeOrigin); 00960 00961 /* Draw background */ 00962 if(ispressed) 00963 { 00964 XSetForeground(display, gc_menus, colors[DARKGREY]); 00965 } 00966 else 00967 { 00968 XSetForeground(display, gc_menus, colors[LIGHTGREY]); 00969 } 00970 00971 /* Give x,y of top corner and width and height */ 00972 XFillRectangle(display, button[bnum].win, gc_menus, thick, thick, 00973 width - 2 * thick, height - 2 * thick); 00974 00975 /* Draw polygon, if there is one */ 00976 if(button[bnum].ispoly) 00977 { 00978 for(i = 0; i < 3; i++) 00979 { 00980 mypoly[i].x = button[bnum].poly[i][0]; 00981 mypoly[i].y = button[bnum].poly[i][1]; 00982 } 00983 XSetForeground(display, gc_menus, colors[BLACK]); 00984 XFillPolygon(display, button[bnum].win, gc_menus, mypoly, 3, 00985 Convex, CoordModeOrigin); 00986 } 00987 00988 /* Draw text, if there is any */ 00989 if(button[bnum].istext) 00990 { 00991 XSetForeground(display, gc_menus, colors[BLACK]); 00992 menutext(button[bnum].win, button[bnum].width / 2, 00993 button[bnum].height / 2, button[bnum].text); 00994 } 00995 }
void drawline | ( | float | x1, | |
float | y1, | |||
float | x2, | |||
float | y2 | |||
) |
Definition at line 1262 of file graphics.c.
01266 { 01267 01268 /* Draw a line from (x1,y1) to (x2,y2) in the user-drawable area. * 01269 * Coordinates are in world (user) space. */ 01270 01271 if(rect_off_screen(x1, y1, x2, y2)) 01272 return; 01273 01274 if(disp_type == SCREEN) 01275 { 01276 /* Xlib.h prototype has x2 and y1 mixed up. */ 01277 XDrawLine(display, toplevel, gc, xcoord(x1), ycoord(y1), 01278 xcoord(x2), ycoord(y2)); 01279 } 01280 else 01281 { 01282 fprintf(ps, "%.2f %.2f %.2f %.2f drawline\n", XPOST(x1), 01283 YPOST(y1), XPOST(x2), YPOST(y2)); 01284 } 01285 }
static void drawmenu | ( | void | ) | [static] |
Definition at line 1031 of file graphics.c.
01032 { 01033 int i; 01034 01035 for(i = 0; i < num_buttons; i++) 01036 { 01037 drawbut(i); 01038 } 01039 }
void drawrect | ( | float | x1, | |
float | y1, | |||
float | x2, | |||
float | y2 | |||
) |
Definition at line 1288 of file graphics.c.
01292 { 01293 01294 /* (x1,y1) and (x2,y2) are diagonally opposed corners, in world coords. */ 01295 01296 unsigned int width, height; 01297 int xw1, yw1, xw2, yw2, xl, yt; 01298 01299 if(rect_off_screen(x1, y1, x2, y2)) 01300 return; 01301 01302 if(disp_type == SCREEN) 01303 { 01304 /* translate to X Windows calling convention. */ 01305 xw1 = xcoord(x1); 01306 xw2 = xcoord(x2); 01307 yw1 = ycoord(y1); 01308 yw2 = ycoord(y2); 01309 xl = min(xw1, xw2); 01310 yt = min(yw1, yw2); 01311 width = abs(xw1 - xw2); 01312 height = abs(yw1 - yw2); 01313 XDrawRectangle(display, toplevel, gc, xl, yt, width, height); 01314 } 01315 else 01316 { 01317 fprintf(ps, "%.2f %.2f %.2f %.2f drawrect\n", XPOST(x1), 01318 YPOST(y1), XPOST(x2), YPOST(y2)); 01319 } 01320 }
void drawtext | ( | float | xc, | |
float | yc, | |||
const char * | text, | |||
float | boundx | |||
) |
Definition at line 1533 of file graphics.c.
01537 { 01538 01539 /* Draws text centered on xc,yc if it fits in boundx */ 01540 01541 int len, width, xw_off, yw_off; 01542 01543 len = strlen(text); 01544 width = XTextWidth(font_info[currentfontsize], text, len); 01545 if(width > fabs(boundx * xmult)) 01546 return; /* Don't draw if it won't fit */ 01547 01548 xw_off = width / (2. * xmult); /* NB: sign doesn't matter. */ 01549 01550 /* NB: 2 * descent makes this slightly conservative but simplifies code. */ 01551 yw_off = (font_info[currentfontsize]->ascent + 01552 2 * font_info[currentfontsize]->descent) / (2. * ymult); 01553 01554 /* Note: text can be clipped when a little bit of it would be visible * 01555 * right now. Perhaps X doesn't return extremely accurate width and * 01556 * ascent values, etc? Could remove this completely by multiplying * 01557 * xw_off and yw_off by, 1.2 or 1.5. */ 01558 01559 if(rect_off_screen(xc - xw_off, yc - yw_off, xc + xw_off, yc + yw_off)) 01560 return; 01561 01562 if(disp_type == SCREEN) 01563 { 01564 XDrawString(display, toplevel, gc, xcoord(xc) - width / 2, 01565 ycoord(yc) + (font_info[currentfontsize]->ascent - 01566 font_info[currentfontsize]->descent) / 01567 2, text, len); 01568 } 01569 else 01570 { 01571 fprintf(ps, "(%s) %.2f %.2f censhow\n", text, XPOST(xc), 01572 YPOST(yc)); 01573 } 01574 }
void event_loop | ( | void(*)(float x, float y) | act_on_button, | |
void(*)(void) | drawscreen | |||
) |
Definition at line 1118 of file graphics.c.
01121 { 01122 01123 /* The program's main event loop. Must be passed a user routine * 01124 * drawscreen which redraws the screen. It handles all window resizing * 01125 * zooming etc. itself. If the user clicks a button in the graphics * 01126 * (toplevel) area, the act_on_button routine passed in is called. */ 01127 01128 XEvent report; 01129 int bnum; 01130 float x, y; 01131 01132 #define OFF 1 01133 #define ON 0 01134 01135 turn_on_off(ON); 01136 while(1) 01137 { 01138 XNextEvent(display, &report); 01139 switch (report.type) 01140 { 01141 case Expose: 01142 #ifdef VERBOSE 01143 printf("Got an expose event.\n"); 01144 printf("Count is: %d.\n", report.xexpose.count); 01145 printf("Window ID is: %d.\n", report.xexpose.window); 01146 #endif 01147 if(report.xexpose.count != 0) 01148 break; 01149 if(report.xexpose.window == menu) 01150 drawmenu(); 01151 else if(report.xexpose.window == toplevel) 01152 drawscreen(); 01153 else if(report.xexpose.window == textarea) 01154 draw_message(); 01155 break; 01156 case ConfigureNotify: 01157 top_width = report.xconfigure.width; 01158 top_height = report.xconfigure.height; 01159 update_transform(); 01160 #ifdef VERBOSE 01161 printf("Got a ConfigureNotify.\n"); 01162 printf("New width: %d New height: %d.\n", top_width, 01163 top_height); 01164 #endif 01165 break; 01166 case ButtonPress: 01167 #ifdef VERBOSE 01168 printf("Got a buttonpress.\n"); 01169 printf("Window ID is: %d.\n", report.xbutton.window); 01170 #endif 01171 if(report.xbutton.window == toplevel) 01172 { 01173 x = XTOWORLD(report.xbutton.x); 01174 y = YTOWORLD(report.xbutton.y); 01175 act_on_button(x, y); 01176 } 01177 else 01178 { /* A menu button was pressed. */ 01179 bnum = which_button(report.xbutton.window); 01180 #ifdef VERBOSE 01181 printf("Button number is %d\n", bnum); 01182 #endif 01183 button[bnum].ispressed = 1; 01184 drawbut(bnum); 01185 XFlush(display); /* Flash the button */ 01186 button[bnum].fcn(drawscreen); 01187 button[bnum].ispressed = 0; 01188 drawbut(bnum); 01189 if(button[bnum].fcn == proceed) 01190 { 01191 turn_on_off(OFF); 01192 flushinput(); 01193 return; /* Rather clumsy way of returning * 01194 * control to the simulator */ 01195 } 01196 } 01197 break; 01198 } 01199 } 01200 }
void fillarc | ( | float | xc, | |
float | yc, | |||
float | rad, | |||
float | startang, | |||
float | angextent | |||
) |
Definition at line 1429 of file graphics.c.
01434 { 01435 01436 /* Fills a circular arc. Startang is relative to the Window's positive x * 01437 * direction. Angles in degrees. */ 01438 01439 int xl, yt; 01440 unsigned int width, height; 01441 01442 /* Conservative (but fast) clip test -- check containing rectangle of * 01443 * a circle. */ 01444 01445 if(rect_off_screen(xc - rad, yc - rad, xc + rad, yc + rad)) 01446 return; 01447 01448 /* X Windows has trouble with very large angles. (Over 360). * 01449 * Do following to prevent its inaccurate (overflow?) problems. */ 01450 01451 if(fabs(angextent) > 360.) 01452 angextent = 360.; 01453 01454 startang = angnorm(startang); 01455 01456 if(disp_type == SCREEN) 01457 { 01458 xl = (int)(xcoord(xc) - fabs(xmult * rad)); 01459 yt = (int)(ycoord(yc) - fabs(ymult * rad)); 01460 width = (unsigned int)(2 * fabs(xmult * rad)); 01461 height = width; 01462 XFillArc(display, toplevel, gc, xl, yt, width, height, 01463 (int)(startang * 64), (int)(angextent * 64)); 01464 } 01465 else 01466 { 01467 fprintf(ps, "%.2f %.2f %.2f %.2f %.2f %s\n", fabs(rad * ps_xmult), 01468 startang, startang + angextent, XPOST(xc), YPOST(yc), 01469 (angextent < 0) ? "fillarcn" : "fillarc"); 01470 } 01471 }
void fillpoly | ( | t_point * | points, | |
int | npoints | |||
) |
Definition at line 1475 of file graphics.c.
01477 { 01478 01479 XPoint transpoints[MAXPTS]; 01480 int i; 01481 float xmin, ymin, xmax, ymax; 01482 01483 if(npoints > MAXPTS) 01484 { 01485 printf 01486 ("Error in fillpoly: Only %d points allowed per polygon.\n", 01487 MAXPTS); 01488 printf("%d points were requested. Polygon is not drawn.\n", 01489 npoints); 01490 return; 01491 } 01492 01493 /* Conservative (but fast) clip test -- check containing rectangle of * 01494 * polygon. */ 01495 01496 xmin = xmax = points[0].x; 01497 ymin = ymax = points[0].y; 01498 01499 for(i = 1; i < npoints; i++) 01500 { 01501 xmin = min(xmin, points[i].x); 01502 xmax = max(xmax, points[i].x); 01503 ymin = min(ymin, points[i].y); 01504 ymax = max(ymax, points[i].y); 01505 } 01506 01507 if(rect_off_screen(xmin, ymin, xmax, ymax)) 01508 return; 01509 01510 if(disp_type == SCREEN) 01511 { 01512 for(i = 0; i < npoints; i++) 01513 { 01514 transpoints[i].x = (short)xcoord(points[i].x); 01515 transpoints[i].y = (short)ycoord(points[i].y); 01516 } 01517 XFillPolygon(display, toplevel, gc, transpoints, npoints, Complex, 01518 CoordModeOrigin); 01519 } 01520 else 01521 { 01522 fprintf(ps, "\n"); 01523 01524 for(i = npoints - 1; i >= 0; i--) 01525 fprintf(ps, "%.2f %.2f\n", XPOST(points[i].x), 01526 YPOST(points[i].y)); 01527 01528 fprintf(ps, "%d fillpoly\n", npoints); 01529 } 01530 }
void fillrect | ( | float | x1, | |
float | y1, | |||
float | x2, | |||
float | y2 | |||
) |
Definition at line 1324 of file graphics.c.
01328 { 01329 01330 /* (x1,y1) and (x2,y2) are diagonally opposed corners in world coords. */ 01331 01332 unsigned int width, height; 01333 int xw1, yw1, xw2, yw2, xl, yt; 01334 01335 if(rect_off_screen(x1, y1, x2, y2)) 01336 return; 01337 01338 if(disp_type == SCREEN) 01339 { 01340 /* translate to X Windows calling convention. */ 01341 xw1 = xcoord(x1); 01342 xw2 = xcoord(x2); 01343 yw1 = ycoord(y1); 01344 yw2 = ycoord(y2); 01345 xl = min(xw1, xw2); 01346 yt = min(yw1, yw2); 01347 width = abs(xw1 - xw2); 01348 height = abs(yw1 - yw2); 01349 XFillRectangle(display, toplevel, gc, xl, yt, width, height); 01350 } 01351 else 01352 { 01353 fprintf(ps, "%.2f %.2f %.2f %.2f fillrect\n", XPOST(x1), 01354 YPOST(y1), XPOST(x2), YPOST(y2)); 01355 } 01356 }
void flushinput | ( | void | ) |
static void force_setcolor | ( | int | cindex | ) | [static] |
Definition at line 262 of file graphics.c.
00263 { 00264 00265 static char *ps_cnames[NUM_COLOR] = 00266 { "white", "black", "grey55", "grey75", 00267 "blue", "green", "yellow", "cyan", "red", "darkgreen", "magenta", 00268 "bisque", "lightblue", "thistle", "plum", "khaki", 00269 "coral", "turquoise", "mediumpurple", "darkslateblue", "darkkhaki" 00270 }; 00271 00272 currentcolor = cindex; 00273 00274 if(disp_type == SCREEN) 00275 { 00276 XSetForeground(display, gc, colors[cindex]); 00277 } 00278 else 00279 { 00280 fprintf(ps, "%s\n", ps_cnames[cindex]); 00281 } 00282 }
static void force_setfontsize | ( | int | pointsize | ) | [static] |
Definition at line 361 of file graphics.c.
00362 { 00363 00364 /* Valid point sizes are between 1 and MAX_FONT_SIZE */ 00365 00366 if(pointsize < 1) 00367 pointsize = 1; 00368 else if(pointsize > MAX_FONT_SIZE) 00369 pointsize = MAX_FONT_SIZE; 00370 00371 currentfontsize = pointsize; 00372 00373 00374 if(disp_type == SCREEN) 00375 { 00376 if(!font_is_loaded[pointsize]) 00377 { 00378 load_font(pointsize); 00379 font_is_loaded[pointsize] = 1; 00380 } 00381 XSetFont(display, gc, font_info[pointsize]->fid); 00382 } 00383 00384 else 00385 { 00386 /* PostScript: set up font and centering function */ 00387 00388 fprintf(ps, "%d setfontsize\n", pointsize); 00389 } 00390 }
static void force_setlinestyle | ( | int | linestyle | ) | [static] |
Definition at line 295 of file graphics.c.
00296 { 00297 00298 /* Note SOLID is 0 and DASHED is 1 for linestyle. */ 00299 00300 /* PostScript and X commands needed, respectively. */ 00301 00302 static char *ps_text[2] = { "linesolid", "linedashed" }; 00303 static int x_vals[2] = { LineSolid, LineOnOffDash }; 00304 00305 currentlinestyle = linestyle; 00306 00307 if(disp_type == SCREEN) 00308 { 00309 XSetLineAttributes(display, gc, currentlinewidth, 00310 x_vals[linestyle], CapButt, JoinMiter); 00311 } 00312 else 00313 { 00314 fprintf(ps, "%s\n", ps_text[linestyle]); 00315 } 00316 }
static void force_setlinewidth | ( | int | linewidth | ) | [static] |
Definition at line 329 of file graphics.c.
00330 { 00331 00332 /* linewidth should be greater than or equal to 0 to make any sense. */ 00333 /* Note SOLID is 0 and DASHED is 1 for linestyle. */ 00334 00335 static int x_vals[2] = { LineSolid, LineOnOffDash }; 00336 00337 currentlinewidth = linewidth; 00338 00339 if(disp_type == SCREEN) 00340 { 00341 XSetLineAttributes(display, gc, linewidth, 00342 x_vals[currentlinestyle], CapButt, JoinMiter); 00343 } 00344 else 00345 { 00346 fprintf(ps, "%d setlinewidth\n", linewidth); 00347 } 00348 }
void init_graphics | ( | char * | window_name | ) |
Definition at line 699 of file graphics.c.
00700 { 00701 00702 /* Open the toplevel window, get the colors, 2 graphics * 00703 * contexts, load a font, and set up the toplevel window * 00704 * Calls build_default_menu to set up the default menu. */ 00705 00706 char *display_name = NULL; 00707 int x, y; /* window position */ 00708 unsigned int border_width = 2; /* ignored by OpenWindows */ 00709 XTextProperty windowName; 00710 00711 /* X Windows' names for my colours. */ 00712 char *cnames[NUM_COLOR] = { "white", "black", "grey55", "grey75", "blue", 00713 "green", "yellow", "cyan", "red", "RGBi:0.0/0.5/0.0", "magenta", 00714 "bisque", "lightblue", "thistle", "plum", "khaki", 00715 "coral", "turquoise", "mediumpurple", "darkslateblue", "darkkhaki" 00716 }; 00717 00718 XColor exact_def; 00719 Colormap cmap; 00720 int i; 00721 unsigned long valuemask = 0; /* ignore XGCvalues and use defaults */ 00722 XGCValues values; 00723 XEvent event; 00724 00725 00726 disp_type = SCREEN; /* Graphics go to screen, not ps */ 00727 00728 for(i = 0; i <= MAX_FONT_SIZE; i++) 00729 font_is_loaded[i] = 0; /* No fonts loaded yet. */ 00730 00731 /* connect to X server */ 00732 if((display = XOpenDisplay(display_name)) == NULL) 00733 { 00734 fprintf(stderr, "Cannot connect to X server %s\n", 00735 XDisplayName(display_name)); 00736 exit(-1); 00737 } 00738 00739 /* get screen size from display structure macro */ 00740 screen_num = DefaultScreen(display); 00741 display_width = DisplayWidth(display, screen_num); 00742 display_height = DisplayHeight(display, screen_num); 00743 00744 x = y = 0; 00745 00746 top_width = 2 * display_width / 3; 00747 top_height = 4 * display_height / 5; 00748 00749 cmap = DefaultColormap(display, screen_num); 00750 private_cmap = None; 00751 00752 for(i = 0; i < NUM_COLOR; i++) 00753 { 00754 if(!XParseColor(display, cmap, cnames[i], &exact_def)) 00755 { 00756 fprintf(stderr, "Color name %s not in database", 00757 cnames[i]); 00758 exit(-1); 00759 } 00760 if(!XAllocColor(display, cmap, &exact_def)) 00761 { 00762 fprintf(stderr, "Couldn't allocate color %s.\n", 00763 cnames[i]); 00764 00765 if(private_cmap == None) 00766 { 00767 fprintf(stderr, 00768 "Will try to allocate a private colourmap.\n"); 00769 fprintf(stderr, 00770 "Colours will only display correctly when your " 00771 "cursor is in the graphics window.\n" 00772 "Exit other colour applications and rerun this " 00773 "program if you don't like that.\n\n"); 00774 00775 private_cmap = 00776 XCopyColormapAndFree(display, cmap); 00777 cmap = private_cmap; 00778 if(!XAllocColor(display, cmap, &exact_def)) 00779 { 00780 fprintf(stderr, 00781 "Couldn't allocate color %s as private.\n", 00782 cnames[i]); 00783 exit(1); 00784 } 00785 } 00786 00787 else 00788 { 00789 fprintf(stderr, 00790 "Couldn't allocate color %s as private.\n", 00791 cnames[i]); 00792 exit(1); 00793 } 00794 } 00795 colors[i] = exact_def.pixel; 00796 } 00797 00798 toplevel = 00799 XCreateSimpleWindow(display, RootWindow(display, screen_num), x, y, 00800 top_width, top_height, border_width, 00801 colors[BLACK], colors[WHITE]); 00802 00803 if(private_cmap != None) 00804 XSetWindowColormap(display, toplevel, private_cmap); 00805 00806 /* hints stuff deleted. */ 00807 00808 XSelectInput(display, toplevel, ExposureMask | StructureNotifyMask | 00809 ButtonPressMask); 00810 00811 00812 /* Create default Graphics Contexts. valuemask = 0 -> use defaults. */ 00813 gc = XCreateGC(display, toplevel, valuemask, &values); 00814 gc_menus = XCreateGC(display, toplevel, valuemask, &values); 00815 00816 /* Create XOR graphics context for Rubber Banding */ 00817 values.function = GXxor; 00818 values.foreground = colors[BLACK]; 00819 gcxor = XCreateGC(display, toplevel, (GCFunction | GCForeground), 00820 &values); 00821 00822 /* specify font for menus. */ 00823 load_font(menu_font_size); 00824 font_is_loaded[menu_font_size] = 1; 00825 XSetFont(display, gc_menus, font_info[menu_font_size]->fid); 00826 00827 /* Set drawing defaults for user-drawable area. Use whatever the * 00828 * initial values of the current stuff was set to. */ 00829 force_setfontsize(currentfontsize); 00830 force_setcolor(currentcolor); 00831 force_setlinestyle(currentlinestyle); 00832 force_setlinewidth(currentlinewidth); 00833 00834 XStringListToTextProperty(&window_name, 1, &windowName); 00835 XSetWMName(display, toplevel, &windowName); 00836 /* Uncomment to set icon name */ 00837 /* XSetWMIconName (display, toplevel, &windowName); */ 00838 00839 /* XStringListToTextProperty copies the window_name string into * 00840 * windowName.value. Free this memory now. */ 00841 00842 free(windowName.value); 00843 00844 XMapWindow(display, toplevel); 00845 build_textarea(); 00846 build_default_menu(); 00847 00848 /* The following is completely unnecessary if the user is using the * 00849 * interactive (event_loop) graphics. It waits for the first Expose * 00850 * event before returning so that I can tell the window manager has got * 00851 * the top-level window up and running. Thus the user can start drawing * 00852 * into this window immediately, and there's no danger of the window not * 00853 * being ready and output being lost. */ 00854 00855 XPeekIfEvent(display, &event, test_if_exposed, NULL); 00856 }
int init_postscript | ( | char * | fname | ) |
Definition at line 1983 of file graphics.c.
01984 { 01985 /* Opens a file for PostScript output. The header information, * 01986 * clipping path, etc. are all dumped out. If the file could * 01987 * not be opened, the routine returns 0; otherwise it returns 1. */ 01988 01989 ps = fopen(fname, "w"); 01990 if(ps == NULL) 01991 { 01992 printf("Error: could not open %s for PostScript output.\n", 01993 fname); 01994 printf("Drawing to screen instead.\n"); 01995 return (0); 01996 } 01997 disp_type = POSTSCRIPT; /* Graphics go to postscript file now. */ 01998 01999 /* Header for minimal conformance with the Adobe structuring convention */ 02000 fprintf(ps, "%%!PS-Adobe-1.0\n"); 02001 fprintf(ps, "%%%%DocumentFonts: Helvetica\n"); 02002 fprintf(ps, "%%%%Pages: 1\n"); 02003 /* Set up postscript transformation macros and page boundaries */ 02004 update_ps_transform(); 02005 /* Bottom margin is at ps_bot - 15. to leave room for the on-screen message. */ 02006 fprintf(ps, "%%%%BoundingBox: %d %d %d %d\n", 02007 (int)ps_left, (int)(ps_bot - 15.), (int)ps_right, (int)ps_top); 02008 fprintf(ps, "%%%%EndComments\n"); 02009 02010 fprintf(ps, "/censhow %%draw a centered string\n"); 02011 fprintf(ps, " { moveto %% move to proper spot\n"); 02012 fprintf(ps, " dup stringwidth pop %% get x length of string\n"); 02013 fprintf(ps, " -2 div %% Proper left start\n"); 02014 fprintf(ps, 02015 " yoff rmoveto %% Move left that much and down half font height\n"); 02016 fprintf(ps, " show newpath } def %% show the string\n\n"); 02017 02018 fprintf(ps, "/setfontsize %% set font to desired size and compute " 02019 "centering yoff\n"); 02020 fprintf(ps, " { /Helvetica findfont\n"); 02021 fprintf(ps, " exch scalefont\n"); 02022 fprintf(ps, " setfont %% Font size set ...\n\n"); 02023 fprintf(ps, " 0 0 moveto %% Get vertical centering offset\n"); 02024 fprintf(ps, " (Xg) true charpath\n"); 02025 fprintf(ps, " flattenpath pathbbox\n"); 02026 fprintf(ps, " /ascent exch def pop -1 mul /descent exch def pop\n"); 02027 fprintf(ps, " newpath\n"); 02028 fprintf(ps, " descent ascent sub 2 div /yoff exch def } def\n\n"); 02029 02030 fprintf(ps, "%% Next two lines for debugging only.\n"); 02031 fprintf(ps, "/str 20 string def\n"); 02032 fprintf(ps, "/pnum {str cvs print ( ) print} def\n"); 02033 02034 fprintf(ps, "/drawline %% draw a line from (x2,y2) to (x1,y1)\n"); 02035 fprintf(ps, " { moveto lineto stroke } def\n\n"); 02036 02037 fprintf(ps, "/rect %% outline a rectangle \n"); 02038 fprintf(ps, " { /y2 exch def /x2 exch def /y1 exch def /x1 exch def\n"); 02039 fprintf(ps, " x1 y1 moveto\n"); 02040 fprintf(ps, " x2 y1 lineto\n"); 02041 fprintf(ps, " x2 y2 lineto\n"); 02042 fprintf(ps, " x1 y2 lineto\n"); 02043 fprintf(ps, " closepath } def\n\n"); 02044 02045 fprintf(ps, "/drawrect %% draw outline of a rectanagle\n"); 02046 fprintf(ps, " { rect stroke } def\n\n"); 02047 02048 fprintf(ps, "/fillrect %% fill in a rectanagle\n"); 02049 fprintf(ps, " { rect fill } def\n\n"); 02050 02051 fprintf(ps, "/drawarc { arc stroke } def %% draw an arc\n"); 02052 fprintf(ps, "/drawarcn { arcn stroke } def " 02053 " %% draw an arc in the opposite direction\n\n"); 02054 02055 fprintf(ps, "%%Fill a counterclockwise or clockwise arc sector, " 02056 "respectively.\n"); 02057 fprintf(ps, 02058 "/fillarc { moveto currentpoint 5 2 roll arc closepath fill } " 02059 "def\n"); 02060 fprintf(ps, 02061 "/fillarcn { moveto currentpoint 5 2 roll arcn closepath fill } " 02062 "def\n\n"); 02063 02064 fprintf(ps, 02065 "/fillpoly { 3 1 roll moveto %% move to first point\n" 02066 " 2 exch 1 exch {pop lineto} for %% line to all other points\n" 02067 " closepath fill } def\n\n"); 02068 02069 02070 fprintf(ps, "%%Color Definitions:\n"); 02071 fprintf(ps, "/white { 1 setgray } def\n"); 02072 fprintf(ps, "/black { 0 setgray } def\n"); 02073 fprintf(ps, "/grey55 { .55 setgray } def\n"); 02074 fprintf(ps, "/grey75 { .75 setgray } def\n"); 02075 fprintf(ps, "/blue { 0 0 1 setrgbcolor } def\n"); 02076 fprintf(ps, "/green { 0 1 0 setrgbcolor } def\n"); 02077 fprintf(ps, "/yellow { 1 1 0 setrgbcolor } def\n"); 02078 fprintf(ps, "/cyan { 0 1 1 setrgbcolor } def\n"); 02079 fprintf(ps, "/red { 1 0 0 setrgbcolor } def\n"); 02080 fprintf(ps, "/darkgreen { 0 0.5 0 setrgbcolor } def\n"); 02081 fprintf(ps, "/magenta { 1 0 1 setrgbcolor } def\n"); 02082 fprintf(ps, "/bisque { 1 0.9 0.8 setrgbcolor } def\n"); 02083 fprintf(ps, "/lightblue { 0.7 0.8 0.9 setrgbcolor } def\n"); 02084 fprintf(ps, "/thistle { 0.8 0.7 0.8 setrgbcolor } def\n"); 02085 fprintf(ps, "/plum {0.8 0.6 0.8 setrgbcolor } def\n"); 02086 fprintf(ps, "/khaki { 1 0.9 0.6 setrgbcolor } def\n"); 02087 fprintf(ps, "/coral { 1 0.7 0.6 setrgbcolor } def\n"); 02088 fprintf(ps, "/turquoise { 0.5 0.6 0.9 setrgbcolor } def\n"); 02089 fprintf(ps, "/mediumpurple { 0.7 0.6 0.7 setrgbcolor } def\n"); 02090 fprintf(ps, "/darkslateblue { 0.7 0.5 0.7 setrgbcolor } def\n"); 02091 fprintf(ps, "/darkkhaki { 0.9 0.7 0.4 setrgbcolor } def\n"); 02092 02093 fprintf(ps, "\n%%Solid and dashed line definitions:\n"); 02094 fprintf(ps, "/linesolid {[] 0 setdash} def\n"); 02095 fprintf(ps, "/linedashed {[3 3] 0 setdash} def\n"); 02096 02097 fprintf(ps, "\n%%%%EndProlog\n"); 02098 fprintf(ps, "%%%%Page: 1 1\n\n"); 02099 02100 /* Set up PostScript graphics state to match current one. */ 02101 force_setcolor(currentcolor); 02102 force_setlinestyle(currentlinestyle); 02103 force_setlinewidth(currentlinewidth); 02104 force_setfontsize(currentfontsize); 02105 02106 /* Draw this in the bottom margin -- must do before the clippath is set */ 02107 draw_message(); 02108 02109 /* Set clipping on page. */ 02110 fprintf(ps, "%.2f %.2f %.2f %.2f rect ", ps_left, ps_bot, ps_right, 02111 ps_top); 02112 fprintf(ps, "clip newpath\n\n"); 02113 02114 return (1); 02115 }
void init_world | ( | float | x1, | |
float | y1, | |||
float | x2, | |||
float | y2 | |||
) |
Definition at line 1587 of file graphics.c.
01591 { 01592 01593 /* Sets the coordinate system the user wants to draw into. */ 01594 01595 xleft = x1; 01596 xright = x2; 01597 ytop = y1; 01598 ybot = y2; 01599 01600 saved_xleft = xleft; /* Save initial world coordinates to allow full */ 01601 saved_xright = xright; /* view button to zoom all the way out. */ 01602 saved_ytop = ytop; 01603 saved_ybot = ybot; 01604 01605 if(disp_type == SCREEN) 01606 { 01607 update_transform(); 01608 } 01609 else 01610 { 01611 update_ps_transform(); 01612 } 01613 }
static void load_font | ( | int | pointsize | ) | [static] |
Definition at line 234 of file graphics.c.
00235 { 00236 00237 /* Makes sure the font of the specified size is loaded. Point_size * 00238 * MUST be between 1 and MAX_FONT_SIZE -- no check is performed here. */ 00239 /* Use proper point-size medium-weight upright helvetica font */ 00240 00241 char fontname[44]; 00242 00243 sprintf(fontname, "-*-helvetica-medium-r-*--*-%d0-*-*-*-*-*-*", 00244 pointsize); 00245 00246 #ifdef VERBOSE 00247 printf("Loading font: point size: %d, fontname: %s\n", pointsize, 00248 fontname); 00249 #endif 00250 00251 /* Load font and get font information structure. */ 00252 00253 if((font_info[pointsize] = XLoadQueryFont(display, fontname)) == NULL) 00254 { 00255 fprintf(stderr, "Cannot open desired font\n"); 00256 exit(-1); 00257 } 00258 }
static void map_button | ( | int | bnum | ) | [static] |
Definition at line 557 of file graphics.c.
00558 { 00559 00560 /* Maps a button onto the screen and set it up for input, etc. */ 00561 00562 button[bnum].win = XCreateSimpleWindow(display, menu, 00563 button[bnum].xleft, 00564 button[bnum].ytop, 00565 button[bnum].width, 00566 button[bnum].height, 0, 00567 colors[WHITE], colors[LIGHTGREY]); 00568 XMapWindow(display, button[bnum].win); 00569 XSelectInput(display, button[bnum].win, ButtonPressMask); 00570 button[bnum].ispressed = 1; 00571 }
static void menutext | ( | Window | win, | |
int | xc, | |||
int | yc, | |||
char * | text | |||
) | [static] |
Definition at line 878 of file graphics.c.
00882 { 00883 00884 /* draws text center at xc, yc -- used only by menu drawing stuff */ 00885 00886 int len, width; 00887 00888 len = strlen(text); 00889 width = XTextWidth(font_info[menu_font_size], text, len); 00890 XDrawString(display, win, gc_menus, xc - width / 2, yc + 00891 (font_info[menu_font_size]->ascent - 00892 font_info[menu_font_size]->descent) / 2, text, len); 00893 }
static void postscript | ( | void(*)(void) | drawscreen | ) | [static] |
Definition at line 1917 of file graphics.c.
01918 { 01919 01920 /* Takes a snapshot of the screen and stores it in pic?.ps. The * 01921 * first picture goes in pic1.ps, the second in pic2.ps, etc. */ 01922 01923 static int piccount = 1; 01924 int success; 01925 char fname[20]; 01926 01927 sprintf(fname, "pic%d.ps", piccount); 01928 success = init_postscript(fname); 01929 01930 if(success == 0) 01931 return; /* Couldn't open file, abort. */ 01932 01933 drawscreen(); 01934 close_postscript(); 01935 piccount++; 01936 }
static void proceed | ( | void(*)(void) | drawscreen | ) | [static] |
static void quit | ( | void(*)(void) | drawscreen | ) | [static] |
Definition at line 1949 of file graphics.c.
01950 { 01951 01952 close_graphics(); 01953 exit(0); 01954 }
static int rect_off_screen | ( | float | x1, | |
float | y1, | |||
float | x2, | |||
float | y2 | |||
) | [static] |
Definition at line 1226 of file graphics.c.
01230 { 01231 01232 /* Return 1 if I can quarantee no part of this rectangle will * 01233 * lie within the user drawing area. Otherwise return 0. * 01234 * Note: this routine is only used to help speed (and to shrink ps * 01235 * files) -- it will be highly effective when the graphics are zoomed * 01236 * in and lots are off-screen. I don't have to pre-clip for * 01237 * correctness. */ 01238 01239 float xmin, xmax, ymin, ymax; 01240 01241 xmin = min(xleft, xright); 01242 if(x1 < xmin && x2 < xmin) 01243 return (1); 01244 01245 xmax = max(xleft, xright); 01246 if(x1 > xmax && x2 > xmax) 01247 return (1); 01248 01249 ymin = min(ytop, ybot); 01250 if(y1 < ymin && y2 < ymin) 01251 return (1); 01252 01253 ymax = max(ytop, ybot); 01254 if(y1 > ymax && y2 > ymax) 01255 return (1); 01256 01257 return (0); 01258 }
void setcolor | ( | int | cindex | ) |
Definition at line 286 of file graphics.c.
00287 { 00288 00289 if(currentcolor != cindex) 00290 force_setcolor(cindex); 00291 }
void setfontsize | ( | int | pointsize | ) |
Definition at line 394 of file graphics.c.
00395 { 00396 /* For efficiency, this routine doesn't do anything if no change is * 00397 * implied. If you want to force the graphics context or PS file * 00398 * to have font info set, call force_setfontsize (this is necessary * 00399 * in initialization and X11 / Postscript switches). */ 00400 00401 if(pointsize != currentfontsize) 00402 force_setfontsize(pointsize); 00403 }
void setlinestyle | ( | int | linestyle | ) |
Definition at line 320 of file graphics.c.
00321 { 00322 00323 if(linestyle != currentlinestyle) 00324 force_setlinestyle(linestyle); 00325 }
void setlinewidth | ( | int | linewidth | ) |
Definition at line 352 of file graphics.c.
00353 { 00354 00355 if(linewidth != currentlinewidth) 00356 force_setlinewidth(linewidth); 00357 }
static void setpoly | ( | int | bnum, | |
int | xc, | |||
int | yc, | |||
int | r, | |||
float | theta | |||
) | [static] |
Definition at line 431 of file graphics.c.
00436 { 00437 00438 /* Puts a triangle in the poly array for button[bnum] */ 00439 00440 int i; 00441 00442 button[bnum].istext = 0; 00443 button[bnum].ispoly = 1; 00444 for(i = 0; i < 3; i++) 00445 { 00446 button[bnum].poly[i][0] = (int)(xc + r * cos(theta) + 0.5); 00447 button[bnum].poly[i][1] = (int)(yc + r * sin(theta) + 0.5); 00448 theta += 2 * PI / 3; 00449 } 00450 }
static Bool test_if_exposed | ( | Display * | disp, | |
XEvent * | event_ptr, | |||
XPointer | dummy | |||
) | [static] |
Definition at line 860 of file graphics.c.
00863 { 00864 00865 /* Returns True if the event passed in is an exposure event. Note that * 00866 * the bool type returned by this function is defined in Xlib.h. */ 00867 00868 if(event_ptr->type == Expose) 00869 { 00870 return (True); 00871 } 00872 00873 return (False); 00874 }
static void translate_down | ( | void(*)(void) | drawscreen | ) | [static] |
Definition at line 1743 of file graphics.c.
01744 { 01745 01746 /* Moves view 1/2 screen down. */ 01747 01748 float ystep; 01749 01750 ystep = (ybot - ytop) / 2.; 01751 ytop += ystep; 01752 ybot += ystep; 01753 update_transform(); 01754 drawscreen(); 01755 }
static void translate_left | ( | void(*)(void) | drawscreen | ) | [static] |
Definition at line 1759 of file graphics.c.
01760 { 01761 01762 /* Moves view 1/2 screen left. */ 01763 01764 float xstep; 01765 01766 xstep = (xright - xleft) / 2.; 01767 xleft -= xstep; 01768 xright -= xstep; 01769 update_transform(); 01770 drawscreen(); 01771 }
static void translate_right | ( | void(*)(void) | drawscreen | ) | [static] |
Definition at line 1775 of file graphics.c.
01776 { 01777 01778 /* Moves view 1/2 screen right. */ 01779 01780 float xstep; 01781 01782 xstep = (xright - xleft) / 2.; 01783 xleft += xstep; 01784 xright += xstep; 01785 update_transform(); 01786 drawscreen(); 01787 }
static void translate_up | ( | void(*)(void) | drawscreen | ) | [static] |
Definition at line 1727 of file graphics.c.
01728 { 01729 01730 /* Moves view 1/2 screen up. */ 01731 01732 float ystep; 01733 01734 ystep = (ybot - ytop) / 2.; 01735 ytop -= ystep; 01736 ybot -= ystep; 01737 update_transform(); 01738 drawscreen(); 01739 }
static void turn_on_off | ( | int | pressed | ) | [static] |
Definition at line 999 of file graphics.c.
01000 { 01001 01002 /* Shows when the menu is active or inactive by colouring the * 01003 * buttons. */ 01004 01005 int i; 01006 01007 for(i = 0; i < num_buttons; i++) 01008 { 01009 button[i].ispressed = pressed; 01010 drawbut(i); 01011 } 01012 }
static void unmap_button | ( | int | bnum | ) | [static] |
Definition at line 575 of file graphics.c.
00576 { 00577 00578 /* Unmaps a button from the screen. */ 00579 00580 XUnmapWindow(display, button[bnum].win); 00581 }
void update_message | ( | char * | msg | ) |
Definition at line 1659 of file graphics.c.
01660 { 01661 01662 /* Changes the message to be displayed on screen. */ 01663 01664 my_strncpy(message, msg, BUFSIZE); 01665 draw_message(); 01666 }
static void update_ps_transform | ( | void | ) | [static] |
Definition at line 1077 of file graphics.c.
01078 { 01079 01080 /* Postscript coordinates start at (0,0) for the lower left hand corner * 01081 * of the page and increase upwards and to the right. For 8.5 x 11 * 01082 * sheet, coordinates go from (0,0) to (612,792). Spacing is 1/72 inch.* 01083 * I'm leaving a minimum of half an inch (36 units) of border around * 01084 * each edge. */ 01085 01086 float ps_width, ps_height; 01087 01088 ps_width = 540.; /* 72 * 7.5 */ 01089 ps_height = 720.; /* 72 * 10 */ 01090 01091 ps_xmult = ps_width / (xright - xleft); 01092 ps_ymult = ps_height / (ytop - ybot); 01093 /* Need to use same scaling factor to preserve aspect ratio. * 01094 * I show exactly as much on paper as the screen window shows, * 01095 * or the user specifies. */ 01096 if(fabs(ps_xmult) <= fabs(ps_ymult)) 01097 { 01098 ps_left = 36.; 01099 ps_right = 36. + ps_width; 01100 ps_bot = 396. - fabs(ps_xmult * (ytop - ybot)) / 2.; 01101 ps_top = 396. + fabs(ps_xmult * (ytop - ybot)) / 2.; 01102 /* Maintain aspect ratio but watch signs */ 01103 ps_ymult = (ps_xmult * ps_ymult < 0) ? -ps_xmult : ps_xmult; 01104 } 01105 else 01106 { 01107 ps_bot = 36.; 01108 ps_top = 36. + ps_height; 01109 ps_left = 306. - fabs(ps_ymult * (xright - xleft)) / 2.; 01110 ps_right = 306. + fabs(ps_ymult * (xright - xleft)) / 2.; 01111 /* Maintain aspect ratio but watch signs */ 01112 ps_xmult = (ps_xmult * ps_ymult < 0) ? -ps_ymult : ps_ymult; 01113 } 01114 }
static void update_transform | ( | void | ) | [static] |
Definition at line 1043 of file graphics.c.
01044 { 01045 01046 /* Set up the factors for transforming from the user world to X Windows * 01047 * coordinates. */ 01048 01049 float mult, y1, y2, x1, x2; 01050 01051 /* X Window coordinates go from (0,0) to (width-1,height-1) */ 01052 xmult = ((float)top_width - 1. - MWIDTH) / (xright - xleft); 01053 ymult = ((float)top_height - 1. - T_AREA_HEIGHT) / (ybot - ytop); 01054 /* Need to use same scaling factor to preserve aspect ratio */ 01055 if(fabs(xmult) <= fabs(ymult)) 01056 { 01057 mult = fabs(ymult / xmult); 01058 y1 = ytop - (ybot - ytop) * (mult - 1.) / 2.; 01059 y2 = ybot + (ybot - ytop) * (mult - 1.) / 2.; 01060 ytop = y1; 01061 ybot = y2; 01062 } 01063 else 01064 { 01065 mult = fabs(xmult / ymult); 01066 x1 = xleft - (xright - xleft) * (mult - 1.) / 2.; 01067 x2 = xright + (xright - xleft) * (mult - 1.) / 2.; 01068 xleft = x1; 01069 xright = x2; 01070 } 01071 xmult = ((float)top_width - 1. - MWIDTH) / (xright - xleft); 01072 ymult = ((float)top_height - 1. - T_AREA_HEIGHT) / (ybot - ytop); 01073 }
static void update_win | ( | int | x[2], | |
int | y[2], | |||
void(*)(void) | drawscreen | |||
) | [static] |
Definition at line 1791 of file graphics.c.
01794 { 01795 float x1, x2, y1, y2; 01796 01797 x[0] = min(x[0], top_width - MWIDTH); /* Can't go under menu */ 01798 x[1] = min(x[1], top_width - MWIDTH); 01799 y[0] = min(y[0], top_height - T_AREA_HEIGHT); /* Can't go under text area */ 01800 y[1] = min(y[1], top_height - T_AREA_HEIGHT); 01801 01802 if((x[0] == x[1]) || (y[0] == y[1])) 01803 { 01804 printf("Illegal (zero area) window. Window unchanged.\n"); 01805 return; 01806 } 01807 x1 = XTOWORLD(min(x[0], x[1])); 01808 x2 = XTOWORLD(max(x[0], x[1])); 01809 y1 = YTOWORLD(min(y[0], y[1])); 01810 y2 = YTOWORLD(max(y[0], y[1])); 01811 xleft = x1; 01812 xright = x2; 01813 ytop = y1; 01814 ybot = y2; 01815 update_transform(); 01816 drawscreen(); 01817 }
static int which_button | ( | Window | win | ) | [static] |
Definition at line 1016 of file graphics.c.
01017 { 01018 int i; 01019 01020 for(i = 0; i < num_buttons; i++) 01021 { 01022 if(button[i].win == win) 01023 return (i); 01024 } 01025 printf("Error: Unknown button ID in which_button.\n"); 01026 return (0); 01027 }
static int xcoord | ( | float | worldx | ) | [static] |
Definition at line 189 of file graphics.c.
00190 { 00191 /* Translates from my internal coordinates to X Windows coordinates * 00192 * in the x direction. Add 0.5 at end for extra half-pixel accuracy. */ 00193 00194 int winx; 00195 00196 winx = (int)((worldx - xleft) * xmult + 0.5); 00197 00198 /* Avoid overflow in the X Window routines. This will allow horizontal * 00199 * and vertical lines to be drawn correctly regardless of zooming, but * 00200 * will cause diagonal lines that go way off screen to change their * 00201 * slope as you zoom in. The only way I can think of to completely fix * 00202 * this problem is to do all the clipping in advance in floating point, * 00203 * then convert to integers and call X Windows. This is a lot of extra * 00204 * coding, and means that coordinates will be clipped twice, even though * 00205 * this "Super Zoom" problem won't occur unless users zoom way in on * 00206 * the graphics. */ 00207 00208 winx = max(winx, MINPIXEL); 00209 winx = min(winx, MAXPIXEL); 00210 00211 return (winx); 00212 }
static int ycoord | ( | float | worldy | ) | [static] |
Definition at line 216 of file graphics.c.
00217 { 00218 /* Translates from my internal coordinates to X Windows coordinates * 00219 * in the y direction. Add 0.5 at end for extra half-pixel accuracy. */ 00220 00221 int winy; 00222 00223 winy = (int)((worldy - ytop) * ymult + 0.5); 00224 00225 /* Avoid overflow in the X Window routines. */ 00226 winy = max(winy, MINPIXEL); 00227 winy = min(winy, MAXPIXEL); 00228 00229 return (winy); 00230 }
static void zoom_fit | ( | void(*)(void) | drawscreen | ) | [static] |
Definition at line 1710 of file graphics.c.
01711 { 01712 01713 /* Sets the view back to the initial view set by init_world (i.e. a full * 01714 * view) of all the graphics. */ 01715 01716 xleft = saved_xleft; 01717 xright = saved_xright; 01718 ytop = saved_ytop; 01719 ybot = saved_ybot; 01720 01721 update_transform(); 01722 drawscreen(); 01723 }
static void zoom_in | ( | void(*)(void) | drawscreen | ) | [static] |
Definition at line 1670 of file graphics.c.
01671 { 01672 01673 /* Zooms in by a factor of 1.666. */ 01674 01675 float xdiff, ydiff; 01676 01677 xdiff = xright - xleft; 01678 ydiff = ybot - ytop; 01679 xleft += xdiff / 5.; 01680 xright -= xdiff / 5.; 01681 ytop += ydiff / 5.; 01682 ybot -= ydiff / 5.; 01683 01684 update_transform(); 01685 drawscreen(); 01686 }
static void zoom_out | ( | void(*)(void) | drawscreen | ) | [static] |
Definition at line 1690 of file graphics.c.
01691 { 01692 01693 /* Zooms out by a factor of 1.666. */ 01694 01695 float xdiff, ydiff; 01696 01697 xdiff = xright - xleft; 01698 ydiff = ybot - ytop; 01699 xleft -= xdiff / 3.; 01700 xright += xdiff / 3.; 01701 ytop -= ydiff / 3.; 01702 ybot += ydiff / 3.; 01703 01704 update_transform(); 01705 drawscreen(); 01706 }
Definition at line 117 of file graphics.c.
int colors[NUM_COLOR] [static] |
Definition at line 149 of file graphics.c.
int currentcolor = BLACK [static] |
Definition at line 141 of file graphics.c.
int currentfontsize = 10 [static] |
Definition at line 144 of file graphics.c.
int currentlinestyle = SOLID [static] |
Definition at line 142 of file graphics.c.
int currentlinewidth = 0 [static] |
Definition at line 143 of file graphics.c.
int disp_type [static] |
Definition at line 120 of file graphics.c.
Display* display [static] |
Definition at line 121 of file graphics.c.
unsigned int display_height [static] |
Definition at line 126 of file graphics.c.
unsigned int display_width [static] |
Definition at line 126 of file graphics.c.
XFontStruct* font_info[MAX_FONT_SIZE+1] [static] |
Definition at line 124 of file graphics.c.
int font_is_loaded[MAX_FONT_SIZE+1] [static] |
Definition at line 125 of file graphics.c.
GC gc [static] |
Definition at line 123 of file graphics.c.
GC gc_menus [static] |
Definition at line 123 of file graphics.c.
GC gcxor [static] |
Definition at line 123 of file graphics.c.
Window menu [static] |
Definition at line 128 of file graphics.c.
const int menu_font_size = 14 [static] |
Definition at line 115 of file graphics.c.
char message[BUFSIZE] = "\0" [static] |
Definition at line 146 of file graphics.c.
int num_buttons [static] |
Definition at line 118 of file graphics.c.
Colormap private_cmap [static] |
Definition at line 138 of file graphics.c.
FILE* ps [static] |
Definition at line 152 of file graphics.c.
float ps_bot [static] |
Definition at line 134 of file graphics.c.
float ps_left [static] |
Definition at line 134 of file graphics.c.
float ps_right [static] |
Definition at line 134 of file graphics.c.
float ps_top [static] |
Definition at line 134 of file graphics.c.
float ps_xmult [static] |
Definition at line 136 of file graphics.c.
float ps_ymult [static] |
Definition at line 136 of file graphics.c.
float saved_xleft [static] |
Definition at line 132 of file graphics.c.
float saved_xright [static] |
Definition at line 132 of file graphics.c.
float saved_ybot [static] |
Definition at line 132 of file graphics.c.
float saved_ytop [static] |
Definition at line 132 of file graphics.c.
int screen_num [static] |
Definition at line 122 of file graphics.c.
Window textarea [static] |
Definition at line 128 of file graphics.c.
unsigned int top_height [static] |
Definition at line 127 of file graphics.c.
unsigned int top_width [static] |
Definition at line 127 of file graphics.c.
Window toplevel [static] |
Definition at line 128 of file graphics.c.
float xleft [static] |
Definition at line 129 of file graphics.c.
float xmult [static] |
Definition at line 137 of file graphics.c.
float xright [static] |
Definition at line 129 of file graphics.c.
float ybot [static] |
Definition at line 129 of file graphics.c.
float ymult [static] |
Definition at line 137 of file graphics.c.
float ytop [static] |
Definition at line 129 of file graphics.c.