BRL-CAD
dm-tk.c
Go to the documentation of this file.
1 /* D M - T K . C
2  * BRL-CAD
3  *
4  * Copyright (c) 1988-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @file libdm/dm-tk.c
21  *
22  * A Display Manager that should work wherever tk does.
23  *
24  */
25 
26 #include "common.h"
27 
28 #ifdef DM_TK
29 
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <limits.h>
33 #include <string.h>
34 
35 /* Even on a platform that has no real X, I should be able to use the
36  * Xutil that comes with Tk
37  */
38 #include <tk.h>
39 #include <X11/Xutil.h>
40 #include <X11/X.h>
41 
42 #define USE_DIALS_AND_BUTTONS 0
43 
44 #ifdef HAVE_X11_XOSDEFS_H
45 # include <X11/Xfuncproto.h>
46 # include <X11/Xosdefs.h>
47 #endif
48 #if USE_DIALS_AND_BUTTONS
49 # include <X11/extensions/XInput.h>
50 #endif
51 #if defined(linux)
52 # undef X_NOT_STDC_ENV
53 # undef X_NOT_POSIX
54 #endif
55 
56 #include "vmath.h"
57 #include "bn.h"
58 #include "raytrace.h"
59 #include "dm.h"
60 #include "dm-tk.h"
61 #include "dm-X.h"
62 #include "dm-Null.h"
63 #include "dm/dm_xvars.h"
64 #include "dm_private.h"
65 #include "solid.h"
66 
67 #define PLOTBOUND 1000.0 /* Max magnification in Rot matrix */
68 
69 static fastf_t min_short = (fastf_t)SHRT_MIN;
70 static fastf_t max_short = (fastf_t)SHRT_MAX;
71 
72 extern int vectorThreshold; /* defined in libdm/tcl.c */
73 
74 
75 /**
76  * @proc tk_close
77  *
78  * Gracefully release the display.
79  */
80 HIDDEN int
81 tk_close(struct dm_internal *dmp)
82 {
83  if (((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy) {
84  if (((struct x_vars *)dmp->dm_vars.priv_vars)->gc)
85  Tk_FreeGC(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
86  ((struct x_vars *)dmp->dm_vars.priv_vars)->gc);
87 
88  if (((struct x_vars *)dmp->dm_vars.priv_vars)->pix)
89  Tk_FreePixmap(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
90  ((struct x_vars *)dmp->dm_vars.priv_vars)->pix);
91 
92  /*XXX Possibly need to free the colormap */
93  if (((struct dm_xvars *)dmp->dm_vars.pub_vars)->cmap)
94  XFreeColormap(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
95  ((struct dm_xvars *)dmp->dm_vars.pub_vars)->cmap);
96 
97  if (((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin)
98  Tk_DestroyWindow(((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin);
99 
100  }
101 
102  bu_vls_free(&dmp->dm_pathName);
103  bu_vls_free(&dmp->dm_tkName);
104  bu_vls_free(&dmp->dm_dName);
105  bu_free(dmp->dm_vars.priv_vars, "tk_close: tk_vars");
106  bu_free(dmp->dm_vars.pub_vars, "tk_close: dm_tkvars");
107  bu_free(dmp, "tk_close: dmp");
108 
109  return TCL_OK;
110 }
111 
112 
113 /**
114  * @proc tk_drawBegin
115  * This white-washes the dm's pixmap with the background color.
116  */
117 HIDDEN int
118 tk_drawBegin(struct dm_internal *dmp)
119 {
120  XGCValues gcv;
121 
122  if (dmp->dm_debugLevel)
123  bu_log("tk_drawBegin()\n");
124 
125  /* clear pixmap */
126  gcv.foreground = ((struct x_vars *)dmp->dm_vars.priv_vars)->bg;
127  XChangeGC(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
128  ((struct x_vars *)dmp->dm_vars.priv_vars)->gc,
129  GCForeground, &gcv);
130  XFillRectangle(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
131  ((struct x_vars *)dmp->dm_vars.priv_vars)->pix,
132  ((struct x_vars *)dmp->dm_vars.priv_vars)->gc, 0,
133  0, dmp->dm_width + 1,
134  dmp->dm_height + 1);
135 
136  /* reset foreground */
137 
138  gcv.foreground = ((struct x_vars *)dmp->dm_vars.priv_vars)->fg;
139  XChangeGC(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
140  ((struct x_vars *)dmp->dm_vars.priv_vars)->gc,
141  GCForeground, &gcv);
142 
143  return TCL_OK;
144 }
145 
146 
147 /**
148  * tk_drawEnd
149  * This copies the pixmap into the window.
150  */
151 HIDDEN int
152 tk_drawEnd(struct dm_internal *dmp)
153 {
154  if (dmp->dm_debugLevel)
155  bu_log("tk_drawEnd()\n");
156 
157  XCopyArea(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
158  ((struct x_vars *)dmp->dm_vars.priv_vars)->pix,
159  ((struct dm_xvars *)dmp->dm_vars.pub_vars)->win,
160  ((struct x_vars *)dmp->dm_vars.priv_vars)->gc,
161  0, 0, dmp->dm_width,
162  dmp->dm_height, 0, 0);
163 
164 
165  /* Prevent lag between events and updates */
166  XSync(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy, 0);
167 
168  return TCL_OK;
169 }
170 
171 
172 /**
173  * @proc tk_loadMatrix
174  *
175  * Load a new transformation matrix. This will be followed by
176  * many calls to tk_drawVList().
177  */
178 /* ARGSUSED */
179 HIDDEN int
180 tk_loadMatrix(struct dm_internal *dmp, fastf_t *mat, int which_eye)
181 {
182  if (dmp->dm_debugLevel) {
183  bu_log("tk_loadMatrix()\n");
184 
185  bu_log("which eye = %d\t", which_eye);
186  bu_log("transformation matrix = \n");
187 
188  bu_log("%g %g %g %g\n", mat[0], mat[1], mat[2], mat[3]);
189  bu_log("%g %g %g %g\n", mat[4], mat[5], mat[6], mat[7]);
190  bu_log("%g %g %g %g\n", mat[8], mat[9], mat[10], mat[11]);
191  bu_log("%g %g %g %g\n", mat[12], mat[13], mat[14], mat[15]);
192  }
193 
194  MAT_COPY(((struct x_vars *)dmp->dm_vars.priv_vars)->xmat, mat);
195  return TCL_OK;
196 }
197 
198 
199 /**
200  * tk_drawVList
201  *
202  */
203 
204 HIDDEN int
205 tk_drawVList(struct dm_internal *dmp, struct bn_vlist *vp)
206 {
207  static vect_t spnt, lpnt, pnt;
208  struct bn_vlist *tvp;
209  XSegment segbuf[1024]; /* XDrawSegments list */
210  XSegment *segp; /* current segment */
211  int nseg; /* number of segments */
212  fastf_t delta;
213  point_t *pt_prev = NULL;
214  fastf_t dist_prev=1.0;
215  static int nvectors = 0;
216 
217  if (dmp->dm_debugLevel) {
218  bu_log("tk_drawVList()\n");
219  bu_log("vp - %lu, perspective - %d\n", vp, dmp->dm_perspective);
220  }
221 
222  /* delta is used in clipping to insure clipped endpoint is slightly
223  * in front of eye plane (perspective mode only).
224  * This value is a SWAG that seems to work OK.
225  */
226  delta = ((struct x_vars *)dmp->dm_vars.priv_vars)->xmat[15]*0.0001;
227  if (delta < 0.0)
228  delta = -delta;
229  if (delta < SQRT_SMALL_FASTF)
230  delta = SQRT_SMALL_FASTF;
231 
232  nseg = 0;
233  segp = segbuf;
234  for (BU_LIST_FOR(tvp, bn_vlist, &vp->l)) {
235  int i;
236  int nused = tvp->nused;
237  int *cmd = tvp->cmd;
238  point_t *pt = tvp->pt;
239  fastf_t dist;
240 
241  /* Viewing region is from -1.0 to +1.0 */
242  /* 2^31 ~= 2e9 -- dynamic range of a long int */
243  /* 2^(31-11) = 2^20 ~= 1e6 */
244  /* Integerize and let the X server do the clipping */
245  for (i = 0; i < nused; i++, cmd++, pt++) {
246  switch (*cmd) {
247  case BN_VLIST_POLY_START:
249  case BN_VLIST_TRI_START:
251  continue;
252  case BN_VLIST_POLY_MOVE:
253  case BN_VLIST_LINE_MOVE:
254  case BN_VLIST_TRI_MOVE:
255  /* Move, not draw */
256  if (dmp->dm_debugLevel > 2) {
257  bu_log("before transformation:\n");
258  bu_log("pt - %lf %lf %lf\n", V3ARGS(*pt));
259  }
260 
261  if (dmp->dm_perspective > 0) {
262  /* cannot apply perspective transformation to
263  * points behind eye plane!!!!
264  */
265  dist = VDOT(*pt, &((struct x_vars *)dmp->dm_vars.priv_vars)->xmat[12]) + ((struct x_vars *)dmp->dm_vars.priv_vars)->xmat[15];
266  if (dist <= 0.0) {
267  pt_prev = pt;
268  dist_prev = dist;
269  continue;
270  } else {
271  MAT4X3PNT(lpnt, ((struct x_vars *)dmp->dm_vars.priv_vars)->xmat, *pt);
272  dist_prev = dist;
273  pt_prev = pt;
274  }
275  } else {
276  MAT4X3PNT(lpnt, ((struct x_vars *)dmp->dm_vars.priv_vars)->xmat, *pt);
277  }
278 
279  lpnt[0] *= 2047;
280  lpnt[1] *= 2047 * dmp->dm_aspect;
281  lpnt[2] *= 2047;
282  continue;
283  case BN_VLIST_POLY_DRAW:
284  case BN_VLIST_POLY_END:
285  case BN_VLIST_LINE_DRAW:
286  case BN_VLIST_TRI_DRAW:
287  case BN_VLIST_TRI_END:
288  /* draw */
289  if (dmp->dm_debugLevel > 2) {
290  bu_log("before transformation:\n");
291  bu_log("pt - %lf %lf %lf\n", V3ARGS(*pt));
292  }
293 
294  if (dmp->dm_perspective > 0) {
295  /* cannot apply perspective transformation to
296  * points behind eye plane!!!!
297  */
298  dist = VDOT(*pt, &((struct x_vars *)dmp->dm_vars.priv_vars)->xmat[12]) + ((struct x_vars *)dmp->dm_vars.priv_vars)->xmat[15];
299  if (dmp->dm_debugLevel > 2)
300  bu_log("dist=%g, dist_prev=%g\n", dist, dist_prev);
301  if (dist <= 0.0) {
302  if (dist_prev <= 0.0) {
303  /* nothing to plot */
304  dist_prev = dist;
305  pt_prev = pt;
306  continue;
307  } else {
308  if (pt_prev) {
309  fastf_t alpha;
310  vect_t diff;
311  point_t tmp_pt;
312 
313  /* clip this end */
314  VSUB2(diff, *pt, *pt_prev);
315  alpha = (dist_prev - delta) / (dist_prev - dist);
316  VJOIN1(tmp_pt, *pt_prev, alpha, diff);
317  MAT4X3PNT(pnt, ((struct x_vars *)dmp->dm_vars.priv_vars)->xmat, tmp_pt);
318  }
319  }
320  } else {
321  if (dist_prev <= 0.0) {
322  if (pt_prev) {
323  fastf_t alpha;
324  vect_t diff;
325  point_t tmp_pt;
326 
327  /* clip other end */
328  VSUB2(diff, *pt, *pt_prev);
329  alpha = (-dist_prev + delta) / (dist - dist_prev);
330  VJOIN1(tmp_pt, *pt_prev, alpha, diff);
331  MAT4X3PNT(lpnt, ((struct x_vars *)dmp->dm_vars.priv_vars)->xmat, tmp_pt);
332  lpnt[0] *= 2047;
333  lpnt[1] *= 2047 * dmp->dm_aspect;
334  lpnt[2] *= 2047;
335  MAT4X3PNT(pnt, ((struct x_vars *)dmp->dm_vars.priv_vars)->xmat, *pt);
336  }
337  } else {
338  MAT4X3PNT(pnt, ((struct x_vars *)dmp->dm_vars.priv_vars)->xmat, *pt);
339  }
340  }
341  dist_prev = dist;
342  } else {
343  MAT4X3PNT(pnt, ((struct x_vars *)dmp->dm_vars.priv_vars)->xmat, *pt);
344  }
345 
346  pnt[0] *= 2047;
347  pnt[1] *= 2047 * dmp->dm_aspect;
348  pnt[2] *= 2047;
349 
350  /* save pnt --- it might get changed by clip() */
351  VMOVE(spnt, pnt);
352  pt_prev = pt;
353 
354  if (dmp->dm_debugLevel > 2) {
355  bu_log("before clipping:\n");
356  bu_log("clipmin - %lf %lf %lf\n",
357  dmp->dm_clipmin[X],
358  dmp->dm_clipmin[Y],
359  dmp->dm_clipmin[Z]);
360  bu_log("clipmax - %lf %lf %lf\n",
361  dmp->dm_clipmax[X],
362  dmp->dm_clipmax[Y],
363  dmp->dm_clipmax[Z]);
364  bu_log("pt1 - %lf %lf %lf\n", lpnt[X], lpnt[Y], lpnt[Z]);
365  bu_log("pt2 - %lf %lf %lf\n", pnt[X], pnt[Y], pnt[Z]);
366  }
367 
368  if (dmp->dm_zclip) {
369  if (vclip(lpnt, pnt,
370  dmp->dm_clipmin,
371  dmp->dm_clipmax) == 0) {
372  VMOVE(lpnt, spnt);
373  continue;
374  }
375  } else {
376  /* Check to see if lpnt or pnt contain values that exceed
377  the capacity of a short (segbuf is an array of XSegments which
378  contain shorts). If so, do clipping now. Otherwise, let the
379  X server do the clipping */
380  if (lpnt[0] < min_short || max_short < lpnt[0] ||
381  lpnt[1] < min_short || max_short < lpnt[1] ||
382  pnt[0] < min_short || max_short < pnt[0] ||
383  pnt[1] < min_short || max_short < pnt[1]) {
384  /* if the entire line segment will not be visible then ignore it */
385  if (clip(&lpnt[0], &lpnt[1], &pnt[0], &pnt[1]) == -1) {
386  VMOVE(lpnt, spnt);
387  continue;
388  }
389  }
390  }
391 
392  if (dmp->dm_debugLevel > 2) {
393  bu_log("after clipping:\n");
394  bu_log("pt1 - %lf %lf %lf\n", lpnt[X], lpnt[Y], lpnt[Z]);
395  bu_log("pt2 - %lf %lf %lf\n", pnt[X], pnt[Y], pnt[Z]);
396  }
397 
398  /* convert to X window coordinates */
399  segp->x1 = (short)GED_TO_Xx(dmp, lpnt[0]);
400  segp->y1 = (short)GED_TO_Xy(dmp, lpnt[1]);
401  segp->x2 = (short)GED_TO_Xx(dmp, pnt[0]);
402  segp->y2 = (short)GED_TO_Xy(dmp, pnt[1]);
403 
404  nseg++;
405  segp++;
406  VMOVE(lpnt, spnt);
407 
408  if (nseg == 1024) {
409  XDrawSegments(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
410  ((struct x_vars *)dmp->dm_vars.priv_vars)->pix,
411  ((struct x_vars *)dmp->dm_vars.priv_vars)->gc, segbuf, nseg);
412 
413  nseg = 0;
414  segp = segbuf;
415  }
416  break;
417  }
418  }
419 
420  nvectors += nused;
421  if (nvectors >= vectorThreshold) {
422  if (dmp->dm_debugLevel)
423  bu_log("tk_drawVList(): handle Tcl events\n");
424 
425  nvectors = 0;
426 
427  /* Handle events in the queue */
428  while (Tcl_DoOneEvent(TCL_ALL_EVENTS|TCL_DONT_WAIT));
429  }
430  }
431 
432  if (nseg) {
433  XDrawSegments(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
434  ((struct x_vars *)dmp->dm_vars.priv_vars)->pix,
435  ((struct x_vars *)dmp->dm_vars.priv_vars)->gc, segbuf, nseg);
436  }
437 
438  return TCL_OK;
439 }
440 
441 
442 int
443 tk_draw(struct dm_internal *dmp, struct bn_vlist *(*callback_function)(void *), void **data)
444 {
445  struct bn_vlist *vp;
446  if (!callback_function) {
447  if (data) {
448  vp = (struct bn_vlist *)data;
449  tk_drawVList(dmp, vp);
450  }
451  } else {
452  if (!data) {
453  return TCL_ERROR;
454  } else {
455  (void)callback_function(data);
456  }
457  }
458  return TCL_OK;
459 }
460 
461 
462 /*
463  * Restore the display processor to a normal mode of operation
464  * (i.e., not scaled, rotated, displaced, etc.).
465  */
466 HIDDEN int
467 tk_normal(struct dm_internal *dmp)
468 {
469  if (dmp->dm_debugLevel)
470  bu_log("tk_normal()\n");
471 
472  return TCL_OK;
473 }
474 
475 
476 /*
477  * Output a string into the displaylist.
478  * The starting position of the beam is as specified.
479  */
480 /* ARGSUSED */
481 HIDDEN int
482 tk_drawString2D(struct dm_internal *dmp, const char *str, fastf_t x, fastf_t y, int size, int use_aspect)
483 {
484  int sx, sy;
485 
486  if (dmp->dm_debugLevel) {
487  bu_log("tk_drawString2D():\n");
488  bu_log("\tstr - %s\n", str);
489  bu_log("\tx - %g\n", x);
490  bu_log("\ty - %g\n", y);
491  bu_log("\tsize - %d\n", size);
492 
493  bu_log("color = %lu\n", ((struct x_vars *)dmp->dm_vars.priv_vars)->fg);
494  /* bu_log("real_color = %d\n", ((struct x_vars *)dmp->dm_vars.priv_vars)->gc->foreground); */
495 
496  if (use_aspect) {
497  bu_log("\tuse_aspect - %d\t\taspect ratio - %g\n", use_aspect, dmp->dm_aspect);
498  } else
499  bu_log("\tuse_aspect - 0");
500  }
501 
502  sx = dm_Normal2Xx(dmp, x);
503  sy = dm_Normal2Xy(dmp, y, use_aspect);
504 
505 
506  Tk_DrawChars(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
507  ((struct x_vars *)dmp->dm_vars.priv_vars)->pix,
508  ((struct x_vars *)dmp->dm_vars.priv_vars)->gc,
509  ((struct dm_xvars *)dmp->dm_vars.pub_vars)->tkfontstruct,
510  str, strlen(str), sx, sy);
511 
512  return TCL_OK;
513 }
514 
515 
516 HIDDEN int
517 tk_drawLine2D(struct dm_internal *dmp, fastf_t xpos1, fastf_t ypos1, fastf_t xpos2, fastf_t ypos2)
518 {
519  int sx1, sy1, sx2, sy2;
520 
521  sx1 = dm_Normal2Xx(dmp, xpos1);
522  sx2 = dm_Normal2Xx(dmp, xpos2);
523  sy1 = dm_Normal2Xy(dmp, ypos1, 0);
524  sy2 = dm_Normal2Xy(dmp, ypos2, 0);
525 
526  if (dmp->dm_debugLevel) {
527  bu_log("tk_drawLine2D()\n");
528  bu_log("x1 = %g, y1 = %g\n", xpos1, ypos1);
529  bu_log("x2 = %g, y2 = %g\n", xpos2, ypos2);
530  bu_log("sx1 = %d, sy1 = %d\n", sx1, sy1);
531  bu_log("sx2 = %d, sy2 = %d\n", sx2, sy2);
532  bu_log("color = %lu\n", ((struct x_vars *)dmp->dm_vars.priv_vars)->fg);
533  }
534 
535  XDrawLine(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
536  ((struct x_vars *)dmp->dm_vars.priv_vars)->pix,
537  ((struct x_vars *)dmp->dm_vars.priv_vars)->gc,
538  sx1, sy1, sx2, sy2);
539 
540  return TCL_OK;
541 }
542 
543 
544 HIDDEN int
545 tk_drawLine3D(struct dm_internal *dmp, point_t UNUSED(pt1), point_t UNUSED(pt2))
546 {
547  if (!dmp)
548  return TCL_ERROR;
549 
550  return TCL_OK;
551 }
552 
553 
554 HIDDEN int
555 tk_drawLines3D(struct dm_internal *dmp, int npoints, point_t *points, int UNUSED(sflag))
556 {
557  if (!dmp || npoints < 0 || (npoints > 0 && !points))
558  return TCL_ERROR;
559 
560  return TCL_OK;
561 }
562 
563 
564 HIDDEN int
565 tk_drawPoint2D(struct dm_internal *dmp, fastf_t x, fastf_t y)
566 {
567  int sx, sy;
568 
569  sx = dm_Normal2Xx(dmp, x);
570  sy = dm_Normal2Xy(dmp, y, 0);
571 
572  if (dmp->dm_debugLevel) {
573  bu_log("tk_drawPoint2D()\n");
574  bu_log("x = %g, y = %g\n", x, y);
575  bu_log("sx = %d, sy = %d\n", sx, sy);
576  }
577 
578  XDrawPoint(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
579  ((struct x_vars *)dmp->dm_vars.priv_vars)->pix,
580  ((struct x_vars *)dmp->dm_vars.priv_vars)->gc, sx, sy);
581 
582  return TCL_OK;
583 }
584 
585 
586 HIDDEN int
587 tk_setFGColor(struct dm_internal *dmp, unsigned char r, unsigned char g, unsigned char b, int strict, fastf_t transparency)
588 {
589  XColor color;
590 
591  INIT_XCOLOR(&color);
592 
593  if (!dmp) {
594  bu_log("WARNING: NULL display (r/g/b => %d/%d/%d; strict => %d; transparency => %f)\n", r, g, b, strict, transparency);
595  return TCL_ERROR;
596  }
597 
598  if (dmp->dm_debugLevel)
599  bu_log("tk_setFGColor(%d %d %d)\n", r, g, b);
600 
601  dmp->dm_fg[0] = r;
602  dmp->dm_fg[1] = g;
603  dmp->dm_fg[2] = b;
604 
605  color.red = r << 8;
606  color.green = g << 8;
607  color.blue = b << 8;
608 
609  ((struct x_vars *)dmp->dm_vars.priv_vars)->fg = Tk_GetColorByValue
610  (((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin, &color)->pixel;
611 
612  XSetForeground(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
613  ((struct x_vars *)dmp->dm_vars.priv_vars)->gc,
614  ((struct x_vars *)dmp->dm_vars.priv_vars)->fg);
615 
616  return TCL_OK;
617 }
618 
619 
620 HIDDEN int
621 tk_setBGColor(struct dm_internal *dmp, unsigned char r, unsigned char g, unsigned char b)
622 {
623  XColor color;
624 
625  INIT_XCOLOR(&color);
626 
627  if (!dmp) {
628  bu_log("WARNING: NULL display (r/g/b==%d/%d/%d)\n", r, g, b);
629  return TCL_ERROR;
630  }
631 
632  if (dmp->dm_debugLevel)
633  bu_log("tk_setBGColor()\n");
634 
635  dmp->dm_bg[0] = r;
636  dmp->dm_bg[1] = g;
637  dmp->dm_bg[2] = b;
638 
639  color.red = r << 8;
640  color.green = g << 8;
641  color.blue = b << 8;
642 
643  XSetBackground(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
644  ((struct x_vars *)dmp->dm_vars.priv_vars)->gc,
645  Tk_GetColorByValue(((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin,
646  &color)->pixel);
647 
648  return TCL_OK;
649 }
650 
651 
652 HIDDEN int
653 tk_setLineAttr(struct dm_internal *dmp, int width, int style)
654 {
655  int linestyle;
656 
657  if (dmp->dm_debugLevel)
658  bu_log("tk_setLineAttr(width: %d, style: %d)\n", width, style);
659 
660  dmp->dm_lineWidth = width;
661  dmp->dm_lineStyle = style;
662 
663  if (width < 1)
664  width = 1;
665 
666  if (style == DM_DASHED_LINE)
667  linestyle = LineOnOffDash;
668  else
669  linestyle = LineSolid;
670 
671  XSetLineAttributes(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
672  ((struct x_vars *)dmp->dm_vars.priv_vars)->gc,
673  width, linestyle, CapButt, JoinMiter);
674 
675  return TCL_OK;
676 }
677 
678 
679 /* ARGSUSED */
680 HIDDEN int
681 tk_debug(struct dm_internal *dmp, int lvl)
682 {
683  dmp->dm_debugLevel = lvl;
684 
685  return TCL_OK;
686 }
687 
688 HIDDEN int
689 tk_logfile(struct dm_internal *dmp, const char *filename)
690 {
691  bu_vls_sprintf(&dmp->dm_log, "%s", filename);
692 
693  return TCL_OK;
694 }
695 
696 
697 
698 HIDDEN int
699 tk_setWinBounds(struct dm_internal *dmp, fastf_t *w)
700 {
701  if (dmp->dm_debugLevel)
702  bu_log("tk_setWinBounds()\n");
703 
704  dmp->dm_clipmin[0] = w[0];
705  dmp->dm_clipmin[1] = w[2];
706  dmp->dm_clipmin[2] = w[4];
707  dmp->dm_clipmax[0] = w[1];
708  dmp->dm_clipmax[1] = w[3];
709  dmp->dm_clipmax[2] = w[5];
710 
711  return TCL_OK;
712 }
713 
714 
715 HIDDEN int
716 tk_configureWin_guts(struct dm_internal *dmp, int force)
717 {
718  int h, w;
719 
720  /* nothing to do */
721  h = Tk_Height(((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin);
722  w = Tk_Width(((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin);
723 
724  if (!force && dmp->dm_width==w && dmp->dm_height == h)
725  return TCL_OK;
726 
727  dmp->dm_width=w;
728  dmp->dm_width=h;
729 
730  dmp->dm_aspect = (fastf_t)dmp->dm_width / (fastf_t)dmp->dm_height;
731 
732  if (dmp->dm_debugLevel) {
733  bu_log("tk_configureWin_guts()\n");
734  bu_log("width = %d, height = %d\n", dmp->dm_width, dmp->dm_height);
735  }
736 
737  Tk_FreePixmap(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
738  ((struct x_vars *)dmp->dm_vars.priv_vars)->pix);
739  ((struct x_vars *)dmp->dm_vars.priv_vars)->pix =
740  Tk_GetPixmap(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
741  DefaultRootWindow(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy),
742  dmp->dm_width,
743  dmp->dm_height,
744  Tk_Depth(((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin));
745 
746  /* First time through, load a font or quit */
747  if (((struct dm_xvars *)dmp->dm_vars.pub_vars)->tkfontset == 0) {
748 
749  ((struct dm_xvars *)dmp->dm_vars.pub_vars)->tkfontstruct =
750  Tk_GetFont(dmp->dm_interp, ((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin, FONT9);
751 
752  if (((struct dm_xvars *)dmp->dm_vars.pub_vars)->tkfontstruct == NULL) {
753  /* Try hardcoded backup font */
754 
755  ((struct dm_xvars *)dmp->dm_vars.pub_vars)->tkfontstruct =
756  Tk_GetFont(dmp->dm_interp, ((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin, FONTBACK);
757 
758  if (((struct dm_xvars *)dmp->dm_vars.pub_vars)->tkfontstruct == NULL) {
759  bu_log("dm-Tk: Can't open font '%s' or '%s'\n", FONT9, FONTBACK);
760  return TCL_ERROR;
761  }
762  }
763  ((struct dm_xvars *)dmp->dm_vars.pub_vars)->tkfontset = 1;
764  }
765 
766  /* XXX: I removed the font-sizing routine from dm-X from here. Something
767  should be devised to replace it. --TJM*/
768 
769  return TCL_OK;
770 }
771 
772 
773 HIDDEN int
774 tk_configureWin(struct dm_internal *dmp, int force)
775 {
776  /* don't force */
777  return tk_configureWin_guts(dmp, force);
778 }
779 
780 
781 HIDDEN int
782 tk_setLight(struct dm_internal *dmp, int light_on)
783 {
784  if (dmp->dm_debugLevel)
785  bu_log("tk_setLight:\n");
786 
787  dmp->dm_light = light_on;
788 
789  return TCL_OK;
790 }
791 
792 
793 HIDDEN int
794 tk_setZBuffer(struct dm_internal *dmp, int zbuffer_on)
795 {
796  if (dmp->dm_debugLevel)
797  bu_log("tk_setZBuffer:\n");
798 
799  dmp->dm_zbuffer = zbuffer_on;
800 
801  return TCL_OK;
802 }
803 
804 struct bu_structparse Tk_vparse[] = {
805  {"%g", 1, "bound", DM_O(dm_bound), dm_generic_hook, NULL, NULL},
806  {"%d", 1, "useBound", DM_O(dm_boundFlag), dm_generic_hook, NULL, NULL},
807  {"%d", 1, "zclip", DM_O(dm_zclip), dm_generic_hook, NULL, NULL},
808  {"%d", 1, "debug", DM_O(dm_debugLevel), dm_generic_hook, NULL, NULL},
809  {"", 0, (char *)0, 0, BU_STRUCTPARSE_FUNC_NULL, NULL, NULL}
810 };
811 
812 struct dm_internal dm_tk = {
813  tk_close,
814  tk_drawBegin,
815  tk_drawEnd,
816  tk_normal,
817  tk_loadMatrix,
819  tk_drawString2D,
820  tk_drawLine2D,
821  tk_drawLine3D,
822  tk_drawLines3D,
823  tk_drawPoint2D,
826  tk_drawVList,
827  tk_drawVList,
828  tk_draw,
829  tk_setFGColor,
830  tk_setBGColor,
831  tk_setLineAttr,
832  tk_configureWin,
833  tk_setWinBounds,
834  tk_setLight,
837  tk_setZBuffer,
838  tk_debug,
839  tk_logfile,
845  NULL,
846  null_getDisplayImage, /* display to image function */
847  null_reshape,
849  null_openFb,
850  NULL,
851  NULL,
852  0,
853  0, /* no displaylist */
854  0, /* no stereo */
855  PLOTBOUND, /* zoom-in limit */
856  1, /* bound flag */
857  "Tk",
858  "Tk Abstraction Layer",
859  DM_TYPE_TK,
860  1,
861  0,
862  0,
863  0, /* bytes per pixel */
864  0, /* bits per channel */
865  0,
866  0,
867  1.0, /* aspect ratio */
868  0,
869  {0, 0},
870  NULL,
871  NULL,
872  BU_VLS_INIT_ZERO, /* bu_vls path name*/
873  BU_VLS_INIT_ZERO, /* bu_vls full name drawing window */
874  BU_VLS_INIT_ZERO, /* bu_vls short name drawing window */
875  {0, 0, 0}, /* bg color */
876  {0, 0, 0}, /* fg color */
877  {GED_MIN, GED_MIN, GED_MIN}, /* clipmin */
878  {GED_MAX, GED_MAX, GED_MAX}, /* clipmax */
879  0, /* no debugging */
880  BU_VLS_INIT_ZERO, /* bu_vls logfile */
881  0, /* no perspective */
882  0, /* no lighting */
883  0, /* no transparency */
884  0, /* depth buffer is not writable */
885  0, /* no zbuffer */
886  0, /* no zclipping */
887  1, /* clear back buffer after drawing and swap */
888  0, /* not overriding the auto font size */
889  Tk_vparse,
890  FB_NULL,
891  0 /* Tcl interpreter */
892 };
893 
894 
895 struct dm_internal *tk_open_dm(Tcl_Interp *interp, int argc, char **argv);
896 
897 /* Display Manager package interface */
898 
899 
900 /*
901  * Fire up the display manager, and the display processor.
902  *
903  */
904 struct dm_internal *
905 tk_open_dm(Tcl_Interp *interp, int argc, char **argv)
906 {
907  static int count = 0;
908  int make_square = -1;
909  XGCValues gcv;
910 
911  struct bu_vls str = BU_VLS_INIT_ZERO;
912  struct bu_vls init_proc_vls = BU_VLS_INIT_ZERO;
913  struct dm_internal *dmp = (struct dm_internal *)NULL;
914  Tk_Window tkwin;
915  Display *dpy = (Display *)NULL;
916  XColor fg, bg;
917 
918  INIT_XCOLOR(&fg);
919  INIT_XCOLOR(&bg);
920 
921  if ((tkwin = Tk_MainWindow(interp)) == NULL) {
922  return DM_NULL;
923  }
924 
925  BU_ALLOC(dmp, struct dm_internal);
926 
927  *dmp = dm_tk; /* struct copy */
928  dmp->dm_interp = interp;
929 
930  BU_ALLOC(dmp->dm_vars.pub_vars, struct dm_xvars);
931  BU_ALLOC(dmp->dm_vars.priv_vars, struct tk_vars);
932 
933  bu_vls_init(&dmp->dm_pathName);
934  bu_vls_init(&dmp->dm_tkName);
935  bu_vls_init(&dmp->dm_dName);
936 
937  dm_processOptions(dmp, &init_proc_vls, --argc, ++argv);
938 
939  if (bu_vls_strlen(&dmp->dm_pathName) == 0) {
940  bu_vls_printf(&dmp->dm_pathName, ".dm_tk%d", count);
941  }
942 
943  ++count;
944  if (bu_vls_strlen(&dmp->dm_dName) == 0) {
945  char *dp;
946 
947  dp = DisplayString(Tk_Display(tkwin));
948 
949  if (dp)
950  bu_vls_strcpy(&dmp->dm_dName, dp);
951  else
952  bu_vls_strcpy(&dmp->dm_dName, ":0.0");
953  }
954  if (bu_vls_strlen(&init_proc_vls) == 0)
955  bu_vls_strcpy(&init_proc_vls, "bind_dm");
956 
957  /* initialize dm specific variables */
958  ((struct dm_xvars *)dmp->dm_vars.pub_vars)->devmotionnotify = LASTEvent;
959  ((struct dm_xvars *)dmp->dm_vars.pub_vars)->devbuttonpress = LASTEvent;
960  ((struct dm_xvars *)dmp->dm_vars.pub_vars)->devbuttonrelease = LASTEvent;
961  dmp->dm_aspect = 1.0;
962 
963  ((struct dm_xvars *)dmp->dm_vars.pub_vars)->tkfontset = 0;
964 
965  if (dmp->dm_top) {
966  /* Make xtkwin a toplevel window */
967  ((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin = Tk_CreateWindowFromPath(interp, tkwin,
968  bu_vls_addr(&dmp->dm_pathName),
969  bu_vls_addr(&dmp->dm_dName));
970  ((struct dm_xvars *)dmp->dm_vars.pub_vars)->top = ((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin;
971  } else {
972  char *cp;
973 
974  cp = strrchr(bu_vls_addr(&dmp->dm_pathName), (int)'.');
975  if (cp == bu_vls_addr(&dmp->dm_pathName)) {
976  ((struct dm_xvars *)dmp->dm_vars.pub_vars)->top = tkwin;
977  } else {
978  struct bu_vls top_vls = BU_VLS_INIT_ZERO;
979 
980  bu_vls_strncpy(&top_vls, (const char *)bu_vls_addr(&dmp->dm_pathName), cp - bu_vls_addr(&dmp->dm_pathName));
981 
982  ((struct dm_xvars *)dmp->dm_vars.pub_vars)->top =
983  Tk_NameToWindow(interp, bu_vls_addr(&top_vls), tkwin);
984  bu_vls_free(&top_vls);
985  }
986 
987  /* Make xtkwin an embedded window */
988  ((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin =
989  Tk_CreateWindow(interp, ((struct dm_xvars *)dmp->dm_vars.pub_vars)->top,
990  cp + 1, (char *)NULL);
991  }
992 
993  if (((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin == NULL) {
994  bu_log("tk_open: Failed to open %s\n", bu_vls_addr(&dmp->dm_pathName));
995  (void)tk_close(dmp);
996  return DM_NULL;
997  }
998 
999  bu_vls_printf(&dmp->dm_tkName, "%s",
1000  (char *)Tk_Name(((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin));
1001 
1002  bu_vls_printf(&str, "_init_dm %s %s\n",
1003  bu_vls_addr(&init_proc_vls),
1004  bu_vls_addr(&dmp->dm_pathName));
1005 
1006  if (Tcl_Eval(interp, bu_vls_addr(&str)) == TCL_ERROR) {
1007  bu_vls_free(&str);
1008  (void)tk_close(dmp);
1009 
1010  return DM_NULL;
1011  }
1012 
1013  bu_vls_free(&init_proc_vls);
1014  bu_vls_free(&str);
1015 
1016  ((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy =
1017  Tk_Display(((struct dm_xvars *)dmp->dm_vars.pub_vars)->top);
1018  dpy = ((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy;
1019 
1020  /* make sure there really is a display before proceeding. */
1021  if (!dpy) {
1022  (void)tk_close(dmp);
1023  return DM_NULL;
1024  }
1025 
1026  if (dmp->dm_width == 0) {
1027  dmp->dm_width =
1028  WidthOfScreen(Tk_Screen((
1029  (struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin)) - 30;
1030  ++make_square;
1031  }
1032 
1033  if (dmp->dm_height == 0) {
1034  dmp->dm_height =
1035  HeightOfScreen(Tk_Screen((
1036  (struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin)) - 30;
1037  ++make_square;
1038  }
1039 
1040  if (make_square > 0) {
1041  /* Make window square */
1042  if (dmp->dm_height <
1043  dmp->dm_width)
1044  dmp->dm_width = dmp->dm_height;
1045  else
1046  dmp->dm_height = dmp->dm_width;
1047  }
1048 
1049  Tk_GeometryRequest(((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin,
1050  dmp->dm_width,
1051  dmp->dm_height);
1052 
1053  Tk_MakeWindowExist(((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin);
1054  ((struct dm_xvars *)dmp->dm_vars.pub_vars)->win =
1055  Tk_WindowId(((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin);
1056  dmp->dm_id = ((struct dm_xvars *)dmp->dm_vars.pub_vars)->win;
1057 
1058  ((struct x_vars *)dmp->dm_vars.priv_vars)->pix =
1059  Tk_GetPixmap(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy,
1060  DefaultRootWindow(((struct dm_xvars *)dmp->dm_vars.pub_vars)->dpy),
1061  dmp->dm_width,
1062  dmp->dm_height,
1063  Tk_Depth(((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin));
1064 
1065  fg.red = 65535;
1066  fg.green = fg.blue = 0;
1067 
1068  ((struct x_vars *)dmp->dm_vars.priv_vars)->fg =
1069  Tk_GetColorByValue(((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin,
1070  &fg)->pixel;
1071 
1072  bg.red = bg.green = bg.blue = 3277;
1073 
1074  ((struct x_vars *)dmp->dm_vars.priv_vars)->bg =
1075  Tk_GetColorByValue(((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin,
1076  &bg)->pixel;
1077 
1078  gcv.background = ((struct x_vars *)dmp->dm_vars.priv_vars)->bg;
1079  gcv.foreground = ((struct x_vars *)dmp->dm_vars.priv_vars)->fg;
1080 
1081  ((struct x_vars *)dmp->dm_vars.priv_vars)->gc =
1082  Tk_GetGC(((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin,
1083  (GCForeground|GCBackground), &gcv);
1084 
1085  (void)tk_configureWin_guts(dmp, 1);
1086 
1087  /*
1088  Tk_SetWindowBackground(((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin,
1089  ((struct x_vars *)dmp->dm_vars.priv_vars)->bg);
1090  */
1091  Tk_MapWindow(((struct dm_xvars *)dmp->dm_vars.pub_vars)->xtkwin);
1092 
1093  MAT_IDN(((struct x_vars *)dmp->dm_vars.priv_vars)->xmat);
1094 
1095  return dmp;
1096 }
1097 
1098 
1099 #endif /* DM_TK */
1100 
1101 /*
1102  * Local Variables:
1103  * mode: C
1104  * tab-width: 8
1105  * indent-tabs-mode: t
1106  * c-file-style: "stroustrup"
1107  * End:
1108  * ex: shiftwidth=4 tabstop=8
1109  */
void bu_vls_init(struct bu_vls *vp)
Definition: vls.c:56
int null_setDepthMask(struct dm_internal *dmp, int mask)
Definition: dm-Null.c:199
#define BU_LIST_FOR(p, structure, hp)
Definition: list.h:365
char filename[MAXLENGTH]
Definition: human.c:105
size_t nused
elements 0..nused active
Definition: vlist.h:73
#define GED_MAX
Definition: ged.h:253
void bu_log(const char *,...) _BU_ATTR_PRINTF12
Definition: log.c:176
struct bu_list l
magic, forw, back
Definition: vlist.h:72
int dm_top
!0 means toplevel window
Definition: dm_private.h:90
int dm_width
Definition: dm_private.h:91
void * pub_vars
Definition: dm_private.h:35
ustring interp
#define DM_DASHED_LINE
Definition: dm.h:109
int dm_zclip
!0 means zclipping
Definition: dm_private.h:116
int cmd[BN_VLIST_CHUNK]
VL_CMD_*.
Definition: vlist.h:74
#define GED_TO_Xx(_dmp, x)
Definition: dm.h:61
int dm_Normal2Xx(dm *dmp, fastf_t f)
Definition: dm-generic.c:216
#define FONT9
Definition: dm.h:79
vect_t dm_clipmax
maximum clipping vector
Definition: dm_private.h:108
Tcl_Interp * dm_interp
Tcl interpreter.
Definition: dm_private.h:121
unsigned char dm_fg[3]
foreground color
Definition: dm_private.h:106
int dm_processOptions(dm *dmp, struct bu_vls *init_proc_vls, int argc, char **argv)
Definition: options.c:38
void bu_vls_strncpy(struct bu_vls *vp, const char *s, size_t n)
Definition: vls.c:339
long Display
Definition: dm_xvars.h:49
int null_genDLists(struct dm_internal *dmp, size_t range)
Definition: dm-Null.c:252
Header file for the BRL-CAD common definitions.
int null_loadPMatrix(struct dm_internal *dmp, fastf_t *mat)
Definition: dm-Null.c:73
int dm_light
!0 means lighting on
Definition: dm_private.h:112
ustring width
int null_freeDLists(struct dm_internal *dmp, unsigned int list, int range)
Definition: dm-Null.c:245
fastf_t dm_aspect
Definition: dm_private.h:97
#define HIDDEN
Definition: common.h:86
#define BN_VLIST_POLY_MOVE
move to first poly vertex
Definition: vlist.h:85
int null_openFb(struct dm_internal *dmp)
Definition: dm-Null.c:279
#define BN_VLIST_TRI_VERTNORM
per-vertex normal, for interpolation
Definition: vlist.h:93
struct bu_vls dm_tkName
short Tcl/Tk name of drawing window
Definition: dm_private.h:103
void bu_vls_free(struct bu_vls *vp)
Definition: vls.c:248
#define DM_TYPE_TK
Definition: dm.h:100
Definition: color.c:49
COMPLEX data[64]
Definition: fftest.c:34
#define DM_NULL
Definition: dm.h:43
#define FB_NULL
Definition: fb.h:95
#define BU_ALLOC(_ptr, _type)
Definition: malloc.h:223
int dm_perspective
!0 means perspective on
Definition: dm_private.h:111
unsigned long dm_id
window id
Definition: dm_private.h:82
struct bu_vls dm_log
!NULL && !empty means log debug output to the file
Definition: dm_private.h:110
void bu_vls_sprintf(struct bu_vls *vls, const char *fmt,...) _BU_ATTR_PRINTF23
Definition: vls.c:707
#define PLOTBOUND
Definition: dm-plot.c:56
#define BN_VLIST_POLY_START
pt[] has surface normal
Definition: vlist.h:84
#define BN_VLIST_LINE_MOVE
Definition: vlist.h:82
int null_makeCurrent(struct dm_internal *dmp)
Definition: dm-Null.c:272
#define V3ARGS(a)
Definition: color.c:56
struct bu_vls dm_dName
Display name.
Definition: dm_private.h:104
#define SQRT_SMALL_FASTF
Definition: defines.h:346
int vclip(fastf_t *, fastf_t *, fastf_t *, fastf_t *)
#define BN_VLIST_LINE_DRAW
Definition: vlist.h:83
int vectorThreshold
Definition: tcl.c:46
size_t bu_vls_strlen(const struct bu_vls *vp)
Definition: vls.c:189
#define UNUSED(parameter)
Definition: common.h:239
int null_beginDList(struct dm_internal *dmp, unsigned int list)
Definition: dm-Null.c:225
#define BN_VLIST_POLY_DRAW
subsequent poly vertex
Definition: vlist.h:86
#define GED_MIN
Definition: ged.h:254
char * bu_vls_addr(const struct bu_vls *vp)
Definition: vls.c:111
#define BN_VLIST_TRI_END
last vert (repeats 1st), draw poly
Definition: vlist.h:92
int dm_lineWidth
Definition: dm_private.h:95
void null_reshape(struct dm_internal *dmp, int width, int height)
Definition: dm-Null.c:266
#define BU_STRUCTPARSE_FUNC_NULL
Definition: parse.h:153
struct fg_node fg
Definition: chull3d.cpp:80
ustring alpha
void * Tk_Window
Definition: dm_xvars.h:44
#define BN_VLIST_TRI_START
pt[] has surface normal
Definition: vlist.h:89
void * priv_vars
Definition: dm_private.h:36
vect_t dm_clipmin
minimum clipping vector
Definition: dm_private.h:107
Definition: vlist.h:71
struct dm_vars dm_vars
display manager dependent variables
Definition: dm_private.h:99
int dm_height
Definition: dm_private.h:92
int dm_zbuffer
!0 means zbuffer on
Definition: dm_private.h:115
#define BN_VLIST_POLY_VERTNORM
per-vertex normal, for interpolation
Definition: vlist.h:88
void null_drawDList(unsigned int list)
Definition: dm-Null.c:239
int clip(fastf_t *, fastf_t *, fastf_t *, fastf_t *)
Definition: clip.c:66
#define BN_VLIST_POLY_END
last vert (repeats 1st), draw poly
Definition: vlist.h:87
Definition: dm-tk.h:34
void bu_vls_printf(struct bu_vls *vls, const char *fmt,...) _BU_ATTR_PRINTF23
Definition: vls.c:694
int null_setTransparency(struct dm_internal *dmp, int transparency)
Definition: dm-Null.c:192
struct bu_vls dm_pathName
full Tcl/Tk name of drawing window
Definition: dm_private.h:102
#define FONTBACK
Definition: dm.h:74
#define DM_O(_m)
Definition: dm.h:47
#define BN_VLIST_TRI_DRAW
subsequent triangle vertex
Definition: vlist.h:91
int dm_Normal2Xy(dm *dmp, fastf_t f, int use_aspect)
Definition: dm-generic.c:233
unsigned char dm_bg[3]
background color
Definition: dm_private.h:105
Definition: color.c:51
int null_drawPoint3D(struct dm_internal *dmp, point_t point)
Definition: dm-Null.c:115
void bu_vls_strcpy(struct bu_vls *vp, const char *s)
Definition: vls.c:310
#define INIT_XCOLOR(c)
Definition: dm_xvars.h:56
void dm_generic_hook(const struct bu_structparse *sdp, const char *name, void *base, const char *value, void *data)
Definition: dm-generic.c:831
void bu_free(void *ptr, const char *str)
Definition: malloc.c:328
int null_getDisplayImage(struct dm_internal *dmp, unsigned char **image)
Definition: dm-Null.c:259
int null_drawPoints3D(struct dm_internal *dmp, int npoints, point_t *points)
Definition: dm-Null.c:122
Definition: dm-X.h:37
#define BU_VLS_INIT_ZERO
Definition: vls.h:84
point_t pt[BN_VLIST_CHUNK]
associated 3-point/vect
Definition: vlist.h:75
int dm_debugLevel
!0 means debugging
Definition: dm_private.h:109
int null_endDList(struct dm_internal *dmp)
Definition: dm-Null.c:232
Definition: vls.h:56
HIDDEN const point_t delta
Definition: sh_prj.c:618
dm dm_tk
double fastf_t
Definition: defines.h:300
#define GED_TO_Xy(_dmp, x)
Definition: dm.h:62
int dm_lineStyle
Definition: dm_private.h:96
Definition: color.c:50
#define BN_VLIST_TRI_MOVE
move to first triangle vertex
Definition: vlist.h:90