/
geometry_macros.h
192 lines (181 loc) · 12.1 KB
/
geometry_macros.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/**
* \file IMP/display/geometry_macros.h
* \brief macros for display classes
*
* Copyright 2007-2022 IMP Inventors. All rights reserved.
*/
#ifndef IMPDISPLAY_GEOMETRY_MACROS_H
#define IMPDISPLAY_GEOMETRY_MACROS_H
#include "declare_Geometry.h"
#include <IMP/singleton_macros.h>
#include <IMP/pair_macros.h>
//! Define information for an Geometry object
#define IMP_DISPLAY_GEOMETRY_DEF(Name, Type) \
Name::Name(std::string name) : display::Geometry(name) {} \
Name::Name(const Type &v) : display::Geometry(#Name), v_(v) {} \
Name::Name(const Type &v, const Color &c) \
: display::Geometry(c, #Name), v_(v) {} \
Name::Name(const Type &v, const std::string n) \
: display::Geometry(n), v_(v) {} \
Name::Name(const Type &v, const Color &c, std::string n) \
: display::Geometry(c, n), v_(v) {} \
display::Geometries Name::get_components() const { \
return display::Geometries(1, const_cast<Name *>(this)); \
} \
IMP_REQUIRE_SEMICOLON_NAMESPACE
#if defined(IMP_DOXYGEN) || defined(SWIG)
//! Define a geometric object using an IMP::algebra one
#define IMP_DISPLAY_GEOMETRY_DECL(Name, Names, Type) \
/** Display a geometric object.*/ \
class IMPDISPLAYEXPORT Name : public display::Geometry { \
public: \
Name(const Type &v); \
Name(const Type &v, const display::Color &c); \
Name(const Type &v, const std::string n); \
Name(const Type &v, const display::Color &c, std::string n); \
virtual const Type &get_geometry() const { return v_; } \
void set_geometry(const Type &v) { v_ = v; } \
virtual IMP::display::Geometries get_components() const override; \
IMP_OBJECT_METHODS(Name); \
}; \
/** Create a Geometry with the passed primitive.*/ \
inline Name *create_geometry(const Type &t, std::string name = #Type + \
"%1" \
"%")
#define IMP_DISPLAY_GEOMETRY_DECOMPOSABLE_DECL(Name, Names, Type) \
/** Display a compound geometric object.*/ \
class IMPDISPLAYEXPORT Name : public display::Geometry { \
public: \
Name(const Type &v); \
Name(const Type &v, const display::Color &c); \
Name(const Type &v, const std::string n); \
Name(const Type &v, const display::Color &c, std::string n); \
virtual const Type &get_geometry() const { return v_; } \
void set_geometry(const Type &v) { v_ = v; } \
virtual IMP::display::Geometries get_components() const override; \
IMP_OBJECT_METHODS(Name); \
}; \
/** Create a Geometry with the passed primitive.*/ \
inline Name *create_geometry(const Type &t, std::string name = #Type + \
"%1" \
"%")
#else
//! Define a geometric object using an IMP::algebra one
#define IMP_DISPLAY_GEOMETRY_DECL(Name, Names, Type) \
/** Display a geometric object.*/ \
class IMPDISPLAYEXPORT Name : public display::Geometry { \
Type v_; \
\
public: \
Name(std::string name); \
Name(const Type &v); \
Name(const Type &v, const display::Color &c); \
Name(const Type &v, const std::string n); \
Name(const Type &v, const display::Color &c, std::string n); \
virtual const Type &get_geometry() const { return v_; } \
void set_geometry(const Type &v) { v_ = v; } \
virtual IMP::display::Geometries get_components() const override; \
IMP_OBJECT_METHODS(Name); \
}; \
inline Name *create_geometry( \
const Type &t, std::string name = std::string(#Type) + "%1%") { \
return new Name(t, name); \
} \
IMP_OBJECTS(Name, Names)
#define IMP_DISPLAY_GEOMETRY_DECOMPOSABLE_DECL(Name, Names, Type) \
/** Display a compound geometric object.*/ \
class IMPDISPLAYEXPORT Name : public display::Geometry { \
Type v_; \
\
public: \
Name(std::string name); \
Name(const Type &v); \
Name(const Type &v, const display::Color &c); \
Name(const Type &v, const std::string n); \
Name(const Type &v, const display::Color &c, std::string n); \
virtual const Type &get_geometry() const { return v_; } \
void set_geometry(const Type &v) { v_ = v; } \
virtual IMP::display::Geometries get_components() const override; \
IMP_OBJECT_METHODS(Name); \
}; \
inline Name *create_geometry( \
const Type &t, std::string name = std::string(#Type) + "%1%") { \
return new Name(t, name); \
} \
IMP_OBJECTS(Name, Names)
#endif
#define IMP_DISPLAY_GEOMETRY_DECOMPOSABLE_DEF(Name, Type, decomp) \
Name::Name(std::string name) : display::Geometry(name) {} \
Name::Name(const Type &v) : display::Geometry(#Name), v_(v) {} \
Name::Name(const Type &v, const display::Color &c) \
: display::Geometry(c, #Name), v_(v) {} \
Name::Name(const Type &v, const std::string n) \
: display::Geometry(n), v_(v) {} \
Name::Name(const Type &v, const display::Color &c, std::string n) \
: display::Geometry(c, n), v_(v) {} \
display::Geometries Name::get_components() const { \
display::Geometries ret; \
decomp; \
return ret; \
} \
IMP_REQUIRE_SEMICOLON_NAMESPACE
#define IMP_PARTICLE_GEOMETRY(Name, Decorator, action) \
/** Display a particle.*/ \
class Name##Geometry : public display::SingletonGeometry { \
public: \
Name##Geometry(Particle *p) : display::SingletonGeometry(p) {} \
Name##Geometry(Decorator d) : display::SingletonGeometry(d) {} \
IMP_IMPLEMENT_INLINE(display::Geometries get_components() const, { \
display::Geometries ret; \
Decorator d(get_particle()); \
action; \
return ret; \
}); \
IMP_OBJECT_METHODS(Name##Geometry); \
}; \
/** Display multiple particles.*/ \
class Name##sGeometry : public display::SingletonsGeometry { \
public: \
Name##sGeometry(SingletonContainer *sc) \
: display::SingletonsGeometry(sc) {} \
display::Geometries get_components() const override { \
display::Geometries ret; \
for(ParticleIndex pi : get_container()->get_contents()) { \
Decorator d(get_container()->get_model(), pi); \
action; \
} \
return ret; \
} \
IMP_OBJECT_METHODS(Name##sGeometry); \
}
#define IMP_PARTICLE_PAIR_GEOMETRY(Name, Decorator, action) \
/** Display a pair of particles.*/ \
class Name##Geometry : public display::PairGeometry { \
public: \
Name##Geometry(const ParticlePair &pp) \
: display::PairGeometry(pp) {} \
display::Geometries get_components() const override { \
display::Geometries ret; \
Decorator d0(std::get<0>(get_particle_pair())); \
Decorator d1(std::get<1>(get_particle_pair())); \
action; \
return ret; \
} \
IMP_OBJECT_METHODS(Name##Geometry); \
}; \
/** Display multiple pairs of particles.*/ \
class Name##sGeometry : public display::PairsGeometry { \
public: \
Name##sGeometry(PairContainer *sc) : display::PairsGeometry(sc) {} \
display::Geometries get_components() const override { \
display::Geometries ret; \
for(ParticleIndexPair pip : get_container()->get_contents()) { \
Decorator d0(get_container()->get_model(), std::get<0>(pip)); \
Decorator d1(get_container()->get_model(), std::get<1>(pip)); \
action; \
} \
return ret; \
} \
IMP_OBJECT_METHODS(Name##sGeometry); \
}
#endif /* IMPDISPLAY_GEOMETRY_MACROS_H */