MCPcopy Create free account
hub / github.com/Image-Py/imagepy / draw_coord

Method draw_coord

imagepy/ui/plotwindow.py:79–110  ·  view source on GitHub ↗
(self, dc, w, h, l, t, r, b)

Source from the content-addressed store, hash-verified

77 self.data.append((xs, ys, color, lw))
78
79 def draw_coord(self, dc, w, h, l, t, r, b):
80 xs = [5, 10, 20, 40, 50, 100, 200, 400, 500, 1000, 2000, 4000, 10000]
81 n, dx, dy = len(self.data), 0, 0
82 left, low, right, high = self.extent
83 for i in xs[::-1]:
84 if (right-left)*1.0/i<=10:dx=i
85 for i in xs[::-1]:
86 if (high-low)*1.0/i<=10:dy=i
87 dc.SetPen(wx.Pen((0, 0, 0), width=1, style=wx.SOLID))
88 dc.DrawRectangle(l, t, w+1, h+1)
89 dc.SetPen(wx.Pen((100, 100, 100), width=1, style=wx.SOLID))
90 for i in range(int(ceil(left*1.0/dx)*dx), int(right)+1, dx):
91 x = l+(i-left)*1.0/(right-left)*w
92 dc.DrawLine(x, t, x, t+h)
93 dc.DrawText(str(i), x-5, t+h)
94 for i in range(int(ceil(low*1.0/dy)*dy), int(high)+1, dy):
95 y = h+t-(i-low)*1.0/(high-low)*h
96 dc.DrawLine(l, y, l+w, y)
97 dc.DrawText(str(i), 5, y-5)
98
99 titlefont = wx.Font(18, wx.FONTFAMILY_DEFAULT,
100 wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
101 dc.SetFont(titlefont)
102 dw,dh = dc.GetTextExtent(self.title)
103 dc.DrawText(self.title, l+w/2-dw/2, 3)
104
105 lablelfont = wx.Font(14, wx.FONTFAMILY_DEFAULT,
106 wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
107 dc.SetFont(lablelfont)
108 dw,dh = dc.GetTextExtent(self.labelx)
109 dc.DrawText(self.labelx, l+w-dw, t+h+15)
110 dc.DrawText(self.labely, 5, 10)
111
112 def draw(self):
113 l, t, r, b = 35,35,15,35

Callers 1

drawMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected