]> Git trees. - libqmvoc.git/commitdiff
* s/Spektrum/Spectrum
authorCarsten Niehaus <cniehaus@gmx.de>
Sun, 17 Jul 2005 15:15:53 +0000 (15:15 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Sun, 17 Jul 2005 15:15:53 +0000 (15:15 +0000)
* move the class into spectrum.cpp/h
* add some more API

svn path=/trunk/KDE/kdeedu/kalzium/src/spectrum.h; revision=435591

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

index 83b42cb2092ef467e8a49be7f2612b5b80e1ae38..5c1993cd360a46351b8a3067b8d3ad33cd7a3b4f 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "element.h"
 #include "prefs.h"
+#include "spectrum.h"
 
 #include <qdom.h>
 #include <qfile.h>
@@ -625,10 +626,10 @@ EList KalziumDataObject::readData(  QDomDocument &dataDocument )
 
                QDomNodeList spectrumList = domElement.namedItem( "spectra" ).toElement().elementsByTagName( "spectrum" );
 
-               Spektrum *spectrum = new Spektrum();
+               Spectrum *spectrum = new Spectrum();
                for( uint i = 0; i < spectrumList.length(); i++ )
                {
-                       Spektrum::band b;
+                       Spectrum::band b;
                        QDomElement spec = spectrumList.item( i ).toElement();
                        
                        b.intensity = spec.attributeNode( "intensity" ).value().toInt();
@@ -647,7 +648,7 @@ EList KalziumDataObject::readData(  QDomDocument &dataDocument )
                }
        
                Element *e = new Element();
-               e->setSpektrum( spectrum );
+               e->setSpectrum( spectrum );
                e->setDate(date);
                e->setBiologicalMeaning(bio);
                e->setNumber( number );
index 21bd86be2450d76fae907abba29966b9972cb0d4..60e68f5708ab809bdabb9ee46c2e180712a516e3 100644 (file)
@@ -29,6 +29,7 @@ class Element;
 class QDomDocument;
 class QPainter;
 class QPoint;
+class Spectrum;
 
 struct coordinate;
 
@@ -36,42 +37,6 @@ typedef QValueList<Element*> EList;
 typedef QValueList<coordinate> CList;
 typedef QValueList<double> doubleList;
 
-/**
- * @author Carsten Niehaus
- *
- * This class represents an spectrum with all its properties
- */
-class Spektrum
-{
-       public:
-               Spektrum(){};
-               ~Spektrum(){};
-
-               /**
-                * a band is one line in the spektrum of an element
-                */
-               struct band
-               {
-                       double wavelength;
-                       double aki;
-                       double energy1;
-                       double energy2;
-                       int intensity;
-                       QString electronconfig1;
-                       QString electronconfig2;
-                       QString term1;
-                       QString term2;
-                       QString J1;
-                       QString J2;
-               };
-
-               void addBand( band b ){
-                       m_bandlist.append( b );
-               }
-
-               QValueList<band> m_bandlist;
-};
-
 /**
  * @author Carsten Niehaus
  * @author Jörg Buchwald
@@ -322,7 +287,7 @@ class Element{
                        m_isotopeList = list;
                }
 
-               void setSpektrum( Spektrum *spec ){
+               void setSpectrum( Spectrum *spec ){
                        m_spectrum = spec;
                }
 
@@ -562,7 +527,7 @@ class Element{
                 */
                int m_ElementNumber;
 
-               Spektrum *m_spectrum;
+               Spectrum *m_spectrum;
 
                QValueList<Isotope*> m_isotopeList;
 
index 6b04dcb1ac0e14326d70ecfc6c51262bdc230779..53564d3692eb05711abb5faad5d3b57e057eee9a 100644 (file)
 
 #include <math.h>
 
+double Spectrum::minBand()
+{
+       double value = ( *m_bandlist.begin() ).wavelength;
+       QValueList<band>::Iterator it = m_bandlist.begin();
+       const QValueList<band>::Iterator itEnd = m_bandlist.end();
+       for (;it!=itEnd;++it)
+       {
+               if ( value > ( *it ).wavelength )
+                       value = ( *it ).wavelength;
+       }
+       return value;
+}
+
+double Spectrum::maxBand()
+{
+       double value = ( *m_bandlist.begin() ).wavelength;
+       QValueList<band>::Iterator it = m_bandlist.begin();
+       const QValueList<band>::Iterator itEnd = m_bandlist.end();
+       for (;it!=itEnd;++it)
+       {
+               if ( value < ( *it ).wavelength )
+                       value = ( *it ).wavelength;
+       }
+       return value;
+}
+
 SpectrumWidget::SpectrumWidget( QWidget* parent, const char* name )
        : QWidget( parent,name )
 {
@@ -263,8 +289,8 @@ 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 );
+       m_spectrumWidget = new SpectrumWidget( this, "spectrum" );
+       spectrumLayout->addWidget( m_spectrumWidget );
 
        QHBoxLayout *hbox = new QHBoxLayout( this );
        m_spinbox_left = new QSpinBox( 380, 779, 1, this );
@@ -272,13 +298,13 @@ SpectrumView::SpectrumView( QWidget *parent, const char* name )
        m_spinbox_right->setValue( 700 );
        m_spinbox_left->setValue( 400 );
        
-       connect( m_spinbox_right, SIGNAL( valueChanged( int ) ), m_spectrum, SLOT( setRightBorder( int ) ) );
-       connect( m_spinbox_left, SIGNAL( valueChanged( int ) ), m_spectrum, SLOT( setLeftBorder( int ) ) );
+       connect( m_spinbox_right, SIGNAL( valueChanged( int ) ), m_spectrumWidget, SLOT( setRightBorder( int ) ) );
+       connect( m_spinbox_left, SIGNAL( valueChanged( int ) ), m_spectrumWidget, SLOT( setLeftBorder( int ) ) );
 
        m_spectrumbox = new KComboBox( this, "combobox" );
        m_spectrumbox->insertItem( "Emission Spectrum" );
        m_spectrumbox->insertItem( "Absorption Spectrum" );
-       connect( m_spectrumbox, SIGNAL( activated( int ) ), m_spectrum, SLOT( slotActivateSpectrum( int ) ) );
+       connect( m_spectrumbox, SIGNAL( activated( int ) ), m_spectrumWidget, SLOT( slotActivateSpectrum( int ) ) );
        
        
        hbox->addWidget( new QLabel( i18n( "Minimumvalue" ), this ) );
index 7bee4abd50ad4ac9fbbd6ce701a57b66d5d9e9ca..34fc98084c74a9a7326bfec5503d38d8958a7b65 100644 (file)
 
 #include "element.h"
 
+/**
+ * @author Carsten Niehaus
+ *
+ * This class represents an spectrum with all its properties
+ */
+class Spectrum
+{
+       public:
+               Spectrum(){
+                       m_min = minBand();
+                       m_max = maxBand();
+               };
+               ~Spectrum(){};
+
+               /**
+                * a band is one line in the spectrum of an element
+                */
+               struct band
+               {
+                       double wavelength;
+                       double aki;
+                       double energy1;
+                       double energy2;
+                       int intensity;
+                       QString electronconfig1;
+                       QString electronconfig2;
+                       QString term1;
+                       QString term2;
+                       QString J1;
+                       QString J2;
+               };
+
+               void addBand( band b ){
+                       m_bandlist.append( b );
+               }
+
+       private:
+               /**
+                * @return the smallest wavelength
+                */
+               double minBand();
+               
+               /**
+                * @return the biggest wavelength
+                */
+               double maxBand();
+
+               QValueList<band> m_bandlist;
+
+               double m_max, m_min;
+};
+
 /**
  * @author Carsten Niehaus
  */
@@ -46,8 +98,8 @@ class SpectrumWidget : public QWidget
                SpectrumWidget( QWidget *parent, const char* name = 0 );
                ~SpectrumWidget();
 
-               void setSpektrum( Spektrum* spec ){
-                       m_spektrum = spec;
+               void setSpectrum( Spectrum* spec ){
+                       m_spectrum = spec;
                }
 
                /**
@@ -106,7 +158,7 @@ class SpectrumWidget : public QWidget
                 */
                int Adjust( double color, double factor );
 
-               Spektrum *m_spektrum;
+               Spectrum *m_spectrum;
 
                /**
                 * @param the position on a 0 to 1-scale in the widget. 0.5 mean 
@@ -210,13 +262,14 @@ class SpectrumView : public QWidget
        public: 
                SpectrumView( QWidget* parent, const char* name );
 
-//X            void setSpectra( QValueList<double> l ){
-//X                    m_spectrum->setSpektrum( l );
-//X                    update();
-//X            }
+               void setSpectra( Spectrum* spec ){
+                       m_spectrum = spec;
+               }
 
        private:
-               SpectrumWidget *m_spectrum;
+               SpectrumWidget *m_spectrumWidget;
+
+               Spectrum* m_spectrum;
 
                QSpinBox *m_spinbox_left, *m_spinbox_right;