| 19 | self.helper = Polygonbuf() |
| 20 | |
| 21 | def mouse_down(self, ips, x, y, btn, **key): |
| 22 | lim = 5.0/key['canvas'].get_scale() |
| 23 | ips.mark = self.helper |
| 24 | if btn==1: |
| 25 | if not self.doing: |
| 26 | if ips.roi!= None: |
| 27 | self.curobj = ips.roi.pick(x, y, ips.cur, lim) |
| 28 | ips.roi.info(ips, self.curobj) |
| 29 | if not self.curobj in (None,True):return |
| 30 | self.oper = '+' |
| 31 | if ips.roi==None or not hasattr(ips.roi, 'topolygon'): |
| 32 | ips.roi = ovalroi.OvalRoi() |
| 33 | self.doing = True |
| 34 | ips.roi.lt, ips.roi.tp = x, y |
| 35 | ips.roi.rt, ips.roi.bm = x, y |
| 36 | self.curobj = 'rb' |
| 37 | self.odx, self.ody = x,y |
| 38 | elif hasattr(ips.roi, 'topolygon'): |
| 39 | self.odx, self.ody = x, y |
| 40 | self.ox, self.oy = x, y |
| 41 | if key['shift']: |
| 42 | ips.roi = ips.roi.topolygon() |
| 43 | self.oper,self.doing,self.curobj = '+',True,None |
| 44 | elif key['ctrl']: |
| 45 | ips.roi = ips.roi.topolygon() |
| 46 | self.oper,self.doing,self.curobj = '-',True,None |
| 47 | elif self.curobj: return |
| 48 | else: |
| 49 | ips.roi = ovalroi.OvalRoi() |
| 50 | self.doing = True |
| 51 | ips.roi.lt, ips.roi.tp = x, y |
| 52 | ips.roi.rt, ips.roi.bm = x, y |
| 53 | self.curobj = 'rb' |
| 54 | self.odx, self.ody = x,y |
| 55 | else: ips.roi = None |
| 56 | |
| 57 | ips.update() |
| 58 | |
| 59 | def mouse_up(self, ips, x, y, btn, **key): |
| 60 | if self.doing: |