00001
00002
00003
00004
00005
00006
00007
00008 #ifndef IMPDISPLAY_MACROS_H
00009 #define IMPDISPLAY_MACROS_H
00010
00011
00012
00013
00014
00015 #define IMP_WRITER(Name) \
00016 Name(TextOutput of): Writer(of, #Name) \
00017 {} \
00018 Name(): Writer(#Name){} \
00019 IMP_OBJECT_INLINE(Name,,close()); \
00020 protected: \
00021 using Writer::process; \
00022 virtual void on_open(); \
00023 virtual void on_close(); \
00024
00025
00026
00027 #define IMP_GEOMETRY(Name) \
00028 IMP::display::Geometries get_components() const; \
00029 IMP_OBJECT(Name)
00030
00031
00032
00033 #define IMP_DISPLAY_GEOMETRY_DECL(Name, Type) \
00034 class IMPDISPLAYEXPORT Name: public Type, \
00035 public Geometry { \
00036 public: \
00037 Name(const Type &v); \
00038 Name(const Type &v, const Color &c); \
00039 Name(const Type &v, const std::string n); \
00040 Name(const Type &v, const Color &c, std::string n); \
00041 IMP_GEOMETRY(Name); \
00042 }; \
00043
00044
00045 #define IMP_DISPLAY_GEOMETRY_DEF(Name, Type) \
00046 Name::Name(const Type &v): Type(v), Geometry(#Name){} \
00047 Name::Name(const Type &v, const Color &c): \
00048 Type(v), Geometry(c, #Name) {} \
00049 Name::Name(const Type &v, const std::string n): \
00050 Type(v), Geometry(n) {} \
00051 Name::Name(const Type &v, const Color &c, std::string n): \
00052 Type(v), Geometry(c,n) {} \
00053 Geometries Name::get_components() const { \
00054 return Geometries(const_cast<Name*>(this)); \
00055 } \
00056 void Name::do_show(std::ostream &out) const { \
00057 out << #Name << "Geometry: " << static_cast<Type >(*this); \
00058 } \
00059
00060
00061 #define IMP_DISPLAY_GEOMETRY_DECOMPOSABLE_DECL(Name, Type) \
00062 class IMPDISPLAYEXPORT Name: public Type, \
00063 public Geometry { \
00064 public: \
00065 Name(const Type &v); \
00066 Name(const Type &v, const Color &c); \
00067 Name(const Type &v, const std::string n); \
00068 Name(const Type &v, const Color &c, std::string n); \
00069 IMP_GEOMETRY(Name); \
00070 }; \
00071
00072
00073 #define IMP_DISPLAY_GEOMETRY_DECOMPOSABLE_DEF(Name, Type, decomp) \
00074 Name::Name(const Type &v): Type(v), Geometry(#Name){} \
00075 Name::Name(const Type &v, const Color &c): \
00076 Type(v), Geometry(c, #Name) {} \
00077 Name::Name(const Type &v, const std::string n): \
00078 Type(v), Geometry(n) {} \
00079 Name::Name(const Type &v, const Color &c, std::string n): \
00080 Type(v), Geometry(c,n) {} \
00081 void Name::do_show(std::ostream &out) const { \
00082 out << #Name << "Geometry: " \
00083 << static_cast<Type>(*this); \
00084 } \
00085 Geometries Name::get_components() const { \
00086 Geometries ret; \
00087 decomp; \
00088 return ret; \
00089 }
00090
00091 #define IMP_PARTICLE_GEOMETRY(Name, Decorator, action) \
00092 class Name##Geometry: public SingletonGeometry { \
00093 public: \
00094 Name##Geometry(Decorator d): SingletonGeometry(d){} \
00095 Geometries get_components() const { \
00096 Geometries ret; \
00097 Decorator d(get_particle()); \
00098 action; \
00099 return ret; \
00100 } \
00101 IMP_OBJECT_INLINE(Name##Geometry, \
00102 out << Decorator(get_particle())<< std::endl;,) \
00103 }; \
00104 class Name##sGeometry: public SingletonsGeometry { \
00105 public: \
00106 Name##sGeometry(SingletonContainer* sc): SingletonsGeometry(sc){} \
00107 Geometries get_components() const { \
00108 Geometries ret; \
00109 for (unsigned int i=0; \
00110 i< get_container()->get_number_of_particles(); \
00111 ++i) { \
00112 Decorator d(get_container()->get_particle(i)); \
00113 action; \
00114 } \
00115 return ret; \
00116 } \
00117 IMP_OBJECT_INLINE(Name##sGeometry, \
00118 out << get_container() << std::endl;,) \
00119 }; \
00120
00121
00122 #define IMP_PARTICLE_TRAITS_GEOMETRY(Name, Decorator, TraitsName, \
00123 traits_name,action) \
00124 class Name##Geometry: public SingletonGeometry { \
00125 TraitsName traits_; \
00126 public: \
00127 Name##Geometry(Decorator d): SingletonGeometry(d), \
00128 traits_(d.get_##traits_name()){} \
00129 Geometries get_components() const { \
00130 Geometries ret; \
00131 Decorator d(get_particle(), traits_); \
00132 action; \
00133 return ret; \
00134 } \
00135 IMP_OBJECT_INLINE(Name##Geometry, \
00136 out << Decorator(get_particle(), traits_) \
00137 << std::endl;,) \
00138 }; \
00139 class Name##sGeometry: public SingletonsGeometry { \
00140 TraitsName traits_; \
00141 public: \
00142 Name##sGeometry(SingletonContainer* sc, TraitsName tr): \
00143 SingletonsGeometry(sc), traits_(tr){} \
00144 Geometries get_components() const { \
00145 Geometries ret; \
00146 for (unsigned int i=0; \
00147 i< get_container()->get_number_of_particles(); \
00148 ++i) { \
00149 Decorator d(get_container()->get_particle(i), traits_); \
00150 action; \
00151 } \
00152 return ret; \
00153 } \
00154 IMP_OBJECT_INLINE(Name##sGeometry, \
00155 out << get_container() << std::endl;,) \
00156 }; \
00157
00158
00159 #define IMP_PARTICLE_PAIR_GEOMETRY(Name, Decorator, action) \
00160 class Name##Geometry: public PairGeometry { \
00161 public: \
00162 Name##Geometry(Decorator d0, Decorator d1): \
00163 PairGeometry(d0, d1){} \
00164 Geometries get_components() const { \
00165 Geometries ret; \
00166 Decorator d0(get_particle_pair()[0]); \
00167 Decorator d1(get_particle_pair()[1]); \
00168 action; \
00169 return ret; \
00170 } \
00171 IMP_OBJECT_INLINE(Name##Geometry, \
00172 out << Decorator(get_particle_pair()[0]) \
00173 << " " << Decorator(get_particle_pair()[1]) \
00174 << std::endl;,); \
00175 }; \
00176 class Name##sGeometry: public PairsGeometry { \
00177 public: \
00178 Name##sGeometry(PairContainer* sc): PairsGeometry(sc){} \
00179 Geometries get_components() const { \
00180 Geometries ret; \
00181 for (unsigned int i=0; \
00182 i< get_container()->get_number_of_particle_pairs(); \
00183 ++i) { \
00184 Decorator d0(get_container()->get_particle_pair(i)[0]); \
00185 Decorator d1(get_container()->get_particle_pair(i)[1]); \
00186 action; \
00187 } \
00188 return ret; \
00189 } \
00190 IMP_OBJECT_INLINE(Name##sGeometry, \
00191 out << get_container() << std::endl;,) \
00192 };
00193
00194 #endif