00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __P_ATOM_H
00021 #define __P_ATOM_H
00022
00023 #include <string>
00024 using std::string;
00025
00026 #include <math3d/primitives.h>
00027 #include <GLdraw/GLMaterial.h>
00028 using namespace Math3D;
00029
00030 #include "PAtomShell.h"
00031 #include "PFunctors.h"
00032 #include "PHashing.h"
00033
00034 class PBlock;
00035 class PChain;
00036 class PGrid;
00037 class PSpaceManager;
00038 class PResidue;
00039
00050 class PAtom {
00051 public:
00052 friend class PBond;
00053 friend class PResidue;
00054 friend class PBlock;
00055
00060 PAtom(PBlock * block, const string &name, Vector3 position, const string &id);
00061
00066 ~PAtom();
00067
00071 string getID()const { return m_id; }
00072
00077 void changePosition(const Vector3 &newPosition);
00078
00083 void ApplyTransform(const Matrix4 &transform);
00084
00089 AtomSet* getAllCollidingStatic() const;
00090
00095 AtomSet* getAllCollidingSelf() const;
00096
00101 AtomSet* getAllCollidingEither() const;
00102
00106 PBond *getBond(PResidue *res, const string &id);
00107
00112 PAtom *FindStaticCollision() const;
00113
00118 PAtom *FindSelfCollision() const;
00119
00124 PAtom *FindAnyCollision() const;
00125
00130 bool InStaticCollision() const;
00131
00136 bool InSelfCollision() const;
00137
00142 bool InAnyCollision() const;
00143
00147 bool isOnBackbone() const;
00148
00152 PBlock *getParentBlock() { return m_atomBlock; }
00153
00157 PResidue *getParentResidue();
00158
00162 PChain *getChain() const;
00163
00167 Vector3 getPos() const { return m_atomPos; }
00168
00173 const vector<PBond *> *getBonds() const { return &m_bonds; }
00174
00178 Real getCovalentRadius() const { return m_atomShell->getCovalentRadius(); }
00179
00183 Real getVanDerWaalsRadius() const { return m_atomShell->getVanDerWaalsRadius(); }
00184
00188 Real getOccupancy() const { return m_occupancy; }
00189
00193 void setOccupancy(Real newVal) { m_occupancy = newVal; }
00194
00198 Real getTempFactor() const { return m_tempFactor; }
00199
00203 void setTempFactor(Real newVal) { m_tempFactor = newVal; }
00204
00210 void setColor(const GLColor setColor) {m_colorSet=true; m_atomColor = setColor;}
00211
00215 void revertColor(){ m_colorSet=false; }
00216
00221 GLColor getColor() const {
00222 if (m_colorSet) {
00223 return m_atomColor;
00224 } else {
00225 return m_atomShell->getColor();
00226 }
00227 }
00228
00232 string getName() const { return m_atomShell->getName(); }
00233
00238 Vector3 getGridPos() const;
00239
00244 bool WithinActiveBlock() const;
00245
00250 bool isBonded(const PAtom *other) const;
00251
00264 static int shortestBondPath(const PAtom *a1, const PAtom *a2, int threshold = -1);
00265
00271 void traverseChain(AtomFunctor *atomFn, BondFunctor *bondFn);
00272
00278 void traverseAtoms(AtomFunctor *atomFn) { traverseChain(atomFn, NULL); }
00279
00285 void traverseBonds(BondFunctor *bondFn) { traverseChain(NULL, bondFn); }
00286
00290 const PSpaceManager* getSpaceManager() const;
00291
00296 bool isActive() const { return m_active; }
00297
00301 void inactivate() { m_active = false; }
00302
00306 void activate() { m_active = true; }
00307
00308 private:
00309
00310
00311 void insertMeIntoGrid();
00312 void removeMeFromGrid();
00313
00314
00315 void DestroyBonds();
00316
00317 Vector3 m_atomPos;
00318 string m_id;
00319 PAtomShell *m_atomShell;
00320 vector<PBond *> m_bonds;
00321 PBlock *m_atomBlock;
00322 PGrid *m_grid;
00323 bool m_colorSet;
00324 GLColor m_atomColor;
00325 Real m_tempFactor, m_occupancy;
00326
00327 void internalTraverse(AtomFunctor *atomFn,
00328 BondFunctor *bondFn,
00329 AtomSet &atomsTraversed,
00330 PChain *rootChain,
00331 PBond *bondFrom);
00332
00333 bool m_active;
00334 };
00335
00336 #endif // __P_ATOM_H