911 |
911 |
912 def AddError(self, infos, start, end): |
912 def AddError(self, infos, start, end): |
913 if infos[0] == "priority" and start[0] == 0 and start[1] == 0: |
913 if infos[0] == "priority" and start[0] == 0 and start[1] == 0: |
914 self.Errors[infos[0]] = (start[1], end[1]) |
914 self.Errors[infos[0]] = (start[1], end[1]) |
915 elif infos[0] == "inline": |
915 elif infos[0] == "inline": |
916 if infos[0] not in self.Errors: |
916 if not self.Errors.has_key(infos[0]): |
917 self.Errors[infos[0]] = [] |
917 self.Errors[infos[0]] = [] |
918 self.Errors[infos[0]].append((start[1], end[1])) |
918 self.Errors[infos[0]].append((start[1], end[1])) |
919 else: |
919 else: |
920 pass |
920 pass |
921 |
921 |
963 # Draw input and output connectors |
963 # Draw input and output connectors |
964 self.Input.Draw(dc) |
964 self.Input.Draw(dc) |
965 self.Output.Draw(dc) |
965 self.Output.Draw(dc) |
966 if self.Type == "connection": |
966 if self.Type == "connection": |
967 self.Condition.Draw(dc) |
967 self.Condition.Draw(dc) |
968 if "priority" in self.Errors: |
968 if self.Errors.has_key("priority"): |
969 HighlightErrorZone(dc, priority_pos[0], priority_pos[1], priority_size[0], priority_size[1]) |
969 HighlightErrorZone(dc, priority_pos[0], priority_pos[1], priority_size[0], priority_size[1]) |
970 if "inline" in self.Errors: |
970 if self.Errors.has_key("inline"): |
971 for start, end in self.Errors["inline"]: |
971 for start, end in self.Errors["inline"]: |
972 offset = dc.GetTextExtent(self.Condition[:start]) |
972 offset = dc.GetTextExtent(self.Condition[:start]) |
973 size = dc.GetTextExtent(self.Condition[start:end + 1]) |
973 size = dc.GetTextExtent(self.Condition[start:end + 1]) |
974 HighlightErrorZone(dc, condition_pos[0] + offset[0], condition_pos[1], size[0], size[1]) |
974 HighlightErrorZone(dc, condition_pos[0] + offset[0], condition_pos[1], size[0], size[1]) |
975 |
975 |
1679 self.Pos.y + (self.Size[1] - target_size[1]) / 2) |
1679 self.Pos.y + (self.Size[1] - target_size[1]) / 2) |
1680 dc.DrawText(self.Target, target_pos[0], target_pos[1]) |
1680 dc.DrawText(self.Target, target_pos[0], target_pos[1]) |
1681 # Draw input connector |
1681 # Draw input connector |
1682 if self.Input: |
1682 if self.Input: |
1683 self.Input.Draw(dc) |
1683 self.Input.Draw(dc) |
1684 if "target" in self.Errors: |
1684 if self.Errors.has_key("target"): |
1685 HighlightErrorZone(dc, target_pos[0], target_pos[1], target_size[0], target_size[1]) |
1685 HighlightErrorZone(dc, target_pos[0], target_pos[1], target_size[0], target_size[1]) |
1686 |
1686 |
1687 |
1687 |
1688 #------------------------------------------------------------------------------- |
1688 #------------------------------------------------------------------------------- |
1689 # Sequencial Function Chart Action Block |
1689 # Sequencial Function Chart Action Block |
1805 min_height = 0 |
1805 min_height = 0 |
1806 for action in self.Actions: |
1806 for action in self.Actions: |
1807 width, height = self.Parent.GetTextExtent(action["qualifier"]) |
1807 width, height = self.Parent.GetTextExtent(action["qualifier"]) |
1808 self.ColSize[0] = max(self.ColSize[0], width + 10) |
1808 self.ColSize[0] = max(self.ColSize[0], width + 10) |
1809 row_height = height |
1809 row_height = height |
1810 if "duration" in action: |
1810 if action.has_key("duration"): |
1811 width, height = self.Parent.GetTextExtent(action["duration"]) |
1811 width, height = self.Parent.GetTextExtent(action["duration"]) |
1812 row_height = max(row_height, height) |
1812 row_height = max(row_height, height) |
1813 self.ColSize[0] = max(self.ColSize[0], width + 10) |
1813 self.ColSize[0] = max(self.ColSize[0], width + 10) |
1814 width, height = self.Parent.GetTextExtent(action["value"]) |
1814 width, height = self.Parent.GetTextExtent(action["value"]) |
1815 row_height = max(row_height, height) |
1815 row_height = max(row_height, height) |
1816 self.ColSize[1] = max(self.ColSize[1], width + 10) |
1816 self.ColSize[1] = max(self.ColSize[1], width + 10) |
1817 if "indicator" in action and action["indicator"] != "": |
1817 if action.get("indicator", "") != "": |
1818 width, height = self.Parent.GetTextExtent(action["indicator"]) |
1818 width, height = self.Parent.GetTextExtent(action["indicator"]) |
1819 row_height = max(row_height, height) |
1819 row_height = max(row_height, height) |
1820 self.ColSize[2] = max(self.ColSize[2], width + 10) |
1820 self.ColSize[2] = max(self.ColSize[2], width + 10) |
1821 min_height += row_height + 5 |
1821 min_height += row_height + 5 |
1822 if self.Parent.GetDrawingMode() == FREEDRAWING_MODE: |
1822 if self.Parent.GetDrawingMode() == FREEDRAWING_MODE: |
1880 def RefreshModel(self, move=True): |
1880 def RefreshModel(self, move=True): |
1881 self.Parent.RefreshActionBlockModel(self) |
1881 self.Parent.RefreshActionBlockModel(self) |
1882 |
1882 |
1883 def AddError(self, infos, start, end): |
1883 def AddError(self, infos, start, end): |
1884 if infos[0] == "action" and infos[1] < len(self.Actions): |
1884 if infos[0] == "action" and infos[1] < len(self.Actions): |
1885 if infos[1] not in self.Errors: |
1885 if not self.Errors.has_key(infos[1]): |
1886 self.Errors[infos[1]] = {} |
1886 self.Errors[infos[1]] = {} |
1887 if infos[2] == "inline": |
1887 if infos[2] == "inline": |
1888 if infos[2] not in self.Errors[infos[1]]: |
1888 if not self.Errors[infos[1]].has_key(infos[2]): |
1889 self.Errors[infos[1]][infos[2]] = [] |
1889 self.Errors[infos[1]][infos[2]] = [] |
1890 self.Errors[infos[1]][infos[2]].append((start[1], end[1])) |
1890 self.Errors[infos[1]][infos[2]].append((start[1], end[1])) |
1891 else: |
1891 else: |
1892 self.Errors[infos[1]][infos[2]] = (start[1], end[1]) |
1892 self.Errors[infos[1]][infos[2]] = (start[1], end[1]) |
1893 |
1893 |
1910 for i, action in enumerate(self.Actions): |
1910 for i, action in enumerate(self.Actions): |
1911 if i != 0: |
1911 if i != 0: |
1912 dc.DrawLine(self.Pos.x, self.Pos.y + i * line_size, |
1912 dc.DrawLine(self.Pos.x, self.Pos.y + i * line_size, |
1913 self.Pos.x + self.Size[0], self.Pos.y + i * line_size) |
1913 self.Pos.x + self.Size[0], self.Pos.y + i * line_size) |
1914 qualifier_size = dc.GetTextExtent(action["qualifier"]) |
1914 qualifier_size = dc.GetTextExtent(action["qualifier"]) |
1915 if "duration" in action: |
1915 if action.has_key("duration"): |
1916 qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) / 2, |
1916 qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) / 2, |
1917 self.Pos.y + i * line_size + line_size / 2 - qualifier_size[1]) |
1917 self.Pos.y + i * line_size + line_size / 2 - qualifier_size[1]) |
1918 duration_size = dc.GetTextExtent(action["duration"]) |
1918 duration_size = dc.GetTextExtent(action["duration"]) |
1919 duration_pos = (self.Pos.x + (colsize[0] - duration_size[0]) / 2, |
1919 duration_pos = (self.Pos.x + (colsize[0] - duration_size[0]) / 2, |
1920 self.Pos.y + i * line_size + line_size / 2) |
1920 self.Pos.y + i * line_size + line_size / 2) |
1925 dc.DrawText(action["qualifier"], qualifier_pos[0], qualifier_pos[1]) |
1925 dc.DrawText(action["qualifier"], qualifier_pos[0], qualifier_pos[1]) |
1926 content_size = dc.GetTextExtent(action["value"]) |
1926 content_size = dc.GetTextExtent(action["value"]) |
1927 content_pos = (self.Pos.x + colsize[0] + (colsize[1] - content_size[0]) / 2, |
1927 content_pos = (self.Pos.x + colsize[0] + (colsize[1] - content_size[0]) / 2, |
1928 self.Pos.y + i * line_size + (line_size - content_size[1]) / 2) |
1928 self.Pos.y + i * line_size + (line_size - content_size[1]) / 2) |
1929 dc.DrawText(action["value"], content_pos[0], content_pos[1]) |
1929 dc.DrawText(action["value"], content_pos[0], content_pos[1]) |
1930 if "indicator" in action: |
1930 if action.has_key("indicator"): |
1931 indicator_size = dc.GetTextExtent(action["indicator"]) |
1931 indicator_size = dc.GetTextExtent(action["indicator"]) |
1932 indicator_pos = (self.Pos.x + colsize[0] + colsize[1] + (colsize[2] - indicator_size[0]) / 2, |
1932 indicator_pos = (self.Pos.x + colsize[0] + colsize[1] + (colsize[2] - indicator_size[0]) / 2, |
1933 self.Pos.y + i * line_size + (line_size - indicator_size[1]) / 2) |
1933 self.Pos.y + i * line_size + (line_size - indicator_size[1]) / 2) |
1934 dc.DrawText(action["indicator"], indicator_pos[0], indicator_pos[1]) |
1934 dc.DrawText(action["indicator"], indicator_pos[0], indicator_pos[1]) |
1935 if i in self.Errors: |
1935 if i in self.Errors: |
1936 if "duration" in self.Errors[i] and "duration" in action: |
1936 if self.Errors[i].has_key("duration") and action.has_key("duration"): |
1937 HighlightErrorZone(dc, duration_pos[0], duration_pos[1], duration_size[0], duration_size[1]) |
1937 HighlightErrorZone(dc, duration_pos[0], duration_pos[1], duration_size[0], duration_size[1]) |
1938 if "qualifier" in self.Errors[i]: |
1938 if self.Errors[i].has_key("qualifier"): |
1939 HighlightErrorZone(dc, qualifier_pos[0], qualifier_pos[1], qualifier_size[0], qualifier_size[1]) |
1939 HighlightErrorZone(dc, qualifier_pos[0], qualifier_pos[1], qualifier_size[0], qualifier_size[1]) |
1940 if "reference" in self.Errors[i]: |
1940 if self.Errors[i].has_key("reference"): |
1941 HighlightErrorZone(dc, content_pos[0], content_pos[1], content_size[0], content_size[1]) |
1941 HighlightErrorZone(dc, content_pos[0], content_pos[1], content_size[0], content_size[1]) |
1942 elif "inline" in self.Errors[i]: |
1942 elif self.Errors[i].has_key("inline"): |
1943 for start, end in self.Errors[i]["inline"]: |
1943 for start, end in self.Errors[i]["inline"]: |
1944 offset = dc.GetTextExtent(action["value"][:start]) |
1944 offset = dc.GetTextExtent(action["value"][:start]) |
1945 size = dc.GetTextExtent(action["value"][start:end + 1]) |
1945 size = dc.GetTextExtent(action["value"][start:end + 1]) |
1946 HighlightErrorZone(dc, content_pos[0] + offset[0], content_pos[1], size[0], size[1]) |
1946 HighlightErrorZone(dc, content_pos[0] + offset[0], content_pos[1], size[0], size[1]) |
1947 if "indicator" in self.Errors[i]: |
1947 if self.Errors[i].has_key("indicator"): |
1948 HighlightErrorZone(dc, indicator_pos[0], indicator_pos[1], indicator_size[0], indicator_size[1]) |
1948 HighlightErrorZone(dc, indicator_pos[0], indicator_pos[1], indicator_size[0], indicator_size[1]) |
1949 # Draw input connector |
1949 # Draw input connector |
1950 self.Input.Draw(dc) |
1950 self.Input.Draw(dc) |
1951 |
1951 |