controls/DebugVariablePanel.py
changeset 1044 41bd726aa23c
parent 1043 b46e45e0afc7
child 1084 baa09a1c7b15
equal deleted inserted replaced
1043:b46e45e0afc7 1044:41bd726aa23c
   605                 if refresh_positions:
   605                 if refresh_positions:
   606                     offset = 0
   606                     offset = 0
   607                     buttons = self.Buttons[:]
   607                     buttons = self.Buttons[:]
   608                     buttons.reverse()
   608                     buttons.reverse()
   609                     for button in buttons:
   609                     for button in buttons:
   610                         if button.IsShown() and button.IsEnabled():
   610                         w, h = button.GetSize()
   611                             w, h = button.GetSize()
   611                         button.SetPosition(width - 5 - w - offset, 5)
   612                             button.SetPosition(width - 5 - w - offset, 5)
   612                         offset += w + 2
   613                             offset += w + 2
       
   614                     self.ParentWindow.ForceRefresh()
   613                     self.ParentWindow.ForceRefresh()
   615         
   614         
   616         def DrawCommonElements(self, dc, buttons=None):
   615         def DrawCommonElements(self, dc, buttons=None):
   617             width, height = self.GetSize()
   616             width, height = self.GetSize()
   618             
   617             
   797     class DebugVariableGraphic(DebugVariableViewer, FigureCanvas):
   796     class DebugVariableGraphic(DebugVariableViewer, FigureCanvas):
   798         
   797         
   799         def __init__(self, parent, window, items, graph_type):
   798         def __init__(self, parent, window, items, graph_type):
   800             DebugVariableViewer.__init__(self, window, items)
   799             DebugVariableViewer.__init__(self, window, items)
   801             
   800             
   802             self.CanvasSize = SIZE_MAXI
   801             self.CanvasSize = SIZE_MINI
   803             self.GraphType = graph_type
   802             self.GraphType = graph_type
   804             self.CursorTick = None
   803             self.CursorTick = None
   805             self.MouseStartPos = None
   804             self.MouseStartPos = None
   806             self.StartCursorTick = None
   805             self.StartCursorTick = None
   807             self.CanvasStartSize = None
   806             self.CanvasStartSize = None
   884                 self.ContextualButtonsItem = item
   883                 self.ContextualButtonsItem = item
   885                 
   884                 
   886                 if self.ContextualButtonsItem.IsForced():
   885                 if self.ContextualButtonsItem.IsForced():
   887                     self.ContextualButtons.append(
   886                     self.ContextualButtons.append(
   888                         GraphButton(0, 0, GetBitmap("release"), self.OnReleaseButton))
   887                         GraphButton(0, 0, GetBitmap("release"), self.OnReleaseButton))
   889                 else:
   888                 self.ContextualButtons.append(
   890                     self.ContextualButtons.append(
   889                     GraphButton(0, 0, GetBitmap("force"), self.OnForceButton))
   891                         GraphButton(0, 0, GetBitmap("force"), self.OnForceButton))
       
   892                 self.ContextualButtons.append(
   890                 self.ContextualButtons.append(
   893                     GraphButton(0, 0, GetBitmap("export_graph_mini"), self.OnExportItemGraphButton))
   891                     GraphButton(0, 0, GetBitmap("export_graph_mini"), self.OnExportItemGraphButton))
   894                 self.ContextualButtons.append(
   892                 self.ContextualButtons.append(
   895                     GraphButton(0, 0, GetBitmap("delete_graph"), self.OnRemoveItemButton))
   893                     GraphButton(0, 0, GetBitmap("delete_graph"), self.OnRemoveItemButton))
   896                 
   894                 
   960         def OnRemoveItemButton(self):            
   958         def OnRemoveItemButton(self):            
   961             wx.CallAfter(self.ParentWindow.DeleteValue, self, 
   959             wx.CallAfter(self.ParentWindow.DeleteValue, self, 
   962                          self.ContextualButtonsItem)
   960                          self.ContextualButtonsItem)
   963             self.DismissContextualButtons()
   961             self.DismissContextualButtons()
   964         
   962         
   965         def RefreshButtonsState(self, refresh_positions=False):
       
   966             if self:
       
   967                 width, height = self.GetSize()
       
   968                 min_width, min_height = self.GetCanvasMinSize()
       
   969                 for button, size in zip(self.Buttons, 
       
   970                                         [min_height, SIZE_MIDDLE, SIZE_MAXI]):
       
   971                     if size == height and button.IsEnabled():
       
   972                         button.Disable()
       
   973                         refresh_positions = True
       
   974                     elif not button.IsEnabled():
       
   975                         button.Enable()
       
   976                         refresh_positions = True
       
   977                 if refresh_positions:
       
   978                     offset = 0
       
   979                     buttons = self.Buttons[:]
       
   980                     buttons.reverse()
       
   981                     for button in buttons:
       
   982                         if button.IsShown() and button.IsEnabled():
       
   983                             w, h = button.GetSize()
       
   984                             button.SetPosition(width - 5 - w - offset, 5)
       
   985                             offset += w + 2
       
   986                     self.ParentWindow.ForceRefresh()
       
   987         
       
   988         def RefreshLabelsPosition(self, height):
   963         def RefreshLabelsPosition(self, height):
   989             canvas_ratio = 1. / height
   964             canvas_ratio = 1. / height
   990             graph_ratio = 1. / ((1.0 - (CANVAS_BORDER[0] + CANVAS_BORDER[1]) * canvas_ratio) * height)
   965             graph_ratio = 1. / ((1.0 - (CANVAS_BORDER[0] + CANVAS_BORDER[1]) * canvas_ratio) * height)
   991             
   966             
   992             self.Figure.subplotpars.update(
   967             self.Figure.subplotpars.update(
  1019         
   994         
  1020         def SetCanvasSize(self, width, height):
   995         def SetCanvasSize(self, width, height):
  1021             height = max(height, self.GetCanvasMinSize()[1])
   996             height = max(height, self.GetCanvasMinSize()[1])
  1022             self.SetMinSize(wx.Size(width, height))
   997             self.SetMinSize(wx.Size(width, height))
  1023             self.RefreshLabelsPosition(height)
   998             self.RefreshLabelsPosition(height)
       
   999             self.RefreshButtonsState()
  1024             self.ParentWindow.RefreshGraphicsSizer()
  1000             self.ParentWindow.RefreshGraphicsSizer()
  1025             
  1001             
  1026         def GetAxesBoundingBox(self, absolute=False):
  1002         def GetAxesBoundingBox(self, absolute=False):
  1027             width, height = self.GetSize()
  1003             width, height = self.GetSize()
  1028             ax, ay, aw, ah = self.figure.gca().get_position().bounds
  1004             ax, ay, aw, ah = self.figure.gca().get_position().bounds
  1659         if len(panel.GetItems()) > 1:
  1635         if len(panel.GetItems()) > 1:
  1660             self.DraggingAxesPanel = DebugVariableGraphic(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
  1636             self.DraggingAxesPanel = DebugVariableGraphic(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
  1661             self.DraggingAxesPanel.SetCursorTick(self.CursorTick)
  1637             self.DraggingAxesPanel.SetCursorTick(self.CursorTick)
  1662             width, height = panel.GetSize()
  1638             width, height = panel.GetSize()
  1663             self.DraggingAxesPanel.SetSize(wx.Size(width, height))
  1639             self.DraggingAxesPanel.SetSize(wx.Size(width, height))
       
  1640             self.DraggingAxesPanel.ResetGraphics()
  1664             self.DraggingAxesPanel.SetPosition(wx.Point(0, -height))
  1641             self.DraggingAxesPanel.SetPosition(wx.Point(0, -height))
  1665         else:
  1642         else:
  1666             self.DraggingAxesPanel = panel
  1643             self.DraggingAxesPanel = panel
  1667         self.DraggingAxesBoundingBox = panel.GetAxesBoundingBox(absolute=True)
  1644         self.DraggingAxesBoundingBox = panel.GetAxesBoundingBox(absolute=True)
  1668         self.DraggingAxesMousePos = wx.Point(
  1645         self.DraggingAxesMousePos = wx.Point(