Commit b538adff authored by Yan's avatar Yan
Browse files

Exported figures now configurable in config

* added functionality to settings
* minor debug of annotation function
parent 061e29be
......@@ -10,7 +10,13 @@ def settings():
defvals = {("view/autozoomy", True),
("view/filebrowservisible", True),
("view/intensities", False),
("view/oddeven", False)}
("view/oddeven", False),
("print/xinch", 10),
("print/yinch", 4),
("print/dpi", 300),
("imggen/xinch", 10),
("imggen/yinch", 4),
("imggen/dpi", 300)}
[settings.setValue(i[0], i[1]) for i in defvals if settings.value(i[0]) == None]
return settings
......@@ -22,7 +28,7 @@ def pathsearch(text, value, config):
config.setValue(value, filename)
def pathlayout(label, value, config):
def pathlineconf(label, value, config):
"""adds generic filepath config line"""
textfield = QtWidgets.QLineEdit(config.value(value))
textfield.editingFinished.connect(lambda: config.setValue(
......@@ -37,6 +43,21 @@ def pathlayout(label, value, config):
return layout
def posintvarconf(label, value, config):
"""adds generic positive integer config line"""
textfield = QtWidgets.QLineEdit(config.value(value))
textfield.editingFinished.connect(lambda: config.setValue(
value, textfield.text()))
validator = QtGui.QIntValidator()
validator.setBottom(0)
textfield.setValidator(validator)
layout = QtWidgets.QHBoxLayout()
layout.addWidget(QtWidgets.QLabel("{}:".format(label)))
layout.addStretch()
layout.addWidget(textfield)
return layout
def dial(parent):
"""constructs a dialog window"""
dialog = QtWidgets.QDialog(
......@@ -44,6 +65,37 @@ def dial(parent):
dialog.resize(600,-1)
config = settings()
tabs = QtWidgets.QTabWidget()
pathtab = QtWidgets.QWidget()
pathlayout = QtWidgets.QVBoxLayout(pathtab)
pathlayout.addLayout(pathlineconf(
"Acquisition temp folder", "tmp_location", config))
pathlayout.addLayout(pathlineconf(
"Default open folder", "open_folder", config))
tabs.addTab(pathtab, "Paths")
printtab = QtWidgets.QWidget()
printlayout = QtWidgets.QVBoxLayout(printtab)
printlayout.addLayout(posintvarconf(
"Figure width (inch)", "print/xinch", config))
printlayout.addLayout(posintvarconf(
"Figure height (inch)", "print/yinch", config))
printlayout.addLayout(posintvarconf(
"Figure dpi", "print/dpi", config))
tabs.addTab(printtab, "Printing")
imggentab = QtWidgets.QWidget()
imggenlayout = QtWidgets.QVBoxLayout(imggentab)
imggenlayout.addLayout(posintvarconf(
"Figure width (inch)", "imggen/xinch", config))
imggenlayout.addLayout(posintvarconf(
"Figure height (inch)", "imggen/yinch", config))
imggenlayout.addLayout(posintvarconf(
"Figure dpi", "imggen/dpi", config))
tabs.addTab(imggentab, "Image clip/export")
close_button = QtWidgets.QPushButton("Close")
close_button.clicked.connect(dialog.close)
......@@ -52,10 +104,7 @@ def dial(parent):
butt_layout.addStretch(1)
layout = QtWidgets.QVBoxLayout(dialog)
layout.addLayout(pathlayout("Acquisition temp folder",
"tmp_location", config))
layout.addLayout(pathlayout("Default open folder",
"open_folder", config))
layout.addWidget(tabs)
layout.addStretch(1)
layout.addLayout(butt_layout)
......
......@@ -195,15 +195,16 @@ def ann_spec(ms_spec, msdata, ann_limit=0.01):
('x', float),('y', float)]), order='y')).copy()
red_x = xrange / coef_x
red_y = yrange / coef_y
big_peaks = np.array([], dtype=[('x', float),('y', float)])
big_peaks = np.array([], dtype=[('x', float),('y', float)])
for peak in np.nditer(sort_peaks):
if not np.any((abs(peak['y'] - big_peaks['y']) < red_y) \
& (abs(peak['x'] - big_peaks['x']) < red_x)):
big_peaks = np.append(big_peaks,peak)
return big_peaks
xdata = ms_spec.lines[0].get_data()[0]
ydata = [j.get_data()[1] for j in ms_spec.lines]
xdata = ms_spec.lines[-1].get_data()[0]
ydata = [j.get_data()[1] for j in ms_spec.lines\
if len(j.get_data()[1]) == len(xdata)]
if np.array_equal(xdata, [0]):
return
argvis = dt.argsubselect(xdata, *ms_spec.get_xlim())
......
......@@ -7,19 +7,17 @@ from PyQt5 import QtGui
from PyQt5 import QtPrintSupport
from PyQt5 import QtWidgets
import prasopes.graphtools as gt
import prasopes.config as cf
def paint_image(mass_spec, spect, painttarget=None):
"""generates QImage from mass spectrum"""
if isinstance(painttarget, type(QtPrintSupport.QPrinter())):
#TODO: make it configurable from settings
xinch = 10
yinch = 4
dpi = 300
xinch, yinch, dpi = [cf.settings().value(
"print/{}".format(i), type=int) for i in ("xinch", "yinch", "dpi")]
else:
#TODO: make it configurable from settings
xinch = 10
yinch = 4
dpi = 300
xinch, yinch, dpi = [cf.settings().value(
"imggen/{}".format(i), type=int) for i in ("xinch", "yinch", "dpi")]
paintfig = Figure(figsize=(xinch, yinch), dpi=dpi)
canvas = FigureCanvas(paintfig)
printplot = paintfig.add_subplot(111)
......
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