IMP  2.0.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-2013 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/SingletonContainer.h>
16 #include <IMP/PairContainer.h>
17 #include <IMP/SingletonScore.h>
18 
19 IMPDISPLAY_BEGIN_NAMESPACE
20 
21 //! A base class for geometry contained in particles
22 /** */
23 class IMPDISPLAYEXPORT SingletonGeometry: public Geometry
24 {
25  IMP::Pointer<Particle> p_;
26 public:
28 
29  bool get_has_color() const {
30  return Geometry::get_has_color()
31  || Colored::particle_is_instance(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  Particle *get_particle() const {
43  return p_;
44  }
45 
46  virtual ~SingletonGeometry(){}
47 };
48 
49 
50 
51 //! A base class for geometry from a set of particles
52 /**
53  */
54 class IMPDISPLAYEXPORT SingletonsGeometry: public Geometry
55 {
56  IMP::OwnerPointer<SingletonContainer> sc_;
57 public:
60 
61  SingletonContainer *get_container() const {
62  return sc_;
63  }
64 
65  virtual ~SingletonsGeometry(){}
66 };
67 
68 
69 //! A base class for geometry contained in particles
70 /** */
71 class IMPDISPLAYEXPORT PairGeometry: public Geometry
72 {
73  IMP::Pointer<Particle> p0_, p1_;
74 public:
75  PairGeometry(const ParticlePair &pp);
76 
77  bool get_has_color() const {
78  return Geometry::get_has_color()
79  || Colored::particle_is_instance(p0_)
80  || Colored::particle_is_instance(p1_);
81  }
82 
83  Color get_color() const {
84  if (Geometry::get_has_color()) {
85  return Geometry::get_color();
86  } else if (Colored::particle_is_instance(p0_))
87  return Colored(p0_).get_color();
88  else return Colored(p1_).get_color();
89  }
90 
91  ParticlePair get_particle_pair() const {
92  return ParticlePair(p0_, p1_);
93  }
94 
95  virtual ~PairGeometry(){}
96 };
97 
98 
99 //! A base class for geometry from a set of particles
100 /**
101  */
102 class IMPDISPLAYEXPORT PairsGeometry: public Geometry
103 {
104  IMP::OwnerPointer<PairContainer> sc_;
105 public:
108 
109  PairContainer *get_container() const {
110  return sc_;
111  }
112 
113  virtual ~PairsGeometry(){}
114 };
115 
116 
117 IMPDISPLAY_END_NAMESPACE
118 
119 #endif /* IMPDISPLAY_PARTICLE_GEOMETRY_H */