[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeedu/kalzium/src
From: Carsten Niehaus <cniehaus () gmx ! de>
Date: 2005-07-12 15:35:02
Message-ID: 1121182502.349937.6971.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 434010 by cniehaus:
Pino, can you do this?
M +28 -7 spectrum.cpp
M +4 -0 spectrum.h
--- trunk/KDE/kdeedu/kalzium/src/spectrum.cpp #434009:434010
@@ -23,10 +23,12 @@
: QWidget( parent,name )
{
startValue = 450;
- endValue = 800;
+ endValue = 760;
m_realWidth = 360;
m_realHeight = 200;
+
+ ref_image = QImage( "/home/carsten/cvs/trunk/kdeedu/kalzium/src/data/spectrum.png" );
}
SpectrumWidget::~SpectrumWidget(){}
@@ -48,13 +50,19 @@
//580 green
//500 light blue
//400 dark blue
+ //
+ //(0,166,172) is for 500 nm
+ //(99,182,82) is for 550 nm
+ //(255,231,49) is for 600 nm
+ //(246,144,49) is for 650 nm
- for(int h = 0; h < 300 ; ++h)
+ for(int h = 450; h < 750 ; ++h)
{
- p->setPen(linecolor( h+450 ));
- int xvalue = m_realWidth/360;
- p->drawLine(xvalue*h,0,xvalue*h,m_realHeight );
+ p->setPen(linecolor(h) );
+ p->drawLine(h-450,0,h-450,m_realHeight );
}
+
+ p->setPen(Qt::black);
int i = 0;
for ( QValueList<double>::Iterator it = m_spectra.begin();
@@ -89,8 +97,21 @@
QColor SpectrumWidget::linecolor( double spectrum )
{
-// int Hcolor =
- QColor c( ( int )spectrum-450,255,255, QColor::Hsv );
+//The picture has 575 pixel
+//
+
+ int max = endValue;
+ int min = startValue;
+
+ //Example: Freq is 600nm. 760-450 = 360.
+ //760 - 600 = 160. 360/160 = 2.25
+ int proportion = ( max-min )/( max - spectrum );
+
+ QRgb rgb = ref_image.pixel(proportion, 2 );
+
+ kdDebug() << "RGB: " << rgb << " Prop " << proportion << endl;
+
+ QColor c( rgb );
return c;
}
--- trunk/KDE/kdeedu/kalzium/src/spectrum.h #434009:434010
@@ -31,6 +31,8 @@
#include <kdebug.h>
#include <kpixmapeffect.h>
+#define MAXCOLOR = 750
+#define MINCOLOR = 450
class SpectrumWidget : public QWidget
{
@@ -47,6 +49,8 @@
private:
QValueList<double> m_spectra;
+ QImage ref_image;
+
/**
* draws the spectra-lines
*/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic