BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
FormFactorItems.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Sample/FormFactorItems.h
6 //! @brief Defines FormFactorItems classes
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_MODEL_SAMPLE_FORMFACTORITEMS_H
16 #define BORNAGAIN_GUI_MODEL_SAMPLE_FORMFACTORITEMS_H
17 
20 #include <QVector>
21 #include <memory>
22 
23 class IFormFactor;
24 class GroupInfo;
25 
26 #define FF_PROPERTY(nameLower, nameUpper) \
27 private: \
28  DoubleProperty m_##nameLower; \
29  \
30 public: \
31  DoubleDescriptor nameLower() const { return m_##nameLower; } \
32  void set##nameUpper(double v) { m_##nameLower.set(v); }
33 
35 public:
36  virtual ~FormFactorItem() = default;
37 
38 public:
39  virtual std::unique_ptr<IFormFactor> createFormFactor() const = 0;
40  virtual DoubleDescriptors geometryValues() const = 0;
41  virtual QVector<DoubleProperty*> serializationProperties() = 0;
42  virtual void serialize(Streamer& s);
43 };
44 
45 class Pyramid2Item : public FormFactorItem {
46 public:
47  Pyramid2Item();
48  std::unique_ptr<IFormFactor> createFormFactor() const override;
49 
50  FF_PROPERTY(length, Length)
51  FF_PROPERTY(width, Width)
52  FF_PROPERTY(height, Height)
53  FF_PROPERTY(alpha, Alpha)
54 
56  {
57  return {length(), width(), height(), alpha()};
58  }
59  QVector<DoubleProperty*> serializationProperties() override
60  {
61  return {&m_length, &m_width, &m_height, &m_alpha};
62  }
63 };
64 
65 class BarGaussItem : public FormFactorItem {
66 public:
67  BarGaussItem();
68  std::unique_ptr<IFormFactor> createFormFactor() const override;
69 
70  FF_PROPERTY(length, Length)
71  FF_PROPERTY(width, Width)
72  FF_PROPERTY(height, Height)
73 
74  DoubleDescriptors geometryValues() const override { return {length(), width(), height()}; }
75  QVector<DoubleProperty*> serializationProperties() override
76  {
77  return {&m_length, &m_width, &m_height};
78  }
79 };
80 
82 public:
84  std::unique_ptr<IFormFactor> createFormFactor() const override;
85 
86  FF_PROPERTY(length, Length)
87  FF_PROPERTY(width, Width)
88  FF_PROPERTY(height, Height)
89 
90  DoubleDescriptors geometryValues() const override { return {length(), width(), height()}; }
91  QVector<DoubleProperty*> serializationProperties() override
92  {
93  return {&m_length, &m_width, &m_height};
94  }
95 };
96 
97 class BoxItem : public FormFactorItem {
98 public:
99  BoxItem();
100  std::unique_ptr<IFormFactor> createFormFactor() const override;
101 
102  FF_PROPERTY(length, Length)
103  FF_PROPERTY(width, Width)
104  FF_PROPERTY(height, Height)
105 
106  DoubleDescriptors geometryValues() const override { return {length(), width(), height()}; }
107  QVector<DoubleProperty*> serializationProperties() override
108  {
109  return {&m_length, &m_width, &m_height};
110  }
111 };
112 
113 class ConeItem : public FormFactorItem {
114 public:
115  ConeItem();
116  std::unique_ptr<IFormFactor> createFormFactor() const override;
117 
118  FF_PROPERTY(radius, Radius)
119  FF_PROPERTY(height, Height)
120  FF_PROPERTY(alpha, Alpha)
121 
122  DoubleDescriptors geometryValues() const override { return {radius(), height(), alpha()}; }
123  QVector<DoubleProperty*> serializationProperties() override
124  {
125  return {&m_radius, &m_height, &m_alpha};
126  }
127 };
128 
129 class Pyramid6Item : public FormFactorItem {
130 public:
131  Pyramid6Item();
132  std::unique_ptr<IFormFactor> createFormFactor() const override;
133 
134  FF_PROPERTY(baseEdge, BaseEdge)
135  FF_PROPERTY(height, Height)
136  FF_PROPERTY(alpha, Alpha)
137 
138  DoubleDescriptors geometryValues() const override { return {baseEdge(), height(), alpha()}; }
139  QVector<DoubleProperty*> serializationProperties() override
140  {
141  return {&m_baseEdge, &m_height, &m_alpha};
142  }
143 };
144 
146 public:
147  Bipyramid4Item();
148  std::unique_ptr<IFormFactor> createFormFactor() const override;
149 
150  FF_PROPERTY(length, Length)
151  FF_PROPERTY(height, Height)
152  FF_PROPERTY(heightRatio, HeightRatio)
153  FF_PROPERTY(alpha, Alpha)
154 
156  {
157  return {length(), height(), heightRatio(), alpha()};
158  }
159  QVector<DoubleProperty*> serializationProperties() override
160  {
161  return {&m_length, &m_height, &m_heightRatio, &m_alpha};
162  }
163 };
164 
165 class CylinderItem : public FormFactorItem {
166 public:
167  CylinderItem();
168  std::unique_ptr<IFormFactor> createFormFactor() const override;
169 
170  FF_PROPERTY(radius, Radius)
171  FF_PROPERTY(height, Height)
172 
173  DoubleDescriptors geometryValues() const override { return {radius(), height()}; }
174  QVector<DoubleProperty*> serializationProperties() override { return {&m_radius, &m_height}; }
175 };
176 
178 public:
180  std::unique_ptr<IFormFactor> createFormFactor() const override;
181 
182  FF_PROPERTY(edge, Edge)
183 
184  DoubleDescriptors geometryValues() const override { return {edge()}; }
185  QVector<DoubleProperty*> serializationProperties() override { return {&m_edge}; }
186 };
187 
189 public:
191  std::unique_ptr<IFormFactor> createFormFactor() const override;
192 
193  FF_PROPERTY(radiusX, RadiusX)
194  FF_PROPERTY(radiusY, RadiusY)
195  FF_PROPERTY(height, Height)
196 
197  DoubleDescriptors geometryValues() const override { return {radiusX(), radiusY(), height()}; }
198  QVector<DoubleProperty*> serializationProperties() override
199  {
200  return {&m_radiusX, &m_radiusY, &m_height};
201  }
202 };
203 
204 class SphereItem : public FormFactorItem {
205 public:
206  SphereItem();
207  std::unique_ptr<IFormFactor> createFormFactor() const override;
208 
209  FF_PROPERTY(radius, Radius)
210 
211  DoubleDescriptors geometryValues() const override { return {radius()}; }
212  QVector<DoubleProperty*> serializationProperties() override { return {&m_radius}; }
213 };
214 
215 class SpheroidItem : public FormFactorItem {
216 public:
217  SpheroidItem();
218  std::unique_ptr<IFormFactor> createFormFactor() const override;
219 
220  FF_PROPERTY(radius, Radius)
221  FF_PROPERTY(height, Height)
222 
223  DoubleDescriptors geometryValues() const override { return {radius(), height()}; }
224  QVector<DoubleProperty*> serializationProperties() override { return {&m_radius, &m_height}; }
225 };
226 
228 public:
230  std::unique_ptr<IFormFactor> createFormFactor() const override;
231 
232  FF_PROPERTY(radiusX, RadiusX)
233  FF_PROPERTY(radiusY, RadiusY)
234  FF_PROPERTY(height, Height)
235 
236  DoubleDescriptors geometryValues() const override { return {radiusX(), radiusY(), height()}; }
237  QVector<DoubleProperty*> serializationProperties() override
238  {
239  return {&m_radiusX, &m_radiusY, &m_height};
240  }
241 };
242 
244 public:
245  IcosahedronItem();
246  std::unique_ptr<IFormFactor> createFormFactor() const override;
247 
248  FF_PROPERTY(edge, Edge)
249 
250  DoubleDescriptors geometryValues() const override { return {edge()}; }
251  QVector<DoubleProperty*> serializationProperties() override { return {&m_edge}; }
252 };
253 
254 class Prism3Item : public FormFactorItem {
255 public:
256  Prism3Item();
257  std::unique_ptr<IFormFactor> createFormFactor() const override;
258 
259  FF_PROPERTY(baseEdge, BaseEdge)
260  FF_PROPERTY(height, Height)
261 
262  DoubleDescriptors geometryValues() const override { return {baseEdge(), height()}; }
263  QVector<DoubleProperty*> serializationProperties() override { return {&m_baseEdge, &m_height}; }
264 };
265 
266 class Prism6Item : public FormFactorItem {
267 public:
268  Prism6Item();
269  std::unique_ptr<IFormFactor> createFormFactor() const override;
270 
271  FF_PROPERTY(baseEdge, BaseEdge)
272  FF_PROPERTY(height, Height)
273 
274  DoubleDescriptors geometryValues() const override { return {baseEdge(), height()}; }
275  QVector<DoubleProperty*> serializationProperties() override { return {&m_baseEdge, &m_height}; }
276 };
277 
278 class Pyramid4Item : public FormFactorItem {
279 public:
280  Pyramid4Item();
281  std::unique_ptr<IFormFactor> createFormFactor() const override;
282 
283  FF_PROPERTY(baseEdge, BaseEdge)
284  FF_PROPERTY(height, Height)
285  FF_PROPERTY(alpha, Alpha)
286 
287  DoubleDescriptors geometryValues() const override { return {baseEdge(), height(), alpha()}; }
288  QVector<DoubleProperty*> serializationProperties() override
289  {
290  return {&m_baseEdge, &m_height, &m_alpha};
291  }
292 };
293 
295 public:
297  std::unique_ptr<IFormFactor> createFormFactor() const override;
298 
299  FF_PROPERTY(length, Length)
300  FF_PROPERTY(width, Width)
301  FF_PROPERTY(height, Height)
302 
303  DoubleDescriptors geometryValues() const override { return {length(), width(), height()}; }
304  QVector<DoubleProperty*> serializationProperties() override
305  {
306  return {&m_length, &m_width, &m_height};
307  }
308 };
309 
311 public:
313  std::unique_ptr<IFormFactor> createFormFactor() const override;
314 
315  FF_PROPERTY(length, Length)
316  FF_PROPERTY(width, Width)
317  FF_PROPERTY(height, Height)
318 
319  DoubleDescriptors geometryValues() const override { return {length(), width(), height()}; }
320  QVector<DoubleProperty*> serializationProperties() override
321  {
322  return {&m_length, &m_width, &m_height};
323  }
324 };
325 
327 public:
329  std::unique_ptr<IFormFactor> createFormFactor() const override;
330 
331  FF_PROPERTY(length, Length)
332  FF_PROPERTY(width, Width)
333  FF_PROPERTY(height, Height)
334 
335  DoubleDescriptors geometryValues() const override { return {length(), width(), height()}; }
336  QVector<DoubleProperty*> serializationProperties() override
337  {
338  return {&m_length, &m_width, &m_height};
339  }
340 };
341 
343 public:
345  std::unique_ptr<IFormFactor> createFormFactor() const override;
346 
347  FF_PROPERTY(length, Length)
348  FF_PROPERTY(width, Width)
349  FF_PROPERTY(height, Height)
350  FF_PROPERTY(asymmetry, Asymmetry)
351 
353  {
354  return {length(), width(), height(), asymmetry()};
355  }
356  QVector<DoubleProperty*> serializationProperties() override
357  {
358  return {&m_length, &m_width, &m_height, &m_asymmetry};
359  }
360 };
361 
363 public:
365  std::unique_ptr<IFormFactor> createFormFactor() const override;
366 
367  FF_PROPERTY(length, Length)
368  FF_PROPERTY(width, Width)
369  FF_PROPERTY(height, Height)
370  FF_PROPERTY(asymmetry, Asymmetry)
371 
373  {
374  return {length(), width(), height(), asymmetry()};
375  }
376  QVector<DoubleProperty*> serializationProperties() override
377  {
378  return {&m_length, &m_width, &m_height, &m_asymmetry};
379  }
380 };
381 
383 public:
385  std::unique_ptr<IFormFactor> createFormFactor() const override;
386 
387  FF_PROPERTY(length, Length)
388  FF_PROPERTY(width, Width)
389  FF_PROPERTY(height, Height)
390  FF_PROPERTY(asymmetry, Asymmetry)
391 
393  {
394  return {length(), width(), height(), asymmetry()};
395  }
396  QVector<DoubleProperty*> serializationProperties() override
397  {
398  return {&m_length, &m_width, &m_height, &m_asymmetry};
399  }
400 };
401 
402 class Pyramid3Item : public FormFactorItem {
403 public:
404  Pyramid3Item();
405  std::unique_ptr<IFormFactor> createFormFactor() const override;
406 
407  FF_PROPERTY(baseEdge, BaseEdge)
408  FF_PROPERTY(height, Height)
409  FF_PROPERTY(alpha, Alpha)
410 
411  DoubleDescriptors geometryValues() const override { return {baseEdge(), height(), alpha()}; }
412  QVector<DoubleProperty*> serializationProperties() override
413  {
414  return {&m_baseEdge, &m_height, &m_alpha};
415  }
416 };
417 
419 public:
421  std::unique_ptr<IFormFactor> createFormFactor() const override;
422 
423  FF_PROPERTY(length, Length)
424  FF_PROPERTY(removedLength, RemovedLength)
425 
426  DoubleDescriptors geometryValues() const override { return {length(), removedLength()}; }
427  QVector<DoubleProperty*> serializationProperties() override
428  {
429  return {&m_length, &m_removedLength};
430  }
431 };
432 
434 public:
436  std::unique_ptr<IFormFactor> createFormFactor() const override;
437 
438  FF_PROPERTY(radius, Radius)
439  FF_PROPERTY(height, Height)
440  FF_PROPERTY(removedTop, RemovedTop)
441 
442  DoubleDescriptors geometryValues() const override { return {radius(), height(), removedTop()}; }
443  QVector<DoubleProperty*> serializationProperties() override
444  {
445  return {&m_radius, &m_height, &m_removedTop};
446  }
447 };
448 
450 public:
452  std::unique_ptr<IFormFactor> createFormFactor() const override;
453 
454  FF_PROPERTY(radius, Radius)
455  FF_PROPERTY(height, Height)
456  FF_PROPERTY(heightFlattening, HeightFlattening)
457  FF_PROPERTY(removedTop, RemovedTop)
458 
460  {
461  return {radius(), height(), heightFlattening(), removedTop()};
462  }
463  QVector<DoubleProperty*> serializationProperties() override
464  {
465  return {&m_radius, &m_height, &m_heightFlattening, &m_removedTop};
466  }
467 };
468 
470 public:
472  std::unique_ptr<IFormFactor> createFormFactor() const override;
473 
474  FF_PROPERTY(length, Length)
475  FF_PROPERTY(removedLength, RemovedLength)
476 
477  DoubleDescriptors geometryValues() const override { return {length(), removedLength()}; }
478  QVector<DoubleProperty*> serializationProperties() override
479  {
480  return {&m_length, &m_removedLength};
481  }
482 };
483 
485 public:
487  std::unique_ptr<IFormFactor> createFormFactor() const override;
488 
489  FF_PROPERTY(radius, Radius)
490  FF_PROPERTY(length, Length)
491  FF_PROPERTY(sliceBottom, SliceBottom)
492  FF_PROPERTY(sliceTop, SliceTop)
493 
495  {
496  return {radius(), length(), sliceBottom(), sliceTop()};
497  }
498  QVector<DoubleProperty*> serializationProperties() override
499  {
500  return {&m_radius, &m_length, &m_sliceBottom, &m_sliceTop};
501  }
502 };
503 
505 public:
507  std::unique_ptr<IFormFactor> createFormFactor() const override;
508 
509  FF_PROPERTY(edge, Edge)
510 
511  DoubleDescriptors geometryValues() const override { return {edge()}; }
512  QVector<DoubleProperty*> serializationProperties() override { return {&m_edge}; }
513 };
514 
516 public:
518  std::unique_ptr<IFormFactor> createFormFactor() const override;
519 
520  FF_PROPERTY(edge, Edge)
521 
522  DoubleDescriptors geometryValues() const override { return {edge()}; }
523  QVector<DoubleProperty*> serializationProperties() override { return {&m_edge}; }
524 };
525 
526 #endif // BORNAGAIN_GUI_MODEL_SAMPLE_FORMFACTORITEMS_H
QList< DoubleDescriptor > DoubleDescriptors
Defines class DoubleProperty.
#define FF_PROPERTY(nameLower, nameUpper)
Defines class Streamer.
std::unique_ptr< IFormFactor > createFormFactor() const override
DoubleDescriptors geometryValues() const override
QVector< DoubleProperty * > serializationProperties() override
DoubleDescriptors geometryValues() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
QVector< DoubleProperty * > serializationProperties() override
QVector< DoubleProperty * > serializationProperties() override
std::unique_ptr< IFormFactor > createFormFactor() const override
DoubleDescriptors geometryValues() const override
DoubleDescriptors geometryValues() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
QVector< DoubleProperty * > serializationProperties() override
std::unique_ptr< IFormFactor > createFormFactor() const override
QVector< DoubleProperty * > serializationProperties() override
DoubleDescriptors geometryValues() const override
QVector< DoubleProperty * > serializationProperties() override
std::unique_ptr< IFormFactor > createFormFactor() const override
DoubleDescriptors geometryValues() const override
DoubleDescriptors geometryValues() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
QVector< DoubleProperty * > serializationProperties() override
DoubleDescriptors geometryValues() const override
QVector< DoubleProperty * > serializationProperties() override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
DoubleDescriptors geometryValues() const override
QVector< DoubleProperty * > serializationProperties() override
DoubleDescriptors geometryValues() const override
QVector< DoubleProperty * > serializationProperties() override
std::unique_ptr< IFormFactor > createFormFactor() const override
QVector< DoubleProperty * > serializationProperties() override
DoubleDescriptors geometryValues() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
QVector< DoubleProperty * > serializationProperties() override
DoubleDescriptors geometryValues() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
virtual QVector< DoubleProperty * > serializationProperties()=0
virtual std::unique_ptr< IFormFactor > createFormFactor() const =0
virtual ~FormFactorItem()=default
virtual void serialize(Streamer &s)
virtual DoubleDescriptors geometryValues() const =0
Defines info for GroupProperty, i.e. collection of model types, their labels and the name of default ...
Definition: GroupInfo.h:25
QVector< DoubleProperty * > serializationProperties() override
DoubleDescriptors geometryValues() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
DoubleDescriptors geometryValues() const override
QVector< DoubleProperty * > serializationProperties() override
DoubleDescriptors geometryValues() const override
QVector< DoubleProperty * > serializationProperties() override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
DoubleDescriptors geometryValues() const override
QVector< DoubleProperty * > serializationProperties() override
DoubleDescriptors geometryValues() const override
QVector< DoubleProperty * > serializationProperties() override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
DoubleDescriptors geometryValues() const override
QVector< DoubleProperty * > serializationProperties() override
DoubleDescriptors geometryValues() const override
QVector< DoubleProperty * > serializationProperties() override
std::unique_ptr< IFormFactor > createFormFactor() const override
DoubleDescriptors geometryValues() const override
QVector< DoubleProperty * > serializationProperties() override
std::unique_ptr< IFormFactor > createFormFactor() const override
DoubleDescriptors geometryValues() const override
QVector< DoubleProperty * > serializationProperties() override
std::unique_ptr< IFormFactor > createFormFactor() const override
QVector< DoubleProperty * > serializationProperties() override
DoubleDescriptors geometryValues() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
DoubleDescriptors geometryValues() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
QVector< DoubleProperty * > serializationProperties() override
std::unique_ptr< IFormFactor > createFormFactor() const override
QVector< DoubleProperty * > serializationProperties() override
DoubleDescriptors geometryValues() const override
DoubleDescriptors geometryValues() const override
QVector< DoubleProperty * > serializationProperties() override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
QVector< DoubleProperty * > serializationProperties() override
DoubleDescriptors geometryValues() const override
DoubleDescriptors geometryValues() const override
QVector< DoubleProperty * > serializationProperties() override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
DoubleDescriptors geometryValues() const override
QVector< DoubleProperty * > serializationProperties() override
Supports serialization to or deserialization from QXmlStream.
Definition: Streamer.h:36
QVector< DoubleProperty * > serializationProperties() override
DoubleDescriptors geometryValues() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
DoubleDescriptors geometryValues() const override
QVector< DoubleProperty * > serializationProperties() override
std::unique_ptr< IFormFactor > createFormFactor() const override
QVector< DoubleProperty * > serializationProperties() override
DoubleDescriptors geometryValues() const override