From abe13df9ccefd220697127204f4dca7d3768a12d Mon Sep 17 00:00:00 2001 From: Sam Fries Date: Mon, 2 Mar 2015 13:59:55 -0800 Subject: [PATCH] Detach 2D UI when plotting 3D charts --- Packages/vcs/Lib/Canvas.py | 9 +++++++-- Packages/vcs/Lib/configurator.py | 31 +++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/Packages/vcs/Lib/Canvas.py b/Packages/vcs/Lib/Canvas.py index 09ec6edfab..f1d9a8b4db 100644 --- a/Packages/vcs/Lib/Canvas.py +++ b/Packages/vcs/Lib/Canvas.py @@ -468,7 +468,8 @@ def start(self,*args,**kargs): self.interact(*args,**kargs) def interact(self,*args,**kargs): - self.configurator.show() + if self.configurator is not None: + self.configurator.show() self.backend.interact(*args,**kargs) def _datawc_tv(self, tv, arglist): @@ -3730,8 +3731,12 @@ def set_convert_labels(copy_mthd,test=0): setattr(arglist[0],p,tmp) if dn is not None: self.display_names.append(result.name) - if self.backend.bg == False: + if result.g_type in ("3d_scalar", "3d_vector") and self.configurator is not None: + self.configurator.detach() + self.configurator = None + if self.backend.bg == False and self.configurator is not None: self.configurator.update(self.display_names) + # Commented out as agreed we shouldn't use warnings in these contexts. #if not hasattr(__main__,"__file__") and not bg: # warnings.warn("VCS Behaviour changed, in order to interact with window, start the interaction mode with:\n x.interact()") diff --git a/Packages/vcs/Lib/configurator.py b/Packages/vcs/Lib/configurator.py index 62503b10aa..d1c355fb92 100644 --- a/Packages/vcs/Lib/configurator.py +++ b/Packages/vcs/Lib/configurator.py @@ -162,6 +162,7 @@ def __init__(self, canvas, show_on_update=False): self.initialized = False self.animation_speed = 250 self.animation_timer = None + self.listeners = [] self.animation_last_frame_time = datetime.datetime.now() # Map custom templates to their source template self.templates = {} @@ -175,10 +176,10 @@ def shift(self): def update(self, displays): if self.backend.renWin and self.interactor is None: self.interactor = self.backend.renWin.GetInteractor() - self.interactor.AddObserver("TimerEvent", self.animate) - self.interactor.AddObserver("LeftButtonPressEvent", self.click) - self.interactor.AddObserver("MouseMoveEvent", self.hover) - self.interactor.AddObserver("LeftButtonReleaseEvent", self.release) + self.listeners.append(self.interactor.AddObserver("TimerEvent", self.animate)) + self.listeners.append(self.interactor.AddObserver("LeftButtonPressEvent", self.click)) + self.listeners.append(self.interactor.AddObserver("MouseMoveEvent", self.hover)) + self.listeners.append(self.interactor.AddObserver("LeftButtonReleaseEvent", self.release)) self.init_buttons() self.init_toolbar() @@ -201,12 +202,30 @@ def update(self, displays): self.show() self.show_on_update = False + def detach(self): + if self.toolbar is not None: + self.toolbar.detach() + self.toolbar = None + if self.fill_button is not None: + self.fill_button.detach() + self.fill_button = None + if self.text_button is not None: + self.text_button.detach() + self.text_button = None + if self.line_button is not None: + self.line_button.detach() + self.line_button = None + if self.marker_button is not None: + self.marker_button.detach() + self.marker_button = None + + for listener in self.listeners: + self.interactor.RemoveObserver(listener) + def release(self, object, event): if self.clicking is None: return - - if datetime.datetime.now() - self.clicking[1] < datetime.timedelta(0, .5): point = self.clicking[0]