Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Cursor.H

Go to the documentation of this file.
00001 
00010 #ifndef CURSOR_H
00011 #define CURSOR_H
00012 
00013 // Gluebase includes
00014 #define OUTSIDE_GLUE_CORE
00015 #include <std/list.H>
00016 
00017 #include "DrawObj.H"
00018 #include <DrawMgr.H>
00019 
00020 class Cursor
00021 {
00022  public:
00023 
00024   Cursor() {
00025     active_=true;
00026   }
00027 
00028   virtual ~Cursor() {}
00029 
00030   virtual void addDrawObj(DrawObj *o)    {  
00031     _drawobjs += o; 
00032     moveTo(_curXform,_curScale);
00033     DRAWMGR::registerObj(o);
00034     o->setRoomObj(1);
00035   }
00036 
00037   virtual void removeDrawObj(DrawObj *o) { 
00038     _drawobjs -= o; 
00039     DRAWMGR::removeObj(o);
00040   }
00041 
00043   virtual void saveIcon() {
00044     _lastIcon = _drawobjs;
00045   }
00046   
00048   virtual void removeAllDrawObj() { 
00049     saveIcon();
00050     for (int i=0;i<_drawobjs.num();i++){
00051       DRAWMGR::removeObj(_drawobjs[i]);
00052     }
00053     _drawobjs.clear(); 
00054   }
00055 
00057   virtual void removeAllNoSave(){
00058     for (int i=0;i<_drawobjs.num();i++){
00059       DRAWMGR::removeObj(_drawobjs[i]);
00060     }
00061     _drawobjs.clear();
00062   }
00063 
00065   virtual void resetIcon() {
00066     int i;
00067     //need to remove drawobjs from drawMGR
00068     for (i=0;i<_drawobjs.num();i++){
00069       DRAWMGR::removeObj(_drawobjs[i]);
00070     }
00071     //and add back in the lastIcon ones
00072     for (i=0;i<_lastIcon.num();i++){
00073       DRAWMGR::registerObj(_lastIcon[i]);
00074       _lastIcon[i]->setRoomObj(1);
00075     }
00076     ARRAY<DrawObj*> tmp = _drawobjs;
00077     _drawobjs = _lastIcon;
00078     _lastIcon = tmp;
00079     moveTo(_curXform,_curScale);
00080   }
00081 
00082   virtual void hide() { 
00083     for (int i=0;i<_drawobjs.num();i++)
00084       _drawobjs[i]->hide();
00085   }
00086   virtual void show() {
00087     for (int i=0;i<_drawobjs.num();i++)
00088       _drawobjs[i]->show();
00089   }
00090 
00091   virtual void moveTo(Wtransf m, double scale=1.0) {
00092     _curXform = m;
00093     _curScale=scale;
00094     for (int i=0;i<_drawobjs.num();i++) {
00095       _drawobjs[i]->setTrans(Wtransf::translation(m.origin() - Origin));
00096       _drawobjs[i]->setRot(m.rotation());
00097       _drawobjs[i]->setScale(Wtransf::scaling(m.get_scale())*
00098                  Wtransf::scaling(scale));
00099     }
00100   }
00101 
00102   virtual Wtransf getCurXform() { return _curXform; }
00103   
00104   virtual void activate(){active_=true;};
00105   virtual void deactivate(){active_=false;};
00106   
00107   virtual int active(){return active_;};
00108 
00109   virtual void setColor(Color c) {
00110     for (int i=0;i<_drawobjs.num();i++){
00111       _drawobjs[i]->reColor(c);
00112     }
00113   }
00114 
00115   virtual void setTexture(str_ptr texname) {
00116     cout << "in Cursor::setTexture" << endl;
00117     for (int i=0;i<_drawobjs.num();i++){
00118       _drawobjs[i]->reTexture(texname);
00119     }
00120   }
00121 
00122 
00123  protected:
00124   
00125   ARRAY<DrawObj *> _drawobjs;
00126   ARRAY<DrawObj *> _lastIcon;
00127 
00128   Wtransf _curXform;
00129   double _curScale;
00130 
00131   int active_;
00132 };
00133 
00134 
00135 #endif

Generated on Mon Sep 15 16:27:55 2003 for inspace by doxygen1.2.18