Ignore:
Timestamp:
03/06/13 14:23:08 (14 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Added 'clear' method to Scheme class.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/scheme/scheme.py

    r11367 r11385  
    545545        self.annotation_removed.emit(annotation) 
    546546 
     547    def clear(self): 
     548        """ 
     549        Remove all nodes, links, and annotation items from the scheme. 
     550        """ 
     551        def is_terminal(node): 
     552            return not bool(self.find_links(source_node=node)) 
     553 
     554        while self.nodes: 
     555            terminal_nodes = filter(is_terminal, self.nodes) 
     556            for node in terminal_nodes: 
     557                self.remove_node(node) 
     558 
     559        for annotation in self.annotations: 
     560            self.remove_annotation(annotation) 
     561 
     562        assert(not (self.nodes or self.links or self.annotations)) 
     563 
    547564    def save_to(self, stream, pretty=True): 
    548565        """ 
Note: See TracChangeset for help on using the changeset viewer.