示例#1
0
文件: HMMEd.py 项目: tempbottle/ghmm
    def OpenGraph(self):

        self.DeleteDrawItems()  # clear screen
        if self.hasGraph == 1:
            self.G.Clear()
            self.HMM.G.Clear()
            self.HMM.Clear()
            self.hasGraph = 0

        file = askopenfilename(title="Open HMM",
                               defaultextension=".xml",
                               filetypes=(("XML", ".xml"), ))
        if file is "":
            print "cancelled"
        else:
            self.fileName = file
            self.graphName = stripPath(file)
            e = extension(file)

            if e == 'xml':
                self.HMM.OpenXML(file)
            else:
                print "Unknown extension"
                return

        #self.HMM.hmmAlphabet ?
        #self.HMM.hmmClass    ?

            self.ShowGraph(self.HMM.G, self.graphName)
            self.RegisterGraphInformer(HMMInformer(self.HMM))
            self.SetTitle("HMMEd _VERSION_ - " + self.graphName)

            if not self.gridding:
                self.graphMenu.invoke(self.graphMenu.index('Grid'))
示例#2
0
文件: HMMEd.py 项目: tempbottle/ghmm
    def OpenGraph(self):

        self.DeleteDrawItems() # clear screen
	if self.hasGraph == 1:
            self.G.Clear()
	    self.HMM.G.Clear()
            self.HMM.Clear()
	    self.hasGraph = 0
	            
	file = askopenfilename(title="Open HMM",
			       defaultextension=".xml",
			       filetypes = (("XML", ".xml"),)
			       )
	if file is "": 
	    print "cancelled"
	else:
	    self.fileName = file
	    self.graphName = stripPath(file)
	    e = extension(file)
            
	    if e == 'xml':
		self.HMM.OpenXML(file)
	    else:
		print "Unknown extension"
		return

            #self.HMM.hmmAlphabet ?
            #self.HMM.hmmClass    ?
            
	    self.ShowGraph(self.HMM.G, self.graphName)
	    self.RegisterGraphInformer(HMMInformer(self.HMM))
	    self.SetTitle("HMMEd _VERSION_ - " + self.graphName)

	    if not self.gridding:
		self.graphMenu.invoke(self.graphMenu.index('Grid'))	
示例#3
0
 def OpenGraph(self):	
     file = askopenfilename(title="Open HMM",
                            defaultextension=".xml",
                            filetypes = (("XML", ".xml"),
                                         )
                            )
     if file is "": 
         print "cancelled"
     else:
         self.fileName = file
         self.graphName = stripPath(file)
         e = extension(file)
         
         if e == 'xml':
             self.HMM.OpenXML(file)
         else:
             print "Unknown extension"
             return
             
         self.ShowGraph(self.HMM.G, self.graphName)
         self.RegisterGraphInformer(HMMInformer(self.HMM))
         self.SetTitle("HMMEd _VERSION_ - " + self.graphName)
         
         if not self.gridding:
             self.graphMenu.invoke(self.graphMenu.index('Grid'))	
示例#4
0
    def OpenGraph(self):
        file = askopenfilename(title="Open HMM",
                               defaultextension=".xml",
                               filetypes=(("XML", ".xml"), ))
        if file is "":
            print "cancelled"
        else:
            self.fileName = file
            self.graphName = stripPath(file)
            e = extension(file)

            if e == 'xml':
                self.HMM.OpenXML(file)
            else:
                print "Unknown extension"
                return

            self.ShowGraph(self.HMM.G, self.graphName)
            self.RegisterGraphInformer(HMMInformer(self.HMM))
            self.SetTitle("HMMEd _VERSION_ - " + self.graphName)

            if not self.gridding:
                self.graphMenu.invoke(self.graphMenu.index('Grid'))
