***************************************************************************/
#include "spectrum.h"
-#include <klocale.h>
+#include <qlayout.h>
+
#include <kglobal.h>
#include <kstandarddirs.h>
+#include <klocale.h>
#include <math.h>
void SpectrumWidget::wavelengthToRGB( double wavelength, int& r, int& g, int& b )
{
- double blue, green, red, factor;
+ double blue = 0.0, green = 0.0, red = 0.0, factor = 0.0;
- double wavelength_ = floor( wavelength );
+ int wavelength_ = floor( wavelength );
kdDebug() << wavelength << " :: " << wavelength_ << endl;
return c;
}
+SpectrumView::SpectrumView( QWidget *parent, const char* name )
+ : QWidget( parent, name )
+{
+ QVBoxLayout *spectrumLayout = new QVBoxLayout( this );
+ m_spectrum = new SpectrumWidget( this, "spectrum" );
+ spectrumLayout->addWidget( m_spectrum );
+
+ QHBoxLayout *hbox = new QHBoxLayout( this );
+ m_spinbox_left = new QSpinBox( 380, 779, 1, this );
+ m_spinbox_right = new QSpinBox( 381, 780, 1, this );
+ hbox->addWidget( m_spinbox_left );
+ hbox->addWidget( m_spinbox_right );
+
+ spectrumLayout->addLayout( hbox );
+}
+
#include "spectrum.moc"
#include <qimage.h>
#include <qstring.h>
#include <qvaluelist.h>
+#include <qspinbox.h>
#include <kimageeffect.h>
#include <kdebug.h>
void setSpectra( QValueList<double> l ){
m_spectra = l;
}
+
+ /**
+ * This limits the width of the spectrum in terms of
+ * wavelength. For example you can set it to only
+ * show the area between 500 and 550 nm
+ *
+ * @param left the left border
+ * @param right the right border
+ */
+ void setBorders( double left, double right ){
+ startValue = left;
+ endValue = right;
+ }
private:
QValueList<double> m_spectra;
protected:
virtual void paintEvent( QPaintEvent *e );
};
+
+class SpectrumView : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ SpectrumView( QWidget* parent, const char* name );
+
+ void setSpectra( QValueList<double> l ){
+ m_spectrum->setSpectra( l );
+ }
+
+ private:
+ SpectrumWidget *m_spectrum;
+
+ QSpinBox *m_spinbox_left, *m_spinbox_right;
+};
+
#endif // SPECTRUM_H