Commit c33398f0 authored by eric pellegrini's avatar eric pellegrini

Reintroduced some parts of the GUI in MDANSE

parent 173dd9ab
......@@ -62,7 +62,7 @@ master_doc = 'index'
# General information about the project.
project = u'MDANSE'
copyright = u'2014, B. Aoun & G. Goret & E. Pellegrini'
copyright = u'2015, G. Goret & B. Aoun & E. Pellegrini'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
......@@ -105,18 +105,18 @@ latex_documents = [
u'B. Aoun \\& G. Goret \\& E. Pellegrini', 'manual'),
]
pdf_documents = [('index', 'MDANSE', u'MDANSE Documentation', u'B. Aoun & G. Goret & E. Pellegrini'),]
pdf_documents = [('index', 'MDANSE', u'MDANSE Documentation', u'G. Goret & B. Aoun & E. Pellegrini'),]
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [('index', 'MDANSE', u'MDANSE Documentation', u'B. Aoun & G. Goret & E. Pellegrini'),]
man_pages = [('index', 'MDANSE', u'MDANSE Documentation', u'G. Goret & B. Aoun & E. Pellegrini'),]
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [('index', 'MDANSE', u'MDANSE Documentation',u'B. Aoun & G. Goret & E. Pellegrini','MDANSE', 'One line description of project.','Miscellaneous'),]
texinfo_documents = [('index', 'MDANSE', u'MDANSE Documentation',u'G. Goret & B. Aoun & E. Pellegrini','MDANSE', 'One line description of project.','Miscellaneous'),]
exclude_patterns = ['MDANSE.Externals**', 'MDANSE.__pkginfo__']
......
import wx.combo
class ComboCheckbox(wx.combo.ComboPopup):
def __init__(self, items, maxNumberOfItems=None):
wx.combo.ComboPopup.__init__(self)
self._items = items
self._maxNumberOfItems = maxNumberOfItems
@property
def items(self):
return self._items
@property
def checklistbox(self):
return self._checklistbox
def Create(self, parent):
self._checklistbox = wx.CheckListBox(parent, -1, choices=self._items)
self._checklistbox.Bind(wx.EVT_CHECKLISTBOX, self.on_check_item)
if not self._checklistbox.IsEmpty():
self._checklistbox.Check(0)
return True
def GetControl(self):
return self._checklistbox
def GetAdjustedSize(self, minWidth, prefHeight, maxHeight):
return self._checklistbox.GetSize()
def GetStringValue(self):
return self._checklistbox.GetCheckedStrings()
def on_check_item(self, event):
if self._maxNumberOfItems is None:
return
nCheckedItems = len(self._checklistbox.GetChecked())
if nCheckedItems > self._maxNumberOfItems:
self._checklistbox.Check(event.GetInt(), False)
\ No newline at end of file
This diff is collapsed.
import wx
from MDANSE import REGISTRY
from MDANSE.Framework.Configurators.IConfigurator import ConfiguratorError
class ConfigurationPanel(wx.Panel):
def __init__(self, parent, configuration):
wx.Panel.__init__(self, parent, wx.ID_ANY)
self._configuration = configuration
self._widgets = {}
self.build_panel()
def build_panel(self):
self.panelSizer = wx.BoxSizer(wx.VERTICAL)
for cfg in self._configuration.configurators.values():
widgetClass = REGISTRY["configurator_widget"][cfg.widget]
self._widgets[cfg.name] = widgetClass(self, cfg.name, self._configuration)
self.panelSizer.Add(self._widgets[cfg.name], 0, wx.ALL|wx.EXPAND, 5)
self.SetSizer(self.panelSizer)
self.Layout()
self.Fit()
@property
def widgets(self):
return self._widgets
def get_value(self):
return dict([(k,v.get_value()) for k,v in self._widgets.items()])
def validate(self):
for w in self._widgets.values():
w.SetBackgroundColour(wx.NullColour)
w.Refresh()
try:
self._configuration.parameters = self.get_value()
except ConfiguratorError as e:
d = wx.MessageDialog(self, str(e), style=wx.ICON_ERROR|wx.STAY_ON_TOP|wx.CENTRE)
d.ShowModal()
w = self._widgets[e.configurator.name]
w.SetBackgroundColour("Pink")
w.Refresh()
w.SetFocus()
return False
else:
return True
#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 10, 2015
@author: pellegrini
'''
import wx
from MDANSE import REGISTRY
from MDANSE.Framework.Configurable import ConfigurationError
class ConfigurationPanel(wx.Panel):
def __init__(self, parent, configuration):
wx.Panel.__init__(self, parent, wx.ID_ANY)
self._configuration = configuration
self._widgets = {}
self.build_panel()
def build_panel(self):
self.panelSizer = wx.BoxSizer(wx.VERTICAL)
for cfg in self._configuration.configurators.values():
widgetClass = REGISTRY["configuratorwidget"][cfg.widget]
self._widgets[cfg.name] = widgetClass(self, cfg.name, self._configuration)
self.panelSizer.Add(self._widgets[cfg.name], 0, wx.ALL|wx.EXPAND, 5)
self.SetSizer(self.panelSizer)
self.Layout()
self.Fit()
@property
def widgets(self):
return self._widgets
def get_value(self):
return dict([(k,v.get_value()) for k,v in self._widgets.items()])
def validate(self):
for w in self._widgets.values():
w.SetBackgroundColour(wx.NullColour)
w.Refresh()
try:
self._configuration.setup(self.get_value())
except ConfigurationError as e:
d = wx.MessageDialog(self, str(e), style=wx.ICON_ERROR|wx.STAY_ON_TOP|wx.CENTRE)
d.ShowModal()
w = self._widgets[e.configurator.name]
w.SetBackgroundColour("Pink")
w.Refresh()
w.SetFocus()
return False
else:
return True
#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: pellegrini
'''
from MDANSE.Externals.pubsub import pub
from MDANSE.App.GUI.ConfiguratorWidgets.IConfiguratorWidget import ConfiguratorWidgetError
from MDANSE.App.GUI.ConfiguratorWidgets.UserDefinitionWidget import UserDefinitionWidget
class AtomSelectionWidget(UserDefinitionWidget):
type = "atom_selection"
def __init__(self, parent, name, configuration, *args, **kwargs):
UserDefinitionWidget.__init__(self, parent, name, configuration, *args, **kwargs)
pub.subscribe(self.msg_set_trajectory, ("set_trajectory"))
pub.subscribe(self.msg_new_definition, ("new_selection",))
def get_widget_value(self):
names = self._selections.GetControl().GetCheckedStrings()
if not names:
return None
if len(names) != 1:
raise ConfiguratorWidgetError("Invalid number of atom selection definitions selected")
return names[0]
def set_widget_value(self, value):
pass
\ No newline at end of file
#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: pellegrini
'''
from MDANSE.Externals.pubsub import pub
from MDANSE.App.GUI.ConfiguratorWidgets.UserDefinitionWidget import UserDefinitionWidget
class AtomTransmutationWidget(UserDefinitionWidget):
type = "atom_transmutation"
def __init__(self, parent, name, configuration, *args, **kwargs):
UserDefinitionWidget.__init__(self, parent, name, configuration, *args, **kwargs)
pub.subscribe(self.msg_set_trajectory, ("set_trajectory"))
pub.subscribe(self.msg_new_definition, ("new_transmutation",))
def get_widget_value(self):
names = self._selections.GetControl().GetCheckedStrings()
if not names:
return None
return names
def set_widget_value(self, value):
pass
\ No newline at end of file
#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: pellegrini
'''
from MDANSE.Externals.pubsub import pub
from MDANSE.App.GUI.ConfiguratorWidgets.IConfiguratorWidget import ConfiguratorWidgetError
from MDANSE.App.GUI.ConfiguratorWidgets.UserDefinitionWidget import UserDefinitionWidget
class AxisSelectionWidget(UserDefinitionWidget):
type = "axis_selection"
def __init__(self, parent, name, configuration, *args, **kwargs):
super(AxisSelectionWidget,self).__init__(parent, name, configuration, *args, **kwargs)
pub.subscribe(self.msg_set_trajectory, ("set_trajectory"))
pub.subscribe(self.msg_new_definition, ("new_axis",))
def get_widget_value(self):
names = self._selections.GetControl().GetCheckedStrings()
if len(names) != 1:
raise ConfiguratorWidgetError("Invalid number of axis definitions selected")
return names[0]
def set_widget_value(self, value):
pass
\ No newline at end of file
#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: pellegrini
'''
from MDANSE.Externals.pubsub import pub
from MDANSE.App.GUI.ConfiguratorWidgets.IConfiguratorWidget import ConfiguratorWidgetError
from MDANSE.App.GUI.ConfiguratorWidgets.UserDefinitionWidget import UserDefinitionWidget
class BasisSelectionWidget(UserDefinitionWidget):
type = "basis_selection"
def __init__(self, parent, name, configuration, *args, **kwargs):
super(BasisSelectionWidget,self).__init__(parent, name, configuration, *args, **kwargs)
pub.subscribe(self.msg_set_trajectory, ("set_trajectory"))
pub.subscribe(self.msg_new_definition, ("new_basis",))
def get_widget_value(self):
names = self._selections.GetControl().GetCheckedStrings()
if len(names) != 1:
raise ConfiguratorWidgetError("Invalid number of basis definitions selected")
return names[0]
def set_widget_value(self, value):
pass
#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: pellegrini
'''
import wx
from MDANSE.App.GUI.ConfiguratorWidgets.IConfiguratorWidget import IConfiguratorWidget
class BooleanWidget(IConfiguratorWidget):
type = "boolean"
def initialize(self):
pass
def add_widgets(self):
sizer = wx.BoxSizer(wx.VERTICAL)
default = self.configurator.default
self._boolean = wx.CheckBox(self._widgetPanel, wx.ID_ANY, label="Yes")
self._boolean.SetValue(default)
sizer.Add(self._boolean, 1, wx.ALL|wx.EXPAND, 5)
return sizer
def get_widget_value(self):
return self._boolean.GetValue()
def set_widget_value(self, value):
pass
#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: pellegrini
'''
import wx
from MDANSE.App.GUI.ConfiguratorWidgets.StringWidget import StringWidget
from MDANSE.App.GUI.ConfiguratorWidgets.IConfiguratorWidget import ConfiguratorWidgetError
class FloatWidget(StringWidget):
type = "float"
def initialize(self):
pass
def add_widgets(self):
sizer = wx.BoxSizer(wx.VERTICAL)
self._float = wx.TextCtrl(self._widgetPanel, wx.ID_ANY, value=str(self.configurator.default))
sizer.Add(self._float, 0, wx.ALL, 5)
return sizer
def set_widget_value(self, value):
pass
def get_widget_value(self):
try:
_ = float(self._float.GetValue())
except ValueError:
raise ConfiguratorWidgetError("Invalid value for %r entry" % self.configurator.name)
val = self._float.GetValue()
return val
#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: pellegrini
'''
import wx
import wx.lib.intctrl as wxintctrl
from MDANSE.Externals.pubsub import pub
from MDANSE.App.GUI import DATA_CONTROLLER
from MDANSE.App.GUI.ConfiguratorWidgets.IConfiguratorWidget import IConfiguratorWidget
class FramesWidget(IConfiguratorWidget):
type = "frames"
def initialize(self):
pass
def add_widgets(self):
sizer = wx.BoxSizer(wx.HORIZONTAL)
gbSizer = wx.GridBagSizer(5,5)
firstLabel = wx.StaticText(self._widgetPanel, wx.ID_ANY, label="First frame")
self._first = wxintctrl.IntCtrl(self._widgetPanel, wx.ID_ANY, limited=True, allow_none=False)
labelLabel = wx.StaticText(self._widgetPanel, wx.ID_ANY, label="Last frame")
self._last = wxintctrl.IntCtrl(self._widgetPanel, wx.ID_ANY, limited=True, allow_none=False)
stepLabel = wx.StaticText(self._widgetPanel, wx.ID_ANY, label="Frame step")
self._step = wxintctrl.IntCtrl(self._widgetPanel, wx.ID_ANY, limited=True, allow_none=False)
gbSizer.Add(firstLabel, (0,0), flag=wx.ALIGN_CENTER_VERTICAL)
gbSizer.Add(labelLabel, (0,3), flag=wx.ALIGN_CENTER_VERTICAL)