spec->addPeak( p );
}
- spec->adjustMinMax();
-
return spec;
}
void Spectrum::adjustIntensities()
{
int maxInt = 0;
- QList<peak*>::Iterator it = m_peaklist.begin();
- const QList<peak*>::Iterator itEnd = m_peaklist.end();
-
//find the highest intensity
- for ( ; it != itEnd; ++it )
+ foreach ( Spectrum::peak * p, m_peaklist)
{
- if ( ( *it )->intensity > maxInt )
- maxInt = ( *it )->intensity;
+ if ( p->intensity > maxInt )
+ maxInt = p->intensity;
}
//check if an adjustment is needed or not
if ( maxInt == 1000 ) return;
- double max = ( double ) maxInt;
+ const double max = ( double ) maxInt;
//now adjust the intensities.
- it = m_peaklist.begin();
- for ( ; it != itEnd; ++it )
+ foreach ( Spectrum::peak * p, m_peaklist)
{
- double curInt = ( ( double )( *it )->intensity );
-
- double newInt = max*1000/curInt;
- ( *it )->intensity = ( int ) round( newInt );
+ double newInt = max*1000/p->intensity;
+
+ p->intensity = ( int ) round( newInt );
}
}
*/
QList<double> wavelengths( double min, double max );
- /**
- * @return the smallest wavelength
- */
- double min() const{
- return m_min;
- }
-
- /**
- * @return the highest wavelength
- */
- double max() const{
- return m_max;
- }
-
/**
* @return the list of peaks of the spectrum
*/
QList<Spectrum::peak*> peaklist(){
return m_peaklist;
}
-
- /**
- * cache the values of the biggest and
- * smallest wavelenght
- */
- void adjustMinMax(){
- m_min = minPeak();
- m_max = maxPeak();
- }
/**
* @return the parent element of this spectrum
return m_parentElement;
}
- private:
/**
* @return the smallest wavelength
*/
*/
double maxPeak();
+ private:
/**
* the internal dataset
*/
QList<peak*> m_peaklist;
- /**
- * the cached values of the highest and lowest wavelength
- */
- double m_max, m_min;
-
Element* m_parentElement;
};
#endif // SPECTRUM_H