dot_graph.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 '''
00003 Created on Sep 10, 2013
00004  \todo Add license information here
00005 @author: dnad
00006 '''
00007 from python_qt_binding import QtGui
00008 from qt_dotgraph.dot_to_qt import DotToQtGenerator
00009 from qt_dotgraph.pydotfactory import PydotFactory 
00010 import pydot
00011 
00012 class DotGraph(QtGui.QGraphicsScene):
00013     def __init__(self):
00014         #Init the base class
00015         QtGui.QGraphicsScene.__init__(self)
00016         
00017         # dot_to_qt transforms into Qt elements using dot layout
00018         self._dot_to_qt = DotToQtGenerator()
00019         #The pydotfactory
00020         self._dot_factory = PydotFactory()
00021         self._graph = None      
00022         pass
00023     
00024     def drawDot(self, data):        
00025         self._graph = pydot.dot_parser.parse_dot_data(data)
00026         
00027         #Clean current drawing
00028         self.clear()
00029         highlight_level = 3
00030  
00031         dot = self._dot_factory.create_dot(self._graph)
00032         # layout graph and create qt items
00033         (nodes, edges) = self._dot_to_qt.dotcode_to_qt_items(dot,
00034                                                             highlight_level,
00035                                                             True)
00036  
00037         for node_item in nodes.itervalues():
00038             self.addItem(node_item)
00039         for edge_items in edges.itervalues():
00040             for edge_item in edge_items:
00041                 edge_item.add_to_scene(self)
00042  
00043         self.setSceneRect(self.itemsBoundingRect())


labust_gui
Author(s): Gyula Nagy
autogenerated on Fri Feb 7 2014 11:36:55