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

icon2d.H

Go to the documentation of this file.
00001 #ifndef ICON2D_H_IS_INCLUDED
00002 #define ICON2D_H_IS_INCLUDED
00003 
00004 #include "std/support.H"
00005 #include "disp/cam.H"
00006 #include "disp/ray.H"
00007 #include "geom/geom.H"
00008 #include "disp/view.H"
00009 #include "dlhandler/dlhandler.H"
00010 #include "geom/texturegl.H"
00011 
00012 // this defines a ICON2Dptr which inherits (sort of) from a
00013 // GEOMptr.  Thus, ICON2Dptr's can be used wherever GEOMptr's are.
00014 //
00015 MAKE_PTR_SUBC(ICON2D,GEOM);
00016 typedef const ICON2Dptr CICON2Dptr;
00017 
00018 class ICON2D : public GEOM {
00019  public:
00020    //constructors
00021    ICON2D() {}
00022    //constructor: passes in the name of the button, the texture name
00023    //the camera number, toggle bool, and the lower left corner pixel location
00024    ICON2D(Cstr_ptr &n, Cstr_ptr &filename, int num, bool tog, const mlib::PIXEL &p);
00025 
00026    DEFINE_RTTI_METHODS3("ICON2D", ICON2D*, GEOM, CDATA_ITEM *);
00027 
00028    bool toggle_suppress_draw() {
00029       return (_suppress_draw = !_suppress_draw);
00030    }
00031       
00032    void add_skin(Cstr_ptr &n);
00033    void update_skin();
00034    void toggle_active() { _active = !_active; }
00035    void toggle_hidden() { _hide = !_hide; }
00036    bool activate() { return (_active = true); }
00037    bool deactivate() {return (_active = false); }
00038 
00039    Cstr_ptr name() {return _name; }
00040 
00041    virtual  BBOX2D  bbox2d   (int b=5, char*s=0, int r=0) const;
00042    virtual  void    update   ()                { }
00043 
00044    virtual  int     draw     (CVIEWptr  &v);
00045    virtual  RAYhit &intersect(RAYhit    &r, mlib::CWtransf &m, int uv = 0) const;
00046 
00047 
00048    int  cam_num()                      { return _cam; } //returns the camera number
00049    bool can_intersect()           const{ return _can_intersect; }
00050    void can_intersect(bool c)          { _can_intersect = c;}
00051    void show_boxes   (bool sb =1 )     { _show_boxes = sb;}
00052    bool &centered    ()                { return _center; }
00053    void set_loc      (mlib::CXYpt &p)        { set_xform(mlib::Wpt(p[0],p[1],0));}
00054    bool  is2d        () const          { return _is2d;}
00055    void set_is2d     (bool is2d)       { _is2d = is2d;}
00056 
00057    //******** GEOM virtual methods ********
00058 
00059    // we use textures with transparency, so needs_blend() should return true.
00060    // this ensures the icons will be drawn AFTER normal objects, so alpha blending
00061    // will work correctly, and icons will not be occluded by others.
00062    virtual bool needs_blend() const { return true; }
00063 
00064  protected:
00065    mlib::NDCZpt         _npt2d;         // might want this instead of XYpt..
00066    mlib::XYpt           _pt2d; 
00067    mlib::PIXEL          _pix;
00068    bool                 _is2d;  
00069    bool                 _center;
00070    bool                 _can_intersect;
00071    bool                 _show_boxes;
00072    str_ptr              _name;          //! name of button
00073    str_ptr              _filename;      //! Filename of 2D image
00074    ARRAY<str_ptr>       _skins;         //! Array of skins for 1 button
00075    int               _currentTex;  
00076    ARRAY<TEXTUREglptr>  _texture;       // 2d texture to map on the icon
00077    TEXTUREglptr         _act_tex; // 2d texture to map on the icon representing "active"
00078    int                  _cam;           //  Camera Number
00079    bool                 _suppress_draw; // turn off ICON (e.g. for making videos!)
00080    bool                 _active; // determines if the button is activated or not
00081    bool                 _toggle; // if the button can be toggled(on and off) or not
00082    bool                 _hide;
00083 
00084    //******** STATICS ********
00085 
00086    static DLhandler     _dl;
00087 
00088    //******** UTILITIES ********
00089 
00090    static void initialize(CVIEWptr &v);
00091 
00092    void   recompute_xform();
00093 };
00094 
00095 #endif // ICON2D_H_IS_INCLUDED
00096 
00097 // end of file ICON2d.H

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