Skip to content

Commit

Permalink
Merge pull request #1099 from chaosphere2112/2d_widget_not_on_3d
Browse files Browse the repository at this point in the history
Detach 2D UI when plotting 3D charts
  • Loading branch information
doutriaux1 committed Mar 4, 2015
2 parents 33a751c + abe13df commit 45c40d5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
9 changes: 7 additions & 2 deletions Packages/vcs/Lib/Canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()")
Expand Down
31 changes: 25 additions & 6 deletions Packages/vcs/Lib/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand All @@ -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()

Expand All @@ -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]
Expand Down

0 comments on commit 45c40d5

Please sign in to comment.