#include "element.h"
#include "prefs.h"
+#include "spectrum.h"
#include <qdom.h>
#include <qfile.h>
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();
}
Element *e = new Element();
- e->setSpektrum( spectrum );
+ e->setSpectrum( spectrum );
e->setDate(date);
e->setBiologicalMeaning(bio);
e->setNumber( number );
class QDomDocument;
class QPainter;
class QPoint;
+class Spectrum;
struct coordinate;
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
m_isotopeList = list;
}
- void setSpektrum( Spektrum *spec ){
+ void setSpectrum( Spectrum *spec ){
m_spectrum = spec;
}
*/
int m_ElementNumber;
- Spektrum *m_spectrum;
+ Spectrum *m_spectrum;
QValueList<Isotope*> m_isotopeList;
#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 )
{
: 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 );
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 ) );
#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
*/
SpectrumWidget( QWidget *parent, const char* name = 0 );
~SpectrumWidget();
- void setSpektrum( Spektrum* spec ){
- m_spektrum = spec;
+ void setSpectrum( Spectrum* spec ){
+ m_spectrum = spec;
}
/**
*/
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
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;