Changeset 8586:e6d62b780a37 in orange


Ignore:
Timestamp:
08/03/11 11:36:44 (3 years ago)
Author:
miha <miha.stajdohar@…>
Branch:
default
Convert:
0a1ec39c74a57bc268c4f7ca10cf62844616a8fb
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Prototypes/OWNxCanvasQt.py

    r8581 r8586  
    673673        self.networkCurve.remove_nodes(list(remove_nodes)) 
    674674         
    675         nodes = dict((v, NodeItem(v, parent=self.networkCurve)) for v in new_nodes) 
     675        nodes = dict((v, NodeItem(v, parent=self.networkCurve)) for v in add_nodes) 
     676        self.networkCurve.add_nodes(nodes) 
     677        nodes = self.networkCurve.nodes() 
    676678         
    677679        #build edge index 
     
    692694        if self.links is not None and len(self.links) > 0: 
    693695            links = self.links 
    694             links_indices = (row_ind[i + 1][j + 1] for (i, j) in self.graph.edges(new_nodes)) 
    695             labels = ([str(row[r].value) for r in range(2, len(row))] for row in (links[links_index] for links_index in links_indices)) 
     696            links_indices = (row_ind[i + 1][j + 1] for (i, j) in self.graph.edges(add_nodes)) 
     697            labels = ([str(row[r].value) for r in range(2, len(row))] for row \ 
     698                      in (links[links_index] for links_index in links_indices)) 
    696699             
    697700            if self.graph.is_directed(): 
    698701                edges = [EdgeItem(nodes[i], nodes[j], 
    699                     self.graph[i][j].get('weight', 1), 0, 1, links_index, label, parent=self.networkCurve) for \ 
    700                     ((i, j), links_index, label) in zip(self.graph.edges(new_nodes), \ 
    701                                                        links_indices, labels)] 
     702                    self.graph[i][j].get('weight', 1), 0, 1, links_index, label, \ 
     703                    parent=self.networkCurve) for ((i, j), links_index, label) in \ 
     704                         zip(self.graph.edges(add_nodes), links_indices, labels)] 
    702705            else: 
    703706                edges = [EdgeItem(nodes[i], nodes[j], 
    704707                    self.graph[i][j].get('weight', 1), links_index, label) for \ 
    705                     ((i, j), links_index, label) in zip(self.graph.edges(new_nodes), \ 
    706                                                         links_indices, labels, parent=self.networkCurve)] 
     708                    ((i, j), links_index, label) in zip(self.graph.edges(add_nodes), \ 
     709                                        links_indices, labels, parent=self.networkCurve)] 
    707710        elif self.graph.is_directed(): 
    708             edges = [EdgeItem(nodes[i], nodes[j], 
    709                                       self.graph[i][j].get('weight', 1), 0, 1, parent=self.networkCurve) for (i, j) in self.graph.edges(new_nodes)] 
     711            edges = [EdgeItem(nodes[i], nodes[j], self.graph[i][j].get('weight', 1), \ 
     712                    0, 1, parent=self.networkCurve) for (i, j) in self.graph.edges(add_nodes)] 
    710713        else: 
    711             edges = [EdgeItem(nodes[i], nodes[j], 
    712                                       self.graph[i][j].get('weight', 1), parent=self.networkCurve) for (i, j) in self.graph.edges(new_nodes)] 
    713              
    714          
    715         self.networkCurve.add_nodes(nodes, edges) 
    716          
    717         #self.replot() 
    718         pass 
     714            edges = [EdgeItem(nodes[i], nodes[j], self.graph[i][j].get('weight', 1), \ 
     715                    parent=self.networkCurve) for (i, j) in self.graph.edges(add_nodes)] 
     716             
     717        self.networkCurve.add_edges(edges) 
    719718         
    720719    def set_graph(self, graph, curve=None, items=None, links=None): 
Note: See TracChangeset for help on using the changeset viewer.