00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00020
00021 #ifndef ATOMSET_H
00022 #define ATOMSET_H
00023
00025
00026
00027 #include <vector>
00028 using std::vector;
00029
00030
00031 class QColor;
00032 class QDomDocument;
00033 class QDomDocumentFragment;
00034 class QDomElement;
00035 class QString;
00036
00037
00038
00039 template <class T> class Point3D;
00040
00042 class AtomSet
00043 {
00044 public:
00045 AtomSet();
00046 ~AtomSet();
00047
00049 enum ChargeType{None, Mulliken, Stockholder};
00050
00052 void clear();
00053 void reserve(const unsigned int size);
00054 void addAtom(const Point3D<double>& location, const unsigned int atomicNumber, const QColor color, const int index = -1);
00055 void addAtom(const Point3D<double>& location, const unsigned int atomicNumber, const int index = -1);
00056 void addAtom(const double x, const double y, const double z, const unsigned int atomicNumber, const QColor color, const int index = -1);
00057 void addAtom(const double x, const double y, const double z, const unsigned int atomicNumber, const int index = -1);
00058 void removeAtom(const unsigned int index);
00059
00061 void setX(const unsigned int index, const double x);
00062 void setY(const unsigned int index, const double y);
00063 void setZ(const unsigned int index, const double z);
00064 void setColor(const unsigned int index, const QColor color);
00065 void setCharges(const vector<double>& charges, const ChargeType type, const QString scf = QString::null, const QString density = QString::null);
00066 void clearCharges(const ChargeType type);
00067 void setForces(const unsigned int index, const double dx, const double dy, const double dz);
00068 void changeBond(const double amount, const unsigned int movingAtom, const unsigned int secondAtom, const bool includeNeighbours = false);
00069 void changeAngle(const double amount, const unsigned int movingAtom, const unsigned int centralAtom, const unsigned int lastAtom, const bool includeNeighbours = false);
00070 void changeTorsion(const double amount, const unsigned int movingAtom, const unsigned int secondAtom, const unsigned int thirdAtom, const unsigned int fourthAtom, const bool includeNeighbours = false);
00071 void transferCoordinates(const AtomSet* source);
00072
00074 unsigned int count() const;
00075 Point3D<double> coordinates(const unsigned int index) const;
00076 double x(const unsigned int index) const;
00077 double y(const unsigned int index) const;
00078 double z(const unsigned int index) const;
00079 unsigned int atomicNumber(const unsigned int index) const;
00080 QColor color(const unsigned int index) const;
00081 vector<unsigned int> usedAtomicNumbers() const;
00082 void bonds(vector<unsigned int>*& first, vector<unsigned int>*& second);
00083 unsigned int numberOfBonds(const unsigned int index) const;
00084 bool isLinear() const;
00085 bool isChanged() const;
00086 double dx(const unsigned int index) const;
00087 double dy(const unsigned int index) const;
00088 double dz(const unsigned int index) const;
00089 double bond(const unsigned int atom1, const unsigned int atom2) const;
00090 double angle(const unsigned int atom1, const unsigned int atom2, const unsigned int atom3) const;
00091 double torsion(const unsigned int atom1, const unsigned int atom2, const unsigned int atom3, const unsigned int atom4) const;
00092 double charge(const ChargeType type, const unsigned int index) const;
00093 bool hasCharges(const ChargeType type) const;
00094 QString chargesSCF(const ChargeType type) const;
00095 QString chargesDensity(const ChargeType type) const;
00096 bool hasForces() const;
00097 Point3D<float> rotationCenter() const;
00098 bool needsExtendedFormat();
00099
00100
00101 void loadCML(const QDomElement* root);
00102 void saveCML(QDomElement* root);
00103
00104
00105 static const unsigned int maxElements;
00106 static unsigned int atomToNum(const QString& atom);
00107 static QString numToAtom(const unsigned int atom);
00108 static float vanderWaals(const unsigned int atom);
00109 static QColor stdColor(const unsigned int atom);
00110
00111 private:
00112
00113 void setChanged(const bool state = true);
00114 void setGeometryChanged();
00115 bool addBondList(const unsigned int callingAtom, const unsigned int startAtom, const unsigned int endAtom1, const unsigned int endAtom2, std::vector<unsigned int>* result);
00116 void clearProperties();
00117 void updateBoxDimensions();
00118 void addBonds(const vector<unsigned int>* atomList1, const vector<unsigned int>* atomList2);
00119
00120
00121 unsigned int numAtoms;
00122 bool changed;
00123
00124 vector<Point3D<double> > coords;
00125 vector<QColor> colors;
00126 vector<Point3D<double> >* forces;
00127 vector<unsigned int> bonds1;
00128 vector<unsigned int> bonds2;
00129 vector<double>* chargesMulliken;
00130 vector<double>* chargesStockholder;
00131 QString chargesMullikenSCF;
00132 QString chargesMullikenDensity;
00133 QString chargesStockholderSCF;
00134 QString chargesStockholderDensity;
00135 Point3D<double>* boxMax;
00136 Point3D<double>* boxMin;
00137 bool dirtyBox;
00138 };
00139
00140 #endif
00141