--- a/graphics/FBD_Objects.py Thu Feb 01 18:09:34 2007 +0100
+++ b/graphics/FBD_Objects.py Wed Feb 07 18:43:32 2007 +0100
@@ -42,21 +42,12 @@
# Create a new block
def __init__(self, parent, type, name, id = None, extension = 0, inputs = [], outputs = []):
Graphic_Element.__init__(self, parent)
- self.Type = type
self.Name = name
self.Id = id
- # Find the block definition from type given and create the corresponding
- # inputs and outputs
- blocktype = GetBlockType(type)
- if blocktype:
- inputs = [input for input in blocktype["inputs"]]
- outputs = [output for output in blocktype["outputs"]]
- if blocktype["extensible"]:
- start = int(inputs[-1][0].replace("IN", ""))
- for i in xrange(extension - len(blocktype["inputs"])):
- start += 1
- inputs.append(("IN%d"%start, inputs[-1][1], input[-1][2]))
- self.SetConnectors(inputs, outputs)
+ self.Extension = extension
+ self.Inputs = []
+ self.Outputs = []
+ self.SetType(type)
# Destructor
def __del__(self):
@@ -70,9 +61,9 @@
# Unconnect all inputs and outputs
def Clean(self):
for input in self.Inputs:
- input.UnConnect()
- for output in self.Outputs:
- output.UnConnect()
+ input.UnConnect(delete = True)
+ for output in self.Outputs:
+ output.UnConnect(delete = True)
# Refresh the block bounding box
def RefreshBoundingBox(self):
@@ -144,6 +135,22 @@
return output
return None
+ # Changes the block type
+ def SetType(self, type):
+ self.Type = type
+ # Find the block definition from type given and create the corresponding
+ # inputs and outputs
+ blocktype = GetBlockType(type)
+ if blocktype:
+ inputs = [input for input in blocktype["inputs"]]
+ outputs = [output for output in blocktype["outputs"]]
+ if blocktype["extensible"]:
+ start = int(inputs[-1][0].replace("IN", ""))
+ for i in xrange(self.Extension - len(blocktype["inputs"])):
+ start += 1
+ inputs.append(("IN%d"%start, inputs[-1][1], input[-1][2]))
+ self.SetConnectors(inputs, outputs)
+
# Returns the block type
def GetType(self):
return self.Type
@@ -156,6 +163,14 @@
def GetName(self):
return self.Name
+ # Changes the extension name
+ def SetExtension(self, extension):
+ self.Extension = extension
+
+ # Returs the extension name
+ def GetExtension(self):
+ return self.Extension
+
# Returns the block minimum size
def GetMinSize(self):
dc = wxClientDC(self.Parent)
@@ -176,6 +191,7 @@
# Changes the block connectors
def SetConnectors(self, inputs, outputs):
+ self.Clean()
# Extract the inputs properties and create the corresponding connector
self.Inputs = []
for input_name, input_type, input_modifier in inputs:
@@ -194,6 +210,7 @@
elif output_modifier != "none":
connector.SetEdge(output_modifier)
self.Outputs.append(connector)
+ self.RefreshConnectors()
self.RefreshBoundingBox()
# Changes the negated property of the connector handled
@@ -210,6 +227,11 @@
handle.SetEdge(edge)
self.RefreshModel(False)
+ # Method called when a LeftDClick event have been generated
+ def OnLeftDClick(self, event, scaling):
+ # Edit the step properties
+ self.Parent.EditBlockContent(self)
+
# Method called when a RightUp event have been generated
def OnRightUp(self, event, scaling):
pos = GetScaledEventPosition(event, scaling)