Improved matplotlib graphic debug panel implementation
authorLaurent Bessard
Wed, 20 Feb 2013 01:18:08 +0100
changeset 932 ebe63100b6d7
parent 931 da4970f6c46c
child 933 6c320534627e
Improved matplotlib graphic debug panel implementation
controls/DebugVariablePanel.py
--- a/controls/DebugVariablePanel.py	Wed Feb 20 00:53:19 2013 +0100
+++ b/controls/DebugVariablePanel.py	Wed Feb 20 01:18:08 2013 +0100
@@ -969,6 +969,7 @@
                     self.ParentWindow.StartDragNDrop(self, 
                         self.Items[item_idx], x + xw, y + yw, x + xw, y + yw)
                 elif event.button == 1 and event.inaxes == self.Axes:
+                    self.StartCursorTick = self.CursorTick
                     self.HandleCursorMove(event)
                 elif event.button == 2 and self.GraphType == GRAPH_PARALLEL:
                     width, height = self.Canvas.GetSize()
@@ -1004,6 +1005,7 @@
                             self.HandleCursorMove(event)
                     elif self.MouseStartPos is not None and len(self.Items) == 1:
                         xw, yw = self.GetPosition()
+                        self.ParentWindow.SetCursorTick(self.StartCursorTick)
                         self.ParentWindow.StartDragNDrop(self, 
                             self.Items[0],
                             event.x + xw, height - event.y + yw, 
@@ -1087,14 +1089,6 @@
             if cursor_tick is not None:
                 self.ParentWindow.SetCursorTick(cursor_tick)
         
-        def DoDragDrop(self, item_idx):
-            self.Canvas.ShowButtons(False)
-            self.Canvas.DismissContextualButtons()
-            data = wx.TextDataObject(str((self.Items[item_idx].GetVariable(), "debug", "move")))
-            dragSource = wx.DropSource(self.Canvas)
-            dragSource.SetData(data)
-            dragSource.DoDragDrop()
-        
         def OnAxesMotion(self, event):
             if self.Is3DCanvas():
                 current_time = gettime()
@@ -1816,7 +1810,7 @@
             menu.Destroy()
         event.Skip()
     
-    def ChangeRange(self, dir, tick):
+    def ChangeRange(self, dir, tick=None):
         current_range = self.CurrentRange
         current_range_idx = self.CanvasRange.GetSelection()
         new_range_idx = max(0, min(current_range_idx + dir, len(self.RangeValues) - 1))
@@ -1827,6 +1821,8 @@
             else:
                 self.CurrentRange = self.RangeValues[new_range_idx][1] / self.Ticktime
             if len(self.Ticks) > 0:
+                if tick is None:
+                    tick = self.StartTick + self.CurrentRange / 2.
                 new_start_tick = tick - (tick - self.StartTick) * self.CurrentRange / current_range 
                 self.StartTick = self.Ticks[numpy.argmin(numpy.abs(self.Ticks - new_start_tick))]
                 self.Fixed = self.StartTick < self.Ticks[-1] - self.CurrentRange