]> Git trees. - libqmvoc.git/commitdiff
* now all wavelength are stored in nm, not angstrom
authorCarsten Niehaus <cniehaus@gmx.de>
Tue, 19 Jul 2005 08:58:14 +0000 (08:58 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Tue, 19 Jul 2005 08:58:14 +0000 (08:58 +0000)
* adding kdebug()-calls to catch one stupid bug.
  --> Michael, your turn :)

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

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

index 6f7abde20e6daaaf4454f2cfb007fe9c8903b772..db4ab7a56a7e8b0154376f2473efc6a29da3d8b9 100644 (file)
@@ -37,12 +37,30 @@ double Spectrum::minBand()
        const QValueList<band>::Iterator itEnd = m_bandlist.end();
        for (;it!=itEnd;++it)
        {
+               kdDebug() << "value: " << ( *it ).wavelength << " Current min-value: " << value << endl;
                if ( value > ( *it ).wavelength )
                        value = ( *it ).wavelength;
        }
        return value;
 }
 
+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();
+       for (;it!=itEnd;++it)
+       {
+               kdDebug() << "value: " << ( *it ).wavelength << " Current max-value: " << value << endl;
+               if ( value < ( *it ).wavelength )
+                       value = ( *it ).wavelength;
+       }
+       return value;
+}
+
+
 Spectrum* Spectrum::adjustToWavelength( double min, double max )
 {
        Spectrum *spec = new Spectrum();
@@ -52,6 +70,7 @@ Spectrum* Spectrum::adjustToWavelength( double min, double max )
 
        for ( ; it != itEnd; ++it )
        {
+               kdDebug( ) << "WL: " << ( *it ).wavelength << endl;
                if ( ( *it ).wavelength < min || ( *it ).wavelength > max )
                        continue;
 
@@ -96,19 +115,22 @@ void Spectrum::adjustIntensities()
        }
 }
 
-double Spectrum::maxBand()
+QValueList<double> Spectrum::wavelengths( double min, double max )
 {
-       kdDebug() << "Spectrum::maxBand()" << endl;
-
-       double value = ( *m_bandlist.begin() ).wavelength;
+       QValueList<double> list;
+       
        QValueList<band>::Iterator it = m_bandlist.begin();
        const QValueList<band>::Iterator itEnd = m_bandlist.end();
-       for (;it!=itEnd;++it)
+
+       for ( ; it != itEnd; ++it )
        {
-               if ( value < ( *it ).wavelength )
-                       value = ( *it ).wavelength;
+               if ( ( *it ).wavelength < min || ( *it ).wavelength > max )
+                       continue;
+
+               list.append( ( *it ).wavelength );
        }
-       return value;
+
+       return list;
 }
 
 SpectrumView::SpectrumView( Spectrum *spec, QWidget *parent, const char* name )
@@ -116,11 +138,14 @@ SpectrumView::SpectrumView( Spectrum *spec, QWidget *parent, const char* name )
 {
        kdDebug()<<"SpectrumView::SpectrumView()" << endl;
 
-       m_spectrum = spec;
+       //make sure only visible light will be plotted
+       m_spectrum = spec->adjustToWavelength( 380.0, 780.0 );
+       m_spectrum->adjustMinMax();
        
        QVBoxLayout *spectrumLayout = new QVBoxLayout( this, 0, -1, "spectrumLayout" );
        m_spectrumWidget = new SpectrumWidget( this, "spectrum" );
        m_spectrumWidget->setSpectrum( m_spectrum );
+       kdDebug() << spec->min() << " max: " << spec->max() << endl;
        m_spectrumWidget->setBorders( spec->min(), spec->max() );
        
        spectrumLayout->addWidget( m_spectrumWidget );
index a1e15d053bd832784450bef72f951c987fc7417b..bed4a7efda8299196591e6f93f12747f19ea99b7 100644 (file)
@@ -48,8 +48,6 @@ class Spectrum
                 * public ctor
                 */
                Spectrum(){
-                       m_min = 400;
-                       m_max = 700;
                };
                
                /**
@@ -62,7 +60,7 @@ class Spectrum
                 */
                struct band
                {
-                       ///in Angstrom (1/10 nm)
+                       ///in nm)
                        double wavelength;
 
                        ///Transition Probabilities
@@ -95,8 +93,8 @@ class Spectrum
                }
 
                /**
-                * @param min the lowest allowed wavalength
-                * @param max the highest allowed wavalength
+                * @param min the lowest allowed wavalength in nanometer
+                * @param max the highest allowed wavalength in nanometer
                 * 
                 * @returns a spectrum with the wavelength in the range
                 * of @p min to @p max. The intensities are readjusted
@@ -111,6 +109,14 @@ class Spectrum
                 */
                void adjustIntensities();
 
+               /**
+                * @param min the lowest allowed wavalength in nanometer
+                * @param max the highest allowed wavalength in nanometer
+                * 
+                * @return the wavelength in a QValueList<double>
+                */
+               QValueList<double> wavelengths( double min, double max );
+
                /**
                 * @return the smallest wavelength
                 */
@@ -128,6 +134,17 @@ class Spectrum
                QValueList<band>* bandlist(){
                        return &m_bandlist;
                }
+       
+               /**
+                * cache the values of the biggest and
+                * smallest wavelenght
+                */
+               void adjustMinMax(){
+                       m_min = minBand();
+                       kdDebug() << "adjustMinMax::m_min: " << m_min << endl;
+                       m_max = maxBand();
+                       kdDebug() << "adjustMinMax::m_max: " << m_max << endl;
+               }
 
        private:
                /**
@@ -139,15 +156,6 @@ class Spectrum
                 * @return the biggest wavelength
                 */
                double maxBand();
-               
-               /**
-                * cache the values of the biggest and
-                * smallest wavelenght
-                */
-               void adjustMinMax(){
-                       m_min = minBand();
-                       m_max = maxBand();
-               }
 
                /**
                 * the internal dataset