1
0
Fork 0
mirror of https://github.com/gwm17/spspy.git synced 2024-11-22 10:18:49 -05:00

Added delete functionality to SPANC calibration peaks

This commit is contained in:
Gordon McCann 2023-03-29 16:02:25 -04:00
parent c866c07abc
commit 462e959100
3 changed files with 20 additions and 1 deletions

View File

@ -79,6 +79,12 @@ class Spanc:
data.peakID = len(self.calibrations)
self.calibrations[data.peakID] = data
return
def remove_calibration(self, data: Peak) -> bool:
if data.peakID not in self.calibrations.keys():
return False
self.calibrations.pop(data.peakID)
return True
def add_output(self, data: Peak) -> None:
if data.peakID == INVALID_PEAK_ID:

View File

@ -237,8 +237,11 @@ class SpancGUI(QMainWindow):
peakData = self.spanc.calibrations[row]
calDia = PeakDialog(PeakType.CALIBRATION, self.spanc.reactions.keys(), self, peak=peakData)
calDia.new_peak.connect(self.spanc.add_calibration)
calDia.delete_peak.connect(self.spanc.remove_calibration)
if calDia.exec():
self.update_calibration_table()
if self.spanc.isFit == True:
self.handle_run_fit()
return
def handle_new_output(self) -> None:

View File

@ -2,11 +2,12 @@ from ..Spanc import Peak, PeakType, INVALID_PEAK_ID
from PySide6.QtWidgets import QLabel
from PySide6.QtWidgets import QVBoxLayout, QFormLayout, QGroupBox
from PySide6.QtWidgets import QComboBox, QDoubleSpinBox
from PySide6.QtWidgets import QDialog, QDialogButtonBox
from PySide6.QtWidgets import QDialog, QDialogButtonBox, QPushButton
from PySide6.QtCore import Signal
class PeakDialog(QDialog):
new_peak = Signal(Peak)
delete_peak = Signal(Peak)
def __init__(self, peakType: PeakType, rxnList: list[str], parent=None, peak: Peak=None):
super().__init__(parent)
@ -29,6 +30,9 @@ class PeakDialog(QDialog):
self.set_calibration_inputs(peak)
self.peakID = peak.peakID
self.buttonBox.accepted.connect(self.send_update_calibration_peak)
self.deleteButton = QPushButton("Delete", self)
self.deleteButton.clicked.connect(self.send_delete_calibration_peak)
self.centralLayout.addWidget(self.deleteButton)
else:
self.buttonBox.accepted.connect(self.send_calibration_peak)
elif peakType == PeakType.OUTPUT:
@ -114,6 +118,12 @@ class PeakDialog(QDialog):
peak = Peak(excitation=self.exInput.value(), excitationErr=self.uexInput.value(), position=self.xInput.value(),
positionErrStat=self.uxstatInput.value(), positionErrSys=self.uxsysInput.value(), rxnName=self.rxnNameBox.currentText(), peakID=self.peakID)
self.new_peak.emit(peak)
def send_delete_calibration_peak(self) -> None:
peak = Peak(excitation=self.exInput.value(), excitationErr=self.uexInput.value(), position=self.xInput.value(),
positionErrStat=self.uxstatInput.value(), positionErrSys=self.uxsysInput.value(), rxnName=self.rxnNameBox.currentText(), peakID=self.peakID)
self.delete_peak.emit(peak)
self.done(3)
def send_output_peak(self) -> None:
peak = Peak(position=self.xInput.value(), positionErrStat=self.uxstatInput.value(), positionErrSys=self.uxsysInput.value(),