def DrawCommonElements(self, dc, buttons=None): """ Function that draw common graphics for every Viewers @param dc: wx.DC object corresponding to Device context where drawing common graphics @param buttons: List of buttons to draw if different from default (default None) """ # Get Viewer size width, height = self.GetSize() # Set dc styling for drop before or drop after highlight dc.SetPen(HIGHLIGHT_DROP_PEN) dc.SetBrush(HIGHLIGHT_DROP_BRUSH) # Draw line at upper side of Viewer if highlight is drop before if self.Highlight == HIGHLIGHT_BEFORE: dc.DrawLine(0, 1, width - 1, 1) # Draw line at lower side of Viewer if highlight is drop before elif self.Highlight == HIGHLIGHT_AFTER: dc.DrawLine(0, height - 1, width - 1, height - 1) # If no specific buttons are defined, get default buttons if buttons is None: buttons = self.Buttons # Draw buttons for button in buttons: button.Draw(dc) # If graph dragging is processing if self.ParentWindow.IsDragging(): destBBox = self.ParentWindow.GetDraggingAxesClippingRegion(self) srcPos = self.ParentWindow.GetDraggingAxesPosition(self) if destBBox.width > 0 and destBBox.height > 0: srcPanel = self.ParentWindow.DraggingAxesPanel srcBBox = srcPanel.GetAxesBoundingBox() srcX = srcBBox.x - (srcPos.x if destBBox.x == 0 else 0) srcY = srcBBox.y - (srcPos.y if destBBox.y == 0 else 0) srcBmp = _convert_agg_to_wx_bitmap( srcPanel.get_renderer(), None) srcDC = wx.MemoryDC() srcDC.SelectObject(srcBmp) dc.Blit(destBBox.x, destBBox.y, int(destBBox.width), int(destBBox.height), srcDC, srcX, srcY)
def DrawCommonElements(self, dc, buttons=None): """ Function that draw common graphics for every Viewers @param dc: wx.DC object corresponding to Device context where drawing common graphics @param buttons: List of buttons to draw if different from default (default None) """ # Get Viewer size width, height = self.GetSize() # Set dc styling for drop before or drop after highlight dc.SetPen(HIGHLIGHT['DROP_PEN']) dc.SetBrush(HIGHLIGHT['DROP_BRUSH']) # Draw line at upper side of Viewer if highlight is drop before if self.Highlight == HIGHLIGHT_BEFORE: dc.DrawLine(0, 1, width - 1, 1) # Draw line at lower side of Viewer if highlight is drop before elif self.Highlight == HIGHLIGHT_AFTER: dc.DrawLine(0, height - 1, width - 1, height - 1) # If no specific buttons are defined, get default buttons if buttons is None: buttons = self.Buttons # Draw buttons for button in buttons: button.Draw(dc) # If graph dragging is processing if self.ParentWindow.IsDragging(): destBBox = self.ParentWindow.GetDraggingAxesClippingRegion(self) srcPos = self.ParentWindow.GetDraggingAxesPosition(self) if destBBox.width > 0 and destBBox.height > 0: srcPanel = self.ParentWindow.DraggingAxesPanel srcBBox = srcPanel.GetAxesBoundingBox() srcX = srcBBox.x - (srcPos.x if destBBox.x == 0 else 0) srcY = srcBBox.y - (srcPos.y if destBBox.y == 0 else 0) srcBmp = _convert_agg_to_wx_bitmap(srcPanel.get_renderer(), None) srcDC = wx.MemoryDC() srcDC.SelectObject(srcBmp) dc.Blit(destBBox.x, destBBox.y, int(destBBox.width), int(destBBox.height), srcDC, srcX, srcY)
def draw(self, drawDC=None): """ Render the figure using agg. """ #print "drawing" # Only draw if window is shown, otherwise graph will bleed through # on the notebook style AUI widgets. if self.IsShownOnScreen(): #print "on screen" #import traceback; traceback.print_stack() self._isRendered = True FigureCanvasWxAgg.draw(self) self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None) self.gui_repaint(drawDC=drawDC) else: self._isRendered = False
def prepare_bitmap(self): from matplotlib.backends.backend_wxagg import _convert_agg_to_wx_bitmap self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None) self.renderer.bitmap = self.bitmap
def RefreshView(self): self.RefreshCanvasPosition() width, height = self.GraphicsWindow.GetVirtualSize() bitmap = wx.EmptyBitmap(width, height) dc = wx.BufferedDC(wx.ClientDC(self.GraphicsWindow), bitmap) dc.Clear() dc.BeginDrawing() if self.DraggingAxesPanel is not None: destBBox = self.DraggingAxesBoundingBox srcBBox = self.DraggingAxesPanel.GetAxesBoundingBox() srcBmp = _convert_agg_to_wx_bitmap(self.DraggingAxesPanel.get_renderer(), None) srcDC = wx.MemoryDC() srcDC.SelectObject(srcBmp) dc.Blit(destBBox.x, destBBox.y, int(destBBox.width), int(destBBox.height), srcDC, srcBBox.x, srcBBox.y) dc.EndDrawing() if not self.Fixed or self.Force: self.Force = False refresh_graphics = True else: refresh_graphics = False if self.DraggingAxesPanel is not None and self.DraggingAxesPanel not in self.GraphicPanels: self.DraggingAxesPanel.RefreshViewer(refresh_graphics) for panel in self.GraphicPanels: if isinstance(panel, DebugVariableGraphicViewer): panel.RefreshViewer(refresh_graphics) else: panel.RefreshViewer() if self.CursorTick is not None: tick = self.CursorTick elif len(self.Ticks) > 0: tick = self.Ticks[-1] else: tick = None if tick is not None: self.TickLabel.SetLabel(label=_("Tick: %d") % tick) tick_duration = int(tick * self.Ticktime) not_null = False duration = "" for value, format in [(tick_duration / DAY, _("%dd")), ((tick_duration % DAY) / HOUR, _("%dh")), ((tick_duration % HOUR) / MINUTE, _("%dm")), ((tick_duration % MINUTE) / SECOND, _("%ds"))]: if value > 0 or not_null: duration += format % value not_null = True duration += _("%03gms") % (float(tick_duration % SECOND) / MILLISECOND) self.TickTimeLabel.SetLabel("t: %s" % duration) else: self.TickLabel.SetLabel("") self.TickTimeLabel.SetLabel("") self.TickSizer.Layout()
def RefreshView(self): self.RefreshCanvasPosition() width, height = self.GraphicsWindow.GetVirtualSize() bitmap = wx.EmptyBitmap(width, height) dc = wx.BufferedDC(wx.ClientDC(self.GraphicsWindow), bitmap) dc.Clear() dc.BeginDrawing() if self.DraggingAxesPanel is not None: destBBox = self.DraggingAxesBoundingBox srcBBox = self.DraggingAxesPanel.GetAxesBoundingBox() srcBmp = _convert_agg_to_wx_bitmap(self.DraggingAxesPanel.get_renderer(), None) srcDC = wx.MemoryDC() srcDC.SelectObject(srcBmp) dc.Blit(destBBox.x, destBBox.y, int(destBBox.width), int(destBBox.height), srcDC, srcBBox.x, srcBBox.y) dc.EndDrawing() if not self.Fixed or self.Force: self.Force = False refresh_graphics = True else: refresh_graphics = False if self.DraggingAxesPanel is not None and self.DraggingAxesPanel not in self.GraphicPanels: self.DraggingAxesPanel.RefreshViewer(refresh_graphics) for panel in self.GraphicPanels: if isinstance(panel, DebugVariableGraphicViewer): panel.RefreshViewer(refresh_graphics) else: panel.RefreshViewer() if self.CursorTick is not None: tick = self.CursorTick elif len(self.Ticks) > 0: tick = self.Ticks[-1] else: tick = None if tick is not None: self.TickLabel.SetLabel("Tick: %d" % tick) tick_duration = int(tick * self.Ticktime) not_null = False duration = "" for value, format in [(tick_duration / DAY, "%dd"), ((tick_duration % DAY) / HOUR, "%dh"), ((tick_duration % HOUR) / MINUTE, "%dm"), ((tick_duration % MINUTE) / SECOND, "%ds")]: if value > 0 or not_null: duration += format % value not_null = True duration += "%gms" % (float(tick_duration % SECOND) / MILLISECOND) self.TickTimeLabel.SetLabel("t: %s" % duration) else: self.TickLabel.SetLabel("") self.TickTimeLabel.SetLabel("") self.TickSizer.Layout()