viewer/grphics.h

Go to the documentation of this file.
00001 
00019 #ifndef           GRPHICS_H
00020 #define           GRPHICS_H
00021 
00036 #include          "sbgdefs.h"
00037 #include          "sbgconst.h"
00038 
00040 #define STATESIZE     13
00041 
00042 #define line_color_index(fd,index) fd->Line_color_index(index)
00043 #define perimeter_color_index(fd,index) fd->Perimeter_color_index(index)
00044 #define fill_color_index(fd,index) fd->Fill_color_index(index)
00045 #define fill_color(fd,r,g,b) fd->Fill_color(r,g,b)
00046 #define text_color_index(fd,index) fd->Text_color_index(index)
00047 #define text_font_index(fd,index) fd->Text_font_index(index)
00048 #define character_height(fd,height) fd->Character_height(height)
00049 #define line_type(fd,style) fd->Line_type(style)
00050 #define interior_style(fd,style,edged) fd->Interior_style(style,edged)
00051 #define move2d(fd,x,y) fd->Move2d(x,y)
00052 #define draw2d(fd,x,y) fd->Draw2d(x,y)
00053 #define rectangle(fd,x1,y1,x2,y2) fd->Rectangle(x1,y1,x2,y2)
00054 #define text2d(fd,x,y,string,xform,more) fd->Text2d(x,y,string,xform,more)
00055 #define ellipse(fd,x_radius,y_radius,x_center,y_center,rotation) fd->Ellipse(x_radius,y_radius,x_center,y_center,rotation)
00056 #define destroy_window(fd) fd->Destroy_window()
00057 #define clear_view_surface(fd) fd->Clear_view_surface()
00058 #define vdc_extent(fd,xmin,ymin,xmax,ymax) fd->Vdc_extent(xmin,ymin,xmax,ymax)
00059 #define make_picture_current(fd) fd->Make_picture_current()
00060 #define set_click_handler(fd,handler) fd->Set_click_handler(handler)
00061 #define set_selection_handler(fd,handler) fd->Set_selection_handler(handler)
00062 #define set_key_handler(fd,handler) fd->Set_key_handler(handler)
00063 #define set_destroy_handler(fd,handler) fd->Set_destroy_handler(handler)
00064 #define clear_event_queue(fd) fd->Clear_event_queue()
00065 #define create_window(name,window_type,xpos,ypos,xsize,ysize,xmin,xmax,ymin,ymax,downon,moveon,upon,keyon) (*create_func)(name,window_type,xpos,ypos,xsize,ysize,xmin,xmax,ymin,ymax,downon,moveon,upon,keyon)
00066 #define overlap_picture_ops(update) (*overlap_func)(update)
00067 #define await_event(win,wait,type,event) (*await_event_func)(win,wait,type,event)
00068 
00069 typedef void (*EVENT_HANDLER) (GRAPHICS_EVENT *);
00070                                  /*name/title of window */
00071 typedef WINDOW (*WINCREATEFUNC) (const char *name,
00072 INT8 window_type,                /*type of window */
00073 INT16 xpos,                      /*coords of window */
00074 INT16 ypos,                      /*coords of window */
00075 INT16 xsize,                     /*size of window */
00076 INT16 ysize,                     /*size of window */
00077 float xmin,                      /*scrolling limits */
00078 float xmax,                      /*to stop users */
00079 float ymin,                      /*getting lost in */
00080 float ymax,                      /*empty space */
00081 BOOL8 downon,                    /*Events wanted */
00082 BOOL8 moveon, BOOL8 upon, BOOL8 keyon);
00083 
00084 extern WINCREATEFUNC create_func;
00085 extern void (*overlap_func) (BOOL8);
00086 extern WINDOW (*await_event_func) (WINDOW, BOOL8, INT8, GRAPHICS_EVENT *);
00087 
00088 
00101 class DLLSYM WINFD
00102 {
00103   public:
00104     //Constructors for WINFD are host dependent to match different
00105     //implementations and are intended to be called only by
00106     //create_window. Use create_window to make a window.
00107     static WINDOW create(                   /*create a window */
00108                          const char *name,  /*name/title of window */
00109                          INT8 window_type,  /*type of window */
00110                          INT16 xpos,        /*coords of window */
00111                          INT16 ypos,        /*coords of window */
00112                          INT16 xsize,       /*size of window */
00113                          INT16 ysize,       /*size of window */
00114                          float xmin,        /*scrolling limits */
00115                          float xmax,        /*to stop users */
00116                          float ymin,        /*getting lost in */
00117                          float ymax,        /*empty space */
00118                          BOOL8 downon,      /*Events wanted */
00119                          BOOL8 moveon,
00120                          BOOL8 upon,
00121                          BOOL8 keyon);
00122     WINFD();  //constructor
00123     virtual ~ WINFD ();
00124 
00125                                  /*set line colour */
00126     virtual void Line_color_index(COLOUR index);  /*index to use */
00127                                  /*set perimeter colour */
00128     virtual void Perimeter_color_index(COLOUR index);  /*index to use */
00129                                  /*set fill colour */
00130     virtual void Fill_color_index(COLOUR index);  /*index to use */
00131     virtual void Fill_color(  /*set RGB fill colour */
00132                             UINT8 red,
00133                             UINT8 green,
00134                             UINT8 blue);
00135                                  /*set marker colour */
00136     virtual void Marker_color_index(COLOUR index);  /*index to use */
00137                                  /*set text colour */
00138     virtual void Text_color_index(COLOUR index);  /*index to use */
00139                                  /*set text font */
00140     virtual void Text_font_index(INT16 index);  /*index to use */
00141                                  /*set text height */
00142     virtual void Character_height(float height);  /*height to use */
00143     virtual void Line_type(               /*set line type */
00144                            INT16 style);  /*style to use */
00145     virtual void Marker_type(              /*set marker type */
00146                              INT16 type);  /*type to use */
00147     virtual void Interior_style(               /*set polygon style */
00148                                 INT16 style,   /*style to use */
00149                                 INT16 edged);  /*draw edge or not */
00150     virtual void Marker_size(              /*set marker size */
00151                              float size);  /*size to use */
00152     virtual void Move2d(           /*move the pen */
00153                         float x,   /*coords to move to */
00154                         float y);  /*coords to move to */
00155     virtual void Draw2d(           /*draw the pen */
00156                         float x,   /*coords to draw to */
00157                         float y);  /*coords to draw to */
00158     virtual void Rectangle(            /*draw a rectangle */
00159                            float x1,   /*coords to draw to */
00160                            float y1,   /*coords to draw to */
00161                            float x2,   /*coords to draw to */
00162                            float y2);  /*coords to draw to */
00163     virtual void Text_alignment(                 /*draw a rectangle */
00164                                 INT32 h_select,  //horizontal
00165                                 INT32 v_select,  //vertical
00166                                 float horiz,     /*coords to draw to */
00167                                 float vert);     /*coords to draw to */
00168     virtual void Polyline2d (    /*draw a polyline */
00169       float clist[],             /*coordinate list */
00170       INT16 numpts,              /*number of coords */
00171       INT16 flags);              /*does it have move/draws */
00172     virtual void Polygon2d (     /*draw a polygon */
00173       float clist[],             /*coordinate list */
00174       INT16 numpts,              /*number of coords */
00175       INT16 flags);              /*does it have move/draws */
00176     virtual void Polymarker2d (  /*draw a polymarker */
00177       float clist[],             /*coordinate list */
00178       INT16 numpts,              /*number of coords */
00179       INT16 flags);              /*does it have move/draws */
00180     virtual void Text2d(                     /*draw a text */
00181                         float x,             /*coords of text */
00182                         float y,
00183                         const char *string,  /*text to draw */
00184                         INT16 xform,         /*transform */
00185                         INT16 more);         /*more text? */
00186     void Append_text(                     /*draw a text */
00187                      const char *string,  /*text to draw */
00188                      INT16 xform,         /*transform */
00189                      INT16 more);         /*more text? */
00190     virtual void Ellipse(                  /*draw a ellipse */
00191                          float x_radius,   /*radii of ellipse */
00192                          float y_radius,   /*radii of ellipse */
00193                          float x_center,   /*centre of ellipse */
00194                          float y_center,   /*centre of ellipse */
00195                          float rotation);  /*rotation of ellipse */
00196     virtual void Arc(                    /*draw a arc */
00197                      float x_radius,     /*radii of arc */
00198                      float y_radius,     /*radii of arc */
00199                      float x_center,     /*centre of arc */
00200                      float y_center,     /*centre of arc */
00201                      float start,        /*ends of arc */
00202                      float stop,         /*ends of arc */
00203                      float rotation,     /*rotation of arc */
00204                      INT16 close_type);  /*type of closure */
00205                                  /*destroy a window */
00206     virtual void Destroy_window(); 
00207                                  /*clear window */
00208     virtual void Clear_view_surface(); 
00209                                  /*Mark need to recalc */
00210     virtual void Re_compute_colourmap(); 
00211     virtual void Vdc_extent(              /*set window focus */
00212                             float xmin,   /*min values */
00213                             float ymin,   /*min values */
00214                             float xmax,   /*max values */
00215                             float ymax);  /*max values */
00216     void Set_echo(                      /*set window echo */
00217                   ECHO_TYPE echo_type,  //type of echo
00218                   float xorig,          /*min values */
00219                   float yorig);         /*min values */
00220                                  /*update window */
00221     virtual void Make_picture_current(); 
00222                                  /*flush output */
00223     friend void def_overlap_picture_ops(BOOL8 update);  /*send make_ */
00224                                  /*set line colour */
00225     virtual void Synchronize_windows(WINDOW fd2);  //other window
00226     /*   void              Show_sub_image(            //show rectangle
00227         IMAGE*          source,                 //source image
00228         INT32           xstart,                 //start coords
00229         INT32           ystart,
00230         INT32           xext,                //extent to copy
00231         INT32           yext,
00232         INT32           xdest,                  //destination coords
00233         INT32           ydest);*/
00234 
00235     INT16 get_fd() {  //access
00236       return fd;
00237     }
00238 
00239     void Set_selection_handler(                         //set callback function
00240                                EVENT_HANDLER handler);  //handler function
00241     void Set_key_handler(                         //set callback function
00242                          EVENT_HANDLER handler);  //handler function
00243     void Set_destroy_handler(                         //set callback function
00244                              EVENT_HANDLER handler);  //handler function
00245     void Set_click_handler(                         //set callback function
00246                            EVENT_HANDLER handler);  //handler function
00247                                  /*delete all events */
00248     virtual void Clear_event_queue(); 
00249 
00250     //internal maintenance functions
00251     friend void add_event(                         /*add an event */
00252                           GRAPHICS_EVENT *event);  /*event to add */
00253                                  /*search for event */
00254     friend GRAPHICS_EVENT *search_event_queue(INT16 &fd,         /*queue to search */
00255                                               INT8 event_type);  /*type to search for */
00256                                  /*search for event */
00257     friend GRAPHICS_EVENT *search_single_queue(INT16 fd,          /*queue to search */
00258                                                INT8 event_type);  /*type to search for */
00259 
00260   protected:
00261     EVENT_HANDLER click_handler; //callback function
00262                                  //callback function
00263     EVENT_HANDLER selection_handler;
00264     EVENT_HANDLER key_handler;   //callback function
00265                                  //callback function
00266     EVENT_HANDLER destroy_handler;
00267   private:
00268     void get_lock() { 
00269     }                            //wait for lock
00270     void get_lock_for_draw() { 
00271     }                            //kill draw thread
00272     void release_lock() { 
00273     }                            //let it go
00274     void get_core_lock() { 
00275     }                            //wait for lock
00276     void release_core_lock() { 
00277     }                            //let it go
00278 
00279     INT16 fd;                    //"file descriptor"
00280     BOOL8 used;                  /*true if fd in use */
00281     BOOL8 downevent;             /*event flags */
00282     BOOL8 moveevent;
00283     BOOL8 upevent;
00284     BOOL8 keyevent;
00285     GRAPHICS_EVENT *events;      /*event queue */
00286     GRAPHICS_EVENT *lastevent;   /*event queue */
00287 };
00288 #endif

Generated on Wed Feb 28 19:49:12 2007 for Tesseract by  doxygen 1.5.1