Commit fdc3a84e authored by Yan's avatar Yan

Implemented paintFig into zcetools

parent 73e56a5f
......@@ -145,7 +145,7 @@ def print_graph(augCanvas):
printer.setPageSize(printer.A5)
printer.setDuplex(printer.DuplexNone)
imggen = imgt.ImagePainter("msspec", printer)
imggen.popfig = lambda: popfig_override(imggen, augCanvas)
imggen.popfig = lambda: paint_override(imggen, augCanvas)
image = imggen.paint()
printPreview.paintRequested.connect(lambda:
printimage(printer, image))
......@@ -229,7 +229,7 @@ def oddeven_changed(augCanvas, config, oddevenact):
update_spectrum(augCanvas, config)
def popfig_override(self, augCanvas):
def paint_override(self, augCanvas):
self.plot.set_xlim(augCanvas.spectplot.get_xlim())
self.plot.set_ylim(augCanvas.spectplot.get_ylim())
data = [line.get_data() for line in augCanvas.spectplot.lines]
......@@ -264,7 +264,7 @@ def key_pressed(event, augCanvas, config, update):
dt.clip_tablestr(augCanvas)
else:
painter = imgt.ImagePainter("msspec")
painter.popfig = lambda: popfig_override(painter, augCanvas)
painter.popfig = lambda: paint_override(painter, augCanvas)
painter.clip()
if event.modifiers().__int__() == QtCore.Qt.ControlModifier + \
QtCore.Qt.ShiftModifier:
......
......@@ -16,10 +16,16 @@ def settings():
("print/msspec_yinch", 4),
("print/msspec_dpi", 300),
("print/msspec_xtics", 5),
("print/zcespec_xinch", 5),
("print/zcespec_yinch", 2),
("print/zcespec_dpi", 300),
("imggen/msspec_xinch", 10),
("imggen/msspec_yinch", 4),
("imggen/msspec_dpi", 300),
("imggen/msspec_xtics", 5),
("imggen/zcespec_xinch", 5),
("imggen/zcespec_yinch", 2),
("imggen/zcespec_dpi", 300),
("imggen/msspec_onlymanann", False),
("reactivity/index", 0),
("recents", "")}
......
......@@ -6,6 +6,7 @@ from PyQt5 import QtGui
from PyQt5 import QtWidgets
from PyQt5 import QtPrintSupport
from prasopes.zcetools_help import helpstr
from prasopes import imagetools as imgt
from io import BytesIO
import numpy as np
import prasopes.graphtools as gt
......@@ -100,25 +101,10 @@ def help_msg(pw):
pw, "TSQ zce tool help", "{}".format(helpstr))
def paint_zcegraph(ds, coff, coffgrad, filename):
paintfig = Figure(figsize=(5, 2), dpi=300, constrained_layout=True)
printplot = paintfig.add_subplot(111)
printplot_overlay = printplot.twinx()
FigureCanvas(paintfig)
def paint_override(self, ds, coff, coffgrad, filename):
overlay = self.plot.twinx()
textfield = QtWidgets.QLabel()
pop_dial(printplot, printplot_overlay, ds, coff, coffgrad,
textfield, filename, None)
cache_file = BytesIO()
paintfig.savefig(cache_file)
cache_file.seek(0)
image = QtGui.QImage.fromData(cache_file.read())
return image
def clip_spect_img(ds, coff, coffgrad, filename):
image = paint_zcegraph(ds, coff, coffgrad, filename)
QtWidgets.QApplication.clipboard().clear()
[QtWidgets.QApplication.clipboard().setImage(image, i) for i in range(2)]
pop_dial(self.plot, overlay, ds, coff, coffgrad, textfield, filename, None)
def print_graph(ds, coff, coffgrad, filename):
......@@ -132,9 +118,10 @@ def print_graph(ds, coff, coffgrad, filename):
printer = printPreview.printer()
printer.setPageSize(printer.A5)
printer.setDuplex(printer.DuplexNone)
image = paint_zcegraph(ds, coff, coffgrad, filename)
printPreview.paintRequested.connect(lambda:
printimage(printer, image))
imggen = imgt.ImagePainter("msspec", printer)
imggen.popfig = lambda: paint_override(imggen, ds, coff, coffgrad, filename)
image = imggen.paint()
printPreview.paintRequested.connect(lambda: printimage(printer, image))
printPreview.exec()
......@@ -142,7 +129,10 @@ def key_pressed(event, ds, coff, coffgrad, filename):
print("trigged")
if event.key() == QtCore.Qt.Key_C:
if event.modifiers().__int__() == QtCore.Qt.ControlModifier:
clip_spect_img(ds, coff, coffgrad, filename)
painter = imgt.ImagePainter("zcespec")
painter.popfig = lambda: paint_override(
painter, ds, coff, coffgrad, filename)
painter.clip()
def dialog(parent, augCanvas, update_signal):
......
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