/* * This Software is the original work of Daniel TUNG * This Software is submitted in partial fulfillment of the * requirements for the degree of BCSE. * Dept. Computer Science, Monash University 2000 * * Copyright (c) 2000 beetung@cs.monash.edu.au * beetung@geocities.com */ #ifndef XWIN_H #define XWIN_H #include extern "C" { #include #include #include #include #include #include }; #include "fastbuf.h" #include "semaphore.h" //// //// Our main Xwindow class, with some ugly and disgusting code //// //////////////////////////////////////// //////class Xwin : public Thread { class Xwin { //////////////////////////////////////// public: void* vdoSim () ; // simulate grapping a track void* vdoSimNodeSwim () ; // simulate grapping a track void* vdoSimNodeSwimLock () ; // simulate grapping a track void getCriticalRegion (void); public: ~Xwin(); // Xwin(string); void realize_window (void) ; // flush window out void* serveEvent (void) ; // serveWindow Event void serveQLock (void) ; // 'Q' to lock and unlock int serveKey (void) ; // serve arrow keys void serveStop (void) ; // stop serve, dont unmap void serveStart (void) ; // start serve again void drawXShm (const int&) const ; // Draw XImage to screen void drawXShm (XImage*&) ; // void drawXShm (Fastbuf*) ; // void setBaseFrame (Fastbuf*) ; // void drawBaseFrame (void) ; // void drawX (XImage*&) ; // void drawGrid (void); void markPoint (int,int,int); int wait4Click (void); void setSimBuf (Fastbuf *); void setFastbuf (Fastbuf *); void initNode (void); void copyBaseFrame (void); //------------------------------- operator bool (void) { return isAlive; } //------------------------------- Xwin& operator<< ( const string& s) { //------------------------------- drawString(s.c_str()); return *this; } //------------------------------- Xwin& operator<< ( const char* mesg) { //------------------------------- drawString(mesg); return *this; } private: void init_X11 (string&); // void execute_once (void) ; // things to execute 1ce void init_color (void) ; // void init_cursor (void) ; // void terminate_X11 (void) ; // Destructor call void serveExit (void) ; // exit from serveEvent() protected: void drawString (const char *); // write on screen void drawString (const char *,int,int); // write on screen /// /// static variable initialized via a static function /// //------------------------------- static int& winID_total(void) { //------------------------------- static int _wCount =0; return _wCount; } private: int winID ; // unique ID to identify this.Xwindow int strPosX,strPosY ; // drawString next position int mx,my ; // drawString stuff protected: bool ready2sim; // ready to simulate yet? bool isAlive; // X quiting? bool isStopServe; // stop serving, but dont unmap private: /* ------------[ Xwindows stuff ]------------------------ */ Display *dpy; // display Window w; // window GC gc; // graphic context XEvent e; // event Font font; // Cursor cursor; // my cursor /* ------------------------------------------------------- */ // // these are redundant if non-static right? // static int depth; // depth of display static int blackColor; // Colors static int whiteColor; // static XColor colorList[9]; // some default colors static const int colorMod =9; /* ------------------------------------------------------- */ /// /// Frame Related Variables /// protected: // // these are for simulation only // int frameID; int frameCount; int nodeCount; Fastbuf *simBuffer[100]; // image buffers copied from image sequences public: // // these are for the real thing, ie: grabbing image from bttv // bool kbhitArrows; // keyboard hit? bool isSettingNode; // Q lock, setting nodes? Fastbuf *baseFrame ; // for simulating the 2 frame buffers // provided by our bttv card, ie: we can // only capture to frame[0] and frame[1] /* ------------------------------------------------------- */ private: enum { SCREEN_COLUMN_PIXEL =(384), SCREEN_ROW_PIXEL =(288), FRAME_SIZE_X =(SCREEN_COLUMN_PIXEL) , FRAME_SIZE_Y =(SCREEN_ROW_PIXEL) , FRAME_XY_SIZE =(FRAME_SIZE_X*FRAME_SIZE_Y) }; protected: }; /////////////////////////////////////////////////////////// class XStreamWin : public Xwin { /////////////////////////////////////////////////////////// private: MySemaphore aSem; // this one should die with the object!!! // - to synchronize betwn isSettingNodes public: XStreamWin(string s) : Xwin (s){;} ~XStreamWin() {;} }; #endif