Go to the documentation of this file.00001
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
00015 QtGui.QGraphicsScene.__init__(self)
00016
00017
00018 self._dot_to_qt = DotToQtGenerator()
00019
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
00028 self.clear()
00029 highlight_level = 3
00030
00031 dot = self._dot_factory.create_dot(self._graph)
00032
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())