graphics/SFC_Objects.py
changeset 1339 6adf05c4508d
parent 1338 c1e6c712cc35
child 1571 486f94a8032c
equal deleted inserted replaced
1338:c1e6c712cc35 1339:6adf05c4508d
  1892     def SetActions(self, actions):
  1892     def SetActions(self, actions):
  1893         self.Actions = actions
  1893         self.Actions = actions
  1894         self.ColSize = [0, 0, 0]
  1894         self.ColSize = [0, 0, 0]
  1895         min_height = 0
  1895         min_height = 0
  1896         for action in self.Actions:
  1896         for action in self.Actions:
  1897             width, height = self.Parent.GetTextExtent(action.qualifier)
  1897             width, height = self.Parent.GetTextExtent(
       
  1898                 action.qualifier if action.qualifier != "" else "N")
  1898             self.ColSize[0] = max(self.ColSize[0], width + 10)
  1899             self.ColSize[0] = max(self.ColSize[0], width + 10)
  1899             row_height = height
  1900             row_height = height
  1900             if action.duration is not None:
  1901             if action.duration != "":
  1901                 width, height = self.Parent.GetTextExtent(action.duration)
  1902                 width, height = self.Parent.GetTextExtent(action.duration)
  1902                 row_height = max(row_height, height)
  1903                 row_height = max(row_height, height)
  1903                 self.ColSize[0] = max(self.ColSize[0], width + 10)
  1904                 self.ColSize[0] = max(self.ColSize[0], width + 10)
  1904             width, height = self.Parent.GetTextExtent(action.value)
  1905             width, height = self.Parent.GetTextExtent(action.value)
  1905             row_height = max(row_height, height)
  1906             row_height = max(row_height, height)
  1906             self.ColSize[1] = max(self.ColSize[1], width + 10)
  1907             self.ColSize[1] = max(self.ColSize[1], width + 10)
  1907             if action.indicator is not None:
  1908             if action.indicator != "":
  1908                 width, height = self.Parent.GetTextExtent(action.indicator)
  1909                 width, height = self.Parent.GetTextExtent(action.indicator)
  1909                 row_height = max(row_height, height)
  1910                 row_height = max(row_height, height)
  1910                 self.ColSize[2] = max(self.ColSize[2], width + 10)
  1911                 self.ColSize[2] = max(self.ColSize[2], width + 10)
  1911             min_height += row_height + 5
  1912             min_height += row_height + 5
  1912         if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
  1913         if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
  1918             self.Size = wx.Size(max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2],
  1919             self.Size = wx.Size(max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2],
  1919                 SFC_ACTION_MIN_SIZE[0]), len(self.Actions) * SFC_ACTION_MIN_SIZE[1])
  1920                 SFC_ACTION_MIN_SIZE[0]), len(self.Actions) * SFC_ACTION_MIN_SIZE[1])
  1920             self.MinSize = max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2],
  1921             self.MinSize = max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2],
  1921                 SFC_ACTION_MIN_SIZE[0]), len(self.Actions) * SFC_ACTION_MIN_SIZE[1]
  1922                 SFC_ACTION_MIN_SIZE[0]), len(self.Actions) * SFC_ACTION_MIN_SIZE[1]
  1922             self.RefreshBoundingBox()
  1923             self.RefreshBoundingBox()
  1923             if self.Input:
  1924             if self.Input is not None:
  1924                 wires = self.Input.GetWires()
  1925                 wires = self.Input.GetWires()
  1925                 if len(wires) == 1:
  1926                 if len(wires) == 1:
  1926                     input_block = wires[0][0].GetOtherConnected(self.Input).GetParentBlock()
  1927                     input_block = wires[0][0].GetOtherConnected(self.Input).GetParentBlock()
  1927                     input_block.RefreshOutputPosition()
  1928                     input_block.RefreshOutputPosition()
  1928                     input_block.RefreshOutputModel(True)
  1929                     input_block.RefreshOutputModel(True)
  2021         for i, action in enumerate(self.Actions):
  2022         for i, action in enumerate(self.Actions):
  2022             if i != 0:
  2023             if i != 0:
  2023                 dc.DrawLine(self.Pos.x, self.Pos.y + i * line_size, 
  2024                 dc.DrawLine(self.Pos.x, self.Pos.y + i * line_size, 
  2024                     self.Pos.x + self.Size[0], self.Pos.y + i * line_size)
  2025                     self.Pos.x + self.Size[0], self.Pos.y + i * line_size)
  2025             qualifier_size = dc.GetTextExtent(action.qualifier)
  2026             qualifier_size = dc.GetTextExtent(action.qualifier)
  2026             if action.duration is not None:
  2027             if action.duration != "":
  2027                 qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) / 2,
  2028                 qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) / 2,
  2028                                  self.Pos.y + i * line_size + line_size / 2 - qualifier_size[1])
  2029                                  self.Pos.y + i * line_size + line_size / 2 - qualifier_size[1])
  2029                 duration_size = dc.GetTextExtent(action.duration)
  2030                 duration_size = dc.GetTextExtent(action.duration)
  2030                 duration_pos = (self.Pos.x + (colsize[0] - duration_size[0]) / 2,
  2031                 duration_pos = (self.Pos.x + (colsize[0] - duration_size[0]) / 2,
  2031                                 self.Pos.y + i * line_size + line_size / 2)
  2032                                 self.Pos.y + i * line_size + line_size / 2)
  2036             dc.DrawText(action.qualifier, qualifier_pos[0], qualifier_pos[1])
  2037             dc.DrawText(action.qualifier, qualifier_pos[0], qualifier_pos[1])
  2037             content_size = dc.GetTextExtent(action.value)
  2038             content_size = dc.GetTextExtent(action.value)
  2038             content_pos = (self.Pos.x + colsize[0] + (colsize[1] - content_size[0]) / 2,
  2039             content_pos = (self.Pos.x + colsize[0] + (colsize[1] - content_size[0]) / 2,
  2039                            self.Pos.y + i * line_size + (line_size - content_size[1]) / 2)
  2040                            self.Pos.y + i * line_size + (line_size - content_size[1]) / 2)
  2040             dc.DrawText(action.value, content_pos[0], content_pos[1])
  2041             dc.DrawText(action.value, content_pos[0], content_pos[1])
  2041             if action.indicator is not None:
  2042             if action.indicator != "":
  2042                 indicator_size = dc.GetTextExtent(action.indicator)
  2043                 indicator_size = dc.GetTextExtent(action.indicator)
  2043                 indicator_pos = (self.Pos.x + colsize[0] + colsize[1] + (colsize[2] - indicator_size[0]) / 2,
  2044                 indicator_pos = (self.Pos.x + colsize[0] + colsize[1] + (colsize[2] - indicator_size[0]) / 2,
  2044                                  self.Pos.y + i * line_size + (line_size - indicator_size[1]) / 2)
  2045                                  self.Pos.y + i * line_size + (line_size - indicator_size[1]) / 2)
  2045                 dc.DrawText(action.indicator, indicator_pos[0], indicator_pos[1])
  2046                 dc.DrawText(action.indicator, indicator_pos[0], indicator_pos[1])
  2046             
  2047