Commit fa82b41d authored by 3Yan's avatar 3Yan
Browse files

Spectrum clipping now shows part of the path

parent 6e88d312
......@@ -179,7 +179,7 @@ def key_pressed(event, chrom, spect, ds, ms_ds, fn, chrom_ds, config):
update_spectrum(chrom, spect, ds, ms_ds, fn, chrom_ds, config)
if event.key() == QtCore.Qt.Key_C:
if event.modifiers().__int__() == QtCore.Qt.ControlModifier:
imgt.clip_spect_img(ms_ds, spect)
imgt.clip_spect_img(ms_ds, spect, fn)
if event.modifiers().__int__() == QtCore.Qt.ControlModifier+\
QtCore.Qt.ShiftModifier:
dt.clip_spectstr(spect, chrom_ds, fn)
......
......@@ -6,11 +6,12 @@ from PyQt5 import QtCore
from PyQt5 import QtGui
from PyQt5 import QtPrintSupport
from PyQt5 import QtWidgets
from pathlib import Path
import prasopes.graphtools as gt
import prasopes.config as cf
def paint_image(mass_spec, spect, painttarget=None):
def paint_image(mass_spec, spect, fn=None, painttarget=None):
"""generates QImage from mass spectrum"""
if isinstance(painttarget, type(QtPrintSupport.QPrinter())):
xinch, yinch, dpi, xtics = [cf.settings().value("print/{}".format(i),
......@@ -33,6 +34,9 @@ def paint_image(mass_spec, spect, painttarget=None):
[gt.pop_plot(*line, printplot, mass_spec, i)
for i,line in enumerate(data)]
printplot.locator_params(nbins=xtics, axis='x')
if fn not in (None, [None]):
printplot.set_title(Path(*Path(fn[0]).resolve().parts[-2:]),
loc="right")
cache_file = BytesIO()
paintfig.savefig(cache_file)
cache_file.seek(0)
......@@ -40,7 +44,7 @@ def paint_image(mass_spec, spect, painttarget=None):
return image
def clip_spect_img(mass_spec, spect):
image = paint_image(mass_spec, spect)
def clip_spect_img(mass_spec, spect, fn):
image = paint_image(mass_spec, spect, fn=fn)
QtWidgets.QApplication.clipboard().setImage(image)
QtWidgets.QApplication.clipboard().setPixmap(QtGui.QPixmap.fromImage(image))
Markdown is supported
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