|
| 1 | +from episode.episode_filter import EpisodeFilter |
| 2 | +from graphics.track_analysis_canvas import TrackAnalysisCanvas |
| 3 | +from tracks.track import Track |
| 4 | +from ui.colours import Colours |
| 5 | + |
| 6 | +SECTOR_BORDER = 0.2 |
| 7 | + |
| 8 | +class TrackPainter: |
| 9 | + def __init__(self): |
| 10 | + self.track_colour = Colours.TRACK_GREY |
| 11 | + |
| 12 | + self.waypoint_major_size = 0 |
| 13 | + self.waypoint_minor_size = 0 |
| 14 | + |
| 15 | + self.waypoints_on = True |
| 16 | + self.waypoint_labels_on = False |
| 17 | + self.grid_on = False |
| 18 | + self.annotations_on = False |
| 19 | + self.sectors_on = False |
| 20 | + |
| 21 | + self.drawing_order = [ "G", "A", "T", "N" ] |
| 22 | + |
| 23 | + self.set_track_colour_grey() |
| 24 | + self.set_waypoint_sizes_micro() |
| 25 | + |
| 26 | + self.zoom_x = None |
| 27 | + self.zoom_y = None |
| 28 | + self.zoom_x2 = None |
| 29 | + self.zoom_y2 = None |
| 30 | + |
| 31 | + self.zoom_in = False |
| 32 | + |
| 33 | + def set_track_colour_grey(self): |
| 34 | + self.track_colour = Colours.TRACK_GREY |
| 35 | + |
| 36 | + def set_track_colour_blue(self): |
| 37 | + self.track_colour = Colours.TRACK_BLUE |
| 38 | + |
| 39 | + def set_waypoint_sizes_large(self): |
| 40 | + self.waypoint_minor_size = 5 |
| 41 | + self.waypoint_major_size = 9 |
| 42 | + self.waypoints_on = True |
| 43 | + |
| 44 | + def set_waypoint_sizes_small(self): |
| 45 | + self.waypoint_minor_size = 3 |
| 46 | + self.waypoint_major_size = 5 |
| 47 | + self.waypoints_on = True |
| 48 | + |
| 49 | + def set_waypoint_sizes_micro(self): |
| 50 | + self.waypoint_minor_size = 2 |
| 51 | + self.waypoint_major_size = 3 |
| 52 | + self.waypoints_on = True |
| 53 | + |
| 54 | + def set_waypoints_off(self): |
| 55 | + self.waypoints_on = False |
| 56 | + |
| 57 | + def set_waypoint_labels_on(self): |
| 58 | + self.waypoint_labels_on = True |
| 59 | + |
| 60 | + def set_waypoint_labels_off(self): |
| 61 | + self.waypoint_labels_on = False |
| 62 | + |
| 63 | + def set_grid_front(self): |
| 64 | + self.grid_on = True |
| 65 | + self.drawing_order.remove("G") |
| 66 | + self.drawing_order.append("G") |
| 67 | + |
| 68 | + def set_grid_back(self): |
| 69 | + self.grid_on = True |
| 70 | + self.drawing_order.remove("G") |
| 71 | + self.drawing_order.insert(0, "G") |
| 72 | + |
| 73 | + def set_grid_off(self): |
| 74 | + self.grid_on = False |
| 75 | + |
| 76 | + def set_track_front(self): |
| 77 | + self.drawing_order.remove("T") |
| 78 | + self.drawing_order.append("T") |
| 79 | + |
| 80 | + def set_track_back(self): |
| 81 | + self.drawing_order.remove("T") |
| 82 | + self.drawing_order.insert(0, "T") |
| 83 | + |
| 84 | + def set_analyze_front(self): |
| 85 | + self.drawing_order.remove("A") |
| 86 | + self.drawing_order.append("A") |
| 87 | + |
| 88 | + def set_analyze_back(self): |
| 89 | + self.drawing_order.remove("A") |
| 90 | + self.drawing_order.insert(0, "A") |
| 91 | + |
| 92 | + def set_annotations_front(self): |
| 93 | + self.annotations_on = True |
| 94 | + self.drawing_order.remove("N") |
| 95 | + self.drawing_order.append("N") |
| 96 | + |
| 97 | + def set_annotations_back(self): |
| 98 | + self.annotations_on = True |
| 99 | + self.drawing_order.remove("N") |
| 100 | + self.drawing_order.insert(0, "N") |
| 101 | + |
| 102 | + def set_annotations_off(self): |
| 103 | + self.annotations_on = False |
| 104 | + |
| 105 | + def set_sectors_on(self): |
| 106 | + self.sectors_on = True |
| 107 | + |
| 108 | + def set_sectors_off(self): |
| 109 | + self.sectors_on = False |
| 110 | + |
| 111 | + def draw(self, track_canvas: TrackAnalysisCanvas, current_track: Track, episode_filter: EpisodeFilter): |
| 112 | + # analyzer.recalculate() |
| 113 | + # if background_analyser: |
| 114 | + # background_analyser.recalculate() |
| 115 | + # |
| 116 | + # track_graphics.reset_to_blank() |
| 117 | + # |
| 118 | + # if self.zoom_in and self.zoom_x: |
| 119 | + # track_graphics.set_track_area(self.zoom_x, self.zoom_y, self.zoom_x2, self.zoom_y2) |
| 120 | + # else: |
| 121 | + # current_track.configure_track_graphics(track_graphics) |
| 122 | + |
| 123 | + for do in self.drawing_order: |
| 124 | + if do == "G" and self.grid_on: |
| 125 | + current_track.draw_grid(track_canvas, Colours.GRID_GREY) |
| 126 | + |
| 127 | + if do == "T": |
| 128 | + current_track.draw_track_edges(track_canvas, self.track_colour) |
| 129 | + if episode_filter.filter_complete_section: |
| 130 | + (start, finish) = episode_filter.filter_complete_section |
| 131 | + current_track.draw_section_highlight(track_canvas, self.track_colour, start, finish) |
| 132 | + |
| 133 | + current_track.draw_starting_line(track_canvas, self.track_colour) |
| 134 | + if self.sectors_on: |
| 135 | + current_track.draw_sector_dividers(track_canvas, self.track_colour) |
| 136 | + current_track.draw_sector_labels(track_canvas, self.track_colour) |
| 137 | + if self.waypoints_on: |
| 138 | + current_track.draw_waypoints(track_canvas, self.track_colour, self.waypoint_minor_size, |
| 139 | + self.waypoint_major_size) |
| 140 | + if self.waypoint_labels_on: |
| 141 | + current_track.draw_waypoint_labels(track_canvas, self.track_colour, 9) |
| 142 | + |
| 143 | + # if do == "A": |
| 144 | + # if background_analyser: |
| 145 | + # background_analyser.redraw() |
| 146 | + # analyzer.redraw() |
| 147 | + |
| 148 | + if do == "N" and self.annotations_on: |
| 149 | + current_track.draw_annotations(track_canvas) |
| 150 | + |
| 151 | + # def zoom_set(self, track_graphics, x, y, x2, y2): |
| 152 | + # real_x, real_y = track_graphics.get_real_point_for_widget_location(x, y) |
| 153 | + # real_x2, real_y2 = track_graphics.get_real_point_for_widget_location(x2, y2) |
| 154 | + # |
| 155 | + # self.zoom_x = min(real_x, real_x2) |
| 156 | + # self.zoom_x2 = max(real_x, real_x2) |
| 157 | + # self.zoom_y = min(real_y, real_y2) |
| 158 | + # self.zoom_y2 = max(real_y, real_y2) |
| 159 | + # |
| 160 | + # self.zoom_in = True |
| 161 | + # |
| 162 | + # def zoom_sector(self, track: Track, sector: str): |
| 163 | + # (self.zoom_x, self.zoom_y, self.zoom_x2, self.zoom_y2) = track.get_sector_coordinates(sector) |
| 164 | + # self.zoom_x -= SECTOR_BORDER |
| 165 | + # self.zoom_y -= SECTOR_BORDER |
| 166 | + # self.zoom_x2 += SECTOR_BORDER |
| 167 | + # self.zoom_y2 += SECTOR_BORDER |
| 168 | + # self.zoom_in = True |
| 169 | + # |
| 170 | + # def zoom_toggle(self): |
| 171 | + # self.zoom_in = not self.zoom_in |
| 172 | + # |
| 173 | + # def zoom_clear(self): |
| 174 | + # self.zoom_x = None |
| 175 | + # self.zoom_y = None |
| 176 | + # self.zoom_x2 = None |
| 177 | + # self.zoom_y2 = None |
| 178 | + # |
| 179 | + # self.zoom_in = False |
0 commit comments