Commit fdc3a84e authored by Yan's avatar Yan
Browse files

Implemented paintFig into zcetools

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