def local_move_centre_pt(self, centre_pt, name, drag_image): # check in zones to speed things up location = -1 update = False detail_index = -1 centre_pt = self.CalcUnscrolledPosition(centre_pt) which_id = 0 # BED zooming support if (self.zoom != 1.0): centre_pt.Set(centre_pt.x/self.zoom, centre_pt.y/self.zoom) for loc, rect in self.locations_empty: if (rect.InsideXY(centre_pt.x, centre_pt.y)): location = loc break if (location != self.zone_hit): good = win_data.config_check(location, name) dc = None origin = self.mb_origin[:] if (good): # put the overlay on overlay = device_data.get_overlay_bmap(location) else: # put no overlay on overlay = device_data.get_overlay_bmap() if (self.zoom != 1.0): image = overlay.ConvertToImage() w = image.GetWidth() * self.zoom h = image.GetHeight() * self.zoom image.Rescale(w, h) overlay = image.ConvertToBitmap() origin[0] *= self.zoom origin[1] *= self.zoom dc = wx.ClientDC(self) self.DoPrepareDC(dc) drag_image.Hide() update = True dc.DrawBitmap(overlay, origin[0], origin[1], True) self.zone_hit = location return location, update, None
def local_move_centre_pt(self, centre_pt, name, drag_image): # check in zones to speed things up location = -1 update = False detail_index = -1 centre_pt = self.CalcUnscrolledPosition(centre_pt) which_id = 0 # BED zooming support if (self.zoom != 1.0): centre_pt.Set(centre_pt.x / self.zoom, centre_pt.y / self.zoom) for loc, rect in self.locations_empty: if (rect.InsideXY(centre_pt.x, centre_pt.y)): location = loc break if (location != self.zone_hit): good = win_data.config_check(location, name) dc = None origin = self.mb_origin[:] if (good): # put the overlay on overlay = device_data.get_overlay_bmap(location) else: # put no overlay on overlay = device_data.get_overlay_bmap() if (self.zoom != 1.0): image = overlay.ConvertToImage() w = image.GetWidth() * self.zoom h = image.GetHeight() * self.zoom image.Rescale(w, h) overlay = image.ConvertToBitmap() origin[0] *= self.zoom origin[1] *= self.zoom dc = wx.ClientDC(self) self.DoPrepareDC(dc) drag_image.Hide() update = True dc.DrawBitmap(overlay, origin[0], origin[1], True) self.zone_hit = location return location, update, None
def on_paint(self, event): dc = wx.PaintDC(self) self.DoPrepareDC(dc) dc.SetBackground(wx.Brush("white", wx.SOLID)) dc.SetUserScale(self.zoom, self.zoom) dc.Clear() # paint mb first mb = device_data.get_mb_bmap() dc.DrawBitmap(mb, self.mb_origin[0], self.mb_origin[1], True) self.locations_full = [] self.locations_empty = [] overlay = None # now the current configuration cfg = win_data.config_get_all() for i in range(12): if (cfg.has_key(i)): dtype = cfg[i][0] orient = 0 if (i in [1, 4, 7, 10] and (dtype == "Motor A" or dtype == "Motor B")): orient = win_data.config_orient_from_loc(i) if (orient == 1): image_index_base = 2 else: image_index_base = 4 else: image_index_base = 0 if (win_data.selection_check('cwork', None, i)): overlay = device_data.get_overlay_bmap(i) image = device_data.get_fullsize_image(dtype, image_index_base + 1) else: image = device_data.get_fullsize_image(dtype, image_index_base) else: dtype = None image = None offset = (0, 0) size = self.hit_size x,y = self.centres[i] if (i in [5, 6, 7]): if (image): # no rotation needed b = wx.BitmapFromImage(image) size = b.GetSize() offset = (0, 10) if (dtype == 'Motor A'): if (i == 7 and orient < 0): b = wx.BitmapFromImage(image.Rotate90(clockwise=True)) size = b.GetSize() x,y = self.centres[8] x = x - offset[1]-90 y = y + size[1] - self.hit_size[1]*4 else: x = x - self.hit_size[0]/2 if (i == 7): y = y -size[1]+offset[1]+90 else: y = y - size[1] + offset[1] elif (dtype == 'Motor B'): if (i == 7 and orient < 0): b = wx.BitmapFromImage(image.Rotate90(clockwise=True)) size = b.GetSize() x,y = self.centres[8] x = x - offset[1]-90 y = y + size[1] - self.hit_size[1]*4.5 else: x = x - size[0] + self.hit_size[0]*1.5 if (i == 7): y = y -size[1]+offset[1]+90 else: y = y - size[1] + offset[1] else: x = x - (size[0]/2) + offset[0] y = y - (size[1]) + offset[1] elif (i in [2, 3, 4]): if (image): # -90 rotation needed b = wx.BitmapFromImage(image.Rotate90(clockwise=False)) size = b.GetSize() offset = (10, 0) if (dtype == 'Motor A'): if (i == 4 and orient < 0): b = wx.BitmapFromImage(image) size = b.GetSize() x,y = self.centres[5] x = x - self.hit_size[0]*1.5 y = y - size[1] + self.hit_size[1]*1 +offset[1] else: y = y - size[1] + self.hit_size[1]/2 if (i == 4): x = x -size[0]+offset[0]+90 else: x = x - size[0]+offset[0] elif (dtype == 'Motor B'): if (i == 4 and orient < 0): b = wx.BitmapFromImage(image) size = b.GetSize() x,y = self.centres[5] x = x - self.hit_size[0]*2 y = y - size[1] + self.hit_size[1]*1 +offset[1] else: y = y - size[1] + self.hit_size[1] if (i == 4): x = x -size[0]+offset[0]+90 else: x = x - size[0]+offset[0] else: x = x - (size[0]) + offset[0] y = y - (size[1]/2) + offset[1] elif (i in [8, 9, 10]): if (image): # +90 rotation needed b = wx.BitmapFromImage(image.Rotate90(clockwise=True)) size = b.GetSize() offset = (-10, 0) if (dtype == 'Motor A'): if (i == 10 and orient < 0): b = wx.BitmapFromImage(image.Rotate90().Rotate90()) size = b.GetSize() x,y = self.centres[11] x = x - self.hit_size[0]*1 + offset[1] y = y - 90 + offset[0] else: y = y + size[1] - self.hit_size[1]*3 if (i == 10): x = x +offset[0]-90 else: x = x +offset[0] elif (dtype == 'Motor B'): if (i == 10 and orient < 0): b = wx.BitmapFromImage(image.Rotate90().Rotate90()) size = b.GetSize() x,y = self.centres[11] x = x - self.hit_size[0]*0.5 + offset[1] y = y - 90 + offset[0] else: y = y - size[1] + self.hit_size[1]*1.5 if (i == 10): x = x +offset[0]-90 else: x = x +offset[0] else: x = x + offset[0] y = y - (size[1]/2) + offset[1] else: if (image): # 180 rotation needed b = wx.BitmapFromImage(image.Rotate90().Rotate90()) size = b.GetSize() offset = (0, -10) if (dtype == 'Motor A'): if (i == 1 and orient < 0): b = wx.BitmapFromImage(image.Rotate90(clockwise=False)) size = b.GetSize() x,y = self.centres[2] x = x - size[0] + self.hit_size[0] y = y - 90 + offset[1] else: x = x - self.hit_size[0]*2 if (i == 1): y = y +offset[1]-90 else: y = y + offset[1] elif (dtype == 'Motor B'): if (i == 1 and orient < 0): b = wx.BitmapFromImage(image.Rotate90(clockwise=False)) size = b.GetSize() x,y = self.centres[2] x = x - size[0] + self.hit_size[0] y = y - 90 + + self.hit_size[1]*0.5 + offset[1] else: x = x - size[0] + self.hit_size[0]*1 if (i == 1): y = y +offset[1]-90 else: y = y + offset[1] else: x = x - (size[0]/2) + offset[0] y = y + offset[1] if (image): dc.DrawBitmap(b, x, y, True) self.locations_full.append((i, cfg[i][0], wx.Rect(x, y, size[0], size[1]))) else: self.locations_empty.append((i, wx.Rect(x, y, size[0], size[1]))) if (not overlay): overlay = device_data.get_overlay_bmap() dc.DrawBitmap(overlay, self.mb_origin[0], self.mb_origin[1], True) self.SetVirtualSize(self.window_size)
def on_paint(self, event): dc = wx.PaintDC(self) self.DoPrepareDC(dc) dc.SetBackground(wx.Brush("white", wx.SOLID)) dc.SetUserScale(self.zoom, self.zoom) dc.Clear() # paint mb first mb = device_data.get_mb_bmap() dc.DrawBitmap(mb, self.mb_origin[0], self.mb_origin[1], True) self.locations_full = [] self.locations_empty = [] overlay = None # now the current configuration cfg = win_data.config_get_all() for i in range(12): if (cfg.has_key(i)): dtype = cfg[i][0] orient = 0 if (i in [1, 4, 7, 10] and (dtype == "Motor A" or dtype == "Motor B")): orient = win_data.config_orient_from_loc(i) if (orient == 1): image_index_base = 2 else: image_index_base = 4 else: image_index_base = 0 if (win_data.selection_check('cwork', None, i)): overlay = device_data.get_overlay_bmap(i) image = device_data.get_fullsize_image( dtype, image_index_base + 1) else: image = device_data.get_fullsize_image( dtype, image_index_base) else: dtype = None image = None offset = (0, 0) size = self.hit_size x, y = self.centres[i] if (i in [5, 6, 7]): if (image): # no rotation needed b = wx.BitmapFromImage(image) size = b.GetSize() offset = (0, 10) if (dtype == 'Motor A'): if (i == 7 and orient < 0): b = wx.BitmapFromImage(image.Rotate90(clockwise=True)) size = b.GetSize() x, y = self.centres[8] x = x - offset[1] - 90 y = y + size[1] - self.hit_size[1] * 4 else: x = x - self.hit_size[0] / 2 if (i == 7): y = y - size[1] + offset[1] + 90 else: y = y - size[1] + offset[1] elif (dtype == 'Motor B'): if (i == 7 and orient < 0): b = wx.BitmapFromImage(image.Rotate90(clockwise=True)) size = b.GetSize() x, y = self.centres[8] x = x - offset[1] - 90 y = y + size[1] - self.hit_size[1] * 4.5 else: x = x - size[0] + self.hit_size[0] * 1.5 if (i == 7): y = y - size[1] + offset[1] + 90 else: y = y - size[1] + offset[1] else: x = x - (size[0] / 2) + offset[0] y = y - (size[1]) + offset[1] elif (i in [2, 3, 4]): if (image): # -90 rotation needed b = wx.BitmapFromImage(image.Rotate90(clockwise=False)) size = b.GetSize() offset = (10, 0) if (dtype == 'Motor A'): if (i == 4 and orient < 0): b = wx.BitmapFromImage(image) size = b.GetSize() x, y = self.centres[5] x = x - self.hit_size[0] * 1.5 y = y - size[1] + self.hit_size[1] * 1 + offset[1] else: y = y - size[1] + self.hit_size[1] / 2 if (i == 4): x = x - size[0] + offset[0] + 90 else: x = x - size[0] + offset[0] elif (dtype == 'Motor B'): if (i == 4 and orient < 0): b = wx.BitmapFromImage(image) size = b.GetSize() x, y = self.centres[5] x = x - self.hit_size[0] * 2 y = y - size[1] + self.hit_size[1] * 1 + offset[1] else: y = y - size[1] + self.hit_size[1] if (i == 4): x = x - size[0] + offset[0] + 90 else: x = x - size[0] + offset[0] else: x = x - (size[0]) + offset[0] y = y - (size[1] / 2) + offset[1] elif (i in [8, 9, 10]): if (image): # +90 rotation needed b = wx.BitmapFromImage(image.Rotate90(clockwise=True)) size = b.GetSize() offset = (-10, 0) if (dtype == 'Motor A'): if (i == 10 and orient < 0): b = wx.BitmapFromImage(image.Rotate90().Rotate90()) size = b.GetSize() x, y = self.centres[11] x = x - self.hit_size[0] * 1 + offset[1] y = y - 90 + offset[0] else: y = y + size[1] - self.hit_size[1] * 3 if (i == 10): x = x + offset[0] - 90 else: x = x + offset[0] elif (dtype == 'Motor B'): if (i == 10 and orient < 0): b = wx.BitmapFromImage(image.Rotate90().Rotate90()) size = b.GetSize() x, y = self.centres[11] x = x - self.hit_size[0] * 0.5 + offset[1] y = y - 90 + offset[0] else: y = y - size[1] + self.hit_size[1] * 1.5 if (i == 10): x = x + offset[0] - 90 else: x = x + offset[0] else: x = x + offset[0] y = y - (size[1] / 2) + offset[1] else: if (image): # 180 rotation needed b = wx.BitmapFromImage(image.Rotate90().Rotate90()) size = b.GetSize() offset = (0, -10) if (dtype == 'Motor A'): if (i == 1 and orient < 0): b = wx.BitmapFromImage(image.Rotate90(clockwise=False)) size = b.GetSize() x, y = self.centres[2] x = x - size[0] + self.hit_size[0] y = y - 90 + offset[1] else: x = x - self.hit_size[0] * 2 if (i == 1): y = y + offset[1] - 90 else: y = y + offset[1] elif (dtype == 'Motor B'): if (i == 1 and orient < 0): b = wx.BitmapFromImage(image.Rotate90(clockwise=False)) size = b.GetSize() x, y = self.centres[2] x = x - size[0] + self.hit_size[0] y = y - 90 + +self.hit_size[1] * 0.5 + offset[1] else: x = x - size[0] + self.hit_size[0] * 1 if (i == 1): y = y + offset[1] - 90 else: y = y + offset[1] else: x = x - (size[0] / 2) + offset[0] y = y + offset[1] if (image): dc.DrawBitmap(b, x, y, True) self.locations_full.append( (i, cfg[i][0], wx.Rect(x, y, size[0], size[1]))) else: self.locations_empty.append( (i, wx.Rect(x, y, size[0], size[1]))) if (not overlay): overlay = device_data.get_overlay_bmap() dc.DrawBitmap(overlay, self.mb_origin[0], self.mb_origin[1], True) self.SetVirtualSize(self.window_size)