From e607a1a5d2b19a2fb37a0c5e8d3694955dd97679 Mon Sep 17 00:00:00 2001 From: Carsten Niehaus Date: Mon, 18 Jul 2005 11:40:11 +0000 Subject: [PATCH] * Add APIDOCS * Add two methods to Spectrum:: svn path=/trunk/KDE/kdeedu/kalzium/src/spectrum.h; revision=435842 --- kalzium/src/spectrum.cpp | 36 +++++++++++++++++++++++++++++++++--- kalzium/src/spectrum.h | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/kalzium/src/spectrum.cpp b/kalzium/src/spectrum.cpp index 2baad62..0b1d5db 100644 --- a/kalzium/src/spectrum.cpp +++ b/kalzium/src/spectrum.cpp @@ -48,7 +48,7 @@ Spectrum* Spectrum::adjustToWavelength( double min, double max ) Spectrum *spec = new Spectrum(); QValueList::Iterator it = m_bandlist.begin(); - QValueList::Iterator itEnd = m_bandlist.end(); + const QValueList::Iterator itEnd = m_bandlist.end(); for ( ; it != itEnd; ++it ) { @@ -63,13 +63,43 @@ Spectrum* Spectrum::adjustToWavelength( double min, double max ) return spec; } -Spectrum* Spectrum::adjustIntensities() +void Spectrum::adjustIntensities() { - return this; + kdDebug() << "Spectrum::adjustIntensities()" << endl; + + int maxInt = 0; + QValueList::Iterator it = m_bandlist.begin(); + const QValueList::Iterator itEnd = m_bandlist.end(); + + //find the highest intensity + for ( ; it != itEnd; ++it ) + { + if ( ( *it ).intensity > maxInt ) + maxInt = ( *it ).intensity; + } + + kdDebug() << "maxInt" << maxInt << endl; + + //check if an adjustment is needed or not + if ( maxInt == 1000 ) return; + + double max = ( double ) maxInt; + + //now adjust the intensities. + it = m_bandlist.begin(); + for ( ; it != itEnd; ++it ) + { + double curInt = ( ( double )( *it ).intensity ); + + double newInt = max*1000/curInt; + ( *it ).intensity = ( int ) round( newInt ); + } } double Spectrum::maxBand() { + kdDebug() << "Spectrum::maxBand()" << endl; + double value = ( *m_bandlist.begin() ).wavelength; QValueList::Iterator it = m_bandlist.begin(); const QValueList::Iterator itEnd = m_bandlist.end(); diff --git a/kalzium/src/spectrum.h b/kalzium/src/spectrum.h index b993899..ccb8c6b 100644 --- a/kalzium/src/spectrum.h +++ b/kalzium/src/spectrum.h @@ -44,9 +44,16 @@ class SpectrumWidget; class Spectrum { public: + /** + * public ctor + */ Spectrum(){ kdDebug() <<"Spectrum::Spectrum" << endl; }; + + /** + * public dtor + */ ~Spectrum(){}; /** @@ -67,6 +74,10 @@ class Spectrum QString J2; }; + /** + * adds the band @p b to the internal + * lists of bands + */ void addBand( band b ){ m_bandlist.append( b ); } @@ -82,12 +93,22 @@ class Spectrum */ Spectrum* adjustToWavelength( double min, double max ); - Spectrum* adjustIntensities(); + /** + * sets the highest intensity to 1000 and adjusts the + * others + */ + void adjustIntensities(); + /** + * @return the smallest wavelength + */ double min() const{ return m_min; } + /** + * @return the highest wavelength + */ double max() const{ return m_max; } @@ -103,16 +124,29 @@ class Spectrum */ double maxBand(); + /** + * cache the values of the biggest and + * smallest wavelenght + */ void adjustMinMax(){ m_min = minBand(); m_max = maxBand(); } + /** + * the internal dataset + */ QValueList m_bandlist; + /** + * the cached values of the highest and lowest wavelength + */ double m_max, m_min; }; +/** + * @author Carsten Niehaus + */ class SpectrumView : public QWidget { Q_OBJECT -- 2.47.3