]> Git trees. - libqmvoc.git/commitdiff
* Add APIDOCS
authorCarsten Niehaus <cniehaus@gmx.de>
Mon, 18 Jul 2005 11:40:11 +0000 (11:40 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Mon, 18 Jul 2005 11:40:11 +0000 (11:40 +0000)
* Add two methods to Spectrum::

svn path=/trunk/KDE/kdeedu/kalzium/src/spectrum.h; revision=435842

kalzium/src/spectrum.cpp
kalzium/src/spectrum.h

index 2baad62389ccad437fb3c6b21d07f1c19caf7669..0b1d5dbc55fc61ae8fba166b38fb3c769d0f1346 100644 (file)
@@ -48,7 +48,7 @@ Spectrum* Spectrum::adjustToWavelength( double min, double max )
        Spectrum *spec = new Spectrum();
 
        QValueList<band>::Iterator it = m_bandlist.begin();
-       QValueList<band>::Iterator itEnd = m_bandlist.end();
+       const QValueList<band>::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<band>::Iterator it = m_bandlist.begin();
+       const QValueList<band>::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<band>::Iterator it = m_bandlist.begin();
        const QValueList<band>::Iterator itEnd = m_bandlist.end();
index b99389906e53db563f060ab65ce4a60015eb753d..ccb8c6b3e973e928a2067597bc461b78f0d8cb3b 100644 (file)
@@ -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<band> 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