Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jan Zelenka
prasopes
Commits
25b3c1ef
Commit
25b3c1ef
authored
Jul 15, 2019
by
Yan
Browse files
Printing support Pt2/2
* Printing is not perfect, but it is somehow working
parent
91ce38cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
prasopes/__main__.py
View file @
25b3c1ef
...
...
@@ -12,6 +12,7 @@ from rawprasslib import load_raw
from
rawprasslib
import
rawprasslib
from
prasopes.predictmz
import
predict
as
getmzpattern
from
io
import
BytesIO
import
numpy
as
np
import
prasopes.graphtools
as
gt
import
prasopes.filetools
as
ft
import
prasopes.zcetools
as
zce
...
...
@@ -59,25 +60,32 @@ def load_file(parent, chrom_plot, spc, d_set, ms_s, fn, chrom_s,
update
.
signal
.
emit
()
def
print_graph
(
mass_spec
,
chrom_spec
,
spect
,
fn
):
def
print_graph
(
data_set
,
mass_spec
,
chrom_spec
,
spect
,
fn
):
def
printimage
(
printdevice
,
img
):
painter
=
QtGui
.
QPainter
(
printdevice
)
painter
.
drawImage
(
QtCore
.
QPoint
(
0
,
0
),
img
)
painter
.
end
()
printfig
=
Figure
(
figsize
=
(
10
,
4
),
dpi
=
300
)
printplot
=
printfig
.
add_subplot
(
111
)
if
cf
.
settings
().
value
(
"view/oddeven"
,
type
=
bool
):
print
(
"TODO"
)
else
:
gt
.
pop_plot
(
printplot
,
mass_spec
)
printplot
.
set_xlim
(
spect
.
get_xlim
())
printplot
.
set_ylim
(
spect
.
get_ylim
())
ydata
=
[
line
.
get_data
()[
1
]
for
line
in
spect
.
lines
]
for
yline
in
ydata
:
spect
=
mass_spec
.
copy
()
spect
[
'y'
]
=
yline
gt
.
pop_plot
(
printplot
,
spect
)
cache_file
=
BytesIO
()
printfig
.
savefig
(
cache_file
)
cache_file
.
seek
(
0
)
image
=
QtGui
.
QImage
.
fromData
(
cache_file
.
read
())
#TODO: substitute the QPrintPreviewDialog with QPrintPreviewWidget
printPreview
=
QtPrintSupport
.
QPrintPreviewDialog
()
printer
=
printPreview
.
printer
()
def
ubercommand
():
cache_file
=
BytesIO
()
printfig
.
savefig
(
cache_file
)
cache_file
.
seek
(
0
)
image
=
QtGui
.
QImage
.
fromData
(
cache_file
.
read
())
printer
.
setResolution
(
600
)
painter
=
QtGui
.
QPainter
(
printPreview
.
printer
())
painter
.
drawImage
(
QtCore
.
QPoint
(
0
,
0
),
image
)
painter
.
end
()
printPreview
.
paintRequested
.
connect
(
lambda
:
ubercommand
())
printer
.
setResolution
(
600
)
printer
.
setPageSize
(
printer
.
A5
)
printer
.
setDuplex
(
printer
.
DuplexNone
)
printPreview
.
paintRequested
.
connect
(
lambda
:
printimage
(
printer
,
image
))
printPreview
.
exec
()
...
...
@@ -197,7 +205,8 @@ def main():
printact
=
QtWidgets
.
QAction
(
QtGui
.
QIcon
.
fromTheme
(
"document-print"
),
"&Print"
,
None
)
printact
.
setShortcut
(
QtCore
.
Qt
.
CTRL
+
QtCore
.
Qt
.
Key_P
)
printact
.
triggered
.
connect
(
lambda
:
print_graph
(
ms
,
chrom
,
spectrum
,
filename
))
printact
.
triggered
.
connect
(
lambda
:
print_graph
(
ds
,
ms
,
chrom
,
spectrum
,
filename
))
settingsact
=
QtWidgets
.
QAction
(
QtGui
.
QIcon
.
fromTheme
(
"preferences-system"
),
"&Settings..."
,
None
)
settingsact
.
triggered
.
connect
(
lambda
:
cf
.
dial
(
main_window
))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment