From: Carsten Niehaus Date: Mon, 11 Jul 2005 11:57:19 +0000 (+0000) Subject: Add the spectrum view. Doesn't add any new strings. X-Git-Tag: v3.80.2~300^2~96 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=e4cc105d3a8da3856468150f7a166c93bd3e417c;p=libqmvoc.git Add the spectrum view. Doesn't add any new strings. svn path=/trunk/KDE/kdeedu/kalzium/src/spectrum.h; revision=433674 --- diff --git a/kalzium/src/spectrum.cpp b/kalzium/src/spectrum.cpp new file mode 100644 index 0000000..188e140 --- /dev/null +++ b/kalzium/src/spectrum.cpp @@ -0,0 +1,38 @@ +#include "spectrum.h" + +SpectrumWidget::SpectrumWidget( QWidget* parent, const char* name ) + : QWidget( parent,name ) +{ +} + +SpectrumWidget::~SpectrumWidget(){} + +void SpectrumWidget::paintEvent( QPaintEvent *e ) +{ + QPainter p; + p.begin( this ); + p.fillRect( 0, 0, width(), height(), paletteBackgroundColor() ); + drawLines( &p ); +} + +void SpectrumWidget::drawLines( QPainter *p ) +{ + //the spectrum goes from about 780nm to about 400nm + //750 is a dark red + //660 yellow + //580 green + //500 light blue + //400 dark blue + + QImage img = KImageEffect::gradient ( QSize( width(), height() ), Qt::blue, Qt::red, + KImageEffect::HorizontalGradient ); + QPixmap pm( img ); + + p->drawPixmap( width(), height(), pm ); +} + +QColor SpectrumWidget::linecolor( double spectrum ) +{ + QColor c( 128,128,128 ); + return c; +} diff --git a/kalzium/src/spectrum.h b/kalzium/src/spectrum.h new file mode 100644 index 0000000..bc18e9f --- /dev/null +++ b/kalzium/src/spectrum.h @@ -0,0 +1,41 @@ +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + +class SpectrumWidget : public QWidget +{ + Q_OBJECT + + public: + SpectrumWidget( QWidget *parent, const char* name = 0 ); + ~SpectrumWidget(); + + void setSpectra( QValueList l ){ + m_spectra = l; + } + + private: + QValueList m_spectra; + + /** + * draws the spectra-lines + */ + void drawLines( QPainter *p ); + + /** + * @returns the color of a line + * @param spectrum the value of the spectrum + */ + QColor linecolor( double spectrum ); + + protected: + virtual void paintEvent( QPaintEvent *e ); +};