Skip to content

Commit

Permalink
Merge pull request #1034 from VisTrails/remove-versiontree-timer
Browse files Browse the repository at this point in the history
Removes version layout animation
  • Loading branch information
remram44 committed Apr 2, 2015
2 parents 9d643c3 + 25f7fcd commit 97c3364
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 107 deletions.
27 changes: 2 additions & 25 deletions vistrails/gui/version_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,6 @@ def __init__(self, parent=None):
self.edges = {} # (sourceVersion, targetVersion) -> edge gui object
self.controller = None
self.fullGraph = None
self.timer = QtCore.QBasicTimer()
self.animation_step = 1
self.num_animation_steps = 1
self.emit_selection = True
self.select_by_click = True
self.connect(self, QtCore.SIGNAL("selectionChanged()"),
Expand Down Expand Up @@ -971,8 +968,7 @@ def setupScene(self, controller, select_node=True):

# perform graph layout
(tree, self.fullGraph, layout) = \
controller.refine_graph(float(self.animation_step)/
float(self.num_animation_steps))
controller.refine_graph(2.0)

tClearRefine = time.clock() - tClearRefine

Expand Down Expand Up @@ -1070,33 +1066,14 @@ def setupScene(self, controller, select_node=True):

# Update bounding rects and fit to all view
tUpdate = time.clock()
if not self.controller.animate_layout:
self.updateSceneBoundingRect()
elif not self.timer.isActive():
self.timer.start(0, self)
self.updateSceneBoundingRect()
tUpdate = time.clock() - tUpdate

self.select_by_click = True

t = time.clock() - t
# print "time in msec to setupScene total: %f refine %f layout %f create %f" % (t, tClearRefine, tCreate)

def timerEvent(self, event):
""" timerEvent(event: QTimerEvent) -> None
Start up a timer for animating tree drawing events
"""
if event.timerId() == self.timer.timerId():
self.animation_step += 1
if self.animation_step >= self.num_animation_steps:
self.animation_step = 1
self.timer.stop()
self.controller.animate_layout = False
self.setupScene(self.controller)
self.update()
else:
qt_super(QVersionTreeScene, self).timerEvent(event)

def keyPressEvent(self, event):
""" keyPressEvent(event: QKeyEvent) -> None
Capture 'Del', 'Backspace' for pruning versions when not editing a tag
Expand Down
84 changes: 2 additions & 82 deletions vistrails/gui/vistrail_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ def __init__(self, vistrail=None, locator=None, abstractions=None,
self.timer = None
if self._auto_save:
self.setup_timer()

self._previous_graph_layout = None

def width_f(text):
return CurrentTheme.VERSION_FONT_METRIC.width(text)
Expand All @@ -170,7 +168,6 @@ def width_f(text):
CurrentTheme.VERSION_FONT_METRIC.height(),
CurrentTheme.VERSION_LABEL_MARGIN[0],
CurrentTheme.VERSION_LABEL_MARGIN[1])
self.animate_layout = False
#this was moved to BaseController
#self.num_versions_always_shown = 1
BaseController.__init__(self, vistrail, locator, abstractions,
Expand Down Expand Up @@ -238,7 +235,6 @@ def invalidate_version_tree(self, reset_version_view=True, animate_layout=False)
"""
self.reset_version_view = reset_version_view
self.animate_layout = animate_layout
#FIXME: in the future, rename the signal
try:
self.emit(QtCore.SIGNAL('vistrailChanged()'))
Expand Down Expand Up @@ -632,7 +628,6 @@ def set_full_tree(self, full):

def recompute_terse_graph(self):
BaseController.recompute_terse_graph(self)
self._previous_graph_layout = copy.deepcopy(self._current_graph_layout)
self._current_graph_layout.layout_from(self.vistrail,
self._current_terse_graph)

Expand All @@ -646,83 +641,8 @@ def refine_graph(self, step=1.0):
if self._current_full_graph is None:
self.recompute_terse_graph()

if not self.animate_layout:
return (self._current_terse_graph, self._current_full_graph,
self._current_graph_layout)

graph_layout = copy.deepcopy(self._current_graph_layout)
terse_graph = copy.deepcopy(self._current_terse_graph)
am = self.vistrail.actionMap
step = 1.0/(1.0+math.exp(-(step*12-6))) # use a logistic sigmoid function

# Adding nodes to tree
for (c_id, c_node) in self._current_graph_layout.nodes.iteritems():
if self._previous_graph_layout.nodes.has_key(c_id):
p_node = self._previous_graph_layout.nodes[c_id]
else:
p_id = c_id
# Find closest child of contained in both graphs
while not self._previous_graph_layout.nodes.has_key(p_id):
# Should always have exactly one child
p_id = [to for (to, _) in \
self._current_full_graph.adjacency_list[p_id]
if (to in am) and \
not self.vistrail.is_pruned(to)][0]
p_node = self._previous_graph_layout.nodes[p_id]

# Interpolate position
x = p_node.p.x - c_node.p.x
y = p_node.p.y - c_node.p.y
graph_layout.move_node(c_id, x*(1.0-step), y*(1.0-step))

# Removing nodes from tree
for (p_id, p_node) in self._previous_graph_layout.nodes.iteritems():
if not self._current_graph_layout.nodes.has_key(p_id):
# Find closest parent contained in both graphs
shared_parent = p_id
while (shared_parent > 0 and
shared_parent not in self._current_graph_layout.nodes):
shared_parent = \
self._current_full_graph.parent(shared_parent)

# Find closest child contained in both graphs
c_id = p_id
while not self._current_graph_layout.nodes.has_key(c_id):
# Should always have exactly one child
c_id = [to for (to, _) in \
self._current_full_graph.adjacency_list[c_id]
if (to in am) and \
not self.vistrail.is_pruned(to)][0]

# Don't show edge that skips the disappearing nodes
if terse_graph.has_edge(shared_parent, c_id):
terse_graph.delete_edge(shared_parent, c_id)

# Add the disappearing node to the graph and layout
c_node = copy.deepcopy(self._current_graph_layout.nodes[c_id])
c_node.id = p_id
graph_layout.add_node(p_id, c_node)
terse_graph.add_vertex(p_id)
p_parent = self._current_full_graph.parent(p_id)
if not terse_graph.has_edge(p_id, p_parent):
terse_graph.add_edge(p_parent, p_id)
p_child = p_id
while p_child not in self._current_graph_layout.nodes:
# Should always have exactly one child
p_child = [to for (to, _) in \
self._current_full_graph.adjacency_list[p_child]
if (to in am) and \
not self.vistrail.is_pruned(to)][0]
if not terse_graph.has_edge(p_id, p_child):
terse_graph.add_edge(p_id, p_child)

# Interpolate position
x = p_node.p.x - c_node.p.x
y = p_node.p.y - c_node.p.y
graph_layout.move_node(p_id, x*(1.0-step), y*(1.0-step))

return (terse_graph, self._current_full_graph,
graph_layout)
return (self._current_terse_graph, self._current_full_graph,
self._current_graph_layout)

##########################################################################
# undo/redo navigation
Expand Down

0 comments on commit 97c3364

Please sign in to comment.