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


Python Dot.create_svg方法代码示例

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


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

示例1: SysCDiagramPlugin

# 需要导入模块: from pydot import Dot [as 别名]
# 或者: from pydot.Dot import create_svg [as 别名]

#.........这里部分代码省略.........
        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:
            self.block_diagram.add_subgraph(clusters[sptr])
        for sptr in nodes:
            self.block_diagram.add_node(nodes[sptr])

        self._file_obj.write(self.block_diagram.create_svg())
        self.signalproxy.inferiorStoppedNormally.disconnect(self.update)
        self.showDiagram()

    def __buildHierachy(self, obj_dict, clusters, nodes):
        """ Build Cluster and Node hierachy for pydot
        """
        for ptr in obj_dict:
            obj = obj_dict[ptr]
            if ptr in (self.sysc_ports.keys()+self.sysc_prim_channels.keys()):
                continue

            if len(obj["children"].keys()) == 0:
                node = Node(obj["name"])
                nodes[ptr] = node
            else:
                clust = Cluster(obj["name"].replace(".", "_"),
                                color='red',
                                label=obj["name"])
                c_clusters = {}
                c_nodes = {}
                self.__buildHierachy(obj["children"], c_clusters, c_nodes)
                for sptr in c_clusters:
                    clust.add_subgraph(c_clusters[sptr])
                for sptr in c_nodes:
                    clust.add_node(c_nodes[sptr])
                clusters[ptr] = clust

    def __findSysCObjects(self, obj_vec, obj_type, dst_dict):
        """ Find sc_object from module, port and prim channel registry
        """
        for i in obj_vec.childs:
            ptr = i.value
开发者ID:dstoeg,项目名称:ricodebug,代码行数:70,代码来源:SysCDiagramPlugin.py


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