--- a/graphics/GraphicCommons.py Tue Aug 07 17:37:38 2007 +0200
+++ b/graphics/GraphicCommons.py Tue Aug 07 17:38:48 2007 +0200
@@ -22,7 +22,6 @@
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from wxPython.wx import *
import wx
from math import *
@@ -91,12 +90,12 @@
def ResetCursors():
global CURSORS
if CURSORS == None:
- CURSORS = [wxNullCursor,
- wxStockCursor(wxCURSOR_HAND),
- wxStockCursor(wxCURSOR_SIZENWSE),
- wxStockCursor(wxCURSOR_SIZENESW),
- wxStockCursor(wxCURSOR_SIZEWE),
- wxStockCursor(wxCURSOR_SIZENS)]
+ CURSORS = [wx.NullCursor,
+ wx.StockCursor(wx.CURSOR_HAND),
+ wx.StockCursor(wx.CURSOR_SIZENWSE),
+ wx.StockCursor(wx.CURSOR_SIZENESW),
+ wx.StockCursor(wx.CURSOR_SIZEWE),
+ wx.StockCursor(wx.CURSOR_SIZENS)]
HANDLE_CURSORS = {
(1, 1) : 2,
@@ -197,15 +196,15 @@
pos = GetScaledEventPosition(event, dc, scaling)
# Save the point for calculate the box position and size
self.startPoint = pos
- self.currentBox = wxRect(pos.x, pos.y, 0, 0)
- self.drawingSurface.SetCursor(wxStockCursor(wxCURSOR_CROSS))
+ 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 = wxRect(self.currentBox.x, self.currentBox.y, self.currentBox.width,
+ 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:
@@ -224,7 +223,7 @@
# Method called when dragging is stopped
def OnLeftUp(self, event, dc, scaling):
- self.drawingSurface.SetCursor(wxNullCursor)
+ self.drawingSurface.SetCursor(wx.NullCursor)
self.lastBox = self.currentBox
self.currentBox = None
self.Redraw()
@@ -232,9 +231,9 @@
# Method that erase the last box and draw the new box
def Redraw(self):
dc = self.drawingSurface.GetLogicalDC()
- dc.SetPen(wxPen(wxWHITE, 1, wxDOT))
- dc.SetBrush(wxTRANSPARENT_BRUSH)
- dc.SetLogicalFunction(wxXOR)
+ 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, self.lastBox.y, self.lastBox.width,
@@ -247,9 +246,9 @@
# Erase last box
def Erase(self):
dc = self.drawingSurface.GetLogicalDC()
- dc.SetPen(wxPen(wxWHITE, 1, wxDOT))
- dc.SetBrush(wxTRANSPARENT_BRUSH)
- dc.SetLogicalFunction(wxXOR)
+ 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, self.lastBox.y, self.lastBox.width,
self.lastBox.height)
@@ -257,9 +256,9 @@
# Draw current box
def Draw(self):
dc = self.drawingSurface.GetLogicalDC()
- dc.SetPen(wxPen(wxWHITE, 1, wxDOT))
- dc.SetBrush(wxTRANSPARENT_BRUSH)
- dc.SetLogicalFunction(wxXOR)
+ 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, self.currentBox.y, self.currentBox.width,
@@ -284,9 +283,9 @@
self.Handle = False
self.Dragging = False
self.Selected = False
- self.Pos = wxPoint(0, 0)
- self.Size = wxSize(0, 0)
- self.BoundingBox = wxRect(0, 0, 0, 0)
+ self.Pos = wx.Point(0, 0)
+ self.Size = wx.Size(0, 0)
+ self.BoundingBox = wx.Rect(0, 0, 0, 0)
self.CurrentCursor = 0
ResetCursors()
@@ -318,7 +317,7 @@
# Refresh the element Bounding Box
def RefreshBoundingBox(self):
- self.BoundingBox = wxRect(self.Pos.x, self.Pos.y, self.Size[0], self.Size[1])
+ self.BoundingBox = wx.Rect(self.Pos.x, self.Pos.y, self.Size[0], self.Size[1])
# Refresh the element connectors position
def RefreshConnectors(self):
@@ -363,9 +362,9 @@
# Test if the point is on a handle of this element
def TestHandle(self, pt):
- extern_rect = wxRect(self.BoundingBox.x - HANDLE_SIZE - 2, self.BoundingBox.y - HANDLE_SIZE - 2,
+ extern_rect = wx.Rect(self.BoundingBox.x - HANDLE_SIZE - 2, self.BoundingBox.y - HANDLE_SIZE - 2,
self.BoundingBox.width + 2 * HANDLE_SIZE + 4, self.BoundingBox.height + 2 * HANDLE_SIZE + 4)
- intern_rect = wxRect(self.BoundingBox.x - 2, self.BoundingBox.y - 2,
+ intern_rect = wx.Rect(self.BoundingBox.x - 2, self.BoundingBox.y - 2,
self.BoundingBox.width + 4, self.BoundingBox.height + 4)
# Verify that this element is selected
if self.Selected and extern_rect.InsideXY(pt.x, pt.y) and not intern_rect.InsideXY(pt.x, pt.y):
@@ -507,8 +506,8 @@
# Draws the handles of this element if it is selected
def Draw(self, dc):
if self.Selected:
- dc.SetPen(wxBLACK_PEN)
- dc.SetBrush(wxBLACK_BRUSH)
+ dc.SetPen(wx.BLACK_PEN)
+ dc.SetBrush(wx.BLACK_BRUSH)
dc.DrawRectangle(self.BoundingBox.x - HANDLE_SIZE - 2, self.BoundingBox.y - HANDLE_SIZE - 2, HANDLE_SIZE, HANDLE_SIZE)
dc.DrawRectangle(self.BoundingBox.x + (self.BoundingBox.width - HANDLE_SIZE) / 2,
self.BoundingBox.y - HANDLE_SIZE - 2, HANDLE_SIZE, HANDLE_SIZE)
@@ -522,7 +521,7 @@
self.BoundingBox.y + self.BoundingBox.height + 2, HANDLE_SIZE, HANDLE_SIZE)
dc.DrawRectangle(self.BoundingBox.x - HANDLE_SIZE - 2, self.BoundingBox.y + self.BoundingBox.height + 2, HANDLE_SIZE, HANDLE_SIZE)
dc.DrawRectangle(self.BoundingBox.x - HANDLE_SIZE - 2, self.BoundingBox.y + (self.BoundingBox.height - HANDLE_SIZE) / 2, HANDLE_SIZE, HANDLE_SIZE)
- dc.SetBrush(wxWHITE_BRUSH)
+ dc.SetBrush(wx.WHITE_BRUSH)
#-------------------------------------------------------------------------------
@@ -632,9 +631,9 @@
miny = min(miny, bbox.y)
maxx = max(maxx, bbox.x + bbox.width)
maxy = max(maxy, bbox.y + bbox.height)
- self.BoundingBox = wxRect(minx, miny, maxx - minx, maxy - miny)
+ self.BoundingBox = wx.Rect(minx, miny, maxx - minx, maxy - miny)
else:
- self.BoundingBox = wxRect(0, 0, 0, 0)
+ self.BoundingBox = wx.Rect(0, 0, 0, 0)
# Forbids to change the group position
def SetPosition(x, y):
@@ -684,7 +683,7 @@
self.Negated = negated
self.Edge = edge
self.OneConnected = onlyone
- self.Pen = wxBLACK_PEN
+ self.Pen = wx.BLACK_PEN
self.RefreshNameSize()
# Change the connector pen
@@ -693,7 +692,7 @@
# Make a clone of the connector
def Clone(self):
- return Connector(self.ParentBlock, self.Name, self.Type, wxPoint(self.Pos[0], self.Pos[1]),
+ return Connector(self.ParentBlock, self.Name, self.Type, wx.Point(self.Pos[0], self.Pos[1]),
self.Direction, self.Negated)
# Returns the connector parent block
@@ -720,7 +719,7 @@
# Changes the connector name size
def RefreshNameSize(self):
if self.Name != "":
- dc = wxClientDC(self.ParentBlock.Parent)
+ dc = wx.ClientDC(self.ParentBlock.Parent)
self.NameSize = dc.GetTextExtent(self.Name)
else:
self.NameSize = 0, 0
@@ -751,7 +750,7 @@
else:
x = parent_pos[0] + self.Pos.x
y = parent_pos[1] + self.Pos.y
- return wxPoint(x, y)
+ return wx.Point(x, y)
# Change the connector relative position
def SetPosition(self, pos):
@@ -820,9 +819,9 @@
for wire, index in self.Wires:
if wire not in exclude:
if index == 0:
- wire.MoveStartPoint(wxPoint(x, y))
+ wire.MoveStartPoint(wx.Point(x, y))
else:
- wire.MoveEndPoint(wxPoint(x, y))
+ wire.MoveEndPoint(wx.Point(x, y))
# Refreshes the model of all the wires connected
def RefreshWires(self):
@@ -839,9 +838,9 @@
for wire, handle in self.Wires:
# Get other connector connected to each wire
if handle == 0:
- connector = blocks.GetEndConnected()
+ connector = wire.GetEndConnected()
else:
- connector = blocks.GetStartConnected()
+ connector = wire.GetStartConnected()
# Get parent block for this connector
if connector:
block = connector.GetParentBlock()
@@ -876,14 +875,14 @@
y = parent_pos[1] + self.Pos.y + self.Direction[1] * CONNECTOR_SIZE - ANCHOR_DISTANCE
width = ANCHOR_DISTANCE * 2 + abs(self.Direction[0]) * CONNECTOR_SIZE
height = ANCHOR_DISTANCE * 2 + abs(self.Direction[1]) * CONNECTOR_SIZE
- rect = wxRect(x, y, width, height)
+ rect = wx.Rect(x, y, width, height)
return rect.InsideXY(pt.x, pt.y)
return False
# Draws the connector
def Draw(self, dc):
dc.SetPen(self.Pen)
- dc.SetBrush(wxWHITE_BRUSH)
+ dc.SetBrush(wx.WHITE_BRUSH)
parent_pos = self.ParentBlock.GetPosition()
if self.Negated:
# If connector is negated, draw a circle
@@ -988,25 +987,25 @@
# The selected segment is reinitialised
if segment == None:
if self.StartConnected:
- self.StartConnected.SetPen(wxBLACK_PEN)
+ self.StartConnected.SetPen(wx.BLACK_PEN)
if self.EndConnected:
- self.EndConnected.SetPen(wxBLACK_PEN)
+ self.EndConnected.SetPen(wx.BLACK_PEN)
# The segment selected is the first
elif segment == 0:
if self.StartConnected:
- self.StartConnected.SetPen(wxRED_PEN)
+ self.StartConnected.SetPen(wx.RED_PEN)
if self.EndConnected:
# There is only one segment
if len(self.Segments) == 1:
- self.EndConnected.SetPen(wxRED_PEN)
+ self.EndConnected.SetPen(wx.RED_PEN)
else:
- self.EndConnected.SetPen(wxBLACK_PEN)
+ self.EndConnected.SetPen(wx.BLACK_PEN)
# The segment selected is the last
elif segment == len(self.Segments) - 1:
if self.StartConnected:
- self.StartConnected.SetPen(wxBLACK_PEN)
+ self.StartConnected.SetPen(wx.BLACK_PEN)
if self.EndConnected:
- self.EndConnected.SetPen(wxRED_PEN)
+ self.EndConnected.SetPen(wx.RED_PEN)
self.SelectedSegment = segment
# Reinitialize the wire points
@@ -1043,9 +1042,9 @@
maxx, maxbbxx = max(maxx, self.Points[-1].x), max(maxbbxx, self.Points[-1].x + end_radius)
miny, minbbxy = min(miny, self.Points[-1].y), min(minbbxy, self.Points[-1].y - end_radius)
maxy, maxbbxy = max(maxy, self.Points[-1].y), max(maxbbxy, self.Points[-1].y + end_radius)
- self.Pos = wxPoint(minx, miny)
- self.Size = wxSize(maxx -minx + 1, maxy - miny + 1)
- self.BoundingBox = wxRect(minbbxx, minbbxy, maxbbxx - minbbxx + 1, maxbbxy - minbbxy + 1)
+ self.Pos = wx.Point(minx, miny)
+ self.Size = wx.Size(maxx -minx + 1, maxy - miny + 1)
+ self.BoundingBox = wx.Rect(minbbxx, minbbxy, maxbbxx - minbbxx + 1, maxbbxy - minbbxy + 1)
# Refresh the realpoints that permits to keep the proportionality in wire during resizing
def RefreshRealPoints(self):
@@ -1082,11 +1081,11 @@
def HitTest(self, pt):
test = False
for i in xrange(len(self.Points) - 1):
- rect = wxRect(0, 0, 0, 0)
+ rect = wx.Rect(0, 0, 0, 0)
x1, y1 = self.Points[i].x, self.Points[i].y
x2, y2 = self.Points[i + 1].x, self.Points[i + 1].y
# Calculate a rectangle around the segment
- rect = wxRect(min(x1, x2) - ANCHOR_DISTANCE, min(y1, y2) - ANCHOR_DISTANCE,
+ rect = wx.Rect(min(x1, x2) - ANCHOR_DISTANCE, min(y1, y2) - ANCHOR_DISTANCE,
abs(x1 - x2) + 2 * ANCHOR_DISTANCE, abs(y1 - y2) + 2 * ANCHOR_DISTANCE)
test |= rect.InsideXY(pt.x, pt.y)
return test
@@ -1094,13 +1093,13 @@
# Returns the wire start or end point if the point given is on one of them
def TestPoint(self, pt):
# Test the wire start point
- rect = wxRect(self.Points[0].x - ANCHOR_DISTANCE, self.Points[0].y - ANCHOR_DISTANCE,
+ rect = wx.Rect(self.Points[0].x - ANCHOR_DISTANCE, self.Points[0].y - ANCHOR_DISTANCE,
2 * ANCHOR_DISTANCE, 2 * ANCHOR_DISTANCE)
if rect.InsideXY(pt.x, pt.y):
return 0
# Test the wire end point
if len(self.Points) > 1:
- rect = wxRect(self.Points[-1].x - ANCHOR_DISTANCE, self.Points[-1].y - ANCHOR_DISTANCE,
+ rect = wx.Rect(self.Points[-1].x - ANCHOR_DISTANCE, self.Points[-1].y - ANCHOR_DISTANCE,
2 * ANCHOR_DISTANCE, 2 * ANCHOR_DISTANCE)
if rect.InsideXY(pt.x, pt.y):
return -1
@@ -1114,7 +1113,7 @@
x1, y1 = self.Points[i].x, self.Points[i].y
x2, y2 = self.Points[i + 1].x, self.Points[i + 1].y
# Calculate a rectangle around the segment
- rect = wxRect(min(x1, x2) - ANCHOR_DISTANCE, min(y1, y2) - ANCHOR_DISTANCE,
+ rect = wx.Rect(min(x1, x2) - ANCHOR_DISTANCE, min(y1, y2) - ANCHOR_DISTANCE,
abs(x1 - x2) + 2 * ANCHOR_DISTANCE, abs(y1 - y2) + 2 * ANCHOR_DISTANCE)
if rect.InsideXY(pt.x, pt.y):
return i, self.Segments[i]
@@ -1123,14 +1122,14 @@
# Define the wire points
def SetPoints(self, points):
if len(points) > 1:
- self.Points = [wxPoint(x, y) for x, y in points]
+ self.Points = [wx.Point(x, y) for x, y in points]
# Calculate the start and end directions
self.StartPoint = [None, vector(self.Points[0], self.Points[1])]
self.EndPoint = [None, vector(self.Points[-1], self.Points[-2])]
# Calculate the start and end points
- self.StartPoint[0] = wxPoint(self.Points[0].x + CONNECTOR_SIZE * self.StartPoint[1][0],
+ self.StartPoint[0] = wx.Point(self.Points[0].x + CONNECTOR_SIZE * self.StartPoint[1][0],
self.Points[0].y + CONNECTOR_SIZE * self.StartPoint[1][1])
- self.EndPoint[0] = wxPoint(self.Points[-1].x + CONNECTOR_SIZE * self.EndPoint[1][0],
+ self.EndPoint[0] = wx.Point(self.Points[-1].x + CONNECTOR_SIZE * self.EndPoint[1][0],
self.Points[-1].y + CONNECTOR_SIZE * self.EndPoint[1][1])
self.Points[0] = self.StartPoint[0]
self.Points[-1] = self.EndPoint[0]
@@ -1150,9 +1149,9 @@
# Returns a list of the position of all wire points
def GetPoints(self, invert = False):
points = self.VerifyPoints()
- points[0] = wxPoint(points[0].x - CONNECTOR_SIZE * self.StartPoint[1][0],
+ points[0] = wx.Point(points[0].x - CONNECTOR_SIZE * self.StartPoint[1][0],
points[0].y - CONNECTOR_SIZE * self.StartPoint[1][1])
- points[-1] = wxPoint(points[-1].x - CONNECTOR_SIZE * self.EndPoint[1][0],
+ points[-1] = wx.Point(points[-1].x - CONNECTOR_SIZE * self.EndPoint[1][0],
points[-1].y - CONNECTOR_SIZE * self.EndPoint[1][1])
# An inversion of the list is asked
if invert:
@@ -1192,9 +1191,9 @@
def GeneratePoints(self, realpoints = True):
i = 0
# Calculate the start enad end points with the minimum segment size in the right direction
- end = wxPoint(self.EndPoint[0].x + self.EndPoint[1][0] * MIN_SEGMENT_SIZE,
+ end = wx.Point(self.EndPoint[0].x + self.EndPoint[1][0] * MIN_SEGMENT_SIZE,
self.EndPoint[0].y + self.EndPoint[1][1] * MIN_SEGMENT_SIZE)
- start = wxPoint(self.StartPoint[0].x + self.StartPoint[1][0] * MIN_SEGMENT_SIZE,
+ start = wx.Point(self.StartPoint[0].x + self.StartPoint[1][0] * MIN_SEGMENT_SIZE,
self.StartPoint[0].y + self.StartPoint[1][1] * MIN_SEGMENT_SIZE)
# Evaluate the point till it's the last
while i < len(self.Points) - 1:
@@ -1206,14 +1205,14 @@
if i == 0:
# If the end point is not in the start direction, a point is added
if v_end != self.Segments[0] or v_end == self.EndPoint[1]:
- self.Points.insert(1, wxPoint(start.x, start.y))
+ self.Points.insert(1, wx.Point(start.x, start.y))
self.Segments.insert(1, DirectionChoice((self.Segments[0][1],
self.Segments[0][0]), v_end, self.EndPoint[1]))
# The current point is the second
elif i == 1:
# The previous direction and the target direction are mainly opposed, a point is added
if product(v_end, self.Segments[0]) < 0:
- self.Points.insert(2, wxPoint(self.Points[1].x, self.Points[1].y))
+ self.Points.insert(2, wx.Point(self.Points[1].x, self.Points[1].y))
self.Segments.insert(2, DirectionChoice((self.Segments[1][1],
self.Segments[1][0]), v_end, self.EndPoint[1]))
# The previous direction and the end direction are the same or they are
@@ -1226,7 +1225,7 @@
self.Points[1].y = end.y
# If the previous direction and the end direction are the same, a point is added
if product(self.Segments[0], self.EndPoint[1]) > 0:
- self.Points.insert(2, wxPoint(self.Points[1].x, self.Points[1].y))
+ self.Points.insert(2, wx.Point(self.Points[1].x, self.Points[1].y))
self.Segments.insert(2, DirectionChoice((self.Segments[1][1],
self.Segments[1][0]), v_end, self.EndPoint[1]))
else:
@@ -1236,7 +1235,7 @@
self.Points[1].x = (end.x + start.x) / 2
if self.Segments[0][1] != 0:
self.Points[1].y = (end.y + start.y) / 2
- self.Points.insert(2, wxPoint(self.Points[1].x, self.Points[1].y))
+ self.Points.insert(2, wx.Point(self.Points[1].x, self.Points[1].y))
self.Segments.insert(2, DirectionChoice((self.Segments[1][1],
self.Segments[1][0]), v_end, self.EndPoint[1]))
else:
@@ -1257,12 +1256,13 @@
# If the current point is the third, test if the second
# point can be aligned with the end point
if i == 2:
- test_point = wxPoint(self.Points[1].x, self.Points[1].y)
+ test_point = wx.Point(self.Points[1].x, self.Points[1].y)
if self.Segments[1][0] != 0:
test_point.y = end.y
if self.Segments[1][1] != 0:
test_point.x = end.x
- test = norm(vector(self.Points[0], test_point, False)) > MIN_SEGMENT_SIZE
+ vector_test = vector(self.Points[0], test_point, False)
+ test = norm(vector_test) > MIN_SEGMENT_SIZE and product(self.Segments[0], vector_test) > 0
# The previous point can be aligned
if test:
self.Points[i].x, self.Points[i].y = end.x, end.y
@@ -1278,7 +1278,7 @@
self.Points[2].x = (self.Points[1].x + end.x) / 2
if self.Segments[1][1] != 0:
self.Points[2].y = (self.Points[1].y + end.y) / 2
- self.Points.insert(3, wxPoint(self.Points[2].x, self.Points[2].y))
+ self.Points.insert(3, wx.Point(self.Points[2].x, self.Points[2].y))
self.Segments.insert(3, DirectionChoice((self.Segments[2][1],
self.Segments[2][0]), v_end, self.EndPoint[1]))
else:
@@ -1299,7 +1299,7 @@
if self.Segments[i - 1][1] != 0:
self.Points[i].y = (end.y + self.Points[i - 1].y) / 2
# A point is added
- self.Points.insert(i + 1, wxPoint(self.Points[i].x, self.Points[i].y))
+ self.Points.insert(i + 1, wx.Point(self.Points[i].x, self.Points[i].y))
self.Segments.insert(i + 1, DirectionChoice((self.Segments[i][1],
self.Segments[i][0]), v_end, self.EndPoint[1]))
else:
@@ -1307,7 +1307,7 @@
if i == 0 and product(vector(start, self.Points[1]), self.Segments[0]) < 0:
# If first and second directions aren't perpendiculars, a point is added
if product(self.Segments[0], self.Segments[1]) != 0:
- self.Points.insert(1, wxPoint(start.x, start.y))
+ self.Points.insert(1, wx.Point(start.x, start.y))
self.Segments.insert(1, DirectionChoice((self.Segments[0][1],
self.Segments[0][0]), vector(start, self.Points[1]), self.Segments[1]))
else:
@@ -1375,7 +1375,7 @@
width - dir[0] * MIN_SEGMENT_SIZE - 1))
pointy = max(-dir[1] * MIN_SEGMENT_SIZE, min(int(round(point[1] * (height - 1) / float(lastheight - 1))),
height - dir[1] * MIN_SEGMENT_SIZE - 1))
- self.Points[i] = wxPoint(minx + x + pointx, miny + y + pointy)
+ self.Points[i] = wx.Point(minx + x + pointx, miny + y + pointy)
self.StartPoint[0] = self.Points[0]
self.EndPoint[0] = self.Points[-1]
self.GeneratePoints(False)
@@ -1410,7 +1410,7 @@
width - dir[0] * MIN_SEGMENT_SIZE - 1))
realpointy = max(-dir[1] * MIN_SEGMENT_SIZE, min(int(round(point[1])),
height - dir[1] * MIN_SEGMENT_SIZE - 1))
- self.Points[i] = wxPoint(minx + x + realpointx, miny + y + realpointy)
+ self.Points[i] = wx.Point(minx + x + realpointx, miny + y + realpointy)
self.StartPoint[0] = self.Points[0]
self.EndPoint[0] = self.Points[-1]
self.GeneratePoints(False)
@@ -1504,9 +1504,9 @@
pointx = (self.Points[segment].x + self.Points[segment + 1].x) / 2
if dir[1] != 0:
pointy = (self.Points[segment].y + self.Points[segment + 1].y) / 2
- self.Points.insert(segment + 1, wxPoint(pointx, pointy))
+ self.Points.insert(segment + 1, wx.Point(pointx, pointy))
self.Segments.insert(segment + 1, (dir[1], dir[0]))
- self.Points.insert(segment + 2, wxPoint(pointx, pointy))
+ self.Points.insert(segment + 2, wx.Point(pointx, pointy))
self.Segments.insert(segment + 2, dir)
self.GeneratePoints()
@@ -1528,15 +1528,15 @@
#result = self.TestPoint(pos)
#if result != None:
# self.Handle = (HANDLE_POINT, result)
- # self.Parent.SetCursor(wxStockCursor(wxCURSOR_HAND))
+ # self.Parent.SetCursor(wx.StockCursor(wx.CURSOR_HAND))
#else:
# Test if a segment have been handled
result = self.TestSegment(pos)
if result != None:
if result[1] in (NORTH, SOUTH):
- self.Parent.SetCursor(wxStockCursor(wxCURSOR_SIZEWE))
+ self.Parent.SetCursor(wx.StockCursor(wx.CURSOR_SIZEWE))
elif result[1] in (EAST, WEST):
- self.Parent.SetCursor(wxStockCursor(wxCURSOR_SIZENS))
+ self.Parent.SetCursor(wx.StockCursor(wx.CURSOR_SIZENS))
self.Handle = (HANDLE_SEGMENT, result)
# Execute the default method for a graphic element
else:
@@ -1560,6 +1560,8 @@
def OnLeftDClick(self, event, dc, scaling):
self.ResetPoints()
self.GeneratePoints()
+ self.RefreshModel()
+ self.Parent.RefreshBuffer()
# Method called when a Motion event have been generated
def OnMotion(self, event, dc, scaling):
@@ -1569,9 +1571,13 @@
result = self.TestSegment(pos)
if result:
if result[1] in (NORTH, SOUTH):
- wxCallAfter(self.Parent.SetCursor, wxStockCursor(wxCURSOR_SIZEWE))
+ if self.CurrentCursor != 4:
+ self.CurrentCursor = 4
+ wx.CallAfter(self.Parent.SetCursor, CURSORS[4])
elif result[1] in (EAST, WEST):
- wxCallAfter(self.Parent.SetCursor, wxStockCursor(wxCURSOR_SIZENS))
+ if self.CurrentCursor != 5:
+ self.CurrentCursor = 5
+ wx.CallAfter(self.Parent.SetCursor, CURSORS[5])
else:
# Test if a point has been handled
#result = self.TestPoint(pos)
@@ -1595,7 +1601,7 @@
# A point has been handled
if handle_type == HANDLE_POINT:
# Try to connect point to a connector
- new_pos = wxPoint(self.Points[handle].x + movex, self.Points[handle].y + movey)
+ new_pos = wx.Point(self.Points[handle].x + movex, self.Points[handle].y + movey)
connector = self.Parent.FindBlockConnector(new_pos)
if connector:
if handle == 0 and self.EndConnected != connector:
@@ -1639,8 +1645,8 @@
# Draws the wire lines and points
def Draw(self, dc):
- dc.SetPen(wxBLACK_PEN)
- dc.SetBrush(wxBLACK_BRUSH)
+ dc.SetPen(wx.BLACK_PEN)
+ dc.SetBrush(wx.BLACK_BRUSH)
# Draw the start and end points if they are not connected or the mouse is over them
if len(self.Points) > 0 and (not self.StartConnected or self.OverStart):
dc.DrawCircle(self.Points[0].x, self.Points[0].y, POINT_RADIUS)
@@ -1651,7 +1657,7 @@
dc.DrawPoint(self.Points[-1].x, self.Points[-1].y)
# Draw the segment selected in red
if self.SelectedSegment != None:
- dc.SetPen(wxRED_PEN)
+ dc.SetPen(wx.RED_PEN)
dc.DrawLine(self.Points[self.SelectedSegment].x, self.Points[self.SelectedSegment].y,
self.Points[self.SelectedSegment + 1].x, self.Points[self.SelectedSegment + 1].y)
if self.SelectedSegment == len(self.Segments) - 1:
@@ -1674,8 +1680,8 @@
Graphic_Element.__init__(self, parent)
self.Id = id
self.Content = content
- self.Pos = wxPoint(0, 0)
- self.Size = wxSize(0, 0)
+ self.Pos = wx.Point(0, 0)
+ self.Size = wx.Size(0, 0)
# Method for keeping compatibility with others
def Clean(self):
@@ -1687,7 +1693,7 @@
# Refresh the comment bounding box
def RefreshBoundingBox(self):
- self.BoundingBox = wxRect(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
+ self.BoundingBox = wx.Rect(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
# Changes the comment size
def SetSize(self, width, height):
@@ -1701,7 +1707,7 @@
# Returns the comment minimum size
def GetMinSize(self):
- dc = wxClientDC(self.Parent)
+ dc = wx.ClientDC(self.Parent)
min_width = 0
min_height = 0
# The comment minimum size is the maximum size of words in the content
@@ -1761,18 +1767,18 @@
# Draws the comment and its content
def Draw(self, dc):
- dc.SetPen(wxBLACK_PEN)
- dc.SetBrush(wxWHITE_BRUSH)
+ dc.SetPen(wx.BLACK_PEN)
+ dc.SetBrush(wx.WHITE_BRUSH)
# Draws the comment shape
- polygon = [wxPoint(self.Pos.x, self.Pos.y),
- wxPoint(self.Pos.x + self.Size[0] - 10, self.Pos.y),
- wxPoint(self.Pos.x + self.Size[0], self.Pos.y + 10),
- wxPoint(self.Pos.x + self.Size[0], self.Pos.y + self.Size[1] + 1),
- wxPoint(self.Pos.x, self.Pos.y + self.Size[1] + 1)]
+ polygon = [wx.Point(self.Pos.x, self.Pos.y),
+ wx.Point(self.Pos.x + self.Size[0] - 10, self.Pos.y),
+ wx.Point(self.Pos.x + self.Size[0], self.Pos.y + 10),
+ wx.Point(self.Pos.x + self.Size[0], self.Pos.y + self.Size[1] + 1),
+ wx.Point(self.Pos.x, self.Pos.y + self.Size[1] + 1)]
dc.DrawPolygon(polygon)
- lines = [wxPoint(self.Pos.x + self.Size[0] - 10, self.Pos.y),
- wxPoint(self.Pos.x + self.Size[0] - 10, self.Pos.y + 10),
- wxPoint(self.Pos.x + self.Size[0], self.Pos.y + 10)]
+ lines = [wx.Point(self.Pos.x + self.Size[0] - 10, self.Pos.y),
+ wx.Point(self.Pos.x + self.Size[0] - 10, self.Pos.y + 10),
+ wx.Point(self.Pos.x + self.Size[0], self.Pos.y + 10)]
dc.DrawLines(lines)
# Draws the comment content
y = self.Pos.y + 10