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 )
{
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();
class Spectrum
{
public:
+ /**
+ * public ctor
+ */
Spectrum(){
kdDebug() <<"Spectrum::Spectrum" << endl;
};
+
+ /**
+ * public dtor
+ */
~Spectrum(){};
/**
QString J2;
};
+ /**
+ * adds the band @p b to the internal
+ * lists of bands
+ */
void addBand( band b ){
m_bandlist.append( b );
}
*/
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;
}
*/
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