controls/DebugVariablePanel/DebugVariableGraphicPanel.py
changeset 1217 b64dcc1a011f
parent 1216 598ff0043ad3
child 1218 a5a6072ac944
equal deleted inserted replaced
1216:598ff0043ad3 1217:b64dcc1a011f
   730         return self.VariableNameMask
   730         return self.VariableNameMask
   731     
   731     
   732     def InsertValue(self, iec_path, idx = None, force=False, graph=False):
   732     def InsertValue(self, iec_path, idx = None, force=False, graph=False):
   733         for panel in self.GraphicPanels:
   733         for panel in self.GraphicPanels:
   734             if panel.GetItem(iec_path) is not None:
   734             if panel.GetItem(iec_path) is not None:
       
   735                 if graph and isinstance(panel, DebugVariableTextViewer):
       
   736                     self.ToggleViewerType(panel)
   735                 return
   737                 return
   736         if idx is None:
   738         if idx is None:
   737             idx = len(self.GraphicPanels)
   739             idx = len(self.GraphicPanels)
   738         item = DebugVariableItem(self, iec_path, True)
   740         item = DebugVariableItem(self, iec_path, True)
   739         result = self.AddDataConsumer(iec_path.upper(), item)
   741         result = self.AddDataConsumer(iec_path.upper(), item)
   765             if item is not None:
   767             if item is not None:
   766                 source_panel = panel
   768                 source_panel = panel
   767                 break
   769                 break
   768         if source_panel is not None:
   770         if source_panel is not None:
   769             source_panel_idx = self.GraphicPanels.index(source_panel)
   771             source_panel_idx = self.GraphicPanels.index(source_panel)
   770             if len(panel.GetItems()) == 1 and \
   772             
   771                idx in [source_panel_idx, source_panel_idx + 1]:
   773             if (len(panel.GetItems()) == 1):
   772                 return
   774                 
   773             
   775                 self.GraphicPanels.insert(idx, source_panel)
   774             source_panel.RemoveItem(item)
   776                 self.GraphicPanels.pop(source_panel_idx)
   775             source_size = source_panel.GetSize()
   777                 
   776             if item.IsNumVariable() and graph:
   778             else:
   777                 panel = DebugVariableGraphicViewer(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
   779                 source_panel.RemoveItem(item)
   778                 panel.SetCanvasSize(source_size.width, source_size.height)
   780                 source_size = source_panel.GetSize()
   779                 if self.CursorTick is not None:
   781                 if item.IsNumVariable() and graph:
   780                     panel.SetCursorTick(self.CursorTick)
   782                     panel = DebugVariableGraphicViewer(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
   781             
   783                     panel.SetCanvasSize(source_size.width, source_size.height)
   782             else:
   784                     if self.CursorTick is not None:
   783                 panel = DebugVariableTextViewer(self.GraphicsWindow, self, [item])
   785                         panel.SetCursorTick(self.CursorTick)
   784             
   786                 
   785             self.GraphicPanels.insert(idx, panel)
   787                 else:
   786             
   788                     panel = DebugVariableTextViewer(self.GraphicsWindow, self, [item])
   787             if source_panel.ItemsIsEmpty():
   789                 
   788                 if source_panel.HasCapture():
   790                 self.GraphicPanels.insert(idx, panel)
   789                     source_panel.ReleaseMouse()
   791                 
   790                 source_panel.Destroy()
   792                 if source_panel.ItemsIsEmpty():
   791                 self.GraphicPanels.remove(source_panel)
   793                     if source_panel.HasCapture():
       
   794                         source_panel.ReleaseMouse()
       
   795                     source_panel.Destroy()
       
   796                     self.GraphicPanels.remove(source_panel)
   792                 
   797                 
   793             self.ResetVariableNameMask()
   798             self.ResetVariableNameMask()
   794             self.RefreshGraphicsSizer()
   799             self.RefreshGraphicsSizer()
   795             self.ForceRefresh()
   800             self.ForceRefresh()
   796     
   801