Exemple #1
0
 def onOrderNodes(self, evt):
     """
     handler for the 'Order Nodes' option in AlpinoViewMenu 
     """
     self.dotGraphPair.from_subgraph.order_nodes_option(evt.Checked())
     self.dotGraphPair.to_subgraph.order_nodes_option(evt.Checked())
     send(self.onOrderNodes, "orderNodesChanged")
Exemple #2
0
 def onOrderNodes(self, evt):
     """
     handler for the 'Order Nodes' option in AlpinoViewMenu 
     """
     self.dotGraphPair.from_subgraph.order_nodes_option(evt.Checked())
     self.dotGraphPair.to_subgraph.order_nodes_option(evt.Checked())
     send(self.onOrderNodes, "orderNodesChanged")
Exemple #3
0
 def onHideAlignments(self, evt):
     """
     handler for the 'Hide Alignments' option in View menu 
     """
     self.dotGraphPair.hide_alignments_option(evt.Checked())
     send(self.onHideAlignments, "hideAlignmentsChanged")
     send(self.onHideAlignments, "statusDescription", 
          "Hide Alignments option is %s" % evt.Checked())
Exemple #4
0
 def onMarkSelectedAlignments(self, evt):
     """
     handler for the 'Mark Selected Alignments' option in View menu 
     """
     self.dotGraphPair.mark_selected_alignments_option(evt.Checked())
     send(self.onLabelEdges, "markSelectedAlignmentsChanged")
     send(self.onMarkSelectedAlignments, "statusDescription", 
          "Mark Selected Alignments option is %s" % evt.Checked())
Exemple #5
0
 def onMarkAlignedNodes(self, evt):
     """
     handler for the 'Mark Aligned Nodes" in the View menu
     """
     self.dotGraphPair.mark_aligned_nodes_option(evt.Checked())
     send(self.onMarkAlignedNodes, "markAlignedNodesChanged")
     send(self.onMarkAlignedNodes, "statusDescription",
          "Mark Aligned Nodes option is %s" % evt.Checked())
Exemple #6
0
 def onHideAlignments(self, evt):
     """
     handler for the 'Hide Alignments' option in View menu 
     """
     self.dotGraphPair.hide_alignments_option(evt.Checked())
     send(self.onHideAlignments, "hideAlignmentsChanged")
     send(self.onHideAlignments, "statusDescription",
          "Hide Alignments option is %s" % evt.Checked())
Exemple #7
0
 def onCoSelectAlignedNode(self, evt):
     """
     handler for the 'Co-select Aligned Node' option in the View menu 
     """
     self.aligner.co_node_selection_mode(evt.Checked())
     send(self.onCoSelectAlignedNode, "coSelectAlignedNodeChanged")
     send(self.onCoSelectAlignedNode, "statusDescription",
          "Co-select Aligned Node option is %s" % evt.Checked())
Exemple #8
0
 def onMarkSelectedAlignments(self, evt):
     """
     handler for the 'Mark Selected Alignments' option in View menu 
     """
     self.dotGraphPair.mark_selected_alignments_option(evt.Checked())
     send(self.onLabelEdges, "markSelectedAlignmentsChanged")
     send(self.onMarkSelectedAlignments, "statusDescription",
          "Mark Selected Alignments option is %s" % evt.Checked())
Exemple #9
0
 def onMarkAlignedNodes(self, evt):
     """
     handler for the 'Mark Aligned Nodes" in the View menu
     """
     self.dotGraphPair.mark_aligned_nodes_option(evt.Checked())
     send(self.onMarkAlignedNodes, "markAlignedNodesChanged")
     send(self.onMarkAlignedNodes, "statusDescription", 
          "Mark Aligned Nodes option is %s" % evt.Checked())
Exemple #10
0
 def set_to_node(self, node=None):
     self._nodes.target = node
     
     if self._co_node_selection:
         self._nodes.source = self.get_aligned_from_node()
         
     send(self.set_to_node, "newNodeSelect.viz")
     send(self.set_to_node, "newNodeSelect.gui")
Exemple #11
0
 def onCoSelectAlignedNode(self, evt):
     """
     handler for the 'Co-select Aligned Node' option in the View menu 
     """
     self.aligner.co_node_selection_mode(evt.Checked())
     send(self.onCoSelectAlignedNode, "coSelectAlignedNodeChanged")
     send(self.onCoSelectAlignedNode, "statusDescription", 
          "Co-select Aligned Node option is %s" % evt.Checked())
