# HG changeset patch
# User Laurent Bessard
# Date 1342176122 -7200
# Node ID 57b6446d54f850da4b5b816347f5556b3112fff6
# Parent 5df934c273e1ce0e059ce166e6ac0ab6dacc316b
Adding support for using middle button for moving debug graph
Adding button for resetting zoom and of position of debug graph
diff -r 5df934c273e1 -r 57b6446d54f8 GraphicViewer.py
--- a/GraphicViewer.py Fri Jul 13 12:27:05 2012 +0200
+++ b/GraphicViewer.py Fri Jul 13 12:42:02 2012 +0200
@@ -75,12 +75,14 @@
self.Canvas.SetYSpec('border')
self.Canvas.canvas.Bind(wx.EVT_LEFT_DOWN, self.OnCanvasLeftDown)
self.Canvas.canvas.Bind(wx.EVT_LEFT_UP, self.OnCanvasLeftUp)
+ self.Canvas.canvas.Bind(wx.EVT_MIDDLE_DOWN, self.OnCanvasMiddleDown)
+ self.Canvas.canvas.Bind(wx.EVT_MIDDLE_UP, self.OnCanvasMiddleUp)
self.Canvas.canvas.Bind(wx.EVT_MOTION, self.OnCanvasMotion)
self.Canvas.canvas.Bind(wx.EVT_MOUSEWHEEL, self.OnCanvasMouseWheel)
self.Canvas.canvas.Bind(wx.EVT_SIZE, self.OnCanvasResize)
main_sizer.AddWindow(self.Canvas, 0, border=0, flag=wx.GROW)
- range_sizer = wx.FlexGridSizer(cols=9, hgap=5, rows=1, vgap=0)
+ range_sizer = wx.FlexGridSizer(cols=10, hgap=5, rows=1, vgap=0)
range_sizer.AddGrowableCol(5)
range_sizer.AddGrowableRow(0)
main_sizer.AddSizer(range_sizer, 0, border=5, flag=wx.GROW|wx.ALL)
@@ -131,6 +133,13 @@
self.Bind(wx.EVT_BUTTON, self.OnCurrentButton, self.CurrentButton)
range_sizer.AddWindow(self.CurrentButton, 0, border=0, flag=0)
+ self.ResetZoomOffsetButton = wx.lib.buttons.GenBitmapButton(self.Editor,
+ bitmap=GetBitmap("fit"), size=wx.Size(28, 28), style=wx.NO_BORDER)
+ self.CurrentButton.SetToolTipString(_("Reset zoom and offset"))
+ self.Bind(wx.EVT_BUTTON, self.OnResetZoomOffsetButton,
+ self.ResetZoomOffsetButton)
+ range_sizer.AddWindow(self.ResetZoomOffsetButton, 0, border=0, flag=0)
+
self.ExportGraphButton = wx.lib.buttons.GenBitmapButton(self.Editor,
bitmap=GetBitmap("export_graph"), size=wx.Size(28, 28), style=wx.NO_BORDER)
self.ExportGraphButton.SetToolTipString(_("Export graph values to clipboard"))
@@ -162,7 +171,7 @@
self.MinValue = None
self.MaxValue = None
self.YCenter = 0
- self.CurrentZoom = 1
+ self.CurrentZoom = 1.0
self.Fixed = False
self.Ticktime = self.DataProducer.GetTicktime()
self.RefreshCanvasRange()
@@ -285,7 +294,8 @@
return self.InstancePath == tagname
def NewValue(self, tick, value, forced=False):
- self.Datas.append((float(tick), {True:1., False:0.}.get(value, float(value))))
+ value = {True:1., False:0.}.get(value, float(value))
+ self.Datas.append((float(tick), value))
if self.MinValue is None:
self.MinValue = value
else:
@@ -340,10 +350,11 @@
event.Skip()
def OnPositionChanging(self, event):
- self.ResetBounds()
- self.StartTick = self.Datas[0][0] + event.GetPosition()
- self.Fixed = True
- self.NewDataAvailable(True)
+ if len(self.Datas) > 0:
+ self.ResetBounds()
+ self.StartTick = self.Datas[0][0] + event.GetPosition()
+ self.Fixed = True
+ self.NewDataAvailable(True)
event.Skip()
def OnResetButton(self, event):
@@ -352,10 +363,21 @@
event.Skip()
def OnCurrentButton(self, event):
- self.ResetBounds()
- self.StartTick = max(self.Datas[0][0], self.Datas[-1][0] - self.CurrentRange)
- self.Fixed = False
- self.NewDataAvailable(True)
+ if len(self.Datas) > 0:
+ self.ResetBounds()
+ self.StartTick = max(self.Datas[0][0], self.Datas[-1][0] - self.CurrentRange)
+ self.Fixed = False
+ self.NewDataAvailable(True)
+ event.Skip()
+
+ def OnResetZoomOffsetButton(self, event):
+ if len(self.Datas) > 0:
+ self.YCenter = (self.MaxValue + self.MinValue) / 2
+ else:
+ self.YCenter = 0.0
+ self.CurrentZoom = 1.0
+ self.CanvasZoom.SetSelection(0)
+ wx.CallAfter(self.RefreshView, True)
event.Skip()
def OnExportGraphButtonClick(self, event):
@@ -380,7 +402,7 @@
self.CurrentMousePos = event.GetPosition()
self.CurrentMotionValue = self.Datas[self.StartIdx][0]
event.Skip()
-
+
def OnCanvasLeftUp(self, event):
self.Dragging = False
if self.Mode == MODE_MOTION:
@@ -389,6 +411,22 @@
if self.Canvas.canvas.HasCapture():
self.Canvas.canvas.ReleaseMouse()
event.Skip()
+
+ def OnCanvasMiddleDown(self, event):
+ self.Fixed = True
+ self.Canvas.canvas.CaptureMouse()
+ if len(self.Datas) > 0:
+ self.GetBounds()
+ self.CurrentMousePos = event.GetPosition()
+ self.CurrentMotionValue = self.Datas[self.StartIdx][0]
+ event.Skip()
+
+ def OnCanvasMiddleUp(self, event):
+ self.CurrentMousePos = None
+ self.CurrentMotionValue = None
+ if self.Canvas.canvas.HasCapture():
+ self.Canvas.canvas.ReleaseMouse()
+ event.Skip()
def OnCanvasMotion(self, event):
if self.Mode == MODE_SELECTION and self.Dragging:
diff -r 5df934c273e1 -r 57b6446d54f8 Images/fit.png
Binary file Images/fit.png has changed
diff -r 5df934c273e1 -r 57b6446d54f8 Images/icons.svg
--- a/Images/icons.svg Fri Jul 13 12:27:05 2012 +0200
+++ b/Images/icons.svg Fri Jul 13 12:42:02 2012 +0200
@@ -8942,6 +8942,207 @@
style="stop-color:#acbbff;stop-opacity:0"
id="stop2194-4" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ %%fit%%
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+