def __init__(self, gloss_text='', comments=None, syntax=None): """ Create an empty forest. Gloss_text and comments are metadata about trees that doesn't belong to syntax implementation, so its kept here. Syntax implementations may still use it. By default, a new Forest doesn't create its nodes -- it doesn't do the derivation yet. This is to save speed and memory with large structures. If the is_parsed -flag is False when created, but once Forest is displayed, the derivation has to run and after that is_parsed is True. """ super().__init__() self.nodes_from_synobs = {} self.main = ctrl.main self.main.forest = self # assign self to be the active forest while # creating the managers. self.in_display = False self.visualization = None self.gloss = None self.is_parsed = False self.syntax = syntax or classes.get('SyntaxConnection')() self.parser = INodeToKatajaConstituent(self) self.undo_manager = UndoManager(self) self.chain_manager = ChainManager(self) self.tree_manager = TreeManager(self) self.free_drawing = FreeDrawing(self) self.projection_manager = ProjectionManager(self) self.derivation_steps = DerivationStepManager(self) self.old_label_mode = 0 self.trees = [] self.nodes = {} self.edges = {} self.groups = {} self.others = {} self.vis_data = {} self.width_map = {} self.traces_to_draw = {} self.comments = [] self.gloss_text = '' self.ongoing_animations = set() self.halt_drawing = False self.gloss_text = gloss_text self.comments = comments # Update request flags self._do_edge_visibility_check = False
def clear(self): if self.in_display: for item in self.get_all_objects(): self.remove_from_scene(item, fade_out=False) self.nodes_from_synobs = {} self.gloss = None self.parser = INodeToKatajaConstituent(self) self.undo_manager = UndoManager(self) self.chain_manager = ChainManager(self) self.tree_manager = TreeManager(self) self.free_drawing = FreeDrawing(self) self.projection_manager = ProjectionManager(self) self.derivation_steps = DerivationStepManager(self) self.trees = [] self.nodes = {} self.edges = {} self.groups = {} self.others = {} self.width_map = {} self.traces_to_draw = {} self.comments = [] self.gloss_text = ''