graphics/SFC_Objects.py
changeset 633 3536f4469cde
parent 566 6014ef82a98a
child 634 cc3335911c01
equal deleted inserted replaced
632:3ea55a5db68e 633:3536f4469cde
   251             self.Action.MoveConnected(exclude)
   251             self.Action.MoveConnected(exclude)
   252     
   252     
   253     # Returns the step connector that starts with the point given if it exists 
   253     # Returns the step connector that starts with the point given if it exists 
   254     def GetConnector(self, position, name = None):
   254     def GetConnector(self, position, name = None):
   255         # if a name is given
   255         # if a name is given
   256         if name:
   256         if name is not None:
   257             # Test input, output and action connector if they exists
   257             # Test input, output and action connector if they exists
   258             if self.Input and name == self.Input.GetName():
   258             #if self.Input and name == self.Input.GetName():
   259                 return self.Input
   259             #    return self.Input
   260             if self.Output and name == self.Output.GetName():
   260             if self.Output and name == self.Output.GetName():
   261                 return self.Output
   261                 return self.Output
   262             if self.Action and name == self.Action.GetName():
   262             if self.Action and name == self.Action.GetName():
   263                 return self.Action
   263                 return self.Action
   264         connectors = []
   264         connectors = []
   755             self.Condition.MoveConnected(exclude)
   755             self.Condition.MoveConnected(exclude)
   756     
   756     
   757     # Returns the transition connector that starts with the point given if it exists 
   757     # Returns the transition connector that starts with the point given if it exists 
   758     def GetConnector(self, position, name = None):
   758     def GetConnector(self, position, name = None):
   759         # if a name is given
   759         # if a name is given
   760         if name:
   760         if name is not None:
   761             # Test input and output connector
   761             # Test input and output connector
   762             if name == self.Input.GetName():
   762             #if name == self.Input.GetName():
   763                 return self.Input
   763             #    return self.Input
   764             if name == self.Output.GetName():
   764             if name == self.Output.GetName():
   765                 return self.Output
   765                 return self.Output
   766             if self.Type == "connection" and name == self.Condition.GetName():
   766             if self.Type == "connection" and name == self.Condition.GetName():
   767                 return self.Condition
   767                 return self.Condition
   768         connectors = [self.Input, self.Output]
   768         connectors = [self.Input, self.Output]
  1176             return len(self.Outputs)
  1176             return len(self.Outputs)
  1177         elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]:
  1177         elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]:
  1178             return len(self.Inputs)
  1178             return len(self.Inputs)
  1179     
  1179     
  1180     # Returns if the point given is in the bounding box
  1180     # Returns if the point given is in the bounding box
  1181     def HitTest(self, pt):
  1181     def HitTest(self, pt, connectors=True):
  1182         rect = self.BoundingBox
  1182         if connectors:
       
  1183             rect = self.BoundingBox
       
  1184         else:
       
  1185             rect = wx.Rect(self.Pos.x, self.Pos.y, self.Size[0], self.Size[1])
  1183         return rect.InsideXY(pt.x, pt.y) or self.TestConnector(pt, exclude=False) != None
  1186         return rect.InsideXY(pt.x, pt.y) or self.TestConnector(pt, exclude=False) != None
  1184     
  1187     
  1185     # Refresh the divergence bounding box
  1188     # Refresh the divergence bounding box
  1186     def RefreshBoundingBox(self):
  1189     def RefreshBoundingBox(self):
  1187         if self.Type in [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE]:
  1190         if self.Type in [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE]:
  1227         self.RefreshBoundingBox()
  1230         self.RefreshBoundingBox()
  1228     
  1231     
  1229     # Returns the divergence connector that starts with the point given if it exists 
  1232     # Returns the divergence connector that starts with the point given if it exists 
  1230     def GetConnector(self, position, name = None):
  1233     def GetConnector(self, position, name = None):
  1231         # if a name is given
  1234         # if a name is given
  1232         if name:
  1235         if name is not None:
  1233             # Test each input and output connector
  1236             # Test each input and output connector
  1234             for input in self.Inputs:
  1237             #for input in self.Inputs:
  1235                 if name == input.GetName():
  1238             #    if name == input.GetName():
  1236                     return input
  1239             #        return input
  1237             for output in self.Outputs:
  1240             for output in self.Outputs:
  1238                 if name == output.GetName():
  1241                 if name == output.GetName():
  1239                     return output
  1242                     return output
  1240         return self.FindNearestConnector(position, self.Inputs + self.Outputs)
  1243         return self.FindNearestConnector(position, self.Inputs + self.Outputs)
  1241     
  1244