Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
MDANSE
Commits
3f553546
Commit
3f553546
authored
Sep 04, 2015
by
eric pellegrini
Browse files
Modified deeply the UD based widgets such that all of the can be
alunched as standalone widget of used as a plugin
parent
e9aa2ee7
Changes
6
Hide whitespace changes
Inline
Side-by-side
MDANSE/Framework/Widgets/AtomSelectionWidget.py
View file @
3f553546
...
...
@@ -34,13 +34,14 @@ import collections
import
os
import
wx
import
wx.aui
as
wxaui
from
MDANSE
import
LOGGER
,
REGISTRY
from
MDANSE.Externals.pubsub
import
pub
from
MDANSE.Framework.AtomSelectionParser
import
AtomSelectionParser
,
AtomSelectionParserError
from
MDANSE.MolecularDynamics.Trajectory
import
sorted_atoms
from
MDANSE.Framework.Widgets.UserDefinitionWidget
import
U
serDefinitionsDialog
,
UserDefinitionWidget
from
MDANSE.Framework.Widgets.UserDefinitionWidget
import
U
DDialog
,
UDPlugin
,
UserDefinitionWidget
from
MDANSE.Framework.Plugins.DataPlugin
import
get_data_plugin
class
Query
(
object
):
...
...
@@ -148,12 +149,16 @@ class Query(object):
def
set_parser
(
self
,
parser
):
self
.
_parser
=
parser
class
AtomSelection
Dialog
(
UserDefinitionsDialog
):
class
AtomSelection
Plugin
(
UDPlugin
):
type
=
'atom_selection'
def
__init__
(
self
,
parent
,
trajectory
,
*
args
,
**
kwargs
):
label
=
"Atom selection"
ancestor
=
[
"molecular_viewer"
]
def
__init__
(
self
,
parent
,
*
args
,
**
kwargs
):
self
.
_query
=
Query
()
...
...
@@ -161,19 +166,11 @@ class AtomSelectionDialog(UserDefinitionsDialog):
self
.
_selection
=
[]
self
.
_trajectory
=
trajectory
self
.
_query
.
set_parser
(
AtomSelectionParser
(
self
.
_trajectory
.
universe
))
pub
.
subscribe
(
self
.
on_select_atoms_from_viewer
,
(
'msg_select_atoms_from_viewer'
))
self
.
_atoms
=
sorted_atoms
(
self
.
_trajectory
.
universe
)
target
=
os
.
path
.
basename
(
self
.
_trajectory
.
filename
)
UDPlugin
.
__init__
(
self
,
parent
,
size
=
(
800
,
500
))
UserDefinitionsDialog
.
__init__
(
self
,
parent
,
target
,
wx
.
ID_ANY
,
title
=
"Atom selection dialog"
,
style
=
wx
.
DEFAULT_DIALOG_STYLE
|
wx
.
RESIZE_BORDER
|
wx
.
MINIMIZE_BOX
|
wx
.
MAXIMIZE_BOX
)
pub
.
subscribe
(
self
.
on_select_atoms_from_viewer
,
(
'msg_select_atoms_from_viewer'
))
def
build_dialog
(
self
):
def
build_panel
(
self
):
self
.
_mainPanel
=
wx
.
ScrolledWindow
(
self
,
wx
.
ID_ANY
,
size
=
self
.
GetSize
())
self
.
_mainPanel
.
SetScrollbars
(
20
,
20
,
50
,
50
)
...
...
@@ -250,9 +247,14 @@ class AtomSelectionDialog(UserDefinitionsDialog):
sizer
.
Add
(
self
.
_selectionSummary
,
1
,
wx
.
ALL
|
wx
.
EXPAND
,
5
)
self
.
_mainPanel
.
SetSizer
(
sizer
)
self
.
_mainSizer
.
Add
(
self
.
_mainPanel
,
1
,
wx
.
EXPAND
|
wx
.
ALL
,
5
)
self
.
_mainSizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
self
.
_mainSizer
.
Add
(
self
.
_mainPanel
,
1
,
wx
.
EXPAND
|
wx
.
ALL
,
5
)
self
.
SetSizer
(
self
.
_mainSizer
)
self
.
_mgr
.
AddPane
(
self
.
_mainPanel
,
wxaui
.
AuiPaneInfo
().
DestroyOnClose
().
Center
().
Dock
().
CaptionVisible
(
False
).
CloseButton
(
False
).
BestSize
(
self
.
GetSize
()))
self
.
_mgr
.
Update
()
self
.
Bind
(
wx
.
EVT_TREE_SEL_CHANGED
,
self
.
on_display_keyword_values
,
self
.
filterTree
)
self
.
Bind
(
wx
.
EVT_LISTBOX
,
self
.
on_insert_keyword_values
,
self
.
values
)
...
...
@@ -263,7 +265,25 @@ class AtomSelectionDialog(UserDefinitionsDialog):
self
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
on_add_operator
,
notLinker
)
self
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
on_clear
,
clearButton
)
def
plug
(
self
):
self
.
parent
.
mgr
.
GetPane
(
self
).
Float
().
Dockable
(
False
).
CloseButton
(
True
).
BestSize
((
600
,
600
))
self
.
parent
.
mgr
.
Update
()
self
.
set_trajectory
(
self
.
dataproxy
.
data
)
def
set_trajectory
(
self
,
trajectory
):
self
.
_trajectory
=
trajectory
self
.
_query
.
set_parser
(
AtomSelectionParser
(
self
.
_trajectory
.
universe
))
self
.
_atoms
=
sorted_atoms
(
self
.
_trajectory
.
universe
)
self
.
_target
=
os
.
path
.
basename
(
self
.
_trajectory
.
filename
)
def
display_selection_summary
(
self
):
self
.
_selectionSummary
.
Clear
()
...
...
@@ -317,10 +337,6 @@ class AtomSelectionDialog(UserDefinitionsDialog):
self
.
_selectionSummary
.
Clear
()
pub
.
sendMessage
(
'msg_clear_selection'
,
message
=
self
)
def
on_close
(
self
,
event
=
None
):
self
.
Destroy
()
def
on_display_keyword_values
(
self
,
event
=
None
):
...
...
@@ -378,25 +394,17 @@ class AtomSelectionDialog(UserDefinitionsDialog):
if
not
self
.
_selection
:
LOGGER
(
"The current selection is empty"
,
"error"
,
[
"dialog"
])
return
None
self
.
_ud
[
'indexes'
]
=
self
.
_selection
return
self
.
_ud
return
{
'indexes'
:
self
.
_selection
}
class
AtomSelectionWidget
(
UserDefinitionWidget
):
type
=
"atom_selection"
def
on_new_user_definition
(
self
,
event
):
dlg
=
AtomSelectionDialog
(
self
,
self
.
_trajectory
)
dlg
.
Show
()
def
get_widget_value
(
self
):
ud
=
self
.
_availableUDs
.
GetStringSelection
()
if
not
ud
:
return
'all'
else
:
...
...
@@ -406,11 +414,13 @@ if __name__ == "__main__":
from
MMTK.Trajectory
import
Trajectory
t
=
Trajectory
(
None
,
"../../../../../Data/Trajectories/MMTK/protein_in_periodic_universe.nc"
,
"r"
)
from
MDANSE
import
PLATFORM
t
=
Trajectory
(
None
,
os
.
path
.
join
(
PLATFORM
.
example_data_directory
(),
"Trajectories"
,
"MMTK"
,
"protein_in_periodic_universe.nc"
),
"r"
)
app
=
wx
.
App
(
False
)
p
=
AtomSelectionDialog
(
None
,
t
)
p
=
UDDialog
(
None
,
t
,
'atom_selection'
)
p
.
SetSize
((
800
,
800
))
...
...
MDANSE/Framework/Widgets/AtomTransmutationWidget.py
View file @
3f553546
...
...
@@ -35,18 +35,20 @@ import wx
from
MDANSE
import
ELEMENTS
,
LOGGER
from
MDANSE.Framework.Widgets.UserDefinitionWidget
import
UserDefinitionWidget
from
MDANSE.Framework.Widgets.AtomSelectionWidget
import
AtomSelection
Dialog
from
MDANSE.Framework.Widgets.AtomSelectionWidget
import
AtomSelection
Plugin
class
AtomTransmutation
Dialog
(
AtomSelection
Dialog
):
class
AtomTransmutation
Plugin
(
AtomSelection
Plugin
):
type
=
'atom_transmutation'
label
=
"Atom transmutation"
ancestor
=
[
"molecular_viewer"
]
def
build_dialog
(
self
):
AtomSelectionDialog
.
build_dialog
(
self
)
self
.
SetTitle
(
"Atom transmutation dialog"
)
AtomSelectionPlugin
.
build_dialog
(
self
)
self
.
_elements
=
wx
.
ComboBox
(
self
.
_mainPanel
,
wx
.
ID_ANY
,
value
=
"Transmutate to"
,
choices
=
ELEMENTS
.
elements
)
self
.
_selectionExpressionSizer
.
Add
(
self
.
_elements
,
pos
=
(
0
,
3
),
flag
=
wx
.
EXPAND
|
wx
.
ALIGN_CENTER_VERTICAL
)
...
...
@@ -67,39 +69,14 @@ class AtomTransmutationDialog(AtomSelectionDialog):
return
self
.
_ud
class
AtomTransmutationWidget
(
UserDefinitionWidget
):
type
=
"atom_transmutation"
def
on_new_user_definition
(
self
,
event
):
dlg
=
AtomTransmutationDialog
(
self
,
self
.
_trajectory
)
dlg
.
Show
()
def
get_widget_value
(
self
):
ud
=
self
.
_availableUDs
.
GetStringSelection
()
if
not
ud
:
return
None
else
:
return
str
(
ud
)
if
__name__
==
"__main__"
:
from
MMTK.Trajectory
import
Trajectory
t
=
Trajectory
(
None
,
"../../../../../Data/Trajectories/MMTK/protein_in_periodic_universe.nc"
,
"r"
)
app
=
wx
.
App
(
False
)
p
=
AtomTransmutationDialog
(
None
,
t
)
p
.
SetSize
((
800
,
800
))
p
.
ShowModal
()
p
.
Destroy
()
app
.
MainLoop
()
\ No newline at end of file
return
str
(
ud
)
\ No newline at end of file
MDANSE/Framework/Widgets/AtomsListWidget.py
View file @
3f553546
...
...
@@ -33,9 +33,10 @@ Created on Jun 30, 2015
import
os
import
wx
import
wx.aui
as
wxaui
from
MDANSE
import
LOGGER
from
MDANSE.Framework.Widgets.UserDefinitionWidget
import
U
serDefinitionsDialog
,
UserDefinitionWidget
from
MDANSE.Framework.Widgets.UserDefinitionWidget
import
U
DPlugin
,
UserDefinitionWidget
,
UDDialog
from
MDANSE.MolecularDynamics.Trajectory
import
find_atoms_in_molecule
,
get_chemical_objects_dict
class
AtomNameDropTarget
(
wx
.
TextDropTarget
):
...
...
@@ -68,56 +69,57 @@ class AtomNameDropTarget(wx.TextDropTarget):
self
.
_atoms
.
Append
([
data
])
class
AtomsList
Dialog
(
UserDefinitionsDialog
):
class
AtomsList
Plugin
(
UDPlugin
):
def
__init__
(
self
,
parent
,
trajectory
,
nAtoms
):
type
=
'atoms_list'
label
=
"Atoms list"
ancestor
=
[
"molecular_viewer"
]
def
__init__
(
self
,
parent
,
*
args
,
**
kwargs
):
self
.
_parent
=
parent
self
.
_trajectory
=
trajectory
self
.
_nAtoms
=
nAtoms
self
.
_nAtoms
=
1
self
.
_selectedAtoms
=
[]
self
.
_selection
=
[]
target
=
os
.
path
.
basename
(
self
.
_trajectory
.
filename
)
self
.
type
=
"%d_atoms_list"
%
self
.
_nAtoms
UserDefinitionsDialog
.
__init__
(
self
,
parent
,
target
,
wx
.
ID_ANY
,
title
=
"%d Atoms selection dialog"
%
nAtoms
,
style
=
wx
.
DEFAULT_DIALOG_STYLE
|
wx
.
RESIZE_BORDER
|
wx
.
MINIMIZE_BOX
|
wx
.
MAXIMIZE_BOX
)
UDPlugin
.
__init__
(
self
,
parent
,
size
=
(
800
,
500
))
self
.
SetSize
((
400
,
400
))
def
build_
dialog
(
self
):
def
build_
panel
(
self
):
p
anel
=
wx
.
ScrolledWindow
(
self
,
wx
.
ID_ANY
,
size
=
self
.
GetSize
())
p
anel
.
SetScrollbars
(
20
,
20
,
50
,
50
)
self
.
_mainP
anel
=
wx
.
ScrolledWindow
(
self
,
wx
.
ID_ANY
,
size
=
self
.
GetSize
())
self
.
_mainP
anel
.
SetScrollbars
(
20
,
20
,
50
,
50
)
sizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
self
.
_nAtomsSelectionSizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
label
=
wx
.
StaticText
(
self
.
_mainPanel
,
wx
.
ID_ANY
,
label
=
"Number of atoms"
)
self
.
_nAtomsSpinCtrl
=
wx
.
SpinCtrl
(
self
.
_mainPanel
,
wx
.
ID_ANY
,
style
=
wx
.
SP_ARROW_KEYS
|
wx
.
SP_WRAP
)
self
.
_nAtomsSpinCtrl
.
SetRange
(
1
,
100
)
self
.
_nAtomsSpinCtrl
.
SetValue
(
self
.
_nAtoms
)
self
.
_nAtomsSelectionSizer
.
Add
(
label
,
0
,
wx
.
ALL
|
wx
.
ALIGN_CENTRE_VERTICAL
,
5
)
self
.
_nAtomsSelectionSizer
.
Add
(
self
.
_nAtomsSpinCtrl
,
1
,
wx
.
ALL
|
wx
.
EXPAND
,
5
)
gbSizer
=
wx
.
GridBagSizer
(
5
,
5
)
label1
=
wx
.
StaticText
(
p
anel
,
wx
.
ID_ANY
,
label
=
"Molecules"
)
label2
=
wx
.
StaticText
(
p
anel
,
wx
.
ID_ANY
,
label
=
"Selected atoms"
)
label1
=
wx
.
StaticText
(
self
.
_mainP
anel
,
wx
.
ID_ANY
,
label
=
"Molecules"
)
label2
=
wx
.
StaticText
(
self
.
_mainP
anel
,
wx
.
ID_ANY
,
label
=
"Selected atoms"
)
gbSizer
.
Add
(
label1
,
(
0
,
0
),
flag
=
wx
.
EXPAND
)
gbSizer
.
Add
(
label2
,
(
0
,
1
),
flag
=
wx
.
EXPAND
)
self
.
_molecules
=
wx
.
TreeCtrl
(
panel
,
wx
.
ID_ANY
,
style
=
wx
.
TR_DEFAULT_STYLE
|
wx
.
LB_HSCROLL
|
wx
.
LB_NEEDED_SB
^
wx
.
TR_HIDE_ROOT
)
self
.
_molecularContents
=
get_chemical_objects_dict
(
self
.
_trajectory
.
universe
)
root
=
self
.
_molecules
.
AddRoot
(
''
)
for
mname
in
sorted
(
self
.
_molecularContents
.
keys
()):
molnode
=
self
.
_molecules
.
AppendItem
(
root
,
mname
)
atomsList
=
self
.
_molecularContents
[
mname
][
0
].
atomList
()
atomNames
=
sorted
(
set
([
at
.
name
for
at
in
atomsList
]))
for
aname
in
atomNames
:
self
.
_molecules
.
AppendItem
(
molnode
,
aname
)
self
.
_atoms
=
wx
.
ListCtrl
(
panel
,
wx
.
ID_ANY
)
self
.
_molecules
=
wx
.
TreeCtrl
(
self
.
_mainPanel
,
wx
.
ID_ANY
,
style
=
wx
.
TR_DEFAULT_STYLE
|
wx
.
LB_HSCROLL
|
wx
.
LB_NEEDED_SB
^
wx
.
TR_HIDE_ROOT
)
self
.
_atoms
=
wx
.
ListCtrl
(
self
.
_mainPanel
,
wx
.
ID_ANY
)
dt
=
AtomNameDropTarget
(
self
.
_molecules
,
self
.
_atoms
)
self
.
_atoms
.
SetDropTarget
(
dt
)
...
...
@@ -129,21 +131,71 @@ class AtomsListDialog(UserDefinitionsDialog):
gbSizer
.
AddGrowableCol
(
0
)
gbSizer
.
AddGrowableCol
(
1
)
setButton
=
wx
.
Button
(
p
anel
,
wx
.
ID_ANY
,
label
=
"Set"
)
self
.
_resultsTextCtrl
=
wx
.
TextCtrl
(
p
anel
,
wx
.
ID_ANY
,
style
=
wx
.
TE_READONLY
|
wx
.
TE_MULTILINE
)
setButton
=
wx
.
Button
(
self
.
_mainP
anel
,
wx
.
ID_ANY
,
label
=
"Set"
)
self
.
_resultsTextCtrl
=
wx
.
TextCtrl
(
self
.
_mainP
anel
,
wx
.
ID_ANY
,
style
=
wx
.
TE_READONLY
|
wx
.
TE_MULTILINE
)
sizer
.
Add
(
self
.
_nAtomsSelectionSizer
,
0
,
wx
.
EXPAND
|
wx
.
ALL
,
5
)
sizer
.
Add
(
gbSizer
,
1
,
wx
.
EXPAND
|
wx
.
ALL
,
5
)
sizer
.
Add
(
setButton
,
0
,
wx
.
EXPAND
|
wx
.
ALL
,
5
)
sizer
.
Add
(
self
.
_resultsTextCtrl
,
1
,
wx
.
EXPAND
|
wx
.
ALL
,
5
)
p
anel
.
SetSizer
(
sizer
)
self
.
_mainP
anel
.
SetSizer
(
sizer
)
self
.
_mainSizer
.
Add
(
panel
,
1
,
wx
.
EXPAND
|
wx
.
ALL
,
5
)
self
.
_mainSizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
self
.
_mainSizer
.
Add
(
self
.
_mainPanel
,
1
,
wx
.
EXPAND
|
wx
.
ALL
,
5
)
self
.
SetSizer
(
self
.
_mainSizer
)
self
.
_mgr
.
AddPane
(
self
.
_mainPanel
,
wxaui
.
AuiPaneInfo
().
DestroyOnClose
().
Center
().
Dock
().
CaptionVisible
(
False
).
CloseButton
(
False
).
BestSize
(
self
.
GetSize
()))
self
.
_mgr
.
Update
()
self
.
Bind
(
wx
.
EVT_SPINCTRL
,
self
.
on_select_natoms
,
self
.
_nAtomsSpinCtrl
)
self
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
on_set_user_definition
,
setButton
)
self
.
Bind
(
wx
.
EVT_TREE_BEGIN_DRAG
,
self
.
on_drag_atom_name
,
self
.
_molecules
)
self
.
Bind
(
wx
.
EVT_LIST_KEY_DOWN
,
self
.
on_delete_atom_name
,
self
.
_atoms
)
def
plug
(
self
):
self
.
parent
.
mgr
.
GetPane
(
self
).
Float
().
Dockable
(
False
).
CloseButton
(
True
).
BestSize
((
600
,
600
))
self
.
parent
.
mgr
.
Update
()
self
.
set_trajectory
(
self
.
dataproxy
.
data
)
def
enable_natoms_selection
(
self
,
state
):
self
.
_nAtomsSelectionSizer
.
ShowItems
(
state
)
def
set_natoms
(
self
,
nAtoms
):
self
.
_nAtoms
=
nAtoms
self
.
_nAtomsSpinCtrl
.
SetValue
(
nAtoms
)
def
set_trajectory
(
self
,
trajectory
):
self
.
_trajectory
=
trajectory
self
.
_target
=
os
.
path
.
basename
(
self
.
_trajectory
.
filename
)
self
.
_molecularContents
=
get_chemical_objects_dict
(
self
.
_trajectory
.
universe
)
root
=
self
.
_molecules
.
AddRoot
(
''
)
for
mname
in
sorted
(
self
.
_molecularContents
.
keys
()):
molnode
=
self
.
_molecules
.
AppendItem
(
root
,
mname
)
atomsList
=
self
.
_molecularContents
[
mname
][
0
].
atomList
()
atomNames
=
sorted
(
set
([
at
.
name
for
at
in
atomsList
]))
for
aname
in
atomNames
:
self
.
_molecules
.
AppendItem
(
molnode
,
aname
)
def
on_select_natoms
(
self
,
event
):
self
.
_nAtoms
=
event
.
GetInt
()
self
.
_atoms
.
ClearAll
()
self
.
_resultsTextCtrl
.
Clear
()
def
on_delete_atom_name
(
self
,
event
):
keycode
=
event
.
GetKeyCode
()
...
...
@@ -226,38 +278,35 @@ class AtomsListDialog(UserDefinitionsDialog):
class
AtomListWidget
(
UserDefinitionWidget
):
type
=
'atoms_list'
def
initialize
(
self
):
self
.
type
=
"%d_atoms_list"
%
self
.
_configurator
.
_nAtoms
UserDefinitionWidget
.
initialize
(
self
)
def
on_new_user_definition
(
self
,
event
):
dlg
=
UDDialog
(
self
,
self
.
_trajectory
,
self
.
type
)
atomsListDlg
=
AtomsListDialog
(
self
,
self
.
_trajectory
,
self
.
_configurator
.
_nAtoms
)
dlg
.
plugin
.
set_natoms
(
self
.
_configurator
.
_nAtoms
)
atomsListDlg
.
ShowModal
()
atomsListDlg
.
Destroy
()
dlg
.
plugin
.
enable_natoms_selection
(
False
)
if
__name__
==
"__main__"
:
from
MMTK.Trajectory
import
Trajectory
from
MDANSE
import
PLATFORM
,
REGISTRY
LOGGER
.
add_handler
(
"dialog"
,
REGISTRY
[
'handler'
][
'dialog'
](),
level
=
"error"
,
start
=
True
)
dlg
.
ShowModal
()
t
=
Trajectory
(
None
,
os
.
path
.
join
(
os
.
path
.
dirname
(
PLATFORM
.
package_directory
()),
"Data"
,
"Trajectories"
,
"MMTK"
,
"nagma_in_periodic_universe.nc"
),
"r"
)
app
=
wx
.
App
(
False
)
p
=
AtomsListDialog
(
None
,
t
,
4
)
p
.
ShowModal
()
p
.
Destroy
()
app
.
MainLoop
()
# if __name__ == "__main__":
#
# from MMTK.Trajectory import Trajectory
#
# from MDANSE import PLATFORM,REGISTRY
#
# LOGGER.add_handler("dialog", REGISTRY['handler']['dialog'](), level="error", start=True)
#
# t = Trajectory(None,os.path.join(os.path.dirname(PLATFORM.package_directory()),"Data","Trajectories","MMTK","nagma_in_periodic_universe.nc"),"r")
#
# app = wx.App(False)
#
# p = AtomsListDialog(None,t,4)
#
# p.ShowModal()
#
# p.Destroy()
#
# app.MainLoop()
\ No newline at end of file
MDANSE/Framework/Widgets/PartialChargesWidget.py
View file @
3f553546
...
...
@@ -34,37 +34,65 @@ import operator
import
os
import
wx
import
wx.aui
as
wxaui
import
wx.grid
as
wxgrid
from
MDANSE
import
LOGGER
from
MDANSE.Framework.Widgets.UserDefinitionWidget
import
U
serDefinitions
Dialog
,
UserDefinitionWidget
from
MDANSE.Framework.Widgets.UserDefinitionWidget
import
U
DPlugin
,
UD
Dialog
,
UserDefinitionWidget
class
PartialCharges
Dialog
(
UserDefinitionsDialog
):
class
PartialCharges
Plugin
(
UDPlugin
):
def
__init__
(
self
,
parent
,
trajectory
):
type
=
'partial_charges'
label
=
"Partial charges settings"
ancestor
=
[
"molecular_viewer"
]
def
__init__
(
self
,
parent
,
*
args
,
**
kwargs
):
self
.
_parent
=
parent
self
.
_trajectory
=
trajectory
self
.
_selectedAtoms
=
[]
target
=
os
.
path
.
basename
(
self
.
_trajectory
.
filename
)
UserDefinitionsDialog
.
__init__
(
self
,
parent
,
target
,
'partial_charges'
,
wx
.
ID_ANY
,
title
=
"Partial charges dialog"
,
style
=
wx
.
DEFAULT_DIALOG_STYLE
|
wx
.
RESIZE_BORDER
|
wx
.
MINIMIZE_BOX
|
wx
.
MAXIMIZE_BOX
)
def
build_dialog
(
self
):
UDPlugin
.
__init__
(
self
,
parent
)
def
build_panel
(
self
):
self
.
_mainPanel
=
wx
.
Panel
(
self
,
wx
.
ID_ANY
)
sizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
self
.
_grid
=
wxgrid
.
Grid
(
self
.
_mainPanel
)
self
.
_grid
=
wxgrid
.
Grid
(
self
)
sizer
.
Add
(
self
.
_grid
,
1
,
wx
.
ALL
|
wx
.
EXPAND
,
5
)
self
.
_mainPanel
.
SetSizer
(
sizer
)
self
.
_mgr
.
AddPane
(
self
.
_mainPanel
,
wxaui
.
AuiPaneInfo
().
DestroyOnClose
().
Center
().
Dock
().
CaptionVisible
(
False
).
CloseButton
(
False
).
BestSize
(
self
.
GetSize
()))
self
.
_mgr
.
Update
()
def
plug
(
self
):
self
.
parent
.
mgr
.
GetPane
(
self
).
Float
().
Dockable
(
False
).
CloseButton
(
True
).
BestSize
((
600
,
600
))
self
.
_grid
.
CreateGrid
(
self
.
_trajectory
.
universe
.
numberOfAtoms
(),
3
)
self
.
parent
.
mgr
.
Update
(
)
self
.
set_trajectory
(
self
.
dataproxy
.
data
)
def
set_trajectory
(
self
,
trajectory
):
self
.
_trajectory
=
trajectory
self
.
_target
=
os
.
path
.
basename
(
self
.
_trajectory
.
filename
)
self
.
_grid
.
CreateGrid
(
self
.
_trajectory
.
universe
.
numberOfAtoms
(),
3
)
self
.
_grid
.
SetRowLabelSize
(
1
)
self
.
_grid
.
SetColFormatNumber
(
0
)
self
.
_grid
.
SetColFormatNumber
(
1
)
self
.
_grid
.
SetColFormatNumber
(
2
)
roAttr
=
wxgrid
.
GridCellAttr
()
roAttr
.
SetReadOnly
(
True
)
roAttr
.
SetBackgroundColour
(
wx
.
Colour
(
220
,
220
,
220
))
...
...
@@ -84,9 +112,7 @@ class PartialChargesDialog(UserDefinitionsDialog):
for
idx
,
at
in
enumerate
(
atoms
):
self
.
_grid
.
SetCellValue
(
idx
,
0
,
str
(
idx
))
self
.
_grid
.
SetCellValue
(
idx
,
1
,
at
.
name
)
self
.
_mainSizer
.
Add
(
self
.
_grid
,
1
,
wx
.
EXPAND
|
wx
.
ALL
,
5
)
def
validate
(
self
):
charges
=
{}
...
...
@@ -105,32 +131,23 @@ class PartialChargesDialog(UserDefinitionsDialog):
class
PartialChargesWidget
(
UserDefinitionWidget
):
type
=
"partial_charges"
def
initialize
(
self
):
UserDefinitionWidget
.
initialize
(
self
)
def
on_new_user_definition
(
self
,
event
):
dlg
=
PartialChargesDialog
(
self
,
self
.
_trajectory
)
dlg
.
ShowModal
()
dlg
.
Destroy
()
if
__name__
==
"__main__"
:
from
MMTK.Trajectory
import
Trajectory
t
=
Trajectory
(
None
,
"../../../../../Data/Trajectories/MMTK/waterbox_in_periodic_universe.nc"
,
"r"
)
from
MDANSE
import
PLATFORM
t
=
Trajectory
(
None
,
os
.
path
.
join
(
PLATFORM
.
example_data_directory
(),
"Trajectories"
,
"MMTK"
,
"protein_in_periodic_universe.nc"
),
"r"
)