Commit c67e4126 authored by eric pellegrini's avatar eric pellegrini
Browse files

The job plugin can now be plugged into the viewer or on the data plugin

The DataInfoPlugin is now OK
Bug fix with pubsub.sendMessage wrong keyword
Improved the AtomListSelectionDialog
Removed unuseful pubsub calls from the molecular viewer
parent 9e9c7fe1
......@@ -50,7 +50,7 @@ class RootMeanSquareFluctuation(IJob):
category = ('Structure',)
ancestor = "mmtk_trajectory"
ancestor = ["mmtk_trajectory"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -66,7 +66,7 @@ class SolventAccessibleSurface(IJob):
category = ('Structure',)
ancestor = "mmtk_trajectory"
ancestor = ["mmtk_trajectory"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -60,7 +60,7 @@ class SpatialDensity(IJob):
category = ('Structure',)
ancestor = "mmtk_trajectory"
ancestor = ["mmtk_trajectory"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory', {'default':os.path.join('..','..','..','Data','Trajectories', 'MMTK', 'protein_in_periodic_universe.nc')})
......
......@@ -49,7 +49,7 @@ class StaticStructureFactor(DistanceHistogram):
category = ('Structure',)
ancestor = "mmtk_trajectory"
ancestor = ["mmtk_trajectory"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -47,7 +47,7 @@ class StructureFactorFromScatteringFunction(IJob):
category = ('Scattering',)
ancestor = 'netcdf_data'
ancestor = ["netcdf_data"]
settings = collections.OrderedDict()
settings['netcdf_input_file'] = ('netcdf_input_file', {'variables':['time','f(q,t)_total'],
......
......@@ -57,7 +57,7 @@ class Temperature(IJob):
category = ('Thermodynamics',)
ancestor = "mmtk_trajectory"
ancestor = ["mmtk_trajectory"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -66,7 +66,7 @@ class UnfoldedTrajectory(IJob):
category = ('Trajectory',)
ancestor = "mmtk_trajectory"
ancestor = ["mmtk_trajectory"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -72,7 +72,7 @@ class VelocityAutoCorrelationFunction(IJob):
category = ('Dynamics',)
ancestor = "mmtk_trajectory"
ancestor = ["mmtk_trajectory"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -63,7 +63,7 @@ class Voronoi(IJob):
category = ('Structure',)
ancestor = "mmtk_trajectory"
ancestor = ["mmtk_trajectory"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -68,7 +68,7 @@ class StaticStructureFactor(DistanceHistogram):
category = ('Structure',)
ancestor = "mmtk_trajectory"
ancestor = ["mmtk_trajectory"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -33,7 +33,7 @@ Created on Apr 14, 2015
import wx
import wx.aui as wxaui
from MDANSE.Externals.pubsub import pub as Publisher
from MDANSE.Externals.pubsub import pub
from MDANSE.GUI.Icons import ICONS
from MDANSE.Framework.Plugins.ComponentPlugin import ComponentPlugin
......@@ -44,7 +44,7 @@ class AnimationPlugin(ComponentPlugin):
label = "Animation"
ancestor = "molecular_viewer"
ancestor = ["molecular_viewer"]
def __init__(self, parent, *args, **kwargs):
......@@ -57,9 +57,10 @@ class AnimationPlugin(ComponentPlugin):
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])
self.startStop = 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.frameSlider.SetRange(0,self._parent.n_frames-1)
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)
......@@ -69,7 +70,7 @@ class AnimationPlugin(ComponentPlugin):
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(self.startStop, 0, wx.ALIGN_CENTER_VERTICAL)
controlSizer.Add(lastButton, 0, wx.ALIGN_CENTER_VERTICAL)
controlSizer.Add((5, -1), 0, wx.ALIGN_RIGHT)
......@@ -97,13 +98,13 @@ class AnimationPlugin(ComponentPlugin):
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_start_stop_animation, self.startStop)
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'))
# pub.subscribe(self.on_update_animation_icon, ('msg_animate_trajectory'))
# pub.subscribe(self.on_set_up_frame_slider, ('msg_load_trajectory'))
pub.subscribe(self.on_timer, ('msg_timer'))
def plug(self):
self._parent._mgr.GetPane(self).LeftDockable(False).RightDockable(False).Dock().Bottom().CloseButton(True)
......@@ -170,20 +171,24 @@ class AnimationPlugin(ComponentPlugin):
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])
if self._parent.animation_loop:
self.startStop.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
self.startStop.SetBitmapLabel(ICONS["play",32,32])
# def on_update_animation_icon(self, plugin):
#
# if not plugin.is_parent(self):
# return
#
# if plugin.animation_loop:
# self.startStop.SetBitmapLabel(ICONS["pause",32,32])
# else:
# self.startStop.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
......@@ -33,6 +33,7 @@ Created on Apr 14, 2015
import wx
import wx.aui as aui
from MDANSE import REGISTRY
from MDANSE.Framework.Plugins.ComponentPlugin import ComponentPlugin
class DataInfoPlugin(ComponentPlugin):
......@@ -41,13 +42,12 @@ class DataInfoPlugin(ComponentPlugin):
label = "Data info"
ancestor = "data"
ancestor = [data.type for data in REGISTRY["input_data"].values()]
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())
......@@ -66,12 +66,10 @@ class DataInfoPlugin(ComponentPlugin):
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())
......
......@@ -55,7 +55,7 @@ class DataPlugin(IPlugin):
type = 'data'
ancestor = None
ancestor = []
def __init__(self, parent, datakey, **kwargs):
......@@ -103,11 +103,12 @@ class DataPlugin(IPlugin):
if plugin is None:
return
if not issubclass(self.__class__,REGISTRY['plugin'][plugin.ancestor]):
klasses = tuple([REGISTRY['plugin'][anc] for anc in plugin.ancestor])
if not issubclass(self.__class__,klasses):
return
plugin = plugin(self)
self._mgr.AddPane(plugin, wxaui.AuiPaneInfo().Caption(getattr(plugin, "label", pluginName)))
self._mgr.Update()
......
......@@ -51,7 +51,7 @@ class DensitySuperpositionPlugin(ComponentPlugin):
label = "Density superposition"
ancestor = "molecular_viewer"
ancestor = ["molecular_viewer"]
def __init__(self, parent, *args, **kwargs):
......
......@@ -83,7 +83,7 @@ class IPlugin(wx.Panel):
type = "plugin"
ancestor = None
ancestor = []
def __init__(self, parent, *args, **kwargs):
......@@ -146,7 +146,9 @@ class IPlugin(wx.Panel):
plugin.close_children()
except AttributeError:
plugin.Close()
self._parent.SetFocus()
def build_dialog(self):
self.Freeze()
......@@ -165,8 +167,9 @@ class IPlugin(wx.Panel):
plugin = REGISTRY["plugin"].get(pluginName,None)
if plugin is None:
return
if not issubclass(self.__class__,REGISTRY['plugin'][plugin.ancestor]):
klasses = tuple([REGISTRY['plugin'][anc] for anc in plugin.ancestor])
if not issubclass(self.__class__,klasses):
self.parent.drop(pluginName)
return
......
......@@ -154,7 +154,7 @@ class MolecularViewerPanel(ComponentPlugin):
label = "Molecular Viewer"
ancestor = "mmtk_trajectory"
ancestor = ["mmtk_trajectory"]
category = ("Viewer",)
......@@ -197,8 +197,6 @@ class MolecularViewerPanel(ComponentPlugin):
self._iren.RemoveObservers("CharEvent")
self._iren.AddObserver("CharEvent", self.on_keyboard_input)
self._iren.AddObserver("LeftButtonPressEvent", self.emulate_focus)
pub.subscribe(self.check_switch_consistancy, ('msg_switch'))
self._iren.Bind(wx.EVT_CONTEXT_MENU, self.on_show_popup_menu)
......@@ -272,9 +270,7 @@ class MolecularViewerPanel(ComponentPlugin):
def close(self):
self.clear_universe()
pub.unsubscribe(self.check_switch_consistancy, "msg_switch")
def set_trajectory(self, trajectory, selection=None, frame=0):
if not isinstance(trajectory,Trajectory):
......@@ -291,12 +287,10 @@ class MolecularViewerPanel(ComponentPlugin):
# The number of atoms of the universe stored by the trajectory.
self._nAtoms = trajectory.universe.numberOfAtoms()
# Hack for reducing objects resolution when the system is big
self._resolution = int(numpy.sqrt(300000.0 / self._nAtoms))
if self._resolution > 10:
self._resolution = 10
if self._resolution < 4:
self._resolution = 4
self._resolution = 10 if self._resolution > 10 else self._resolution
self._resolution = 4 if self._resolution < 4 else self._resolution
# The array that will store the color and alpha scale for all the atoms.
self._atomsColours , self._lut= self.build_ColorTransferFunction()
......@@ -333,7 +327,7 @@ class MolecularViewerPanel(ComponentPlugin):
self._trajectoryLoaded = True
pub.sendMessage(('msg_load_trajectory'), message = self)
# pub.sendMessage('msg_load_trajectory', plugin=self)
def color_string_to_RGB(self, s):
......@@ -383,16 +377,6 @@ class MolecularViewerPanel(ComponentPlugin):
popupMenu = wx.Menu()
if self._animationLoop:
animationLabel = "Stop animation"
else:
animationLabel = "Start animation"
item = popupMenu.Append(wx.ID_ANY, animationLabel)
popupMenu.Bind(wx.EVT_MENU, self.start_stop_animation, item)
popupMenu.AppendSeparator()
renderingMenu = wx.Menu()
item = renderingMenu.Append(wx.ID_ANY, "Line")
self.Bind(wx.EVT_MENU, lambda event : self.set_rendering_mode(0), item)
......@@ -592,11 +576,11 @@ class MolecularViewerPanel(ComponentPlugin):
if self._iren._timer.IsRunning():
return
self.set_configuration(self._timerCounter)
self._timerCounter += 1
pub.sendMessage(("msg_timer"), plugin=self)
pub.sendMessage("msg_timer", plugin=self)
def set_rendering_mode(self, mode):
if not self._trajectoryLoaded:
......@@ -674,7 +658,7 @@ class MolecularViewerPanel(ComponentPlugin):
self.show_selection(list(self.__pickedAtoms))
pub.sendMessage(('msg_select_atoms_from_viewer'), message = (self.dataplugin,list(self.__pickedAtoms)))
pub.sendMessage('msg_select_atoms_from_viewer', message = (self.dataplugin,list(self.__pickedAtoms)))
def box_atoms(self, atomsList):
......@@ -721,12 +705,14 @@ class MolecularViewerPanel(ComponentPlugin):
self._iren.Render()
def start_animation(self, event=None):
if self._trajectoryLoaded:
self._timerId = self.create_timer()
self._iren.TimerEventResetsTimerOn()
self._animationLoop = True
def stop_animation(self, event=None):
if self._trajectoryLoaded:
self._iren.TimerEventResetsTimerOff()
self._animationLoop = False
......@@ -738,26 +724,23 @@ class MolecularViewerPanel(ComponentPlugin):
if self._first:
self._first = False
if not self._animationLoop:
self.start_animation()
else:
self.stop_animation()
if check:
pub.sendMessage(('msg_switch'), message = self)
pub.sendMessage(('msg_animate_trajectory'), message = self)
# if check:
# self.check_switch_consistancy()
# pub.sendMessage('msg_animate_trajectory', plugin=self)
def check_switch_consistancy(self, message):
if not self._animationLoop:
return
mv = message
if self == mv:
return
self.start_stop_animation(check = False)
# def check_switch_consistancy(self):
#
# if not self._animationLoop:
# return
#
# self.start_stop_animation(check = False)
def get_atom_index(self,pid):
......
......@@ -70,7 +70,7 @@ class MviViewerPlugin(ComponentPlugin):
label = "McStas Virtual Instrument Viewer"
ancestor = "mvi_trace"
ancestor = ["mvi_trace"]
category = ("Viewer",)
......
......@@ -742,7 +742,7 @@ class PeriodicTablePlugin(ComponentPlugin):
label = "Periodic Table"
ancestor = None
ancestor = []
def build_panel(self):
......
......@@ -360,7 +360,7 @@ class PlotterPlugin(ComponentPlugin):
label = "2D/3D Plotter"
ancestor = 'netcdf_data'
ancestor = ["netcdf_data"]
category = ("Plotter",)
......
......@@ -50,7 +50,7 @@ class RegistryViewerPlugin(ComponentPlugin):
label = "Registry Viewer"
ancestor = None
ancestor = []
def __init__(self, parent, *args, **kwargs):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment