From 72fdbc276a8901cbe1c2a12d1d8ba41494bfc790 Mon Sep 17 00:00:00 2001 From: Carsten Niehaus Date: Wed, 13 Jul 2005 17:15:42 +0000 Subject: [PATCH] improve the spectrumdialog svn path=/trunk/KDE/kdeedu/kalzium/src/spectrum.h; revision=434309 --- kalzium/src/spectrum.cpp | 24 +++++++++++++++++++++--- kalzium/src/spectrum.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/kalzium/src/spectrum.cpp b/kalzium/src/spectrum.cpp index abb3669..54850b8 100644 --- a/kalzium/src/spectrum.cpp +++ b/kalzium/src/spectrum.cpp @@ -19,9 +19,11 @@ ***************************************************************************/ #include "spectrum.h" -#include +#include + #include #include +#include #include @@ -105,9 +107,9 @@ void SpectrumWidget::drawLines( QPainter *p ) 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; @@ -191,4 +193,20 @@ QColor SpectrumWidget::linecolor( double spectrum ) 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" diff --git a/kalzium/src/spectrum.h b/kalzium/src/spectrum.h index 2048a72..7bdcdd0 100644 --- a/kalzium/src/spectrum.h +++ b/kalzium/src/spectrum.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -45,6 +46,19 @@ class SpectrumWidget : public QWidget void setSpectra( QValueList 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 m_spectra; @@ -93,5 +107,23 @@ class SpectrumWidget : public QWidget protected: virtual void paintEvent( QPaintEvent *e ); }; + +class SpectrumView : public QWidget +{ + Q_OBJECT + + public: + SpectrumView( QWidget* parent, const char* name ); + + void setSpectra( QValueList l ){ + m_spectrum->setSpectra( l ); + } + + private: + SpectrumWidget *m_spectrum; + + QSpinBox *m_spinbox_left, *m_spinbox_right; +}; + #endif // SPECTRUM_H -- 2.47.3