--- a/controls/DebugVariablePanel.py Wed Jan 30 19:03:25 2013 +0100
+++ b/controls/DebugVariablePanel.py Wed Jan 30 19:07:59 2013 +0100
@@ -273,7 +273,12 @@
target_idx = self.ParentControl.GetIndex()
merge_type = GRAPH_PARALLEL
if self.ParentControl.Is3DCanvas():
- self.ParentWindow.InsertValue(values[0], target_idx, force=True)
+ if len(values) > 2 and values[2] == "move": + self.ParentWindow.MoveGraph(values[0], target_idx) + self.ParentWindow.InsertValue(values[0], target_idx, force=True) ax, ay, aw, ah = self.ParentControl.Axes.get_position().bounds
rect = wx.Rect(ax * width, height - (ay + ah) * height,
@@ -285,7 +290,14 @@
merge_type = GRAPH_ORTHOGONAL
wx.CallAfter(self.ParentWindow.MergeGraphs, values[0], target_idx, merge_type, force=True)
- self.ParentWindow.InsertValue(values[0], target_idx, force=True)
+ if len(values) > 2 and values[2] == "move": + self.ParentWindow.MoveGraph(values[0], target_idx) + self.ParentWindow.InsertValue(values[0], target_idx, force=True) + elif len(values) > 2 and values[2] == "move": + self.ParentWindow.MoveGraph(values[0]) self.ParentWindow.InsertValue(values[0], force=True)
@@ -572,23 +584,40 @@
button_sizer.AddWindow(button, border=5, flag=wx.LEFT)
def OnCanvasClick(self, event):
+ x, y = event.GetPosition() + width, height = self.Canvas.GetSize() - width, height = self.Canvas.GetSize()
- x, y = event.GetPosition()
ax, ay, aw, ah = self.Axes.get_position().bounds
rect = wx.Rect(ax * width, height - (ay + ah) * height,
- data = wx.TextDataObject(str((self.Items[0].GetVariable(), "debug")))
- dragSource = wx.DropSource(self.Canvas)
- dragSource.SetData(data)
- dragSource.DoDragDrop()
+ elif self.Legend is not None: + for i, t in enumerate(self.Legend.get_texts()): + (x0, y0), (x1, y1) = t.get_window_extent().get_points() + rect = wx.Rect(x0, height - y1, x1 - x0, y1 - y0) + if rect.InsideXY(x, y): + if item_idx is not None: + self.DoDragDrop(item_idx) + def DoDragDrop(self, item_idx): + data = wx.TextDataObject(str((self.Items[item_idx].GetVariable(), "debug", "move"))) + dragSource = wx.DropSource(self.Canvas) + dragSource.SetData(data) + dragSource.DoDragDrop() def OnMotion(self, event):
- current_time = gettime()
- if current_time - self.LastMotionTime > REFRESH_PERIOD:
- self.LastMotionTime = current_time
- Axes3D._on_move(self.Axes, event)
+ current_time = gettime() + if current_time - self.LastMotionTime > REFRESH_PERIOD: + self.LastMotionTime = current_time + Axes3D._on_move(self.Axes, event) def OnSplitButton(self, event):
if len(self.Items) == 2 or self.GraphType == GRAPH_ORTHOGONAL:
@@ -713,16 +742,17 @@
self.Axes.set_xlim(x_min, x_max)
self.Axes.set_ylim(y_min, y_max)
- labels = ["%s: %s" % (item.GetVariable(), item.GetValue())
+ labels = ["%s: %s" % (item.GetVariable(40), item.GetValue()) colors = [{True: 'b', False: 'k'}[item.IsForced()] for item in self.Items]
if self.GraphType == GRAPH_PARALLEL:
- legend = self.Axes.legend(self.Plots, labels,
+ self.Legend = self.Axes.legend(self.Plots, labels, loc="upper left", frameon=False,
- for t, color in zip(legend.get_texts(), colors):
+ for t, color in zip(self.Legend.get_texts(), colors): self.Axes.set_xlabel(labels[0], fontdict={'size':'small','color':colors[0]})
self.Axes.set_ylabel(labels[1], fontdict={'size':'small','color':colors[1]})
@@ -1159,6 +1189,29 @@
+ def MoveGraph(self, iec_path, idx = None): + idx = len(self.GraphicPanels) + for panel in self.GraphicPanels: + item = panel.GetItem(iec_path) + if source_panel is not None: + source_panel.RemoveItem(item) + if source_panel.IsEmpty(): + if source_panel.Canvas.HasCapture(): + source_panel.Canvas.ReleaseMouse() + self.GraphicPanels.remove(source_panel) + panel = DebugVariableGraphic(self.GraphicsWindow, self, [item], GRAPH_PARALLEL) + self.GraphicPanels.insert(idx, panel) + self.RefreshGraphicsSizer() def SplitGraphs(self, source_panel, item=None):
source_idx = self.GetViewerIndex(source_panel)
if source_idx is not None: