From: Carsten Niehaus Date: Sun, 12 Jun 2005 20:15:29 +0000 (+0000) Subject: * Adding the class Isotope. The html-generation is not yet working. X-Git-Tag: v3.80.2~300^2~109 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=25cfdf4fdee0d249b1de67d09bc8ec92e6716cf7;p=libqmvoc.git * Adding the class Isotope. The html-generation is not yet working. svn path=/trunk/KDE/kdeedu/kalzium/src/element.cpp; revision=424707 --- diff --git a/kalzium/src/element.cpp b/kalzium/src/element.cpp index 06a4b06..c359a1f 100644 --- a/kalzium/src/element.cpp +++ b/kalzium/src/element.cpp @@ -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 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 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; +} diff --git a/kalzium/src/element.h b/kalzium/src/element.h index 79d0b6e..b277cc2 100644 --- a/kalzium/src/element.h +++ b/kalzium/src/element.h @@ -36,6 +36,65 @@ typedef QValueList EList; typedef QValueList CList; typedef QValueList 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 @@ -151,7 +210,15 @@ class Element{ m_ionenergies = l; } - QValueList ionisationList() const{ + QValueList isotopeList()const{ + return m_isotopeList; + } + + void setIsotopeList( QValueList 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 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 m_isotopeList; QColor m_Color;