示例#5
0
    def OpenGraph(self):
        file = askopenfilename(
            title="Open Graph",
            defaultextension=".cat",
            filetypes=[("Gato", ".cat"), ("Dot", ".dotted")
                       #,("Graphlet", ".let")
                       ])
        if file is "":
            pass
        else:
            self.fileName = file
            self.dirty = 0
            self.graphName = stripPath(file)
            e = extension(file)
            if e == 'cat':
                G = OpenCATBoxGraph(file)
            elif e == 'gml':
                G = OpenGMLGraph(file)
            elif e == 'dotted':
                G = OpenDotGraph(file)
            else:
                log.error("Unknown extension %s" % e)

            if not self.gridding:
                self.graphMenu.invoke(self.graphMenu.index('Grid'))

            if G.QDirected() != self.directedVar.get():
                self.graphMenu.invoke(self.graphMenu.index('Directed'))

            if G.QEuclidian() != self.euclideanVar.get():
                self.graphMenu.invoke(self.graphMenu.index('Euclidean'))

            if G.edgeWeights[0].QInteger() != self.edgeIntegerWeightsVar.get():
                self.graphMenu.invoke(
                    self.graphMenu.index('Integer Edge Weights'))
                self.graphMenu.invoke(
                    self.graphMenu.index('Integer Vertex Weights'))
                # Just one integer flag for vertex and edge weights

            if G.NrOfEdgeWeights() == 1:
                self.edgeWeightsSubmenu.invoke(
                    self.edgeWeightsSubmenu.index('One'))
            elif G.NrOfEdgeWeights() == 2:
                self.edgeWeightsSubmenu.invoke(
                    self.edgeWeightsSubmenu.index('Two'))
            elif G.NrOfEdgeWeights() == 3:
                self.edgeWeightsSubmenu.invoke(
                    self.edgeWeightsSubmenu.index('Three'))

            if G.NrOfVertexWeights() == 0 or (G.NrOfVertexWeights() > 0 and
                                              G.vertexWeights[0].QInteger()):
                self.graphMenu.invoke(
                    self.graphMenu.index('Integer Vertex Weights'))

            if G.NrOfVertexWeights() == 0:
                self.vertexWeightsSubmenu.invoke(
                    self.vertexWeightsSubmenu.index('None'))
            elif G.NrOfVertexWeights() == 1:
                self.vertexWeightsSubmenu.invoke(
                    self.vertexWeightsSubmenu.index('One'))
            elif G.NrOfVertexWeights() == 2:
                self.vertexWeightsSubmenu.invoke(
                    self.vertexWeightsSubmenu.index('Two'))
            elif G.NrOfVertexWeights() == 3:
                self.vertexWeightsSubmenu.invoke(
                    self.vertexWeightsSubmenu.index('Three'))

            self.RegisterGraphInformer(WeightedGraphInformer(G, "weight"))
            self.ShowGraph(G, self.graphName)

            if e == 'dotted':  # Show annotations
                for v in G.Vertices():
                    self.SetVertexAnnotation(v, self.G.vertexAnnotation[v])
                for e in G.Edges():
                    self.SetEdgeAnnotation(e[0], e[1],
                                           self.G.edgeAnnotation[e])

            self.SetTitle("Gred %s - %s" (GatoGlobals.gatoVersion,
                                          self.graphName))
