Commit 7202be0d authored by 3Yan's avatar 3Yan
Browse files

DRL evolution - pt4

* columns for "correct to" selection are now responsive as they should
parent 08eb1dd2
......@@ -5,6 +5,7 @@ from PyQt5 import QtCore
from PyQt5 import QtWidgets
from PyQt5 import QtGui
from PyQt5 import QtPrintSupport
from copy import copy
import matplotlib
import numpy as np
import prasopes.datatools as dt
......@@ -154,7 +155,7 @@ def update_drlspectrum(ds, drls, drlspectrum):
#Do not divide by 0
intensity = np.divide(intensity, np.clip(np.sum(
intensities, 0), np.nextafter(
0, 1, dtype=np.float32), None))
0, 1, dtype=np.float32), None), dtype=np.float64)
drlspectrum.plot(times, intensity, label=label,
color=(colors[row % len(colors)] / 255))
i += 1
......@@ -212,24 +213,27 @@ def ptable_changed(row, column, ds, drls, drlspectrum):
def dtable_changed(row, column, ds, drls, drlspectrum):
"""routine called by change of the dtable spectra"""
logger.info("Change in the daughter ion table detected")
#TODO: multiple corrections not incorporated!!!
if drls['dt'].cellWidget(row, 0).checkState() == 2:
if (column == 0) or (column % 2 == 0 and drls['dt'].cellWidget(
row, column-1).currentIndex() != 0):
update_drlspectrum(ds, drls, drlspectrum)
def corr_changed(row, ds, drls, drlspectrum):
def corr_changed(correction, ds, drls, drlspectrum):
"""routine called by change of correction for ion"""
logger.info('''Change of the "correct to" detected''')
#TODO: multiple corrections not incorporated!!!
for i in range(drls['dt'].rowCount()):
for j in range(drls['dt'].columnCount()):
if correction == drls['dt'].cellWidget(i, 1+j*2):
row, column = i, 1 + j*2
if (drls['dt'].cellWidget(row, 0).checkState() == 2
and floatize(drls['dt'], row, 2, False) != 0):
and floatize(drls['dt'], row, column+1, False) != 0):
update_drlspectrum(ds, drls, drlspectrum)
def remove_rows(ds, drls, drlspectrum, rows=None):
# TODO: maybe nicer selection in future, but this works for now
logger.info("remowing rows")
if rows == None:
rows = reversed(list(set(
map(lambda x: x.row(), drls['pt'].selectedIndexes()))))
......@@ -237,9 +241,11 @@ def remove_rows(ds, drls, drlspectrum, rows=None):
drls['dt'].cellWidget(row,0).setCheckState(0)
drls['dt'].removeRow(row)
drls['pt'].removeRow(row)
cors = []
for i in range(drls['dt'].rowCount()):
for cornum in range(drls['cors']):
corfor = drls['dt'].cellWidget(i, 1+cornum*2)
cors.append(corfor)
corfor.disconnect()
index = corfor.currentIndex()
corfor.clear()
......@@ -247,13 +253,13 @@ def remove_rows(ds, drls, drlspectrum, rows=None):
corfor.addItems(gettableitemlist(drls['pt']))
if index == row+1:
corfor.setCurrentIndex(0)
corr_changed(i, ds, drls, drlspectrum)
corr_changed(corfor, ds, drls, drlspectrum)
elif index > row+1:
corfor.setCurrentIndex(index-1)
else:
corfor.setCurrentIndex(index)
corfor.currentIndexChanged.connect(lambda:
corr_changed(i, ds, drls, drlspectrum))
list(map(lambda x: x.currentIndexChanged.connect(lambda:
corr_changed(x, ds, drls, drlspectrum)), cors))
def add_line(ds, drls, drlspectrum):
......@@ -289,18 +295,22 @@ def add_line(ds, drls, drlspectrum):
drls['dt'].setCellWidget(newrow, 0, checkbox)
for i in range(drls['cors']):
corfor = QtWidgets.QComboBox()
#TODO: verify on windows that this fixed the weird selection issues
#corfor.setFocusProxy(drls['dt'])
corfor.setFrame(False)
drls['dt'].setCellWidget(newrow, 1+i*2, corfor)
drls['dt'].setItem(newrow, 2+i*2, QtWidgets.QTableWidgetItem())
corfor.currentIndexChanged.connect(lambda: corr_changed(
newrow, ds, drls, drlspectrum))
col = copy(1+i*2)
drls['dt'].setCellWidget(newrow, col, QtWidgets.QComboBox())
drls['dt'].cellWidget(newrow, col).setFrame(False)
drls['dt'].setItem(newrow, col+1, QtWidgets.QTableWidgetItem())
drls['pt'].blockSignals(False)
drls['dt'].blockSignals(False)
#dirty hack, but if if cycle is applied it assigns all cellWidgets
#to a maximal value of i (as this is the value of i after the end
#of the cycle)
cors = list(map(lambda x: drls['dt'].cellWidget(newrow, 1+x*2),
range(drls['cors'])))
list(map(lambda x: x.currentIndexChanged.connect(lambda:
corr_changed(x, ds, drls, drlspectrum)), cors))
ptable_changed(newrow, 1, ds, drls, drlspectrum)
checkbox.stateChanged.connect(lambda: update_drlspectrum(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment