equal
deleted
inserted
replaced
237 FigureCanvas.__init__(self, parent, -1, self.Figure) |
237 FigureCanvas.__init__(self, parent, -1, self.Figure) |
238 self.SetWindowStyle(wx.WANTS_CHARS) |
238 self.SetWindowStyle(wx.WANTS_CHARS) |
239 self.SetBackgroundColour(wx.WHITE) |
239 self.SetBackgroundColour(wx.WHITE) |
240 |
240 |
241 # Bind wx events |
241 # Bind wx events |
|
242 self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick) |
242 self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) |
243 self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) |
243 self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) |
244 self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) |
244 self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) |
245 self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) |
245 self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) |
246 self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) |
246 self.Bind(wx.EVT_SIZE, self.OnResize) |
247 self.Bind(wx.EVT_SIZE, self.OnResize) |
611 xw + event.x, yw + height - event.y) |
612 xw + event.x, yw + height - event.y) |
612 |
613 |
613 else: |
614 else: |
614 # Reset any move in progress |
615 # Reset any move in progress |
615 self.MouseStartPos = None |
616 self.MouseStartPos = None |
616 self.StartCursorTick = None |
|
617 self.CanvasStartSize = None |
617 self.CanvasStartSize = None |
618 |
618 |
619 # Handle button under mouse if it exist |
619 # Handle button under mouse if it exist |
620 width, height = self.GetSize() |
620 width, height = self.GetSize() |
621 self.HandleButton(event.x, height - event.y) |
621 self.HandleButton(event.x, height - event.y) |
750 self.ParentWindow.ChangeRange(int(-event.step) / 3, tick) |
750 self.ParentWindow.ChangeRange(int(-event.step) / 3, tick) |
751 |
751 |
752 # Vetoing event to prevent parent panel to be scrolled |
752 # Vetoing event to prevent parent panel to be scrolled |
753 self.ParentWindow.VetoScrollEvent = True |
753 self.ParentWindow.VetoScrollEvent = True |
754 |
754 |
|
755 def OnLeftDClick(self, event): |
|
756 """ |
|
757 Function called when a left mouse button is double clicked |
|
758 @param event: Mouse event |
|
759 """ |
|
760 # Check that double click was done inside figure |
|
761 pos = event.GetPosition() |
|
762 rect = self.GetAxesBoundingBox() |
|
763 if rect.InsideXY(pos.x, pos.y): |
|
764 # Reset Cursor tick to value before starting clicking |
|
765 self.ParentWindow.SetCursorTick(self.StartCursorTick) |
|
766 # Toggle to text Viewer(s) |
|
767 self.ParentWindow.ToggleViewerType(self) |
|
768 |
|
769 else: |
|
770 event.Skip() |
|
771 |
755 # Cursor tick move for each arrow key |
772 # Cursor tick move for each arrow key |
756 KEY_CURSOR_INCREMENT = { |
773 KEY_CURSOR_INCREMENT = { |
757 wx.WXK_LEFT: -1, |
774 wx.WXK_LEFT: -1, |
758 wx.WXK_RIGHT: 1, |
775 wx.WXK_RIGHT: 1, |
759 wx.WXK_UP: -10, |
776 wx.WXK_UP: -10, |
980 # Figure position like text position in figure are expressed is ratio |
997 # Figure position like text position in figure are expressed is ratio |
981 # canvas size and figure size. As we want that border around figure and |
998 # canvas size and figure size. As we want that border around figure and |
982 # text position in figure don't change when canvas size change, we |
999 # text position in figure don't change when canvas size change, we |
983 # expressed border and text position in pixel on screen and apply the |
1000 # expressed border and text position in pixel on screen and apply the |
984 # ratio calculated hereafter to get border and text position in |
1001 # ratio calculated hereafter to get border and text position in |
985 # matplotlib coordinate |
1002 # matplotlib coordinate |
986 canvas_ratio = 1. / height # Divide by canvas height in pixel |
1003 canvas_ratio = 1. / height # Divide by canvas height in pixel |
987 graph_ratio = 1. / ( |
1004 graph_ratio = 1. / ( |
988 (1.0 - (CANVAS_BORDER[0] + CANVAS_BORDER[1]) * canvas_ratio) |
1005 (1.0 - (CANVAS_BORDER[0] + CANVAS_BORDER[1]) * canvas_ratio) |
989 * height) # Divide by figure height in pixel |
1006 * height) # Divide by figure height in pixel |
990 |
1007 |