]> Git trees. - libqmvoc.git/commitdiff
* Adding the class Isotope. The html-generation is not yet working.
authorCarsten Niehaus <cniehaus@gmx.de>
Sun, 12 Jun 2005 20:15:29 +0000 (20:15 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Sun, 12 Jun 2005 20:15:29 +0000 (20:15 +0000)
svn path=/trunk/KDE/kdeedu/kalzium/src/element.cpp; revision=424707

kalzium/src/element.cpp
kalzium/src/element.h

index 06a4b0610edc4d31ad106628cb4aa029dbd301eb..c359a1f5639ef0fbe9f371dc0abfc15404bc8667 100644 (file)
@@ -649,13 +649,28 @@ EList KalziumDataObject::readData(  QDomDocument &dataDocument )
                QString symbol = domElement.namedItem( "symbol" ).toElement().text();
                QString oxydation = domElement.namedItem( "oxydation" ).toElement().text();
                QString acidicbehaviour = domElement.namedItem( "acidicbehaviour" ).toElement().text();
-               QString isotopes = domElement.namedItem( "isotopes" ).toElement().text();
 
                QDomNodeList elist = domElement.elementsByTagName( "energy" );
                QValueList<double> ionlist;
                for( uint i = 0; i < elist.length(); i++ )
                {
-                       ionlist.append( elist.item( i ).toElement().text().toDouble() );
+                       ionlist.append(  elist.item(  i ).toElement().text().toDouble() );
+               }
+               
+               //now read in all the date for the isotopes
+               QDomNodeList isotopelist = domElement.elementsByTagName( "isotope" );
+               QValueList<Isotope*> isolist;
+               for( uint i = 0; i < isotopelist.length(); i++ )
+               {
+                       QDomElement iso = elist.item( i ).toElement();
+                       double halflife = iso.attributeNode( "halflife" ).value().toDouble();
+                       double weight = iso.attributeNode( "weight" ).value().toDouble();
+                       QString format = iso.attributeNode( "halflifeformat" ).value();
+                       int neutrons  = iso.attributeNode( "neutron" ).value().toInt();
+                       double percentage = iso.attributeNode( "percentage" ).value().toDouble();
+
+                       Isotope *isotope = new Isotope( neutrons, percentage, weight, halflife, format );
+                       isolist.append( isotope );
                }
        
                Element *e = new Element();
@@ -683,8 +698,8 @@ EList KalziumDataObject::readData(  QDomDocument &dataDocument )
                e->setSymbol(symbol);
                e->setOxydation(oxydation);
                e->setAcidicbehaviour(acidicbehaviour);
-               e->setIsotopes(isotopes);
                e->setIonisationList( ionlist );
+               e->setIsotopeList( isolist );
                
                e->setMass( mass );     
                e->setEN( en );
@@ -707,3 +722,12 @@ const int KalziumDataObject::numberOfElements() const
 {
        return m_numOfElements;
 }
+
+Isotope::Isotope(  int neutrons, double percentage, double weight, double halflife, QString format )
+{
+       m_neutrons = neutrons;
+       m_percentage = percentage;
+       m_halflife = halflife;
+       m_format = format;
+       m_weight = weight;
+}
index 79d0b6e3e20dd34c211aa0c0001fea36b28d73eb..b277cc201fe2e73c744fcb74768c8558dee0d3f0 100644 (file)
@@ -36,6 +36,65 @@ typedef QValueList<Element*> EList;
 typedef QValueList<coordinate> CList;
 typedef QValueList<double> doubleList;
 
+class Isotope
+{
+       public:
+               Isotope( int neutrons, double percentage, double weight, double halflife, QString format );
+
+               bool seconds() {
+                       if ( m_format == "seconds" )
+                               return true;
+                       else
+                               return false;
+               }
+
+               double halflife() const{
+                       return m_halflife;
+               }
+               
+               double percentage() const{
+                       return m_percentage;
+               }
+
+               int neutrons() const{
+                       return m_neutrons;
+               }
+
+               double weight() const{
+                       return m_weight;
+               }
+
+       private:
+               /**
+                * it is either "years" or "seconds". Usually we use seconds. But some
+                * isotopes have half-lifes of billion of years. This simply
+                * doesn't fit into a unsigned int or double
+                */
+               QString m_format;
+
+               /**
+                * the weight of the isotope
+                */
+               double m_weight;
+
+               /**
+                * the half-life of an isotope, usually in seconds
+                * @see m_format
+                */
+               double m_halflife;
+               
+               /**
+                * If 95.2% of the isotopes are of this type, this 
+                * variable will have the value 95.2
+                */
+               double m_percentage;
+
+               /**
+                * the number of neutrons
+                */
+               int m_neutrons;
+};
+
 /**
  * @short this class contains all Element-objects as
  * a QValueList<Element*>
@@ -151,7 +210,15 @@ class Element{
                        m_ionenergies = l;
                }
 
-               QValueList<double> ionisationList() const{
+               QValueList<Isotope*> isotopeList()const{
+                       return m_isotopeList;
+               }
+
+               void setIsotopeList( QValueList<Isotope*> list ){
+                       m_isotopeList = list;
+               }
+
+               doubleList ionisationList() const{
                        return m_ionenergies;
                }
                
@@ -247,17 +314,9 @@ class Element{
                        return m_acidbeh;
                }
 
-               /**
-                * @return the isotopes of the element
-                */
-               QString Isotopes() const {
-                       return m_isotopes;
-               }
-               
                /**
                 * @return the oxydationstages of the element
                 */
-               
                QString oxstage() const {
                        return m_oxstage;
                }
@@ -380,6 +439,10 @@ class Element{
     QColor elementColor() const { 
                return m_Color; 
        }
+
+       QValueList<Isotope*> isotopes() const{
+               return m_isotopeList;
+       }
                
        void setupXY();
 
@@ -388,6 +451,8 @@ class Element{
                 * the integer num represents the number of the element
                 */
                int m_ElementNumber;
+
+               QValueList<Isotope*> m_isotopeList;
        
                QColor m_Color;