00001 #ifndef GEL_H_IS_INCLUDED
00002 #define GEL_H_IS_INCLUDED
00003
00004 #include "std/support.H"
00005 #include "net/data_item.H"
00006 #include "net/stream.H"
00007 #include "mlib/points.H"
00008 #include "disp/bbox.H"
00009 #include "disp/ref_img_client.H"
00010
00011
00012 class RAYhit;
00013 #define CRAYhit const RAYhit
00014 class RAYnear;
00015 #define CRAYnear const RAYnear
00016 class VIEWptr;
00017 #define CVIEWptr const VIEWptr
00018 class VIEW;
00019
00020
00021 #define CFRAMEobslist const FRAMEobslist
00022 #define CFRAMEobsptr const FRAMEobsptr
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 MAKE_PTR_BASEC(FRAMEobs);
00033 class FRAMEobs: public REFcounter {
00034 protected:
00035
00036
00037 int _index;
00038
00039 public :
00040 FRAMEobs() : _index(-1) {}
00041 virtual ~FRAMEobs() { }
00042
00043 virtual int tick() { return -1; }
00044 virtual void setIndex(int idx) { _index = idx; }
00045 virtual int getIndex() const { return _index; }
00046 };
00047
00048 typedef LIST<FRAMEobsptr> FRAMEobslist;
00049
00050
00051 #define CSCHEDULERptr const SCHEDULERptr
00052 #define CSCHEDULER const SCHEDULER
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 MAKE_PTR_SUBC(SCHEDULER, FRAMEobs);
00063 class SCHEDULER: public FRAMEobs {
00064 protected:
00065 FRAMEobslist _scheduled;
00066 FRAMEobslist _unscheduled;
00067
00068 bool _ticking;
00069
00070 public :
00071 SCHEDULER() : _ticking(0) { }
00072 virtual ~SCHEDULER() {}
00073
00074 virtual int tick(void);
00075
00076 bool is_scheduled(CFRAMEobsptr& o) const;
00077 int get_index (CFRAMEobsptr& o) const;
00078
00079 virtual void schedule (CFRAMEobsptr& o);
00080 virtual void unschedule(CFRAMEobsptr& o);
00081
00082 static STAT_STR_RET static_name() {RET_STAT_STR("SCHEDULER");}
00083 virtual STAT_STR_RET class_name () const{ return static_name(); }
00084 virtual int is_of_type (Cstr_ptr &n)const{ return IS (n);}
00085 static int isa (CSCHEDULERptr &o){ return ISA(o); }
00086 };
00087
00088
00089
00090 MAKE_PTR_BASEC(GEL);
00091 typedef const GELptr CGELptr;
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 class GEL: public REFcounter,
00104 public DATA_ITEM,
00105 public RefImageClient
00106 {
00107 public:
00108 GEL();
00109 virtual ~GEL();
00110
00111 DEFINE_RTTI_METHODS3("GEL", GEL*, DATA_ITEM, CDATA_ITEM*);
00112
00113 virtual CTAGlist& tags() const {
00114 return _gel_tags ? *_gel_tags : *(_gel_tags = new TAGlist);
00115 }
00116 virtual RAYhit& intersect
00117 (RAYhit &r,mlib::CWtransf&m=mlib::Identity,int uv=0)const;
00118 virtual RAYnear& nearest
00119 (RAYnear &r,mlib::CWtransf&m=mlib::Identity) const;
00120 virtual bool inside(mlib::CXYpt_list&)const { return false; }
00121 virtual bool needs_blend() const { return false; }
00122 virtual BBOX bbox(int =0) const { return BBOX(); }
00123 virtual bool cull(const VIEW *) const { return 0; }
00124 virtual int draw(CVIEWptr &) { return 0; }
00125
00126 virtual bool is_3D() const { return false; }
00127 virtual bool can_do_halo() const { return false; }
00128
00129 virtual Cstr_ptr& name () const { return _name; }
00130
00131 virtual ostream& print(ostream &s) const { return s; }
00132 virtual DATA_ITEM* dup () const = 0;
00133
00134 private:
00135 static Cstr_ptr _name;
00136 protected:
00137 GEL(CGELptr &g);
00138 static TAGlist* _gel_tags;
00139 };
00140
00141 STDdstream &operator>>(STDdstream &d, GELptr &p);
00142 STDdstream &operator<<(STDdstream &d,const GEL *p);
00143 inline ostream &operator<<(ostream &d,const GEL *p) {return p?p->print(d):d;}
00144
00145
00146
00147
00148
00149
00150
00151 template <class T>
00152 class GEL_list : public RIC_list<T> {
00153 public :
00154
00155 GEL_list(int n=0) : RIC_list<T>(n) {}
00156
00157
00158 bool cull(const VIEW * v) const{
00159 bool ret = true;
00160 for (int i=0; i<num(); i++)
00161 ret = ret && (*this)[i]->cull(v);
00162 return ret;
00163 }
00164
00165 int draw(CVIEWptr& v) const {
00166 int ret = 0;
00167 for (int i=0; i<num(); i++)
00168 ret += (*this)[i]->draw(v);
00169 return ret;
00170 }
00171
00172 BBOX bbox() const {
00173 BBOX ret;
00174 for (int i=0; i<num(); i++)
00175 ret += (*this)[i]->bbox();
00176 return ret;
00177 }
00178
00179
00180 bool needs_blend() const {
00181 for (int i=0; i<num(); i++)
00182 if ((*this)[i]->needs_blend())
00183 return true;
00184 return false;
00185 }
00186
00187
00188 RAYhit& intersect(RAYhit& r, mlib::CWtransf& m=mlib::Identity) const;
00189
00190 using RIC_list<T>::num;
00191 };
00192
00193
00194
00195
00196
00197
00198 class GELFILT;
00199 class GELlist;
00200 typedef const GELlist CGELlist;
00201 class GELlist : public GEL_list<GELptr> {
00202 public :
00203
00204 GELlist(int n=16) : GEL_list<GELptr>(n) {}
00205 GELlist(CGELptr &g) { add(g); }
00206 GELlist(GEL *g) { add(g); }
00207
00208
00209
00210 GELlist filter(GELFILT&) const;
00211 };
00212
00213
00214
00215 class DrawnList : public GELlist {
00216 protected :
00217 class DispOp {
00218 public:
00219 GELptr _gel;
00220 bool _op;
00221 DispOp(CGELptr &g, bool op = true) : _gel(g), _op(op) {}
00222 DispOp() : _op(false) {}
00223 int operator==(const DispOp &c) const {
00224 return _gel == c._gel && _op == c._op;
00225 }
00226 };
00227 ARRAY<DispOp> _dispq;
00228 bool _buffering;
00229 public :
00230 DrawnList() { }
00231 void add (CGELptr &g);
00232 void rem (CGELptr &g);
00233 GELptr lookup(Cstr_ptr &n) const;
00234
00235 virtual void buffer() { _buffering = 1;}
00236 virtual int buffering() { return _buffering; }
00237 virtual void flush();
00238 };
00239
00240 class ExistList : public GELlist {
00241 public :
00242 ExistList() { }
00243 void add (CGELptr &g);
00244 void rem (CGELptr &g);
00245 GELptr lookup (Cstr_ptr &n) const;
00246 str_ptr unique_dupname(Cstr_ptr &) const;
00247 str_ptr unique_name (Cstr_ptr &) const;
00248 bool allocated() const { return _array != 0; }
00249 };
00250
00251 extern ExistList EXIST;
00252 extern DrawnList DRAWN;
00253
00254
00255 #include "disp/gel_obs.H"
00256 #include "disp/hash_types.H"
00257
00258
00259 extern GrabVar GRABBED;
00260 extern hashvar<int> NO_COLOR_MOD, NO_XFORM_MOD, NO_DISP_MOD, NO_COPY,
00261 PICKABLE,
00262 NETWORK,
00263 NO_CONSTRAINT_MOD,
00264 NO_SCALE_MOD,
00265 NO_EXTNETWORK,
00266
00267 NO_SAVE;
00268
00269 extern hashvar<mlib::Wpt> CONSTRAINT_POINT;
00270 extern hashvar<mlib::Wvec> CONSTRAINT_VECTOR;
00271
00272 #endif // GEL_H_IS_INCLUDED
00273
00274