Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 from airbus_docgen import env
00019 from airbus_docgen.common.html import HtmlElement
00020 from airbus_docgen.digraph.digraph import *
00021 import catkin_pkg.workspaces
00022 import os
00023
00024 class RosWorkspace(HtmlElement):
00025
00026 def __init__(self, packages_dir_list):
00027 HtmlElement.__init__(self,
00028 tag=html.Sections.article,
00029 attrib={"class":"ros_ws"})
00030
00031 self.generate_ws_dot(packages_dir_list)
00032
00033 a = HtmlElement(html.Text.a)
00034 a.set(html.Attrib.href,"../dot/agi_workspace.png")
00035 a.set("target", "_blank")
00036
00037 p = HtmlElement(html.Grouping.p)
00038 p.set("align","center")
00039
00040 img = HtmlElement(html.EmbeddedContent.img)
00041 img.set("src","../dot/agi_workspace.png")
00042 img.set("width","1024")
00043 img.set("height","150")
00044
00045 p.append(img)
00046
00047 a.append(p)
00048
00049 self.append(a)
00050
00051 def generate_ws_dot(self, packages_dir):
00052
00053 digraph = Digraph("AgiWorksapce")
00054 digraph.setAttrib(Digraph.NODESEP, 0.1)
00055
00056 nconf = NODE("node")
00057 nconf.setAttrib(NODE.SHAPE, SHAPE.Plaintext)
00058 digraph.addNode(nconf)
00059
00060 pkg = NODE("ROS_WORKSPACE")
00061 pkg.setAttrib(NODE.SHAPE, SHAPE.Box)
00062 pkg.setAttrib(NODE.STYLE, STYLE.FILLED)
00063 pkg.setAttrib(NODE.COLOR, RgbColor.CornflowerBlue)
00064 digraph.addRootNode(pkg)
00065
00066 connection_register = []
00067
00068 for directory in packages_dir:
00069 rpkg = directory
00070 path = rpkg.split('/')
00071
00072 for i in range(1,len(path)-1):
00073
00074 conn = "%s->%s"%(path[i], path[i+1])
00075
00076 if conn not in connection_register and path[i] != path[i+1]:
00077 n1 = NODE(path[i])
00078 n1.setAttrib(NODE.SHAPE, SHAPE.Box)
00079 n1.setAttrib(NODE.STYLE, STYLE.FILLED)
00080 n1.setAttrib(NODE.COLOR, RgbColor.LightGray)
00081
00082 n2 = NODE(path[i+1])
00083 if path[i+1] == path[-1]:
00084 n2.setAttrib(NODE.SHAPE, SHAPE.Ellipse)
00085 n2.setAttrib(NODE.STYLE, STYLE.FILLED)
00086 n2.setAttrib(NODE.COLOR, RgbColor.LightSeaGreen)
00087 else:
00088 n2.setAttrib(NODE.SHAPE, SHAPE.Box)
00089 n2.setAttrib(NODE.STYLE, STYLE.FILLED)
00090 n2.setAttrib(NODE.COLOR, RgbColor.LightGray)
00091
00092 digraph.addNode(n1)
00093 digraph.addNode(n2)
00094 digraph.connect(n1,n2)
00095 connection_register.append(conn)
00096
00097 digraph.connect(digraph.getRootNode(), "src")
00098
00099 digraph.saveDot(env.ROSDOC_DOT+"/agi_workspace.dot")
00100 digraph.dotToPng(env.ROSDOC_DOT+"/agi_workspace.png")
00101
00102