controls/DebugVariablePanel/DebugVariableGraphicViewer.py
changeset 1215 786f2533200a
parent 1214 2ef048b5383c
child 1218 a5a6072ac944
equal deleted inserted replaced
1214:2ef048b5383c 1215:786f2533200a
    56 # Colors used cyclically for graph curves
    56 # Colors used cyclically for graph curves
    57 COLOR_CYCLE = ['r', 'b', 'g', 'm', 'y', 'k']
    57 COLOR_CYCLE = ['r', 'b', 'g', 'm', 'y', 'k']
    58 # Color for graph cursor
    58 # Color for graph cursor
    59 CURSOR_COLOR = '#800080'
    59 CURSOR_COLOR = '#800080'
    60 
    60 
    61 def OrthogonalDataAndRange(item, start_tick, end_tick):
       
    62     data = item.GetData(start_tick, end_tick)
       
    63     min_value, max_value = item.GetValueRange()
       
    64     if min_value is not None and max_value is not None:
       
    65         center = (min_value + max_value) / 2.
       
    66         range = max(1.0, max_value - min_value)
       
    67     else:
       
    68         center = 0.5
       
    69         range = 1.0
       
    70     return data, center - range * 0.55, center + range * 0.55
       
    71 
       
    72 #-------------------------------------------------------------------------------
    61 #-------------------------------------------------------------------------------
    73 #                   Debug Variable Graphic Viewer Drop Target
    62 #                   Debug Variable Graphic Viewer Drop Target
    74 #-------------------------------------------------------------------------------
    63 #-------------------------------------------------------------------------------
    75 
    64 
    76 """
    65 """
    77 Class that implements a custom drop target class for Debug Variable Graphic Viewer
    66 Class that implements a custom drop target class for Debug Variable Graphic
       
    67 Viewer
    78 """
    68 """
    79 
    69 
    80 class DebugVariableGraphicDropTarget(wx.TextDropTarget):
    70 class DebugVariableGraphicDropTarget(wx.TextDropTarget):
    81     
    71     
    82     def __init__(self, parent, window):
    72     def __init__(self, parent, window):
   110         
   100         
   111         return wx.TextDropTarget.OnDragOver(self, x, y, d)
   101         return wx.TextDropTarget.OnDragOver(self, x, y, d)
   112         
   102         
   113     def OnDropText(self, x, y, data):
   103     def OnDropText(self, x, y, data):
   114         """
   104         """
   115         Function called when mouse is dragged over Drop Target
   105         Function called when mouse is released in Drop Target
   116         @param x: X coordinate of mouse pointer
   106         @param x: X coordinate of mouse pointer
   117         @param y: Y coordinate of mouse pointer
   107         @param y: Y coordinate of mouse pointer
   118         @param data: Text associated to drag'n drop
   108         @param data: Text associated to drag'n drop
   119         """
   109         """
   120         message = None
   110         message = None
  1093             else:
  1083             else:
  1094                 min_start_tick = max(start_tick, self.GetItemsMinCommonTick())
  1084                 min_start_tick = max(start_tick, self.GetItemsMinCommonTick())
  1095                 start_tick = max(start_tick, min_start_tick)
  1085                 start_tick = max(start_tick, min_start_tick)
  1096                 end_tick = max(end_tick, min_start_tick)
  1086                 end_tick = max(end_tick, min_start_tick)
  1097                 items = self.ItemsDict.values()
  1087                 items = self.ItemsDict.values()
  1098                 x_data, x_min, x_max = OrthogonalDataAndRange(items[0], start_tick, end_tick)
  1088                 x_data, x_min, x_max = items[0].OrthogonalDataAndRange(start_tick, end_tick)
  1099                 y_data, y_min, y_max = OrthogonalDataAndRange(items[1], start_tick, end_tick)
  1089                 y_data, y_min, y_max = items[1].OrthogonalDataAndRange(start_tick, end_tick)
  1100                 if self.CursorTick is not None:
  1090                 if self.CursorTick is not None:
  1101                     x_cursor, x_forced = items[0].GetValue(self.CursorTick, raw=True)
  1091                     x_cursor, x_forced = items[0].GetValue(self.CursorTick, raw=True)
  1102                     y_cursor, y_forced = items[1].GetValue(self.CursorTick, raw=True)
  1092                     y_cursor, y_forced = items[1].GetValue(self.CursorTick, raw=True)
  1103                 length = 0
  1093                 length = 0
  1104                 if x_data is not None and y_data is not None:  
  1094                 if x_data is not None and y_data is not None:  
  1131                         if self.HLine is not None:
  1121                         if self.HLine is not None:
  1132                             self.HLine.set_visible(False)
  1122                             self.HLine.set_visible(False)
  1133                 else:
  1123                 else:
  1134                     while len(self.Axes.lines) > 0:
  1124                     while len(self.Axes.lines) > 0:
  1135                         self.Axes.lines.pop()
  1125                         self.Axes.lines.pop()
  1136                     z_data, z_min, z_max = OrthogonalDataAndRange(items[2], start_tick, end_tick)
  1126                     z_data, z_min, z_max = items[2].OrthogonalDataAndRange(start_tick, end_tick)
  1137                     if self.CursorTick is not None:
  1127                     if self.CursorTick is not None:
  1138                         z_cursor, z_forced = items[2].GetValue(self.CursorTick, raw=True)
  1128                         z_cursor, z_forced = items[2].GetValue(self.CursorTick, raw=True)
  1139                     if x_data is not None and y_data is not None and z_data is not None:
  1129                     if x_data is not None and y_data is not None and z_data is not None:
  1140                         length = min(length, len(z_data))
  1130                         length = min(length, len(z_data))
  1141                         self.Axes.plot(x_data[:, 1][:length],
  1131                         self.Axes.plot(x_data[:, 1][:length],