22 class ExcluderWindow(gviz.GvizWindow): |
22 class ExcluderWindow(gviz.GvizWindow): |
23 |
23 |
24 def __init__(self, excluder, *args, **kwargs): |
24 def __init__(self, excluder, *args, **kwargs): |
25 super(ExcluderWindow, self).__init__(*args, **kwargs) |
25 super(ExcluderWindow, self).__init__(*args, **kwargs) |
26 self.SetTitle(_("Part excluder: draw rectangles where print instructions should be ignored")) |
26 self.SetTitle(_("Part excluder: draw rectangles where print instructions should be ignored")) |
27 self.toolbar.AddLabelTool(128, " " + _("Reset selection"), |
27 self.toolbar.AddTool(128, " " + _("Reset selection"), |
28 wx.Image(imagefile('reset.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap(), |
28 wx.Image(imagefile('reset.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap(), |
29 shortHelp = _("Reset selection"), |
29 _("Reset selection")) |
30 longHelp = "") |
|
31 self.Bind(wx.EVT_TOOL, self.reset_selection, id = 128) |
30 self.Bind(wx.EVT_TOOL, self.reset_selection, id = 128) |
32 self.parent = excluder |
31 self.parent = excluder |
33 self.p.paint_overlay = self.paint_selection |
32 self.p.paint_overlay = self.paint_selection |
34 self.p.layerup() |
33 self.p.layerup() |
35 |
34 |
44 def mouse(self, event): |
43 def mouse(self, event): |
45 if event.ButtonUp(wx.MOUSE_BTN_LEFT) \ |
44 if event.ButtonUp(wx.MOUSE_BTN_LEFT) \ |
46 or event.ButtonUp(wx.MOUSE_BTN_RIGHT): |
45 or event.ButtonUp(wx.MOUSE_BTN_RIGHT): |
47 self.initpos = None |
46 self.initpos = None |
48 elif event.Dragging() and event.RightIsDown(): |
47 elif event.Dragging() and event.RightIsDown(): |
49 e = event.GetPositionTuple() |
48 e = event.GetPosition() |
50 if not self.initpos or not hasattr(self, "basetrans"): |
49 if not self.initpos or not hasattr(self, "basetrans"): |
51 self.initpos = e |
50 self.initpos = e |
52 self.basetrans = self.p.translate |
51 self.basetrans = self.p.translate |
53 self.p.translate = [self.basetrans[0] + (e[0] - self.initpos[0]), |
52 self.p.translate = [self.basetrans[0] + (e[0] - self.initpos[0]), |
54 self.basetrans[1] + (e[1] - self.initpos[1])] |
53 self.basetrans[1] + (e[1] - self.initpos[1])] |
55 self.p.dirty = 1 |
54 self.p.dirty = 1 |
56 wx.CallAfter(self.p.Refresh) |
55 wx.CallAfter(self.p.Refresh) |
57 elif event.Dragging() and event.LeftIsDown(): |
56 elif event.Dragging() and event.LeftIsDown(): |
58 x, y = event.GetPositionTuple() |
57 x, y = event.GetPosition() |
59 if not self.initpos: |
58 if not self.initpos: |
60 self.basetrans = self.p.translate |
59 self.basetrans = self.p.translate |
61 x = (x - self.basetrans[0]) / self.p.scale[0] |
60 x = (x - self.basetrans[0]) / self.p.scale[0] |
62 y = (y - self.basetrans[1]) / self.p.scale[1] |
61 y = (y - self.basetrans[1]) / self.p.scale[1] |
63 x, y = self.real_to_gcode(x, y) |
62 x, y = self.real_to_gcode(x, y) |