22 # along with this program; if not, write to the Free Software |
22 # along with this program; if not, write to the Free Software |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 |
24 |
25 |
25 |
26 from __future__ import absolute_import |
26 from __future__ import absolute_import |
27 from types import TupleType |
27 from __future__ import division |
|
28 from functools import reduce |
28 import numpy |
29 import numpy |
29 |
30 |
30 import wx |
31 import wx |
31 import wx.lib.buttons |
32 import wx.lib.buttons |
32 |
33 |
305 if self.Ticktime == 0: |
306 if self.Ticktime == 0: |
306 self.Ticktime = MILLISECOND |
307 self.Ticktime = MILLISECOND |
307 |
308 |
308 # Calculate range to apply to data |
309 # Calculate range to apply to data |
309 self.CurrentRange = self.RANGE_VALUES[ |
310 self.CurrentRange = self.RANGE_VALUES[ |
310 self.CanvasRange.GetSelection()][1] / self.Ticktime |
311 self.CanvasRange.GetSelection()][1] // self.Ticktime |
311 |
312 |
312 def SetDataProducer(self, producer): |
313 def SetDataProducer(self, producer): |
313 """ |
314 """ |
314 Set Data Producer |
315 Set Data Producer |
315 @param producer: Data Producer |
316 @param producer: Data Producer |
388 cursor_tick = max(self.Ticks[0], |
389 cursor_tick = max(self.Ticks[0], |
389 min(self.CursorTick + move, self.Ticks[-1])) |
390 min(self.CursorTick + move, self.Ticks[-1])) |
390 cursor_tick_idx = numpy.argmin(numpy.abs(self.Ticks - cursor_tick)) |
391 cursor_tick_idx = numpy.argmin(numpy.abs(self.Ticks - cursor_tick)) |
391 if self.Ticks[cursor_tick_idx] == self.CursorTick: |
392 if self.Ticks[cursor_tick_idx] == self.CursorTick: |
392 cursor_tick_idx = max(0, |
393 cursor_tick_idx = max(0, |
393 min(cursor_tick_idx + abs(move) / move, |
394 min(cursor_tick_idx + abs(move) // move, |
394 len(self.Ticks) - 1)) |
395 len(self.Ticks) - 1)) |
395 self.CursorTick = self.Ticks[cursor_tick_idx] |
396 self.CursorTick = self.Ticks[cursor_tick_idx] |
396 self.StartTick = max( |
397 self.StartTick = max( |
397 self.Ticks[numpy.argmin( |
398 self.Ticks[numpy.argmin( |
398 numpy.abs(self.Ticks - self.CursorTick + self.CurrentRange))], |
399 numpy.abs(self.Ticks - self.CursorTick + self.CurrentRange))], |
486 bbox = wx.Rect(xw, yw, width, height) |
487 bbox = wx.Rect(xw, yw, width, height) |
487 if bbox.InsideXY(x_mouse, y_mouse): |
488 if bbox.InsideXY(x_mouse, y_mouse): |
488 panel.ShowButtons(True) |
489 panel.ShowButtons(True) |
489 merge_type = GRAPH_PARALLEL |
490 merge_type = GRAPH_PARALLEL |
490 if isinstance(panel, DebugVariableTextViewer) or panel.Is3DCanvas(): |
491 if isinstance(panel, DebugVariableTextViewer) or panel.Is3DCanvas(): |
491 if y_mouse > yw + height / 2: |
492 if y_mouse > yw + height // 2: |
492 idx += 1 |
493 idx += 1 |
493 wx.CallAfter(self.MoveValue, variable, idx, True) |
494 wx.CallAfter(self.MoveValue, variable, idx, True) |
494 else: |
495 else: |
495 rect = panel.GetAxesBoundingBox(True) |
496 rect = panel.GetAxesBoundingBox(True) |
496 if rect.InsideXY(x_mouse, y_mouse): |
497 if rect.InsideXY(x_mouse, y_mouse): |
497 merge_rect = wx.Rect(rect.x, rect.y, rect.width / 2., rect.height) |
498 merge_rect = wx.Rect(rect.x, rect.y, rect.width // 2, rect.height) |
498 if merge_rect.InsideXY(x_mouse, y_mouse): |
499 if merge_rect.InsideXY(x_mouse, y_mouse): |
499 merge_type = GRAPH_ORTHOGONAL |
500 merge_type = GRAPH_ORTHOGONAL |
500 wx.CallAfter(self.MergeGraphs, variable, idx, merge_type, force=True) |
501 wx.CallAfter(self.MergeGraphs, variable, idx, merge_type, force=True) |
501 else: |
502 else: |
502 if y_mouse > yw + height / 2: |
503 if y_mouse > yw + height // 2: |
503 idx += 1 |
504 idx += 1 |
504 wx.CallAfter(self.MoveValue, variable, idx, True) |
505 wx.CallAfter(self.MoveValue, variable, idx, True) |
505 self.ForceRefresh() |
506 self.ForceRefresh() |
506 return |
507 return |
507 width, height = self.GraphicsWindow.GetVirtualSize() |
508 width, height = self.GraphicsWindow.GetVirtualSize() |
545 if tick is not None: |
546 if tick is not None: |
546 self.TickLabel.SetLabel(label=_("Tick: %d") % tick) |
547 self.TickLabel.SetLabel(label=_("Tick: %d") % tick) |
547 tick_duration = int(tick * self.Ticktime) |
548 tick_duration = int(tick * self.Ticktime) |
548 not_null = False |
549 not_null = False |
549 duration = "" |
550 duration = "" |
550 for value, format in [(tick_duration / DAY, _("%dd")), |
551 for value, format in [(tick_duration // DAY, _("%dd")), |
551 ((tick_duration % DAY) / HOUR, _("%dh")), |
552 ((tick_duration % DAY) // HOUR, _("%dh")), |
552 ((tick_duration % HOUR) / MINUTE, _("%dm")), |
553 ((tick_duration % HOUR) // MINUTE, _("%dm")), |
553 ((tick_duration % MINUTE) / SECOND, _("%ds"))]: |
554 ((tick_duration % MINUTE) // SECOND, _("%ds"))]: |
554 |
555 |
555 if value > 0 or not_null: |
556 if value > 0 or not_null: |
556 duration += format % value |
557 duration += format % value |
557 not_null = True |
558 not_null = True |
558 |
559 |
559 duration += _("%03gms") % (float(tick_duration % SECOND) / MILLISECOND) |
560 duration += _("%03gms") % ((tick_duration % SECOND) / MILLISECOND) |
560 self.TickTimeLabel.SetLabel("t: %s" % duration) |
561 self.TickTimeLabel.SetLabel("t: %s" % duration) |
561 else: |
562 else: |
562 self.TickLabel.SetLabel("") |
563 self.TickLabel.SetLabel("") |
563 self.TickTimeLabel.SetLabel("") |
564 self.TickTimeLabel.SetLabel("") |
564 self.TickSizer.Layout() |
565 self.TickSizer.Layout() |
636 self.StartTick = max(self.Ticks[0], self.Ticks[-1] - self.CurrentRange) |
637 self.StartTick = max(self.Ticks[0], self.Ticks[-1] - self.CurrentRange) |
637 self.ForceRefresh() |
638 self.ForceRefresh() |
638 |
639 |
639 def OnRangeChanged(self, event): |
640 def OnRangeChanged(self, event): |
640 try: |
641 try: |
641 self.CurrentRange = self.RANGE_VALUES[self.CanvasRange.GetSelection()][1] / self.Ticktime |
642 self.CurrentRange = self.RANGE_VALUES[self.CanvasRange.GetSelection()][1] // self.Ticktime |
642 except ValueError: |
643 except ValueError: |
643 self.CanvasRange.SetValue(str(self.CurrentRange)) |
644 self.CanvasRange.SetValue(str(self.CurrentRange)) |
644 wx.CallAfter(self.RefreshRange) |
645 wx.CallAfter(self.RefreshRange) |
645 event.Skip() |
646 event.Skip() |
646 |
647 |
907 |
908 |
908 def RefreshGraphicsWindowScrollbars(self): |
909 def RefreshGraphicsWindowScrollbars(self): |
909 xstart, ystart = self.GraphicsWindow.GetViewStart() |
910 xstart, ystart = self.GraphicsWindow.GetViewStart() |
910 window_size = self.GraphicsWindow.GetClientSize() |
911 window_size = self.GraphicsWindow.GetClientSize() |
911 vwidth, vheight = self.GraphicsSizer.GetMinSize() |
912 vwidth, vheight = self.GraphicsSizer.GetMinSize() |
912 posx = max(0, min(xstart, (vwidth - window_size[0]) / SCROLLBAR_UNIT)) |
913 posx = max(0, min(xstart, (vwidth - window_size[0]) // SCROLLBAR_UNIT)) |
913 posy = max(0, min(ystart, (vheight - window_size[1]) / SCROLLBAR_UNIT)) |
914 posy = max(0, min(ystart, (vheight - window_size[1]) // SCROLLBAR_UNIT)) |
914 self.GraphicsWindow.Scroll(posx, posy) |
915 self.GraphicsWindow.Scroll(posx, posy) |
915 self.GraphicsWindow.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
916 self.GraphicsWindow.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
916 vwidth / SCROLLBAR_UNIT, vheight / SCROLLBAR_UNIT, |
917 vwidth // SCROLLBAR_UNIT, |
|
918 vheight // SCROLLBAR_UNIT, |
917 posx, posy) |
919 posx, posy) |
918 |
920 |
919 def OnGraphicsWindowEraseBackground(self, event): |
921 def OnGraphicsWindowEraseBackground(self, event): |
920 pass |
922 pass |
921 |
923 |