示例#6
0
 def OpenGraph(self):	
     file = askopenfilename(title="Open Graph",
                            defaultextension=".cat",
                            filetypes = [("Gato", ".cat"),
                                         ("Dot", ".dotted")
                                          #,("Graphlet", ".let")
                                        ]
                            )
     if file is "": 
         pass
     else:
         self.fileName = file
         self.dirty = 0
         self.graphName = stripPath(file)
         e = extension(file)
         if e == 'cat':
             G = OpenCATBoxGraph(file)
         elif e == 'gml':
             G = OpenGMLGraph(file)
         elif e == 'dotted':
             G = OpenDotGraph(file)
         else:
             log.error("Unknown extension %s" % e)
             
         if not self.gridding:
             self.graphMenu.invoke(self.graphMenu.index('Grid'))	
             
         if G.QDirected() != self.directedVar.get():
             self.graphMenu.invoke(self.graphMenu.index('Directed'))	
             
         if G.QEuclidian() != self.euclideanVar.get():
             self.graphMenu.invoke(self.graphMenu.index('Euclidean'))	
             
         if G.edgeWeights[0].QInteger() != self.edgeIntegerWeightsVar.get():
             self.graphMenu.invoke(self.graphMenu.index('Integer Edge Weights'))
             self.graphMenu.invoke(self.graphMenu.index('Integer Vertex Weights')) 
             # Just one integer flag for vertex and edge weights 
             
         if G.NrOfEdgeWeights() == 1:
             self.edgeWeightsSubmenu.invoke(self.edgeWeightsSubmenu.index('One'))
         elif G.NrOfEdgeWeights() == 2:
             self.edgeWeightsSubmenu.invoke(self.edgeWeightsSubmenu.index('Two'))
         elif G.NrOfEdgeWeights() == 3:
             self.edgeWeightsSubmenu.invoke(self.edgeWeightsSubmenu.index('Three')) 
             
         if G.NrOfVertexWeights() == 0 or (G.NrOfVertexWeights() > 0 and 
                                           G.vertexWeights[0].QInteger()):
             self.graphMenu.invoke(self.graphMenu.index('Integer Vertex Weights'))
             
             
         if G.NrOfVertexWeights() == 0:
             self.vertexWeightsSubmenu.invoke(self.vertexWeightsSubmenu.index('None'))
         elif G.NrOfVertexWeights() == 1:
             self.vertexWeightsSubmenu.invoke(self.vertexWeightsSubmenu.index('One'))
         elif G.NrOfVertexWeights() == 2:
             self.vertexWeightsSubmenu.invoke(self.vertexWeightsSubmenu.index('Two'))
         elif G.NrOfVertexWeights() == 3:
             self.vertexWeightsSubmenu.invoke(self.vertexWeightsSubmenu.index('Three'))
             
             
             
         self.RegisterGraphInformer(WeightedGraphInformer(G,"weight"))
         self.ShowGraph(G,self.graphName)
         
         if e == 'dotted': # Show annotations
             for v in G.Vertices():
                 self.SetVertexAnnotation(v,self.G.vertexAnnotation[v])
             for e in G.Edges():
                 self.SetEdgeAnnotation(e[0],e[1],self.G.edgeAnnotation[e])
                 
                 
         self.SetTitle("Gred %s - %s" (GatoGlobals.gatoVersion,self.graphName))
示例#7
0
    def OpenGraph(self,dummy=None,fileName=None):
        if self.dirty == 1:
            if not askokcancel("Open Graph","Graph changed since last saved."\
                               "Do you want to overwrite it?"):
                return
	if fileName == None:
            fileName = askopenfilename(title="Open Graph",
                                       defaultextension=".cat",
                                       filetypes = [("Gato", ".cat"),
                                                    ("Dot", ".dotted")
                                                    #,("Graphlet", ".let")
                                                    ]
                                       )
        if fileName != "" and fileName != (): 
            self.fileName = fileName
            self.graphName = stripPath(fileName)
            e = extension(fileName)
            if e == 'cat':
                G = OpenCATBoxGraph(fileName)
            elif e == 'gml':
                G = OpenGMLGraph(fileName)
            elif e == 'dotted':
                G = OpenDotGraph(fileName)
            else:
                log.error("Unknown extension %s" % e)
                
            if not self.gridding:
                self.graphMenu.invoke(self.graphMenu.index('Grid'))	
                
            if G.QDirected() != self.directedVar.get():
                self.graphMenu.invoke(self.graphMenu.index('Directed'))	
                
            if G.QEuclidian() != self.euclideanVar.get():
                self.graphMenu.invoke(self.graphMenu.index('Euclidean'))	
                
            if G.edgeWeights[0].QInteger() != self.edgeIntegerWeightsVar.get():
                self.graphMenu.invoke(self.graphMenu.index('Integer Edge Weights'))
                self.graphMenu.invoke(self.graphMenu.index('Integer Vertex Weights')) 
                # Just one integer flag for vertex and edge weights 
                
            if G.NrOfEdgeWeights() == 1:
                self.edgeWeightsSubmenu.invoke(self.edgeWeightsSubmenu.index('One'))
            elif G.NrOfEdgeWeights() == 2:
                self.edgeWeightsSubmenu.invoke(self.edgeWeightsSubmenu.index('Two'))
            elif G.NrOfEdgeWeights() == 3:
                self.edgeWeightsSubmenu.invoke(self.edgeWeightsSubmenu.index('Three')) 
                
            if G.NrOfVertexWeights() == 0 or (G.NrOfVertexWeights() > 0 and 
                                              G.vertexWeights[0].QInteger()):
                self.graphMenu.invoke(self.graphMenu.index('Integer Vertex Weights'))
                
                
            if G.NrOfVertexWeights() == 0:
                self.vertexWeightsSubmenu.invoke(self.vertexWeightsSubmenu.index('None'))
            elif G.NrOfVertexWeights() == 1:
                self.vertexWeightsSubmenu.invoke(self.vertexWeightsSubmenu.index('One'))
            elif G.NrOfVertexWeights() == 2:
                self.vertexWeightsSubmenu.invoke(self.vertexWeightsSubmenu.index('Two'))
            elif G.NrOfVertexWeights() == 3:
                self.vertexWeightsSubmenu.invoke(self.vertexWeightsSubmenu.index('Three'))
                
                
                
            self.RegisterGraphInformer(WeightedGraphInformer(G,"weight"))
            self.ShowGraph(G,self.graphName)
            
            if e == 'dotted': # Show annotations
                for v in G.Vertices():
                    self.SetVertexAnnotation(v,self.G.vertexAnnotation[v])
                for e in G.Edges():
                    self.SetEdgeAnnotation(e[0],e[1],self.G.edgeAnnotation[e])
                    
                    
            self.SetTitle("Gred %s - %s" % (self.graphName, gatoBuildDate))
            self.makeDirty()
            self.dirty = 0
