atomset.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           atomset.h  -  description
00003                              -------------------
00004     begin                : Mon Sep 9 2002
00005     copyright            : (C) 2002-2006 by Ben Swerts
00006     email                : bswerts@users.sourceforge.net
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00020 
00021 #ifndef ATOMSET_H
00022 #define ATOMSET_H
00023 
00025 
00026 // STL header files
00027 #include <vector>
00028 using std::vector;
00029 
00030 // Qt forward class declarations
00031 class QColor;
00032 class QDomDocument;
00033 class QDomDocumentFragment;
00034 class QDomElement;
00035 class QString;
00036 
00037 // Xbrabo forward class declarations
00038 //#include "point3d.h" // gives extremely strange errors when (and only when) compiling crdfactory.cpp
00039 template <class T> class Point3D;
00040 
00042 class AtomSet
00043 {
00044   public:
00045     AtomSet();                          // constructor
00046     ~AtomSet();                         // destructor
00047 
00049     enum ChargeType{None, Mulliken, Stockholder};
00050 
00052     void clear();                       // remove all atoms
00053     void reserve(const unsigned int size);        // allocates space for more atoms
00054     void addAtom(const Point3D<double>& location, const unsigned int atomicNumber, const QColor color, const int index = -1);         // adds an atom at position index with a special color
00055     void addAtom(const Point3D<double>& location, const unsigned int atomicNumber, const int index = -1);         // adds an atom at position index
00056     void addAtom(const double x, const double y, const double z, const unsigned int atomicNumber, const QColor color, const int index = -1);    // adds an atom at position index with a special color
00057     void addAtom(const double x, const double y, const double z, const unsigned int atomicNumber, const int index = -1);    // adds an atom at position index
00058     void removeAtom(const unsigned int index);    // removes an atom
00059 
00061     void setX(const unsigned int index, const double x);    // changes the x-coordinate of atom index
00062     void setY(const unsigned int index, const double y);    // changes the y-coordinate of atom index
00063     void setZ(const unsigned int index, const double z);    // changes the z-coordinate of atom index
00064     void setColor(const unsigned int index, const QColor color);      // changes the color of atom index
00065     void setCharges(const vector<double>& charges, const ChargeType type, const QString scf = QString::null, const QString density = QString::null);  // sets all charges of a certain type
00066     void clearCharges(const ChargeType type);  // removes the charges of a specified type  
00067     void setForces(const unsigned int index, const double dx, const double dy, const double dz);    // changes the forces of atom index
00068     void changeBond(const double amount, const unsigned int movingAtom, const unsigned int secondAtom, const bool includeNeighbours = false);         // changes a bond length
00069     void changeAngle(const double amount, const unsigned int movingAtom, const unsigned int centralAtom, const unsigned int lastAtom, const bool includeNeighbours = false);        // changes a valence angle
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);     // changes a torsion angle
00071     void transferCoordinates(const AtomSet* source);        // copies the coordinates from another AtomSet
00072     
00074     unsigned int count() const;         // returns the number of atoms
00075     Point3D<double> coordinates(const unsigned int index) const;         // returns the coordinates for atom index
00076     double x(const unsigned int index) const;     // returns the x-coordinate for atom index
00077     double y(const unsigned int index) const;     // returns the y-coordinate for atom index
00078     double z(const unsigned int index) const;     // returns the z-coordinate for atom index
00079     unsigned int atomicNumber(const unsigned int index) const;  // returns the atomic number for atom index
00080     QColor color(const unsigned int index) const; // returns the color of the specified atom
00081     vector<unsigned int> usedAtomicNumbers() const;   // returns a sorted list of all the used atomic numbers
00082     void bonds(vector<unsigned int>*& first, vector<unsigned int>*& second);    // returns a list of bonds between the atoms
00083     unsigned int numberOfBonds(const unsigned int index) const; // returns the number of bonds for an atom
00084     bool isLinear() const;              // returns true if the atoms form a linear molecule
00085     bool isChanged() const;             // returns true if the AtomSet has changed
00086     double dx(const unsigned int index) const;    // returns the x-component of the force on atom index
00087     double dy(const unsigned int index) const;    // returns the y-component of the force on atom index
00088     double dz(const unsigned int index) const;    // returns the z-component of the force on atom index
00089     double bond(const unsigned int atom1, const unsigned int atom2) const;      // returns the distance 1-2
00090     double angle(const unsigned int atom1, const unsigned int atom2, const unsigned int atom3) const;         // returns the angle 1-2-3
00091     double torsion(const unsigned int atom1, const unsigned int atom2, const unsigned int atom3, const unsigned int atom4) const; // returns the torsion angle 1-2-3-4
00092     double charge(const ChargeType type, const unsigned int index) const;// the charge on atom index
00093     bool hasCharges(const ChargeType type) const; // returns true if charges of the specified type are present
00094     QString chargesSCF(const ChargeType type) const;        // Returns the type of calculation used for the determination of the charges
00095     QString chargesDensity(const ChargeType type) const;    // Returns the density from which the charges were determined
00096     bool hasForces() const;             // returns if forces are present
00097     Point3D<float> rotationCenter() const;        // returns the center around which the molecule can best be rotated
00098     bool needsExtendedFormat();         // returns true if the coordinates need to be written in BRABO's extended format in order to prevent clipping
00099 
00100     // public member functions for doing IO
00101     void loadCML(const QDomElement* root);        // loads coordinates from a CML file
00102     void saveCML(QDomElement* root);    // saves the coordinates to a CML file under the node root
00103 
00104     // static public member functions/variables
00105     static const unsigned int maxElements;        // the number of supported elements (elements 1 - maxElements)
00106     static unsigned int atomToNum(const QString& atom);     // maps elements to atomic numbers
00107     static QString numToAtom(const unsigned int atom);      // maps atomic numbers to elements
00108     static float vanderWaals(const unsigned int atom);      // returns the Van der Waals radius of atomic number atom
00109     static QColor stdColor(const unsigned int atom);        // returns the standard color for atomic number atom
00110     
00111   private:
00112     // private member functions
00113     void setChanged(const bool state = true);     // sets the 'changed' property
00114     void setGeometryChanged();          // indicates the geometry has changed
00115     bool addBondList(const unsigned int callingAtom, const unsigned int startAtom, const unsigned int endAtom1, const unsigned int endAtom2, std::vector<unsigned int>* result);     // returns a list of all atoms bonded to startAtom
00116     void clearProperties();             // clears the properties
00117     void updateBoxDimensions();         // updates the smallest box surrounding the atoms
00118     void addBonds(const vector<unsigned int>* atomList1, const vector<unsigned int>* atomList2);    // calculates all bonds between the atoms in the 2 list
00119 
00120     // private member data
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 

Generated on Fri May 19 14:31:53 2006 for Brabosphere by  doxygen 1.4.6-NO