--- a/graphics/SFC_Objects.py Tue Aug 07 17:37:38 2007 +0200
+++ b/graphics/SFC_Objects.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 GraphicCommons import *
@@ -50,10 +49,10 @@
self.Name = name
self.Initial = initial
self.Id = id
- self.Size = wxSize(SFC_STEP_DEFAULT_SIZE[0], SFC_STEP_DEFAULT_SIZE[1])
+ self.Size = wx.Size(SFC_STEP_DEFAULT_SIZE[0], SFC_STEP_DEFAULT_SIZE[1])
# Create an input and output connector
if not self.Initial:
- self.Input = Connector(self, "", "ANY", wxPoint(self.Size[0] / 2, 0), NORTH)
+ self.Input = Connector(self, "", "ANY", wx.Point(self.Size[0] / 2, 0), NORTH)
else:
self.Input = None
self.Output = None
@@ -72,16 +71,16 @@
# Unconnect input and output
def Clean(self):
if self.Input:
- self.Input.UnConnect()
+ self.Input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
if self.Output:
- self.Output.UnConnect()
+ self.Output.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
if self.Action:
- self.Action.UnConnect()
+ self.Action.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
# Add output connector to step
def AddOutput(self):
if not self.Output:
- self.Output = Connector(self, "", "ANY", wxPoint(self.Size[0] / 2, self.Size[1]), SOUTH)
+ self.Output = Connector(self, "", "ANY", wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH)
self.RefreshBoundingBox()
# Remove output connector from step
@@ -94,7 +93,7 @@
# Add action connector to step
def AddAction(self):
if not self.Action:
- self.Action = Connector(self, "", "ANY", wxPoint(self.Size[0], self.Size[1] / 2), EAST)
+ self.Action = Connector(self, "", "ANY", wx.Point(self.Size[0], self.Size[1] / 2), EAST)
self.RefreshBoundingBox()
# Remove action connector from step
@@ -106,7 +105,7 @@
# Refresh the step bounding box
def RefreshBoundingBox(self):
- dc = wxClientDC(self.Parent)
+ dc = wx.ClientDC(self.Parent)
# Calculate the bounding box size
if self.Action:
bbx_width = self.Size[0] + CONNECTOR_SIZE
@@ -122,20 +121,20 @@
bbx_height = self.Size[1] + CONNECTOR_SIZE
if self.Output:
bbx_height += CONNECTOR_SIZE
- #self.BoundingBox = wxRect(self.Pos.x, bbx_y, bbx_width + 1, bbx_height + 1)
- self.BoundingBox = wxRect(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
+ #self.BoundingBox = wx.Rect(self.Pos.x, bbx_y, bbx_width + 1, bbx_height + 1)
+ self.BoundingBox = wx.Rect(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
# Refresh the positions of the step connectors
def RefreshConnectors(self):
# Update input position if it exists
if self.Input:
- self.Input.SetPosition(wxPoint(self.Size[0] / 2, 0))
+ self.Input.SetPosition(wx.Point(self.Size[0] / 2, 0))
# Update output position
if self.Output:
- self.Output.SetPosition(wxPoint(self.Size[0] / 2, self.Size[1]))
+ self.Output.SetPosition(wx.Point(self.Size[0] / 2, self.Size[1]))
# Update action position if it exists
if self.Action:
- self.Action.SetPosition(wxPoint(self.Size[0], self.Size[1] / 2))
+ self.Action.SetPosition(wx.Point(self.Size[0], self.Size[1] / 2))
self.RefreshConnected()
# Refresh the position of wires connected to step
@@ -237,7 +236,7 @@
# Returns the step minimum size
def GetMinSize(self):
- dc = wxClientDC(self.Parent)
+ dc = wx.ClientDC(self.Parent)
text_width, text_height = dc.GetTextExtent(self.Name)
if self.Initial:
return text_width + 14, text_height + 14
@@ -285,8 +284,8 @@
if diffy != 0:
if isinstance(output_block, SFC_Step):
output_block.MoveActionBlock((diffx, diffy))
- wires[0][0].SetPoints([wxPoint(current_pos.x, current_pos.y + wire_size),
- wxPoint(current_pos.x, current_pos.y)])
+ wires[0][0].SetPoints([wx.Point(current_pos.x, current_pos.y + wire_size),
+ wx.Point(current_pos.x, current_pos.y)])
if not isinstance(output_block, SFC_Divergence) or output_block.GetConnectors()["inputs"].index(output) == 0:
output_block.Move(diffx, diffy, self.Parent.Wires)
output_block.RefreshOutputPosition((diffx, diffy))
@@ -394,8 +393,8 @@
# Draws step
def Draw(self, dc):
- dc.SetPen(wxBLACK_PEN)
- dc.SetBrush(wxWHITE_BRUSH)
+ dc.SetPen(wx.BLACK_PEN)
+ dc.SetBrush(wx.WHITE_BRUSH)
# Draw two rectangles for representing the step
dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
if self.Initial:
@@ -424,20 +423,22 @@
class SFC_Transition(Graphic_Element):
# Create a new transition
- def __init__(self, parent, type = "reference", condition = "", id = None):
+ def __init__(self, parent, type = "reference", condition = None, id = None):
Graphic_Element.__init__(self, parent)
- self.Type = type
- self.Condition = condition
+ self.Type = None
self.Id = id
- self.Size = wxSize(SFC_TRANSITION_SIZE[0], SFC_TRANSITION_SIZE[1])
+ self.Size = wx.Size(SFC_TRANSITION_SIZE[0], SFC_TRANSITION_SIZE[1])
# Create an input and output connector
- self.Input = Connector(self, "", "ANY", wxPoint(self.Size[0] / 2, 0), NORTH)
- self.Output = Connector(self, "", "ANY", wxPoint(self.Size[0] / 2, self.Size[1]), SOUTH)
+ self.Input = Connector(self, "", "ANY", wx.Point(self.Size[0] / 2, 0), NORTH)
+ self.Output = Connector(self, "", "ANY", wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH)
+ self.SetType(type, condition)
# Destructor
def __del__(self):
self.Input = None
self.Output = None
+ if self.Type == "connection":
+ self.Condition = None
# Forbids to change the transition size
def SetSize(self, width, height):
@@ -449,27 +450,42 @@
if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
Graphic_Element.Resize(self, x, y, width, height)
+ # Refresh the size of text for name
+ def RefreshConditionSize(self):
+ if self.Type != "connection":
+ dc = wx.ClientDC(self.Parent)
+ if self.Condition != "":
+ self.ConditionSize = dc.GetTextExtent(self.Condition)
+ else:
+ self.ConditionSize = dc.GetTextExtent("Transition")
+
# Delete this transition by calling the appropriate method
def Delete(self):
self.Parent.DeleteTransition(self)
# Unconnect input and output
def Clean(self):
- self.Input.UnConnect()
- self.Output.UnConnect()
+ self.Input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ self.Output.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+ if self.Type == "connection":
+ self.Condition.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
# Refresh the transition bounding box
def RefreshBoundingBox(self):
- dc = wxClientDC(self.Parent)
- if self.Condition != "":
- text_width, text_height = dc.GetTextExtent(self.Condition)
- else:
- text_width, text_height = dc.GetTextExtent("Transition")
- # Calculate the bounding box size
- bbx_width = self.Size[0] + 5 + text_width
- bbx_y = self.Pos.y - max(0, (text_height - 5 - self.Size[1]) / 2)
- bbx_height = max(self.Size[1], text_height)
- self.BoundingBox = wxRect(self.Pos.x, bbx_y, bbx_width + 1, bbx_height - 4)
+ dc = wx.ClientDC(self.Parent)
+ if self.Type == "connection":
+ bbx_x = self.Pos.x - CONNECTOR_SIZE
+ bbx_width = self.Size[0] + CONNECTOR_SIZE
+ bbx_y = self.Pos.y
+ bbx_height = self.Size[1]
+ else:
+ text_width, text_height = self.ConditionSize
+ # Calculate the bounding box size
+ bbx_x = self.Pos.x
+ bbx_width = self.Size[0] + 5 + text_width
+ bbx_y = self.Pos.y - max(0, (text_height - 5 - self.Size[1]) / 2)
+ bbx_height = max(self.Size[1], text_height) - 5
+ self.BoundingBox = wx.Rect(bbx_x, bbx_y, bbx_width + 1, bbx_height + 1)
# Returns the connector connected to input
def GetPreviousConnector(self):
@@ -488,15 +504,19 @@
# Refresh the positions of the transition connectors
def RefreshConnectors(self):
# Update input position
- self.Input.SetPosition(wxPoint(self.Size[0] / 2, 0))
+ self.Input.SetPosition(wx.Point(self.Size[0] / 2, 0))
# Update output position
- self.Output.SetPosition(wxPoint(self.Size[0] / 2, self.Size[1]))
+ self.Output.SetPosition(wx.Point(self.Size[0] / 2, self.Size[1]))
+ if self.Type == "connection":
+ self.Condition.SetPosition(wx.Point(0, self.Size[1] / 2))
self.RefreshConnected()
# Refresh the position of the wires connected to transition
def RefreshConnected(self, exclude = []):
self.Input.MoveConnected(exclude)
self.Output.MoveConnected(exclude)
+ if self.Type == "connection":
+ self.Condition.MoveConnected(exclude)
# Returns the transition connector that starts with the point given if it exists
def GetConnector(self, position, name = None):
@@ -507,6 +527,8 @@
return self.Input
if name == self.Output.GetName():
return self.Output
+ if self.Type == "connection" and name == self.Condition.GetName():
+ return self.Condition
# Test input connector
input_pos = self.Input.GetRelPosition()
if position.x == self.Pos.x + input_pos.x and position.y == self.Pos.y + input_pos.y:
@@ -515,11 +537,19 @@
output_pos = self.Output.GetRelPosition()
if position.x == self.Pos.x + output_pos.x and position.y == self.Pos.y + output_pos.y:
return self.Output
+ if self.Type == "connection":
+ # Test condition connector
+ condition_pos = self.Condition.GetRelPosition()
+ if position.x == self.Pos.x + condition_pos.x and position.y == self.Pos.y + condition_pos.y:
+ return self.Condition
return None
# Returns input and output transition connectors
def GetConnectors(self):
- return {"input":self.Input,"output":self.Output}
+ connectors = {"input":self.Input,"output":self.Output}
+ if self.Type == "connection":
+ connectors["connection"] = self.Condition
+ return connectors
# Test if point given is on transition input or output connector
def TestConnector(self, pt, exclude=True):
@@ -529,24 +559,40 @@
# Test output connector
if self.Output.TestPoint(pt, exclude):
return self.Output
+ # Test condition connector
+ if self.Type == "connection" and self.Condition.TestPoint(pt, exclude):
+ return self.Condition
return None
# Changes the transition type
- def SetType(self, type):
- self.Type = type
+ def SetType(self, type, condition = None):
+ if self.Type != type:
+ if self.Type == "connection":
+ self.Condition.UnConnect()
+ self.Type = type
+ if type == "connection":
+ self.Condition = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] / 2), WEST)
+ else:
+ if condition == None:
+ condition = ""
+ self.Condition = condition
+ self.RefreshConditionSize()
+ elif self.Type != "connection":
+ if condition == None:
+ condition = ""
+ self.Condition = condition
+ self.RefreshConditionSize()
+ self.RefreshBoundingBox()
# Returns the transition type
def GetType(self):
return self.Type
- # Changes the transition condition
- def SetCondition(self, condition):
- self.Condition = condition
- self.RefreshBoundingBox()
-
# Returns the transition condition
def GetCondition(self):
- return self.Condition
+ if self.Type != "connection":
+ return self.Condition
+ return None
# Returns the transition minimum size
def GetMinSize(self):
@@ -647,22 +693,24 @@
# Draws transition
def Draw(self, dc):
- dc.SetPen(wxBLACK_PEN)
- dc.SetBrush(wxBLACK_BRUSH)
+ dc.SetPen(wx.BLACK_PEN)
+ dc.SetBrush(wx.BLACK_BRUSH)
# Draw plain rectangle for representing the transition
dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
# Draw transition condition
- if self.Condition != "":
- text_width, text_height = dc.GetTextExtent(self.Condition)
- condition = self.Condition
- else:
- text_width, text_height = dc.GetTextExtent("Transition")
- condition = "Transition"
- dc.DrawText(condition, self.Pos.x + self.Size[0] + 5,
- self.Pos.y + (self.Size[1] - text_height) / 2)
+ if self.Type != "connection":
+ text_width, text_height = self.ConditionSize
+ if self.Condition != "":
+ condition = self.Condition
+ else:
+ condition = "Transition"
+ dc.DrawText(condition, self.Pos.x + self.Size[0] + 5,
+ self.Pos.y + (self.Size[1] - text_height) / 2)
# Draw input and output connectors
self.Input.Draw(dc)
self.Output.Draw(dc)
+ if self.Type == "connection":
+ self.Condition.Draw(dc)
Graphic_Element.Draw(self, dc)
#-------------------------------------------------------------------------------
@@ -684,20 +732,20 @@
self.RealConnectors = None
number = max(2, number)
if self.Type in [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE]:
- self.Size = wxSize((number - 1) * SFC_DEFAULT_SEQUENCE_INTERVAL, 1)
+ self.Size = wx.Size((number - 1) * SFC_DEFAULT_SEQUENCE_INTERVAL, 1)
elif self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]:
- self.Size = wxSize((number - 1) * SFC_DEFAULT_SEQUENCE_INTERVAL, 3)
+ self.Size = wx.Size((number - 1) * SFC_DEFAULT_SEQUENCE_INTERVAL, 3)
# Create an input and output connector
if self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]:
- self.Inputs = [Connector(self, "", "ANY", wxPoint(self.Size[0] / 2, 0), NORTH)]
+ self.Inputs = [Connector(self, "", "ANY", wx.Point(self.Size[0] / 2, 0), NORTH)]
self.Outputs = []
for i in xrange(number):
- self.Outputs.append(Connector(self, "", "ANY", wxPoint(i * SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH))
+ self.Outputs.append(Connector(self, "", "ANY", wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH))
elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]:
self.Inputs = []
for i in xrange(number):
- self.Inputs.append(Connector(self, "", "ANY", wxPoint(i * SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH))
- self.Outputs = [Connector(self, "", "ANY", wxPoint(self.Size[0] / 2, self.Size[1]), SOUTH)]
+ self.Inputs.append(Connector(self, "", "ANY", wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH))
+ self.Outputs = [Connector(self, "", "ANY", wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH)]
# Destructor
def __del__(self):
@@ -720,9 +768,9 @@
# Unconnect input and output
def Clean(self):
for input in self.Inputs:
- input.UnConnect()
+ input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
for output in self.Outputs:
- output.UnConnect()
+ output.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
# Add a branch to the divergence
def AddBranch(self):
@@ -731,7 +779,7 @@
for output in self.Outputs:
pos = output.GetRelPosition()
maxx = max(maxx, pos.x)
- connector = Connector(self, "", "ANY", wxPoint(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH)
+ connector = Connector(self, "", "ANY", wx.Point(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH)
self.Outputs.append(connector)
self.MoveConnector(connector, 0)
elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]:
@@ -739,7 +787,7 @@
for input in self.Inputs:
pos = input.GetRelPosition()
maxx = max(maxx, pos.x)
- connector = Connector(self, "", "ANY", wxPoint(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH)
+ connector = Connector(self, "", "ANY", wx.Point(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH)
self.Inputs.append(connector)
self.MoveConnector(connector, SFC_DEFAULT_SEQUENCE_INTERVAL)
@@ -769,10 +817,10 @@
# Refresh the divergence bounding box
def RefreshBoundingBox(self):
if self.Type in [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE]:
- self.BoundingBox = wxRect(self.Pos.x, self.Pos.y - 2,
+ self.BoundingBox = wx.Rect(self.Pos.x, self.Pos.y - 2,
self.Size[0] + 1, self.Size[1] + 5)
elif self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]:
- self.BoundingBox = wxRect(self.Pos.x - SFC_SIMULTANEOUS_SEQUENCE_EXTRA, self.Pos.y - 2,
+ self.BoundingBox = wx.Rect(self.Pos.x - SFC_SIMULTANEOUS_SEQUENCE_EXTRA, self.Pos.y - 2,
self.Size[0] + 2 * SFC_SIMULTANEOUS_SEQUENCE_EXTRA + 1, self.Size[1] + 5)
# Refresh the position of wires connected to divergence
@@ -785,7 +833,7 @@
# Moves the divergence connector given
def MoveConnector(self, connector, movex):
position = connector.GetRelPosition()
- connector.SetPosition(wxPoint(position.x + movex, position.y))
+ connector.SetPosition(wx.Point(position.x + movex, position.y))
minx = self.Size[0]
maxx = 0
for input in self.Inputs:
@@ -799,10 +847,10 @@
if minx != 0:
for input in self.Inputs:
input_pos = input.GetRelPosition()
- input.SetPosition(wxPoint(input_pos.x - minx, input_pos.y))
+ input.SetPosition(wx.Point(input_pos.x - minx, input_pos.y))
for output in self.Outputs:
output_pos = output.GetRelPosition()
- output.SetPosition(wxPoint(output_pos.x - minx, output_pos.y))
+ output.SetPosition(wx.Point(output_pos.x - minx, output_pos.y))
self.Pos.x += minx
self.Size[0] = maxx - minx
connector.MoveConnected()
@@ -852,18 +900,18 @@
for i, input in enumerate(self.Inputs):
position = input.GetRelPosition()
if self.RealConnectors:
- input.SetPosition(wxPoint(int(round(self.RealConnectors["Inputs"][i] * width)), 0))
+ input.SetPosition(wx.Point(int(round(self.RealConnectors["Inputs"][i] * width)), 0))
else:
- input.SetPosition(wxPoint(int(round(float(position.x)*float(width)/float(self.Size[0]))), 0))
+ input.SetPosition(wx.Point(int(round(float(position.x)*float(width)/float(self.Size[0]))), 0))
input.MoveConnected()
for i, output in enumerate(self.Outputs):
position = output.GetRelPosition()
if self.RealConnectors:
- output.SetPosition(wxPoint(int(round(self.RealConnectors["Outputs"][i] * width)), self.Size[1]))
+ output.SetPosition(wx.Point(int(round(self.RealConnectors["Outputs"][i] * width)), self.Size[1]))
else:
- output.SetPosition(wxPoint(int(round(float(position.x)*float(width)/float(self.Size[0]))), self.Size[1]))
+ output.SetPosition(wx.Point(int(round(float(position.x)*float(width)/float(self.Size[0]))), self.Size[1]))
output.MoveConnected()
- self.Size = wxSize(width, height)
+ self.Size = wx.Size(width, height)
self.RefreshBoundingBox()
# Returns the divergence minimum size
@@ -939,7 +987,7 @@
connector = self.TestConnector(pos, False)
if connector:
self.Handle = (HANDLE_CONNECTOR, connector)
- self.Parent.SetCursor(wxStockCursor(wxCURSOR_HAND))
+ self.Parent.SetCursor(wx.StockCursor(wx.CURSOR_HAND))
self.Selected = False
# Initializes the last position
self.oldPos = GetScaledEventPosition(event, dc, scaling)
@@ -1021,8 +1069,8 @@
# Draws divergence
def Draw(self, dc):
- dc.SetPen(wxBLACK_PEN)
- dc.SetBrush(wxBLACK_BRUSH)
+ dc.SetPen(wx.BLACK_PEN)
+ dc.SetBrush(wx.BLACK_BRUSH)
# Draw plain rectangle for representing the divergence
if self.Type in [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE]:
dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
@@ -1053,9 +1101,9 @@
Graphic_Element.__init__(self, parent)
self.Target = target
self.Id = id
- self.Size = wxSize(SFC_JUMP_SIZE[0], SFC_JUMP_SIZE[1])
+ self.Size = wx.Size(SFC_JUMP_SIZE[0], SFC_JUMP_SIZE[1])
# Create an input and output connector
- self.Input = Connector(self, "", "ANY", wxPoint(self.Size[0] / 2, 0), NORTH)
+ self.Input = Connector(self, "", "ANY", wx.Point(self.Size[0] / 2, 0), NORTH)
# Destructor
def __del__(self):
@@ -1077,15 +1125,15 @@
# Unconnect input
def Clean(self):
- self.Input.UnConnect()
+ self.Input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
# Refresh the jump bounding box
def RefreshBoundingBox(self):
- dc = wxClientDC(self.Parent)
+ dc = wx.ClientDC(self.Parent)
text_width, text_height = dc.GetTextExtent(self.Target)
# Calculate the bounding box size
bbx_width = self.Size[0] + 2 + text_width
- self.BoundingBox = wxRect(self.Pos.x, self.Pos.y - CONNECTOR_SIZE,
+ self.BoundingBox = wx.Rect(self.Pos.x, self.Pos.y - CONNECTOR_SIZE,
bbx_width + 1, self.Size[1] + CONNECTOR_SIZE + 1)
# Returns the connector connected to input
@@ -1097,7 +1145,7 @@
# Refresh the element connectors position
def RefreshConnectors(self):
- self.Input.SetPosition(wxPoint(self.Size[0] / 2, 0))
+ self.Input.SetPosition(wx.Point(self.Size[0] / 2, 0))
self.RefreshConnected()
# Refresh the position of wires connected to jump
@@ -1191,14 +1239,14 @@
# Draws divergence
def Draw(self, dc):
- dc.SetPen(wxBLACK_PEN)
- dc.SetBrush(wxBLACK_BRUSH)
+ dc.SetPen(wx.BLACK_PEN)
+ dc.SetBrush(wx.BLACK_BRUSH)
# Draw plain rectangle for representing the divergence
dc.DrawLine(self.Pos.x + self.Size[0] / 2, self.Pos.y, self.Pos.x + self.Size[0] / 2, self.Pos.y + self.Size[1])
- points = [wxPoint(self.Pos.x, self.Pos.y),
- wxPoint(self.Pos.x + self.Size[0] / 2, self.Pos.y + self.Size[1] / 3),
- wxPoint(self.Pos.x + self.Size[0], self.Pos.y),
- wxPoint(self.Pos.x + self.Size[0] / 2, self.Pos.y + self.Size[1])]
+ points = [wx.Point(self.Pos.x, self.Pos.y),
+ wx.Point(self.Pos.x + self.Size[0] / 2, self.Pos.y + self.Size[1] / 3),
+ wx.Point(self.Pos.x + self.Size[0], self.Pos.y),
+ wx.Point(self.Pos.x + self.Size[0] / 2, self.Pos.y + self.Size[1])]
dc.DrawPolygon(points)
text_width, text_height = dc.GetTextExtent(self.Target)
dc.DrawText(self.Target, self.Pos.x + self.Size[0] + 2,
@@ -1223,9 +1271,9 @@
def __init__(self, parent, actions = [], id = None):
Graphic_Element.__init__(self, parent)
self.Id = id
- self.Size = wxSize(SFC_ACTION_MIN_SIZE[0], SFC_ACTION_MIN_SIZE[1])
+ self.Size = wx.Size(SFC_ACTION_MIN_SIZE[0], SFC_ACTION_MIN_SIZE[1])
# Create an input and output connector
- self.Input = Connector(self, "", "ANY", wxPoint(0, SFC_ACTION_MIN_SIZE[1] / 2), WEST)
+ self.Input = Connector(self, "", "ANY", wx.Point(0, SFC_ACTION_MIN_SIZE[1] / 2), WEST)
self.SetActions(actions)
# Destructor
@@ -1256,11 +1304,11 @@
# Unconnect input and output
def Clean(self):
- self.Input.UnConnect()
+ self.Input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
# Refresh the action block 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 position of wires connected to action block
def RefreshConnected(self, exclude = []):
@@ -1279,7 +1327,7 @@
# Changes the action block actions
def SetActions(self, actions):
- dc = wxClientDC(self.Parent)
+ dc = wx.ClientDC(self.Parent)
self.Actions = actions
self.ColSize = [0, 0, 0]
for action in self.Actions:
@@ -1295,9 +1343,9 @@
self.ColSize[2] = max(self.ColSize[2], width + 10)
if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
line_size = self.GetLineSize()
- self.Size = wxSize(self.ColSize[0] + self.ColSize[1] + self.ColSize[2], len(self.Actions) * line_size)
- else:
- self.Size = wxSize(max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2],
+ self.Size = wx.Size(self.ColSize[0] + self.ColSize[1] + self.ColSize[2], len(self.Actions) * line_size)
+ else:
+ self.Size = wx.Size(max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2],
SFC_ACTION_MIN_SIZE[0]), len(self.Actions) * SFC_ACTION_MIN_SIZE[1])
self.RefreshBoundingBox()
if self.Input:
@@ -1343,8 +1391,8 @@
# Draws divergence
def Draw(self, dc):
- dc.SetPen(wxBLACK_PEN)
- dc.SetBrush(wxWHITE_BRUSH)
+ dc.SetPen(wx.BLACK_PEN)
+ dc.SetBrush(wx.WHITE_BRUSH)
colsize = [self.ColSize[0], self.Size[0] - self.ColSize[0] - self.ColSize[2], self.ColSize[2]]
# Draw plain rectangle for representing the action block
dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)