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

Method mouse_down

imagepy/tools/Standard/polygon_tol.py:38–71  ·  view source on GitHub ↗
(self, ips, x, y, btn, **key)

Source from the content-addressed store, hash-verified

36 self.helper = Polygonbuf()
37
38 def mouse_down(self, ips, x, y, btn, **key):
39 lim = 5.0/key['canvas'].get_scale()
40 ips.mark = self.helper
41 if btn==1:
42 if not self.doing:
43 if ips.roi!= None:
44 self.curobj = ips.roi.pick(x, y, ips.cur, lim)
45 ips.roi.info(ips, self.curobj)
46 if not self.curobj in (None,True):return
47 self.oper = '+'
48 if ips.roi == None:
49 ips.roi = polygonroi.PolygonRoi()
50 self.doing = True
51 elif hasattr(ips.roi, 'topolygon'):
52 if key['shift']:
53 ips.roi = ips.roi.topolygon()
54 self.oper,self.doing = '+',True
55 elif key['ctrl']:
56 ips.roi = ips.roi.topolygon()
57 self.oper,self.doing = '-',True
58 elif self.curobj: return
59 else: ips.roi=None
60 else: ips.roi = None
61 if self.doing:
62 self.helper.addpoint((x,y))
63 self.curobj = (self.helper.buf[0], -1)
64 self.odx, self.ody = x, y
65
66 elif btn==3:
67 if self.doing:
68 self.helper.addpoint((x,y))
69 self.doing = False
70 ips.roi.commit(self.helper.pop(), self.oper)
71 ips.update()
72
73 def mouse_move(self, ips, x, y, btn, **key):
74 if ips.roi==None:return

Callers

nothing calls this directly

Calls 8

get_scaleMethod · 0.80
pickMethod · 0.45
infoMethod · 0.45
topolygonMethod · 0.45
addpointMethod · 0.45
commitMethod · 0.45
popMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected