Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

buffer_ref_image.H

Go to the documentation of this file.
00001 /*****************************************************************
00002  * buffer_ref_image.H
00003  *****************************************************************/
00004 #ifndef BUFFER_REF_IMAGE_HEADER
00005 #define BUFFER_REF_IMAGE_HEADER
00006 
00007 #include "std/support.H"
00008 #include "gtex/ref_image.H"
00009 
00010 /**********************************************************************
00011  * BufferRefImage:
00012  *
00013  * Used to speed interactive drawing applications.  Interactive
00014  * stuff (gesture polylines) are added to a list of objects and
00015  * drawn to the the view after first copying the image.  The
00016  * image has a similar update policy to VisRefImage.  When the
00017  * camera, etc. are unchanging, this image obviates the need to
00018  * draw the scene, thereby accelerating drawing responsiveness.
00019  *
00020  **********************************************************************/
00021 
00022 
00023 #define COUNTUP 4
00024 #define CBufferRefImage const BufferRefImage
00025 
00026 MAKE_PTR_SUBC(BufferRefImage, FRAMEobs);
00027 
00028 class BufferRefImage : public RefImage,
00029                        protected DISPobs,
00030                        protected XFORMobs,
00031                        protected CAMobs,
00032                        protected BMESHobs,
00033                        public FRAMEobs,
00034                        protected VIEWobs
00035 {
00036  public:
00037    virtual ~BufferRefImage() { unobserve(); }
00038 
00039    //******** MANAGERS ********
00040    // no public constructor -- get your hands on one this way:
00041    static BufferRefImage* lookup(CVIEWptr& v);
00042 
00043    // make sure the reference image is current:
00044    virtual void update();
00045    int need_update();
00046 
00047    void force_dirty() { _dirty = 1; }
00048 
00049    // to turn observing on/off:
00050    void observe  ();
00051    void unobserve();
00052    bool is_observing() {return _observing;}
00053 
00054    void add (CGELptr &g) { _list.add(g);}
00055    bool rem (CGELptr &g) { return _list.rem(g);} 
00056    CGELlist & list () {return _list;}
00057 
00058    //void draw_list() {draw_objects(_list);}
00059 
00060    virtual int  tick();
00061 
00062    //*******************************************************
00063    // PROTECTED
00064    //*******************************************************
00065  protected:
00066    BufferRefImage(CVIEWptr& v);
00067 
00068    static  HASH  _hash; // associates a BufferRefImage with a VIEW
00069 
00070    //******** DATA ********
00071    int          _dirty;             // flag set when change occurred
00072    int          _countup;
00073    bool         _observing;
00074    GELlist      _list;
00075 
00076    GELptr      _f; //fps
00077 
00078    //******** UPDATING ********
00079    void reset() { _dirty = 1; _countup = 0; }
00080    
00081    virtual bool resize(uint new_w, uint new_h) {
00082       if (!RefImage::resize(new_w, new_h))
00083          return false;
00084       reset();
00085       return true;
00086    }
00087 
00088    //******** OBSERVER METHODS ********:
00089 
00090    // Convenience, used below:
00091    void changed() { reset(); _countup = COUNTUP; }
00092 
00093    // EXISTobs:
00094    // XXX - BufferRefImage does not derive from EXISTobs so the
00095    //       following has no effect:
00096    virtual void notify_exist (CGELptr&, int) { changed(); }
00097 
00098    // DISPobs:
00099    virtual void notify       (CGELptr&, int) { changed(); }
00100 
00101    // CAMobs:
00102    virtual void notify(CCAMdataptr&) { reset(); }       // It's different
00103 
00104    // XFORMobs
00105    virtual void notify_xform (CGEOMptr&, STATE) { changed(); }
00106 
00107    // BMESHobs:
00108    virtual void notify_xform (BMESH*, mlib::CWtransf&, CMOD&){ changed(); } 
00109    virtual void notify_change(BMESH*, BMESH::change_t) { changed(); }
00110 
00111    virtual void notify_view   (CVIEWptr &v, int) { if (v == _view) changed(); }
00112 };
00113 
00114 #endif // BUFFER_REF_IMAGE_HEADER
00115 
00116 /* end of file buffer_ref_image.H */

Generated on Mon Sep 18 11:39:28 2006 for jot by  doxygen 1.4.4