mirror of
https://github.com/thiagoralves/OpenPLC_Editor.git
synced 2025-05-09 00:21:53 +08:00
Merge pull request #121 from joluxer/python-3.12-editor-missing-casts
Python 3.12 editor missing casts
This commit is contained in:
commit
59f9aa5ad1
@ -349,10 +349,10 @@ class Graphic_Element(ToolTipProducer):
|
||||
posx, posy = self.GetPosition()
|
||||
min_width, min_height = self.GetMinSize()
|
||||
if width < min_width:
|
||||
self.Pos.x = max(0, self.Pos.x - (width - min_width) * x_factor)
|
||||
self.Pos.x = int(round(max(0, self.Pos.x - (width - min_width) * x_factor)))
|
||||
width = min_width
|
||||
if height < min_height:
|
||||
self.Pos.y = max(0, self.Pos.y - (height - min_height) * y_factor)
|
||||
self.Pos.y = int(round(max(0, self.Pos.y - (height - min_height) * y_factor)))
|
||||
height = min_height
|
||||
if scaling is not None:
|
||||
self.Pos.x = round_scaling(self.Pos.x, scaling[0])
|
||||
@ -406,10 +406,10 @@ class Graphic_Element(ToolTipProducer):
|
||||
def GetRedrawRect(self, movex=0, movey=0):
|
||||
scalex, scaley = self.Parent.GetViewScale()
|
||||
rect = wx.Rect()
|
||||
rect.x = self.BoundingBox.x - int(HANDLE_SIZE / scalex) - 3 - abs(movex)
|
||||
rect.y = self.BoundingBox.y - int(HANDLE_SIZE / scaley) - 3 - abs(movey)
|
||||
rect.width = self.BoundingBox.width + 2 * (int(HANDLE_SIZE / scalex) + abs(movex) + 1) + 4
|
||||
rect.height = self.BoundingBox.height + 2 * (int(HANDLE_SIZE / scaley) + abs(movey) + 1) + 4
|
||||
rect.x = int(round(self.BoundingBox.x - int(HANDLE_SIZE / scalex) - 3 - abs(movex)))
|
||||
rect.y = int(round(self.BoundingBox.y - int(HANDLE_SIZE / scaley) - 3 - abs(movey)))
|
||||
rect.width = int(round(self.BoundingBox.width + 2 * (int(HANDLE_SIZE / scalex) + abs(movex) + 1) + 4))
|
||||
rect.height = int(round(self.BoundingBox.height + 2 * (int(HANDLE_SIZE / scaley) + abs(movey) + 1) + 4))
|
||||
return rect
|
||||
|
||||
def Refresh(self, rect=None):
|
||||
@ -537,8 +537,8 @@ class Graphic_Element(ToolTipProducer):
|
||||
self.oldPos.x = self.StartPos.x + self.CurrentDrag.x
|
||||
self.oldPos.y = self.StartPos.y + self.CurrentDrag.y
|
||||
else:
|
||||
self.oldPos.x += dragx
|
||||
self.oldPos.y += dragy
|
||||
self.oldPos.x += int(round(dragx))
|
||||
self.oldPos.y += int(round(dragy))
|
||||
return dragx, dragy
|
||||
return movex, movey
|
||||
# If cursor just pass over the element, changes the cursor if it is on a handle
|
||||
@ -553,8 +553,8 @@ class Graphic_Element(ToolTipProducer):
|
||||
|
||||
# Moves the element
|
||||
def Move(self, dx, dy, exclude=None):
|
||||
self.Pos.x += max(-self.BoundingBox.x, dx)
|
||||
self.Pos.y += max(-self.BoundingBox.y, dy)
|
||||
self.Pos.x += int(round(max(-self.BoundingBox.x, dx)))
|
||||
self.Pos.y += int(round(max(-self.BoundingBox.y, dy)))
|
||||
self.RefreshConnected(exclude)
|
||||
self.RefreshBoundingBox()
|
||||
|
||||
@ -684,13 +684,13 @@ class Graphic_Element(ToolTipProducer):
|
||||
dc.SetPen(MiterPen(wx.BLACK))
|
||||
dc.SetBrush(wx.BLACK_BRUSH)
|
||||
|
||||
left = round((self.BoundingBox.x - 2) * scalex - HANDLE_SIZE)
|
||||
center = round((self.BoundingBox.x + self.BoundingBox.width // 2) * scalex - HANDLE_SIZE // 2)
|
||||
right = round((self.BoundingBox.x + self.BoundingBox.width + 2) * scalex)
|
||||
left = int(round((self.BoundingBox.x - 2) * scalex - HANDLE_SIZE))
|
||||
center = int(round((self.BoundingBox.x + self.BoundingBox.width // 2) * scalex - HANDLE_SIZE // 2))
|
||||
right = int(round((self.BoundingBox.x + self.BoundingBox.width + 2) * scalex))
|
||||
|
||||
top = round((self.BoundingBox.y - 2) * scaley - HANDLE_SIZE)
|
||||
middle = round((self.BoundingBox.y + self.BoundingBox.height // 2) * scaley - HANDLE_SIZE // 2)
|
||||
bottom = round((self.BoundingBox.y + self.BoundingBox.height + 2) * scaley)
|
||||
top = int(round((self.BoundingBox.y - 2) * scaley - HANDLE_SIZE))
|
||||
middle = int(round((self.BoundingBox.y + self.BoundingBox.height // 2) * scaley - HANDLE_SIZE // 2))
|
||||
bottom = int(round((self.BoundingBox.y + self.BoundingBox.height + 2) * scaley))
|
||||
|
||||
for x, y in [(left, top), (center, top), (right, top),
|
||||
(left, middle), (right, middle),
|
||||
@ -1082,7 +1082,7 @@ class Connector(DebugDataConsumer, ToolTipProducer):
|
||||
if self.Edge == "rising" and self.Direction[1] == 1:
|
||||
y -= 5
|
||||
height += 5
|
||||
rect = wx.Rect(x - abs(movex), y - abs(movey), width + 2 * abs(movex), height + 2 * abs(movey))
|
||||
rect = wx.Rect(int(round(x - abs(movex))), int(round(y - abs(movey))), int(round(width + 2 * abs(movex))), int(round(height + 2 * abs(movey))))
|
||||
if self.ValueSize is None and isinstance(self.ComputedValue, str):
|
||||
self.ValueSize = self.ParentBlock.Parent.GetMiniTextExtent(self.ComputedValue)
|
||||
if self.ValueSize is not None:
|
||||
@ -2234,7 +2234,7 @@ class Wire(Graphic_Element, DebugDataConsumer):
|
||||
segments = [segment for segment in self.Segments]
|
||||
i = 1
|
||||
while i < len(points) - 1:
|
||||
if points[i] == points[i + 1] and segments[i - 1] == segments[i + 1]:
|
||||
if points[i] == points[i + 1]: #and segments[i - 1] == segments[i + 1] <- this condition ends up with "IndexError: list index out of range" while creating a connection
|
||||
for dummy in range(2):
|
||||
points.pop(i)
|
||||
segments.pop(i)
|
||||
|
@ -593,11 +593,11 @@ class LD_Contact(Graphic_Element, DebugDataConsumer):
|
||||
dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
|
||||
#dc.SetLogicalFunction(wx.AND)
|
||||
# Draw two rectangles for representing the contact
|
||||
left_left = (self.Pos.x - 1) * scalex - 2
|
||||
right_left = (self.Pos.x + self.Size[0] - 2) * scalex - 2
|
||||
top = (self.Pos.y - 1) * scaley - 2
|
||||
width = 4 * scalex + 5
|
||||
height = (self.Size[1] + 3) * scaley + 5
|
||||
left_left = int(round((self.Pos.x - 1) * scalex - 2))
|
||||
right_left = int(round((self.Pos.x + self.Size[0] - 2) * scalex - 2))
|
||||
top = int(round((self.Pos.y - 1) * scaley - 2))
|
||||
width = int(round(4 * scalex + 5))
|
||||
height = int(round((self.Size[1] + 3) * scaley + 5))
|
||||
|
||||
dc.DrawRectangle(left_left, top, width, height)
|
||||
dc.DrawRectangle(right_left, top, width, height)
|
||||
|
Loading…
x
Reference in New Issue
Block a user