--- a/graphics/FBD_Objects.py Fri Jan 04 17:47:58 2008 +0100
+++ b/graphics/FBD_Objects.py Fri Jan 04 17:49:17 2008 +0100
@@ -54,6 +54,8 @@
# Make a clone of this FBD_Block
def Clone(self, id = None, name = "", pos = None):
+ if self.Name != "" and name == "":
+ name = self.Name
block = FBD_Block(self.Parent, self.Type, name, id, self.Extension)
block.SetSize(self.Size[0], self.Size[1])
if pos is not None:
@@ -67,6 +69,18 @@
self.Inputs = []
self.Outputs = []
+ # Returns the RedrawRect
+ def GetRedrawRect(self, movex = 0, movey = 0):
+ rect = Graphic_Element.GetRedrawRect(self, movex, movey)
+ if movex != 0 or movey != 0:
+ for input in self.Inputs:
+ if input.IsConnected():
+ rect = rect.Union(input.GetConnectedRedrawRect(movex, movey))
+ for output in self.Outputs:
+ if output.IsConnected():
+ rect = rect.Union(output.GetConnectedRedrawRect(movex, movey))
+ return rect
+
# Delete this block by calling the appropriate method
def Delete(self):
self.Parent.DeleteBlock(self)
@@ -172,7 +186,7 @@
resulttype = inputtype
for output in self.Outputs:
name = output.GetName()
- if output != connector and name == "OUT":
+ if output != connector and name == "OUT" and not IsEndType(output.GetType()):
outputtype = output.GetConnectedType()
if resulttype is None or outputtype is not None and IsOfType(outputtype, resulttype):
resulttype = outputtype
@@ -338,6 +352,7 @@
# Draws block
def Draw(self, dc):
+ Graphic_Element.Draw(self, dc)
dc.SetPen(self.Pen)
dc.SetBrush(wx.WHITE_BRUSH)
dc.SetTextForeground(self.Colour)
@@ -358,7 +373,6 @@
dc.DrawText(str(self.ExecutionOrder), self.Pos.x + self.Size[0] - self.ExecutionOrderSize[0],
self.Pos.y + self.Size[1] + 2)
dc.SetTextForeground(wx.BLACK)
- Graphic_Element.Draw(self, dc)
#-------------------------------------------------------------------------------
@@ -389,8 +403,10 @@
variable.SetSize(self.Size[0], self.Size[1])
if pos is not None:
variable.SetPosition(pos.x, pos.y)
- variable.Input = self.Input.Clone(variable)
- variable.Output = self.Output.Clone(variable)
+ if self.Input:
+ variable.Input = self.Input.Clone(variable)
+ if self.Output:
+ variable.Output = self.Output.Clone(variable)
return variable
# Destructor
@@ -398,6 +414,16 @@
self.Input = None
self.Output = None
+ # Returns the RedrawRect
+ def GetRedrawRect(self, movex = 0, movey = 0):
+ rect = Graphic_Element.GetRedrawRect(self, movex, movey)
+ if movex != 0 or movey != 0:
+ if self.Input and self.Input.IsConnected():
+ rect = rect.Union(self.Input.GetConnectedRedrawRect(movex, movey))
+ if self.Output and self.Output.IsConnected():
+ rect = rect.Union(self.Output.GetConnectedRedrawRect(movex, movey))
+ return rect
+
# Unconnect connector
def Clean(self):
if self.Input:
@@ -557,6 +583,7 @@
# Draws variable
def Draw(self, dc):
+ Graphic_Element.Draw(self, dc)
dc.SetPen(wx.BLACK_PEN)
dc.SetBrush(wx.WHITE_BRUSH)
# Draw a rectangle with the variable size
@@ -573,7 +600,6 @@
# Draw variable execution order
dc.DrawText(str(self.ExecutionOrder), self.Pos.x + self.Size[0] - self.ExecutionOrderSize[0],
self.Pos.y + self.Size[1] + 2)
- Graphic_Element.Draw(self, dc)
#-------------------------------------------------------------------------------
@@ -606,6 +632,14 @@
def __del__(self):
self.Connector = None
+ # Returns the RedrawRect
+ def GetRedrawRect(self, movex = 0, movey = 0):
+ rect = Graphic_Element.GetRedrawRect(self, movex, movey)
+ if movex != 0 or movey != 0:
+ if self.Connector and self.Connector.IsConnected():
+ rect = rect.Union(self.Connector.GetConnectedRedrawRect(movex, movey))
+ return rect
+
# Make a clone of this FBD_Connector
def Clone(self, id = None, pos = None):
connection = FBD_Connector(self.Parent, self.Type, self.Name, id)
@@ -714,6 +748,7 @@
# Draws connection
def Draw(self, dc):
+ Graphic_Element.Draw(self, dc)
dc.SetPen(wx.BLACK_PEN)
dc.SetBrush(wx.WHITE_BRUSH)
# Draw a rectangle with the connection size with arrows in
@@ -733,5 +768,4 @@
# Draw connector
if self.Connector:
self.Connector.Draw(dc)
- Graphic_Element.Draw(self, dc)