@@ -37,6 +37,7 @@ float scaleAndBlur(float x, float peak, float intensity, float scale = 1.0,
37
37
38
38
// x is the absolute position, but we need to scale the peak position
39
39
float scaled_peak = (peak - shift) / scale;
40
+
40
41
float delta = x - scaled_peak;
41
42
float exponent = -(delta * delta) / (2 * sigma * sigma);
42
43
float gaussian = exp (exponent);
@@ -136,8 +137,13 @@ void SpectraDialog::updateElementCombo()
136
137
SLOT (changeSpectra ()));
137
138
m_ui->elementCombo ->clear ();
138
139
140
+ // go through the elements in atomic number order
141
+ // make a copy of the vector
142
+ std::vector<unsigned char > elements = m_elements;
143
+ std::sort (elements.begin (), elements.end ());
144
+
139
145
// add the unique elements, with the element number as the data
140
- for (auto & element : m_elements ) {
146
+ for (auto & element : elements ) {
141
147
// check to see if it's already in the combo box
142
148
bool found = false ;
143
149
for (int i = 0 ; i < m_ui->elementCombo ->count (); ++i) {
@@ -186,6 +192,7 @@ void SpectraDialog::updateElementCombo()
186
192
// connect the element combo box
187
193
connect (m_ui->elementCombo , SIGNAL (currentIndexChanged (int )), this ,
188
194
SLOT (changeSpectra ()));
195
+ changeSpectra (); // default to 1H
189
196
}
190
197
191
198
void SpectraDialog::changeSpectra ()
@@ -661,6 +668,11 @@ void SpectraDialog::updatePlot()
661
668
// now compose the plot data
662
669
float scale = m_ui->scaleSpinBox ->value ();
663
670
float offset = m_ui->offsetSpinBox ->value ();
671
+ // NMR offsets should be inverted
672
+ if (type == SpectraType::NMR) {
673
+ scale = -scale;
674
+ }
675
+
664
676
float fwhm = m_ui->peakWidth ->value ();
665
677
666
678
float xMin = m_ui->xAxisMinimum ->value ();
@@ -672,6 +684,8 @@ void SpectraDialog::updatePlot()
672
684
float xScale = 1.0 ;
673
685
if (type == SpectraType::Electronic || type == SpectraType::CircularDichroism)
674
686
xScale = 1 .0f / 0 .05f ;
687
+ else if (type == SpectraType::NMR)
688
+ xScale = 1 .0f / 0 .01f ;
675
689
676
690
float stickWidth = fwhm / (xScale * 30.0 );
677
691
0 commit comments