From 35b217dd46c09ecd72729f1641b4a995a9e8b0cf Mon Sep 17 00:00:00 2001 From: Carsten Niehaus Date: Sat, 8 Oct 2005 15:29:03 +0000 Subject: [PATCH] make Spectrum::band a class, not a struct and convert the using classes svn path=/trunk/KDE/kdeedu/kalzium/src/spectrum.h; revision=468561 --- kalzium/src/spectrum.cpp | 73 ++++++++++++++++++++-------------------- kalzium/src/spectrum.h | 26 ++++++++++---- 2 files changed, 57 insertions(+), 42 deletions(-) diff --git a/kalzium/src/spectrum.cpp b/kalzium/src/spectrum.cpp index d24e699..99a7199 100644 --- a/kalzium/src/spectrum.cpp +++ b/kalzium/src/spectrum.cpp @@ -27,26 +27,26 @@ double Spectrum::minBand() { - double value = ( *m_bandlist.begin() ).wavelength; - QList::const_iterator it = m_bandlist.begin(); - const QList::const_iterator itEnd = m_bandlist.end(); + double value = ( *m_bandlist.begin() )->wavelength; + QList::const_iterator it = m_bandlist.begin(); + const QList::const_iterator itEnd = m_bandlist.end(); for (;it!=itEnd;++it) { - if ( value > ( *it ).wavelength ) - value = ( *it ).wavelength; + if ( value > ( *it )->wavelength ) + value = ( *it )->wavelength; } return value; } double Spectrum::maxBand() { - double value = ( *m_bandlist.begin() ).wavelength; - QList::const_iterator it = m_bandlist.begin(); - const QList::const_iterator itEnd = m_bandlist.end(); + double value = ( *m_bandlist.begin() )->wavelength; + QList::const_iterator it = m_bandlist.begin(); + const QList::const_iterator itEnd = m_bandlist.end(); for (;it!=itEnd;++it) { - if ( value < ( *it ).wavelength ) - value = ( *it ).wavelength; + if ( value < ( *it )->wavelength ) + value = ( *it )->wavelength; } return value; } @@ -56,12 +56,12 @@ Spectrum* Spectrum::adjustToWavelength( double min, double max ) { Spectrum *spec = new Spectrum(); - QList::const_iterator it = m_bandlist.begin(); - const QList::const_iterator itEnd = m_bandlist.end(); + QList::const_iterator it = m_bandlist.begin(); + const QList::const_iterator itEnd = m_bandlist.end(); for ( ; it != itEnd; ++it ) { - if ( ( *it ).wavelength < min || ( *it ).wavelength > max ) + if ( ( *it )->wavelength < min || ( *it )->wavelength > max ) continue; spec->addBand( *it ); @@ -75,14 +75,14 @@ Spectrum* Spectrum::adjustToWavelength( double min, double max ) void Spectrum::adjustIntensities() { int maxInt = 0; - QList::Iterator it = m_bandlist.begin(); - const QList::Iterator itEnd = m_bandlist.end(); + QList::Iterator it = m_bandlist.begin(); + const QList::Iterator itEnd = m_bandlist.end(); //find the highest intensity for ( ; it != itEnd; ++it ) { - if ( ( *it ).intensity > maxInt ) - maxInt = ( *it ).intensity; + if ( ( *it )->intensity > maxInt ) + maxInt = ( *it )->intensity; } //check if an adjustment is needed or not @@ -94,10 +94,10 @@ void Spectrum::adjustIntensities() it = m_bandlist.begin(); for ( ; it != itEnd; ++it ) { - double curInt = ( ( double )( *it ).intensity ); + double curInt = ( ( double )( *it )->intensity ); double newInt = max*1000/curInt; - ( *it ).intensity = ( int ) round( newInt ); + ( *it )->intensity = ( int ) round( newInt ); } } @@ -105,15 +105,15 @@ QList Spectrum::wavelengths( double min, double max ) { QList list; - QList::const_iterator it = m_bandlist.begin(); - const QList::const_iterator itEnd = m_bandlist.end(); + QList::const_iterator it = m_bandlist.begin(); + const QList::const_iterator itEnd = m_bandlist.end(); for ( ; it != itEnd; ++it ) { - if ( ( *it ).wavelength < min || ( *it ).wavelength > max ) + if ( ( *it )->wavelength < min || ( *it )->wavelength > max ) continue; - list.append( ( *it ).wavelength ); + list.append( ( *it )->wavelength ); } return list; @@ -125,22 +125,22 @@ QString Spectrum::bandsAsHtml() html += ""; - QList::const_iterator it = m_bandlist.begin(); - const QList::const_iterator itEnd = m_bandlist.end(); + QList::const_iterator it = m_bandlist.begin(); + const QList::const_iterator itEnd = m_bandlist.end(); for (;it!=itEnd;++it) { html += QString( "" ) - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" - + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + "\n"; } @@ -149,3 +149,4 @@ QString Spectrum::bandsAsHtml() html += ""; return html; } + diff --git a/kalzium/src/spectrum.h b/kalzium/src/spectrum.h index 2811f94..8ef4774 100644 --- a/kalzium/src/spectrum.h +++ b/kalzium/src/spectrum.h @@ -47,9 +47,18 @@ class Spectrum /** * a band is one line in the spectrum of an element */ - struct band + class band { - ///in nm) + public: + band(){ + wavelength = -1.0; + aki = -1.0; + energy1 = -1.0; + energy2 = -1.0; + intensity = -1; + } + + ///in nm double wavelength; ///Transition Probabilities @@ -77,8 +86,9 @@ class Spectrum * adds the band @p b to the internal * lists of bands */ - void addBand( band b ){ - m_bandlist.append( b ); + void addBand( Spectrum::band* b ){ + if ( b ) + m_bandlist.append( b ); } /** @@ -123,9 +133,13 @@ class Spectrum /** * @return the list of bands of the spectrum */ - QList bandlist(){ + QList bandlist(){ return m_bandlist; } + + QList bandList(){ + return bandlist(); + } /** * cache the values of the biggest and @@ -161,7 +175,7 @@ class Spectrum /** * the internal dataset */ - QList m_bandlist; + QList m_bandlist; /** * the cached values of the highest and lowest wavelength -- 2.47.3
" + i18n( "Wavelength: %1 nm" ).arg( ( *it ).wavelength ) + "" + i18n( "Intensity: %1" ).arg( ( *it ).intensity ) + "" + i18n( "Probability: %1 108s-1" ).arg( ( *it ).aki ) + "" + i18n( "Energy 1: %1" ).arg( ( *it ).energy1 ) + "" + i18n( "Energy 2: %1" ).arg( ( *it ).energy2 ) + "" + i18n( "Electron Configuration 1: %1" ).arg( ( *it ).electronconfig1 ) + "" + i18n( "Electron Configuration 2: %1" ).arg( ( *it ).electronconfig2 ) + "" + i18n( "Term 1: %1" ).arg( ( *it ).term1 ) + "" + i18n( "Term 2: %1" ).arg( ( *it ).term2 ) + "" + i18n( "J 1: %1" ).arg( ( *it ).J1 ) + "" + i18n( "J 2: %1" ).arg( ( *it ).J2 ) + "" + i18n( "Wavelength: %1 nm" ).arg( ( *it )->wavelength ) + "" + i18n( "Intensity: %1" ).arg( ( *it )->intensity ) + "" + i18n( "Probability: %1 108s-1" ).arg( ( *it )->aki ) + "" + i18n( "Energy 1: %1" ).arg( ( *it )->energy1 ) + "" + i18n( "Energy 2: %1" ).arg( ( *it )->energy2 ) + "" + i18n( "Electron Configuration 1: %1" ).arg( ( *it )->electronconfig1 ) + "" + i18n( "Electron Configuration 2: %1" ).arg( ( *it )->electronconfig2 ) + "" + i18n( "Term 1: %1" ).arg( ( *it )->term1 ) + "" + i18n( "Term 2: %1" ).arg( ( *it )->term2 ) + "" + i18n( "J 1: %1" ).arg( ( *it )->J1 ) + "" + i18n( "J 2: %1" ).arg( ( *it )->J2 ) + "