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

Method on_mouseevent

imagepy/ui/canvas.py:74–95  ·  view source on GitHub ↗
(self, me)

Source from the content-addressed store, hash-verified

72 self.handle = handle
73
74 def on_mouseevent(self, me):
75 tool = self.ips.tool
76 if tool == None : tool = ToolsManager.curtool
77 x,y = self.to_data_coor(me.GetX(), me.GetY())
78 if me.Moving() and not me.LeftIsDown() and not me.RightIsDown() and not me.MiddleIsDown():
79 xx,yy = int(round(x)), int(round(y))
80 k, unit = self.ips.unit
81 if xx>=0 and xx<self.ips.img.shape[1] and yy>=0 and yy<self.ips.img.shape[0]:
82 IPy.set_info('Location:%.1f %.1f Value:%s'%(x*k, y*k, self.ips.img[yy,xx]))
83 if tool==None:return
84
85 sta = [me.AltDown(), me.ControlDown(), me.ShiftDown()]
86 if me.ButtonDown():tool.mouse_down(self.ips, x, y, me.GetButton(), alt=sta[0], ctrl=sta[1], shift=sta[2], canvas=self)
87 if me.ButtonUp():tool.mouse_up(self.ips, x, y, me.GetButton(), alt=sta[0], ctrl=sta[1], shift=sta[2], canvas=self)
88 if me.Moving():tool.mouse_move(self.ips, x, y, None, alt=sta[0], ctrl=sta[1], shift=sta[2], canvas=self)
89 btn = [me.LeftIsDown(), me.MiddleIsDown(), me.RightIsDown(),True].index(True)
90 if me.Dragging():tool.mouse_move(self.ips, x, y, 0 if btn==3 else btn+1, alt=sta[0], ctrl=sta[1], shift=sta[2], canvas=self)
91 wheel = np.sign(me.GetWheelRotation())
92 if wheel!=0:tool.mouse_wheel(self.ips, x, y, wheel, alt=sta[0], ctrl=sta[1], shift=sta[2], canvas=self)
93 if hasattr(tool, 'cursor'):
94 self.SetCursor(wx.Cursor(tool.cursor))
95 else : self.SetCursor(wx.Cursor(wx.CURSOR_ARROW))
96
97 def bindEvents(self):
98 for event, handler in [ \

Callers

nothing calls this directly

Calls 6

to_data_coorMethod · 0.95
set_infoMethod · 0.45
mouse_downMethod · 0.45
mouse_upMethod · 0.45
mouse_moveMethod · 0.45
mouse_wheelMethod · 0.45

Tested by

no test coverage detected