예제 #1
0
파일: graphview.py 프로젝트: emsrc/algraeph
 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")
예제 #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")
예제 #3
0
파일: graphview.py 프로젝트: emsrc/algraeph
 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())
예제 #4
0
파일: graphview.py 프로젝트: emsrc/algraeph
 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())
예제 #5
0
파일: graphview.py 프로젝트: emsrc/algraeph
 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())
예제 #6
0
파일: graphview.py 프로젝트: emsrc/algraeph
 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())
예제 #7
0
파일: graphview.py 프로젝트: emsrc/algraeph
 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())
예제 #8
0
파일: graphview.py 프로젝트: emsrc/algraeph
 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())
예제 #9
0
파일: graphview.py 프로젝트: emsrc/algraeph
 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())
예제 #10
0
파일: aligner.py 프로젝트: emsrc/algraeph
 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")
예제 #11
0
파일: graphview.py 프로젝트: emsrc/algraeph
 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())
예제 #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")
예제 #13
0
파일: graphview.py 프로젝트: emsrc/algraeph
 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())
예제 #14
0
파일: graphview.py 프로젝트: emsrc/algraeph
 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())
예제 #15
0
파일: graphview.py 프로젝트: emsrc/algraeph
 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())
예제 #16
0
파일: aligner.py 프로젝트: emsrc/algraeph
 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")
예제 #17
0
파일: graphview.py 프로젝트: emsrc/algraeph
 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())
예제 #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")
예제 #19
0
파일: aligner.py 프로젝트: emsrc/algraeph
 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")
예제 #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")
예제 #21
0
파일: graphview.py 프로젝트: emsrc/algraeph
    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()
예제 #22
0
파일: graphview.py 프로젝트: emsrc/algraeph
 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()
예제 #23
0
파일: graphview.py 프로젝트: emsrc/algraeph
    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")
예제 #24
0
파일: graphview.py 프로젝트: emsrc/algraeph
 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")
예제 #25
0
파일: aligner.py 프로젝트: emsrc/algraeph
 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")
예제 #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")
예제 #27
0
파일: aligner.py 프로젝트: emsrc/algraeph
    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)
예제 #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)
예제 #29
0
파일: graphview.py 프로젝트: emsrc/algraeph
 def onAutoFoldEquals(self, evt):
     """
     handler for the 'Auto Fold Equals' option in AlpinoViewMenu 
     """
     send(self.onAutoFoldEquals, "autoFoldEqualsChanged")
예제 #30
0
파일: graphviz.py 프로젝트: emsrc/algraeph
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")
예제 #31
0
파일: graphviz.py 프로젝트: emsrc/algraeph
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")
예제 #32
0
파일: graphview.py 프로젝트: emsrc/algraeph
 def onUnfoldAllNodes(self, evt):
     """
     handler for the 'Unfold All Nodes' option in GraphmlViewMenu 
     """
     send(self.onUnfoldAllNodes, "unfoldAllNodes")
예제 #33
0
파일: graphviz.py 프로젝트: emsrc/algraeph
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")
예제 #34
0
파일: graphviz.py 프로젝트: emsrc/algraeph
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")
예제 #35
0
 def onAutoFoldEquals(self, evt):
     """
     handler for the 'Auto Fold Equals' option in AlpinoViewMenu 
     """
     send(self.onAutoFoldEquals, "autoFoldEqualsChanged")
예제 #36
0
파일: graphview.py 프로젝트: emsrc/algraeph
 def onUnfoldAllNodes(self, evt):
     """
     handler for the 'Unfold All Nodes' option in GraphmlViewMenu 
     """
     send(self.onUnfoldAllNodes, "unfoldAllNodes")