blob: 45c62180f2e7dc6ec3a896f6203668a3b45321d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
/***************************************************************************
* Copyright (C) 2005 by Carsten Niehaus *
* [email protected] *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include "spectrum.h"
#include "element.h"
#include <klocale.h>
#include <math.h>
double Spectrum::minBand()
{
double value = ( *m_bandlist.begin() ).wavelength;
TQValueList<band>::const_iterator it = m_bandlist.begin();
const TQValueList<band>::const_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;
TQValueList<band>::const_iterator it = m_bandlist.begin();
const TQValueList<band>::const_iterator itEnd = m_bandlist.end();
for (;it!=itEnd;++it)
{
if ( value < ( *it ).wavelength )
value = ( *it ).wavelength;
}
return value;
}
Spectrum* Spectrum::adjustToWavelength( double min, double max )
{
Spectrum *spec = new Spectrum();
TQValueList<band>::const_iterator it = m_bandlist.begin();
const TQValueList<band>::const_iterator itEnd = m_bandlist.end();
for ( ; it != itEnd; ++it )
{
if ( ( *it ).wavelength < min || ( *it ).wavelength > max )
continue;
spec->addBand( *it );
}
spec->adjustMinMax();
return spec;
}
void Spectrum::adjustIntensities()
{
int maxInt = 0;
TQValueList<band>::Iterator it = m_bandlist.begin();
const TQValueList<band>::Iterator itEnd = m_bandlist.end();
//find the highest intensity
for ( ; it != itEnd; ++it )
{
if ( ( *it ).intensity > maxInt )
maxInt = ( *it ).intensity;
}
//check if an adjustment is needed or not
if ( maxInt == 1000 ) return;
double max = ( double ) maxInt;
//now adjust the intensities.
it = m_bandlist.begin();
for ( ; it != itEnd; ++it )
{
double curInt = ( ( double )( *it ).intensity );
double newInt = max*1000/curInt;
( *it ).intensity = tqRound( newInt );
}
}
TQValueList<double> Spectrum::wavelengths( double min, double max )
{
TQValueList<double> list;
TQValueList<band>::const_iterator it = m_bandlist.begin();
const TQValueList<band>::const_iterator itEnd = m_bandlist.end();
for ( ; it != itEnd; ++it )
{
if ( ( *it ).wavelength < min || ( *it ).wavelength > max )
continue;
list.append( ( *it ).wavelength );
}
return list;
}
TQString Spectrum::bandsAsHtml()
{
TQString html = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html><head><title>Chemical data</title>i<body>";
html += "<table>";
TQValueList<band>::const_iterator it = m_bandlist.begin();
const TQValueList<band>::const_iterator itEnd = m_bandlist.end();
for (;it!=itEnd;++it)
{
html += TQString( "<tr>" )
+ "<td>" + i18n( "Wavelength: %1 nm" ).tqarg( ( *it ).wavelength ) + "</td>"
+ "<td>" + i18n( "Intensity: %1" ).tqarg( ( *it ).intensity ) + "</td>"
+ "<td>" + i18n( "Probability: %1 10<sup>8</sup>s<sup>-1</sup>" ).tqarg( ( *it ).aki ) + "</td>"
+ "<td>" + i18n( "Energy 1: %1" ).tqarg( ( *it ).energy1 ) + "</td>"
+ "<td>" + i18n( "Energy 2: %1" ).tqarg( ( *it ).energy2 ) + "</td>"
+ "<td>" + i18n( "Electron Configuration 1: %1" ).tqarg( ( *it ).electronconfig1 ) + "</td>"
+ "<td>" + i18n( "Electron Configuration 2: %1" ).tqarg( ( *it ).electronconfig2 ) + "</td>"
+ "<td>" + i18n( "Term 1: %1" ).tqarg( ( *it ).term1 ) + "</td>"
+ "<td>" + i18n( "Term 2: %1" ).tqarg( ( *it ).term2 ) + "</td>"
+ "<td>" + i18n( "J 1: %1" ).tqarg( ( *it ).J1 ) + "</td>"
+ "<td>" + i18n( "J 2: %1" ).tqarg( ( *it ).J2 ) + "</td>"
+ "</tr>\n";
}
html += "</table>";
html += "</body></html>";
return html;
}
|