Exemple #12
0
    def set_to_node(self, node=None):
        self._nodes.target = node

        if self._co_node_selection:
            self._nodes.source = self.get_aligned_from_node()

        send(self.set_to_node, "newNodeSelect.viz")
        send(self.set_to_node, "newNodeSelect.gui")
Exemple #13
0
 def onMarkSelectedNodes(self, evt):
     """
     handler for the 'Mark Selected Nodes" in the View menu
     """
     self.dotGraphPair.from_subgraph.mark_selected_nodes_option(evt.Checked())
     self.dotGraphPair.to_subgraph.mark_selected_nodes_option(evt.Checked())
     send(self.onMarkSelectedNodes, "markSelectedNodesChanged")
     send(self.onMarkSelectedNodes, "statusDescription", 
          "Mark Selected Nodes option is %s" % evt.Checked())
Exemple #14
0
 def onLabelEdges(self, evt):
     """
     handler for the 'Label Edges' option in the View menu 
     """
     self.dotGraphPair.from_subgraph.label_edges_option(evt.Checked())
     self.dotGraphPair.to_subgraph.label_edges_option(evt.Checked())
     send(self.onLabelEdges, "labelEdgesChanged")
     send(self.onLabelEdges, "statusDescription",
          "Label Edges option is %s" % evt.Checked())
Exemple #15
0
 def onLabelEdges(self, evt):
     """
     handler for the 'Label Edges' option in the View menu 
     """
     self.dotGraphPair.from_subgraph.label_edges_option(evt.Checked())
     self.dotGraphPair.to_subgraph.label_edges_option(evt.Checked())
     send(self.onLabelEdges, "labelEdgesChanged")
     send(self.onLabelEdges, "statusDescription", 
          "Label Edges option is %s" % evt.Checked())
Exemple #16
0
 def goto_graph_pair(self, index):
     # don't use try-except here, because negative index is allowed for list
     if 0 <= index < len(self._corpus):
         self._graph_pair = self._corpus[index]
         self._graph_pair_index = index
         self._graphs = self._graph_pair.get_graphs()
         self._nodes = Pair(None, None)
         
         send(self.goto_graph_pair, "newGraphPair.viz")
         send(self.goto_graph_pair, "newGraphPair.gui")
Exemple #17
0
 def onMarkSelectedNodes(self, evt):
     """
     handler for the 'Mark Selected Nodes" in the View menu
     """
     self.dotGraphPair.from_subgraph.mark_selected_nodes_option(
         evt.Checked())
     self.dotGraphPair.to_subgraph.mark_selected_nodes_option(evt.Checked())
     send(self.onMarkSelectedNodes, "markSelectedNodesChanged")
     send(self.onMarkSelectedNodes, "statusDescription",
          "Mark Selected Nodes option is %s" % evt.Checked())
Exemple #18
0
    def goto_graph_pair(self, index):
        # don't use try-except here, because negative index is allowed for list
        if 0 <= index < len(self._corpus):
            self._graph_pair = self._corpus[index]
            self._graph_pair_index = index
            self._graphs = self._graph_pair.get_graphs()
            self._nodes = Pair(None, None)

            send(self.goto_graph_pair, "newGraphPair.viz")
            send(self.goto_graph_pair, "newGraphPair.gui")
Exemple #19
0
 def set_node_pair_relation(self, relation):
     if self.nodes_are_selected():
         if relation != self._no_relation:
             self._graph_pair.add_align(self._nodes, relation)
         else:
             self._graph_pair.del_align(self._nodes)
             
         self._changed = True
             
         send(self.set_node_pair_relation, "newRelation.viz")
         send(self.set_node_pair_relation, "newRelation.gui")
Exemple #20
0
    def set_node_pair_relation(self, relation):
        if self.nodes_are_selected():
            if relation != self._no_relation:
                self._graph_pair.add_align(self._nodes, relation)
            else:
                self._graph_pair.del_align(self._nodes)

            self._changed = True

            send(self.set_node_pair_relation, "newRelation.viz")
            send(self.set_node_pair_relation, "newRelation.gui")
