home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / extensions / lib / PEX / include / ws.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-21  |  16.3 KB  |  500 lines

  1. /* $XConsortium: ws.h,v 5.3 92/10/15 16:23:08 hersh Exp $ */
  2.  
  3. /***********************************************************
  4. Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium.
  5.  
  6.                         All Rights Reserved
  7.  
  8. Permission to use, copy, modify, and distribute this software and its 
  9. documentation for any purpose and without fee is hereby granted, 
  10. provided that the above copyright notice appear in all copies and that
  11. both that copyright notice and this permission notice appear in 
  12. supporting documentation, and that the names of Sun Microsystems,
  13. the X Consortium, and MIT not be used in advertising or publicity 
  14. pertaining to distribution of the software without specific, written 
  15. prior permission.  
  16.  
  17. SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
  18. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT 
  19. SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
  20. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23. SOFTWARE.
  24. ******************************************************************/
  25.  
  26. #ifndef PHG_WS_H_INCLUDED
  27. #define PHG_WS_H_INCLUDED
  28.  
  29. #include "ws_inp.h"
  30. #include <X11/extensions/multibuf.h>
  31.  
  32. /* The maximum number of views for client-side workstations. */
  33. #define WS_MAX_VIEWS    20
  34.  
  35. #define WS_FLUSH( _ws ) \
  36.     if ( (_ws)->flags.flush ){_XFlush( (_ws)->display );}
  37.  
  38. #define WS_DC_TO_DRWBL2( _wsh, _dcp, _dwp ) \
  39.     ((_dwp)->x = (_dcp)->x, \
  40.      (_dwp)->y = (_wsh)->ws_rect.height - (_dcp)->y)
  41.  
  42. #define WS_DRWBL_TO_DC2( _wsh, _dwp, _dcp ) \
  43.     ((_dcp)->x = (_dwp)->x, \
  44.      (_dcp)->y = (_wsh)->ws_rect.height - (_dwp)->y)
  45.  
  46. #define WS_SET_WS_RECT( _wsh, _wattr ) \
  47.     {(_wsh)->ws_rect.x = (_wattr)->x; \
  48.      (_wsh)->ws_rect.y = (_wattr)->y; \
  49.      (_wsh)->ws_rect.width = (_wattr)->width; \
  50.      (_wsh)->ws_rect.height = (_wattr)->height; \
  51.     }
  52.  
  53. #define WS_DC_TO_NPC2(_wsxf, _dc, _npc) \
  54.     (_npc)->x = ( (_dc)->x - (_wsxf)->offset.x) / (_wsxf)->scale.x; \
  55.     (_npc)->y = ( (_dc)->y - (_wsxf)->offset.y) / (_wsxf)->scale.y;
  56.  
  57. #define WS_DC_TO_NPC(_wsxf, _dc, _npc) \
  58.     (_npc)->x = ( (_dc)->x - (_wsxf)->offset.x) / (_wsxf)->scale.x; \
  59.     (_npc)->y = ( (_dc)->y - (_wsxf)->offset.y) / (_wsxf)->scale.y; \
  60.     (_npc)->z = ( (_dc)->z - (_wsxf)->offset.z) / (_wsxf)->scale.z;
  61.  
  62. #define WS_NPC_TO_DC(_wsxf, _npc, _dc) \
  63.     (_dc)->x = (_npc)->x * (_wsxf)->scale.x + (_wsxf)->offset.x; \
  64.     (_dc)->y = (_npc)->y * (_wsxf)->scale.y + (_wsxf)->offset.y; \
  65.     (_dc)->z = (_npc)->z * (_wsxf)->scale.z + (_wsxf)->offset.z;
  66.  
  67. #define WS_PT_IN_LIMIT( lim, pt) \
  68.     (  (pt)->x >= (lim)->x_min && (pt)->x <= (lim)->x_max \
  69.     && (pt)->y >= (lim)->y_min && (pt)->y <= (lim)->y_max \
  70.     && (pt)->z >= (lim)->z_min && (pt)->z <= (lim)->z_max)
  71.  
  72. #define WS_PT_IN_LIMIT2( lim, pt) \
  73.     (  (pt)->x >= (lim)->x_min && (pt)->x <= (lim)->x_max \
  74.     && (pt)->y >= (lim)->y_min && (pt)->y <= (lim)->y_max)
  75.  
  76. #define WS_ANY_INP_DEV_ACTIVE( _wsh ) \
  77.     ((_wsh)->num_active_input_devs > 0)
  78.  
  79. #define WS_MAX_3(_x, _y, _z)    \
  80.     (((_x) > (_y)) ? (((_x) > (_z)) ? (_x) : (_z)) : (((_y) > (_z)) ? (_y) : (_z)))
  81.  
  82. /*
  83.  * These are the "times" when an action occurs. For example,
  84.  * closing a structure could be the time in ASTI (ATI). Or,
  85.  * starting a request is BIL for this workstation and BIG for
  86.  * the others
  87.  */
  88.  
  89. typedef enum {
  90.     PHG_TIME_NOW,         /* the time is "now" */
  91.     PHG_TIME_BIG,         /* begin interaction globally */
  92.     PHG_TIME_BIL,         /* begin interaction locally */
  93.     PHG_TIME_ATI,          /* at the some time */
  94.     PHG_TIME_NUM
  95. } Ws_update_time;
  96.  
  97. /*
  98.  * update actions: what can be done given the current update mode
  99.  * and update time.
  100.  */
  101. typedef enum {
  102.     PHG_UPDATE_ACCURATE,     /* make the display accurate */
  103.     PHG_UPDATE_UWOR,         /* do an update w/o regeneration */
  104.     PHG_UPDATE_UQUM,         /* do a quick update */
  105.     PHG_UPDATE_NOTHING,         /* do nothing (a deferral) */
  106.     PHG_UPDATE_IF_IG,         /* if(global interaction) ACCURATE, else ASTI */
  107.     PHG_UPDATE_IF_IL,         /* if(local interaction) ACCURATE, else ASTI */
  108.     PHG_UPDATE_IF_INCORRECT,     /* if (!PVISUAL_ST_CORRECT) make the display accurate */
  109.     ASSURE_CORRECT,         /* if (!PVISUAL_ST_CORRECT) make the display accurate */
  110.     PHG_UPDATE_NUM
  111. } Ws_update_action;
  112.  
  113. #define NUM_DEFERRAL 5        /* ASAP, BNIG, BNIL, ASTI, WAIT */
  114. #define NUM_MODIFICATION 3    /* NIVE, UWOR, UQUM */
  115.  
  116. /* Idiom to be used after
  117.  * WSB_CHECK_FOR_INTERACTION_UNDERWAY(ws, &out_ws->now_action)
  118.  */
  119. #define case_PHG_UPDATE_ACCURATE_or_IF_Ix                               \
  120.                         case PHG_UPDATE_ACCURATE:                       \
  121.                         case PHG_UPDATE_IF_IG:                          \
  122.                         case PHG_UPDATE_IF_IL
  123.  
  124. #define WSB_CHECK_FOR_INTERACTION_UNDERWAY(ws, now_action_ptr)     \
  125.     { if( *(now_action_ptr) == PHG_UPDATE_IF_IG ||    \
  126.     *(now_action_ptr) == PHG_UPDATE_IF_IL )    \
  127.     phg_wsb_resolve_now_action(ws, now_action_ptr); }
  128.  
  129. /* When empty, dummy elements point to each other:
  130.  * (lowest.higher = &highest) and (highest.lower = &lowest)
  131.  * Typical call:  WS_NONE_POSTED(&out_ws->posted)
  132.  */
  133. #define WSB_NONE_POSTED(posted_ptr)    \
  134.      ( (posted_ptr)->lowest.higher == &(posted_ptr)->highest )
  135. #define WSB_SOME_POSTED(posted_ptr)    \
  136.      ( (posted_ptr)->lowest.higher != &(posted_ptr)->highest )
  137. #define WSB_CHECK_POSTED(posted_ptr)    \
  138.     assure(   ((posted_ptr)->lowest.higher == &(posted_ptr)->highest)   \
  139.         == ((posted_ptr)->highest.lower == &(posted_ptr)->lowest) )
  140.  
  141. typedef struct _Ws_post_str {
  142.     Pfloat              disp_pri;
  143.     Struct_handle       structh;
  144.     struct _Ws_post_str *lower;
  145.     struct _Ws_post_str *higher;
  146. } Ws_post_str;
  147.  
  148. typedef struct {
  149.     /* Posted structures: a doubly-linked list, ordered by posting priority.
  150.      * Dummy structure elements are on both ends of the list.
  151.      * highest.lower is the highest-priority true posted structure on this WS.
  152.      * lowest.higher is the lowest-priority true posted structure on this WS.
  153.      */
  154.     Ws_post_str lowest;            /* lowest.lower is always NULL */
  155.     Ws_post_str highest;        /* highest.higher is always NULL */
  156. } Ws_posted_structs;
  157.  
  158. typedef enum {
  159.     WS_PRE_CSS_DELETE,
  160.     WS_POST_CSS_DELETE
  161. } Ws_delete_flag;
  162.  
  163. typedef    Ws_update_action
  164.     Ws_action_table[PHG_TIME_NUM][NUM_MODIFICATION][NUM_DEFERRAL];
  165.  
  166. typedef Ws_action_table *Ws_action_table_ptr;
  167.  
  168. typedef enum {
  169.     WS_INV_NOT_CURRENT,
  170.     WS_INV_CURRENT,
  171.     WS_INV_NOT_INVERTIBLE
  172. } Ws_inverse_state;
  173.  
  174. typedef struct {
  175.     Pupd_st        pending;
  176.     Pmatrix3        vom;        /* view orientation matrix */
  177.     Pmatrix3        vmm;        /* view mapping matrix */
  178.     Plimit3        clip_limit;    /* clip limits */
  179.     Pclip_ind        xy_clip;    /* x-y clip control */
  180.     Pclip_ind        back_clip;    /* back plane clipping */
  181.     Pclip_ind        front_clip;    /* front plane clipping */
  182.     Ws_inverse_state    npc_to_wc_state;
  183.     Pmatrix3        npc_to_wc;    /* inverse transform, check
  184.                      * npc_to_wc_state to see if it's
  185.                      * current.  */
  186. } Ws_view_entry;
  187.  
  188. typedef struct {
  189.     Pint    id;
  190.     Pview_rep3    view;
  191. } Ws_pending_view;
  192.  
  193. typedef struct {
  194.     int        higher; /* index of higher priority than this one. */
  195.     int        lower;  /* index of lower priority than this one. */
  196. } Ws_view_priority;
  197.  
  198. typedef struct {
  199.     Ppoint3    scale;
  200.     Ppoint3    offset;
  201. } Ws_xform;
  202.  
  203.  
  204. /* API state list data for type A (server-side) workstations.  */
  205. typedef struct {
  206.     Pint        unused;
  207. } Wsa_output_ws;
  208.  
  209.  
  210. /* API state list data for type B (client-side) workstations.  */
  211. typedef struct {
  212.     Css_handle    cssh;
  213.     XID        pipeline;
  214.     Pvisual_st    vis_rep;        /* state of visual representation */
  215.     Pdisp_surf_empty    surf_state;        /* Display surface empty */
  216.     Plimit3    ws_window;        /* current ws window and viewport */
  217.     Plimit3    ws_viewport;
  218.     Pupd_st    ws_window_pending;    /* if a new ws transform is pending */
  219.     Pupd_st    ws_viewport_pending;
  220.     Plimit3    req_ws_window;        /* requested ws window and viewport */
  221.     Plimit3    req_ws_viewport;
  222.     Ws_xform    ws_xform;        /* scale and offset of ws xform */
  223.     int        num_pending_views;    /* number of pending views */
  224.     Ws_pending_view    *pending_views;    /* pending views */
  225.     int        num_views;        /* number of views */
  226.     Ws_view_entry    *views;        /* view table */
  227.     Pint    top_view;        /* highest priority view */
  228.     Ws_view_priority    *view_priorities; /* array of relative priorities.
  229.                        * The "higher" field of the
  230.                        * highest priority view is set to
  231.                        * -1, as is the "lower" field of
  232.                        * the lowest priority view.
  233.                        */
  234.     Ws_posted_structs    posted;        /* List of posted structures */
  235.     Ws_update_action  now_action;    /* cached value for what to do at
  236.                      * time "now". avoids a table lookup.
  237.                      */
  238.     Ws_action_table_ptr     update_action_table;    /* table which controls
  239.                              * what, if anything,
  240.                              * is to be done to
  241.                              * update the screen.
  242.                              */
  243.     /* HLHSR stuff */
  244.     Pupd_st        hlhsr_mode_pending;    /* new hlhsr mode is pending */
  245.     int            req_hlhsr_mode;        /* requested hlhsr mode */
  246.     int            cur_hlhsr_mode;        /* current hlhsr mode */
  247.     /* Double Buffer Stuff */
  248.     int                 front;                  /* index of front drawable */
  249.     int                 back;                  /* index of back drawable */
  250.     int                 has_double_buffer;     /* Boolean for buffer presence */
  251.     Multibuffer         double_drawable[2];    /* the two buffers */
  252. } Wsb_output_ws;
  253.  
  254. typedef struct {
  255.     Pdefer_mode        def_mode;        /* deferral mode */
  256.     Pmod_mode        mod_mode;        /* modification mode */
  257.     struct {    /* Lookup Table Ids */
  258.     XID    marker,
  259.         line,
  260.         text,
  261.         interior,
  262.         edge,
  263.         colour,
  264.         depth_cue,
  265.         light_source,
  266.         colour_approx,
  267.         pattern,
  268.         font,
  269.         view;    /* not used by type A workstations */
  270.     }                lut;
  271.     struct {    /* Hash Table Ids */
  272.     Hash_table    marker,
  273.             line,
  274.             text,
  275.             interior,
  276.             edge,
  277.             colour,
  278.             depth_cue,
  279.             light_source,
  280.             colour_approx,
  281.             pattern,
  282.             font,
  283.             view;    /* not used by type A workstations */
  284.     }                htab;
  285.  
  286.     struct {    /* Name Set Ids */
  287.     XID    hlt_incl,
  288.         hlt_excl,
  289.         invis_incl,
  290.         invis_excl,
  291.         drawable_pick_incl,
  292.         drawable_pick_excl;
  293.     }                nset;
  294.     union {
  295.     Wsa_output_ws    a;
  296.     Wsb_output_ws    b;
  297.     }            model;
  298. } Ws_output_ws;
  299.  
  300. typedef struct _Ws {
  301.     Pint        id;
  302.     Wst            *type;
  303.     Pws_cat        category;
  304.     Ws_output_ws    out_ws;
  305.     Ws_input_ws        in_ws;
  306.     Pint        current_colour_model;
  307.     int            num_active_input_devs;
  308.  
  309.     Cp_handle        cph;
  310.     Err_handle        erh;
  311.     Phg_scratch        scratch;
  312.  
  313.     /* PEX info */
  314.     Cpx_css_srvr    *css_srvr;
  315.     Display        *display;    /* Currently this is always the
  316.                      * same as css_srvr->display when
  317.                      * the css_srvr is associated with
  318.                      * a display.
  319.                      */
  320.     XID             rid;        /* resource id, WS or Renderer */
  321.     Drawable        drawable_id;
  322.     Window        input_overlay_window;
  323.     XRectangle        ws_rect;
  324.     Pint        true_colr_map_count;
  325.     unsigned long    true_colr_map_base_pixel;
  326.     Widget        top_level;        /* only in PM */
  327.     Widget        shell;            /* only in PM */
  328.     Widget        msg_shell;        /* only in PM */
  329.     Widget        msg_label;        /* only in PM */
  330.     struct {
  331.     unsigned flush: 1;    /* if == 1, don't buffer X/PEX requests */
  332.     }            flags;
  333.     struct _Ws            *next;        /* link for CP list */
  334.  
  335.     /* Not all of these are used by all devices. */
  336.     void    (*close)();
  337.     void    (*redraw_all)();
  338.     void    (*conditional_redraw)();
  339.     void    (*repaint_all)();
  340.     void    (*make_requested_current)();
  341.     void    (*update)();
  342.     void    (*set_disp_update_state)();
  343.     void    (*message)();
  344.     void    (*set_rep)();
  345.     void    (*set_filter)();
  346.     void    (*set_colour_model)();
  347.     void    (*set_hlhsr_mode)();
  348.     void    (*set_view_input_priority)();
  349.     void    (*set_ws_window)();
  350.     void    (*set_ws_vp)();
  351.     void    (*delete_el_for_repl)();
  352.     void    (*add_el)();
  353.     void    (*copy_struct)();
  354.     void    (*close_struct)();
  355.     void    (*move_ep)();
  356.     int     (*delete_el)();
  357.     int     (*delete_struct)();
  358.     int     (*delete_struct_net)();
  359.     void     (*delete_all_structs)();
  360.     void    (*post)();
  361.     void    (*unpost)();
  362.     void    (*unpost_all)();
  363.     void    (*change_posting)();
  364.     Ws_handle    (*bnig_update)();
  365.  
  366.     void    (*inq_view_indices)();    /* Inquiry functions */
  367.     void    (*inq_bundle_indices)();
  368.     void    (*inq_posted)();
  369.     void    (*inq_representation)();
  370.     void    (*inq_view_rep)();
  371.     void    (*inq_ws_xform)();
  372.     void    (*inq_disp_update_state)();
  373.     void    (*inq_filter)();
  374.     void    (*inq_hlhsr_mode)();
  375.     void    (*inq_colour_model)();
  376.  
  377.     void    (*set_device_mode)();    /* Input functions */
  378.     void    (*init_device)();
  379.     void    (*request_device)();
  380.     void    (*sample_device)();
  381.     void    (*inq_inp_dev_state)();
  382.     int        (*X_point_in_viewport)();
  383.     void    (*input_repaint)();
  384.     int        (*map_initial_points)();
  385.     int        (*resolve_locator)();
  386.     int        (*resolve_stroke)();
  387.     int        (*resolve_pick)();
  388.     int        (*pick_enable)();
  389.     void    (*pick_disable)();
  390.     int        (*valid_pick_path)();
  391.     void    (*drawable_pick)();
  392.     void    (*map_points)();
  393.     void    (*redraw_regions)();
  394.     void    (*synch)();
  395. } Ws;
  396.  
  397. /* WS utilities */
  398. extern int    phg_wsx_create_LUTs();
  399. extern int    phg_wsx_init_LUTs();
  400. extern void    phg_wsx_destroy_LUTs();
  401. extern void    phg_wsx_set_LUT_entry();
  402. extern void    phg_wsx_inq_LUT_entry();
  403. extern void    phg_wsx_inq_LUT_indices();
  404. extern void    phg_wsx_set_name_set();
  405. extern void    phg_wsx_inq_name_set();
  406. extern int    phg_wsx_setup_tool();
  407. extern int    phg_wsx_setup_colormap();
  408. extern caddr_t    phg_wsx_colr_mapping_entry_from_pex();
  409. extern int    phg_wsx_get_true_colors();
  410. extern int    phg_wsx_find_best_visual();
  411. extern void    phg_wsx_release_window();
  412. extern Window    phg_wsx_create_overlay();
  413. extern void    phg_wsx_destroy_overlay();
  414. extern Ws*    phg_wsx_create();
  415. extern void    phg_wsx_destroy();
  416. extern void    phg_wsx_update_ws_rect();
  417. extern void    phg_wsx_inq_text_extent();
  418. extern int    phg_wsx_build_exposure_rects();
  419. extern void    phg_wsx_synch();
  420. extern void    phg_wsx_convert_rects();
  421. extern void    phg_wsx_lut_update_htab();
  422. extern void    phg_wsx_inq_colr_map_meth_st();
  423.  
  424. extern void    phg_wsx_pm_create_message_win();
  425.  
  426. /* Workstation functions for server structure storage. */
  427. extern Ws*    phg_wsa_open_ws();
  428. extern void    phg_wsa_close_ws();
  429.  
  430. extern int    phg_wsa_resolve_locator();
  431. extern int    phg_wsa_resolve_stroke();
  432. extern int    phg_wsa_resolve_pick();
  433. extern int    phg_wsa_pick_enable();
  434. extern void    phg_wsa_pick_disable();
  435. extern void    phg_wsa_drawable_pick();
  436. extern void    phg_wsa_map_points();
  437. extern void    phg_wsa_redraw_regions();
  438.     /* PM only */
  439. extern Ws*    phg_wsa_pm_open_ws();
  440. extern void    phg_wsa_pm_close_ws();
  441. extern int    phg_wsa_pm_resolve_pick();
  442. extern int    phg_wsa_pm_pick_enable();
  443. extern int    phg_wsa_pm_map_initial_points();
  444. extern int    phg_wsa_pm_valid_pick_path();
  445.  
  446. /* Workstation functions for client-side structure storage. */
  447. extern Ws*    phg_wsb_open_ws();
  448. extern void    phg_wsb_close_ws();
  449. extern Ws*    phg_wsb_pm_open_ws();
  450. extern void    phg_wsb_pm_close_ws();
  451. extern void    phg_wsb_add_el();
  452. extern void    phg_wsb_close_struct();
  453. extern void    phg_wsb_delete_all_structs();
  454. extern int    phg_wsb_delete_struct();
  455. extern int    phg_wsb_delete_struct_net();
  456. extern void    phg_wsb_move_ep();
  457. extern void    phg_wsb_copy_struct();
  458. extern int    phg_wsb_delete_el();
  459. extern void    phg_wsb_redraw_all();
  460. extern void    phg_wsb_conditional_redraw();
  461. extern void    phg_wsb_make_requested_current();
  462. extern void    phg_wsb_repaint_all();
  463. extern void    phg_wsb_traverse_all_postings();
  464. extern void    phg_wsb_traverse_net();
  465. extern void    phg_wsb_resolve_now_action();
  466. extern void    phg_wsb_update();
  467. extern void    phg_wsb_set_disp_update_state();
  468. extern void    phg_wsb_set_hlhsr_mode();
  469. extern void    phg_wsb_set_ws_window();
  470. extern void    phg_wsb_set_ws_vp();
  471. extern void    phg_wsb_set_view_input_priority();
  472. extern void    phg_wsb_set_rep();
  473. extern void    phg_wsb_set_filter();
  474. extern void    phg_wsb_copy_struct();
  475. extern void    phg_wsb_close_struct();
  476. extern int    phg_wsb_asti_update();
  477. extern void    phg_wsb_post();
  478. extern void    phg_wsb_unpost();
  479. extern void    phg_wsb_unpost_all();
  480. extern void    phg_wsb_change_posting();
  481. extern void    phg_wsb_inq_view_indices();
  482. extern void    phg_wsb_inq_posted();
  483. extern void    phg_wsb_inq_view_rep();
  484. extern void    phg_wsb_inq_ws_xform();
  485. extern void    phg_wsb_inq_disp_update_state();
  486. extern void    phg_wsb_inq_hlhsr_mode();
  487. extern void    phg_wsb_inq_rep();
  488. extern int    phg_wsb_resolve_locator();
  489. extern int    phg_wsb_resolve_stroke();
  490. extern int    phg_wsb_resolve_pick();
  491. extern int    phg_wsb_map_initial_points();
  492. extern void    phg_wsb_handle_resize();
  493. extern void    phg_wsb_handle_exposure();
  494. extern void    phg_wsb_inq_filter();
  495. extern void    phg_wsb_drawable_pick();
  496. extern void    phg_wsb_map_points();
  497. extern void    phg_wsb_redraw_regions();
  498.  
  499. #endif    /* PHG_WS_H_INCLUDED */
  500.