BRL-CAD
dm-qt.cpp
Go to the documentation of this file.
1 /* D M - Q T . C P P
2  * BRL-CAD
3  *
4  * Copyright (c) 2013-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-qt.cpp
21  *
22  */
23 #include "common.h"
24 #include <locale.h>
25 
26 #ifdef DM_QT
27 
28 #ifdef HAVE_SYS_TIME_H
29 # include <sys/time.h>
30 #endif
31 
32 #include "dm-qt.h"
33 
34 #include "tcl.h"
35 #include "tk.h"
36 #include "bu/log.h"
37 #include "bu/vls.h"
38 #include "bu/parse.h"
39 #include "dm.h"
40 #include "dm_private.h"
41 #include "dm/dm_xvars.h"
42 #include "dm-Null.h"
43 #include "fb/fb_qt.h"
44 
45 #define DM_QT_DEFAULT_POINT_SIZE 1.0
46 
47 
48 /* token used to cancel previous scheduled function using Tcl_CreateTimerHandler */
49 Tcl_TimerToken token = NULL;
50 
51 
52 HIDDEN bool
53 qt_sendRepaintEvent(dm *dmp)
54 {
55  struct qt_vars *privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
56  QEvent e(QEvent::UpdateRequest);
57  return privars->qapp->sendEvent(privars->win, &e);
58 }
59 
60 /**
61  * Release the display manager
62  */
63 HIDDEN int
64 qt_close(dm *dmp)
65 {
66  struct dm_xvars *pubvars = (struct dm_xvars *)dmp->dm_vars.pub_vars;
67  struct qt_vars *privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
68 
69  if (dmp->dm_debugLevel) {
70  bu_log("qt_close\n");
71  }
72 
73  delete privars->font;
74  delete privars->painter;
75  delete privars->pix;
76  delete privars->win;
77  delete privars->parent;
78 
79  privars->qapp->quit();
80  Tk_DestroyWindow(pubvars->xtkwin);
81 
82  bu_vls_free(&dmp->dm_pathName);
83  bu_vls_free(&dmp->dm_tkName);
84  bu_vls_free(&dmp->dm_dName);
85  bu_free((void *)dmp->dm_vars.priv_vars, "qt_close: qt_vars");
86  bu_free((void *)dmp->dm_vars.pub_vars, "qt_close: dm_xvars");
87  bu_free((void *)dmp, "qt_close: dmp");
88 
89  return TCL_OK;
90 }
91 
92 
93 HIDDEN int
94 qt_drawBegin(dm *dmp)
95 {
96  struct qt_vars *privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
97 
98  if (dmp->dm_debugLevel) {
99  bu_log("qt_drawBegin\n");
100  }
101 
102  privars->pix->fill(privars->bg);
103 
104  privars->painter->setPen(privars->fg);
105  privars->painter->setFont(*privars->font);
106 
107  if (privars->img != NULL && privars->drawFb == 1) {
108  privars->painter->drawImage(0, 0, *privars->img, 0, 0, dmp->dm_width - 1, dmp->dm_height - 1);
109  }
110 
111  return TCL_OK;
112 }
113 
114 
115 HIDDEN int
116 qt_drawEnd(dm *dmp)
117 {
118  struct qt_vars *privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
119 
120  if (dmp->dm_debugLevel) {
121  bu_log("qt_drawEnd\n");
122  }
123  privars->qapp->processEvents();
124  qt_sendRepaintEvent(dmp);
125  privars->qapp->processEvents();
126 
127  return TCL_OK;
128 }
129 
130 /**
131  * Restore the display processor to a normal mode of operation (i.e.,
132  * not scaled, rotated, displaced, etc.).
133  */
134 HIDDEN int
135 qt_normal(dm *dmp)
136 {
137  if (dmp->dm_debugLevel)
138  bu_log("qt_normal()\n");
139 
140  return TCL_OK;
141 }
142 
143 /**
144  * Load a new transformation matrix. This will be followed by many
145  * calls to qt_draw().
146  */
147 HIDDEN int
148 qt_loadMatrix(dm *dmp, fastf_t *mat, int UNUSED(which_eye))
149 {
150  struct qt_vars *privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
151 
152  if (dmp->dm_debugLevel) {
153  bu_log("qt_loadMatrix\n");
154  }
155 
156  MAT_COPY(privars->qmat, mat);
157 
158  return 0;
159 }
160 
161 
162 /**
163  * Output a string into the displaylist. The starting position of the
164  * beam is as specified.
165  */
166 HIDDEN int
167 qt_drawString2D(dm *dmp, const char *str, fastf_t x, fastf_t y, int UNUSED(size), int use_aspect)
168 {
169  int sx, sy;
170  struct qt_vars *privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
171 
172  if (dmp->dm_debugLevel) {
173  bu_log("qt_drawString2D\n");
174  }
175 
176  sx = dm_Normal2Xx(dmp, x);
177  sy = dm_Normal2Xy(dmp, y, use_aspect);
178 
179  if (privars->painter == NULL)
180  return TCL_ERROR;
181  privars->painter->drawText(sx, sy, str);
182 
183  return TCL_OK;
184 }
185 
186 
187 HIDDEN int
188 qt_drawLine2D(dm *dmp, fastf_t x_1, fastf_t y_1, fastf_t x_2, fastf_t y_2)
189 {
190  int sx1, sy1, sx2, sy2;
191  struct qt_vars *privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
192 
193  if (dmp->dm_debugLevel) {
194  bu_log("qt_drawLine2D\n");
195  }
196 
197  sx1 = dm_Normal2Xx(dmp, x_1);
198  sx2 = dm_Normal2Xx(dmp, x_2);
199  sy1 = dm_Normal2Xy(dmp, y_1, 0);
200  sy2 = dm_Normal2Xy(dmp, y_2, 0);
201 
202  if (privars->painter == NULL)
203  return TCL_ERROR;
204  privars->painter->drawLine(sx1, sy1, sx2, sy2);
205 
206  return TCL_OK;
207 }
208 
209 
210 HIDDEN int
211 qt_drawPoint2D(dm *dmp, fastf_t x, fastf_t y)
212 {
213  int sx, sy;
214  struct qt_vars *privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
215 
216  if (dmp->dm_debugLevel) {
217  bu_log("qt_drawPoint2D\n");
218  }
219 
220  sx = dm_Normal2Xx(dmp, x);
221  sy = dm_Normal2Xy(dmp, y, 0);
222 
223  if (privars->painter == NULL)
224  return TCL_ERROR;
225  privars->painter->drawPoint(sx, sy);
226 
227  return TCL_OK;
228 }
229 
230 
231 HIDDEN int
232 qt_drawVList(dm *dmp, struct bn_vlist *vp)
233 {
234  static vect_t spnt, lpnt, pnt;
235  struct bn_vlist *tvp;
236  QLine lines[1024];
237  QLine *linep;
238  int nseg;
239  fastf_t delta;
240  point_t *pt_prev = NULL;
241  fastf_t dist_prev=1.0;
242  fastf_t pointSize = DM_QT_DEFAULT_POINT_SIZE;
243  struct qt_vars *privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
244 
245  if (dmp->dm_debugLevel) {
246  bu_log("qt_drawVList\n");
247  }
248 
249  /* delta is used in clipping to insure clipped endpoint is
250  * slightly in front of eye plane (perspective mode only). This
251  * value is a SWAG that seems to work OK.
252  */
253  delta = privars->qmat[15]*0.0001;
254  if (delta < 0.0)
255  delta = -delta;
256  if (delta < SQRT_SMALL_FASTF)
257  delta = SQRT_SMALL_FASTF;
258 
259  nseg = 0;
260  linep = lines;
261  for (BU_LIST_FOR(tvp, bn_vlist, &vp->l)) {
262  int i;
263  int nused = tvp->nused;
264  int *cmd = tvp->cmd;
265  point_t *pt = tvp->pt;
266  fastf_t dist;
267 
268  for (i = 0; i < nused; i++, cmd++, pt++) {
269  switch (*cmd) {
270  case BN_VLIST_POLY_START:
272  case BN_VLIST_TRI_START:
274  continue;
275  case BN_VLIST_POLY_MOVE:
276  case BN_VLIST_LINE_MOVE:
277  case BN_VLIST_TRI_MOVE:
278  /* Move, not draw */
279  if (dmp->dm_perspective > 0) {
280  /* cannot apply perspective transformation to
281  * points behind eye plane!!!!
282  */
283  dist = VDOT(*pt, &privars->qmat[12]) + privars->qmat[15];
284  if (dist <= 0.0) {
285  pt_prev = pt;
286  dist_prev = dist;
287  continue;
288  } else {
289  MAT4X3PNT(lpnt, privars->qmat, *pt);
290  dist_prev = dist;
291  pt_prev = pt;
292  }
293  } else {
294  MAT4X3PNT(lpnt, privars->qmat, *pt);
295  }
296 
297  lpnt[0] *= 2047;
298  lpnt[1] *= 2047 * dmp->dm_aspect;
299  lpnt[2] *= 2047;
300  continue;
301  case BN_VLIST_POLY_DRAW:
302  case BN_VLIST_POLY_END:
303  case BN_VLIST_LINE_DRAW:
304  case BN_VLIST_TRI_DRAW:
305  case BN_VLIST_TRI_END:
306  /* draw */
307  if (dmp->dm_perspective > 0) {
308  dist = VDOT(*pt, &privars->qmat[12]) + privars->qmat[15];
309  if (dist <= 0.0) {
310  if (dist_prev <= 0.0) {
311  /* nothing to plot */
312  dist_prev = dist;
313  pt_prev = pt;
314  continue;
315  } else {
316  if (pt_prev) {
317  fastf_t alpha;
318  vect_t diff;
319  point_t tmp_pt;
320 
321  /* clip this end */
322  VSUB2(diff, *pt, *pt_prev);
323  alpha = (dist_prev - delta) / (dist_prev - dist);
324  VJOIN1(tmp_pt, *pt_prev, alpha, diff);
325  MAT4X3PNT(pnt, privars->qmat, tmp_pt);
326  }
327  }
328  } else {
329  if (dist_prev <= 0.0) {
330  if (pt_prev) {
331  fastf_t alpha;
332  vect_t diff;
333  point_t tmp_pt;
334 
335  /* clip other end */
336  VSUB2(diff, *pt, *pt_prev);
337  alpha = (-dist_prev + delta) / (dist - dist_prev);
338  VJOIN1(tmp_pt, *pt_prev, alpha, diff);
339  MAT4X3PNT(lpnt, privars->qmat, tmp_pt);
340  lpnt[0] *= 2047;
341  lpnt[1] *= 2047 * dmp->dm_aspect;
342  lpnt[2] *= 2047;
343  MAT4X3PNT(pnt, privars->qmat, *pt);
344  }
345  } else {
346  MAT4X3PNT(pnt, privars->qmat, *pt);
347  }
348  }
349  dist_prev = dist;
350  } else {
351  MAT4X3PNT(pnt, privars->qmat, *pt);
352  }
353 
354  pnt[0] *= 2047;
355  pnt[1] *= 2047 * dmp->dm_aspect;
356  pnt[2] *= 2047;
357 
358  /* save pnt --- it might get changed by clip() */
359  VMOVE(spnt, pnt);
360  pt_prev = pt;
361 
362  if (dmp->dm_zclip) {
363  if (vclip(lpnt, pnt,
364  dmp->dm_clipmin,
365  dmp->dm_clipmax) == 0) {
366  VMOVE(lpnt, spnt);
367  continue;
368  }
369  }
370  /* convert to Qt window coordinates */
371  linep->setLine ((short)GED_TO_Xx(dmp, lpnt[0]),
372  (short)GED_TO_Xy(dmp, lpnt[1]),
373  (short)GED_TO_Xx(dmp, pnt[0]),
374  (short)GED_TO_Xy(dmp, pnt[1])
375  );
376 
377  nseg++;
378  linep++;
379  VMOVE(lpnt, spnt);
380 
381  if (nseg == 1024) {
382  if (privars->painter != NULL)
383  privars->painter->drawLines(lines, nseg);
384  nseg = 0;
385  linep = lines;
386  }
387  break;
388  case BN_VLIST_POINT_DRAW:
389  if (dmp->dm_debugLevel > 2) {
390  bu_log("before transformation:\n");
391  bu_log("pt - %lf %lf %lf\n", V3ARGS(*pt));
392  }
393 
394  if (dmp->dm_perspective > 0) {
395  dist = VDOT(*pt, &privars->qmat[12]) + privars->qmat[15];
396 
397  if (dist <= 0.0) {
398  /* nothing to plot - point is behind eye plane */
399  continue;
400  }
401  }
402 
403  MAT4X3PNT(pnt, privars->qmat, *pt);
404 
405  pnt[0] *= 2047;
406  pnt[1] *= 2047 * dmp->dm_aspect;
407  pnt[2] *= 2047;
408 
409  if (dmp->dm_debugLevel > 2) {
410  bu_log("after clipping:\n");
411  bu_log("pt - %lf %lf %lf\n", pnt[X], pnt[Y], pnt[Z]);
412  }
413 
414  if (pointSize <= DM_QT_DEFAULT_POINT_SIZE) {
415  privars->painter->drawPoint(GED_TO_Xx(dmp, pnt[0]), GED_TO_Xy(dmp, pnt[1]));
416  } else {
417  int upperLeft[2];
418 
419  upperLeft[X] = GED_TO_Xx(dmp, pnt[0]) - pointSize / 2.0;
420  upperLeft[Y] = GED_TO_Xy(dmp, pnt[1]) - pointSize / 2.0;
421 
422  privars->painter->drawRect(upperLeft[X], upperLeft[Y], pointSize, pointSize);
423  }
424  break;
425  case BN_VLIST_POINT_SIZE:
426  pointSize = (*pt)[0];
427  if (pointSize < DM_QT_DEFAULT_POINT_SIZE) {
428  pointSize = DM_QT_DEFAULT_POINT_SIZE;
429  }
430  break;
431  }
432  }
433  }
434 
435  if (nseg) {
436  if (privars->painter != NULL)
437  privars->painter->drawLines(lines, nseg);
438  }
439 
440  return TCL_OK;
441 }
442 
443 
444 HIDDEN int
445 qt_draw(dm *dmp, struct bn_vlist *(*callback_function)(void *), void **data)
446 {
447  struct bn_vlist *vp;
448 
449  if (dmp->dm_debugLevel) {
450  bu_log("qt_draw\n");
451  }
452 
453  if (!callback_function) {
454  if (data) {
455  vp = (struct bn_vlist *)data;
456  qt_drawVList(dmp, vp);
457  }
458  } else {
459  if (!data) {
460  return TCL_ERROR;
461  } else {
462  (void)callback_function(data);
463  }
464  }
465  return TCL_OK;
466 }
467 
468 
469 HIDDEN int
470 qt_setFGColor(dm *dmp, unsigned char r, unsigned char g, unsigned char b, int UNUSED(strict), fastf_t UNUSED(transparency))
471 {
472  struct qt_vars *privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
473 
474  if (dmp->dm_debugLevel) {
475  bu_log("qt_setFGColor\n");
476  }
477 
478  dmp->dm_fg[0] = r;
479  dmp->dm_fg[1] = g;
480  dmp->dm_fg[2] = b;
481 
482  privars->fg.setRgb(r, g, b);
483 
484  if (privars->painter != NULL) {
485  QPen p = privars->painter->pen();
486  p.setColor(privars->fg);
487  privars->painter->setPen(p);
488  }
489 
490  return TCL_OK;
491 }
492 
493 
494 HIDDEN int
495 qt_setBGColor(dm *dmp, unsigned char r, unsigned char g, unsigned char b)
496 {
497  struct qt_vars *privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
498 
499  if (dmp->dm_debugLevel) {
500  bu_log("qt_setBGColor\n");
501  }
502 
503 
504  privars->bg.setRgb(r, g, b);
505 
506  dmp->dm_bg[0] = r;
507  dmp->dm_bg[1] = g;
508  dmp->dm_bg[2] = b;
509 
510  if (privars->pix == NULL)
511  return TCL_ERROR;
512  privars->pix->fill(privars->bg);
513 
514  return TCL_OK;
515 }
516 
517 
518 HIDDEN int
519 qt_setLineAttr(dm *dmp, int width, int style)
520 {
521  struct qt_vars *privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
522 
523  if (dmp->dm_debugLevel) {
524  bu_log("qt_setLineAttr\n");
525  }
526 
527  dmp->dm_lineWidth = width;
528  dmp->dm_lineStyle = style;
529 
530  if (width <= 1)
531  width = 0;
532 
533  if (privars->painter == NULL)
534  return TCL_ERROR;
535  QPen p = privars->painter->pen();
536  p.setWidth(width);
537  if (style == DM_DASHED_LINE)
538  p.setStyle(Qt::DashLine);
539  else
540  p.setStyle(Qt::SolidLine);
541  privars->painter->setPen(p);
542 
543  return TCL_OK;
544 }
545 
546 
547 HIDDEN void
548 qt_reshape(dm *dmp, int width, int height)
549 {
550  if (dmp->dm_debugLevel) {
551  bu_log("qt_reshape\n");
552  }
553 
554  dmp->dm_height = height;
555  dmp->dm_width = width;
556  dmp->dm_aspect = (fastf_t)dmp->dm_width / (fastf_t)dmp->dm_height;
557 
558 }
559 
560 
561 HIDDEN int
562 qt_configureWin(dm *dmp, int force)
563 {
564  struct dm_xvars *pubvars = (struct dm_xvars *)dmp->dm_vars.pub_vars;
565  struct qt_vars *privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
566 
567  int width = Tk_Width(pubvars->xtkwin);
568  int height = Tk_Height(pubvars->xtkwin);
569 
570  if (!force &&
571  dmp->dm_height == height &&
572  dmp->dm_width == width)
573  return TCL_OK;
574 
575  qt_reshape(dmp, width, height);
576  privars->win->resize(width, height);
577 
578  privars->painter->end();
579  *privars->pix = privars->pix->scaled(width, height);
580  privars->painter->begin(privars->pix);
581 
582  if (dmp->dm_debugLevel) {
583  bu_log("qt_configureWin()\n");
584  bu_log("width = %d, height = %d\n", dmp->dm_width, dmp->dm_height);
585  }
586 
587  /* set font according to window size */
588  if (privars->font == NULL) {
589  privars->font = new QFont(QString(FONTBACK));
590  }
591 
592  if (dmp->dm_width < 582) {
593  if (privars->font->pointSize() != 5) {
594  privars->font->setPointSize(5);
595  }
596  } else if (dmp->dm_width < 679) {
597  if (privars->font->pointSize() != 6) {
598  privars->font->setPointSize(6);
599  }
600  } else if (dmp->dm_width < 776) {
601  if (privars->font->pointSize() != 7) {
602  privars->font->setPointSize(7);
603  }
604  } else if (dmp->dm_width < 874) {
605  if (privars->font->pointSize() != 8) {
606  privars->font->setPointSize(8);
607  }
608  } else {
609  if (privars->font->pointSize() != 9) {
610  privars->font->setPointSize(9);
611  }
612  }
613 
614  return TCL_OK;
615 }
616 
617 
618 HIDDEN int
619 qt_setWinBounds(dm *dmp, fastf_t *w)
620 {
621  if (dmp->dm_debugLevel) {
622  bu_log("qt_setWinBounds\n");
623  }
624 
625  dmp->dm_clipmin[0] = w[0];
626  dmp->dm_clipmin[1] = w[2];
627  dmp->dm_clipmin[2] = w[4];
628  dmp->dm_clipmax[0] = w[1];
629  dmp->dm_clipmax[1] = w[3];
630  dmp->dm_clipmax[2] = w[5];
631 
632  return TCL_OK;
633 }
634 
635 
636 HIDDEN int
637 qt_setZBuffer(dm *dmp, int zbuffer_on)
638 {
639  if (dmp->dm_debugLevel) {
640  bu_log("qt_setZBuffer\n");
641  }
642 
643  dmp->dm_zbuffer = zbuffer_on;
644 
645  return TCL_OK;
646 }
647 
648 
649 HIDDEN int
650 qt_debug(dm *dmp, int lvl)
651 {
652  dmp->dm_debugLevel = lvl;
653 
654  return TCL_OK;
655 }
656 
657 
658 HIDDEN int
659 qt_logfile(dm *dmp, const char *filename)
660 {
661  bu_vls_sprintf(&dmp->dm_log, "%s", filename);
662 
663  return TCL_OK;
664 }
665 
666 
667 HIDDEN int
668 qt_getDisplayImage(dm *dmp, unsigned char **image)
669 {
670  struct qt_vars *privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
671  int i,j;
672  int height, width;
673 
674  if (dmp->dm_debugLevel) {
675  bu_log("qt_getDisplayImage\n");
676  }
677 
678  QImage qimage = privars->pix->toImage();
679  height = qimage.height();
680  width = qimage.width();
681 
682  for (i = 0; i < height; i++) {
683  for (j = 0; j < width; j++) {
684  image[i][j] = qimage.pixel(i,j);
685  }
686  }
687 
688  return TCL_OK;
689 }
690 
691 
692 HIDDEN int
693 qt_setLight(dm *dmp, int light_on)
694 {
695  if (dmp->dm_debugLevel)
696  bu_log("qt_setLight:\n");
697 
698  dmp->dm_light = light_on;
699 
700  return TCL_OK;
701 }
702 
703 
704 HIDDEN void
705 qt_processEvents(dm *dmp)
706 {
707  struct qt_vars *privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
708  privars->qapp->processEvents();
709 }
710 
711 
712 HIDDEN int
713 qt_openFb(struct dm_internal *dmp)
714 {
715 
716  struct fb_platform_specific *fb_ps;
717  struct qt_fb_info *qtfb_ps;
718  struct qt_vars *privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
719 
721  qtfb_ps = (struct qt_fb_info *)fb_ps->data;
722  qtfb_ps->qapp = privars->qapp;
723  qtfb_ps->qwin = privars->win;
724  qtfb_ps->qpainter = privars->painter;
725  qtfb_ps->draw = &privars->drawFb;
726  qtfb_ps->qimg = (void **)&privars->img;
727 
728  dmp->fbp = fb_open_existing("Qt", dm_get_width(dmp), dm_get_height(dmp), fb_ps);
730  return 0;
731 }
732 
733 
734 /**
735  * Function called in Tk event loop. It simply processes any
736  * pending Qt events.
737  *
738  */
739 void processQtEvents(ClientData UNUSED(clientData), int UNUSED(flags)) {
740  qt_processEvents(&dm_qt);
741 }
742 
743 
744 /**
745  * Call when Tk is idle. It process Qt events then
746  * reschedules itself.
747  *
748  */
749 void IdleCall(ClientData UNUSED(clientData)) {
750  qt_processEvents(&dm_qt);
751  Tcl_DeleteTimerHandler(token);
752 
753  /* Reschedule the function so that it continuously tries to process Qt events */
754  token = Tcl_CreateTimerHandler(1, IdleCall, NULL);
755 }
756 
758 
759 /*
760  * Fire up the display manager, and the display processor.
761  *
762  */
763 dm *
764 qt_open(Tcl_Interp *interp, int argc, char **argv)
765 {
766  static int count = 0;
767  int make_square = -1;
768  dm *dmp = (dm *)NULL;
769  struct bu_vls init_proc_vls = BU_VLS_INIT_ZERO;
770  struct bu_vls str = BU_VLS_INIT_ZERO;
771  Tk_Window tkwin;
772 
773  struct dm_xvars *pubvars = NULL;
774  struct qt_vars *privars = NULL;
775 
776  if (argc < 0 || !argv) {
777  return DM_NULL;
778  }
779 
780  if ((tkwin = Tk_MainWindow(interp)) == NULL) {
781  return DM_NULL;
782  }
783 
784  BU_ALLOC(dmp, struct dm_internal);
785 
786  *dmp = dm_qt; /* struct copy */
787  dmp->dm_interp = interp;
788 
789  BU_ALLOC(dmp->dm_vars.pub_vars, struct dm_xvars);
790  pubvars = (struct dm_xvars *)dmp->dm_vars.pub_vars;
791 
792  BU_ALLOC(dmp->dm_vars.priv_vars, struct qt_vars);
793  privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
794 
795  bu_vls_init(&dmp->dm_pathName);
796  bu_vls_init(&dmp->dm_tkName);
797  bu_vls_init(&dmp->dm_dName);
798 
799  dm_processOptions(dmp, &init_proc_vls, --argc, ++argv);
800 
801  if (bu_vls_strlen(&dmp->dm_pathName) == 0) {
802  bu_vls_printf(&dmp->dm_pathName, ".dm_qt%d", count);
803  }
804  ++count;
805 
806  if (bu_vls_strlen(&dmp->dm_dName) == 0) {
807  char *dp;
808 
809  dp = getenv("DISPLAY");
810  if (dp)
811  bu_vls_strcpy(&dmp->dm_dName, dp);
812  else
813  bu_vls_strcpy(&dmp->dm_dName, ":0.0");
814  }
815  if (bu_vls_strlen(&init_proc_vls) == 0) {
816  bu_vls_strcpy(&init_proc_vls, "bind_dm");
817  }
818 
819  /* initialize dm specific variables */
820  pubvars->devmotionnotify = LASTEvent;
821  pubvars->devbuttonpress = LASTEvent;
822  pubvars->devbuttonrelease = LASTEvent;
823  dmp->dm_aspect = 1.0;
824 
825  if (dmp->dm_top) {
826  /* Make xtkwin a toplevel window */
827  pubvars->xtkwin = Tk_CreateWindowFromPath(interp, tkwin,
828  bu_vls_addr(&dmp->dm_pathName),
829  bu_vls_addr(&dmp->dm_dName));
830  pubvars->top = pubvars->xtkwin;
831  } else {
832  char *cp;
833 
834  cp = strrchr(bu_vls_addr(&dmp->dm_pathName), (int)'.');
835  if (cp == bu_vls_addr(&dmp->dm_pathName)) {
836  pubvars->top = tkwin;
837  } else {
838  struct bu_vls top_vls = BU_VLS_INIT_ZERO;
839 
840  bu_vls_strncpy(&top_vls, (const char *)bu_vls_addr(&dmp->dm_pathName), cp - bu_vls_addr(&dmp->dm_pathName));
841 
842  pubvars->top = Tk_NameToWindow(interp, bu_vls_addr(&top_vls), tkwin);
843  bu_vls_free(&top_vls);
844  }
845 
846  /* Make xtkwin an embedded window */
847  pubvars->xtkwin =
848  Tk_CreateWindow(interp, pubvars->top,
849  cp + 1, (char *)NULL);
850  }
851 
852  if (pubvars->xtkwin == NULL) {
853  bu_log("qt_open: Failed to open %s\n", bu_vls_addr(&dmp->dm_pathName));
854  (void)qt_close(dmp);
855  return DM_NULL;
856  }
857 
858  bu_vls_printf(&dmp->dm_tkName, "%s", (char *)Tk_Name(pubvars->xtkwin));
859 
860  bu_vls_printf(&str, "_init_dm %s %s\n", bu_vls_addr(&init_proc_vls), bu_vls_addr(&dmp->dm_pathName));
861 
862  if (Tcl_Eval(interp, bu_vls_addr(&str)) == TCL_ERROR) {
863  bu_log("qt_open: _init_dm failed\n");
864  bu_vls_free(&init_proc_vls);
865  bu_vls_free(&str);
866  (void)qt_close(dmp);
867  return DM_NULL;
868  }
869 
870  bu_vls_free(&init_proc_vls);
871  bu_vls_free(&str);
872 
873  pubvars->dpy = Tk_Display(pubvars->top);
874 
875  /* make sure there really is a display before proceeding. */
876  if (!pubvars->dpy) {
877  bu_log("qt_open: Unable to attach to display (%s)\n", bu_vls_addr(&dmp->dm_pathName));
878  (void)qt_close(dmp);
879  return DM_NULL;
880  }
881 
882  if (dmp->dm_width == 0) {
883  dmp->dm_width =
884  WidthOfScreen(Tk_Screen(pubvars->xtkwin)) - 30;
885  ++make_square;
886  }
887 
888  if (dmp->dm_height == 0) {
889  dmp->dm_height =
890  HeightOfScreen(Tk_Screen(pubvars->xtkwin)) - 30;
891  ++make_square;
892  }
893 
894  if (make_square > 0) {
895  /* Make window square */
896  if (dmp->dm_height <
897  dmp->dm_width)
898  dmp->dm_width = dmp->dm_height;
899  else
900  dmp->dm_height = dmp->dm_width;
901  }
902 
903  Tk_GeometryRequest(pubvars->xtkwin, dmp->dm_width, dmp->dm_height);
904 
905  Tk_MakeWindowExist(pubvars->xtkwin);
906  pubvars->win = Tk_WindowId(pubvars->xtkwin);
907  dmp->dm_id = pubvars->win;
908 
909  Tk_SetWindowBackground(pubvars->xtkwin, 0);
910  Tk_MapWindow(pubvars->xtkwin);
911  privars->qapp = new QApplication(argc, argv);
912 
913  privars->parent = QWindow::fromWinId(pubvars->win);
914 
915  privars->pix = new QPixmap(dmp->dm_width, dmp->dm_height);
916 
917  privars->win = new QTkMainWindow(privars->pix, privars->parent, dmp);
918  privars->win->resize(dmp->dm_width, dmp->dm_height);
919  privars->win->show();
920 
921  privars->font = NULL;
922 
923  privars->painter = new QPainter(privars->pix);
924  qt_setFGColor(dmp, 1, 0, 0, 0, 0);
925  qt_setBGColor(dmp, 0, 0, 0);
926 
927  qt_configureWin(dmp, 1);
928 
929  MAT_IDN(privars->qmat);
930 
931  /* inputs and outputs assume POSIX/C locale settings */
932  setlocale(LC_ALL, "POSIX");
933 
934  /* Make Tcl_DoOneEvent call QApplication::processEvents */
935  Tcl_CreateEventSource(NULL, processQtEvents, NULL);
936 
937  /* Try to process Qt events when idle */
938  Tcl_DoWhenIdle(IdleCall, NULL);
939 
940  return dmp;
941 }
942 
943 static void
944 Qt_zclip_hook(const struct bu_structparse *sdp,
945  const char *name,
946  void *base,
947  const char *value,
948  void *data)
949 {
950  dm *dmp = (dm *)base;
951  fastf_t bounds[6] = { GED_MIN, GED_MAX, GED_MIN, GED_MAX, GED_MIN, GED_MAX };
952 
953  if (dmp->dm_zclip) {
954  bounds[4] = -1.0;
955  bounds[5] = 1.0;
956  }
957 
958  (void)dm_make_current(dmp);
959  (void)dm_set_win_bounds(dmp, bounds);
960 
961  dm_generic_hook(sdp, name, base, value, data);
962 }
963 
964 
965 struct bu_structparse Qt_vparse[] = {
966  {"%g", 1, "bound", DM_O(dm_bound), dm_generic_hook, NULL, NULL},
967  {"%d", 1, "useBound", DM_O(dm_boundFlag), dm_generic_hook, NULL, NULL},
968  {"%d", 1, "zclip", DM_O(dm_zclip), Qt_zclip_hook, NULL, NULL},
969  {"%d", 1, "debug", DM_O(dm_debugLevel), dm_generic_hook, NULL, NULL},
970  {"", 0, (char *)0, 0, BU_STRUCTPARSE_FUNC_NULL, NULL, NULL}
971 };
972 
974 
975 struct dm_internal dm_qt = {
976  qt_close,
977  qt_drawBegin,
978  qt_drawEnd,
979  qt_normal,
980  qt_loadMatrix,
982  qt_drawString2D,
983  qt_drawLine2D,
986  qt_drawPoint2D,
989  qt_drawVList,
990  qt_drawVList,
991  qt_draw,
992  qt_setFGColor,
993  qt_setBGColor,
994  qt_setLineAttr,
995  qt_configureWin,
996  qt_setWinBounds,
997  qt_setLight,
1000  qt_setZBuffer,
1001  qt_debug,
1002  qt_logfile,
1004  null_endDList,
1008  NULL,
1009  qt_getDisplayImage,
1010  qt_reshape,
1012  qt_openFb,
1013  NULL,
1014  NULL,
1015  0,
1016  0, /* no displaylist */
1017  0, /* no stereo */
1018  0.0, /* zoom-in limit */
1019  1, /* bound flag */
1020  "qt",
1021  "Qt Display",
1022  DM_TYPE_QT,
1023  1,
1024  0,/* width */
1025  0,/* height */
1026  0,/* bytes per pixel */
1027  0,/* bits per channel */
1028  0,
1029  0,
1030  1.0,/* aspect ratio */
1031  0,
1032  {0, 0},
1033  NULL,
1034  NULL,
1035  BU_VLS_INIT_ZERO, /* bu_vls path name*/
1036  BU_VLS_INIT_ZERO, /* bu_vls full name drawing window */
1037  BU_VLS_INIT_ZERO, /* bu_vls short name drawing window */
1038  {0, 0, 0}, /* bg color */
1039  {0, 0, 0}, /* fg color */
1040  {GED_MIN, GED_MIN, GED_MIN}, /* clipmin */
1041  {GED_MAX, GED_MAX, GED_MAX}, /* clipmax */
1042  0, /* no debugging */
1043  BU_VLS_INIT_ZERO, /* bu_vls logfile */
1044  0, /* no perspective */
1045  0, /* no lighting */
1046  0, /* no transparency */
1047  0, /* depth buffer is not writable */
1048  0, /* no zbuffer */
1049  0, /* no zclipping */
1050  1, /* clear back buffer after drawing and swap */
1051  0, /* not overriding the auto font size */
1052  Qt_vparse,
1053  FB_NULL,
1054  0 /* Tcl interpreter */
1055 };
1056 
1057 
1058 /**
1059  * ================================================== Event bindings declaration ==========================================================
1060  */
1061 
1062 /* left click press */
1063 char* qt_mouseButton1Press(QEvent *event) {
1064  if (event->type() == QEvent::MouseButtonPress) {
1065  QMouseEvent *mouseEv = (QMouseEvent *)event;
1066  if (mouseEv->button() == Qt::LeftButton) {
1067  struct bu_vls str = BU_VLS_INIT_ZERO;
1068  bu_vls_printf(&str, "<1> -x %d -y %d", mouseEv->x(), mouseEv->y());
1069  return bu_vls_addr(&str);
1070  }
1071  }
1072  return NULL;
1073 }
1074 
1075 /* left click release */
1076 char* qt_mouseButton1Release(QEvent *event) {
1077  if (event->type() == QEvent::MouseButtonRelease) {
1078  QMouseEvent *mouseEv = (QMouseEvent *)event;
1079  if (mouseEv->button() == Qt::LeftButton) {
1080  struct bu_vls str = BU_VLS_INIT_ZERO;
1081  bu_vls_printf(&str, "<ButtonRelease-1>");
1082  return bu_vls_addr(&str);
1083  }
1084  }
1085  return NULL;
1086 }
1087 
1088 /* right click press */
1089 char* qt_mouseButton3Press(QEvent *event) {
1090  if (event->type() == QEvent::MouseButtonPress) {
1091  QMouseEvent *mouseEv = (QMouseEvent *)event;
1092  if (mouseEv->button() == Qt::RightButton) {
1093  struct bu_vls str = BU_VLS_INIT_ZERO;
1094  bu_vls_printf(&str, "<3> -x %d -y %d", mouseEv->x(), mouseEv->y());
1095  return bu_vls_addr(&str);
1096  }
1097  }
1098  return NULL;
1099 }
1100 
1101 /* right click release */
1102 char* qt_mouseButton3Release(QEvent *event) {
1103  if (event->type() == QEvent::MouseButtonPress) {
1104  QMouseEvent *mouseEv = (QMouseEvent *)event;
1105  if (mouseEv->button() == Qt::RightButton) {
1106  struct bu_vls str = BU_VLS_INIT_ZERO;
1107  bu_vls_printf(&str, "<ButtonRelease-3>");
1108  return bu_vls_addr(&str);
1109  }
1110  }
1111  return NULL;
1112 }
1113 
1114 /* middle mouse button press */
1115 char* qt_mouseButton2Press(QEvent *event) {
1116  if (event->type() == QEvent::MouseButtonPress) {
1117  QMouseEvent *mouseEv = (QMouseEvent *)event;
1118  if (mouseEv->button() == Qt::MiddleButton) {
1119  struct bu_vls str = BU_VLS_INIT_ZERO;
1120  bu_vls_printf(&str, "<2> -x %d -y %d", mouseEv->x(), mouseEv->y());
1121  return bu_vls_addr(&str);
1122  }
1123  }
1124  return NULL;
1125 }
1126 
1127 /* middle mouse button release */
1128 char* qt_mouseButton2Release(QEvent *event) {
1129  if (event->type() == QEvent::MouseButtonPress) {
1130  QMouseEvent *mouseEv = (QMouseEvent *)event;
1131  if (mouseEv->button() == Qt::MiddleButton) {
1132  struct bu_vls str = BU_VLS_INIT_ZERO;
1133  bu_vls_printf(&str, "<ButtonRelease-2>");
1134  return bu_vls_addr(&str);
1135  }
1136  }
1137  return NULL;
1138 }
1139 
1140 char* qt_controlMousePress(QEvent *event) {
1141  if (event->type() == QEvent::MouseButtonPress) {
1142  QMouseEvent *mouseEv = (QMouseEvent *)event;
1143  if (mouseEv->button() == Qt::LeftButton && mouseEv->modifiers() == Qt::ControlModifier) {
1144  struct bu_vls str = BU_VLS_INIT_ZERO;
1145  bu_vls_printf(&str, "<Control-ButtonPress-1> -x %d -y %d", mouseEv->x(), mouseEv->y());
1146  return bu_vls_addr(&str);
1147  }
1148  }
1149  return NULL;
1150 }
1151 
1152 char* qt_altMousePress(QEvent *event) {
1153  if (event->type() == QEvent::MouseButtonPress) {
1154  QMouseEvent *mouseEv = (QMouseEvent *)event;
1155  if (mouseEv->button() == Qt::LeftButton && mouseEv->modifiers() == Qt::AltModifier) {
1156  struct bu_vls str = BU_VLS_INIT_ZERO;
1157  bu_vls_printf(&str, "<Alt-ButtonPress-1> -x %d -y %d", mouseEv->x(), mouseEv->y());
1158  return bu_vls_addr(&str);
1159  }
1160  }
1161  return NULL;
1162 }
1163 
1164 char* qt_altControlMousePress(QEvent *event) {
1165  if (event->type() == QEvent::MouseButtonPress) {
1166  QMouseEvent *mouseEv = (QMouseEvent *)event;
1167  if (mouseEv->button() == Qt::LeftButton && mouseEv->modifiers() & Qt::AltModifier && mouseEv->modifiers() & Qt::ControlModifier) {
1168  struct bu_vls str = BU_VLS_INIT_ZERO;
1169  bu_vls_printf(&str, "<Control-Alt-ButtonPress-1> -x %d -y %d", mouseEv->x(), mouseEv->y());
1170  return bu_vls_addr(&str);
1171  }
1172  }
1173  return NULL;
1174 }
1175 
1176 char* qt_controlShiftMousePress(QEvent *event) {
1177  if (event->type() == QEvent::MouseButtonPress) {
1178  QMouseEvent *mouseEv = (QMouseEvent *)event;
1179  if (mouseEv->button() == Qt::LeftButton && mouseEv->modifiers() & Qt::ShiftModifier && mouseEv->modifiers() & Qt::ControlModifier) {
1180  struct bu_vls str = BU_VLS_INIT_ZERO;
1181  bu_vls_printf(&str, "<Shift-Alt-ButtonPress-1> -x %d -y %d", mouseEv->x(), mouseEv->y());
1182  return bu_vls_addr(&str);
1183  }
1184  }
1185  return NULL;
1186 }
1187 
1188 char* qt_mouseMove(QEvent *event) {
1189  if (event->type() == QEvent::MouseMove) {
1190  QMouseEvent *mouseEv = (QMouseEvent *)event;
1191  struct bu_vls str = BU_VLS_INIT_ZERO;
1192  bu_vls_printf(&str, "<Motion> -x %d -y %d", mouseEv->x(), mouseEv->y());
1193  return bu_vls_addr(&str);
1194  }
1195  return NULL;
1196 }
1197 
1198 char* qt_keyPress(QEvent *event) {
1199  /* FIXME numeric constant needs to be changed to QEvent::KeyPress but at this moment this does not compile */
1200  if (event->type() == 6 /* QEvent::KeyPress */) {
1201  QKeyEvent *keyEv = (QKeyEvent *)event;
1202  struct bu_vls str = BU_VLS_INIT_ZERO;
1203  bu_vls_printf(&str, "<KeyPress-%s>", keyEv->text().data());
1204  return bu_vls_addr(&str);
1205  }
1206  return NULL;
1207 }
1208 
1209 char* qt_keyRelease(QEvent *event) {
1210  /* FIXME numeric constant needs to be changed to QEvent::KeyRelease but at this moment this does not compile */
1211  if (event->type() == 7 /* QEvent::KeyRelease */) {
1212  QKeyEvent *keyEv = (QKeyEvent *)event;
1213  struct bu_vls str = BU_VLS_INIT_ZERO;
1214  bu_vls_printf(&str, "<KeyRelease-%s>", keyEv->text().data());
1215  return bu_vls_addr(&str);
1216  }
1217  return NULL;
1218 }
1219 
1220 static struct qt_tk_bind qt_bindings[] = {
1221  {qt_keyPress, "keypress"},
1222  {qt_keyRelease, "keyrelease"},
1223  {qt_controlMousePress, "controlbutton1"},
1224  {qt_altMousePress, "altbutton1"},
1225  {qt_altControlMousePress, "altcontrolbutton1"},
1226  {qt_controlShiftMousePress, "controlshiftbutton1"},
1227  {qt_mouseButton1Press, "button1press"},
1228  {qt_mouseButton1Release, "button1release"},
1229  {qt_mouseButton3Press, "button3press"},
1230  {qt_mouseButton3Release, "button3release"},
1231  {qt_mouseButton2Press, "button2press"},
1232  {qt_mouseButton2Release, "button2release"},
1233  {qt_mouseMove, "mouseMove"},
1234  {NULL, NULL}
1235 };
1236 
1237 /**
1238  * ===================================================== Main window class ===============================================
1239  */
1240 
1241 QTkMainWindow::QTkMainWindow(QPixmap *p, QWindow *win, void *d)
1242  : QWindow(win)
1243  , m_update_pending(false)
1244 {
1245  m_backingStore = new QBackingStore(this);
1246  create();
1247  pixmap = p;
1248  dmp = d;
1249 }
1250 
1251 QTkMainWindow::~QTkMainWindow()
1252 {
1253  delete m_backingStore;
1254  close();
1255 }
1256 
1257 void QTkMainWindow::exposeEvent(QExposeEvent *)
1258 {
1259  if (isExposed()) {
1260  renderNow();
1261  }
1262 }
1263 
1264 void QTkMainWindow::resizeEvent(QResizeEvent *resizeEv)
1265 {
1266  m_backingStore->resize(resizeEv->size());
1267  if (isExposed())
1268  renderNow();
1269 }
1270 
1271 bool QTkMainWindow::event(QEvent *ev)
1272 {
1273  int index = 0;
1274  if (ev->type() == QEvent::UpdateRequest) {
1275  m_update_pending = false;
1276  renderNow();
1277  return true;
1278  }
1279  while (qt_bindings[index].name != NULL) {
1280  char *tk_event = qt_bindings[index].bind_function(ev);
1281  if (tk_event != NULL) {
1282  struct bu_vls str = BU_VLS_INIT_ZERO;
1283  bu_vls_printf(&str, "event generate %s %s", bu_vls_addr(&((dm *)dmp)->dm_pathName), tk_event);
1284  if (Tcl_Eval(((dm *)dmp)->dm_interp, bu_vls_addr(&str)) == TCL_ERROR) {
1285  bu_log("error generate event %s\n", tk_event);
1286  }
1287  return true;
1288  }
1289  index++;
1290  }
1291  return QWindow::event(ev);
1292 }
1293 
1294 void QTkMainWindow::renderNow()
1295 {
1296  if (!isExposed()) {
1297  return;
1298  }
1299 
1300  QRect rect(0, 0, width(), height());
1301  m_backingStore->beginPaint(rect);
1302 
1303  QPaintDevice *device = m_backingStore->paintDevice();
1304  QPainter painter(device);
1305 
1306  render(&painter);
1307 
1308  m_backingStore->endPaint();
1309  m_backingStore->flush(rect);
1310 }
1311 
1312 void QTkMainWindow::render(QPainter *painter)
1313 {
1314  painter->drawPixmap(0, 0, *pixmap);
1315 }
1316 
1317 #endif /* DM_QT */
1318 /*
1319  * Local Variables:
1320  * mode: C++
1321  * tab-width: 8
1322  * indent-tabs-mode: t
1323  * c-file-style: "stroustrup"
1324  * End:
1325  * ex: shiftwidth=4 tabstop=8
1326  */
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 devbuttonpress
Definition: dm_xvars.h:82
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
void * data
Definition: fb.h:176
fb * fbp
Framebuffer associated with this display instance.
Definition: dm_private.h:120
int dm_get_width(dm *dmp)
Definition: dm-generic.c:335
int cmd[BN_VLIST_CHUNK]
VL_CMD_*.
Definition: vlist.h:74
#define GED_TO_Xx(_dmp, x)
Definition: dm.h:61
Tk_Window xtkwin
Definition: dm_xvars.h:65
Definition: clone.c:90
int dm_Normal2Xx(dm *dmp, fastf_t f)
Definition: dm-generic.c:216
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
dm dm_qt
void bu_vls_strncpy(struct bu_vls *vp, const char *s, size_t n)
Definition: vls.c:339
HIDDEN int qt_close(fb *ifp)
Definition: if_qt.cpp:957
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
struct fb_platform_specific * fb_get_platform_specific(uint32_t magic)
Definition: fb_generic.c:113
token
Definition: exists.c:65
#define BN_VLIST_POLY_MOVE
move to first poly vertex
Definition: vlist.h:85
#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
if(share_geom)
Definition: nmg_mod.c:3829
void bu_vls_free(struct bu_vls *vp)
Definition: vls.c:248
Definition: color.c:49
COMPLEX data[64]
Definition: fftest.c:34
int null_drawLine3D(struct dm_internal *dmp, point_t pt1, point_t pt2)
Definition: dm-Null.c:94
#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
HIDDEN int qt_open(fb *ifp, const char *file, int width, int height)
Definition: if_qt.cpp:720
struct bu_vls dm_log
!NULL && !empty means log debug output to the file
Definition: dm_private.h:110
#define __BEGIN_DECLS
Definition: common.h:73
#define FB_QT_MAGIC
Definition: magic.h:185
void bu_vls_sprintf(struct bu_vls *vls, const char *fmt,...) _BU_ATTR_PRINTF23
Definition: vls.c:707
#define BN_VLIST_POLY_START
pt[] has surface normal
Definition: vlist.h:84
int devmotionnotify
Definition: dm_xvars.h:81
#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
Tk_Window top
Definition: dm_xvars.h:64
size_t bu_vls_strlen(const struct bu_vls *vp)
Definition: vls.c:189
int devbuttonrelease
Definition: dm_xvars.h:83
#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
int dm_get_height(dm *dmp)
Definition: dm-generic.c:342
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_make_current(dm *dmp)
Definition: dm-generic.c:448
Display * dpy
Definition: dm_xvars.h:62
int dm_lineWidth
Definition: dm_private.h:95
#define BU_STRUCTPARSE_FUNC_NULL
Definition: parse.h:153
ustring alpha
void * Tk_Window
Definition: dm_xvars.h:44
Window win
Definition: dm_xvars.h:63
#define BN_VLIST_TRI_START
pt[] has surface normal
Definition: vlist.h:89
fb * fb_open_existing(const char *file, int _width, int _height, struct fb_platform_specific *fb_p)
Definition: fb_generic.c:146
#define BN_VLIST_POINT_SIZE
specify point pixel size
Definition: vlist.h:95
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
int dm_set_win_bounds(dm *dmp, fastf_t *w)
Definition: dm-generic.c:484
void null_drawDList(unsigned int list)
Definition: dm-Null.c:239
int null_drawLines3D(struct dm_internal *dmp, int npoints, point_t *points, int sflag)
Definition: dm-Null.c:101
#define BN_VLIST_POLY_END
last vert (repeats 1st), draw poly
Definition: vlist.h:87
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 __END_DECLS
Definition: common.h:74
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_drawPoints3D(struct dm_internal *dmp, int npoints, point_t *points)
Definition: dm-Null.c:122
#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
double fastf_t
Definition: defines.h:300
#define GED_TO_Xy(_dmp, x)
Definition: dm.h:62
#define DM_TYPE_QT
Definition: dm.h:103
int dm_lineStyle
Definition: dm_private.h:96
void * dm_interp(dm *dmp)
Definition: dm-generic.c:162
Definition: color.c:50
void fb_put_platform_specific(struct fb_platform_specific *fb_p)
Definition: fb_generic.c:129
#define BN_VLIST_POINT_DRAW
Draw a single point.
Definition: vlist.h:94
#define BN_VLIST_TRI_MOVE
move to first triangle vertex
Definition: vlist.h:90