workspace.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2015 Airbus
00004 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00005 #
00006 # Licensed under the Apache License, Version 2.0 (the "License");
00007 # you may not use this file except in compliance with the License.
00008 # You may obtain a copy of the License at
00009 #
00010 #   http://www.apache.org/licenses/LICENSE-2.0
00011 #
00012 # Unless required by applicable law or agreed to in writing, software
00013 # distributed under the License is distributed on an "AS IS" BASIS,
00014 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 # See the License for the specific language governing permissions and
00016 # limitations under the License.
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         


airbus_docgen
Author(s): Matignon Martin
autogenerated on Thu Jun 6 2019 17:59:08