]> Git trees. - libqmvoc.git/commitdiff
improve the spectrumdialog
authorCarsten Niehaus <cniehaus@gmx.de>
Wed, 13 Jul 2005 17:15:42 +0000 (17:15 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Wed, 13 Jul 2005 17:15:42 +0000 (17:15 +0000)
svn path=/trunk/KDE/kdeedu/kalzium/src/spectrum.h; revision=434309

kalzium/src/spectrum.cpp
kalzium/src/spectrum.h

index abb3669cfa91f2c19624131bade12ef2b6fdbf7f..54850b8fd6e111b284f47cf13a7608e47f7e7b99 100644 (file)
  ***************************************************************************/
 #include "spectrum.h"
 
-#include <klocale.h>
+#include <qlayout.h>
+
 #include <kglobal.h>
 #include <kstandarddirs.h>
+#include <klocale.h>
 
 #include <math.h>
 
@@ -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"
index 2048a722ffcf6fbb8c878ac98a3dd377aaafb8ae..7bdcdd0d55f0c372b3fd4778690af3c526308786 100644 (file)
@@ -26,6 +26,7 @@
 #include <qimage.h>
 #include <qstring.h>
 #include <qvaluelist.h>
+#include <qspinbox.h>
 
 #include <kimageeffect.h>
 #include <kdebug.h>
@@ -45,6 +46,19 @@ class SpectrumWidget : public QWidget
                void setSpectra( QValueList<double> 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<double> 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<double> l ){
+                       m_spectrum->setSpectra( l );
+               }
+
+       private:
+               SpectrumWidget *m_spectrum;
+
+               QSpinBox *m_spinbox_left, *m_spinbox_right;
+};
+
 #endif // SPECTRUM_H