Exemple #21
0
    def onSaveImage(self, evt):
        """
        handler for the 'Save Image' option in View menu 
        """
        formats = get_output_formats()

        if "png" in formats:
            formats.remove("png")
            formats = ["png"] + formats
        else:
            formats.remove("dot")
            formats = ["dot"] + formats

        wildcard = ""

        for s in formats:
            wildcard += s + " (*." + s + ")|" + "*." + s + "|"

        wildcard = wildcard[:-1]

        filename = self.aligner.get_corpus_filename()
        filename = splitext(basename(filename))[0]
        filename += "_%d" % self.aligner.get_graph_pair_counter()[0]
        filename += "." + formats[0]

        dlg = wx.FileDialog(self,
                            "Save image...",
                            defaultFile=filename,
                            defaultDir=self.aligner.get_corpus_dir()
                            or getcwd(),
                            style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT,
                            wildcard=wildcard)

        if dlg.ShowModal() == wx.ID_OK:
            file = dlg.GetPath()
            if " " in file:
                file = '"' + file + '"'
            form = formats[dlg.GetFilterIndex()]

            send(self.onSaveImage, "statusDescription",
                 "Saving image to file %s ..." % file)
            draw(self.dotGraphPair.to_string(), img_file=file, img_format=form)
            send(self.onSaveImage, "statusDescription",
                 "Saved image to file %s" % file)

        dlg.Destroy()
Exemple #22
0
 def onSaveImage(self, evt):
     """
     handler for the 'Save Image' option in View menu 
     """
     formats = get_output_formats()
     
     if "png" in formats:
         formats.remove("png")
         formats = ["png"] + formats
     else:
         formats.remove("dot")
         formats = ["dot"] + formats
         
     wildcard = ""
     
     for s in formats:
         wildcard += s + " (*." + s + ")|" + "*." + s + "|"
         
     wildcard = wildcard[:-1]
     
     filename = self.aligner.get_corpus_filename()
     filename = splitext(basename(filename))[0]
     filename += "_%d" % self.aligner.get_graph_pair_counter()[0]
     filename += "." + formats[0]
     
     dlg = wx.FileDialog(self, "Save image...", 
                         defaultFile=filename,
                         defaultDir=self.aligner.get_corpus_dir() or getcwd(),
                         style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT,
                         wildcard =wildcard)
     
     if dlg.ShowModal() == wx.ID_OK:
         file = dlg.GetPath()
         if " " in file:
             file = '"' + file + '"'
         form = formats[dlg.GetFilterIndex()]
         
         send(self.onSaveImage, "statusDescription", "Saving image to file %s ..." % file)
         draw(self.dotGraphPair.to_string(), img_file=file, img_format=form)
         send(self.onSaveImage, "statusDescription", "Saved image to file %s" % file)
         
     dlg.Destroy()
Exemple #23
0
    def onToggleFold(self, evt=None):
        if self.node.startswith(self.from_node_prefix):
            node = self.node[len(self.from_node_prefix):]
            graph = self.aligner.get_from_graph()

            if graph.node_is_terminal(node):
                return

            self.dotGraphPair.from_subgraph.toggle_node_fold(graph, node)
        elif self.node.startswith(self.to_node_prefix):
            node = self.node[len(self.to_node_prefix):]
            graph = self.aligner.get_to_graph()

            if graph.node_is_terminal(node):
                return

            self.dotGraphPair.to_subgraph.toggle_node_fold(graph, node)
        else:
            # Mouse not on a node. Should not happen, because in that case the
            # "Fold Node" menu item is disabled.
            return

        send(self.onToggleFold, "foldNodeChanged")
Exemple #24
0
 def onToggleFold(self, evt=None):    
     if self.node.startswith(self.from_node_prefix):
         node = self.node[len(self.from_node_prefix):]
         graph = self.aligner.get_from_graph()
         
         if graph.node_is_terminal(node):
             return
         
         self.dotGraphPair.from_subgraph.toggle_node_fold(graph, node)
     elif self.node.startswith(self.to_node_prefix):
         node = self.node[len(self.to_node_prefix):]
         graph = self.aligner.get_to_graph()
         
         if graph.node_is_terminal(node):
             return
         
         self.dotGraphPair.to_subgraph.toggle_node_fold(graph, node)
     else:
         # Mouse not on a node. Should not happen, because in that case the
         # "Fold Node" menu item is disabled.
         return
     
     send(self.onToggleFold, "foldNodeChanged")
