IMP  2.2.0
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-2014 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/base/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 {
31  return Geometry::get_has_color() || Colored::get_is_setup(p_);
32  }
33 
34  Color get_color() const {
35  if (Geometry::get_has_color()) {
36  return Geometry::get_color();
37  } else {
38  return Colored(p_).get_color();
39  }
40  }
41 
42  kernel::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 {
66 
67  public:
69 
70  bool get_has_color() const {
71  return Geometry::get_has_color() || Colored::get_is_setup(p0_) ||
72  Colored::get_is_setup(p1_);
73  }
74 
75  Color get_color() const {
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  kernel::ParticlePair get_particle_pair() const {
85  return kernel::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.
Represent an RGB color.
Definition: Color.h:24
A decorator for a particle with a color.
Import IMP/kernel/SingletonContainer.h in the namespace.
A nullptr-initialized pointer to an IMP Object.
The base class for geometry.
A base class for geometry contained in particles.
A smart pointer to a ref-counted Object that is a class memeber.
Definition: base/Pointer.h:147
A base class for geometry from a set of particles.
macros for display classes
A shared container for Pairs.
A smart pointer to a reference counted object.
Definition: base/Pointer.h:87
base::Array< 2, base::WeakPointer< Particle >, Particle * > ParticlePair
Implement geometry for the basic shapes from IMP.algebra.
A base class for geometry from a set of particles.
A class to store an fixed array of same-typed values.
Definition: base/Array.h:33
Import IMP/kernel/PairContainer.h in the namespace.
Class to handle individual model particles.
Import IMP/kernel/SingletonScore.h in the namespace.
A shared container for Singletons.
A particle with a color.
Definition: Colored.h:23