Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
MDANSE
Commits
ff16cd66
Commit
ff16cd66
authored
Jan 24, 2019
by
Remi Perenon
Browse files
Adding control of new units to check consistancy
parent
2691968b
Pipeline
#4764
passed with stages
in 9 minutes and 50 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Src/GUI/Plugins/PlotterSettings.py
View file @
ff16cd66
...
...
@@ -15,8 +15,20 @@
import
matplotlib
import
wx
from
MDANSE.Core.Error
import
Error
from
MDANSE.Externals.magnitude
import
magnitude
class
ImageSettingsDialog
(
wx
.
Dialog
):
class
UnitsSettingsError
(
Error
):
pass
class
UnitsSettingsDialog
():
def
checkUnits
(
self
,
oldUnit
,
newUnit
):
try
:
magnitude
.
mg
(
1.
,
oldUnit
,
newUnit
).
toval
()
except
magnitude
.
MagnitudeError
:
raise
UnitsSettingsError
(
"the axis unit (%s) is inconsistent with the current unit (%s) "
%
(
newUnit
,
oldUnit
))
class
ImageSettingsDialog
(
wx
.
Dialog
,
UnitsSettingsDialog
):
def
__init__
(
self
,
parent
=
None
):
wx
.
Dialog
.
__init__
(
self
,
parent
,
wx
.
ID_ANY
,
title
=
"Image Settings"
,
style
=
wx
.
DEFAULT_DIALOG_STYLE
|
wx
.
RESIZE_BORDER
|
wx
.
MINIMIZE_BOX
|
wx
.
MAXIMIZE_BOX
)
...
...
@@ -149,7 +161,9 @@ class ImageSettingsDialog(wx.Dialog):
self
.
normType
.
SetValue
(
self
.
parent
.
normType
)
def
set_settings
(
self
,
event
=
None
):
self
.
checkUnits
(
self
.
parent
.
Xunit
,
self
.
Xunit
.
GetValue
())
self
.
checkUnits
(
self
.
parent
.
Yunit
,
self
.
Yunit
.
GetValue
())
self
.
parent
.
figure
.
gca
().
set_title
(
self
.
title
.
GetValue
())
self
.
parent
.
Xlabel
=
self
.
Xlabel
.
GetValue
()
self
.
parent
.
Ylabel
=
self
.
Ylabel
.
GetValue
()
...
...
@@ -305,6 +319,7 @@ class GeneralSettingsDialog(wx.Dialog):
self
.
grid_color_picker
.
SetColour
(
wx
.
Colour
(
int
(
self
.
parent
.
gridColor
[
0
]
*
255
),
int
(
self
.
parent
.
gridColor
[
1
]
*
255
),
int
(
self
.
parent
.
gridColor
[
2
]
*
255
)))
def
set_settings
(
self
,
event
=
None
):
self
.
parent
.
figure
.
gca
().
set_title
(
self
.
title
.
GetValue
())
self
.
parent
.
Xlabel
=
self
.
Xlabel
.
GetValue
()
self
.
parent
.
Ylabel
=
self
.
Ylabel
.
GetValue
()
...
...
@@ -353,7 +368,7 @@ class GeneralSettingsDialog(wx.Dialog):
self
.
MakeModal
(
False
)
self
.
Destroy
()
class
AxesSettingsDialog
(
wx
.
Dialog
):
class
AxesSettingsDialog
(
wx
.
Dialog
,
UnitsSettingsDialog
):
def
__init__
(
self
,
parent
=
None
):
...
...
@@ -467,6 +482,10 @@ class AxesSettingsDialog(wx.Dialog):
self
.
Yscale
.
SetValue
(
self
.
parent
.
Yscale
)
def
set_settings
(
self
,
event
=
None
):
# CheckUnits. checkUnits method will raise exception if needed
self
.
checkUnits
(
self
.
parent
.
Xunit
,
self
.
Xunit
.
GetValue
())
self
.
checkUnits
(
self
.
parent
.
Yunit
,
self
.
Yunit
.
GetValue
())
self
.
parent
.
Xunit
=
self
.
Xunit
.
GetValue
()
self
.
parent
.
Yunit
=
self
.
Yunit
.
GetValue
()
...
...
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