Commit fbd6f81d authored by 3Yan's avatar 3Yan

Advanced image clipping config settings pt 1/2

parent 036fd365
......@@ -20,6 +20,7 @@ def settings():
("imggen/yinch", 4),
("imggen/dpi", 300),
("imggen/xtics", 5),
("imggen/onlymanann", False),
("recents", "")}
[settings.setValue(*i)
for i in defvals if not settings.contains(i[0])]
......@@ -64,6 +65,14 @@ def posvarconf(label, value, config, num="int"):
return layout
def checkboxconf(label, value, config):
checkbox = QtWidgets.QCheckBox(label)
checkbox.setChecked(config.value(value,type=bool))
checkbox.stateChanged.connect(lambda: config.setValue(
value, checkbox.checkState()))
return checkbox
def dial(parent):
"""constructs a dialog window"""
dialog = QtWidgets.QDialog(
......@@ -104,6 +113,8 @@ def dial(parent):
"Figure dpi", "imggen/dpi", config))
imggenlayout.addLayout(posvarconf(
"Figure x axis major ticks count", "imggen/xtics", config))
imggenlayout.addWidget(checkboxconf(
"Manual annotation only", "imggen/onlymanann", config))
tabs.addTab(imggentab, "Image clip/export")
close_button = QtWidgets.QPushButton("Close")
......
......@@ -401,7 +401,7 @@ def ann_spec(ms_spec, msdata, ann_limit=0.01):
msdata['annotation'].append(peaktext)
def pop_plot(xdata, ydata, plot, plot_data, colornum=0, legend=None):
def pop_plot(xdata, ydata, plot, plot_data, colornum=0, legend=None, annotate=True):
"""Define and populate plot"""
plot.plot(xdata, ydata, linewidth=1, color=(
colors[colornum % len(colors)]/255), label=legend)
......@@ -417,8 +417,8 @@ def pop_plot(xdata, ydata, plot, plot_data, colornum=0, legend=None):
plot_data['texts'] = [plot.annotate(
a.get_text(), a.xy, picker=True, bbox=ann_bbox, in_layout=False)
for a in plot_data['texts']]
if "annotation" in plot_data:
ann_spec(plot, plot_data)
if "annotation" in plot_data and annotate == True:
ann_spec(plot, plot_data)
if "xtics" in plot_data:
plot.locator_params(nbins=plot_data["xtics"], axis='x')
plot.minorticks_on()
......
......@@ -29,9 +29,13 @@ def paint_image(mass_spec, spect, fn=None, painttarget=None):
texts = copy.copy(mass_spec)
if len(mass_spec['headers']) != 0:
legend = spect.get_legend().get_texts()
[gt.pop_plot(*line, printplot, texts, i, legend[i].get_text())
[gt.pop_plot(*line, printplot, texts, i, legend[i].get_text(),
not (cf.settings().value(
configtype.format("onlymanann"), type=bool)))
for i, line in enumerate(data)]
printplot.legend(loc=2)
legend = 1
if legend == True:
printplot.legend(loc=2)
else:
[gt.pop_plot(*line, printplot, texts, i)
for i, line in enumerate(data)]
......
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