From: Pino Toscano Date: Tue, 12 Jul 2005 17:02:17 +0000 (+0000) Subject: Trey to making the spectre work. X-Git-Tag: v3.80.2~300^2~89 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=1caf93636399e5fed1c75dcab6732b65907eb7ce;p=libqmvoc.git Trey to making the spectre work. svn path=/trunk/KDE/kdeedu/kalzium/src/spectrum.cpp; revision=434029 --- diff --git a/kalzium/src/spectrum.cpp b/kalzium/src/spectrum.cpp index 047cd0b..4720d39 100644 --- a/kalzium/src/spectrum.cpp +++ b/kalzium/src/spectrum.cpp @@ -19,6 +19,9 @@ ***************************************************************************/ #include "spectrum.h" +#include +#include + SpectrumWidget::SpectrumWidget( QWidget* parent, const char* name ) : QWidget( parent,name ) { @@ -28,7 +31,10 @@ SpectrumWidget::SpectrumWidget( QWidget* parent, const char* name ) m_realWidth = 360; m_realHeight = 200; - ref_image = QImage( "/home/carsten/cvs/trunk/kdeedu/kalzium/src/data/spectrum.png" ); + QString spectrumpix = KGlobal::dirs()->findResourceDir("data", "kalzium/data/" ); + spectrumpix += "kalzium/data/spektrum.png"; + + ref_image = QImage( spectrumpix ); } SpectrumWidget::~SpectrumWidget(){} @@ -56,7 +62,7 @@ void SpectrumWidget::drawLines( QPainter *p ) //(255,231,49) is for 600 nm //(246,144,49) is for 650 nm - for(int h = 450; h < 750 ; ++h) + for(int h = 450; h < 760 ; ++h) { p->setPen(linecolor(h) ); p->drawLine(h-450,0,h-450,m_realHeight ); @@ -104,12 +110,9 @@ QColor SpectrumWidget::linecolor( double spectrum ) //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 ); + int proportion = m_realWidth * ( spectrum - startValue ) / ( endValue - startValue ); QRgb rgb = ref_image.pixel(proportion, 2 );