Exemple #25
0
 def save_corpus(self, filename=None):
     if filename:
         self._filename = filename
         send(self.save_corpus, "newCorpusName")
         
     send(self.save_corpus, "statusDescription", "Saving corpus %s ..." % self._filename)        
     
     self._corpus.write(self._filename, pprint=True)
     self._changed = False
         
     send(self.save_corpus, "statusDescription")
Exemple #26
0
    def save_corpus(self, filename=None):
        if filename:
            self._filename = filename
            send(self.save_corpus, "newCorpusName")

        send(self.save_corpus, "statusDescription",
             "Saving corpus %s ..." % self._filename)

        self._corpus.write(self._filename, pprint=True)
        self._changed = False

        send(self.save_corpus, "statusDescription")
Exemple #27
0
    def open_corpus(self, filename):
        send(self.open_corpus, "statusDescription", "Loading corpus %s ..." % filename)

        # May raise errors such IOErrors, not an xml file, corrupt format, etc.
        # Use of relax_gb_paths allows graphbank files to be located in the
        # same direcory as the corpus file instead of the location specified
        # in the <file> element
        corpus = ParallelGraphCorpus()
        corpus.read(inf=filename, relax_gb_paths=True)
        
        if not corpus:
            raise AlgraephException("Parallel graph corpus contains no alignments")
        
        self._corpus = corpus
        self._filename = filename
        self._changed = False
            
        send(self.open_corpus, "statusDescription")
        send(self.open_corpus, "newCorpus")
        send(self.open_corpus, "newCorpusName")

        self.goto_graph_pair(0)
Exemple #28
0
    def open_corpus(self, filename):
        send(self.open_corpus, "statusDescription",
             "Loading corpus %s ..." % filename)

        # May raise errors such IOErrors, not an xml file, corrupt format, etc.
        # Use of relax_gb_paths allows graphbank files to be located in the
        # same direcory as the corpus file instead of the location specified
        # in the <file> element
        corpus = ParallelGraphCorpus()
        corpus.read(inf=filename, relax_gb_paths=True)

        if not corpus:
            raise AlgraephException(
                "Parallel graph corpus contains no alignments")

        self._corpus = corpus
        self._filename = filename
        self._changed = False

        send(self.open_corpus, "statusDescription")
        send(self.open_corpus, "newCorpus")
        send(self.open_corpus, "newCorpusName")

        self.goto_graph_pair(0)
Exemple #29
0
 def onAutoFoldEquals(self, evt):
     """
     handler for the 'Auto Fold Equals' option in AlpinoViewMenu 
     """
     send(self.onAutoFoldEquals, "autoFoldEqualsChanged")
Exemple #30
0
def update_image_file(graph):
    log.debug("call to daeso.graphviz.update_image_file")
    send(update_image_file, "statusDescription", "Loading image...")
    draw(graph)
    send(update_image_file, "statusDescription")
Exemple #31
0
def update_image_map(graph):
    log.debug("call to daeso.graphviz.update_image_map")
    global __img_map
    send(update_image_map, "statusDescription", "Loading image map...")
    __img_map = draw(graph, img_format="cmap", img_file=None)
    send(update_image_map, "statusDescription")
Exemple #32
0
 def onUnfoldAllNodes(self, evt):
     """
     handler for the 'Unfold All Nodes' option in GraphmlViewMenu 
     """
     send(self.onUnfoldAllNodes, "unfoldAllNodes")
Exemple #33
0
def update_image_file(graph):
    log.debug("call to daeso.graphviz.update_image_file")
    send(update_image_file, "statusDescription", "Loading image...")
    draw(graph)
    send(update_image_file, "statusDescription")
Exemple #34
0
def update_image_map(graph):
    log.debug("call to daeso.graphviz.update_image_map")
    global __img_map
    send(update_image_map, "statusDescription", "Loading image map...")
    __img_map = draw(graph, img_format="cmap", img_file=None)
    send(update_image_map, "statusDescription")
Exemple #35
0
 def onAutoFoldEquals(self, evt):
     """
     handler for the 'Auto Fold Equals' option in AlpinoViewMenu 
     """
     send(self.onAutoFoldEquals, "autoFoldEqualsChanged")
Exemple #36
0
 def onUnfoldAllNodes(self, evt):
     """
     handler for the 'Unfold All Nodes' option in GraphmlViewMenu 
     """
     send(self.onUnfoldAllNodes, "unfoldAllNodes")