Skip to content

Commit 569ca84

Browse files
committed
#187 Minor refactoring of Track Painter
1 parent 9b5e4dc commit 569ca84

File tree

3 files changed

+73
-73
lines changed

3 files changed

+73
-73
lines changed

src/ui/track_painter.py src/graphics/track_painter.py

+69-68
Original file line numberDiff line numberDiff line change
@@ -7,106 +7,107 @@
77

88
class TrackPainter:
99
def __init__(self):
10-
self.track_colour = Colours.TRACK_GREY
10+
self._track_colour = Colours.TRACK_GREY
1111

12-
self.waypoint_major_size = 0
13-
self.waypoint_minor_size = 0
12+
self._waypoint_major_size = 0
13+
self._waypoint_minor_size = 0
1414

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
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
2020

21-
self.drawing_order = [ "G", "A", "T", "N" ]
21+
self._drawing_order = ["G", "A", "T", "N"]
2222

2323
self.set_track_colour_grey()
2424
self.set_waypoint_sizes_micro()
2525

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
26+
# Moves elsewhere
27+
# self.zoom_x = None
28+
# self.zoom_y = None
29+
# self.zoom_x2 = None
30+
# self.zoom_y2 = None
31+
#
32+
# self.zoom_in = False
3233

3334
def set_track_colour_grey(self):
34-
self.track_colour = Colours.TRACK_GREY
35+
self._track_colour = Colours.TRACK_GREY
3536

3637
def set_track_colour_blue(self):
37-
self.track_colour = Colours.TRACK_BLUE
38+
self._track_colour = Colours.TRACK_BLUE
3839

3940
def set_waypoint_sizes_large(self):
40-
self.waypoint_minor_size = 5
41-
self.waypoint_major_size = 9
42-
self.waypoints_on = True
41+
self._waypoint_minor_size = 5
42+
self._waypoint_major_size = 9
43+
self._waypoints_on = True
4344

4445
def set_waypoint_sizes_small(self):
45-
self.waypoint_minor_size = 3
46-
self.waypoint_major_size = 5
47-
self.waypoints_on = True
46+
self._waypoint_minor_size = 3
47+
self._waypoint_major_size = 5
48+
self._waypoints_on = True
4849

4950
def set_waypoint_sizes_micro(self):
50-
self.waypoint_minor_size = 2
51-
self.waypoint_major_size = 3
52-
self.waypoints_on = True
51+
self._waypoint_minor_size = 2
52+
self._waypoint_major_size = 3
53+
self._waypoints_on = True
5354

5455
def set_waypoints_off(self):
55-
self.waypoints_on = False
56+
self._waypoints_on = False
5657

5758
def set_waypoint_labels_on(self):
58-
self.waypoint_labels_on = True
59+
self._waypoint_labels_on = True
5960

6061
def set_waypoint_labels_off(self):
61-
self.waypoint_labels_on = False
62+
self._waypoint_labels_on = False
6263

6364
def set_grid_front(self):
64-
self.grid_on = True
65-
self.drawing_order.remove("G")
66-
self.drawing_order.append("G")
65+
self._grid_on = True
66+
self._drawing_order.remove("G")
67+
self._drawing_order.append("G")
6768

6869
def set_grid_back(self):
69-
self.grid_on = True
70-
self.drawing_order.remove("G")
71-
self.drawing_order.insert(0, "G")
70+
self._grid_on = True
71+
self._drawing_order.remove("G")
72+
self._drawing_order.insert(0, "G")
7273

7374
def set_grid_off(self):
74-
self.grid_on = False
75+
self._grid_on = False
7576

7677
def set_track_front(self):
77-
self.drawing_order.remove("T")
78-
self.drawing_order.append("T")
78+
self._drawing_order.remove("T")
79+
self._drawing_order.append("T")
7980

8081
def set_track_back(self):
81-
self.drawing_order.remove("T")
82-
self.drawing_order.insert(0, "T")
82+
self._drawing_order.remove("T")
83+
self._drawing_order.insert(0, "T")
8384

8485
def set_analyze_front(self):
85-
self.drawing_order.remove("A")
86-
self.drawing_order.append("A")
86+
self._drawing_order.remove("A")
87+
self._drawing_order.append("A")
8788

8889
def set_analyze_back(self):
89-
self.drawing_order.remove("A")
90-
self.drawing_order.insert(0, "A")
90+
self._drawing_order.remove("A")
91+
self._drawing_order.insert(0, "A")
9192

