Commit f4d7ae5d authored by Yan's avatar Yan
Browse files

Printing of TSQ ZCE graph

parent 5afe6fed
Pipeline #14990 failed with stages
in 53 seconds
......@@ -2,6 +2,7 @@ from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
from PyQt5 import QtCore
from PyQt5 import QtWidgets
from PyQt5 import QtPrintSupport
import numpy as np
import prasopes.graphtools as gt
import prasopes.filetools as ft
......@@ -9,12 +10,12 @@ import os.path
import pkg_resources
def pop_dial(zcespec, gradspect, data_set, widget, coff_d, grad_d,
def pop_dial(zcespec, gradspect, data_set, coff_d, grad_d,
textfield, fn, parent):
if fn[0] is None:
QtWidgets.QMessageBox.warning(
parent, "ZCE calculation",
"No spectrum opened, cancelling request")
"No spectrum opened, nothing to display")
return
zcespec.clear()
gradspect.clear()
......@@ -51,7 +52,6 @@ def pop_dial(zcespec, gradspect, data_set, widget, coff_d, grad_d,
gradspect.annotate('{:.2f}'.format(grad_d['gmax']),
xy=(grad_d['x'][maxarg], grad_d['y'][maxarg]))
zcespec.figure.canvas.draw()
widget.show()
def exp_zce(zce_spec, zcegrad_spec, fn, parent):
......@@ -90,6 +90,25 @@ def help_msg(pw):
pw, "TSQ zce tool help", "{}".format(helpcontent))
def print_graph(ds, coff, coffgrad, filename):
printfig = Figure(figsize=(5, 2), dpi=100)
printplot = printfig.add_subplot(111)
printplot_overlay = printplot.twinx()
printcanvas = FigureCanvas(printfig)
textfield = QtWidgets.QLabel()
pop_dial(printplot, printplot_overlay, ds, coff, coffgrad,
textfield, filename, None)
widget = QtWidgets.QDialog(None, windowTitle='Print preview')
layout = QtWidgets.QVBoxLayout(widget)
layout.addWidget(printcanvas)
widget.resize(600, 400)
widget.show()
dialog = QtPrintSupport.QPrintDialog()
if dialog.exec_() == QtWidgets.QDialog.Accepted:
printcanvas.render(dialog.printer())
widget.close()
def dialog(parent, ds, filename):
coff = dict(x=[0], y=[0], line=None, name="",
xlabel="Voltage (V)", ylabel="ion count")
......@@ -114,6 +133,9 @@ def dialog(parent, ds, filename):
zce_export = QtWidgets.QPushButton("Export ZCE")
zce_export.clicked.connect(lambda: exp_zce(
coff, coffgrad, filename, parent))
zce_print = QtWidgets.QPushButton("Print ZCE")
zce_print.clicked.connect(lambda: print_graph(
ds, coff, coffgrad, filename))
zce_help = QtWidgets.QPushButton("Help")
zce_help.clicked.connect(lambda: help_msg(parent))
close_button = QtWidgets.QPushButton("Close")
......@@ -125,11 +147,13 @@ def dialog(parent, ds, filename):
textfield = QtWidgets.QLabel(coffgrad['gmax'])
butt_layout.addWidget(textfield)
butt_layout.addStretch(1)
butt_layout.addWidget(zce_print)
butt_layout.addWidget(zce_export)
butt_layout.addWidget(close_button)
dial_layout = QtWidgets.QVBoxLayout(dial_widget)
dial_layout.addWidget(graph_canvas)
dial_layout.addLayout(butt_layout)
pop_dial(coffspect, coffspect_grad, ds, dial_widget, coff, coffgrad,
dial_widget.show()
pop_dial(coffspect, coffspect_grad, ds, coff, coffgrad,
textfield, filename, parent)
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