controls/DebugVariablePanel/DebugVariableGraphicViewer.py
changeset 2437 105c20fdeb19
parent 2432 dbc065a2f7a5
child 2440 45b43f275ca1
equal deleted inserted replaced
2436:82bfc75bcd9d 2437:105c20fdeb19
    22 # along with this program; if not, write to the Free Software
    22 # along with this program; if not, write to the Free Software
    23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    24 
    24 
    25 
    25 
    26 from __future__ import absolute_import
    26 from __future__ import absolute_import
       
    27 from __future__ import division
    27 from types import TupleType
    28 from types import TupleType
    28 from time import time as gettime
    29 from time import time as gettime
    29 from cycler import cycler
    30 from cycler import cycler
    30 
    31 
    31 import numpy
    32 import numpy
   193             else:
   194             else:
   194                 _width, height = self.ParentControl.GetSize()
   195                 _width, height = self.ParentControl.GetSize()
   195 
   196 
   196                 # Get Before which Viewer the variable has to be moved or added
   197                 # Get Before which Viewer the variable has to be moved or added
   197                 # according to the position of mouse in Viewer.
   198                 # according to the position of mouse in Viewer.
   198                 if y > height / 2:
   199                 if y > height // 2:
   199                     target_idx += 1
   200                     target_idx += 1
   200 
   201 
   201                 # Drag'n Drop is an internal is an internal move inside Debug
   202                 # Drag'n Drop is an internal is an internal move inside Debug
   202                 # Variable Panel
   203                 # Variable Panel
   203                 if len(values) > 2 and values[2] == "move":
   204                 if len(values) > 2 and values[2] == "move":
   441             w, h = button.GetSize()
   442             w, h = button.GetSize()
   442             if direction in [wx.LEFT, wx.RIGHT]:
   443             if direction in [wx.LEFT, wx.RIGHT]:
   443                 x = rect.x + (- w - offset
   444                 x = rect.x + (- w - offset
   444                               if direction == wx.LEFT
   445                               if direction == wx.LEFT
   445                               else rect.width + offset)
   446                               else rect.width + offset)
   446                 y = rect.y + (rect.height - h) / 2
   447                 y = rect.y + (rect.height - h) // 2
   447                 offset += w
   448                 offset += w
   448             else:
   449             else:
   449                 x = rect.x + (rect.width - w) / 2
   450                 x = rect.x + (rect.width - w) // 2
   450                 y = rect.y + (- h - offset
   451                 y = rect.y + (- h - offset
   451                               if direction == wx.TOP
   452                               if direction == wx.TOP
   452                               else rect.height + offset)
   453                               else rect.height + offset)
   453                 offset += h
   454                 offset += h
   454             button.SetPosition(x, y)
   455             button.SetPosition(x, y)
   799 
   800 
   800                 # Move graph along X coordinate
   801                 # Move graph along X coordinate
   801                 self.ParentWindow.SetCanvasPosition(
   802                 self.ParentWindow.SetCanvasPosition(
   802                     self.StartCursorTick +
   803                     self.StartCursorTick +
   803                     (self.MouseStartPos.x - event.x) *
   804                     (self.MouseStartPos.x - event.x) *
   804                     (end_tick - start_tick) / rect.width)
   805                     (end_tick - start_tick) // rect.width)
   805 
   806 
   806     def OnCanvasScroll(self, event):
   807     def OnCanvasScroll(self, event):
   807         """
   808         """
   808         Function called when a wheel mouse is use in Viewer
   809         Function called when a wheel mouse is use in Viewer
   809         @param event: Mouse event
   810         @param event: Mouse event
   817             if self.GraphType == GRAPH_ORTHOGONAL:
   818             if self.GraphType == GRAPH_ORTHOGONAL:
   818                 start_tick, end_tick = self.ParentWindow.GetRange()
   819                 start_tick, end_tick = self.ParentWindow.GetRange()
   819                 tick = (start_tick + end_tick) / 2.
   820                 tick = (start_tick + end_tick) / 2.
   820             else:
   821             else:
   821                 tick = event.xdata
   822                 tick = event.xdata
   822             self.ParentWindow.ChangeRange(int(-event.step) / 3, tick)
   823             self.ParentWindow.ChangeRange(int(-event.step) // 3, tick)
   823 
   824 
   824             # Vetoing event to prevent parent panel to be scrolled
   825             # Vetoing event to prevent parent panel to be scrolled
   825             self.ParentWindow.VetoScrollEvent = True
   826             self.ParentWindow.VetoScrollEvent = True
   826 
   827 
   827     def OnLeftDClick(self, event):
   828     def OnLeftDClick(self, event):
   925         _width, height = self.GetSize()
   926         _width, height = self.GetSize()
   926 
   927 
   927         # Mouse is over Viewer figure and graph is not 3D
   928         # Mouse is over Viewer figure and graph is not 3D
   928         bbox = self.GetAxesBoundingBox()
   929         bbox = self.GetAxesBoundingBox()
   929         if bbox.InsideXY(x, y) and not self.Is3DCanvas():
   930         if bbox.InsideXY(x, y) and not self.Is3DCanvas():
   930             rect = wx.Rect(bbox.x, bbox.y, bbox.width / 2, bbox.height)
   931             rect = wx.Rect(bbox.x, bbox.y, bbox.width // 2, bbox.height)
   931             # Mouse is over Viewer left part of figure
   932             # Mouse is over Viewer left part of figure
   932             if rect.InsideXY(x, y):
   933             if rect.InsideXY(x, y):
   933                 self.SetHighlight(HIGHLIGHT_LEFT)
   934                 self.SetHighlight(HIGHLIGHT_LEFT)
   934 
   935 
   935             # Mouse is over Viewer right part of figure
   936             # Mouse is over Viewer right part of figure
   936             else:
   937             else:
   937                 self.SetHighlight(HIGHLIGHT_RIGHT)
   938                 self.SetHighlight(HIGHLIGHT_RIGHT)
   938 
   939 
   939         # Mouse is over upper part of Viewer
   940         # Mouse is over upper part of Viewer
   940         elif y < height / 2:
   941         elif y < height // 2:
   941             # Viewer is upper one in Debug Variable Panel, show highlight
   942             # Viewer is upper one in Debug Variable Panel, show highlight
   942             if self.ParentWindow.IsViewerFirst(self):
   943             if self.ParentWindow.IsViewerFirst(self):
   943                 self.SetHighlight(HIGHLIGHT_BEFORE)
   944                 self.SetHighlight(HIGHLIGHT_BEFORE)
   944 
   945 
   945             # Viewer is not the upper one, show highlight in previous one
   946             # Viewer is not the upper one, show highlight in previous one
  1398         # rectangle on left or right part of figure depending on highlight type
  1399         # rectangle on left or right part of figure depending on highlight type
  1399         elif self.Highlight in [HIGHLIGHT_LEFT, HIGHLIGHT_RIGHT]:
  1400         elif self.Highlight in [HIGHLIGHT_LEFT, HIGHLIGHT_RIGHT]:
  1400             destGC.SetPen(HIGHLIGHT['DROP_PEN'])
  1401             destGC.SetPen(HIGHLIGHT['DROP_PEN'])
  1401             destGC.SetBrush(HIGHLIGHT['DROP_BRUSH'])
  1402             destGC.SetBrush(HIGHLIGHT['DROP_BRUSH'])
  1402 
  1403 
  1403             x_offset = (bbox.width / 2
  1404             x_offset = (bbox.width // 2
  1404                         if self.Highlight == HIGHLIGHT_RIGHT
  1405                         if self.Highlight == HIGHLIGHT_RIGHT
  1405                         else 0)
  1406                         else 0)
  1406             destGC.DrawRectangle(bbox.x + x_offset, bbox.y,
  1407             destGC.DrawRectangle(bbox.x + x_offset, bbox.y,
  1407                                  bbox.width / 2, bbox.height)
  1408                                  bbox.width // 2, bbox.height)
  1408 
  1409 
  1409         # Draw other Viewer common elements
  1410         # Draw other Viewer common elements
  1410         self.DrawCommonElements(destGC, self.GetButtons())
  1411         self.DrawCommonElements(destGC, self.GetButtons())
  1411 
  1412 
  1412         destGC.EndDrawing()
  1413         destGC.EndDrawing()