]> Git trees. - libqmvoc.git/commitdiff
Add the spectrum view. Doesn't add any new strings.
authorCarsten Niehaus <cniehaus@gmx.de>
Mon, 11 Jul 2005 11:57:19 +0000 (11:57 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Mon, 11 Jul 2005 11:57:19 +0000 (11:57 +0000)
svn path=/trunk/KDE/kdeedu/kalzium/src/spectrum.h; revision=433674

kalzium/src/spectrum.cpp [new file with mode: 0644]
kalzium/src/spectrum.h [new file with mode: 0644]

diff --git a/kalzium/src/spectrum.cpp b/kalzium/src/spectrum.cpp
new file mode 100644 (file)
index 0000000..188e140
--- /dev/null
@@ -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 (file)
index 0000000..bc18e9f
--- /dev/null
@@ -0,0 +1,41 @@
+#include <qwidget.h>
+#include <qcolor.h>
+#include <qpainter.h>
+#include <qimage.h>
+#include <qstring.h>
+#include <qvaluelist.h>
+
+#include <kimageeffect.h>
+#include <kdebug.h>
+#include <kpixmapeffect.h>
+
+
+class SpectrumWidget : public QWidget
+{
+       Q_OBJECT
+
+       public:
+               SpectrumWidget( QWidget *parent, const char* name = 0 );
+               ~SpectrumWidget();
+
+               void setSpectra( QValueList<double> l ){
+                       m_spectra = l;
+               }
+       
+       private:
+               QValueList<double> 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 );
+};