--- a/graphics/GraphicCommons.py Fri May 24 11:17:35 2013 +0200
+++ b/graphics/GraphicCommons.py Fri May 24 16:29:57 2013 +0200
@@ -437,123 +437,6 @@
self.AccessLock.release()
#-------------------------------------------------------------------------------
-# Viewer Rubberband
-#-------------------------------------------------------------------------------
-
-"""
-Class that implements a rubberband
-"""
-
-class RubberBand:
-
- # Create a rubberband by indicated on which window it must be drawn
- def __init__(self, viewer):
- self.Viewer = viewer
- self.drawingSurface = viewer.Editor
- self.Reset()
-
- # Method that initializes the internal attributes of the rubberband
- def Reset(self):
- self.startPoint = None
- self.currentBox = None
- self.lastBox = None
-
- # Method that return if a box is currently edited
- def IsShown(self):
- return self.currentBox != None
-
- # Method that returns the currently edited box
- def GetCurrentExtent(self):
- if self.currentBox is None:
- return self.lastBox
- return self.currentBox
-
- # Method called when a new box starts to be edited
- def OnLeftDown(self, event, dc, scaling):
- pos = GetScaledEventPosition(event, dc, scaling)
- # Save the point for calculate the box position and size
- self.startPoint = pos
- self.currentBox = wx.Rect(pos.x, pos.y, 0, 0)
- self.drawingSurface.SetCursor(wx.StockCursor(wx.CURSOR_CROSS))
- self.Redraw()
-
- # Method called when dragging with a box edited
- def OnMotion(self, event, dc, scaling):
- pos = GetScaledEventPosition(event, dc, scaling)
- # Save the last position and size of the box for erasing it
- self.lastBox = wx.Rect(self.currentBox.x, self.currentBox.y, self.currentBox.width,
- self.currentBox.height)
- # Calculate new position and size of the box
- if pos.x >= self.startPoint.x:
- self.currentBox.x = self.startPoint.x
- self.currentBox.width = pos.x - self.startPoint.x + 1
- else:
- self.currentBox.x = pos.x
- self.currentBox.width = self.startPoint.x - pos.x + 1
- if pos.y >= self.startPoint.y:
- self.currentBox.y = self.startPoint.y
- self.currentBox.height = pos.y - self.startPoint.y + 1
- else:
- self.currentBox.y = pos.y
- self.currentBox.height = self.startPoint.y - pos.y + 1
- self.Redraw()
-
- # Method called when dragging is stopped
- def OnLeftUp(self, event, dc, scaling):
- self.drawingSurface.SetCursor(wx.NullCursor)
- self.lastBox = self.currentBox
- self.currentBox = None
- self.Redraw()
-
- # Method that erase the last box and draw the new box
- def Redraw(self, dc = None):
- if dc is None:
- dc = self.Viewer.GetLogicalDC()
- scalex, scaley = dc.GetUserScale()
- dc.SetUserScale(1, 1)
- dc.SetPen(wx.Pen(wx.WHITE, 1, wx.DOT))
- dc.SetBrush(wx.TRANSPARENT_BRUSH)
- dc.SetLogicalFunction(wx.XOR)
- if self.lastBox:
- # Erase last box
- dc.DrawRectangle(self.lastBox.x * scalex, self.lastBox.y * scaley,
- self.lastBox.width * scalex, self.lastBox.height * scaley)
- if self.currentBox:
- # Draw current box
- dc.DrawRectangle(self.currentBox.x * scalex, self.currentBox.y * scaley,
- self.currentBox.width * scalex, self.currentBox.height * scaley)
- dc.SetUserScale(scalex, scaley)
-
- # Erase last box
- def Erase(self, dc = None):
- if dc is None:
- dc = self.Viewer.GetLogicalDC()
- scalex, scaley = dc.GetUserScale()
- dc.SetUserScale(1, 1)
- dc.SetPen(wx.Pen(wx.WHITE, 1, wx.DOT))
- dc.SetBrush(wx.TRANSPARENT_BRUSH)
- dc.SetLogicalFunction(wx.XOR)
- if self.lastBox:
- dc.DrawRectangle(self.lastBox.x * scalex, self.lastBox.y * scaley,
- self.lastBox.width * scalex, self.lastBox.height * scalex)
- dc.SetUserScale(scalex, scaley)
-
- # Draw current box
- def Draw(self, dc = None):
- if dc is None:
- dc = self.Viewer.GetLogicalDC()
- scalex, scaley = dc.GetUserScale()
- dc.SetUserScale(1, 1)
- dc.SetPen(wx.Pen(wx.WHITE, 1, wx.DOT))
- dc.SetBrush(wx.TRANSPARENT_BRUSH)
- dc.SetLogicalFunction(wx.XOR)
- if self.currentBox:
- # Draw current box
- dc.DrawRectangle(self.currentBox.x * scalex, self.currentBox.y * scaley,
- self.currentBox.width * scalex, self.currentBox.height * scaley)
- dc.SetUserScale(scalex, scaley)
-
-#-------------------------------------------------------------------------------
# Helpers for highlighting text
#-------------------------------------------------------------------------------