graphics/SFC_Objects.py
changeset 175 cc78572dfbbc
parent 172 198f7949f737
child 199 85d721b33574
equal deleted inserted replaced
174:97bbbaa54964 175:cc78572dfbbc
   526         if movex != 0 or movey != 0:
   526         if movex != 0 or movey != 0:
   527             if self.Input.IsConnected():
   527             if self.Input.IsConnected():
   528                 rect = rect.Union(self.Input.GetConnectedRedrawRect(movex, movey))
   528                 rect = rect.Union(self.Input.GetConnectedRedrawRect(movex, movey))
   529             if self.Output.IsConnected():
   529             if self.Output.IsConnected():
   530                 rect = rect.Union(self.Output.GetConnectedRedrawRect(movex, movey))
   530                 rect = rect.Union(self.Output.GetConnectedRedrawRect(movex, movey))
   531             if self.Type == "connection" and self.Connection.IsConnected():
   531             if self.Type == "connection" and self.Condition.IsConnected():
   532                 rect = rect.Union(self.Condition.GetConnectedRedrawRect(movex, movey))
   532                 rect = rect.Union(self.Condition.GetConnectedRedrawRect(movex, movey))
   533         return rect
   533         return rect
   534     
   534     
   535     # Forbids to change the transition size
   535     # Forbids to change the transition size
   536     def SetSize(self, width, height):
   536     def SetSize(self, width, height):
   776             self.Move(movex, 0)
   776             self.Move(movex, 0)
   777             self.RefreshInputPosition()
   777             self.RefreshInputPosition()
   778             self.RefreshOutputPosition()
   778             self.RefreshOutputPosition()
   779             return movex, 0
   779             return movex, 0
   780         else:
   780         else:
   781             return Graphic_Element.ProcessDragging(self, movex, movey, centered, scaling)
   781             return Graphic_Element.ProcessDragging(self, movex, movey, centered, scaling, width_fac = 2, height_fac = 2)
   782     
   782     
   783     # Refresh input element model
   783     # Refresh input element model
   784     def RefreshInputModel(self):
   784     def RefreshInputModel(self):
   785         if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
   785         if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
   786             input = self.GetPreviousConnector()
   786             input = self.GetPreviousConnector()
   814     def Draw(self, dc):
   814     def Draw(self, dc):
   815         Graphic_Element.Draw(self, dc)
   815         Graphic_Element.Draw(self, dc)
   816         dc.SetPen(wx.BLACK_PEN)
   816         dc.SetPen(wx.BLACK_PEN)
   817         dc.SetBrush(wx.BLACK_BRUSH)
   817         dc.SetBrush(wx.BLACK_BRUSH)
   818         # Draw plain rectangle for representing the transition
   818         # Draw plain rectangle for representing the transition
   819         dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
   819         dc.DrawRectangle(self.Pos.x, 
       
   820                          self.Pos.y + (self.Size[1] - SFC_TRANSITION_SIZE[1])/2, 
       
   821                          self.Size[0] + 1,
       
   822                          SFC_TRANSITION_SIZE[1] + 1)
       
   823         vertical_line_x = self.Input.GetPosition()[0]
       
   824         dc.DrawLine(vertical_line_x, self.Pos.y, vertical_line_x, self.Pos.y + self.Size[1]) 
   820         # Draw transition condition
   825         # Draw transition condition
   821         if self.Type != "connection":
   826         if self.Type != "connection":
   822             text_width, text_height = self.ConditionSize
   827             text_width, text_height = self.ConditionSize
   823             if self.Condition != "":
   828             if self.Condition != "":
   824                 condition = self.Condition
   829                 condition = self.Condition
   853         Graphic_Element.__init__(self, parent)
   858         Graphic_Element.__init__(self, parent)
   854         self.Type = type
   859         self.Type = type
   855         self.Id = id
   860         self.Id = id
   856         self.RealConnectors = None
   861         self.RealConnectors = None
   857         number = max(2, number)
   862         number = max(2, number)
   858         if self.Type in [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE]:
   863         self.Size = wx.Size((number - 1) * SFC_DEFAULT_SEQUENCE_INTERVAL, self.GetMinSize()[1])
   859             self.Size = wx.Size((number - 1) * SFC_DEFAULT_SEQUENCE_INTERVAL, 1)
       
   860         elif self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]:
       
   861             self.Size = wx.Size((number - 1) * SFC_DEFAULT_SEQUENCE_INTERVAL, 3)
       
   862         # Create an input and output connector
   864         # Create an input and output connector
   863         if self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]:
   865         if self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]:
   864             self.Inputs = [Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone = True)]
   866             self.Inputs = [Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone = True)]
   865             self.Outputs = []
   867             self.Outputs = []
   866             for i in xrange(number):
   868             for i in xrange(number):
   899         return rect
   901         return rect
   900     
   902     
   901     # Forbids to resize the divergence
   903     # Forbids to resize the divergence
   902     def Resize(self, x, y, width, height):
   904     def Resize(self, x, y, width, height):
   903         if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
   905         if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
   904             Graphic_Element.Resize(self, x, y, width, height)
   906             Graphic_Element.Resize(self, x, 0, width, self.GetMinSize()[1])
   905     
   907     
   906     # Delete this divergence by calling the appropriate method
   908     # Delete this divergence by calling the appropriate method
   907     def Delete(self):
   909     def Delete(self):
   908         self.Parent.DeleteDivergence(self)
   910         self.Parent.DeleteDivergence(self)
   909     
   911     
  1418                 movex = round(float(self.Pos.x + movex) / float(scaling[0])) * scaling[0] - self.Pos.x
  1420                 movex = round(float(self.Pos.x + movex) / float(scaling[0])) * scaling[0] - self.Pos.x
  1419             self.Move(movex, 0)
  1421             self.Move(movex, 0)
  1420             self.RefreshInputPosition()
  1422             self.RefreshInputPosition()
  1421             return movex, 0
  1423             return movex, 0
  1422         else:
  1424         else:
  1423             return Graphic_Element.ProcessDragging(self, movex, movey, centered, scaling)
  1425             return Graphic_Element.ProcessDragging(self, movex, movey, centered, scaling, width_fac = 2)
  1424     
  1426     
  1425     # Refresh input element model
  1427     # Refresh input element model
  1426     def RefreshInputModel(self):
  1428     def RefreshInputModel(self):
  1427         if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
  1429         if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
  1428             input = self.GetPreviousConnector()
  1430             input = self.GetPreviousConnector()