Changeset 9056:5ff105fa0df4 in orange


Ignore:
Timestamp:
10/04/11 23:07:45 (3 years ago)
Author:
matejd <matejd@…>
Branch:
default
Convert:
6391d109932be89dfa0c741b91e78603d24cbad6
Message:

NetExplorer3d doesnt crash any more, not yet useful

Location:
orange/OrangeWidgets/Visualize Qt
Files:
2 edited

Legend:

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

    r9047 r9056  
    3434 
    3535        self.plot = OWPlot3D(self) 
     36        self.plot.initializeGL() 
    3637        self.plot.replot = self.plot.update 
    3738        self.gui = self.plot.gui 
     
    8081        self.title_margin = 0 
    8182        self.graph_margin = 1 
    82         import rpdb2; rpdb2.start_embedded_debugger('pass') 
    8383 
    8484    def update_canvas(self): 
    85         orangeqt.Canvas3D.update_properties(self) 
    8685        self.draw_component_keywords() 
    8786        self.update() 
     
    136135 
    137136    def draw_component_keywords(self): 
    138         self.clear_markers() 
     137        #self.clear_markers() 
    139138        if self.show_component_attribute == None or self.graph is None or self.items is None: 
    140139            return 
     
    188187        return colorIndices, colorIndex, minValue, maxValue 
    189188 
     189    getColorIndeces = get_color_indices 
     190 
    190191    def set_node_colors(self, attribute, nodes=None): 
    191192        if self.graph is None: 
     
    234235             
    235236        if self.trim_label_words > 0: 
    236             self.networkCurve.set_node_labels(dict((node,  
     237            orangeqt.Canvas3D.set_node_labels(self, dict((node,  
    237238                ', '.join(indices[i] +  
    238239                          [' '.join(str(self.items[node][att]).split(' ')[:min(self.trim_label_words,len(str(self.items[node][att]).split(' ')))]) 
    239240                for att in label_attributes])) for i, node in enumerate(nodes))) 
    240241        else: 
    241             self.networkCurve.set_node_labels(dict((node, ', '.join(indices[i]+\ 
     242            orangeqt.Canvas3D.set_node_labels(self, dict((node, ', '.join(indices[i]+\ 
    242243                           [str(self.items[node][att]) for att in \ 
    243244                           label_attributes])) for i, node in enumerate(nodes))) 
     
    252253         
    253254        if colorIndex is not None and self.links.domain[colorIndex].varType == orange.VarTypes.Continuous and minValue == maxValue: 
    254             colors = [self.discEdgePalette[0] for edge in self.networkCurve.edge_indices()] 
     255            colors = [self.discEdgePalette[0] for edge in orangeqt.Canvas3D.edge_indices(self)] 
    255256         
    256257        elif colorIndex is not None and self.links.domain[colorIndex].varType == orange.VarTypes.Continuous: 
    257258            colors = [self.contPalette[(float(self.links[edge.links_index()][colorIndex].value) - minValue) / (maxValue - minValue)] 
    258259                          if str(self.links[edge.links_index()][colorIndex].value) != '?' else  
    259                           self.discPalette[0] for edge in self.networkCurve.edges()] 
     260                          self.discPalette[0] for edge in orangeqt.Canvas3D.edges(self)] 
    260261             
    261262        elif colorIndex is not None and self.links.domain[colorIndex].varType == orange.VarTypes.Discrete: 
    262             colors = [self.discEdgePalette[colorIndices[self.links[edge.links_index()][colorIndex].value]] for edge in self.networkCurve.edges()] 
     263            colors = [self.discEdgePalette[colorIndices[self.links[edge.links_index()][colorIndex].value]] for edge in orangeqt.Canvas3D.edges(self)] 
    263264             
    264265        else: 
    265             colors = [self.discEdgePalette[0] for edge in self.networkCurve.edge_indices()] 
     266            colors = [self.discEdgePalette[0] for edge in orangeqt.Canvas3D.edge_indices(self)] 
    266267             
    267268        orangeqt.Canvas3D.set_edge_colors(self, colors) 
     
    289290            [', '.join(weights[i] + [str(self.links[i][att]) for att in label_attributes]) for i,edge in enumerate(edges)]) 
    290291 
    291         self.upate() 
     292        self.update() 
    292293 
    293294    def set_tooltip_attributes(self, attributes): 
     
    366367    def set_graph(self, graph, curve=None, items=None, links=None): 
    367368        #self.clear() # TODO which one? 
     369        # TODO: clear previous nodes and edges? 
    368370 
    369371        if graph is None: 
    370372            self.graph = None 
    371             self.networkCurve = None 
     373            #self.networkCurve = None 
    372374            self.items = None 
    373375            self.links = None 
     
    381383 
    382384        self.graph = graph 
    383  
    384         # TODO: clear previous nodes and edges? 
    385  
    386385        self.items = items if items is not None else self.graph.items() 
    387386        self.links = links if links is not None else self.graph.links() 
    388387 
    389         vertices = dict((v, self.Node3D(v)) for v in self.graph) 
    390         orangeqt.Canvas3D.set_nodes(self, vertices) 
     388        nodes = dict((v, self.Node3D(v)) for v in self.graph) 
     389        orangeqt.Canvas3D.set_nodes(self, nodes) 
    391390 
    392391        self.edge_to_row = {} 
     
    410409 
    411410            if self.graph.is_directed(): 
    412                 edges = [Edge3D(vertices[i], vertices[j], 
     411                edges = [Edge3D(nodes[i], nodes[j], 
    413412                    graph[i][j].get('weight', 1), links_index, arrows=Edge3D.ArrowV) for ((i, j), links_index) in zip(self.graph.edges(), links_indices)] 
    414413            else: 
    415                 edges = [Edge3D(vertices[i], vertices[j], 
     414                edges = [Edge3D(nodes[i], nodes[j], 
    416415                    graph[i][j].get('weight', 1), links_index) for ((i, j), links_index) in zip(self.graph.edges(), links_indices)] 
    417416        elif self.graph.is_directed(): 
    418             edges = [Edge3D(vertices[i], vertices[j], 
     417            edges = [Edge3D(nodes[i], nodes[j], 
    419418                                      graph[i][j].get('weight', 1), arrows=Edge3D.ArrowV) for (i, j) in self.graph.edges()] 
    420419        else: 
    421             edges = [Edge3D(vertices[i], vertices[j], 
     420            edges = [Edge3D(nodes[i], nodes[j], 
    422421                                      graph[i][j].get('weight', 1)) for (i, j) in self.graph.edges()] 
    423422 
    424423        self.set_edges(edges) 
    425         #self.update_properties() 
     424        self._nodes = nodes # Store references, so these objects are not destroyed 
     425        self._edges = edges 
    426426        self.update()   
    427427 
  • orange/OrangeWidgets/Visualize Qt/OWNxExplorerQt.py

    r8994 r9056  
    932932        self.set_items_distance_matrix(None) 
    933933        self.networkCanvas.set_graph(None) 
    934          
     934 
    935935    def set_graph(self, graph, curve=None): 
    936936        self.information() 
Note: See TracChangeset for help on using the changeset viewer.