Changeset 9257:348e625de866 in orange


Ignore:
Timestamp:
11/23/11 20:09:03 (2 years ago)
Author:
miha <miha.stajdohar@…>
Branch:
default
Convert:
41e412ee06b3d0a35d0f538dabc0e37221ca9fa0
Message:

Killed some nasty bugs in recursion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Visualize Qt/OWNxCanvasQt.py

    r9029 r9257  
    610610        current_nodes = self.networkCurve.nodes() 
    611611         
     612        center_x = numpy.average([node.x() for node in current_nodes.values()]) if len(current_nodes) > 0 else 0 
     613        center_y = numpy.average([node.y() for node in current_nodes.values()]) if len(current_nodes) > 0 else 0 
     614         
    612615        def closest_nodes_with_pos(nodes): 
    613616             
     
    617620 
    618621            # checked all, none found             
    619             if len(neighbors-nodes) == 0: 
     622            if len(neighbors - nodes) == 0: 
    620623                return [] 
    621624             
     
    624627                return inter 
    625628            else: 
    626                 print "in recursion" 
    627                 return closest_nodes_with_pos(neighbors) 
     629                return closest_nodes_with_pos(neighbors | nodes) 
    628630         
    629631        pos = dict((n, [numpy.average(c) for c in zip(*[(current_nodes[u].x(), current_nodes[u].y()) for u in closest_nodes_with_pos(set([n]))])]) for n in add_nodes) 
     
    631633        self.networkCurve.remove_nodes(list(remove_nodes)) 
    632634         
    633         nodes = dict((v, self.NodeItem(v, x=pos[v][0], y=pos[v][1], parent=self.networkCurve)) for v in add_nodes) 
     635        nodes = dict((v, self.NodeItem(v, x=pos[v][0] if len(pos[v]) == 2 else center_x, y=pos[v][1] if len(pos[v]) == 2 else center_y, parent=self.networkCurve)) for v in add_nodes) 
    634636        self.networkCurve.add_nodes(nodes) 
    635637        nodes = self.networkCurve.nodes() 
Note: See TracChangeset for help on using the changeset viewer.