controls/DebugVariablePanel/DebugVariableGraphicViewer.py
changeset 1847 6198190bc121
parent 1832 0f1081928d65
child 1850 614396cbffbf
equal deleted inserted replaced
1846:14b40afccd69 1847:6198190bc121
   191                 wx.CallAfter(self.ParentWindow.MergeGraphs,
   191                 wx.CallAfter(self.ParentWindow.MergeGraphs,
   192                              values[0], target_idx,
   192                              values[0], target_idx,
   193                              merge_type, force=True)
   193                              merge_type, force=True)
   194 
   194 
   195             else:
   195             else:
   196                 width, height = self.ParentControl.GetSize()
   196                 _width, height = self.ParentControl.GetSize()
   197 
   197 
   198                 # Get Before which Viewer the variable has to be moved or added
   198                 # Get Before which Viewer the variable has to be moved or added
   199                 # according to the position of mouse in Viewer.
   199                 # according to the position of mouse in Viewer.
   200                 if y > height / 2:
   200                 if y > height / 2:
   201                     target_idx += 1
   201                     target_idx += 1
   608         Function called when a button of mouse is pressed
   608         Function called when a button of mouse is pressed
   609         @param event: Mouse event
   609         @param event: Mouse event
   610         """
   610         """
   611         # Get mouse position, graph Y coordinate is inverted in matplotlib
   611         # Get mouse position, graph Y coordinate is inverted in matplotlib
   612         # comparing to wx
   612         # comparing to wx
   613         width, height = self.GetSize()
   613         _width, height = self.GetSize()
   614         x, y = event.x, height - event.y
   614         x, y = event.x, height - event.y
   615 
   615 
   616         # Return immediately if mouse is over a button
   616         # Return immediately if mouse is over a button
   617         if self.IsOverButton(x, y):
   617         if self.IsOverButton(x, y):
   618             return
   618             return
   677         Function called when a button of mouse is released
   677         Function called when a button of mouse is released
   678         @param event: Mouse event
   678         @param event: Mouse event
   679         """
   679         """
   680         # If a drag'n drop is in progress, stop it
   680         # If a drag'n drop is in progress, stop it
   681         if self.ParentWindow.IsDragging():
   681         if self.ParentWindow.IsDragging():
   682             width, height = self.GetSize()
   682             _width, height = self.GetSize()
   683             xw, yw = self.GetPosition()
   683             xw, yw = self.GetPosition()
   684             item = self.ParentWindow.DraggingAxesPanel.ItemsDict.values()[0]
   684             item = self.ParentWindow.DraggingAxesPanel.ItemsDict.values()[0]
   685             # Give mouse position in wx coordinate of parent
   685             # Give mouse position in wx coordinate of parent
   686             self.ParentWindow.StopDragNDrop(item.GetVariable(),
   686             self.ParentWindow.StopDragNDrop(item.GetVariable(),
   687                                             xw + event.x, yw + height - event.y)
   687                                             xw + event.x, yw + height - event.y)
   690             # Reset any move in progress
   690             # Reset any move in progress
   691             self.MouseStartPos = None
   691             self.MouseStartPos = None
   692             self.CanvasStartSize = None
   692             self.CanvasStartSize = None
   693 
   693 
   694             # Handle button under mouse if it exist
   694             # Handle button under mouse if it exist
   695             width, height = self.GetSize()
   695             _width, height = self.GetSize()
   696             self.HandleButton(event.x, height - event.y)
   696             self.HandleButton(event.x, height - event.y)
   697 
   697 
   698     def OnCanvasMotion(self, event):
   698     def OnCanvasMotion(self, event):
   699         """
   699         """
   700         Function called when a button of mouse is moved over Viewer
   700         Function called when a button of mouse is moved over Viewer
   701         @param event: Mouse event
   701         @param event: Mouse event
   702         """
   702         """
   703         width, height = self.GetSize()
   703         _width, height = self.GetSize()
   704 
   704 
   705         # If a drag'n drop is in progress, move canvas dragged
   705         # If a drag'n drop is in progress, move canvas dragged
   706         if self.ParentWindow.IsDragging():
   706         if self.ParentWindow.IsDragging():
   707             xw, yw = self.GetPosition()
   707             xw, yw = self.GetPosition()
   708             # Give mouse position in wx coordinate of parent
   708             # Give mouse position in wx coordinate of parent
   710                 xw + event.x,
   710                 xw + event.x,
   711                 yw + height - event.y)
   711                 yw + height - event.y)
   712 
   712 
   713         # If a Viewer resize is in progress, change Viewer size
   713         # If a Viewer resize is in progress, change Viewer size
   714         elif event.button == 1 and self.CanvasStartSize is not None:
   714         elif event.button == 1 and self.CanvasStartSize is not None:
   715             width, height = self.GetSize()
   715             _width, height = self.GetSize()
   716             self.SetCanvasHeight(
   716             self.SetCanvasHeight(
   717                 self.CanvasStartSize + height - event.y - self.MouseStartPos.y)
   717                 self.CanvasStartSize + height - event.y - self.MouseStartPos.y)
   718 
   718 
   719         # If no button is pressed, show or hide contextual buttons or resize
   719         # If no button is pressed, show or hide contextual buttons or resize
   720         # highlight
   720         # highlight
   924         """
   924         """
   925         Refresh Viewer highlight according to mouse position
   925         Refresh Viewer highlight according to mouse position
   926         @param x: X coordinate of mouse pointer
   926         @param x: X coordinate of mouse pointer
   927         @param y: Y coordinate of mouse pointer
   927         @param y: Y coordinate of mouse pointer
   928         """
   928         """
   929         width, height = self.GetSize()
   929         _width, height = self.GetSize()
   930 
   930 
   931         # Mouse is over Viewer figure and graph is not 3D
   931         # Mouse is over Viewer figure and graph is not 3D
   932         bbox = self.GetAxesBoundingBox()
   932         bbox = self.GetAxesBoundingBox()
   933         if bbox.InsideXY(x, y) and not self.Is3DCanvas():
   933         if bbox.InsideXY(x, y) and not self.Is3DCanvas():
   934             rect = wx.Rect(bbox.x, bbox.y, bbox.width / 2, bbox.height)
   934             rect = wx.Rect(bbox.x, bbox.y, bbox.width / 2, bbox.height)
  1068             self.Labels.append(
  1068             self.Labels.append(
  1069                 add_text_func(size='large', rotation='vertical',
  1069                 add_text_func(size='large', rotation='vertical',
  1070                               verticalalignment='top'))
  1070                               verticalalignment='top'))
  1071 
  1071 
  1072         # Refresh position of labels according to Viewer size
  1072         # Refresh position of labels according to Viewer size
  1073         width, height = self.GetSize()
  1073         _width, height = self.GetSize()
  1074         self.RefreshLabelsPosition(height)
  1074         self.RefreshLabelsPosition(height)
  1075 
  1075 
  1076     def RefreshLabelsPosition(self, height):
  1076     def RefreshLabelsPosition(self, height):
  1077         """
  1077         """
  1078         Function called when mouse leave Viewer
  1078         Function called when mouse leave Viewer
  1207                 x_min, x_max = merge_ranges([(x_min, x_max)])
  1207                 x_min, x_max = merge_ranges([(x_min, x_max)])
  1208                 y_min, y_max = merge_ranges([(y_min, y_max)])
  1208                 y_min, y_max = merge_ranges([(y_min, y_max)])
  1209 
  1209 
  1210                 # Get X and Y coordinates for cursor if cursor tick is defined
  1210                 # Get X and Y coordinates for cursor if cursor tick is defined
  1211                 if self.CursorTick is not None:
  1211                 if self.CursorTick is not None:
  1212                     x_cursor, x_forced = items[0].GetValue(
  1212                     x_cursor, _x_forced = items[0].GetValue(
  1213                                             self.CursorTick, raw=True)
  1213                                             self.CursorTick, raw=True)
  1214                     y_cursor, y_forced = items[1].GetValue(
  1214                     y_cursor, _y_forced = items[1].GetValue(
  1215                                             self.CursorTick, raw=True)
  1215                                             self.CursorTick, raw=True)
  1216 
  1216 
  1217                 # Get common data length so that each value has an x and y
  1217                 # Get common data length so that each value has an x and y
  1218                 # coordinate
  1218                 # coordinate
  1219                 length = (min(len(x_data), len(y_data))
  1219                 length = (min(len(x_data), len(y_data))
  1303                     # it is include in values tick range
  1303                     # it is include in values tick range
  1304                     if self.CursorTick is not None and \
  1304                     if self.CursorTick is not None and \
  1305                        start_tick <= self.CursorTick <= end_tick:
  1305                        start_tick <= self.CursorTick <= end_tick:
  1306 
  1306 
  1307                         # Get Z coordinate for cursor
  1307                         # Get Z coordinate for cursor
  1308                         z_cursor, z_forced = items[2].GetValue(
  1308                         z_cursor, _z_forced = items[2].GetValue(
  1309                                                 self.CursorTick, raw=True)
  1309                                                 self.CursorTick, raw=True)
  1310 
  1310 
  1311                         # Add 3 lines parallel to x, y and z axis to display
  1311                         # Add 3 lines parallel to x, y and z axis to display
  1312                         # cursor position in 3D
  1312                         # cursor position in 3D
  1313                         for kwargs in [{"xs": numpy.array([x_min, x_max])},
  1313                         for kwargs in [{"xs": numpy.array([x_min, x_max])},