Skip to content
GitLab
Menu
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
85160f63
Commit
85160f63
authored
Oct 04, 2019
by
3Yan
Browse files
Config now supports floats in copy/print image sizes
parent
fa82b41d
Changes
2
Hide whitespace changes
Inline
Side-by-side
prasopes/config.py
View file @
85160f63
...
...
@@ -45,12 +45,13 @@ def pathlineconf(label, value, config):
return
layout
def
pos
int
varconf
(
label
,
value
,
config
):
def
posvarconf
(
label
,
value
,
config
,
num
=
"int"
):
"""adds generic positive integer config line"""
textfield
=
QtWidgets
.
QLineEdit
(
str
(
config
.
value
(
value
)))
textfield
.
editingFinished
.
connect
(
lambda
:
config
.
setValue
(
value
,
textfield
.
text
()))
validator
=
QtGui
.
QIntValidator
()
validator
=
QtGui
.
QIntValidator
()
if
num
==
"int"
\
else
QtGui
.
QDoubleValidator
()
validator
.
setBottom
(
0
)
textfield
.
setValidator
(
validator
)
layout
=
QtWidgets
.
QHBoxLayout
()
...
...
@@ -80,25 +81,25 @@ def dial(parent):
printtab
=
QtWidgets
.
QWidget
()
printlayout
=
QtWidgets
.
QVBoxLayout
(
printtab
)
printlayout
.
addLayout
(
pos
int
varconf
(
"Figure width (inch)"
,
"print/xinch"
,
config
))
printlayout
.
addLayout
(
pos
int
varconf
(
"Figure height (inch)"
,
"print/yinch"
,
config
))
printlayout
.
addLayout
(
pos
int
varconf
(
printlayout
.
addLayout
(
posvarconf
(
"Figure width (inch)"
,
"print/xinch"
,
config
,
"nonint"
))
printlayout
.
addLayout
(
posvarconf
(
"Figure height (inch)"
,
"print/yinch"
,
config
,
"nonint"
))
printlayout
.
addLayout
(
posvarconf
(
"Figure dpi"
,
"print/dpi"
,
config
))
printlayout
.
addLayout
(
pos
int
varconf
(
printlayout
.
addLayout
(
posvarconf
(
"Figure x axis major ticks count"
,
"print/xtics"
,
config
))
tabs
.
addTab
(
printtab
,
"Printing"
)
imggentab
=
QtWidgets
.
QWidget
()
imggenlayout
=
QtWidgets
.
QVBoxLayout
(
imggentab
)
imggenlayout
.
addLayout
(
pos
int
varconf
(
"Figure width (inch)"
,
"imggen/xinch"
,
config
))
imggenlayout
.
addLayout
(
pos
int
varconf
(
"Figure height (inch)"
,
"imggen/yinch"
,
config
))
imggenlayout
.
addLayout
(
pos
int
varconf
(
imggenlayout
.
addLayout
(
posvarconf
(
"Figure width (inch)"
,
"imggen/xinch"
,
config
,
"nonint"
))
imggenlayout
.
addLayout
(
posvarconf
(
"Figure height (inch)"
,
"imggen/yinch"
,
config
,
"nonint"
))
imggenlayout
.
addLayout
(
posvarconf
(
"Figure dpi"
,
"imggen/dpi"
,
config
))
imggenlayout
.
addLayout
(
pos
int
varconf
(
imggenlayout
.
addLayout
(
posvarconf
(
"Figure x axis major ticks count"
,
"imggen/xtics"
,
config
))
tabs
.
addTab
(
imggentab
,
"Image clip/export"
)
...
...
prasopes/imagetools.py
View file @
85160f63
...
...
@@ -13,12 +13,12 @@ import prasopes.config as cf
def
paint_image
(
mass_spec
,
spect
,
fn
=
None
,
painttarget
=
None
):
"""generates QImage from mass spectrum"""
if
isinstance
(
painttarget
,
type
(
QtPrintSupport
.
QPrinter
())):
xinch
,
yinch
,
dpi
,
xtics
=
[
cf
.
settings
().
value
(
"print/{}"
.
format
(
i
),
type
=
int
)
for
i
in
(
"xinch"
,
"yinch"
,
"dpi"
,
"xtics"
)]
else
:
xinch
,
yinch
,
dpi
,
xtics
=
[
cf
.
settings
().
value
(
"imggen/{}"
.
format
(
i
)
,
type
=
int
)
for
i
in
(
"xinch"
,
"yinch"
,
"dpi"
,
"xtics"
)]
configtype
=
"print/{}"
if
isinstance
(
painttarget
,
type
(
QtPrintSupport
.
QPrinter
()))
else
"imggen/{}"
xinch
,
yinch
=
[
float
(
cf
.
settings
().
value
(
configtype
.
format
(
i
)).
replace
(
","
,
"."
))
for
i
in
(
"xinch"
,
"yinch"
)]
dpi
,
xtics
=
[
int
(
cf
.
settings
().
value
(
configtype
.
format
(
i
)
))
for
i
in
(
"dpi"
,
"xtics"
)]
paintfig
=
Figure
(
figsize
=
(
xinch
,
yinch
),
dpi
=
dpi
,
constrained_layout
=
True
)
canvas
=
FigureCanvas
(
paintfig
)
printplot
=
paintfig
.
add_subplot
(
111
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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