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
0ae79e26
Commit
0ae79e26
authored
Jul 23, 2015
by
eric pellegrini
Browse files
Define separate applications for plotter, ud editor, periodic table
Relocated several packages
parent
fec74957
Changes
107
Expand all
Hide whitespace changes
Inline
Side-by-side
MDANSE/Framework/Handlers/ConsoleHandler.py
0 → 100644
View file @
0ae79e26
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
#This library is free software; you can redistribute it and/or
#modify it under the terms of the GNU Lesser General Public
#License as published by the Free Software Foundation; either
#version 2.1 of the License, or (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Apr 14, 2015
:author: Eric C. Pellegrini
'''
import
logging
import
wx
from
MDANSE.Framework.Handlers.IHandler
import
IHandler
from
MDANSE.Logging.Formatters
import
Formatter
class
ConsoleHandler
(
IHandler
,
logging
.
Handler
):
"""Sets up a GUI handler for the MDANSE logger.
Emits the logging message to the MDANSE GUI console.
@note: inherits from logging.Handler class that sets a generic handler.
"""
type
=
"console"
COLORS
=
{
'DEBUG'
:
wx
.
GREEN
,
'INFO'
:
wx
.
BLACK
,
'WARNING'
:
wx
.
BLUE
,
'ERROR'
:
wx
.
RED
,
'CRITICAL'
:
wx
.
RED
,
'FATAL'
:
wx
.
RED
}
def
__init__
(
self
,
window
):
'''
The constructor.
@param console: the parent widget for the textctrl.
@type console: wx widget
'''
logging
.
Handler
.
__init__
(
self
)
self
.
setFormatter
(
Formatter
())
self
.
_window
=
window
# Creates a wx text attribute.
self
.
style
=
wx
.
TextAttr
()
# Set its font to a non proporiotnal font.
self
.
style
.
SetFont
(
wx
.
Font
(
10
,
wx
.
FONTFAMILY_MODERN
,
wx
.
NORMAL
,
wx
.
NORMAL
))
def
emit
(
self
,
record
):
"""
Send the log message to a wx.TextCtrl widget.
@param record: the log message.
@type record: logging.LogRecord
"""
self
.
style
.
SetTextColour
(
ConsoleHandler
.
COLORS
.
get
(
record
.
levelname
,
wx
.
BLACK
))
# Set the the created text attribute as the default style for the text ctrl.
self
.
_window
.
SetDefaultStyle
(
self
.
style
)
# Append the log message to the text ctrl.
self
.
_window
.
AppendText
(
self
.
format
(
record
))
self
.
_window
.
AppendText
(
"
\n
"
)
MDANSE/Framework/Handlers/DialogHandler.py
0 → 100644
View file @
0ae79e26
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
#This library is free software; you can redistribute it and/or
#modify it under the terms of the GNU Lesser General Public
#License as published by the Free Software Foundation; either
#version 2.1 of the License, or (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Apr 14, 2015
:author: Eric C. Pellegrini
'''
import
logging
import
wx
from
MDANSE.Framework.Handlers.IHandler
import
IHandler
class
DialogHandler
(
IHandler
,
logging
.
Handler
):
type
=
"dialog"
ICONS
=
{
"DEBUG"
:
wx
.
ICON_INFORMATION
,
"CRITICAL"
:
wx
.
ICON_ERROR
,
"ERROR"
:
wx
.
ICON_ERROR
,
"INFO"
:
wx
.
ICON_INFORMATION
,
"WARNING"
:
wx
.
ICON_WARNING
,
}
def
emit
(
self
,
record
):
icon
=
DialogHandler
.
ICONS
[
record
.
levelname
]
d
=
wx
.
MessageDialog
(
None
,
message
=
self
.
format
(
record
),
style
=
wx
.
OK
|
wx
.
STAY_ON_TOP
|
icon
)
d
.
ShowModal
()
\ No newline at end of file
MDANSE/Framework/Plugins/AnimationPlugin.py
0 → 100644
View file @
0ae79e26
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
#This library is free software; you can redistribute it and/or
#modify it under the terms of the GNU Lesser General Public
#License as published by the Free Software Foundation; either
#version 2.1 of the License, or (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Apr 14, 2015
:author: Eric C. Pellegrini
'''
import
wx
import
wx.aui
as
wxaui
from
MDANSE.Externals.pubsub
import
pub
as
Publisher
from
MDANSE.GUI.Icons
import
ICONS
from
MDANSE.Framework.Plugins.ComponentPlugin
import
ComponentPlugin
class
AnimationPlugin
(
ComponentPlugin
):
type
=
"animation"
label
=
"Animation"
ancestor
=
"molecular_viewer"
def
__init__
(
self
,
parent
,
*
args
,
**
kwargs
):
ComponentPlugin
.
__init__
(
self
,
parent
,
size
=
(
-
1
,
50
),
*
args
,
**
kwargs
)
def
build_panel
(
self
):
panel
=
wx
.
Panel
(
self
,
wx
.
ID_ANY
,
size
=
self
.
GetSize
())
controlSizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
firstButton
=
wx
.
BitmapButton
(
panel
,
wx
.
ID_ANY
,
ICONS
[
"first"
,
32
,
32
])
self
.
playPause
=
wx
.
BitmapButton
(
panel
,
wx
.
ID_ANY
,
ICONS
[
"play"
,
32
,
32
])
lastButton
=
wx
.
BitmapButton
(
panel
,
wx
.
ID_ANY
,
ICONS
[
"last"
,
32
,
32
])
self
.
frameSlider
=
wx
.
Slider
(
panel
,
id
=
wx
.
ID_ANY
,
value
=
0
,
minValue
=
0
,
maxValue
=
1
,
style
=
wx
.
SL_HORIZONTAL
)
self
.
frameEntry
=
wx
.
TextCtrl
(
panel
,
id
=
wx
.
ID_ANY
,
value
=
"0"
,
size
=
(
60
,
20
),
style
=
wx
.
SL_HORIZONTAL
|
wx
.
TE_PROCESS_ENTER
)
speedBitmap
=
wx
.
StaticBitmap
(
panel
,
-
1
,
ICONS
[
"clock"
,
42
,
42
])
self
.
speedSlider
=
wx
.
Slider
(
panel
,
id
=
wx
.
ID_ANY
,
value
=
0
,
minValue
=
0
,
maxValue
=
1
,
style
=
wx
.
SL_HORIZONTAL
)
self
.
speedSlider
.
SetRange
(
0
,
self
.
_parent
.
max_laps
)
speed
=
self
.
_parent
.
max_laps
-
self
.
_parent
.
timer_interval
self
.
speedSlider
.
SetValue
(
speed
)
self
.
speedEntry
=
wx
.
TextCtrl
(
panel
,
id
=
wx
.
ID_ANY
,
value
=
str
(
speed
),
size
=
(
60
,
20
),
style
=
wx
.
SL_HORIZONTAL
|
wx
.
TE_PROCESS_ENTER
)
controlSizer
.
Add
(
firstButton
,
0
,
wx
.
LEFT
|
wx
.
ALIGN_CENTER_VERTICAL
,
5
)
controlSizer
.
Add
(
self
.
playPause
,
0
,
wx
.
ALIGN_CENTER_VERTICAL
)
controlSizer
.
Add
(
lastButton
,
0
,
wx
.
ALIGN_CENTER_VERTICAL
)
controlSizer
.
Add
((
5
,
-
1
),
0
,
wx
.
ALIGN_RIGHT
)
controlSizer
.
Add
(
self
.
frameSlider
,
3
,
wx
.
ALIGN_CENTER_VERTICAL
)
controlSizer
.
Add
(
self
.
frameEntry
,
0
,
wx
.
ALIGN_CENTER_VERTICAL
)
controlSizer
.
Add
((
5
,
-
1
),
0
,
wx
.
ALIGN_RIGHT
)
controlSizer
.
Add
(
speedBitmap
,
0
,
wx
.
ALIGN_CENTER_VERTICAL
)
controlSizer
.
Add
((
5
,
-
1
),
0
,
wx
.
ALIGN_RIGHT
)
controlSizer
.
Add
(
self
.
speedSlider
,
1
,
wx
.
ALL
|
wx
.
ALIGN_CENTER_VERTICAL
)
controlSizer
.
Add
(
self
.
speedEntry
,
0
,
wx
.
ALL
|
wx
.
ALIGN_CENTER_VERTICAL
,
5
)
panel
.
SetSizer
(
controlSizer
)
controlSizer
.
Fit
(
panel
)
panel
.
Layout
()
self
.
_mgr
.
AddPane
(
panel
,
wxaui
.
AuiPaneInfo
().
Center
().
Dock
().
CaptionVisible
(
False
).
CloseButton
(
False
).
MinSize
(
self
.
GetSize
()))
self
.
_mgr
.
Update
()
self
.
Bind
(
wx
.
EVT_SCROLL
,
self
.
on_frame_sliding
,
self
.
frameSlider
)
self
.
Bind
(
wx
.
EVT_TEXT_ENTER
,
self
.
on_set_frame
,
self
.
frameEntry
)
self
.
Bind
(
wx
.
EVT_SLIDER
,
self
.
on_change_frame_rate
,
self
.
speedSlider
)
self
.
Bind
(
wx
.
EVT_TEXT_ENTER
,
self
.
on_set_speed
,
self
.
speedEntry
)
self
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
on_start_stop_animation
,
self
.
playPause
)
self
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
on_goto_first_frame
,
firstButton
)
self
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
on_goto_last_frame
,
lastButton
)
Publisher
.
subscribe
(
self
.
on_update_animation_icon
,
(
'msg_animate_trajectory'
))
Publisher
.
subscribe
(
self
.
on_set_up_frame_slider
,
(
'msg_load_trajectory'
))
Publisher
.
subscribe
(
self
.
on_timer
,
(
'msg_timer'
))
def
plug
(
self
):
self
.
_parent
.
_mgr
.
GetPane
(
self
).
LeftDockable
(
False
).
RightDockable
(
False
).
Dock
().
Bottom
().
CloseButton
(
True
)
self
.
_parent
.
_mgr
.
Update
()
def
on_change_frame_rate
(
self
,
event
=
None
):
laps
=
self
.
speedSlider
.
GetValue
()
self
.
_parent
.
change_frame_rate
(
laps
)
self
.
speedEntry
.
SetValue
(
str
(
self
.
speedSlider
.
GetValue
()))
def
on_frame_sliding
(
self
,
event
=
None
):
frame
=
self
.
frameSlider
.
GetValue
()
self
.
_parent
.
set_frame
(
frame
)
frame
=
self
.
_parent
.
current_frame
self
.
frameEntry
.
SetValue
(
str
(
frame
))
self
.
frameSlider
.
SetValue
(
frame
)
def
on_goto_first_frame
(
self
,
event
=
None
):
self
.
_parent
.
goto_first_frame
()
self
.
frameEntry
.
SetValue
(
str
(
0
))
self
.
frameSlider
.
SetValue
(
0
)
def
on_goto_last_frame
(
self
,
event
=
None
):
self
.
_parent
.
goto_last_frame
()
self
.
frameEntry
.
SetValue
(
str
(
self
.
_parent
.
n_frames
-
1
))
self
.
frameSlider
.
SetValue
(
self
.
_parent
.
n_frames
-
1
)
def
on_set_speed
(
self
,
event
=
None
):
self
.
speedSlider
.
SetValue
(
int
(
self
.
speedEntry
.
GetValue
()))
self
.
_parent
.
change_frame_rate
()
def
on_timer
(
self
,
plugin
):
if
not
plugin
.
is_parent
(
self
):
return
frame
=
plugin
.
current_frame
self
.
frameEntry
.
SetValue
(
str
(
frame
))
self
.
frameSlider
.
SetValue
(
int
(
frame
))
def
on_set_frame
(
self
,
event
=
None
):
frame
=
int
(
self
.
frameEntry
.
GetValue
())
self
.
_parent
.
set_configuration
(
frame
)
self
.
frameSlider
.
SetValue
(
frame
)
def
on_start_stop_animation
(
self
,
event
=
None
):
self
.
_parent
.
start_stop_animation
()
def
on_update_animation_icon
(
self
,
plugin
):
if
not
plugin
.
is_parent
(
self
):
return
if
plugin
.
animation_loop
:
self
.
playPause
.
SetBitmapLabel
(
ICONS
[
"pause"
,
32
,
32
])
else
:
self
.
playPause
.
SetBitmapLabel
(
ICONS
[
"play"
,
32
,
32
])
def
on_set_up_frame_slider
(
self
,
plugin
):
if
not
plugin
.
is_parent
(
self
):
return
self
.
frameSlider
.
SetRange
(
0
,
self
.
_parent
.
n_frames
-
1
)
\ No newline at end of file
MDANSE/Framework/Plugins/ComponentPlugin.py
0 → 100644
View file @
0ae79e26
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
#This library is free software; you can redistribute it and/or
#modify it under the terms of the GNU Lesser General Public
#License as published by the Free Software Foundation; either
#version 2.1 of the License, or (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Mar 30, 2015
:author: Gael Goret, Eric C. Pellegrini
'''
from
MDANSE.Framework.Plugins.IPlugin
import
IPlugin
class
ComponentPlugin
(
IPlugin
):
type
=
None
@
property
def
datakey
(
self
):
return
self
.
parent
.
datakey
@
property
def
dataproxy
(
self
):
return
self
.
parent
.
dataproxy
@
property
def
dataplugin
(
self
):
return
self
.
parent
.
dataplugin
MDANSE/Framework/Plugins/DataInfoPlugin.py
0 → 100644
View file @
0ae79e26
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
#This library is free software; you can redistribute it and/or
#modify it under the terms of the GNU Lesser General Public
#License as published by the Free Software Foundation; either
#version 2.1 of the License, or (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Apr 14, 2015
:author: Eric C. Pellegrini
'''
import
wx
import
wx.aui
as
aui
from
MDANSE.Framework.Plugins.ComponentPlugin
import
ComponentPlugin
class
DataInfoPlugin
(
ComponentPlugin
):
type
=
"data_info"
label
=
"Data info"
ancestor
=
"data"
def
__init__
(
self
,
parent
,
*
args
,
**
kwargs
):
ComponentPlugin
.
__init__
(
self
,
parent
,
size
=
(
-
1
,
50
),
*
args
,
**
kwargs
)
def
build_panel
(
self
):
panel
=
wx
.
Panel
(
self
,
wx
.
ID_ANY
,
size
=
self
.
GetSize
())
sizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
_info
=
wx
.
TextCtrl
(
panel
,
wx
.
ID_ANY
,
style
=
wx
.
TE_MULTILINE
|
wx
.
TE_READONLY
)
sizer
.
Add
(
self
.
_info
,
1
,
wx
.
ALL
|
wx
.
EXPAND
,
5
)
panel
.
SetSizer
(
sizer
)
sizer
.
Fit
(
panel
)
panel
.
Layout
()
self
.
_mgr
.
AddPane
(
panel
,
aui
.
AuiPaneInfo
().
Center
().
Dock
().
CaptionVisible
(
False
).
CloseButton
(
False
).
MinSize
(
self
.
GetSize
()))
self
.
_mgr
.
Update
()
def
on_close
(
self
,
event
):
self
.
parent
.
mgr
.
ClosePane
(
self
.
parent
.
mgr
.
GetPane
(
self
))
def
plug
(
self
):
self
.
_info
.
SetValue
(
self
.
dataproxy
.
info
())
self
.
_parent
.
_mgr
.
GetPane
(
self
).
Float
().
CloseButton
(
True
).
BestSize
((
600
,
600
))
self
.
_parent
.
_mgr
.
Update
()
MDANSE/Framework/Plugins/DataPlugin.py
0 → 100644
View file @
0ae79e26
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
#This library is free software; you can redistribute it and/or
#modify it under the terms of the GNU Lesser General Public
#License as published by the Free Software Foundation; either
#version 2.1 of the License, or (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Mar 30, 2015
:author: Gael Goret, Eric C. Pellegrini
'''
import
wx
import
wx.aui
as
wxaui
from
MDANSE
import
REGISTRY
from
MDANSE.Externals.pubsub
import
pub
from
MDANSE.GUI
import
DATA_CONTROLLER
from
MDANSE.Framework.Plugins.IPlugin
import
IPlugin
,
plugin_parent
def
get_data_plugin
(
window
):
if
isinstance
(
window
,
DataPlugin
):
return
window
else
:
try
:
return
get_data_plugin
(
window
.
Parent
)
except
AttributeError
:
return
None
class
DataPlugin
(
IPlugin
):
type
=
'data'
ancestor
=
None
def
__init__
(
self
,
parent
,
datakey
,
**
kwargs
):
IPlugin
.
__init__
(
self
,
parent
,
wx
.
ID_ANY
,
**
kwargs
)
self
.
_datakey
=
datakey
self
.
_dataProxy
=
DATA_CONTROLLER
[
self
.
_datakey
]
self
.
_mgr
.
Bind
(
wx
.
EVT_CHILD_FOCUS
,
self
.
on_changing_pane
)
self
.
_currentWindow
=
self
def
build_panel
(
self
):
pass
def
plug
(
self
,
standalone
=
False
):
pass
@
property
def
currentWindow
(
self
):
return
self
.
_currentWindow
@
property
def
datakey
(
self
):
return
self
.
_datakey
@
datakey
.
setter
def
datakey
(
self
,
key
):
self
.
_datakey
=
key
@
property
def
dataproxy
(
self
):
return
self
.
_dataProxy
@
property
def
dataplugin
(
self
):
return
self
def
drop
(
self
,
pluginName
):
# If no plugin match the name of the dropped plugin, do nothing.
plugin
=
REGISTRY
[
"plugin"
].
get
(
pluginName
,
None
)
if
plugin
is
None
:
return
if
not
issubclass
(
self
.
__class__
,
REGISTRY
[
'plugin'
][
plugin
.
ancestor
]):
return
plugin
=
plugin
(
self
)
self
.
_mgr
.
AddPane
(
plugin
,
wxaui
.
AuiPaneInfo
().
Caption
(
getattr
(
plugin
,
"label"
,
pluginName
)))
self
.
_mgr
.
Update
()
plugin
.
plug
()
plugin
.
SetFocus
()
self
.
_currentWindow
=
plugin
def
on_changing_pane
(
self
,
event
):
window
=
plugin_parent
(
event
.
GetWindow
())