diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionQtTabFitting.ui b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionQtTabFitting.ui index 37790a92d1a8755abea0539978ebbdcb21a1f392..fe234039b3cc25d52f0aaf9b0d2cb5504d9603ce 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionQtTabFitting.ui +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionQtTabFitting.ui @@ -370,6 +370,9 @@ </item> <item> <widget class="QPushButton" name="pushButton_add_peak"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="text"> <string>Add Peak</string> </property> @@ -377,6 +380,9 @@ </item> <item> <widget class="QPushButton" name="pushButton_save_peak_list"> + <property name="enabled"> + <bool>true</bool> + </property> <property name="text"> <string>Save Peaks List</string> </property> diff --git a/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp b/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp index 02c02e43bde3835f0400dc4210ee93852cfbe132..2cc4aa93614dc15c16cdb814153fce8c1f133939 100644 --- a/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp +++ b/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp @@ -784,6 +784,8 @@ void EnggDiffractionViewQtGUI::setPeakPickerEnabled(bool enabled) { m_peakPicker->setEnabled(enabled); m_peakPicker->setVisible(enabled); m_uiTabFitting.dataPlot->replot(); // PeakPicker might get hidden/shown + m_uiTabFitting.pushButton_add_peak->setEnabled(enabled); + m_uiTabFitting.pushButton_select_peak->setEnabled(!enabled); } void EnggDiffractionViewQtGUI::setPeakPicker( @@ -1325,29 +1327,30 @@ void MantidQt::CustomInterfaces::EnggDiffractionViewQtGUI::setPeakPick() { void MantidQt::CustomInterfaces::EnggDiffractionViewQtGUI::addPeakToList() { - if (m_peakPicker->isEnabled()) { - auto peakCentre = getPeakCentre(); - - std::stringstream stream; - stream << std::fixed << std::setprecision(4) << peakCentre; - auto strPeakCentre = stream.str(); - - auto curExpPeaksList = m_uiTabFitting.lineEdit_fitting_peaks->text(); - - if (!curExpPeaksList.isEmpty()) { - - std::string expPeakStr = curExpPeaksList.toStdString(); - std::size_t found = (expPeakStr.find_last_of(", ") || expPeakStr.find_last_of(",")); - if (found) { - QString comma = ", "; - curExpPeaksList.append(comma + QString::fromStdString(strPeakCentre)); - } - else { - curExpPeaksList.append(QString::fromStdString(strPeakCentre)); - } - m_uiTabFitting.lineEdit_fitting_peaks->setText(curExpPeaksList); - } - } + if (m_peakPicker->isEnabled()) { + auto peakCentre = getPeakCentre(); + + std::stringstream stream; + stream << std::fixed << std::setprecision(4) << peakCentre; + auto strPeakCentre = stream.str(); + + auto curExpPeaksList = m_uiTabFitting.lineEdit_fitting_peaks->text(); + + if (!curExpPeaksList.isEmpty()) { + + std::string expPeakStr = curExpPeaksList.toStdString(); + std::string lastTwoChr = expPeakStr.substr(expPeakStr.size() - 2); + auto lastChr = expPeakStr.back(); + char comma = ','; + if (lastChr == comma || lastTwoChr == ", ") { + curExpPeaksList.append(QString::fromStdString(" " + strPeakCentre)); + } else { + QString comma = ", "; + curExpPeaksList.append(comma + QString::fromStdString(strPeakCentre)); + } + m_uiTabFitting.lineEdit_fitting_peaks->setText(curExpPeaksList); + } + } } void MantidQt::CustomInterfaces::EnggDiffractionViewQtGUI::savePeakList() {