dm.h

Go to the documentation of this file.
00001 /*                          D M . H
00002  * BRL-CAD
00003  *
00004  * Copyright (c) 1993-2006 United States Government as represented by
00005  * the U.S. Army Research Laboratory.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public License
00009  * as published by the Free Software Foundation; either version 2.1 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this file; see the file named COPYING for more
00019  * information.
00020  */
00021 /** @addtogroup libdm */
00022 /*@{*/
00023 /** @file dm.h
00024  *
00025  */
00026 #ifndef SEEN_DM_H
00027 #define SEEN_DM_H
00028 
00029 #ifndef DM_EXPORT
00030 #if defined(_WIN32) && !defined(__CYGWIN__) && defined(BRLCAD_DLL)
00031 #  ifdef DM_EXPORT_DLL
00032 #    define DM_EXPORT __declspec(dllexport)
00033 #  else
00034 #    define DM_EXPORT __declspec(dllimport)
00035 #  endif
00036 #else
00037 #  define DM_EXPORT
00038 #endif
00039 #endif
00040 
00041 #ifndef SEEN_BU_H
00042 #  include <bu.h>
00043 #endif
00044 
00045 #ifdef USE_FBSERV
00046 #  include "fbserv_obj.h"
00047 #endif
00048 
00049 #define DM_NULL (struct dm *)NULL
00050 #define DM_MIN (-2048)
00051 #define DM_MAX (2047)
00052 #define X       0
00053 #define Y       1
00054 #define Z       2
00055 
00056 #define DM_O(_m) offsetof(struct dm, _m)
00057 
00058 #define GED_MAX 2047.0
00059 #define GED_MIN -2048.0
00060 #define GED_RANGE 4095.0
00061 #define INV_GED 0.00048828125
00062 #define INV_4096 0.000244140625
00063 
00064 /*
00065  * Display coordinate conversion:
00066  *  GED is using -2048..+2048,
00067  *  X is 0..width,0..height
00068  */
00069 #define DIVBY4096(x) (((double)(x))*INV_4096)
00070 #define GED_TO_Xx(_dmp, x) ((int)((DIVBY4096(x)+0.5)*_dmp->dm_width))
00071 #define GED_TO_Xy(_dmp, x) ((int)((0.5-DIVBY4096(x))*_dmp->dm_height))
00072 #define Xx_TO_GED(_dmp, x) ((int)(((x)/(double)_dmp->dm_width - 0.5) * GED_RANGE))
00073 #define Xy_TO_GED(_dmp, x) ((int)((0.5 - (x)/(double)_dmp->dm_height) * GED_RANGE))
00074 
00075 #if IR_KNOBS
00076 #define NOISE 16                /* Size of dead spot on knob */
00077 #endif
00078 
00079 /* the font used depends on the size of the window opened */
00080 #define FONTBACK        "-adobe-courier-medium-r-normal--10-100-75-75-m-60-iso8859-1"
00081 #define FONT5   "5x7"
00082 #define FONT6   "6x10"
00083 #define FONT7   "7x13"
00084 #define FONT8   "8x13"
00085 #define FONT9   "9x15"
00086 
00087 /* Display Manager Types */
00088 #define DM_TYPE_BAD     -1
00089 #define DM_TYPE_NULL    0
00090 #define DM_TYPE_PLOT    1
00091 #define DM_TYPE_PS      2
00092 #define DM_TYPE_X       3
00093 #define DM_TYPE_OGL     4
00094 #define DM_TYPE_GLX     5
00095 #define DM_TYPE_PEX     6
00096 #define DM_TYPE_WGL     7
00097 
00098 /* Line Styles */
00099 #define DM_SOLID_LINE 0
00100 #define DM_DASHED_LINE 1
00101 
00102 #define IS_DM_TYPE_NULL(_t) ((_t) == DM_TYPE_NULL)
00103 #define IS_DM_TYPE_PLOT(_t) ((_t) == DM_TYPE_PLOT)
00104 #define IS_DM_TYPE_PS(_t) ((_t) == DM_TYPE_PS)
00105 #define IS_DM_TYPE_X(_t) ((_t) == DM_TYPE_X)
00106 #define IS_DM_TYPE_OGL(_t) ((_t) == DM_TYPE_OGL)
00107 #define IS_DM_TYPE_GLX(_t) ((_t) == DM_TYPE_GLX)
00108 #define IS_DM_TYPE_PEX(_t) ((_t) == DM_TYPE_PEX)
00109 #define IS_DM_TYPE_WGL(_t) ((_t) == DM_TYPE_WGL)
00110 
00111 #define GET_DM(p,structure,w,hp) { \
00112         register struct structure *tp; \
00113         for(BU_LIST_FOR(tp, structure, hp)) { \
00114                 if(w == tp->win) { \
00115                         (p) = tp; \
00116                         break; \
00117                 } \
00118         } \
00119 \
00120         if(BU_LIST_IS_HEAD(tp, hp)) \
00121                 p = (struct structure *)NULL; \
00122 }
00123 
00124 /*  Colors */
00125 #define DM_COLOR_HI     ((short)230)
00126 #define DM_COLOR_LOW    ((short)0)
00127 #define DM_BLACK_R      DM_COLOR_LOW
00128 #define DM_BLACK_G      DM_COLOR_LOW
00129 #define DM_BLACK_B      DM_COLOR_LOW
00130 #define DM_RED_R        DM_COLOR_HI
00131 #define DM_RED_G        DM_COLOR_LOW
00132 #define DM_RED_B        DM_COLOR_LOW
00133 #define DM_BLUE_R       DM_COLOR_LOW
00134 #define DM_BLUE_G       DM_COLOR_LOW
00135 #define DM_BLUE_B       DM_COLOR_HI
00136 #define DM_YELLOW_R     DM_COLOR_HI
00137 #define DM_YELLOW_G     DM_COLOR_HI
00138 #define DM_YELLOW_B     DM_COLOR_LOW
00139 #define DM_WHITE_R      DM_COLOR_HI
00140 #define DM_WHITE_G      DM_COLOR_HI
00141 #define DM_WHITE_B      DM_COLOR_HI
00142 #define DM_BLACK        DM_BLACK_R, DM_BLACK_G, DM_BLACK_B
00143 #define DM_RED          DM_RED_R, DM_RED_G, DM_RED_B
00144 #define DM_BLUE         DM_BLUE_R, DM_BLUE_G, DM_BLUE_B
00145 #define DM_YELLOW       DM_YELLOW_R, DM_YELLOW_G, DM_YELLOW_B
00146 #define DM_WHITE        DM_WHITE_R, DM_WHITE_G, DM_WHITE_B
00147 #define DM_COPY_COLOR(_dr,_dg,_db,_sr,_sg,_sb){\
00148         (_dr) = (_sr);\
00149         (_dg) = (_sg);\
00150         (_db) = (_sb); }
00151 #define DM_SAME_COLOR(_dr,_dg,_db,_sr,_sg,_sb)(\
00152         (_dr) == (_sr) &&\
00153         (_dg) == (_sg) &&\
00154         (_db) == (_sb))
00155 
00156 /* Command parameter to dmr_viewchange() */
00157 #define DM_CHGV_REDO    0       /* Display has changed substantially */
00158 #define DM_CHGV_ADD     1       /* Add an object to the display */
00159 #define DM_CHGV_DEL     2       /* Delete an object from the display */
00160 #define DM_CHGV_REPL    3       /* Replace an object */
00161 #define DM_CHGV_ILLUM   4       /* Make new object the illuminated object */
00162 
00163 /*
00164  * Definitions for dealing with the buttons and lights.
00165  * BV are for viewing, and BE are for editing functions.
00166  */
00167 #define LIGHT_OFF       0
00168 #define LIGHT_ON        1
00169 #define LIGHT_RESET     2               /* all lights out */
00170 
00171 struct dm_vars {
00172   genptr_t pub_vars;
00173   genptr_t priv_vars;
00174 };
00175 
00176 /**
00177  * Interface to a specific Display Manager
00178  */
00179 struct dm {
00180   int (*dm_close)();
00181   int (*dm_drawBegin)();        /**< @brief formerly dmr_prolog */
00182   int (*dm_drawEnd)();          /**< @brief formerly dmr_epilog */
00183   int (*dm_normal)();
00184   int (*dm_loadMatrix)();
00185   int (*dm_drawString2D)();     /**< @brief formerly dmr_puts */
00186   int (*dm_drawLine2D)();       /**< @brief formerly dmr_2d_line */
00187   int (*dm_drawPoint2D)();
00188   int (*dm_drawVList)();        /**< @brief formerly dmr_object */
00189   int (*dm_setFGColor)(struct dm *dmp, unsigned char r, unsigned char g, unsigned char b, int strict, fastf_t transparency);
00190   int (*dm_setBGColor)(struct dm *, unsigned char, unsigned char, unsigned char);
00191   int (*dm_setLineAttr)();      /**< @brief currently - linewidth, (not-)dashed */
00192   int (*dm_configureWin)();
00193   int (*dm_setWinBounds)();
00194   int (*dm_setLight)();
00195   int (*dm_setTransparency)();
00196   int (*dm_setDepthMask)();
00197   int (*dm_setZBuffer)();
00198   int (*dm_debug)();            /**< @brief Set DM debug level */
00199   int (*dm_beginDList)();
00200   int (*dm_endDList)();
00201   int (*dm_drawDList)();
00202   int (*dm_freeDLists)();
00203   unsigned long dm_id;          /**< @brief window id */
00204   int dm_displaylist;           /**< @brief !0 means device has displaylist */
00205   int dm_stereo;                /**< @brief stereo flag */
00206   double dm_bound;              /**< @brief zoom-in limit */
00207   int dm_boundFlag;
00208   char *dm_name;                /**< @brief short name of device */
00209   char *dm_lname;               /**< @brief long name of device */
00210   int dm_type;                  /**< @brief display manager type */
00211   int dm_top;                   /**< @brief !0 means toplevel window */
00212   int dm_width;
00213   int dm_height;
00214   int dm_lineWidth;
00215   int dm_lineStyle;
00216   fastf_t dm_aspect;
00217   fastf_t *dm_vp;               /**< @brief XXX--ogl still depends on this--Viewscale pointer */
00218   struct dm_vars dm_vars;       /**< @brief display manager dependant variables */
00219   struct bu_vls dm_pathName;    /**< @brief full Tcl/Tk name of drawing window */
00220   struct bu_vls dm_tkName;      /**< @brief short Tcl/Tk name of drawing window */
00221   struct bu_vls dm_dName;       /**< @brief Display name */
00222   unsigned char dm_bg[3];       /**< @brief background color */
00223   unsigned char dm_fg[3];       /**< @brief foreground color */
00224   vect_t dm_clipmin;            /**< @brief minimum clipping vector */
00225   vect_t dm_clipmax;            /**< @brief maximum clipping vector */
00226   int dm_debugLevel;            /**< @brief !0 means debugging */
00227   int dm_perspective;           /**< @brief !0 means perspective on */
00228   int dm_light;                 /**< @brief !0 means lighting on */
00229   int dm_transparency;          /**< @brief !0 means transparency on */
00230   int dm_depthMask;             /**< @brief !0 means depth buffer is writable */
00231   int dm_zbuffer;               /**< @brief !0 means zbuffer on */
00232   int dm_zclip;                 /**< @brief !0 means zclipping */
00233   int dm_clearBufferAfter;      /**< @brief 1 means clear back buffer after drawing and swap */
00234   Tcl_Interp *dm_interp;        /**< @brief Tcl interpreter */
00235 };
00236 
00237 /**
00238  *                      D M _ O B J
00239  *@brief
00240  * A display manager object is used for interacting with a display manager.
00241  */
00242 struct dm_obj {
00243   struct bu_list        l;
00244   struct bu_vls         dmo_name;               /**< @brief display manager object name/cmd */
00245   struct dm             *dmo_dmp;               /**< @brief display manager pointer */
00246 #ifdef USE_FBSERV
00247   struct fbserv_obj     dmo_fbs;                /**< @brief fbserv object */
00248 #endif
00249   struct bu_observer    dmo_observers;          /**< @brief fbserv observers */
00250   mat_t                 viewMat;
00251   int                   (*dmo_drawLabelsHook)();
00252   void                  *dmo_drawLabelsHookClientData;
00253 };
00254 
00255 #define DM_OPEN(_type,_argc,_argv) dm_open(_type,_argc,_argv)
00256 #define DM_CLOSE(_dmp) _dmp->dm_close(_dmp)
00257 #define DM_DRAW_BEGIN(_dmp) _dmp->dm_drawBegin(_dmp)
00258 #define DM_DRAW_END(_dmp) _dmp->dm_drawEnd(_dmp)
00259 #define DM_NORMAL(_dmp) _dmp->dm_normal(_dmp)
00260 #define DM_LOADMATRIX(_dmp,_mat,_eye) _dmp->dm_loadMatrix(_dmp,_mat,_eye)
00261 #define DM_DRAW_STRING_2D(_dmp,_str,_x,_y,_size,_use_aspect)\
00262      _dmp->dm_drawString2D(_dmp,_str,_x,_y,_size,_use_aspect)
00263 #define DM_DRAW_LINE_2D(_dmp,_x1,_y1,_x2,_y2) _dmp->dm_drawLine2D(_dmp,_x1,_y1,_x2,_y2)
00264 #define DM_DRAW_POINT_2D(_dmp,_x,_y) _dmp->dm_drawPoint2D(_dmp,_x,_y)
00265 #define DM_DRAW_VLIST(_dmp,_vlist) _dmp->dm_drawVList(_dmp,_vlist)
00266 #define DM_SET_FGCOLOR(_dmp,_r,_g,_b,_strict,_transparency) _dmp->dm_setFGColor(_dmp,_r,_g,_b,_strict,_transparency)
00267 #define DM_SET_BGCOLOR(_dmp,_r,_g,_b) _dmp->dm_setBGColor(_dmp,_r,_g,_b)
00268 #define DM_SET_LINE_ATTR(_dmp,_width,_dashed) _dmp->dm_setLineAttr(_dmp,_width,_dashed)
00269 #define DM_CONFIGURE_WIN(_dmp) _dmp->dm_configureWin(_dmp)
00270 #define DM_SET_WIN_BOUNDS(_dmp,_w) _dmp->dm_setWinBounds(_dmp,_w)
00271 #define DM_SET_LIGHT(_dmp,_on) _dmp->dm_setLight(_dmp,_on)
00272 #define DM_SET_TRANSPARENCY(_dmp,_on) _dmp->dm_setTransparency(_dmp,_on)
00273 #define DM_SET_DEPTH_MASK(_dmp,_on) _dmp->dm_setDepthMask(_dmp,_on)
00274 #define DM_SET_ZBUFFER(_dmp,_on) _dmp->dm_setZBuffer(_dmp,_on)
00275 #define DM_DEBUG(_dmp,_lvl) _dmp->dm_debug(_dmp,_lvl)
00276 #define DM_BEGINDLIST(_dmp,_list) _dmp->dm_beginDList(_dmp,_list)
00277 #define DM_ENDDLIST(_dmp) _dmp->dm_endDList(_dmp)
00278 #define DM_DRAWDLIST(_dmp,_list) _dmp->dm_drawDList(_dmp,_list)
00279 #define DM_FREEDLISTS(_dmp,_list,_range) _dmp->dm_freeDLists(_dmp,_list,_range)
00280 
00281 DM_EXPORT extern struct dm dm_Null;
00282 
00283 #ifdef BRLCAD_DEBUG
00284 DM_EXPORT BU_EXTERN(int Dm_d_Init,
00285                     ());
00286 #else
00287 DM_EXPORT BU_EXTERN(int Dm_Init,
00288                     ());
00289 #endif
00290 DM_EXPORT BU_EXTERN(struct dm *dm_open,
00291                     (Tcl_Interp *interp,
00292                      int type,
00293                      int argc,
00294                      char *argv[]));
00295 DM_EXPORT BU_EXTERN(int dm_share_dlist,
00296                     (struct dm *dmp1,
00297                      struct dm *dmp2));
00298 DM_EXPORT BU_EXTERN(fastf_t dm_Xx2Normal,
00299                     (struct dm *dmp,
00300                      register int x));
00301 DM_EXPORT BU_EXTERN(int dm_Normal2Xx,
00302                     (struct dm *dmp,
00303                      register fastf_t f));
00304 DM_EXPORT BU_EXTERN(fastf_t dm_Xy2Normal,
00305                     (struct dm *dmp,
00306                      register int y,
00307                      int use_aspect));
00308 DM_EXPORT BU_EXTERN(int dm_Normal2Xy,
00309                     (struct dm *dmp,
00310                      register fastf_t f,
00311                      int use_aspect));
00312 DM_EXPORT BU_EXTERN(void dm_fogHint,
00313                     (struct dm *dmp,
00314                      int fastfog));
00315 DM_EXPORT BU_EXTERN(int dm_processOptions,
00316                     ());
00317 DM_EXPORT BU_EXTERN(int dm_limit,
00318                     (int i));
00319 DM_EXPORT BU_EXTERN(int dm_unlimit,
00320                     (int i));
00321 DM_EXPORT BU_EXTERN(fastf_t dm_wrap,
00322                     (fastf_t f));
00323 DM_EXPORT BU_EXTERN(void Nu_void,
00324                     ());
00325 DM_EXPORT BU_EXTERN(struct dm *Nu_open,
00326                     ());
00327 DM_EXPORT BU_EXTERN(int Nu_int0,
00328                     ());
00329 DM_EXPORT BU_EXTERN(unsigned Nu_unsign,
00330                     ());
00331 
00332 /* vers.c */
00333 DM_EXPORT extern char dm_version[];
00334 
00335 /* clip.c */
00336 DM_EXPORT BU_EXTERN(int clip,
00337                     (fastf_t *,
00338                      fastf_t *,
00339                      fastf_t *,
00340                      fastf_t *));
00341 DM_EXPORT BU_EXTERN(int vclip,
00342                     (fastf_t *,
00343                      fastf_t *,
00344                      register fastf_t *,
00345                      register fastf_t *));
00346 
00347 /* axes.c */
00348 DM_EXPORT BU_EXTERN(void dmo_drawAxes_cmd,
00349                     (struct dm *dmp,
00350                      fastf_t viewSize,
00351                      mat_t rmat,
00352                      point_t axesPos,
00353                      fastf_t axesSize,
00354                      int *axesColor,
00355                      int *labelColor,
00356                      int lineWidth,
00357                      int posOnly,
00358                      int threeColor,
00359                      int tickEnable,
00360                      int tickLen,
00361                      int majorTickLen,
00362                      fastf_t tickInterval,
00363                      int ticksPerMajor,
00364                      int *tickColor,
00365                      int *majorTickColor,
00366                      int tickThreshold));
00367 
00368 #endif /* SEEN_DM_H */
00369 /*@}*/
00370 /*
00371  * Local Variables:
00372  * mode: C
00373  * tab-width: 8
00374  * c-basic-offset: 4
00375  * indent-tabs-mode: t
00376  * End:
00377  * ex: shiftwidth=4 tabstop=8
00378  */
00379 

Generated on Mon Sep 18 01:24:40 2006 for BRL-CAD by  doxygen 1.4.6