graphics/FBD_Objects.py
changeset 145 4fb225afddf4
parent 144 b67a5de5a24a
child 162 e746ff4aa8be
--- a/graphics/FBD_Objects.py	Fri Jan 04 17:49:17 2008 +0100
+++ b/graphics/FBD_Objects.py	Fri Jan 11 17:51:56 2008 +0100
@@ -123,19 +123,22 @@
     
     # Refresh the positions of the block connectors
     def RefreshConnectors(self):
+        scaling = self.Parent.GetScaling()
         # Calculate the size for the connector lines
         lines = max(len(self.Inputs), len(self.Outputs))
         if lines > 0:
             linesize = max((self.Size[1] - BLOCK_LINE_SIZE) / lines, BLOCK_LINE_SIZE)
-            # Update inputs positions
+            # Update inputs and outputs positions
             position = BLOCK_LINE_SIZE + linesize / 2
-            for input in self.Inputs:
-                input.SetPosition(wx.Point(0, position))
-                position += linesize
-            # Update outputs positions
-            position = BLOCK_LINE_SIZE + linesize / 2
-            for output in self.Outputs:
-                output.SetPosition(wx.Point(self.Size[0], position))
+            for i in xrange(lines):
+                if scaling is not None:
+                    ypos = round(float(self.Pos.y + position) / float(scaling[1])) * scaling[1] - self.Pos.y
+                else:
+                    ypos = position
+                if i < len(self.Inputs):
+                    self.Inputs[i].SetPosition(wx.Point(0, ypos))
+                if i < len(self.Outputs):
+                    self.Outputs[i].SetPosition(wx.Point(self.Size[0], ypos))
                 position += linesize
         self.RefreshConnected()
     
@@ -192,7 +195,7 @@
                     resulttype = outputtype
         return resulttype
     
-    # Returns all the block connectors 
+    # Returns all the block connectors
     def GetConnectors(self):
         return {"inputs" : self.Inputs, "outputs" : self.Outputs}
     
@@ -464,10 +467,15 @@
     
     # Refresh the position of the variable connector
     def RefreshConnectors(self):
+        scaling = self.Parent.GetScaling()
+        if scaling is not None:
+            position = round(float(self.Pos.y + self.Size[1] / 2) / float(scaling[1])) * scaling[1] - self.Pos.y
+        else:
+            position = self.Size[1] / 2
         if self.Input:
-            self.Input.SetPosition(wx.Point(0, self.Size[1] / 2))
+            self.Input.SetPosition(wx.Point(0, position))
         if self.Output:
-            self.Output.SetPosition(wx.Point(self.Size[0], self.Size[1] / 2))
+            self.Output.SetPosition(wx.Point(self.Size[0], position))
         self.RefreshConnected()
     
     # Refresh the position of wires connected to connector
@@ -674,10 +682,15 @@
     
     # Refresh the position of the connection connector
     def RefreshConnectors(self):
+        scaling = self.Parent.GetScaling()
+        if scaling is not None:
+            position = round(float(self.Pos.y + self.Size[1] / 2) / float(scaling[1])) * scaling[1] - self.Pos.y
+        else:
+            position = self.Size[1] / 2
         if self.Type == CONNECTOR:
-            self.Connector.SetPosition(wx.Point(0, self.Size[1] / 2))
-        else:
-            self.Connector.SetPosition(wx.Point(self.Size[0], self.Size[1] / 2))
+            self.Connector.SetPosition(wx.Point(0, position))
+        else:
+            self.Connector.SetPosition(wx.Point(self.Size[0], position))
         self.RefreshConnected()
     
     # Refresh the position of wires connected to connector
@@ -711,6 +724,9 @@
     def GetType(self):
         return self.Type
     
+    def GetConnectionResultType(self, connector, connectortype):
+        return connectortype
+    
     # Changes the connection name
     def SetName(self, name):
         self.Name = name