SFCViewer.py
changeset 2 93bc4c2cf376
parent 1 e9d01d824086
child 5 f8652b073e84
equal deleted inserted replaced
1:e9d01d824086 2:93bc4c2cf376
    73             next_pos = next.GetPosition(False)
    73             next_pos = next.GetPosition(False)
    74             transition.RefreshOutputPosition((0, pos.y + SFC_WIRE_MIN_SIZE - next_pos.y))
    74             transition.RefreshOutputPosition((0, pos.y + SFC_WIRE_MIN_SIZE - next_pos.y))
    75             wire.SetPoints([wxPoint(pos.x, pos.y + SFC_WIRE_MIN_SIZE), wxPoint(pos.x, pos.y)])
    75             wire.SetPoints([wxPoint(pos.x, pos.y + SFC_WIRE_MIN_SIZE), wxPoint(pos.x, pos.y)])
    76             if isinstance(next_block, SFC_Divergence):
    76             if isinstance(next_block, SFC_Divergence):
    77                 next_block.RefreshPosition()
    77                 next_block.RefreshPosition()
    78             next_block.RefreshModel()
    78             transition.RefreshOutputModel(True)
    79         return transition
    79         return transition
    80     
    80     
    81     def RemoveTransition(self, transition):
    81     def RemoveTransition(self, transition):
    82         connectors = transition.GetConnectors()
    82         connectors = transition.GetConnectors()
    83         input_wires = connectors["input"].GetWires()
    83         input_wires = connectors["input"].GetWires()
   131             next_pos = next.GetPosition(False)
   131             next_pos = next.GetPosition(False)
   132             step.RefreshOutputPosition((0, pos.y + SFC_WIRE_MIN_SIZE - next_pos.y))
   132             step.RefreshOutputPosition((0, pos.y + SFC_WIRE_MIN_SIZE - next_pos.y))
   133             wire.SetPoints([wxPoint(pos.x, pos.y + SFC_WIRE_MIN_SIZE), wxPoint(pos.x, pos.y)])
   133             wire.SetPoints([wxPoint(pos.x, pos.y + SFC_WIRE_MIN_SIZE), wxPoint(pos.x, pos.y)])
   134             if isinstance(next_block, SFC_Divergence):
   134             if isinstance(next_block, SFC_Divergence):
   135                 next_block.RefreshPosition()
   135                 next_block.RefreshPosition()
   136             next_block.RefreshModel()
   136             step.RefreshOutputModel(True)
   137         return step
   137         return step
   138 
   138 
   139     def RemoveStep(self, step):
   139     def RemoveStep(self, step):
   140         connectors = step.GetConnectors()
   140         connectors = step.GetConnectors()
   141         if connectors["input"]:
   141         if connectors["input"]:
   793                     wire_size = GetWireSize(previous_block)
   793                     wire_size = GetWireSize(previous_block)
   794                     previous_block.RefreshOutputPosition((0, pos.y + wire_size - next_pos.y))
   794                     previous_block.RefreshOutputPosition((0, pos.y + wire_size - next_pos.y))
   795                     wire.SetPoints([wxPoint(pos.x, pos.y + wire_size), wxPoint(pos.x, pos.y)])
   795                     wire.SetPoints([wxPoint(pos.x, pos.y + wire_size), wxPoint(pos.x, pos.y)])
   796                     if isinstance(next_block, SFC_Divergence):
   796                     if isinstance(next_block, SFC_Divergence):
   797                         next_block.RefreshPosition()
   797                         next_block.RefreshPosition()
   798                     next_block.RefreshModel()
   798                     previous_block.RefreshOutputModel(True)
   799             else:
   799             else:
   800                 if isinstance(previous_block, SFC_Step):
   800                 if isinstance(previous_block, SFC_Step):
   801                     previous_block.RemoveOutput()
   801                     previous_block.RemoveOutput()
   802                     self.RefreshStepModel(previous_block)
   802                     self.RefreshStepModel(previous_block)
   803                 elif isinstance(previous_block, SFC_Divergence):
   803                 elif isinstance(previous_block, SFC_Divergence):
   908                 previous_block.RefreshOutputPosition((0, previous_pos.y + wire_size - next_pos.y))
   908                 previous_block.RefreshOutputPosition((0, previous_pos.y + wire_size - next_pos.y))
   909                 wire.SetPoints([wxPoint(previous_pos.x, previous_pos.y + wire_size), 
   909                 wire.SetPoints([wxPoint(previous_pos.x, previous_pos.y + wire_size), 
   910                     wxPoint(previous_pos.x, previous_pos.y)])
   910                     wxPoint(previous_pos.x, previous_pos.y)])
   911                 if isinstance(next_block, SFC_Divergence):
   911                 if isinstance(next_block, SFC_Divergence):
   912                     next_block.RefreshPosition()
   912                     next_block.RefreshPosition()
   913                 next_block.RefreshModel()
   913                 previous_block.RefreshOutputModel(True)
   914         elif divergence.GetBranchNumber() == 1:
   914         elif divergence.GetBranchNumber() == 1:
   915             wires = connectors["inputs"][0].GetWires()
   915             wires = connectors["inputs"][0].GetWires()
   916             if len(wires) != 1:
   916             if len(wires) != 1:
   917                 return
   917                 return
   918             wire = wires[0][0]
   918             wire = wires[0][0]
   941             previous_block.RefreshOutputPosition((previous_pos.x - next_pos.x, previous_pos.y + wire_size - next_pos.y))
   941             previous_block.RefreshOutputPosition((previous_pos.x - next_pos.x, previous_pos.y + wire_size - next_pos.y))
   942             wire.SetPoints([wxPoint(previous_pos.x, previous_pos.y + wire_size), 
   942             wire.SetPoints([wxPoint(previous_pos.x, previous_pos.y + wire_size), 
   943                 wxPoint(previous_pos.x, previous_pos.y)])
   943                 wxPoint(previous_pos.x, previous_pos.y)])
   944             if isinstance(next_block, SFC_Divergence):
   944             if isinstance(next_block, SFC_Divergence):
   945                 next_block.RefreshPosition()
   945                 next_block.RefreshPosition()
   946             next_block.RefreshModel()
   946             previous_block.RefreshOutputModel(True)
   947         self.Parent.RefreshProjectTree()
   947         self.Parent.RefreshProjectTree()
   948 
   948 
   949     def DeleteJump(self, jump):
   949     def DeleteJump(self, jump):
   950         previous = jump.GetPreviousConnector()
   950         previous = jump.GetPreviousConnector()
   951         previous_block = previous.GetParentBlock()
   951         previous_block = previous.GetParentBlock()