260 def UpdateSize(self, width, height): |
263 def UpdateSize(self, width, height): |
261 diffx = self.Size.GetWidth() / 2 - width / 2 |
264 diffx = self.Size.GetWidth() / 2 - width / 2 |
262 diffy = height - self.Size.GetHeight() |
265 diffy = height - self.Size.GetHeight() |
263 self.Move(diffx, 0) |
266 self.Move(diffx, 0) |
264 Graphic_Element.SetSize(self, width, height) |
267 Graphic_Element.SetSize(self, width, height) |
265 self.RefreshOutputPosition((0, diffy)) |
268 if self.Parent.GetDrawingMode() == FREEDRAWING_MODE: |
|
269 self.RefreshConnected() |
|
270 else: |
|
271 self.RefreshOutputPosition((0, diffy)) |
266 |
272 |
267 # Align input element with this step |
273 # Align input element with this step |
268 def RefreshInputPosition(self): |
274 def RefreshInputPosition(self): |
269 if self.Input: |
275 if self.Input: |
270 current_pos = self.Input.GetPosition(False) |
276 current_pos = self.Input.GetPosition(False) |
441 self.Type = None |
447 self.Type = None |
442 self.Id = id |
448 self.Id = id |
443 self.Priority = 0 |
449 self.Priority = 0 |
444 self.Size = wx.Size(SFC_TRANSITION_SIZE[0], SFC_TRANSITION_SIZE[1]) |
450 self.Size = wx.Size(SFC_TRANSITION_SIZE[0], SFC_TRANSITION_SIZE[1]) |
445 # Create an input and output connector |
451 # Create an input and output connector |
446 self.Input = Connector(self, "", "ANY", wx.Point(self.Size[0] / 2, 0), NORTH) |
452 self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH) |
447 self.Output = Connector(self, "", "ANY", wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH) |
453 self.Output = Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH) |
448 self.SetType(type, condition) |
454 self.SetType(type, condition) |
449 self.SetPriority(priority) |
455 self.SetPriority(priority) |
450 |
456 |
451 # Destructor |
457 # Destructor |
452 def __del__(self): |
458 def __del__(self): |
774 self.Size = wx.Size((number - 1) * SFC_DEFAULT_SEQUENCE_INTERVAL, 1) |
780 self.Size = wx.Size((number - 1) * SFC_DEFAULT_SEQUENCE_INTERVAL, 1) |
775 elif self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]: |
781 elif self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]: |
776 self.Size = wx.Size((number - 1) * SFC_DEFAULT_SEQUENCE_INTERVAL, 3) |
782 self.Size = wx.Size((number - 1) * SFC_DEFAULT_SEQUENCE_INTERVAL, 3) |
777 # Create an input and output connector |
783 # Create an input and output connector |
778 if self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]: |
784 if self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]: |
779 self.Inputs = [Connector(self, "", "ANY", wx.Point(self.Size[0] / 2, 0), NORTH)] |
785 self.Inputs = [Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH)] |
780 self.Outputs = [] |
786 self.Outputs = [] |
781 for i in xrange(number): |
787 for i in xrange(number): |
782 self.Outputs.append(Connector(self, "", "ANY", wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH)) |
788 self.Outputs.append(Connector(self, "", None, wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH)) |
783 elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]: |
789 elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]: |
784 self.Inputs = [] |
790 self.Inputs = [] |
785 for i in xrange(number): |
791 for i in xrange(number): |
786 self.Inputs.append(Connector(self, "", "ANY", wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH)) |
792 self.Inputs.append(Connector(self, "", None, wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH)) |
787 self.Outputs = [Connector(self, "", "ANY", wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH)] |
793 self.Outputs = [Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH)] |
788 |
794 |
789 # Destructor |
795 # Destructor |
790 def __del__(self): |
796 def __del__(self): |
791 self.Inputs = [] |
797 self.Inputs = [] |
792 self.Outputs = [] |
798 self.Outputs = [] |
816 if self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]: |
822 if self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]: |
817 maxx = 0 |
823 maxx = 0 |
818 for output in self.Outputs: |
824 for output in self.Outputs: |
819 pos = output.GetRelPosition() |
825 pos = output.GetRelPosition() |
820 maxx = max(maxx, pos.x) |
826 maxx = max(maxx, pos.x) |
821 connector = Connector(self, "", "ANY", wx.Point(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH) |
827 connector = Connector(self, "", None, wx.Point(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH) |
822 self.Outputs.append(connector) |
828 self.Outputs.append(connector) |
823 self.MoveConnector(connector, 0) |
829 self.MoveConnector(connector, 0) |
824 elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]: |
830 elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]: |
825 maxx = 0 |
831 maxx = 0 |
826 for input in self.Inputs: |
832 for input in self.Inputs: |
827 pos = input.GetRelPosition() |
833 pos = input.GetRelPosition() |
828 maxx = max(maxx, pos.x) |
834 maxx = max(maxx, pos.x) |
829 connector = Connector(self, "", "ANY", wx.Point(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH) |
835 connector = Connector(self, "", None, wx.Point(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH) |
830 self.Inputs.append(connector) |
836 self.Inputs.append(connector) |
831 self.MoveConnector(connector, SFC_DEFAULT_SEQUENCE_INTERVAL) |
837 self.MoveConnector(connector, SFC_DEFAULT_SEQUENCE_INTERVAL) |
832 |
838 |
833 # Remove a branch from the divergence |
839 # Remove a branch from the divergence |
834 def RemoveBranch(self, connector): |
840 def RemoveBranch(self, connector): |
1316 # Create a new action block |
1322 # Create a new action block |
1317 def __init__(self, parent, actions = [], id = None): |
1323 def __init__(self, parent, actions = [], id = None): |
1318 Graphic_Element.__init__(self, parent) |
1324 Graphic_Element.__init__(self, parent) |
1319 self.Id = id |
1325 self.Id = id |
1320 self.Size = wx.Size(SFC_ACTION_MIN_SIZE[0], SFC_ACTION_MIN_SIZE[1]) |
1326 self.Size = wx.Size(SFC_ACTION_MIN_SIZE[0], SFC_ACTION_MIN_SIZE[1]) |
|
1327 self.MinSize = wx.Size(SFC_ACTION_MIN_SIZE[0], SFC_ACTION_MIN_SIZE[1]) |
1321 # Create an input and output connector |
1328 # Create an input and output connector |
1322 self.Input = Connector(self, "", "ANY", wx.Point(0, SFC_ACTION_MIN_SIZE[1] / 2), WEST) |
1329 self.Input = Connector(self, "", None, wx.Point(0, SFC_ACTION_MIN_SIZE[1] / 2), WEST) |
1323 self.SetActions(actions) |
1330 self.SetActions(actions) |
1324 |
1331 |
1325 # Destructor |
1332 # Destructor |
1326 def __del__(self): |
1333 def __del__(self): |
1327 self.Input = None |
1334 self.Input = None |
1374 # Changes the action block actions |
1381 # Changes the action block actions |
1375 def SetActions(self, actions): |
1382 def SetActions(self, actions): |
1376 dc = wx.ClientDC(self.Parent) |
1383 dc = wx.ClientDC(self.Parent) |
1377 self.Actions = actions |
1384 self.Actions = actions |
1378 self.ColSize = [0, 0, 0] |
1385 self.ColSize = [0, 0, 0] |
|
1386 min_height = 0 |
1379 for action in self.Actions: |
1387 for action in self.Actions: |
1380 width, height = dc.GetTextExtent(action["qualifier"]) |
1388 width, height = dc.GetTextExtent(action["qualifier"]) |
1381 self.ColSize[0] = max(self.ColSize[0], width + 10) |
1389 self.ColSize[0] = max(self.ColSize[0], width + 10) |
|
1390 row_height = height |
1382 if "duration" in action: |
1391 if "duration" in action: |
1383 width, height = dc.GetTextExtent(action["duration"]) |
1392 width, height = dc.GetTextExtent(action["duration"]) |
|
1393 row_height = max(row_height, height) |
1384 self.ColSize[0] = max(self.ColSize[0], width + 10) |
1394 self.ColSize[0] = max(self.ColSize[0], width + 10) |
1385 width, height = dc.GetTextExtent(action["value"]) |
1395 width, height = dc.GetTextExtent(action["value"]) |
|
1396 row_height = max(row_height, height) |
1386 self.ColSize[1] = max(self.ColSize[1], width + 10) |
1397 self.ColSize[1] = max(self.ColSize[1], width + 10) |
1387 if "indicator" in action and action["indicator"] != "": |
1398 if "indicator" in action and action["indicator"] != "": |
1388 width, height = dc.GetTextExtent(action["indicator"]) |
1399 width, height = dc.GetTextExtent(action["indicator"]) |
|
1400 row_height = max(row_height, height) |
1389 self.ColSize[2] = max(self.ColSize[2], width + 10) |
1401 self.ColSize[2] = max(self.ColSize[2], width + 10) |
|
1402 min_height += row_height + 5 |
1390 if self.Parent.GetDrawingMode() == FREEDRAWING_MODE: |
1403 if self.Parent.GetDrawingMode() == FREEDRAWING_MODE: |
1391 line_size = self.GetLineSize() |
1404 self.Size = wx.Size(self.ColSize[0] + self.ColSize[1] + self.ColSize[2], max(min_height, SFC_ACTION_MIN_SIZE[1], self.Size[1])) |
1392 self.Size = wx.Size(self.ColSize[0] + self.ColSize[1] + self.ColSize[2], len(self.Actions) * line_size) |
1405 self.MinSize = max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2], |
|
1406 SFC_ACTION_MIN_SIZE[0]), max(SFC_ACTION_MIN_SIZE[1], min_height) |
|
1407 self.RefreshBoundingBox() |
1393 else: |
1408 else: |
1394 self.Size = wx.Size(max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2], |
1409 self.Size = wx.Size(max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2], |
1395 SFC_ACTION_MIN_SIZE[0]), len(self.Actions) * SFC_ACTION_MIN_SIZE[1]) |
1410 SFC_ACTION_MIN_SIZE[0]), len(self.Actions) * SFC_ACTION_MIN_SIZE[1]) |
1396 self.RefreshBoundingBox() |
1411 self.MinSize = max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2], |
1397 if self.Input: |
1412 SFC_ACTION_MIN_SIZE[0]), len(self.Actions) * SFC_ACTION_MIN_SIZE[1] |
1398 wires = self.Input.GetWires() |
1413 self.RefreshBoundingBox() |
1399 if len(wires) == 1: |
1414 if self.Input: |
1400 input_block = wires[0][0].EndConnected.GetParentBlock() |
1415 wires = self.Input.GetWires() |
1401 input_block.RefreshOutputPosition() |
1416 if len(wires) == 1: |
1402 input_block.RefreshOutputModel(True) |
1417 input_block = wires[0][0].EndConnected.GetParentBlock() |
|
1418 input_block.RefreshOutputPosition() |
|
1419 input_block.RefreshOutputModel(True) |
1403 |
1420 |
1404 # Returns the action block actions |
1421 # Returns the action block actions |
1405 def GetActions(self): |
1422 def GetActions(self): |
1406 return self.Actions |
1423 return self.Actions |
1407 |
1424 |
1408 # Returns the action block minimum size |
1425 # Returns the action block minimum size |
1409 def GetMinSize(self): |
1426 def GetMinSize(self): |
1410 return max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2], |
1427 return self.MinSize |
1411 SFC_ACTION_MIN_SIZE[0]), len(self.Actions) * SFC_ACTION_MIN_SIZE[1] |
|
1412 |
1428 |
1413 # Method called when a LeftDClick event have been generated |
1429 # Method called when a LeftDClick event have been generated |
1414 def OnLeftDClick(self, event, dc, scaling): |
1430 def OnLeftDClick(self, event, dc, scaling): |
1415 # Edit the action block properties |
1431 # Edit the action block properties |
1416 self.Parent.EditActionBlockContent(self) |
1432 self.Parent.EditActionBlockContent(self) |