def add_reachable_poly(self, poly_verts, parent, mode_name):
'''add a polygon which was reachable'''
assert isinstance(parent, ContinuousPostParent)
if len(poly_verts) <= 2:
markers = self.parent_to_markers.get(parent)
if markers is None:
face_col, edge_col = self.mode_colors.get_edge_face_colors(mode_name)
markers = Line2D([], [], animated=True, ls='None', alpha=0.5, marker='o', mew=2, ms=5,
mec=edge_col, mfc=face_col)
self.axes.add_line(markers)
self.parent_to_markers[parent] = markers
xdata = markers.get_xdata()
ydata = markers.get_ydata()
xdata.append(poly_verts[0][0])
ydata.append(poly_verts[0][1])
markers.set_xdata(xdata)
markers.set_ydata(ydata)
else:
polys = self.parent_to_polys.get(parent)
if polys is None:
face_col, edge_col = self.mode_colors.get_edge_face_colors(mode_name)
polys = collections.PolyCollection([], lw=2, animated=True, alpha=0.5,
edgecolor=edge_col, facecolor=face_col)
self.axes.add_collection(polys)
self.parent_to_polys[parent] = polys
paths = polys.get_paths()
codes = [Path.MOVETO] + [Path.LINETO] * (len(poly_verts) - 2) + [Path.CLOSEPOLY]
paths.append(Path(poly_verts, codes))
评论列表
文章目录