controls/DebugVariablePanel/DebugVariableGraphicPanel.py
changeset 1217 b64dcc1a011f
parent 1216 598ff0043ad3
child 1218 a5a6072ac944
--- a/controls/DebugVariablePanel/DebugVariableGraphicPanel.py	Mon Jun 03 22:48:42 2013 +0200
+++ b/controls/DebugVariablePanel/DebugVariableGraphicPanel.py	Tue Jun 04 09:12:03 2013 +0200
@@ -732,6 +732,8 @@
     def InsertValue(self, iec_path, idx = None, force=False, graph=False):
         for panel in self.GraphicPanels:
             if panel.GetItem(iec_path) is not None:
+                if graph and isinstance(panel, DebugVariableTextViewer):
+                    self.ToggleViewerType(panel)
                 return
         if idx is None:
             idx = len(self.GraphicPanels)
@@ -767,28 +769,31 @@
                 break
         if source_panel is not None:
             source_panel_idx = self.GraphicPanels.index(source_panel)
-            if len(panel.GetItems()) == 1 and \
-               idx in [source_panel_idx, source_panel_idx + 1]:
-                return
-            
-            source_panel.RemoveItem(item)
-            source_size = source_panel.GetSize()
-            if item.IsNumVariable() and graph:
-                panel = DebugVariableGraphicViewer(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
-                panel.SetCanvasSize(source_size.width, source_size.height)
-                if self.CursorTick is not None:
-                    panel.SetCursorTick(self.CursorTick)
-            
-            else:
-                panel = DebugVariableTextViewer(self.GraphicsWindow, self, [item])
-            
-            self.GraphicPanels.insert(idx, panel)
-            
-            if source_panel.ItemsIsEmpty():
-                if source_panel.HasCapture():
-                    source_panel.ReleaseMouse()
-                source_panel.Destroy()
-                self.GraphicPanels.remove(source_panel)
+            
+            if (len(panel.GetItems()) == 1):
+                
+                self.GraphicPanels.insert(idx, source_panel)
+                self.GraphicPanels.pop(source_panel_idx)
+                
+            else:
+                source_panel.RemoveItem(item)
+                source_size = source_panel.GetSize()
+                if item.IsNumVariable() and graph:
+                    panel = DebugVariableGraphicViewer(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
+                    panel.SetCanvasSize(source_size.width, source_size.height)
+                    if self.CursorTick is not None:
+                        panel.SetCursorTick(self.CursorTick)
+                
+                else:
+                    panel = DebugVariableTextViewer(self.GraphicsWindow, self, [item])
+                
+                self.GraphicPanels.insert(idx, panel)
+                
+                if source_panel.ItemsIsEmpty():
+                    if source_panel.HasCapture():
+                        source_panel.ReleaseMouse()
+                    source_panel.Destroy()
+                    self.GraphicPanels.remove(source_panel)
                 
             self.ResetVariableNameMask()
             self.RefreshGraphicsSizer()