--- a/Viewer.py Thu Sep 22 10:56:52 2011 +0200
+++ b/Viewer.py Thu Sep 22 15:33:31 2011 +0200
@@ -65,14 +65,14 @@
'mono' : 'Courier New',
'helv' : 'Arial',
'other': 'Comic Sans MS',
- 'size' : 20,
+ 'size' : 10,
}
else:
faces = { 'times': 'Times',
'mono' : 'Courier',
'helv' : 'Helvetica',
'other': 'new century schoolbook',
- 'size' : 20,
+ 'size' : 12,
}
ZOOM_FACTORS = [math.sqrt(2) ** x for x in xrange(-6, 7)]
@@ -757,7 +757,7 @@
dc = wx.MemoryDC(bitmap)
dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
dc.Clear()
- dc.SetPen(wx.Pen(wx.Colour(180, 180, 180)))
+ dc.SetPen(MiterPen(wx.Colour(180, 180, 180)))
dc.DrawPoint(0, 0)
self.GridBrush = wx.BrushFromBitmap(bitmap)
else:
@@ -768,7 +768,7 @@
page_size = properties["pageSize"]
if page_size != (0, 0):
self.PageSize = map(int, page_size)
- self.PagePen = wx.Pen(wx.Colour(180, 180, 180))
+ self.PagePen = MiterPen(wx.Colour(180, 180, 180))
else:
self.PageSize = None
self.PagePen = wx.TRANSPARENT_PEN
@@ -1016,24 +1016,30 @@
# Search Element functions
#-------------------------------------------------------------------------------
- def FindBlock(self, pos):
+ def FindBlock(self, event):
+ dc = self.GetLogicalDC()
+ pos = event.GetLogicalPosition(dc)
for block in self.Blocks.itervalues():
- if block.HitTest(pos) or block.TestHandle(pos) != (0, 0):
+ if block.HitTest(pos) or block.TestHandle(event) != (0, 0):
return block
return None
- def FindWire(self, pos):
+ def FindWire(self, event):
+ dc = self.GetLogicalDC()
+ pos = event.GetLogicalPosition(dc)
for wire in self.Wires:
- if wire.HitTest(pos) or wire.TestHandle(pos) != (0, 0):
+ if wire.HitTest(pos) or wire.TestHandle(event) != (0, 0):
return wire
return None
- def FindElement(self, pos, exclude_group = False):
+ def FindElement(self, event, exclude_group = False):
+ dc = self.GetLogicalDC()
+ pos = event.GetLogicalPosition(dc)
if self.SelectedElement and not (exclude_group and isinstance(self.SelectedElement, Graphic_Group)):
- if self.SelectedElement.HitTest(pos) or self.SelectedElement.TestHandle(pos) != (0, 0):
+ if self.SelectedElement.HitTest(pos) or self.SelectedElement.TestHandle(event) != (0, 0):
return self.SelectedElement
for element in self.GetElements():
- if element.HitTest(pos) or element.TestHandle(pos) != (0, 0):
+ if element.HitTest(pos) or element.TestHandle(event) != (0, 0):
return element
return None
@@ -1318,19 +1324,19 @@
self.SelectedElement = elements[0]
self.SelectedElement.SetSelected(True)
else:
- element = self.FindElement(pos)
- if not self.Debug and (element is None or element.TestHandle(pos) == (0, 0)):
+ element = self.FindElement(event)
+ if not self.Debug and (element is None or element.TestHandle(event) == (0, 0)):
connector = self.FindBlockConnector(pos)
else:
connector = None
if not self.Debug and self.DrawingWire:
self.DrawingWire = False
if self.SelectedElement is not None:
- if element is None or element.TestHandle(pos) == (0, 0):
+ if element is None or element.TestHandle(event) == (0, 0):
connector = self.FindBlockConnector(pos, self.SelectedElement.GetConnectionDirection())
if connector is not None:
event.Dragging = lambda : True
- self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling)
+ self.SelectedElement.OnMotion(event, dc, self.Scaling)
if self.SelectedElement.EndConnected is not None:
self.SelectedElement.ResetPoints()
self.SelectedElement.GeneratePoints()
@@ -1346,7 +1352,7 @@
self.RefreshRect(self.GetScrolledRect(rect), False)
elif not self.Debug and connector is not None:
self.DrawingWire = True
- scaled_pos = GetScaledEventPosition(event, self.GetLogicalDC(), self.Scaling)
+ scaled_pos = GetScaledEventPosition(event, dc, self.Scaling)
if (connector.GetDirection() == EAST):
wire = Wire(self, [wx.Point(pos.x, pos.y), EAST], [wx.Point(scaled_pos.x, scaled_pos.y), WEST])
else:
@@ -1473,28 +1479,25 @@
def OnViewerRightDown(self, event):
if self.Mode == MODE_SELECTION:
- dc = self.GetLogicalDC()
- pos = event.GetLogicalPosition(dc)
- element = self.FindElement(pos)
+ element = self.FindElement(event)
if self.SelectedElement is not None and self.SelectedElement != element:
self.SelectedElement.SetSelected(False)
self.SelectedElement = None
if element:
self.SelectedElement = element
if self.Debug:
- Graphic_Element.OnRightDown(self.SelectedElement, event, dc, self.Scaling)
+ Graphic_Element.OnRightDown(self.SelectedElement, event, self.GetLogicalDC(), self.Scaling)
else:
- self.SelectedElement.OnRightDown(event, dc, self.Scaling)
+ self.SelectedElement.OnRightDown(event, self.GetLogicalDC(), self.Scaling)
self.SelectedElement.Refresh()
event.Skip()
def OnViewerRightUp(self, event):
- dc = self.GetLogicalDC()
if self.SelectedElement is not None:
if self.Debug:
- Graphic_Element.OnRightUp(self.SelectedElement, event, dc, self.Scaling)
+ Graphic_Element.OnRightUp(self.SelectedElement, event, self.GetLogicalDC(), self.Scaling)
else:
- self.SelectedElement.OnRightUp(event, dc, self.Scaling)
+ self.SelectedElement.OnRightUp(event, self.GetLogicalDC(), self.Scaling)
wx.CallAfter(self.SetCurrentCursor, 0)
elif not self.Debug:
self.PopupDefaultMenu(False)
@@ -1552,7 +1555,7 @@
tooltip_pos = self.ClientToScreen(event.GetPosition())
tooltip_pos.x += 10
tooltip_pos.y += 10
- highlighted = self.FindElement(pos)
+ highlighted = self.FindElement(event)
if self.HighlightedElement is not None and self.HighlightedElement != highlighted:
if self.Debug and isinstance(self.HighlightedElement, Wire):
self.HighlightedElement.ClearToolTip()