8 #ifndef IMPDISPLAY_GEOMETRY_MACROS_H
9 #define IMPDISPLAY_GEOMETRY_MACROS_H
15 #define IMP_DISPLAY_GEOMETRY_DEF(Name, Type) \
16 Name::Name(std::string name) : display::Geometry(name) {} \
17 Name::Name(const Type &v) : display::Geometry(#Name), v_(v) {} \
18 Name::Name(const Type &v, const Color &c) \
19 : display::Geometry(c, #Name), v_(v) {} \
20 Name::Name(const Type &v, const std::string n) \
21 : display::Geometry(n), v_(v) {} \
22 Name::Name(const Type &v, const Color &c, std::string n) \
23 : display::Geometry(c, n), v_(v) {} \
24 display::Geometries Name::get_components() const { \
25 return display::Geometries(1, const_cast<Name *>(this)); \
27 IMP_REQUIRE_SEMICOLON_NAMESPACE
29 #if defined(IMP_DOXYGEN) || defined(SWIG)
31 #define IMP_DISPLAY_GEOMETRY_DECL(Name, Names, Type) \
33 class IMPDISPLAYEXPORT Name : public display::Geometry { \
35 Name(const Type &v); \
36 Name(const Type &v, const display::Color &c); \
37 Name(const Type &v, const std::string n); \
38 Name(const Type &v, const display::Color &c, std::string n); \
39 virtual const Type &get_geometry() const { return v_; } \
40 void set_geometry(const Type &v) { v_ = v; } \
41 virtual IMP::display::Geometries get_components() const IMP_OVERRIDE; \
42 IMP_OBJECT_METHODS(Name); \
45 inline Name *create_geometry(const Type &t, std::string name = #Type + \
49 #define IMP_DISPLAY_GEOMETRY_DECOMPOSABLE_DECL(Name, Names, Type) \
51 class IMPDISPLAYEXPORT Name : public display::Geometry { \
53 Name(const Type &v); \
54 Name(const Type &v, const display::Color &c); \
55 Name(const Type &v, const std::string n); \
56 Name(const Type &v, const display::Color &c, std::string n); \
57 virtual const Type &get_geometry() const { return v_; } \
58 void set_geometry(const Type &v) { v_ = v; } \
59 virtual IMP::display::Geometries get_components() const IMP_OVERRIDE; \
60 IMP_OBJECT_METHODS(Name); \
63 inline Name *create_geometry(const Type &t, std::string name = #Type + \
70 #define IMP_DISPLAY_GEOMETRY_DECL(Name, Names, Type) \
72 class IMPDISPLAYEXPORT Name : public display::Geometry { \
76 Name(std::string name); \
77 Name(const Type &v); \
78 Name(const Type &v, const display::Color &c); \
79 Name(const Type &v, const std::string n); \
80 Name(const Type &v, const display::Color &c, std::string n); \
81 virtual const Type &get_geometry() const { return v_; } \
82 void set_geometry(const Type &v) { v_ = v; } \
83 virtual IMP::display::Geometries get_components() const IMP_OVERRIDE; \
84 IMP_OBJECT_METHODS(Name); \
86 inline Name *create_geometry( \
87 const Type &t, std::string name = std::string(#Type) + "%1%") { \
88 return new Name(t, name); \
90 IMP_OBJECTS(Name, Names)
92 #define IMP_DISPLAY_GEOMETRY_DECOMPOSABLE_DECL(Name, Names, Type) \
94 class IMPDISPLAYEXPORT Name : public display::Geometry { \
98 Name(std::string name); \
99 Name(const Type &v); \
100 Name(const Type &v, const display::Color &c); \
101 Name(const Type &v, const std::string n); \
102 Name(const Type &v, const display::Color &c, std::string n); \
103 virtual const Type &get_geometry() const { return v_; } \
104 void set_geometry(const Type &v) { v_ = v; } \
105 virtual IMP::display::Geometries get_components() const IMP_OVERRIDE; \
106 IMP_OBJECT_METHODS(Name); \
108 inline Name *create_geometry( \
109 const Type &t, std::string name = std::string(#Type) + "%1%") { \
110 return new Name(t, name); \
112 IMP_OBJECTS(Name, Names)
115 #define IMP_DISPLAY_GEOMETRY_DECOMPOSABLE_DEF(Name, Type, decomp) \
116 Name::Name(std::string name) : display::Geometry(name) {} \
117 Name::Name(const Type &v) : display::Geometry(#Name), v_(v) {} \
118 Name::Name(const Type &v, const display::Color &c) \
119 : display::Geometry(c, #Name), v_(v) {} \
120 Name::Name(const Type &v, const std::string n) \
121 : display::Geometry(n), v_(v) {} \
122 Name::Name(const Type &v, const display::Color &c, std::string n) \
123 : display::Geometry(c, n), v_(v) {} \
124 display::Geometries Name::get_components() const { \
125 display::Geometries ret; \
129 IMP_REQUIRE_SEMICOLON_NAMESPACE
131 #define IMP_PARTICLE_GEOMETRY(Name, Decorator, action) \
133 class Name##Geometry : public display::SingletonGeometry { \
135 Name##Geometry(Particle *p) : display::SingletonGeometry(p) {} \
136 Name##Geometry(Decorator d) : display::SingletonGeometry(d) {} \
137 IMP_IMPLEMENT_INLINE(display::Geometries get_components() const, { \
138 display::Geometries ret; \
139 Decorator d(get_particle()); \
143 IMP_OBJECT_METHODS(Name##Geometry); \
146 class Name##sGeometry : public display::SingletonsGeometry { \
148 Name##sGeometry(SingletonContainer *sc) \
149 : display::SingletonsGeometry(sc) {} \
150 display::Geometries get_components() const { \
151 display::Geometries ret; \
152 IMP_FOREACH(ParticleIndex pi, get_container()->get_contents()) { \
153 Decorator d(get_container()->get_model(), pi); \
158 IMP_OBJECT_METHODS(Name##sGeometry); \
161 #define IMP_PARTICLE_PAIR_GEOMETRY(Name, Decorator, action) \
163 class Name##Geometry : public display::PairGeometry { \
165 Name##Geometry(const ParticlePair &pp) \
166 : display::PairGeometry(pp) {} \
167 display::Geometries get_components() const { \
168 display::Geometries ret; \
169 Decorator d0(get_particle_pair()[0]); \
170 Decorator d1(get_particle_pair()[1]); \
174 IMP_OBJECT_METHODS(Name##Geometry); \
177 class Name##sGeometry : public display::PairsGeometry { \
179 Name##sGeometry(PairContainer *sc) : display::PairsGeometry(sc) {} \
180 display::Geometries get_components() const { \
181 display::Geometries ret; \
182 IMP_FOREACH(ParticleIndexPair pip, \
183 get_container()->get_contents()) { \
184 Decorator d0(get_container()->get_model(), pip[0]); \
185 Decorator d1(get_container()->get_model(), pip[1]); \
190 IMP_OBJECT_METHODS(Name##sGeometry); \
Macros for various classes.
Macros for various classes.
Implement geometry for the basic shapes from IMP.algebra.