00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 from airbus_docgen.digraph.digraph import *
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 def getStdTDModel(text, bgcolor=RgbColor.White, align = ALIGN.Center):
00042
00043 model = TD()
00044 model.setAttrib(TD.COLSPAN, 1)
00045 model.setAttrib(TD.ALIGN, align)
00046 model.setAttrib(TD.BGCOLOR, bgcolor)
00047 model.setText(text)
00048
00049 return model
00050
00051 class _CMakeListsDotModel(NODE):
00052
00053 def __init__(self, node_name, node_title, title_color=RgbColor.LightSkyBlue):
00054 NODE.__init__(self, node_name)
00055
00056 self._table = TABLE()
00057 self._table.setAttrib(TABLE.BORDER, 0)
00058 self._table.setAttrib(TABLE.CELLBORDER, 1)
00059 self._table.setAttrib(TABLE.CELLSPACING, 0)
00060 self._table.setAttrib(TABLE.BGCOLOR, RgbColor.White)
00061
00062 title = TD()
00063 title.setAttrib(TD.ALIGN, ALIGN.Center)
00064 title.setAttrib(TD.BGCOLOR, title_color)
00065 title.setAttrib(TD.COLSPAN, 1)
00066 title.setText(node_title)
00067 self._table.addTR(TR(title))
00068
00069 def add(self, name):
00070 self._table.addTR(TR(getStdTDModel(name)))
00071
00072 def getNode(self):
00073 self.setHtml(self._table)
00074 return self
00075
00076 def __str__(self):
00077 self.setHtml(self._table)
00078 return NODE.__str__(self)
00079
00080 class BuildDependDotModel(_CMakeListsDotModel):
00081 def __init__(self):
00082 _CMakeListsDotModel.__init__(self,
00083 'find_package',
00084 "Package dependencies",
00085 RgbColor.Red)
00086
00087
00088 class AddMessageFilesDotModel(_CMakeListsDotModel):
00089 def __init__(self):
00090 _CMakeListsDotModel.__init__(self,
00091 'add_message_files',
00092 "Message files generated",
00093 RgbColor.LightSkyBlue)
00094
00095 class AddServiceFilesDotModel(_CMakeListsDotModel):
00096 def __init__(self):
00097 _CMakeListsDotModel.__init__(self,
00098 'add_service_files',
00099 "Service files generated",
00100 RgbColor.Yellow)
00101
00102 class AddActionFilesDotModel(_CMakeListsDotModel):
00103 def __init__(self):
00104 _CMakeListsDotModel.__init__(self,
00105 'add_action_files',
00106 "Action files generated",
00107 RgbColor.Chartreuse)
00108
00109 class AddExecutableDotModel(_CMakeListsDotModel):
00110 def __init__(self, name='add_executable', label='Executable generated'):
00111 _CMakeListsDotModel.__init__(self,
00112 name,
00113 label,
00114 RgbColor.OrangeRed)
00115
00116
00117 class AddLibraryDotModel(_CMakeListsDotModel):
00118 def __init__(self):
00119 _CMakeListsDotModel.__init__(self,
00120 'add_library',
00121 "Library generated",
00122 RgbColor.LightCoral)
00123
00124
00125
00126 if __name__ == '__main__':
00127
00128 digraph = Digraph("digraph_test")
00129
00130 nconf = NODE("node")
00131 nconf.setAttrib(NODE.SHAPE, SHAPE.Plaintext)
00132 digraph.addNode(nconf)
00133
00134 pkg = NODE("ros_package")
00135 pkg.setAttrib(NODE.SHAPE, SHAPE.Ellipse)
00136 pkg.setAttrib(NODE.STYLE, STYLE.FILLED)
00137 pkg.setAttrib(NODE.COLOR, RgbColor.CornflowerBlue)
00138 pkg.setAttrib(NODE.FONTSIZE, 22)
00139 digraph.addRootNode(pkg)
00140
00141 msg = AddMessageFilesDotModel()
00142
00143 msg.add("Twist1")
00144 msg.add("Twist2")
00145 msg.add("Twist3")
00146 msg.add("Twist4")
00147
00148 digraph.addNode(msg)
00149 digraph.connect(digraph.getRootNode(), msg)
00150
00151 srv = AddServiceFilesDotModel()
00152
00153 srv.add("TwistSrv1")
00154 srv.add("TwistSrv2")
00155 srv.add("TwistSrv3")
00156 srv.add("TwistSrv4")
00157
00158 digraph.addNode(srv)
00159 digraph.connect(digraph.getRootNode(), srv)
00160
00161 action = AddActionFilesDotModel()
00162
00163 action.add("TwistSrv1")
00164 action.add("TwistSrv2")
00165 action.add("TwistSrv3")
00166 action.add("TwistSrv4")
00167
00168 digraph.addNode(action)
00169 digraph.connect(digraph.getRootNode(), action)
00170
00171 lib = AddLibraryDotModel()
00172
00173 lib.add("TwistSrv1")
00174 lib.add("TwistSrv2")
00175 lib.add("TwistSrv3")
00176 lib.add("TwistSrv4")
00177
00178 digraph.addNode(lib)
00179 digraph.connect(digraph.getRootNode(), lib)
00180
00181 ex = AddExecutableDotModel()
00182
00183 ex.add("TwistSrv1")
00184 ex.add("TwistSrv2")
00185 ex.add("TwistSrv3")
00186 ex.add("TwistSrv4")
00187
00188 digraph.addNode(ex)
00189 digraph.connect(digraph.getRootNode(), ex)
00190
00191 digraph.saveDot("/home/ihm-pma/Documents/dot_test/CmakeListsModel.dot")
00192 digraph.dotToPng("/home/ihm-pma/Documents/dot_test/CmakeListsModel.png")
00193
00194
00195