当前位置: 首页>>代码示例>>Python>>正文


Python Dot.set_graph_defaults方法代码示例

本文整理汇总了Python中pydot.Dot.set_graph_defaults方法的典型用法代码示例。如果您正苦于以下问题:Python Dot.set_graph_defaults方法的具体用法?Python Dot.set_graph_defaults怎么用?Python Dot.set_graph_defaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pydot.Dot的用法示例。


在下文中一共展示了Dot.set_graph_defaults方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SysCDiagramPlugin

# 需要导入模块: from pydot import Dot [as 别名]
# 或者: from pydot.Dot import set_graph_defaults [as 别名]
class SysCDiagramPlugin():

    def initPlugin(self, signalproxy):
        """Initialise the systemc block diagram plugin"""

        self.signalproxy = signalproxy
        self.do = signalproxy.distributedObjects

        # systemc stuff and and pointer type strings needed for casting in gdb
        # because systemc objects can be systemc modules, systemc ports, etc.
        self.ctx = None
        self.ctx_pointer = None
        self.ctx_func = "sc_get_curr_simcontext()"
        self.ctx_found = False

        self.ctx_type = "(sc_core::sc_simcontext*)"
        self.port_type = "(sc_core::sc_port_base*)"
        self.module_type = "(sc_core::sc_module*)"
        self.object_type = "(sc_core::sc_object*)"
        self.prim_channel_type = "(sc_core::sc_prim_channel*)"

        # dict with a string that represents the pointer as key and
        # a nested dict with parent, children, etc as key-values
        #   dst_dict[ptr] = {"wrapper":    vw,
        #                    "name":       None,
        #                    "parent_ptr": None,
        #                    "children":   {}}
        self.sysc_modules = {}
        self.sysc_objects = {}
        self.sysc_ports = {}
        self.sysc_prim_channels = {}

        # because of how we built the interface for the tracepoints on the
        # datagraph we first need to create an file obj. We choose StringIO
        # because it uses a string as buffer and does not acces the filesystem
        self._file_obj = StringIO()
        self.image = SVGImage("SystemC Block Diagram", self._file_obj)
        self.image_wrapper = SVGDataGraphVW(self.image, self.do)

        self.signalproxy.inferiorStoppedNormally.connect(self.update)

        # hook Datagraph variable wrapper into the datagraph controller
        # after self.action.commit is called the image will be displayed at the
        # datagraph
        self.action = self.do.actions.\
            getAddSVGToDatagraphAction(self.image_wrapper,
                                       self.do.
                                       datagraphController.addVar)

        # pydot graph visualization library
        self.block_diagram = Dot(graph_type='digraph')
        self.block_diagram.set_graph_defaults(compound='true',
                                              splines='ortho',
                                              rankdir='LR')
        self.block_diagram.set_node_defaults(shape='box')

        # Needed for creating the right variables and variable wrappers from
        # the systemc pointers
        self.vwFactory = VarWrapperFactory()
        self.variableList = VariableList(self.vwFactory, self.do)

    def deInitPlugin(self):
        pass

    def evaluateExp(self, exp):
        return self.signalproxy.gdbEvaluateExpression(exp)

    def showDiagram(self):
        self.action.commit()

    def update(self):
        if not self.ctx_found and self.ctx is None:
            self.__findSimContext()
            if self.ctx is None:
                return
        else:
            # don't try to analyze if elaboration is not done
            if not cpp2py(self.ctx["m_elaboration_done"].value):
                return

        # prepare for easy information collection
        object_vec = self.ctx["m_child_objects"]

        # find all relevant information
        self.__findSysCObjects(object_vec, self.object_type, self.sysc_objects)

        # if there are no objects to draw than skip the drawing part
        # this might happen if you set the breakpoint before any objects are
        # created. This is actually catched above, but there might also be a
        # design with no objects.
        if len(self.sysc_objects.keys()) == 0:
            return

        clusters = {}
        nodes = {}

        # build pydot hierachy and add all subgraphs and nodes to the main
        # graph
        self.__buildHierachy(self.sysc_objects, clusters, nodes)
        for sptr in clusters:
#.........这里部分代码省略.........
开发者ID:dstoeg,项目名称:ricodebug,代码行数:103,代码来源:SysCDiagramPlugin.py


注:本文中的pydot.Dot.set_graph_defaults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。