]> Git trees. - libqmvoc.git/commitdiff
pinotree: please review
authorCarsten Niehaus <cniehaus@gmx.de>
Tue, 21 Feb 2006 17:03:16 +0000 (17:03 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Tue, 21 Feb 2006 17:03:16 +0000 (17:03 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=512040

libscience/isotope.cpp
libscience/isotope.h

index e68bb014cfb98bb696e284d8ddeee0c7ca14c089..452eed193cf39546892c8b3af29817248a5c9547 100644 (file)
@@ -23,7 +23,7 @@
 #include <kdebug.h>
 
 Isotope::Isotope()
-       : m_parentElementSymbol( 0 ), m_mass( 0 ), m_identifier( 0 ),
+: m_parentElementSymbol( 0 ), m_mass( 0 ), m_identifier( 0 ),
        m_spin( 0 ), m_magmoment( 0 ), m_halflife( 0 ), m_ecdecay( 0 ),
        m_betaplus( 0 ), m_betaminus( 0 ), m_alpha( 0 )
 { 
@@ -52,7 +52,7 @@ void Isotope::addData( ChemicalDataObject* o )
                m_magmoment = o;
        else if ( o->type() == ChemicalDataObject::halfLife )
                m_halflife = o;
-       
+
        //FIXME in the future there should be real CDOs. But CDO only supports one datavalue...
        if ( o->type() == ChemicalDataObject::betaplusDecay )
                m_betaplus = o;
@@ -101,10 +101,38 @@ QString Isotope::parentElementSymbol() const
 
 void Isotope::setNucleons( int number )
 {
-       m_nucleons = number;
+       int protons = m_identifier->value().toInt();
+       int neutrons = number - protons;
+       m_nucleons.protons = protons;
+       m_nucleons.neutrons = neutrons;
 }
 
 int Isotope::nucleons() const
 {
-       return m_nucleons;
+       return m_nucleons.neutrons + m_nucleons.protons;
+}
+
+Isotope::Nucleons Isotope::nucleonsAfterDecay( Decay kind )
+{
+       Nucleons n = m_nucleons;
+
+       switch ( kind )
+       {
+               case ALPHA:
+                       n.protons-=2;
+                       break;
+               case BETAMINUS:
+                       n.protons+=1;
+                       n.neutrons-=1;
+                       break;
+               case BETAPLUS:
+                       n.protons-=1;
+                       break;
+               case EC:
+                       n.protons-=1;
+                       n.neutrons+=1;
+                       break;
+       }
+
+       return n;
 }
index 681559aacaa29ecb27ce2714b238fd3cf8f62ae9..dae6b7a4385aa338eb277d9d23b3d8455bef2651 100644 (file)
@@ -38,6 +38,12 @@ class Isotope
                Isotope();
                virtual ~Isotope();
 
+               struct Nucleons
+               {
+                       int neutrons;
+                       int protons;
+               };
+
                ChemicalDataObject* data() const;
 
                double mass() const;
@@ -93,6 +99,19 @@ class Isotope
                ChemicalDataObject* alphadecay() const{
                        return m_alpha;
                }
+
+               enum Decay
+               {
+                       ALPHA,
+                       BETAPLUS,
+                       BETAMINUS,
+                       EC
+               };
+
+               /**
+                * @return the number of neutrons of the Isotope after the decay
+                */
+               Isotope::Nucleons nucleonsAfterDecay( Decay kind );
        private:
                /**
                 * the symbol of the element the isotope belongs to
@@ -123,13 +142,14 @@ class Isotope
                 * stores the halfLife of the Isotope
                 */
                ChemicalDataObject* m_halflife;
-               
-               int m_nucleons;
 
                ChemicalDataObject* m_ecdecay;
                ChemicalDataObject* m_betaplus;
                ChemicalDataObject* m_betaminus; 
                ChemicalDataObject* m_alpha;
+       
+               Isotope::Nucleons m_nucleons;
+               
 };
 
 #endif // ISOTOPE_H