BALL
1.4.1
|
00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 // $Id: peak.h,v 1.18 2003/08/26 08:04:45 oliver Exp $ 00005 // 00006 00007 #ifndef BALL_NMR_PEAK_H 00008 #define BALL_NMR_PEAK_H 00009 00010 #ifndef BALL_MATHS_VECTOR3_H 00011 # include <BALL/MATHS/vector3.h> 00012 #endif 00013 00014 #ifndef BALL_MATHS_VECTOR2_H 00015 # include <BALL/MATHS/vector2.h> 00016 #endif 00017 00018 #ifndef BALL_CONCEPT_PROPERTY_H 00019 # include <BALL/CONCEPT/property.h> 00020 #endif 00021 00022 #include <iostream> 00023 00024 namespace BALL 00025 { 00026 class Atom; 00027 00034 template <typename PositionType> 00035 class Peak 00036 : public PropertyManager 00037 { 00038 public: 00039 00043 // Type describing the coordinates and width of the peak in all its dimensions 00044 typedef PositionType Position; 00046 00050 00053 Peak(); 00054 00057 Peak(const Peak& peak); 00058 00061 virtual ~Peak(); 00062 00064 00067 00070 const Position& getPosition() const; 00071 00074 const Position& getWidth() const; 00075 00078 float getIntensity() const; 00079 00082 void setPosition(const Position& position); 00083 00086 void setWidth(const Position& width); 00087 00090 void setIntensity(float intensity); 00091 00094 const Atom* getAtom() const; 00095 00098 void setAtom(const Atom* atom); 00099 00101 00104 00107 void operator = (const Peak& peak); 00108 00110 00113 00116 bool operator == (const Peak<PositionType>& peak) const; 00117 00120 bool operator < (const Peak<PositionType>& peak) const; 00121 00124 bool operator > (const Peak<PositionType>& peak) const; 00126 00127 protected: 00128 00129 Position position_; 00130 Position width_; 00131 float intensity_; 00132 const Atom* atom_; 00133 }; 00134 00135 template <typename PositionType> 00136 Peak<PositionType>::Peak() 00137 : PropertyManager(), 00138 position_(), 00139 width_(), 00140 intensity_(0), 00141 atom_(0) 00142 { 00143 } 00144 00145 template <typename PositionType> 00146 Peak<PositionType>::~Peak() 00147 { 00148 } 00149 00150 template <typename PositionType> 00151 Peak<PositionType>::Peak(const Peak<PositionType>& peak) 00152 : PropertyManager(peak), 00153 position_(peak.position_), 00154 width_(peak.width_), 00155 intensity_(peak.intensity_), 00156 atom_(peak.atom_) 00157 { 00158 } 00159 00160 template <typename PositionType> 00161 BALL_INLINE 00162 const typename Peak<PositionType>::Position& Peak<PositionType>::getPosition() const 00163 { 00164 return position_; 00165 } 00166 00167 template <typename PositionType> 00168 BALL_INLINE 00169 const typename Peak<PositionType>::Position& Peak<PositionType>::getWidth() const 00170 { 00171 return width_; 00172 } 00173 00174 template <typename PositionType> 00175 BALL_INLINE 00176 void Peak<PositionType>::setPosition(const typename Peak<PositionType>::Position& position) 00177 { 00178 position_ = position; 00179 } 00180 00181 template <typename PositionType> 00182 BALL_INLINE 00183 void Peak<PositionType>::setWidth(const typename Peak<PositionType>::Position& width) 00184 { 00185 width_ = width; 00186 } 00187 00188 template <typename PositionType> 00189 BALL_INLINE 00190 float Peak<PositionType>::getIntensity() const 00191 { 00192 return intensity_; 00193 } 00194 00195 template <typename PositionType> 00196 BALL_INLINE 00197 void Peak<PositionType>::setIntensity(float intensity) 00198 { 00199 intensity_ = intensity; 00200 } 00201 00202 template <typename PositionType> 00203 BALL_INLINE 00204 const Atom* Peak<PositionType>::getAtom() const 00205 { 00206 return atom_; 00207 } 00208 00209 template <typename PositionType> 00210 BALL_INLINE 00211 void Peak<PositionType>::setAtom(const Atom* atom) 00212 { 00213 atom_ = atom; 00214 } 00215 00216 template <typename PositionType> 00217 void Peak<PositionType>::operator = (const Peak<PositionType>& peak) 00218 { 00219 position_ = peak.position_; 00220 width_ = peak.width_; 00221 intensity_ = peak.intensity_; 00222 atom_ = peak.atom_; 00223 } 00224 00225 template <typename PositionType> 00226 bool Peak<PositionType>::operator == (const Peak<PositionType>& peak) const 00227 { 00228 return ((position_ == peak.position_) 00229 && (width_ == peak.width_) 00230 && (intensity_ == peak.intensity_) 00231 && (atom_ == peak.atom_)); 00232 } 00233 00234 template <typename PositionType> 00235 bool Peak<PositionType>::operator < (const Peak<PositionType>& peak) const 00236 { 00237 return (position_ < peak.position_); 00238 } 00239 00240 template <typename PositionType> 00241 bool Peak<PositionType>::operator > (const Peak<PositionType>& peak) const 00242 { 00243 return (position_ > peak.position_); 00244 } 00245 00248 template <typename PositionType> 00249 std::ostream& operator << (std::ostream& os, const Peak<PositionType>& peak) 00250 { 00251 return (os << "[ peak @ " << peak.getPosition() 00252 << ": intensity = " << peak.getIntensity() 00253 << ", width = " << peak.getWidth() 00254 << "] "); 00255 } 00256 00261 typedef Peak<float> Peak1D; 00262 typedef Peak<Vector2> Peak2D; 00263 typedef Peak<Vector3> Peak3D; 00265 00266 00267 } // namespace BALL 00268 00269 #endif // BALL_NMR_PEAK_H