I'm drawing a network graph with wx.PaintDC. For each link in my graph
I draw the source and destination port numbers on a box over the link
30pixels away from the endpoints. This works fine when I'm only
drawing the ports for a single link, but when I draw the ports for all
of the links (I'm testing on tree with 12 links) I get a major
performance hit. What strategies can I use to get my graph back to a
usable state?
# If extra info is desired draw ports
if link.hover or
link.info:
dc.SetPen(wx.Pen(wx.Colour(58,58,58), 1))
dc.SetBrush(wx.Brush(wx.Colour(255,255,255)))
# Draw srcport
sx, sy = gmath.PointOnLine(dstpos, srcpos, -30)
ss = str(link.srcport)
sw, sh = dc.GetTextExtent(ss)
dc.DrawRectangle(sx-3, sy-3, sw+6, sh+6)
# Draw dstport
dx, dy = gmath.PointOnLine(srcpos, dstpos, -30)
ds = str(link.dstport)
dw, dh = dc.GetTextExtent(ds)
dc.DrawRectangle(dx-3, dy-3, dw+6, dh+6)
dc.DrawText(ss, sx, sy)
dc.DrawText(ds, dx, dy)