示例#8
0
    def OpenGraph(self, dummy=None):
        if self.dirty == 1:
            if not askokcancel(
                    "Open Graph",
                    "Graph changed since last saved. Do you want to overwrite it?"
            ):
                return

        file = askopenfilename(
            title="Open Graph",
            defaultextension=".cat",
            filetypes=[("Gato", ".cat"), ("Dot", ".dotted")
                       #,("Graphlet", ".let")
                       ])
        if file != "" and file != ():
            self.fileName = file
            self.graphName = stripPath(file)
            e = extension(file)
            if e == 'cat':
                G = OpenCATBoxGraph(file)
            elif e == 'gml':
                G = OpenGMLGraph(file)
            elif e == 'dotted':
                G = OpenDotGraph(file)
            else:
                log.error("Unknown extension %s" % e)

            if not self.gridding:
                self.graphMenu.invoke(self.graphMenu.index('Grid'))

            if G.QDirected() != self.directedVar.get():
                self.graphMenu.invoke(self.graphMenu.index('Directed'))

            if G.QEuclidian() != self.euclideanVar.get():
                self.graphMenu.invoke(self.graphMenu.index('Euclidean'))

            if G.edgeWeights[0].QInteger() != self.edgeIntegerWeightsVar.get():
                self.graphMenu.invoke(
                    self.graphMenu.index('Integer Edge Weights'))
                self.graphMenu.invoke(
                    self.graphMenu.index('Integer Vertex Weights'))
                # Just one integer flag for vertex and edge weights

            if G.NrOfEdgeWeights() == 1:
                self.edgeWeightsSubmenu.invoke(
                    self.edgeWeightsSubmenu.index('One'))
            elif G.NrOfEdgeWeights() == 2:
                self.edgeWeightsSubmenu.invoke(
                    self.edgeWeightsSubmenu.index('Two'))
            elif G.NrOfEdgeWeights() == 3:
                self.edgeWeightsSubmenu.invoke(
                    self.edgeWeightsSubmenu.index('Three'))

            if G.NrOfVertexWeights() == 0 or (G.NrOfVertexWeights() > 0 and
                                              G.vertexWeights[0].QInteger()):
                self.graphMenu.invoke(
                    self.graphMenu.index('Integer Vertex Weights'))

            if G.NrOfVertexWeights() == 0:
                self.vertexWeightsSubmenu.invoke(
                    self.vertexWeightsSubmenu.index('None'))
            elif G.NrOfVertexWeights() == 1:
                self.vertexWeightsSubmenu.invoke(
                    self.vertexWeightsSubmenu.index('One'))
            elif G.NrOfVertexWeights() == 2:
                self.vertexWeightsSubmenu.invoke(
                    self.vertexWeightsSubmenu.index('Two'))
            elif G.NrOfVertexWeights() == 3:
                self.vertexWeightsSubmenu.invoke(
                    self.vertexWeightsSubmenu.index('Three'))

            self.RegisterGraphInformer(WeightedGraphInformer(G, "weight"))
            self.ShowGraph(G, self.graphName)

            if e == 'dotted':  # Show annotations
                for v in G.Vertices():
                    self.SetVertexAnnotation(v, self.G.vertexAnnotation[v])
                for e in G.Edges():
                    self.SetEdgeAnnotation(e[0], e[1],
                                           self.G.edgeAnnotation[e])

            self.SetTitle("Gred 0.99 - " + self.graphName)
            self.dirty = 0