9293
def set_annotations_front(self):
93-
self.annotations_on = True
94-
self.drawing_order.remove("N")
95-
self.drawing_order.append("N")
94+
self._annotations_on = True
95+
self._drawing_order.remove("N")
96+
self._drawing_order.append("N")
9697

9798
def set_annotations_back(self):
98-
self.annotations_on = True
99-
self.drawing_order.remove("N")
100-
self.drawing_order.insert(0, "N")
99+
self._annotations_on = True
100+
self._drawing_order.remove("N")
101+
self._drawing_order.insert(0, "N")
101102

102103
def set_annotations_off(self):
103-
self.annotations_on = False
104+
self._annotations_on = False
104105

105106
def set_sectors_on(self):
106-
self.sectors_on = True
107+
self._sectors_on = True
107108

108109
def set_sectors_off(self):
109-
self.sectors_on = False
110+
self._sectors_on = False
110111

111112
def draw(self, track_canvas: TrackAnalysisCanvas, current_track: Track, episode_filter: EpisodeFilter):
112113
# analyzer.recalculate()
@@ -120,32 +121,32 @@ def draw(self, track_canvas: TrackAnalysisCanvas, current_track: Track, episode_
120121
# else:
121122
# current_track.configure_track_graphics(track_graphics)
122123

123-
for do in self.drawing_order:
124-
if do == "G" and self.grid_on:
124+
for do in self._drawing_order:
125+
if do == "G" and self._grid_on:
125126
current_track.draw_grid(track_canvas, Colours.GRID_GREY)
126127

127128
if do == "T":
128-
current_track.draw_track_edges(track_canvas, self.track_colour)
129+
current_track.draw_track_edges(track_canvas, self._track_colour)
129130
if episode_filter.filter_complete_section:
130131
(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)
132+
current_track.draw_section_highlight(track_canvas, self._track_colour, start, finish)
133+
134+
current_track.draw_starting_line(track_canvas, self._track_colour)
135+
if self._sectors_on:
136+
current_track.draw_sector_dividers(track_canvas, self._track_colour)
137+
current_track.draw_sector_labels(track_canvas, self._track_colour)
138+
if self._waypoints_on:
139+
current_track.draw_waypoints(track_canvas, self._track_colour, self._waypoint_minor_size,
140+
self._waypoint_major_size)
141+
if self._waypoint_labels_on:
142+
current_track.draw_waypoint_labels(track_canvas, self._track_colour, 9)
142143

143144
# if do == "A":
144145
# if background_analyser:
145146
# background_analyser.redraw()
146147
# analyzer.redraw()
147148

148-
if do == "N" and self.annotations_on:
149+
if do == "N" and self._annotations_on:
149150
current_track.draw_annotations(track_canvas)
150151

151152
# def zoom_set(self, track_graphics, x, y, x2, y2):

src/main/guru.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import sys
22

33
from PyQt6.QtCore import Qt
4-
from PyQt6.QtGui import QColor
5-
from PyQt6.QtWidgets import QMainWindow, QApplication, QProgressBar, QFileDialog, QVBoxLayout, QLabel, QHBoxLayout
4+
from PyQt6.QtWidgets import QMainWindow, QApplication, QProgressBar, QFileDialog, QLabel, QHBoxLayout
65

76
from src.log.log import Log
87
from src.configuration.config_manager import ConfigManager
@@ -14,7 +13,7 @@
1413
from src.tracks.tracks import get_all_tracks
1514
from src.ui.open_file_dialog import OpenFileDialog
1615
from ui.icons import get_custom_icon
17-
from ui.track_painter import TrackPainter
16+
from graphics.track_painter import TrackPainter
1817

1918

2019
class MainWindow(QMainWindow):

src/tracks/track.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ def draw_waypoint_labels(self, track_canvas: TrackAnalysisCanvas, colour: QColor
184184
# else:
185185
# last_label_position = label_position
186186

187-
def draw_annotations(self, track_graphics: TrackGraphics):
187+
def draw_annotations(self, track_canvas: TrackAnalysisCanvas):
188188
for a in self._annotations:
189-
a.draw(track_graphics, self._drawing_points, self._track_width)
189+
a.draw(track_canvas, self._drawing_points, self._track_width)
190190

191191
def draw_grid(self, track_canvas: TrackAnalysisCanvas, colour: QColor):
192192
x = self._min_x

0 commit comments

Comments
 (0)