IMP logo
IMP Reference Guide  develop.7cb8855c60,2024/10/08
The Integrative Modeling Platform
particle_geometry.h
Go to the documentation of this file.
1 /**
2  * \file IMP/display/particle_geometry.h
3  * \brief Represent an XYZR particle with a sphere
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPDISPLAY_PARTICLE_GEOMETRY_H
9 #define IMPDISPLAY_PARTICLE_GEOMETRY_H
10 
11 #include <IMP/display/display_config.h>
12 #include "geometry_macros.h"
13 #include "declare_Geometry.h"
14 #include "Colored.h"
15 #include <IMP/Pointer.h>
16 #include <IMP/SingletonContainer.h>
17 #include <IMP/PairContainer.h>
18 #include <IMP/SingletonScore.h>
19 
20 IMPDISPLAY_BEGIN_NAMESPACE
21 
22 //! A base class for geometry contained in particles
23 /** */
24 class IMPDISPLAYEXPORT SingletonGeometry : public Geometry {
26 
27  public:
29 
30  bool get_has_color() const override {
31  return Geometry::get_has_color() || Colored::get_is_setup(p_);
32  }
33 
34  Color get_color() const override {
35  if (Geometry::get_has_color()) {
36  return Geometry::get_color();
37  } else {
38  return Colored(p_).get_color();
39  }
40  }
41 
42  Particle *get_particle() const { return p_; }
43 
44  virtual ~SingletonGeometry() {}
45 };
46 
47 //! A base class for geometry from a set of particles
48 /**
49  */
50 class IMPDISPLAYEXPORT SingletonsGeometry : public Geometry {
52 
53  public:
56 
57  SingletonContainer *get_container() const { return sc_; }
58 
59  virtual ~SingletonsGeometry() {}
60 };
61 
62 //! A base class for geometry contained in particles
63 /** */
64 class IMPDISPLAYEXPORT PairGeometry : public Geometry {
65  IMP::Pointer<Particle> p0_, p1_;
66 
67  public:
68  PairGeometry(const ParticlePair &pp);
69 
70  bool get_has_color() const override {
71  return Geometry::get_has_color() || Colored::get_is_setup(p0_) ||
72  Colored::get_is_setup(p1_);
73  }
74 
75  Color get_color() const override {
76  if (Geometry::get_has_color()) {
77  return Geometry::get_color();
78  } else if (Colored::get_is_setup(p0_))
79  return Colored(p0_).get_color();
80  else
81  return Colored(p1_).get_color();
82  }
83 
84  ParticlePair get_particle_pair() const {
85  return ParticlePair(p0_, p1_);
86  }
87 
88  virtual ~PairGeometry() {}
89 };
90 
91 //! A base class for geometry from a set of particles
92 /**
93  */
94 class IMPDISPLAYEXPORT PairsGeometry : public Geometry {
96 
97  public:
100 
101  PairContainer *get_container() const { return sc_; }
102 
103  virtual ~PairsGeometry() {}
104 };
105 
106 IMPDISPLAY_END_NAMESPACE
107 
108 #endif /* IMPDISPLAY_PARTICLE_GEOMETRY_H */
A base class for geometry contained in particles.
A shared container for Pairs.
Definition: PairContainer.h:39
Represent an RGB color.
Definition: Color.h:25
A decorator for a particle with a color.
A container for Singletons.
The base class for geometry.
A base class for geometry contained in particles.
A class to store a fixed array of same-typed values.
Definition: Array.h:40
A base class for geometry from a set of particles.
macros for display classes
Implement geometry for the basic shapes from IMP.algebra.
A base class for geometry from a set of particles.
A smart pointer to a reference counted object.
Definition: Pointer.h:87
A container for Pairs.
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:143
A shared container for Singletons.
Define SingletonScore.
A nullptr-initialized pointer to an IMP Object.
Array< 2, WeakPointer< Particle >, Particle * > ParticlePair
Definition: base_types.h:159
Class to handle individual particles of a Model object.
Definition: Particle.h:43
A particle with a color.
Definition: Colored.h:23