BRL-CAD
dm.h
Go to the documentation of this file.
1 /* D M . H
2  * BRL-CAD
3  *
4  * Copyright (c) 1993-2024 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 /** @addtogroup libdm */
21 /** @{ */
22 /** @file dm.h
23  *
24  */
25 
26 #ifndef DM_H
27 #define DM_H
28 
29 #include "common.h"
30 
31 #include "vmath.h"
32 #include "bu/vls.h"
33 #include "bn.h"
34 #include "bv.h"
35 #include "icv.h"
36 
37 #include "./dm/defines.h"
38 #include "./dm/fbserv.h"
39 #include "./dm/util.h"
40 #include "./dm/view.h"
41 
42 __BEGIN_DECLS
43 
44 #define DM_NULL (struct dm *)NULL
45 
46 /* the font used depends on the size of the window opened */
47 #define FONTBACK "-adobe-courier-medium-r-normal--10-100-75-75-m-60-iso8859-1"
48 #define FONT5 "5x7"
49 #define FONT6 "6x10"
50 #define FONT7 "7x13"
51 #define FONT8 "8x13"
52 #define FONT9 "9x15"
53 #define FONT10 "10x20"
54 #define FONT12 "12x24"
55 
56 #if defined(_WIN32) && !defined(__CYGWIN__)
57 # define DM_VALID_FONT_SIZE(_size) (14 <= (_size) && (_size) <= 29)
58 #else
59 # define DM_VALID_FONT_SIZE(_size) (5 <= (_size) && (_size) <= 12 && (_size) != 11)
60 # define DM_FONT_SIZE_TO_NAME(_size) (((_size) == 5) ? FONT5 : (((_size) == 6) ? FONT6 : (((_size) == 7) ? FONT7 : (((_size) == 8) ? FONT8 : (((_size) == 9) ? FONT9 : (((_size) == 10) ? FONT10 : FONT12))))))
61 #endif
62 
63 /* This is how a parent application can pass a generic
64  * hook function in when setting dm variables. The dm_hook_data
65  * container holds the bu_structparse hook function and data
66  * needed by it in the dm_hook and dm_hook_data slots. When
67  * bu_struct_parse or one of the other libbu structure parsing
68  * functions is called, the dm_hook_data container is passed
69  * in as the data slot in that call.
70  *
71  * TODO - need example
72  *
73  */
74 struct dm_hook_data {
75  void(*dm_hook)(const struct bu_structparse *, const char *, void *, const char *, void *);
76  void *dmh_data;
77 };
78 
79 DM_EXPORT extern struct dm dm_null;
80 
81 DM_EXPORT extern void *dm_interp(struct dm *dmp);
82 DM_EXPORT extern void *dm_get_ctx(struct dm *dmp);
83 DM_EXPORT extern void *dm_get_udata(struct dm *dmp);
84 DM_EXPORT extern void dm_set_udata(struct dm *dmp, void *udata);
85 DM_EXPORT extern int dm_share_dlist(struct dm *dmp1,
86  struct dm *dmp2);
87 DM_EXPORT extern fastf_t dm_Xx2Normal(struct dm *dmp,
88  int x);
89 DM_EXPORT extern int dm_Normal2Xx(struct dm *dmp,
90  fastf_t f);
91 DM_EXPORT extern fastf_t dm_Xy2Normal(struct dm *dmp,
92  int y,
93  int use_aspect);
94 DM_EXPORT extern int dm_Normal2Xy(struct dm *dmp,
96  int use_aspect);
97 DM_EXPORT extern void dm_fogHint(struct dm *dmp,
98  int fastfog);
99 DM_EXPORT extern int dm_processOptions(struct dm *dmp, struct bu_vls *init_proc_vls, int argc, const char **argv);
100 DM_EXPORT extern int dm_limit(int i);
101 DM_EXPORT extern int dm_unlimit(int i);
102 DM_EXPORT extern fastf_t dm_wrap(fastf_t f);
103 
104 /* adc.c */
105 DM_EXPORT extern void dm_draw_adc(struct dm *dmp,
106  struct bv_adc_state *adcp, mat_t view2model, mat_t model2view);
107 
108 /* axes.c */
109 DM_EXPORT extern void dm_draw_data_axes(struct dm *dmp,
110  fastf_t viewSize,
111  struct bv_data_axes_state *bndasp);
112 
113 DM_EXPORT extern void dm_draw_scene_axes(struct dm *dmp, struct bv_scene_obj *s);
114 
115 
116 DM_EXPORT extern void dm_draw_hud_axes(struct dm *dmp,
117  fastf_t viewSize,
118  const mat_t rmat,
119  struct bv_axes *bnasp);
120 
121 /* clip.c */
122 DM_EXPORT extern int clip(fastf_t *,
124  fastf_t *,
125  fastf_t *);
126 DM_EXPORT extern int vclip(point_t,
128  fastf_t *,
129  fastf_t *);
130 
131 /* grid.c */
132 DM_EXPORT extern void dm_draw_grid(struct dm *dmp,
133  struct bv_grid_state *ggsp,
134  fastf_t scale,
135  mat_t model2view,
136  fastf_t base2local);
137 
138 /* labels.c */
139 #ifdef DM_WITH_RT
140 #include "raytrace.h"
141 DM_EXPORT extern int dm_draw_prim_labels(struct dm *dmp,
142  struct rt_wdb *wdbp,
143  const char *name,
144  mat_t viewmat,
145  int *labelsColor,
146  int (*labelsHook)(struct dm *dmp_arg, struct rt_wdb *wdbp_arg,
147  const char *name_arg, mat_t viewmat_arg,
148  int *labelsColor_arg, void *labelsHookClientdata_arg),
149  void *labelsHookClientdata);
150 #endif
151 
152 /* rect.c */
153 DM_EXPORT extern void dm_draw_rect(struct dm *dmp,
155 
156 /* scale.c */
157 DM_EXPORT extern void dm_draw_scale(struct dm *dmp,
158  fastf_t viewSize,
159  const char *unit,
160  int *lineColor,
161  int *textColor);
162 
163 /* vers.c */
164 DM_EXPORT extern const char *dm_version(void);
165 
166 
167 /* Plugin related functions */
168 DM_EXPORT extern int dm_valid_type(const char *name, const char *dpy_string);
169 DM_EXPORT const char * dm_init_msgs(void);
170 DM_EXPORT extern struct dm *dm_open(void *ctx,
171  void *interp,
172  const char *type,
173  int argc,
174  const char *argv[]);
175 DM_EXPORT extern void dm_list_types(struct bu_vls *list, const char *separator);
176 DM_EXPORT const char *dm_bestXType(const char *dpy_string);
177 DM_EXPORT extern int dm_have_graphics(void);
178 
179 /* This reports the graphics system associated with the specified dm type (returned values
180  * right now would be NULL, Tk or Qt - another eventual possibility is GLFW...) */
181 DM_EXPORT extern const char *dm_graphics_system(const char *dmtype);
182 
183 /* functions to make a dm struct hideable - will need to
184  * sort these out later */
185 
186 DM_EXPORT extern const char *dm_get_dm_name(const struct dm *dmp);
187 DM_EXPORT extern const char *dm_get_dm_lname(struct dm *dmp);
188 DM_EXPORT extern const char *dm_get_graphics_system(const struct dm *dmp);
189 DM_EXPORT extern int dm_get_width(struct dm *dmp);
190 DM_EXPORT extern int dm_get_height(struct dm *dmp);
191 DM_EXPORT extern void dm_set_width(struct dm *dmp, int width);
192 DM_EXPORT extern void dm_set_height(struct dm *dmp, int height);
193 DM_EXPORT extern void dm_geometry_request(struct dm *dmp, int width, int height);
194 DM_EXPORT extern void dm_internal_var(struct bu_vls *result, struct dm *dmp, const char *key); // ick
195 DM_EXPORT extern fastf_t dm_get_aspect(struct dm *dmp);
196 DM_EXPORT extern int dm_graphical(const struct dm *dmp);
197 DM_EXPORT extern const char *dm_get_type(struct dm *dmp);
198 DM_EXPORT extern unsigned long dm_get_id(struct dm *dmp);
199 DM_EXPORT extern void dm_set_id(struct dm *dmp, unsigned long new_id);
200 DM_EXPORT extern int dm_get_displaylist(struct dm *dmp);
201 DM_EXPORT extern int dm_close(struct dm *dmp);
202 DM_EXPORT extern int dm_get_bg(unsigned char **bg1, unsigned char **bg2, struct dm *dmp);
203 DM_EXPORT extern int dm_set_bg(struct dm *dmp, unsigned char r1, unsigned char g1, unsigned char b1, unsigned char r2, unsigned char g2, unsigned char b2);
204 DM_EXPORT extern unsigned char *dm_get_fg(struct dm *dmp);
205 DM_EXPORT extern int dm_set_fg(struct dm *dmp, unsigned char r, unsigned char g, unsigned char b, int strict, fastf_t transparency);
206 DM_EXPORT extern int dm_reshape(struct dm *dmp, int width, int height);
207 DM_EXPORT extern int dm_make_current(struct dm *dmp);
208 DM_EXPORT extern int dm_doevent(struct dm *dmp, void *clientData, void *eventPtr);
209 DM_EXPORT extern int dm_get_dirty(struct dm *dmp);
210 DM_EXPORT extern void dm_set_dirty(struct dm *dmp, int i);
211 DM_EXPORT extern vect_t *dm_get_clipmin(struct dm *dmp);
212 DM_EXPORT extern vect_t *dm_get_clipmax(struct dm *dmp);
213 DM_EXPORT extern int dm_get_stereo(struct dm *dmp);
214 DM_EXPORT extern int dm_set_win_bounds(struct dm *dmp, fastf_t *w);
215 DM_EXPORT extern int dm_configure_win(struct dm *dmp, int force);
216 DM_EXPORT extern struct bu_vls *dm_get_pathname(struct dm *dmp);
217 DM_EXPORT extern void dm_set_pathname(struct dm *dmp, const char *pname);
218 DM_EXPORT extern struct bu_vls *dm_get_dname(struct dm *dmp);
219 DM_EXPORT extern const char *dm_get_name(const struct dm *dmp);
220 DM_EXPORT extern struct bu_vls *dm_get_tkname(struct dm *dmp);
221 DM_EXPORT extern int dm_get_fontsize(struct dm *dmp);
222 DM_EXPORT extern void dm_set_fontsize(struct dm *dmp, int size);
223 
224 DM_EXPORT extern int dm_get_linewidth(struct dm *dmp);
225 DM_EXPORT extern void dm_set_linewidth(struct dm *dmp, int linewidth);
226 DM_EXPORT extern int dm_get_linestyle(struct dm *dmp);
227 DM_EXPORT extern void dm_set_linestyle(struct dm *dmp, int linestyle);
228 DM_EXPORT extern int dm_get_perspective(struct dm *dmp);
229 DM_EXPORT extern void dm_set_perspective(struct dm *dmp, fastf_t perspective);
230 DM_EXPORT extern int dm_get_display_image(struct dm *dmp, unsigned char **image, int flip, int alpha);
231 DM_EXPORT extern int dm_draw_vlist(struct dm *dmp, struct bv_vlist *vp);
232 DM_EXPORT extern int dm_draw_vlist_hidden_line(struct dm *dmp, struct bv_vlist *vp);
233 DM_EXPORT extern int dm_set_line_attr(struct dm *dmp, int width, int style);
234 DM_EXPORT extern int dm_draw_begin(struct dm *dmp);
235 DM_EXPORT extern int dm_draw_end(struct dm *dmp);
236 DM_EXPORT extern int dm_hud_begin(struct dm *dmp);
237 DM_EXPORT extern int dm_hud_end(struct dm *dmp);
238 DM_EXPORT extern int dm_loadmatrix(struct dm *dmp, fastf_t *mat, int eye);
239 DM_EXPORT extern int dm_loadpmatrix(struct dm *dmp, const fastf_t *mat);
240 DM_EXPORT extern void dm_pop_pmatrix(struct dm *dmp);
241 DM_EXPORT extern int dm_draw_string_2d(struct dm *dmp, const char *str, fastf_t x, fastf_t y, int size, int use_aspect);
242 DM_EXPORT extern int dm_string_bbox_2d(struct dm *dmp, vect2d_t *bmin, vect2d_t *bmax, const char *str, fastf_t x, fastf_t y, int size, int use_aspect);
243 DM_EXPORT extern int dm_draw_line_2d(struct dm *dmp, fastf_t x1, fastf_t y1_2d, fastf_t x2, fastf_t y2);
244 DM_EXPORT extern int dm_draw_line_3d(struct dm *dmp, point_t pt1, point_t pt2);
245 DM_EXPORT extern int dm_draw_lines_3d(struct dm *dmp, int npoints, point_t *points, int sflag);
246 DM_EXPORT extern int dm_draw_point_2d(struct dm *dmp, fastf_t x, fastf_t y);
247 DM_EXPORT extern int dm_draw_point_3d(struct dm *dmp, point_t pt);
248 DM_EXPORT extern int dm_draw_points_3d(struct dm *dmp, int npoints, point_t *points);
249 DM_EXPORT extern int dm_draw(struct dm *dmp, struct bv_vlist *(*callback)(void *), void **data);
250 DM_EXPORT extern int dm_set_depth_mask(struct dm *dmp, int d_on);
251 DM_EXPORT extern int dm_set_debug(struct dm *dmp, int lvl);
252 DM_EXPORT extern int dm_get_debug(struct dm *dmp);
253 DM_EXPORT extern int dm_logfile(struct dm *dmp, const char *filename);
254 DM_EXPORT extern struct fb *dm_get_fb(struct dm *dmp);
255 DM_EXPORT extern int dm_get_fb_visible(struct dm *dmp);
256 DM_EXPORT extern int dm_set_fb_visible(struct dm *dmp, int is_fb_visible);
257 
258 
259 /* Variables modifiable by dm get/set commands, as well as C functions */
260 DM_EXPORT extern int dm_get_light(struct dm *dmp);
261 DM_EXPORT extern int dm_set_light(struct dm *dmp, int light);
262 DM_EXPORT extern int dm_get_transparency(struct dm *dmp);
263 DM_EXPORT extern int dm_set_transparency(struct dm *dmp, int transparency);
264 DM_EXPORT extern int dm_get_zbuffer(struct dm *dmp);
265 DM_EXPORT extern int dm_set_zbuffer(struct dm *dmp, int zbuffer);
266 DM_EXPORT extern int dm_get_zclip(struct dm *dmp);
267 DM_EXPORT extern void dm_set_zclip(struct dm *dmp, int zclip);
268 DM_EXPORT extern fastf_t dm_get_bound(struct dm *dmp);
269 DM_EXPORT extern void dm_set_bound(struct dm *dmp, fastf_t val);
270 DM_EXPORT extern int dm_get_bound_flag(struct dm *dmp);
271 DM_EXPORT extern void dm_set_bound_flag(struct dm *dmp, int bound);
272 
273 
274 
275 DM_EXPORT extern int dm_draw_obj(struct dm *dmp, struct bv_scene_obj *s);
276 
277 
278 /* Rather low level exposure of display list concepts. Needed for MGED
279  * and libtclcad, but we want to get to a point where the use (or not)
280  * of display lists is an implementation level action rather than something
281  * visible to the user. */
282 DM_EXPORT extern int dm_gen_dlists(struct dm *dmp, size_t range);
283 DM_EXPORT extern int dm_begin_dlist(struct dm *dmp, unsigned int list);
284 DM_EXPORT extern int dm_draw_dlist(struct dm *dmp, unsigned int list);
285 DM_EXPORT extern int dm_end_dlist(struct dm *dmp);
286 DM_EXPORT extern int dm_free_dlists(struct dm *dmp, unsigned int list, int range);
287 DM_EXPORT extern int dm_draw_display_list(struct dm *dmp, struct display_list *obj);
288 DM_EXPORT extern int dm_draw_head_dl(struct dm *dmp,
289  struct bu_list *dl,
290  fastf_t transparency_threshold,
291  fastf_t inv_viewsize,
292  short r, short g, short b,
293  int line_width,
294  int draw_style,
295  int draw_edit,
296  unsigned char *gdc,
297  int solids_down,
298  int mv_dlist
299  );
300 
301 // TODO - this should be using libicv - right now this is just moving the guts
302 // of dmo_png_cmd behind the call table, so only provides PNG...
303 DM_EXPORT extern int dm_write_image(struct bu_vls *msgs, FILE *fp, struct dm *dmp);
304 
305 DM_EXPORT extern void dm_flush(struct dm *dmp);
306 DM_EXPORT extern void dm_sync(struct dm *dmp);
307 
308 // Return 1 if same, 0 if different and -1 if no dmp available
309 typedef enum {
314 DM_EXPORT extern int dm_event_cmp(struct dm *dmp, dm_event_t type, int event);
315 
316 /* TODO - dm_vp is supposed to go away, but until we figure it out
317  * expose it here to allow dm hiding */
318 DM_EXPORT extern void dm_set_vp(struct dm *dmp, fastf_t *vp);
319 
320 DM_EXPORT extern int dm_set_hook(const struct bu_structparse_map *map,
321  const char *key, void *data, struct dm_hook_data *hook);
322 
323 DM_EXPORT extern struct bu_structparse *dm_get_vparse(struct dm *dmp);
324 DM_EXPORT extern void *dm_get_mvars(struct dm *dmp);
325 
326 DM_EXPORT extern const char *dm_default_type(void);
327 
328 /*
329  * Needed for fd_set, avoid including sys/select.h outright since it
330  * conflicts on some systems (e.g. freebsd4).
331  *
332  * FIXME: would be nice to decouple this interface from fd_set as it's
333  * only used in one place right now.
334  */
335 #if defined(HAVE_SYS_TYPES_H)
336 # include <sys/types.h>
337 #endif
338 #if defined(HAVE_SYS_TIME_H)
339 # include <sys/time.h>
340 #endif
341 #include <stdio.h> /* for FILE */
342 
343 #include "bsocket.h"
344 
345 #include "pkg.h"
346 #include "bu/magic.h"
347 #include "bu/vls.h"
348 
349 /**
350  * Format of disk pixels is .pix raw image files. Formerly used as
351  * arguments to many of the library routines, but has fallen into
352  * disuse due to the difficulties with ANSI function prototypes, and
353  * the fact that arrays are not real types in C. The most notable
354  * problem is that of passing a pointer to an array of RGBpixel. It
355  * looks doubly dimensioned, but isn't.
356  */
357 typedef unsigned char RGBpixel[3];
358 
359 
360 /**
361  * These generic color maps have up to 16 bits of significance,
362  * left-justified in a short. Think of this as fixed-point values
363  * from 0 to 1.
364  */
365 typedef struct {
366  unsigned short cm_red[256];
367  unsigned short cm_green[256];
368  unsigned short cm_blue[256];
370 
371 
372 #define PIXEL_NULL (unsigned char *) 0
373 #define RGBPIXEL_NULL (unsigned char *) 0
374 #define COLORMAP_NULL (ColorMap *) 0
375 
376 #define FB_NULL (struct fb *) 0
377 
378 /**
379  * assert the integrity of a framebuffer struct.
380  */
381 #define FB_CK_FB(_p) BU_CKMAG(_p, FB_MAGIC, "FB")
382 
383 /* Library entry points */
384 
385 DM_EXPORT struct fb *fb_get(void);
386 DM_EXPORT struct fb *fb_raw(const char *type);
387 DM_EXPORT void fb_put(struct fb *ifp);
388 DM_EXPORT struct dm *fb_get_dm(struct fb *ifp);
389 DM_EXPORT extern const char *fb_gettype(struct fb *ifp);
390 DM_EXPORT extern void fb_set_standalone(struct fb *ifp, int val);
391 DM_EXPORT extern int fb_get_standalone(struct fb *ifp);
392 DM_EXPORT extern int fb_get_max_width(struct fb *ifp);
393 DM_EXPORT extern int fb_get_max_height(struct fb *ifp);
394 DM_EXPORT extern int fb_getwidth(struct fb *ifp);
395 DM_EXPORT extern int fb_getheight(struct fb *ifp);
396 DM_EXPORT extern int fb_poll(struct fb *ifp);
397 /* Returns in microseconds the maximum recommended amount of time to linger
398  * before polling for updates for a specific framebuffer instance (can be
399  * implementation dependent.) Zero means the fb_poll process does nothing
400  * (for example, the NULL fb). */
401 DM_EXPORT extern long fb_poll_rate(struct fb *ifp);
402 DM_EXPORT extern int fb_help(struct fb *ifp);
403 DM_EXPORT extern int fb_free(struct fb *ifp);
404 DM_EXPORT extern int fb_clear(struct fb *ifp, unsigned char *pp);
405 DM_EXPORT extern ssize_t fb_read(struct fb *ifp, int x, int y, unsigned char *pp, size_t count);
406 DM_EXPORT extern ssize_t fb_write(struct fb *ifp, int x, int y, const unsigned char *pp, size_t count);
407 DM_EXPORT extern int fb_rmap(struct fb *ifp, ColorMap *cmap);
408 DM_EXPORT extern int fb_wmap(struct fb *ifp, const ColorMap *cmap);
409 DM_EXPORT extern int fb_view(struct fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom);
410 DM_EXPORT extern int fb_getview(struct fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom);
411 DM_EXPORT extern int fb_setcursor(struct fb *ifp, const unsigned char *bits, int xb, int yb, int xo, int yo);
412 DM_EXPORT extern int fb_cursor(struct fb *ifp, int mode, int x, int y);
413 DM_EXPORT extern int fb_getcursor(struct fb *ifp, int *mode, int *x, int *y);
414 DM_EXPORT extern int fb_readrect(struct fb *ifp, int xmin, int ymin, int width, int height, unsigned char *pp);
415 DM_EXPORT extern int fb_writerect(struct fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp);
416 DM_EXPORT extern int fb_bwreadrect(struct fb *ifp, int xmin, int ymin, int width, int height, unsigned char *pp);
417 DM_EXPORT extern int fb_bwwriterect(struct fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp);
418 
419 DM_EXPORT extern struct fb *fb_open(const char *file, int _width, int _height);
420 DM_EXPORT extern int fb_close(struct fb *ifp);
421 DM_EXPORT extern int fb_close_existing(struct fb *ifp);
422 DM_EXPORT extern int fb_genhelp(void);
423 DM_EXPORT extern int fb_ioinit(struct fb *ifp);
424 DM_EXPORT extern int fb_seek(struct fb *ifp, int x, int y);
425 DM_EXPORT extern int fb_tell(struct fb *ifp, int *xp, int *yp);
426 DM_EXPORT extern int fb_rpixel(struct fb *ifp, unsigned char *pp);
427 DM_EXPORT extern int fb_wpixel(struct fb *ifp, unsigned char *pp);
428 DM_EXPORT extern int fb_flush(struct fb *ifp);
429 DM_EXPORT extern int fb_configure_window(struct fb *, int, int);
430 DM_EXPORT extern int fb_refresh(struct fb *ifp, int x, int y, int w, int h);
431 #if !defined(_WIN32) || defined(__CYGWIN__)
432 DM_EXPORT extern void fb_log(const char *fmt, ...) _BU_ATTR_PRINTF12;
433 #endif
434 DM_EXPORT extern int fb_null(struct fb *ifp);
435 DM_EXPORT extern int fb_null_setcursor(struct fb *ifp, const unsigned char *bits, int xbits, int ybits, int xorig, int yorig);
436 
437 /* utility functions */
438 DM_EXPORT extern int fb_common_file_size(size_t *widthp, size_t *heightp, const char *filename, int pixel_size);
439 DM_EXPORT extern int fb_common_image_size(size_t *widthp, size_t *heightp, size_t npixels);
440 DM_EXPORT extern int fb_common_name_size(size_t *widthp, size_t *heightp, const char *name);
441 DM_EXPORT extern int fb_write_fp(struct fb *ifp, FILE *fp, int req_width, int req_height, int crunch, int inverse, struct bu_vls *result);
442 DM_EXPORT extern int fb_read_fd(struct fb *ifp, int fd, int file_width, int file_height, int file_xoff, int file_yoff, int scr_width, int scr_height, int scr_xoff, int scr_yoff, int fileinput, char *file_name, int one_line_only, int multiple_lines, int autosize, int inverse, int clear, int zoom, struct bu_vls *result);
443 DM_EXPORT extern int fb_read_icv(struct fb *ifp, icv_image_t *img, int file_xoff, int file_yoff, int file_maxwidth, int file_maxheight, int scr_xoff, int scr_yoff, int clear, int zoom, int inverse, int one_line_only, int multiple_lines, struct bu_vls *result);
444 DM_EXPORT extern icv_image_t *fb_write_icv(struct fb *ifp, int scr_xoff, int scr_yoff, int width, int height);
445 DM_EXPORT extern int fb_read_png(struct fb *ifp, FILE *fp_in, int file_xoff, int file_yoff, int scr_xoff, int scr_yoff, int clear, int zoom, int inverse, int one_line_only, int multiple_lines, int verbose, int header_only, double def_screen_gamma, struct bu_vls *result);
446 
447 DM_EXPORT extern int fb_set_interface(struct fb *ifp, const char *interface_type);
448 DM_EXPORT extern const char *fb_get_name(const struct fb *ifp);
449 DM_EXPORT extern void fb_set_magic(struct fb *ifp, uint32_t magic);
450 DM_EXPORT extern long fb_get_pagebuffer_pixel_size(struct fb *ifp);
451 
452 DM_EXPORT extern int fb_is_set_fd(struct fb *ifp, fd_set *infds);
453 DM_EXPORT extern int fb_set_fd(struct fb *ifp, fd_set *select_list);
454 DM_EXPORT extern int fb_clear_fd(struct fb *ifp, fd_set *select_list);
455 
456 /* color mapping */
457 DM_EXPORT extern int fb_is_linear_cmap(const ColorMap *cmap);
458 DM_EXPORT extern void fb_make_linear_cmap(ColorMap *cmap);
459 
460 /* open_existing functionality. */
461 struct fb_platform_specific {uint32_t magic; void *data;};
462 DM_EXPORT extern struct fb_platform_specific *fb_get_platform_specific(uint32_t magic);
463 DM_EXPORT extern void fb_put_platform_specific(struct fb_platform_specific *fb_p);
464 DM_EXPORT extern struct fb *fb_open_existing(const char *file, int _width, int _height, struct fb_platform_specific *fb_p);
465 DM_EXPORT extern void fb_setup_existing(struct fb *fbp, int _width, int _height, struct fb_platform_specific *fb_p);
466 
467 /* backward compatibility hacks */
468 DM_EXPORT extern int fb_reset(struct fb *ifp);
469 DM_EXPORT extern int fb_viewport(struct fb *ifp, int left, int top, int right, int bottom);
470 DM_EXPORT extern int fb_window(struct fb *ifp, int xcenter, int ycenter);
471 DM_EXPORT extern int fb_zoom(struct fb *ifp, int xzoom, int yzoom);
472 DM_EXPORT extern int fb_scursor(struct fb *ifp, int mode, int x, int y);
473 
474 /*
475  * Copy one RGB pixel to another.
476  */
477 #define COPYRGB(to, from) { (to)[RED]=(from)[RED];\
478  (to)[GRN]=(from)[GRN];\
479  (to)[BLU]=(from)[BLU]; }
480 
481 /* Debug Bitvector Definition */
482 #define FB_DEBUG_BIO 1 /* Buffered io calls (less r/wpixel) */
483 #define FB_DEBUG_CMAP 2 /* Contents of colormaps */
484 #define FB_DEBUG_RW 4 /* Contents of reads and writes */
485 #define FB_DEBUG_BRW 8 /* Buffered IO rpixel and wpixel */
486 
487 /**
488  * report version information about LIBFB
489  */
490 DM_EXPORT extern const char *fb_version(void);
491 
492 
493 /* To avoid breaking things too badly, temporarily expose
494  * what is now internal API */
495 #ifdef EXPOSE_FB_HEADER
496 # include "../src/libfb/fb_private.h"
497 #endif
498 
499 typedef struct fb_internal FBIO;
500 
501 
502 /*
503  * Types of packages used for the remote frame buffer
504  * communication
505  */
506 #define MSG_FBOPEN 1
507 #define MSG_FBCLOSE 2
508 #define MSG_FBCLEAR 3
509 #define MSG_FBREAD 4
510 #define MSG_FBWRITE 5
511 #define MSG_FBCURSOR 6 /**< @brief fb_cursor(void) */
512 #define MSG_FBWINDOW 7 /**< @brief OLD */
513 #define MSG_FBZOOM 8 /**< @brief OLD */
514 #define MSG_FBSCURSOR 9 /**< @brief OLD */
515 #define MSG_FBVIEW 10 /**< @brief NEW */
516 #define MSG_FBGETVIEW 11 /**< @brief NEW */
517 #define MSG_FBRMAP 12
518 #define MSG_FBWMAP 13
519 #define MSG_FBHELP 14
520 #define MSG_FBREADRECT 15
521 #define MSG_FBWRITERECT 16
522 #define MSG_FBFLUSH 17
523 #define MSG_FBFREE 18
524 #define MSG_FBGETCURSOR 19 /**< @brief NEW */
525 #define MSG_FBPOLL 30 /**< @brief NEW */
526 #define MSG_FBSETCURSOR 31 /**< @brief NEW in Release 4.4 */
527 #define MSG_FBBWREADRECT 32 /**< @brief NEW in Release 4.6 */
528 #define MSG_FBBWWRITERECT 33 /**< @brief NEW in Release 4.6 */
529 
530 #define MSG_DATA 20
531 #define MSG_RETURN 21
532 #define MSG_CLOSE 22
533 #define MSG_ERROR 23
534 
535 #define MSG_NORETURN 100
536 
537 __END_DECLS
538 
539 #endif /* DM_H */
540 
541 /** @} */
542 /*
543  * Local Variables:
544  * mode: C
545  * tab-width: 8
546  * indent-tabs-mode: t
547  * c-file-style: "stroustrup"
548  * End:
549  * ex: shiftwidth=4 tabstop=8
550  */
Header file for the BRL-CAD Numerical Computation Library, LIBBN.
Header file for the BRL-CAD common definitions.
This header holds generic routines and data structures used for TCP based communication between a fra...
#define _BU_ATTR_PRINTF12
Definition: defines.h:90
void int int * yp
Definition: tig.h:209
void int float float float * scale
Definition: tig.h:142
void int * xp
Definition: tig.h:208
void float float * y
Definition: tig.h:73
void int char * mode
Definition: tig.h:179
void float float int int int int float * size
Definition: tig.h:132
void float * x
Definition: tig.h:72
long fb_poll_rate(struct fb *ifp)
int fb_reset(struct fb *ifp)
int dm_get_width(struct dm *dmp)
int dm_get_transparency(struct dm *dmp)
int dm_set_hook(const struct bu_structparse_map *map, const char *key, void *data, struct dm_hook_data *hook)
int dm_get_stereo(struct dm *dmp)
unsigned char * dm_get_fg(struct dm *dmp)
int dm_event_cmp(struct dm *dmp, dm_event_t type, int event)
int fb_close(struct fb *ifp)
void fb_put(struct fb *ifp)
struct fb * fb_raw(const char *type)
int fb_cursor(struct fb *ifp, int mode, int x, int y)
int dm_get_display_image(struct dm *dmp, unsigned char **image, int flip, int alpha)
int dm_free_dlists(struct dm *dmp, unsigned int list, int range)
void dm_set_fontsize(struct dm *dmp, int size)
struct fb_internal FBIO
Definition: dm.h:503
unsigned long dm_get_id(struct dm *dmp)
int fb_bwwriterect(struct fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
int dm_draw_obj(struct dm *dmp, struct bv_scene_obj *s)
int dm_get_linestyle(struct dm *dmp)
int dm_close(struct dm *dmp)
void dm_geometry_request(struct dm *dmp, int width, int height)
int dm_draw_point_2d(struct dm *dmp, fastf_t x, fastf_t y)
struct bu_structparse * dm_get_vparse(struct dm *dmp)
const char * fb_get_name(const struct fb *ifp)
void dm_set_bound(struct dm *dmp, fastf_t val)
struct fb * dm_get_fb(struct dm *dmp)
void dm_draw_rect(struct dm *dmp, struct bv_interactive_rect_state *grsp)
int dm_Normal2Xx(struct dm *dmp, fastf_t f)
int dm_get_zclip(struct dm *dmp)
void dm_set_vp(struct dm *dmp, fastf_t *vp)
void fb_log(const char *fmt,...) _BU_ATTR_PRINTF12
int fb_free(struct fb *ifp)
int dm_hud_begin(struct dm *dmp)
const char * dm_bestXType(const char *dpy_string)
int dm_gen_dlists(struct dm *dmp, size_t range)
void dm_flush(struct dm *dmp)
int fb_wmap(struct fb *ifp, const ColorMap *cmap)
fastf_t dm_Xy2Normal(struct dm *dmp, int y, int use_aspect)
int dm_draw_string_2d(struct dm *dmp, const char *str, fastf_t x, fastf_t y, int size, int use_aspect)
int dm_get_zbuffer(struct dm *dmp)
void dm_draw_hud_axes(struct dm *dmp, fastf_t viewSize, const mat_t rmat, struct bv_axes *bnasp)
struct fb * fb_open(const char *file, int _width, int _height)
int fb_view(struct fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
int dm_unlimit(int i)
int fb_is_set_fd(struct fb *ifp, fd_set *infds)
struct fb_platform_specific * fb_get_platform_specific(uint32_t magic)
struct bu_vls * dm_get_pathname(struct dm *dmp)
int fb_write_fp(struct fb *ifp, FILE *fp, int req_width, int req_height, int crunch, int inverse, struct bu_vls *result)
int dm_end_dlist(struct dm *dmp)
int dm_share_dlist(struct dm *dmp1, struct dm *dmp2)
int dm_set_bg(struct dm *dmp, unsigned char r1, unsigned char g1, unsigned char b1, unsigned char r2, unsigned char g2, unsigned char b2)
int dm_get_bound_flag(struct dm *dmp)
fastf_t dm_Xx2Normal(struct dm *dmp, int x)
const char * dm_graphics_system(const char *dmtype)
void dm_draw_scale(struct dm *dmp, fastf_t viewSize, const char *unit, int *lineColor, int *textColor)
void fb_set_standalone(struct fb *ifp, int val)
void dm_set_height(struct dm *dmp, int height)
int fb_window(struct fb *ifp, int xcenter, int ycenter)
void fb_make_linear_cmap(ColorMap *cmap)
int fb_null(struct fb *ifp)
void fb_put_platform_specific(struct fb_platform_specific *fb_p)
int dm_Normal2Xy(struct dm *dmp, fastf_t f, int use_aspect)
void dm_draw_adc(struct dm *dmp, struct bv_adc_state *adcp, mat_t view2model, mat_t model2view)
int dm_draw_vlist_hidden_line(struct dm *dmp, struct bv_vlist *vp)
void fb_setup_existing(struct fb *fbp, int _width, int _height, struct fb_platform_specific *fb_p)
int fb_setcursor(struct fb *ifp, const unsigned char *bits, int xb, int yb, int xo, int yo)
int dm_logfile(struct dm *dmp, const char *filename)
int dm_get_dirty(struct dm *dmp)
int dm_draw_line_2d(struct dm *dmp, fastf_t x1, fastf_t y1_2d, fastf_t x2, fastf_t y2)
int dm_draw_line_3d(struct dm *dmp, point_t pt1, point_t pt2)
int fb_writerect(struct fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
int fb_clear(struct fb *ifp, unsigned char *pp)
int dm_set_fg(struct dm *dmp, unsigned char r, unsigned char g, unsigned char b, int strict, fastf_t transparency)
int fb_common_image_size(size_t *widthp, size_t *heightp, size_t npixels)
int fb_read_fd(struct fb *ifp, int fd, int file_width, int file_height, int file_xoff, int file_yoff, int scr_width, int scr_height, int scr_xoff, int scr_yoff, int fileinput, char *file_name, int one_line_only, int multiple_lines, int autosize, int inverse, int clear, int zoom, struct bu_vls *result)
fastf_t dm_wrap(fastf_t f)
int dm_set_zbuffer(struct dm *dmp, int zbuffer)
int fb_clear_fd(struct fb *ifp, fd_set *select_list)
ssize_t fb_read(struct fb *ifp, int x, int y, unsigned char *pp, size_t count)
int fb_viewport(struct fb *ifp, int left, int top, int right, int bottom)
const char * dm_get_dm_lname(struct dm *dmp)
int dm_doevent(struct dm *dmp, void *clientData, void *eventPtr)
int dm_draw_lines_3d(struct dm *dmp, int npoints, point_t *points, int sflag)
long fb_get_pagebuffer_pixel_size(struct fb *ifp)
int dm_set_transparency(struct dm *dmp, int transparency)
void dm_set_linewidth(struct dm *dmp, int linewidth)
void * dm_get_udata(struct dm *dmp)
void * dm_interp(struct dm *dmp)
unsigned char RGBpixel[3]
Definition: dm.h:361
int dm_graphical(const struct dm *dmp)
int dm_begin_dlist(struct dm *dmp, unsigned int list)
void * dm_get_ctx(struct dm *dmp)
void dm_set_linestyle(struct dm *dmp, int linestyle)
int fb_configure_window(struct fb *, int, int)
int dm_set_depth_mask(struct dm *dmp, int d_on)
const char * fb_gettype(struct fb *ifp)
int dm_draw_begin(struct dm *dmp)
icv_image_t * fb_write_icv(struct fb *ifp, int scr_xoff, int scr_yoff, int width, int height)
int dm_get_light(struct dm *dmp)
int dm_set_line_attr(struct dm *dmp, int width, int style)
int fb_seek(struct fb *ifp, int x, int y)
int fb_close_existing(struct fb *ifp)
const char * dm_get_name(const struct dm *dmp)
vect_t * dm_get_clipmax(struct dm *dmp)
int fb_tell(struct fb *ifp, int *xp, int *yp)
int fb_getview(struct fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
int dm_draw_vlist(struct dm *dmp, struct bv_vlist *vp)
void dm_draw_data_axes(struct dm *dmp, fastf_t viewSize, struct bv_data_axes_state *bndasp)
void fb_set_magic(struct fb *ifp, uint32_t magic)
void dm_list_types(struct bu_vls *list, const char *separator)
int dm_loadpmatrix(struct dm *dmp, const fastf_t *mat)
int dm_get_fontsize(struct dm *dmp)
struct dm dm_null
void dm_draw_grid(struct dm *dmp, struct bv_grid_state *ggsp, fastf_t scale, mat_t model2view, fastf_t base2local)
int dm_make_current(struct dm *dmp)
int fb_help(struct fb *ifp)
int dm_get_linewidth(struct dm *dmp)
int dm_set_fb_visible(struct dm *dmp, int is_fb_visible)
int dm_hud_end(struct dm *dmp)
void dm_internal_var(struct bu_vls *result, struct dm *dmp, const char *key)
int fb_genhelp(void)
int dm_draw_point_3d(struct dm *dmp, point_t pt)
void dm_sync(struct dm *dmp)
int fb_get_max_width(struct fb *ifp)
fastf_t dm_get_aspect(struct dm *dmp)
int dm_get_perspective(struct dm *dmp)
int fb_read_png(struct fb *ifp, FILE *fp_in, int file_xoff, int file_yoff, int scr_xoff, int scr_yoff, int clear, int zoom, int inverse, int one_line_only, int multiple_lines, int verbose, int header_only, double def_screen_gamma, struct bu_vls *result)
const char * dm_default_type(void)
struct fb * fb_get(void)
void dm_set_perspective(struct dm *dmp, fastf_t perspective)
struct fb * fb_open_existing(const char *file, int _width, int _height, struct fb_platform_specific *fb_p)
int dm_processOptions(struct dm *dmp, struct bu_vls *init_proc_vls, int argc, const char **argv)
int fb_refresh(struct fb *ifp, int x, int y, int w, int h)
int dm_draw_end(struct dm *dmp)
int fb_scursor(struct fb *ifp, int mode, int x, int y)
struct dm * dm_open(void *ctx, void *interp, const char *type, int argc, const char *argv[])
void dm_set_width(struct dm *dmp, int width)
int fb_set_interface(struct fb *ifp, const char *interface_type)
int dm_draw_dlist(struct dm *dmp, unsigned int list)
int dm_have_graphics(void)
int fb_ioinit(struct fb *ifp)
int fb_getheight(struct fb *ifp)
const char * dm_get_dm_name(const struct dm *dmp)
void dm_set_udata(struct dm *dmp, void *udata)
int fb_getcursor(struct fb *ifp, int *mode, int *x, int *y)
int vclip(point_t, point_t, fastf_t *, fastf_t *)
int fb_get_standalone(struct fb *ifp)
int fb_read_icv(struct fb *ifp, icv_image_t *img, int file_xoff, int file_yoff, int file_maxwidth, int file_maxheight, int scr_xoff, int scr_yoff, int clear, int zoom, int inverse, int one_line_only, int multiple_lines, struct bu_vls *result)
int fb_rpixel(struct fb *ifp, unsigned char *pp)
void * dm_get_mvars(struct dm *dmp)
int dm_draw_display_list(struct dm *dmp, struct display_list *obj)
void dm_fogHint(struct dm *dmp, int fastfog)
void dm_set_zclip(struct dm *dmp, int zclip)
const char * dm_get_type(struct dm *dmp)
int dm_get_debug(struct dm *dmp)
int clip(fastf_t *, fastf_t *, fastf_t *, fastf_t *)
int fb_poll(struct fb *ifp)
int fb_null_setcursor(struct fb *ifp, const unsigned char *bits, int xbits, int ybits, int xorig, int yorig)
int fb_common_file_size(size_t *widthp, size_t *heightp, const char *filename, int pixel_size)
int dm_set_debug(struct dm *dmp, int lvl)
int fb_common_name_size(size_t *widthp, size_t *heightp, const char *name)
int fb_flush(struct fb *ifp)
int fb_set_fd(struct fb *ifp, fd_set *select_list)
int fb_readrect(struct fb *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
int dm_get_bg(unsigned char **bg1, unsigned char **bg2, struct dm *dmp)
void dm_pop_pmatrix(struct dm *dmp)
int dm_set_light(struct dm *dmp, int light)
struct dm * fb_get_dm(struct fb *ifp)
void dm_set_id(struct dm *dmp, unsigned long new_id)
const char * fb_version(void)
int dm_reshape(struct dm *dmp, int width, int height)
struct bu_vls * dm_get_tkname(struct dm *dmp)
int dm_draw(struct dm *dmp, struct bv_vlist *(*callback)(void *), void **data)
int dm_draw_points_3d(struct dm *dmp, int npoints, point_t *points)
vect_t * dm_get_clipmin(struct dm *dmp)
int dm_set_win_bounds(struct dm *dmp, fastf_t *w)
const char * dm_init_msgs(void)
int dm_get_height(struct dm *dmp)
void dm_set_bound_flag(struct dm *dmp, int bound)
void dm_draw_scene_axes(struct dm *dmp, struct bv_scene_obj *s)
const char * dm_version(void)
int fb_rmap(struct fb *ifp, ColorMap *cmap)
int dm_configure_win(struct dm *dmp, int force)
int dm_get_fb_visible(struct dm *dmp)
void dm_set_dirty(struct dm *dmp, int i)
int fb_get_max_height(struct fb *ifp)
int fb_is_linear_cmap(const ColorMap *cmap)
int dm_loadmatrix(struct dm *dmp, fastf_t *mat, int eye)
int dm_string_bbox_2d(struct dm *dmp, vect2d_t *bmin, vect2d_t *bmax, const char *str, fastf_t x, fastf_t y, int size, int use_aspect)
int dm_get_displaylist(struct dm *dmp)
struct bu_vls * dm_get_dname(struct dm *dmp)
int dm_limit(int i)
dm_event_t
Definition: dm.h:311
int fb_wpixel(struct fb *ifp, unsigned char *pp)
int fb_zoom(struct fb *ifp, int xzoom, int yzoom)
ssize_t fb_write(struct fb *ifp, int x, int y, const unsigned char *pp, size_t count)
int dm_draw_head_dl(struct dm *dmp, struct bu_list *dl, fastf_t transparency_threshold, fastf_t inv_viewsize, short r, short g, short b, int line_width, int draw_style, int draw_edit, unsigned char *gdc, int solids_down, int mv_dlist)
void dm_set_pathname(struct dm *dmp, const char *pname)
const char * dm_get_graphics_system(const struct dm *dmp)
int fb_bwreadrect(struct fb *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
int dm_valid_type(const char *name, const char *dpy_string)
fastf_t dm_get_bound(struct dm *dmp)
int fb_getwidth(struct fb *ifp)
@ DM_BUTTON_PRESS
Definition: dm.h:313
@ DM_BUTTON_RELEASE
Definition: dm.h:314
@ DM_MOTION_NOTIFY
Definition: dm.h:312
fastf_t vect_t[ELEMENTS_PER_VECT]
3-tuple vector
Definition: vmath.h:349
double fastf_t
fastest 64-bit (or larger) floating point type
Definition: vmath.h:334
fastf_t mat_t[ELEMENTS_PER_MAT]
4x4 matrix
Definition: vmath.h:370
fastf_t point_t[ELEMENTS_PER_POINT]
3-tuple point
Definition: vmath.h:355
fastf_t vect2d_t[ELEMENTS_PER_VECT2D]
2-tuple vector
Definition: vmath.h:337
Global registry of recognized magic numbers.
Definition: dm.h:369
Definition: list.h:132
Definition: vls.h:53
Definition: vlist.h:64
void(* dm_hook)(const struct bu_structparse *, const char *, void *, const char *, void *)
Definition: dm.h:76
void * dmh_data
Definition: dm.h:77
Definition: defines.h:57
struct dm_impl * i
Definition: defines.h:59
uint32_t magic
Definition: dm.h:465
void * data
Definition: dm.h:465
Definition: defines.h:70
Definition: wdb.h:62
fundamental vector, matrix, quaternion math macros