Skip to content
Snippets Groups Projects
Commit cf339625 authored by Kien Le's avatar Kien Le
Browse files

Implement showing gps data when clicking on point

parent 4c24c103
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@ class GPSWidget(QtWidgets.QWidget):
def __init__(self, parent, tracking_box):
super().__init__(parent)
self.tracking_box = tracking_box
self.gps_points = None
self.gps_points: List[GPSPoint] = None
self.fig = Figure(figsize=(6, 6), dpi=100)
self.canvas = Canvas(self.fig)
......@@ -67,6 +67,27 @@ class GPSWidget(QtWidgets.QWidget):
msg = f'Plotted {len(self.gps_points)} points.'
displayTrackingInfo(self.tracking_box, msg)
def on_pick_event(self, event):
artist = event.artist
if isinstance(artist, plt.Line2D):
# index of the clicked point on the plot
click_plot_index = event.ind[0]
picked_point = self.gps_points[click_plot_index]
lat_dir = 'N' if picked_point.latitude > 0 else 'S'
long_dir = 'E' if picked_point.longitude > 0 else 'W'
meta_separator = ' ' * 22
loc_separator = ' ' * 10
msg = (
f'Mark: {picked_point.last_timemark}{meta_separator}'
f'Fix: {picked_point.fix_type}{meta_separator}'
f'Sats: {picked_point.num_satellite_used}<br>'
f'Lat: {lat_dir}{picked_point.latitude:.6f}{loc_separator}'
f'Long: {long_dir}{picked_point.longitude:.6f}{loc_separator}'
f'Elev: {picked_point.height}{picked_point.height_unit}'
)
displayTrackingInfo(self.tracking_box, msg)
class GPSDialog(QtWidgets.QWidget):
def __init__(self, parent=None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment