| 217 | self.buffer.SaveFile(path, wx.BITMAP_TYPE_PNG) |
| 218 | |
| 219 | def draw_ruler(self, dc): |
| 220 | dc.SetPen(wx.Pen((255,255,255), width=2, style=wx.SOLID)) |
| 221 | x1 = max(self.imgbox[0], self.box[0])+5 |
| 222 | x2 = min(self.imgbox[2], self.box[2])+x1-10 |
| 223 | pixs = (x2-x1+10)*self.ips.size[1]/10.0/self.imgbox[2] |
| 224 | h = min(self.imgbox[1]+self.imgbox[3],self.box[3])-5 |
| 225 | dc.DrawLineList([(x1,h,x2,h)]) |
| 226 | dc.DrawLineList([(i,h,i,h-8) for i in np.linspace(x1, x2, 3)]) |
| 227 | dc.DrawLineList([(i,h,i,h-5) for i in np.linspace(x1, x2, 11)]) |
| 228 | |
| 229 | dc.SetTextForeground((255,255,255)) |
| 230 | k, unit = self.ips.unit |
| 231 | text = 'Unit = %.1f %s'%(k*pixs, unit) |
| 232 | dw,dh = dc.GetTextExtent(text) |
| 233 | dc.DrawText(text, (x2-dw, h-10-dh)) |
| 234 | |
| 235 | def update(self, pix): |
| 236 | if self.ips == None: return |