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

The viewer is now cleared when the AtomSelection dialog is closed

Uniformized the pubsub calls
parent 3f553546
......@@ -102,9 +102,9 @@ class AnimationPlugin(ComponentPlugin):
self.Bind(wx.EVT_BUTTON, self.on_goto_first_frame, firstButton)
self.Bind(wx.EVT_BUTTON, self.on_goto_last_frame, lastButton)
# 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'))
pub.subscribe(self.msg_update_animation_icon, 'msg_animate_trajectory')
pub.subscribe(self.msg_set_trajectory, 'msg_set_trajectory')
pub.subscribe(self.msg_timer, 'msg_timer')
def plug(self):
self._parent._mgr.GetPane(self).LeftDockable(False).RightDockable(False).Dock().Bottom().CloseButton(True)
......@@ -149,7 +149,7 @@ class AnimationPlugin(ComponentPlugin):
self.speedSlider.SetValue(int(self.speedEntry.GetValue()))
self._parent.change_frame_rate()
def on_timer(self, plugin):
def msg_timer(self, plugin):
if not plugin.is_parent(self):
return
......@@ -171,24 +171,19 @@ class AnimationPlugin(ComponentPlugin):
self._parent.start_stop_animation()
if self._parent.animation_loop:
def msg_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_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
def msg_set_trajectory(self, plugin):
if not plugin.is_parent(self):
return
self.frameSlider.SetRange(0,self._parent.n_frames-1)
\ No newline at end of file
......@@ -129,4 +129,4 @@ class DataPlugin(IPlugin):
self._currentWindow = window
pub.sendMessage(('msg_set_plugins_tree'), message=window)
pub.sendMessage('msg_set_plugins_tree', plugin=window)
......@@ -131,9 +131,6 @@ class IPlugin(wx.Panel):
if window == self:
return True
if window.TopLevelParent == window:
return False
return self.is_parent(window.Parent)
def close(self):
......@@ -151,7 +148,7 @@ class IPlugin(wx.Panel):
self.SetFocus()
pub.sendMessage(('msg_set_plugins_tree'), message=self)
pub.sendMessage('msg_set_plugins_tree', plugin=self)
def build_dialog(self):
......
......@@ -167,7 +167,7 @@ class MolecularViewerPanel(ComponentPlugin):
self.enable_picking(True)
pub.subscribe(self.on_set_selection, ('msg_set_selection'))
pub.subscribe(self.msg_set_selection, 'msg_set_selection')
def build_panel(self):
......@@ -200,7 +200,8 @@ class MolecularViewerPanel(ComponentPlugin):
self._iren.Bind(wx.EVT_CONTEXT_MENU, self.on_show_popup_menu)
pub.subscribe(self.switch_other_viewers_state, "switch_other_viewers_state")
pub.subscribe(self.msg_switch_viewers_state, "msg_switch_viewers_state")
pub.subscribe(self.msg_clear_selection,'msg_clear_selection')
self._mgr.AddPane(self._iren, aui.AuiPaneInfo().Dock().Center().CaptionVisible(False).CloseButton(False))
......@@ -228,14 +229,12 @@ class MolecularViewerPanel(ComponentPlugin):
del self._surface
self._surface = None
def on_set_selection(self,message):
def msg_set_selection(self,plugin):
window,selection = message
if self.dataplugin != get_data_plugin(window):
if not self.is_parent(plugin):
return
self.show_selection(selection)
self.show_selection(plugin.selection)
def on_show_selection_box(self,message):
......@@ -273,7 +272,8 @@ class MolecularViewerPanel(ComponentPlugin):
self.clear_universe()
pub.unsubscribe(self.switch_other_viewers_state, "switch_other_viewers_state")
pub.unsubscribe(self.msg_switch_viewers_state, "msg_switch_viewers_state")
pub.unsubscribe(self.msg_clear_selection,'msg_clear_selection')
def set_trajectory(self, trajectory, selection=None, frame=0):
......@@ -331,7 +331,7 @@ class MolecularViewerPanel(ComponentPlugin):
self._trajectoryLoaded = True
# pub.sendMessage('msg_load_trajectory', plugin=self)
pub.sendMessage('msg_set_trajectory', plugin=self)
def color_string_to_RGB(self, s):
......@@ -674,7 +674,7 @@ class MolecularViewerPanel(ComponentPlugin):
self.show_selection(atomsList)
def on_clear_selection(self,event):
def on_clear_selection(self,event=None):
if not self._trajectoryLoaded:
return
......@@ -735,11 +735,11 @@ class MolecularViewerPanel(ComponentPlugin):
self.stop_animation()
if check:
pub.sendMessage("switch_other_viewers_state", viewer=self)
pub.sendMessage("msg_switch_viewers_state", viewer=self)
pub.sendMessage('msg_animate_trajectory', plugin=self)
def switch_other_viewers_state(self, viewer):
def msg_switch_viewers_state(self, viewer):
if not self._animationLoop:
return
......@@ -953,6 +953,13 @@ class MolecularViewerPanel(ComponentPlugin):
return assembly
def msg_clear_selection(self,plugin):
if not self.is_parent(plugin):
return
self.on_clear_selection()
def clear_universe(self):
if not hasattr(self, "_actors"):
......
......@@ -41,11 +41,6 @@ class Status(object):
self._elapsedTime = "N/A"
self._lastRefresh = self._startTime
# Publisher.subscribe(self.finish_status, "msg_status_finish")
# Publisher.subscribe(self.start_status, "msg_status_start")
# Publisher.subscribe(self.stop_status, "msg_status_stop")
# Publisher.subscribe(self.update_status, "msg_status_update")
@abc.abstractmethod
def finish_status(self):
pass
......@@ -82,9 +77,7 @@ class Status(object):
self._finished = True
self.finish_status()
# Publisher.sendMessage("msg_status_finish",message=self)
def get_current_step(self):
return self._currentStep
......@@ -126,14 +119,11 @@ class Status(object):
self.start_status()
# Publisher.sendMessage("msg_status_start",message=self)
def stop(self):
self._eta = "N/A"
self._stopped = True
self.stop_status()
# Publisher.sendMessage("msg_status_stop",message=self)
def update(self,force=False):
......@@ -160,4 +150,3 @@ class Status(object):
duration = convert_duration(total_seconds(duration))
self._eta = '%02dd:%02dh:%02dm:%02ds' % duration
self.update_status()
# Publisher.sendMessage("msg_status_update",message=self)
\ No newline at end of file
......@@ -166,7 +166,7 @@ class AtomSelectionPlugin(UDPlugin):
self._selection = []
pub.subscribe(self.on_select_atoms_from_viewer, ('msg_select_atoms_from_viewer'))
pub.subscribe(self.msg_select_atoms_from_viewer, 'msg_select_atoms_from_viewer')
UDPlugin.__init__(self,parent,size=(800,500))
......@@ -308,7 +308,11 @@ class AtomSelectionPlugin(UDPlugin):
self.selectionTextCtrl.SetValue(self._query.get_expression())
self.display_selection_summary()
def close(self):
pub.sendMessage('msg_clear_selection',plugin=self)
def on_add_operator(self, event=None):
operator = event.GetEventObject().GetLabel()
......@@ -336,7 +340,7 @@ class AtomSelectionPlugin(UDPlugin):
self._selectionSummary.Clear()
pub.sendMessage('msg_clear_selection',message=self)
pub.sendMessage('msg_clear_selection',plugin=self)
def on_display_keyword_values(self, event=None):
......@@ -372,7 +376,7 @@ class AtomSelectionPlugin(UDPlugin):
self.keywords.DeselectAll()
self.values.DeselectAll()
def on_select_atoms_from_viewer(self, message):
def msg_select_atoms_from_viewer(self, message):
dataPlugin,selection = message
......@@ -387,8 +391,13 @@ class AtomSelectionPlugin(UDPlugin):
_, self._selection = self._query.parse()
pub.sendMessage("msg_set_selection", message = (self,self._selection))
pub.sendMessage("msg_set_selection", plugin=self)
@property
def selection(self):
return self._selection
def validate(self):
if not self._selection:
......
......@@ -59,7 +59,7 @@ class IWidget(wx.Panel):
self.build_panel()
pub.subscribe(self._set_data, ('msg_set_data'))
pub.subscribe(self._set_data, 'msg_set_data')
@property
def label(self):
......
......@@ -39,7 +39,6 @@ from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as Navigat
import wx
from MDANSE import REGISTRY
from MDANSE.Externals.pubsub import pub
from MDANSE.Framework.Widgets.IWidget import IWidget
from MDANSE.GUI import DATA_CONTROLLER
from MDANSE.GUI.ComboWidgets.ConfigurationPanel import ConfigurationPanel
......@@ -200,8 +199,6 @@ class InstrumentResolutionConfigurator(IWidget):
self.Bind(wx.EVT_BUTTON, self.on_set_instrument_resolution, self._setResolution)
pub.subscribe(self.set_data, ("msg_set_netcdf"))
return sizer
def get_widget_value(self):
......
......@@ -53,11 +53,11 @@ class McStasParametersWidget(IWidget):
self._sizer = wx.BoxSizer(wx.VERTICAL)
pub.subscribe(self.set_layout, ("msg_set_instrument"))
pub.subscribe(self.msg_set_instrument, "msg_set_instrument")
return self._sizer
def set_layout(self, message):
def msg_set_instrument(self, message):
widget, parameters = message
......
......@@ -214,7 +214,7 @@ class UserDefinitionWidget(IWidget):
sizer.Add(self._availableUDs, 1, wx.ALL|wx.EXPAND, 5)
sizer.Add(self._newUD, 0, wx.ALL|wx.EXPAND, 5)
pub.subscribe(self.on_save_definition, ("msg_save_definition",))
pub.subscribe(self.msg_save_definition, "msg_save_definition")
self.Bind(wx.EVT_BUTTON, self.on_new_user_definition, self._newUD)
......@@ -242,7 +242,7 @@ class UserDefinitionWidget(IWidget):
self._availableUDs.SetItems(uds)
def on_save_definition(self, message):
def msg_save_definition(self, message):
filename, section, name = message
......
......@@ -34,7 +34,7 @@ import collections
import weakref
from MDANSE.Core.Singleton import Singleton
from MDANSE.Externals.pubsub import pub as Publisher
from MDANSE.Externals.pubsub import pub
class DataController(collections.OrderedDict):
......@@ -49,7 +49,7 @@ class DataController(collections.OrderedDict):
return
else:
collections.OrderedDict.__delitem__(self,item)
Publisher.sendMessage("msg_delete_input_data", message = item)
pub.sendMessage("msg_delete_input_data", data=item)
def __getitem__(self, key):
......@@ -64,7 +64,7 @@ class DataController(collections.OrderedDict):
collections.OrderedDict.__setitem__(self, item,value)
Publisher.sendMessage("msg_load_input_data", message = value)
pub.sendMessage("msg_load_input_data", data=value)
def has_proxy(self, item):
'''
......
......@@ -57,24 +57,24 @@ class DataTreePanel(wx.Panel):
self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.on_drag_data)
self.Bind(wx.EVT_TREE_KEY_DOWN, self.on_delete_data, self._tree)
pub.subscribe(self.msg_load_input_data, ('msg_load_input_data'))
pub.subscribe(self.msg_delete_input_data, ('msg_delete_input_data'))
pub.subscribe(self.msg_load_input_data, 'msg_load_input_data')
pub.subscribe(self.msg_delete_input_data, 'msg_delete_input_data')
@property
def tree(self):
return self._tree
def msg_load_input_data(self, message):
def msg_load_input_data(self, data):
if message is None:
if data is None:
return
self.add_data(message)
self.add_data(data)
def msg_delete_input_data(self, message):
def msg_delete_input_data(self, data):
item = self.get_tree_item(self._root, message)
item = self.get_tree_item(self._root,data)
if item is None:
return
......
......@@ -183,7 +183,7 @@ class JobControllerPanel(wx.ScrolledWindow):
EVT_JOB_CONTROLLER(self,self.on_update)
EVT_JOB_CRASH(self,self.on_crash_summary)
pub.subscribe(self.on_start_job,"msg_start_job")
pub.subscribe(self.msg_start_job,"msg_start_job")
def __del__(self):
......@@ -191,7 +191,7 @@ class JobControllerPanel(wx.ScrolledWindow):
while self._jobsController.is_alive():
time.sleep(0.01)
def on_start_job(self,message):
def msg_start_job(self,message):
self._jobsController.update()
......
......@@ -60,7 +60,7 @@ class PluginsTreePanel(wx.Panel):
self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.on_drag, self._tree)
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.on_double_click)
pub.subscribe(self.on_set_plugins_tree, ('msg_set_plugins_tree'))
pub.subscribe(self.msg_set_plugins_tree, 'msg_set_plugins_tree')
@property
def tree(self):
......@@ -161,10 +161,8 @@ class PluginsTreePanel(wx.Panel):
self.set_plugins_tree(subnode, v)
def on_set_plugins_tree(self, message):
plugin = message
def msg_set_plugins_tree(self, plugin):
if self._tree.GetCount() !=0:
self._tree.DeleteChildren(self._root)
......
......@@ -121,7 +121,7 @@ class WorkingPanel(wx.Panel):
dataPlugin = self._notebook.GetPage(self._notebook.GetSelection())
pub.sendMessage('msg_set_plugins_tree', message=dataPlugin)
pub.sendMessage('msg_set_plugins_tree', plugin=dataPlugin)
def on_close_page(self, event):
......@@ -130,5 +130,5 @@ class WorkingPanel(wx.Panel):
dataPlugin.close_children()
if self._notebook.GetPageCount() == 1:
pub.sendMessage('msg_set_plugins_tree', message=None)
pub.sendMessage('msg_set_plugins_tree', plugin=None)
\ No newline at end of file
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