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

geom_obs.H

Go to the documentation of this file.
00001 #ifndef GEOM_OBS_H_HAS_BEEN_INCLUDED
00002 #define GEOM_OBS_H_HAS_BEEN_INCLUDED
00003 
00004 #include "geom/geom.H"
00005 
00006 #define CXFORMobs_list const XFORMobs_list
00007 #define CXFORMobs      const XFORMobs
00008 class XFORMobs;
00009 typedef ARRAYptrs<XFORMobs*> XFORMobs_list;
00010 //--------------------------------------------
00011 // XFORMobs -
00012 //   An object that can be notified when some
00013 // other object is transformed
00014 //--------------------------------------------
00015 class XFORMobs {
00016       static HASH          _hash_xf;
00017       static XFORMobs_list _all_xf;
00018       static XFORMobs_list _every_xf;
00019    public:
00020       enum STATE { START = 0, // Start of manipulation
00021                    MIDDLE,    // Middle of manipulation
00022                    END,       // End of manipulation
00023                    PRIMARY,   // top-level calls to set_xform/mult_by
00024                    GRAB,      // Start of spreadsheet drag & drop
00025                    DRAG,      // Spreadsheet drag 
00026                    DROP,      // Spreadsheet drop
00027                    NET,       // xform from the network
00028                    EVERY 
00029                  };
00030       virtual ~XFORMobs() {}
00031       virtual          void notify_xform    (CGEOMptr &, STATE state) = 0;
00032       static void notify_xform_obs(CGEOMptr &, STATE start);
00033       static void notify_xform_every_obs(CGEOMptr &);
00034 
00035    /* ---  object xform observer --- */
00036       void   xform_obs  (CGELptr& g)  { xform_obs_list(g).add_uniquely(this); }
00037       void   xform_obs  ()            { _all_xf.add_uniquely(this); }
00038       void   every_xform_obs  ()      { _every_xf.add_uniquely(this); }
00039       void   unobs_xform()            { _all_xf.rem(this); }
00040       void   unobs_every_xform()      { _every_xf.rem(this); }
00041       void   unobs_xform(CGEOMptr &g) { xform_obs_list(g).rem(this); }
00042    protected :
00043       static XFORMobs_list &xform_obs_list(CGELptr &g)  {
00044          XFORMobs_list *list = (XFORMobs_list *) _hash_xf.find((long) &*g);
00045          if (!list)
00046             _hash_xf.add((long)&*g, (void *)(list = new XFORMobs_list));
00047          return *list;
00048       }
00049 };
00050 
00051 
00052 #define CCOLORobs_list const COLORobs_list
00053 #define CCOLORobs      const COLORobs
00054 class COLORobs;
00055 typedef ARRAYptrs<COLORobs*> COLORobs_list;
00056 //--------------------------------------------
00057 // COLORobs -
00058 //   An object that can be notified when some
00059 // other object's color has changed
00060 //--------------------------------------------
00061 class COLORobs {
00062       static COLORobs_list *_all_col;
00063       static COLORobs_list *col_list() { if (!_all_col)
00064                     _all_col = new COLORobs_list; return _all_col; }
00065    public:
00066       virtual ~COLORobs() {}
00067       virtual void notify_color    (CGEOMptr &, APPEAR *app) = 0;
00068       static  void notify_color_obs(CGEOMptr &g, APPEAR *app = 0) {
00069                                    for (int i=0; i < col_list()->num(); i++)
00070                                       (*_all_col)[i]->notify_color(g,
00071                                                                    app ? app
00072                                                            : (APPEAR *) &*g); }
00073 
00074    /* ---  object color observer --- */
00075       void   color_obs  ()            { col_list()->add_uniquely(this); }
00076       void   unobs_color()            { col_list()->rem(this); }
00077 };
00078 
00079 
00080 
00081 #define CTRANSPobs_list const TRANSPobs_list
00082 #define CTRANSPobs      const TRANSPobs
00083 class TRANSPobs;
00084 typedef ARRAYptrs<TRANSPobs*> TRANSPobs_list;
00085 //--------------------------------------------
00086 // TRANSPobs -
00087 //   An object that can be notified when some
00088 // other object's transp has changed
00089 //--------------------------------------------
00090 class TRANSPobs {
00091       static TRANSPobs_list _all_transp;
00092    public:
00093       virtual ~TRANSPobs() {}
00094       virtual void notify_transp    (CGEOMptr &) = 0;
00095       static  void notify_transp_obs(CGEOMptr &g) {
00096                                       for (int i=0; i < _all_transp.num(); i++)
00097                                           _all_transp[i]->notify_transp(g); }
00098 
00099    /* ---  object transp observer --- */
00100       void   transp_obs  ()            { _all_transp.add_uniquely(this); }
00101       void   unobs_transp()            { _all_transp.rem(this); }
00102 };
00103 
00104 #define CTEXTUREobs_list const TEXTUREobs_list
00105 #define CTEXTUREobs      const TEXTUREobs
00106 class TEXTUREobs;
00107 typedef ARRAYptrs<TEXTUREobs*> TEXTUREobs_list;
00108 //--------------------------------------------
00109 // TEXTUREobs -
00110 //   An object that can be notified when some
00111 // other object's texture has changed
00112 //--------------------------------------------
00113 class TEXTUREobs {
00114       static TEXTUREobs_list *_all_texture;
00115 
00116       static TEXTUREobs_list *texobs_list() { if (!_all_texture)
00117                     _all_texture = new TEXTUREobs_list; return _all_texture; }
00118    public:
00119       virtual ~TEXTUREobs() {}
00120       virtual void notify_texture    (CGEOMptr &) = 0;
00121       static  void notify_texture_obs(CGEOMptr &g) {
00122                                 for (int i=0; i < texobs_list()->num(); i++)
00123                                    (*_all_texture)[i]->notify_texture(g); }
00124 
00125    /* ---  object texture observer --- */
00126       void   texture_obs  ()            { texobs_list()->add_uniquely(this); }
00127       void   unobs_texture()            { texobs_list()->rem(this); }
00128 };
00129 
00130 #define CCSGobs_list const CSGobs_list
00131 #define CCSGobs      const CSGobs
00132 class CSGobs;
00133 typedef ARRAYptrs<CSGobs*> CSGobs_list;
00134 //--------------------------------------------
00135 // CSGobs -
00136 //   An object that can be notified when some
00137 // other object's csg has changed
00138 //--------------------------------------------
00139 class CSGobs {
00140       static CSGobs_list _all_csg;
00141    public:
00142       virtual ~CSGobs() {}
00143       virtual void notify_csg    (CGEOMlist &l) = 0;
00144       static  void notify_csg_obs(CGEOMlist &l) {
00145                                          for (int i=0; i < _all_csg.num(); i++)
00146                                              _all_csg[i]->notify_csg(l); }
00147 
00148    /* ---  object csg observer --- */
00149       void   csg_obs  ()            { _all_csg.add_uniquely(this); }
00150       void   unobs_csg()            { _all_csg.rem(this); }
00151 };
00152 
00153 #define CGEOMobs_list const GEOMobs_list
00154 #define CGEOMobs      const GEOMobs
00155 class GEOMobs;
00156 typedef ARRAYptrs<GEOMobs*> GEOMobs_list;
00157 //--------------------------------------------
00158 // GEOMobs -
00159 //   An object that can be notified when some
00160 // other object's geom has changed
00161 //--------------------------------------------
00162 class GEOMobs {
00163       static GEOMobs_list _all_geom;
00164    public:
00165       virtual ~GEOMobs() {}
00166       virtual void notify_geom    (CGEOMptr &l) = 0;
00167       static  void notify_geom_obs(CGEOMptr &l) {
00168                                          for (int i=0; i < _all_geom.num(); i++)
00169                                              _all_geom[i]->notify_geom(l); }
00170 
00171    /* ---  object geom observer --- */
00172       void   geom_obs  ()            { _all_geom.add_uniquely(this); }
00173       void   unobs_geom()            { _all_geom.rem(this); }
00174 };
00175 
00176 #endif // GEOM_OBS_H_HAS_BEEN_INCLUDED
00177 
00178 // end of file geom_obs.H

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