예제 #1
0
 def center(self, x, y, coord='win'):
     if coord=='data':
         x,y = self.to_panel_coor(x, y)
     dx = (self.winbox[2]-self.winbox[0])/2 - x
     dy = (self.winbox[3]-self.winbox[1])/2 - y
     for i,j in zip((0,1,2,3),(dx,dy,dx,dy)):
         self.conbox[i] += j
     lay(self.winbox, self.conbox)
예제 #2
0
 def zoom(self, k, x, y, coord='win'):
     if coord=='data':
         x,y = self.to_panel_coor(x, y)
         if self.up: y = (self.winbox[3]-self.winbox[1]) - y
     box = np.array(self.conbox).reshape((2,2))
     box = (box - (x,y)) / self.scale * k + (x, y)
     self.conbox = box.ravel().tolist()
     if not self.autofit: return
     a,b,c,d = self.conbox
     if c-a<self.scrbox[0]*0.9 and d-b<self.scrbox[1]*0.9:
         self.SetInitialSize((c-a+4, d-b+4))
     lay(self.winbox, self.conbox)
     self.GetParent().Fit()
예제 #3
0
 def fit(self):
     self.update_box()
     oriw = self.oribox[2]-self.oribox[0]
     orih = self.oribox[3]-self.oribox[1]
     if not self.autofit: a,b,c,d = self.winbox
     else: 
         (a,b),(c,d) = (0,0), self.scrbox
         c, d = c*0.9, d*0.9
     if not self.ingrade:
         for i in self.scales[6::-1]:
             if oriw*i<c-a and orih*i<d-b: break
         self.scaidx = self.scales.index(i)
     else: i = min((c-a)*0.9/oriw, (d-b)*0.9/orih)
     self.zoom(i, 0, 0)
     lay(self.winbox, self.conbox)
     self.update()
예제 #4
0
 def initBuffer(self):
     box = self.GetClientSize()
     self.buffer = wx.Bitmap(*box)
     self.winbox = [0, 0, *box]
     lay(self.winbox, self.conbox)