Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class 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 namespace InSpace {
00021 
00022 class Cursor
00023 {
00024  public:
00025 
00026   Cursor() {
00027     active_=true;
00028   }
00029 
00030   virtual ~Cursor() {}
00031 
00032   virtual void addDrawObj(DrawObj *o)    {  
00033     _drawobjs += o; 
00034     moveTo(_curXform,_curScale);
00035     DRAWMGR::registerObj(o);
00036     o->setRoomObj(1);
00037   }
00038 
00039   virtual void removeDrawObj(DrawObj *o) { 
00040     _drawobjs -= o; 
00041     DRAWMGR::removeObj(o);
00042   }
00043 
00045   virtual void saveIcon() {
00046     _lastIcon = _drawobjs;
00047   }
00048   
00050   virtual void removeAllDrawObj() { 
00051     saveIcon();
00052     for (int i=0;i<_drawobjs.num();i++){
00053       DRAWMGR::removeObj(_drawobjs[i]);
00054     }
00055     _drawobjs.clear(); 
00056   }
00057 
00059   virtual void removeAllNoSave(){
00060     for (int i=0;i<_drawobjs.num();i++){
00061       DRAWMGR::removeObj(_drawobjs[i]);
00062     }
00063     _drawobjs.clear();
00064   }
00065 
00067   virtual void resetIcon() {
00068     int i;
00069     //need to remove drawobjs from drawMGR
00070     for (i=0;i<_drawobjs.num();i++){
00071       DRAWMGR::removeObj(_drawobjs[i]);
00072     }
00073     //and add back in the lastIcon ones
00074     for (i=0;i<_lastIcon.num();i++){
00075       DRAWMGR::registerObj(_lastIcon[i]);
00076       _lastIcon[i]->setRoomObj(1);
00077     }
00078     ARRAY<DrawObj*> tmp = _drawobjs;
00079     _drawobjs = _lastIcon;
00080     _lastIcon = tmp;
00081     moveTo(_curXform,_curScale);
00082   }
00083 
00084   virtual void hide() { 
00085     for (int i=0;i<_drawobjs.num();i++)
00086       _drawobjs[i]->hide();
00087   }
00088   virtual void show() {
00089     for (int i=0;i<_drawobjs.num();i++)
00090       _drawobjs[i]->show();
00091   }
00092 
00093   virtual void moveTo(Wtransf m, double scale=1.0) {
00094     _curXform = m;
00095     _curScale=scale;
00096     for (int i=0;i<_drawobjs.num();i++) {
00097       _drawobjs[i]->setTrans(Wtransf::translation(m.origin() - Origin));
00098       _drawobjs[i]->setRot(m.rotation());
00099       _drawobjs[i]->setScale(Wtransf::scaling(m.get_scale())*
00100                  Wtransf::scaling(scale));
00101     }
00102   }
00103 
00104   virtual Wtransf getCurXform() { return _curXform; }
00105   
00106   virtual void activate(){active_=true;};
00107   virtual void deactivate(){active_=false;};
00108   
00109   virtual int active(){return active_;};
00110 
00111   virtual void setColor(Color c) {
00112     for (int i=0;i<_drawobjs.num();i++){
00113       _drawobjs[i]->reColor(c);
00114     }
00115   }
00116 
00117   virtual void setTexture(str_ptr texname) {
00118     cout << "in Cursor::setTexture" << endl;
00119     for (int i=0;i<_drawobjs.num();i++){
00120       _drawobjs[i]->reTexture(texname);
00121     }
00122   }
00123 
00124 
00125  protected:
00126   
00127   ARRAY<DrawObj *> _drawobjs;
00128   ARRAY<DrawObj *> _lastIcon;
00129 
00130   Wtransf _curXform;
00131   double _curScale;
00132 
00133   int active_;
00134 };
00135 
00136 }
00137 #endif

Generated on Thu Jul 8 15:19:28 2004 for inspace by doxygen 1.3.4