diff options
author | Ruben Undheim <ruben.undheim@gmail.com> | 2018-07-12 22:31:02 +0200 |
---|---|---|
committer | Ruben Undheim <ruben.undheim@gmail.com> | 2018-07-12 22:31:02 +0200 |
commit | 178038ed02d94aaeb341792cce5e3d8f6767e0a5 (patch) | |
tree | 12a24a9583adaf2c581866018998d2f43c861e49 /graphics.c | |
parent | 1fdeebded00f8f9c13229dcf48aca690513c7b00 (diff) |
Imported 1.3.103
Diffstat (limited to 'graphics.c')
-rw-r--r-- | graphics.c | 49 |
1 files changed, 47 insertions, 2 deletions
@@ -32,7 +32,7 @@ static void createGC(Window, GC *, XFontStruct *); XFontStruct *font_info; Pixmap buffer = (Pixmap)0; -Display *dpy; +Display *dpy = NULL; Window win; Colormap cmap; GC gc; @@ -44,6 +44,7 @@ Dimension width, height; int spacing; int bluepix, greenpix, redpix, cyanpix, orangepix, goldpix; int blackpix, whitepix, graypix, ltgraypix, yellowpix; +int tealpix, mauvepix, tanpix; int magentapix, purplepix, greenyellowpix; int brownvector[SHORTSPAN]; int bluevector[LONGSPAN]; @@ -58,6 +59,8 @@ void highlight(int x, int y) { int i, xspc, yspc, hspc; PROUTE *Pr; + if (dpy == NULL) return; + // If Obs2[] at x, y is a source or dest, don't highlight // Do this only for layer 0; it doesn't have to be rigorous. for (i = 0; i < Num_layers; i++) { @@ -86,6 +89,8 @@ void highlight_source() { int i, x, y; PROUTE *Pr; + if (dpy == NULL) return; + if (Obs2[0] == NULL) return; // Determine the number of routes per width and height, if @@ -122,6 +127,8 @@ void highlight_dest() { int i, x, y; PROUTE *Pr; + if (dpy == NULL) return; + if (Obs2[0] == NULL) return; // Determine the number of routes per width and height, if @@ -157,6 +164,8 @@ void highlight_starts(POINT glist) { int xspc, yspc, hspc; POINT gpoint; + if (dpy == NULL) return; + // Determine the number of routes per width and height, if // it has not yet been computed @@ -185,6 +194,8 @@ void highlight_mask(void) { // Determine the number of routes per width and height, if // it has not yet been computed + if (dpy == NULL) return; + hspc = spacing >> 1; // Draw destination pins as tan squares @@ -209,6 +220,8 @@ map_obstruction() int xspc, yspc, hspc; int i, x, y; + if (dpy == NULL) return; + hspc = spacing >> 1; // Draw obstructions as light gray squares @@ -254,6 +267,8 @@ map_congestion() u_char *Congestion; u_char value, maxval; + if (dpy == NULL) return; + hspc = spacing >> 1; Congestion = (u_char *)calloc(NumChannelsX[0] * NumChannelsY[0], @@ -309,6 +324,8 @@ map_estimate() int i, x, y, nwidth, nheight, area, length, value; float density, *Congestion, norm, maxval; + if (dpy == NULL) return; + hspc = spacing >> 1; Congestion = (float *)calloc(NumChannelsX[0] * NumChannelsY[0], @@ -395,6 +412,18 @@ void draw_net(NET net, u_char single, int *lastlayer) { case 3: XSetForeground(dpy, gc, goldpix); break; + case 4: + XSetForeground(dpy, gc, orangepix); + break; + case 5: + XSetForeground(dpy, gc, tealpix); + break; + case 6: + XSetForeground(dpy, gc, mauvepix); + break; + case 7: + XSetForeground(dpy, gc, tanpix); + break; default: XSetForeground(dpy, gc, greenpix); break; @@ -431,6 +460,8 @@ draw_net_nodes(NET net) { DPOINT tap; int first, w, h, n; + if (dpy == NULL) return; + /* Compute bbox for each node and draw it */ for (node = net->netnodes, n = 0; node != NULL; node = node->next, n++) { if (bboxlist == NULL) { @@ -579,7 +610,7 @@ int GUI_init(Tcl_Interp *interp) { Tk_Window tkwind, tktop; static char *qrouterdrawdefault = ".qrouter"; - char *qrouterdrawwin; + char *qrouterdrawwin, *waitcmd; XColor cvcolor, cvexact; int i; float frac; @@ -638,6 +669,13 @@ int GUI_init(Tcl_Interp *interp) magentapix = cvcolor.pixel; XAllocNamedColor(dpy, cmap, "GreenYellow", &cvcolor, &cvexact); greenyellowpix = cvcolor.pixel; + XAllocNamedColor(dpy, cmap, "teal", &cvcolor, &cvexact); + tealpix = cvcolor.pixel; + XAllocNamedColor(dpy, cmap, "MediumVioletRed", &cvcolor, &cvexact); + mauvepix = cvcolor.pixel; + XAllocNamedColor(dpy, cmap, "tan1", &cvcolor, &cvexact); + tanpix = cvcolor.pixel; + blackpix = BlackPixel(dpy,DefaultScreen(dpy)); whitepix = WhitePixel(dpy,DefaultScreen(dpy)); @@ -666,6 +704,13 @@ int GUI_init(Tcl_Interp *interp) XAllocColor(dpy, cmap, &cvcolor); bluevector[i] = cvcolor.pixel; } + + /* Wait on window to be created */ + waitcmd = (char *)malloc(strlen(qrouterdrawwin) + 20); + sprintf(waitcmd, "tkwait visibility %s", qrouterdrawwin); + Tcl_Eval(interp, waitcmd); + free(waitcmd); + return TCL_OK; /* proceed to interpreter */ } |