Commit 90781676 authored by Yan's avatar Yan
Browse files

Prints acquisition parameters

* not nice, but working.
parent aff64725
......@@ -100,11 +100,23 @@ def load_file(parent, chrom_plot, spc, d_set, ms_s, fn, chrom_s,
loadthread.start()
def print_graph(data_set, mass_spec, chrom_spec, spect, fn):
def print_graph(data_set, mass_spec, chrom_spec, spect, fn, table):
def printimage(printdevice, img):
printer.setResolution(600)
painter = QtGui.QPainter(printdevice)
font = painter.font()
linesize = printer.resolution()/15
font.setPixelSize(linesize)
painter.setFont(font)
painter.drawImage(0,0,img)
offset = img.size().height()
line = 1
spacing = 1.5
for row in range(table.rowCount()):
if table.cellWidget(row,0).checkState() == 2:
text = table.item(row,1).text() + table.item(row,2).text()
painter.drawText(300,int(offset+line*linesize*spacing), text)
line += 1
painter.end()
#TODO: substitute the QPrintPreviewDialog with QPrintPreviewWidget
printPreview = QtPrintSupport.QPrintPreviewDialog()
......@@ -184,7 +196,6 @@ def about(parent):
def main():
print(QtCore.QThread.currentThread())
app = QtWidgets.QApplication(sys.argv)
loadthread = QtCore.QThread()
......@@ -221,7 +232,9 @@ def main():
params_logger.addHandler(barHandler)
barHandler.setLevel("DEBUG")
paramstable = dt.table(["name","value"], 100)
paramstable = dt.table(["","name","value"], 100)
paramstable.horizontalHeader().setSectionResizeMode(
0, QtWidgets.QHeaderView.ResizeToContents)
graph = Figure(figsize=(5, 4), dpi=100, facecolor="None")
grid = graph.add_gridspec(2, 1)
chromatogram = graph.add_subplot(grid[0,0], facecolor=(1, 1, 1, 0.8))
......@@ -266,7 +279,7 @@ def main():
"document-print"), "&Print", None)
printact.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_P)
printact.triggered.connect(lambda: print_graph(
ds, ms, chrom, spectrum, filename))
ds, ms, chrom, spectrum, filename, paramstable))
settingsact = QtWidgets.QAction(QtGui.QIcon.fromTheme(
"preferences-system"), "&Settings...", None)
settingsact.triggered.connect(lambda: cf.dial(main_window))
......
......@@ -110,7 +110,7 @@ def plot_subtime(mpl_spectrum, mpl_chromatogram, ds, ms_data, chrom_data):
for i,subset in enumerate(ds):
selection = chrom_data['timesarg'][i]
if len(ms_data['headers']) == len(ds):
legend = legendize(ms_data['headers'][i][selection])
legend = legendize(ms_data['headers'][i][selection], chrom_data)
else:
legend = None
if cf.settings().value("view/oddeven", type=bool):
......@@ -272,7 +272,7 @@ def pop_plot(xdata, ydata, plot, plot_data, colornum=0, legend=None):
plot.tick_params(axis='y', which='minor', left=False)
def legendize(rawlegend):
def legendize(rawlegend, chrom_data):
#sanity check
if len(rawlegend) == 0:
return None
......@@ -287,7 +287,8 @@ def legendize(rawlegend):
marks[int(wut[0])], *wut[1:])
return text
strdata = [translate(i) for i in np.unique(np.array(rawlegend), axis=0)]
strtext = " and ".join(strdata)
strtext = " and ".join(strdata) + "; t = {:.2f}-{:.2f} min".format(
chrom_data['t_start'], chrom_data['t_end'])
return strtext
......@@ -316,7 +317,7 @@ def populate(mpl_chromatogram, mpl_spectrum, data_set,
chrom_data['t_end'] = data_set[-1]['chrom_dat'][0, -1]
for i,subset in enumerate(data_set):
if len(ms_data['headers']) == len(data_set):
legend = legendize(ms_data['headers'][i])
legend = legendize(ms_data['headers'][i], chrom_data)
else:
legend = None
if cf.settings().value("view/oddeven", type=bool):
......@@ -350,13 +351,13 @@ def update_paramstable(table, ms, chrom):
table.setRowCount(len(ms['params'][0]))
for row, paramname in enumerate(ms['params'][0]):
[table.setItem(row,col, QtWidgets.QTableWidgetItem())
for col in range(2)]
table.item(row,0).setText(paramname)
for col in range(1,3)]
table.setCellWidget(row,0,QtWidgets.QCheckBox())
table.item(row,1).setText(paramname)
vals = [param[row] for param in ms['params'][1]
if (param[0] >= chrom['t_start'] and param[0] <= chrom['t_end'])]
if len(vals) == 0:
table.item(row,1).setText("")
continue
text = ""
elif all([type(val) in [np.float32, np.float64] for val in vals]):
aver = np.average(vals)
minim = min(vals)
......@@ -365,4 +366,4 @@ def update_paramstable(table, ms, chrom):
else:
values = [str(i) for i in np.unique(np.array(vals), axis=0)]
text = " or ".join(values)
table.item(row,1).setText(text)
table.item(row,2).setText(text)
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