equal
deleted
inserted
replaced
21 # You should have received a copy of the GNU General Public License |
21 # You should have received a copy of the GNU General Public License |
22 # along with this program; if not, write to the Free Software |
22 # along with this program; if not, write to the Free Software |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 |
24 |
25 |
25 |
26 from __future__ import absolute_import |
26 |
27 from __future__ import division |
27 |
28 import wx |
28 import wx |
29 from six.moves import xrange |
29 from six.moves import xrange |
30 |
30 |
31 from graphics.GraphicCommons import * |
31 from graphics.GraphicCommons import * |
32 from plcopen.structures import * |
32 from plcopen.structures import * |
76 block.Inputs = [input.Clone(block) for input in self.Inputs] |
76 block.Inputs = [input.Clone(block) for input in self.Inputs] |
77 block.Outputs = [output.Clone(block) for output in self.Outputs] |
77 block.Outputs = [output.Clone(block) for output in self.Outputs] |
78 return block |
78 return block |
79 |
79 |
80 def GetConnectorTranslation(self, element): |
80 def GetConnectorTranslation(self, element): |
81 return dict(zip(self.Inputs + self.Outputs, element.Inputs + element.Outputs)) |
81 return dict(list(zip(self.Inputs + self.Outputs, element.Inputs + element.Outputs))) |
82 |
82 |
83 def Flush(self): |
83 def Flush(self): |
84 for input in self.Inputs: |
84 for input in self.Inputs: |
85 input.Flush() |
85 input.Flush() |
86 self.Inputs = [] |
86 self.Inputs = [] |
163 lines = max(len(self.Inputs), len(self.Outputs)) |
163 lines = max(len(self.Inputs), len(self.Outputs)) |
164 if lines > 0: |
164 if lines > 0: |
165 linesize = max((self.Size[1] - BLOCK_LINE_SIZE) // lines, BLOCK_LINE_SIZE) |
165 linesize = max((self.Size[1] - BLOCK_LINE_SIZE) // lines, BLOCK_LINE_SIZE) |
166 # Update inputs and outputs positions |
166 # Update inputs and outputs positions |
167 position = BLOCK_LINE_SIZE + linesize // 2 |
167 position = BLOCK_LINE_SIZE + linesize // 2 |
168 for i in xrange(lines): |
168 for i in range(lines): |
169 if scaling is not None: |
169 if scaling is not None: |
170 ypos = round_scaling(self.Pos.y + position, scaling[1]) - self.Pos.y |
170 ypos = round_scaling(self.Pos.y + position, scaling[1]) - self.Pos.y |
171 else: |
171 else: |
172 ypos = position |
172 ypos = position |
173 if i < len(self.Inputs): |
173 if i < len(self.Inputs): |
254 self.Colour = wx.BLACK |
254 self.Colour = wx.BLACK |
255 inputs = [input for input in blocktype["inputs"]] |
255 inputs = [input for input in blocktype["inputs"]] |
256 outputs = [output for output in blocktype["outputs"]] |
256 outputs = [output for output in blocktype["outputs"]] |
257 if blocktype["extensible"]: |
257 if blocktype["extensible"]: |
258 start = int(inputs[-1][0].replace("IN", "")) |
258 start = int(inputs[-1][0].replace("IN", "")) |
259 for dummy in xrange(self.Extension - len(blocktype["inputs"])): |
259 for dummy in range(self.Extension - len(blocktype["inputs"])): |
260 start += 1 |
260 start += 1 |
261 inputs.append(("IN%d" % start, inputs[-1][1], inputs[-1][2])) |
261 inputs.append(("IN%d" % start, inputs[-1][1], inputs[-1][2])) |
262 comment = blocktype["comment"] |
262 comment = blocktype["comment"] |
263 self.Description = _(comment) + blocktype.get("usage", "") |
263 self.Description = _(comment) + blocktype.get("usage", "") |
264 else: |
264 else: |
449 # Removes all the highlights of one particular type from the block |
449 # Removes all the highlights of one particular type from the block |
450 def ClearHighlight(self, highlight_type=None): |
450 def ClearHighlight(self, highlight_type=None): |
451 if highlight_type is None: |
451 if highlight_type is None: |
452 self.Highlights = {} |
452 self.Highlights = {} |
453 else: |
453 else: |
454 highlight_items = self.Highlights.items() |
454 highlight_items = list(self.Highlights.items()) |
455 for name, highlights in highlight_items: |
455 for name, highlights in highlight_items: |
456 highlights = ClearHighlights(highlights, highlight_type) |
456 highlights = ClearHighlights(highlights, highlight_type) |
457 if len(highlights) == 0: |
457 if len(highlights) == 0: |
458 self.Highlights.pop(name) |
458 self.Highlights.pop(name) |
459 for input in self.Inputs: |
459 for input in self.Inputs: |