added methods for interactive mode
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from typing import Optional
|
||||
|
||||
import pygame
|
||||
|
||||
from gps_loader import GPSLoader
|
||||
@@ -23,6 +25,8 @@ class SpeedMapDisplay(MapDisplay):
|
||||
self.max_speed_col: tuple[int, int, int] = max_speed_col
|
||||
self.segment_threshold: float = segment_threshold
|
||||
|
||||
self._path: Optional[Path] = None
|
||||
|
||||
def draw_path(self, path: Path) -> None:
|
||||
min_speed = min(path.extra_data)
|
||||
max_speed = max(path.extra_data)
|
||||
@@ -55,6 +59,16 @@ class SpeedMapDisplay(MapDisplay):
|
||||
|
||||
return r, g, b
|
||||
|
||||
def render(self) -> None:
|
||||
self.surf.fill((0, 0, 0))
|
||||
self.draw_cities()
|
||||
|
||||
if self._path is not None:
|
||||
self.draw_path(self._path)
|
||||
|
||||
def set_path(self, path: Path) -> None:
|
||||
self._path = path
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
name = "data_28-03"
|
||||
@@ -78,6 +92,6 @@ if __name__ == '__main__':
|
||||
cities,
|
||||
(255, 0, 0), (0, 255, 0), 155)
|
||||
|
||||
display.draw_path(path)
|
||||
pygame.display.flip()
|
||||
input()
|
||||
display.set_path(path)
|
||||
|
||||
display.mainloop()
|
||||
|
||||
Reference in New Issue
Block a user