diff --git a/settings.json b/settings.json index a2d0f59..a17fc3e 100644 --- a/settings.json +++ b/settings.json @@ -3,7 +3,7 @@ "scan_limit": 60, "max_range": 100, "geometry": "1200x1024+463+195", - "last_selected_scenario": "scenario2", + "last_selected_scenario": "scenario3", "connection": { "target": { "type": "tftp", @@ -153,6 +153,28 @@ "use_spline": true } ] + }, + "scenario3": { + "name": "scenario3", + "targets": [ + { + "target_id": 0, + "active": true, + "traceable": true, + "trajectory": [ + { + "maneuver_type": "Fly to Point", + "target_velocity_fps": 506.343, + "target_heading_deg": 180.0, + "duration_s": 10.0, + "target_altitude_ft": 10000.0, + "target_range_nm": 20.0, + "target_azimuth_deg": 0.0 + } + ], + "use_spline": false + } + ] } } } \ No newline at end of file diff --git a/target_simulator/gui/ppi_display.py b/target_simulator/gui/ppi_display.py index f95d7ae..e6502a9 100644 --- a/target_simulator/gui/ppi_display.py +++ b/target_simulator/gui/ppi_display.py @@ -166,6 +166,16 @@ class PPIDisplay(ttk.Frame): self._start_plot.set_data([], []) if hasattr(self, '_preview_artist'): self._preview_artist.set_data([], []) + # Rimuovi eventuali artisti extra creati manualmente (puntini/linee) + if hasattr(self, '_preview_extra_artists'): + for a in self._preview_extra_artists: + try: + a.remove() + except Exception: + pass + self._preview_extra_artists.clear() + else: + self._preview_extra_artists = [] # Forza la pulizia della canvas self.canvas.draw() self._on_range_selected() @@ -185,10 +195,28 @@ class PPIDisplay(ttk.Frame): thetas = [math.radians(getattr(wp, 'target_azimuth_deg', 0)) for wp in waypoints] rs = [getattr(wp, 'target_range_nm', 0) for wp in waypoints] if len(thetas) == 1: - # Mostra solo il punto iniziale + # Mostra solo il punto iniziale con stile simulazione self._preview_artist.set_data([], []) - self._waypoints_plot.set_data(thetas, rs) - self._start_plot.set_data(thetas, rs) + self._waypoints_plot.set_data([], []) + self._start_plot.set_data([], []) + wp0 = waypoints[0] + start_theta = thetas[0] + start_r = rs[0] + self._preview_extra_artists = [] + # Puntino rosso + dot, = self.ax.plot([start_theta], [start_r], 'o', markersize=5, color='red') + self._preview_extra_artists.append(dot) + # Linea di heading corta + heading_deg = getattr(wp0, 'target_heading_deg', None) + if heading_deg is not None: + h_rad = math.radians(heading_deg) + vector_len = self.max_range / 25 + x1, y1 = start_r * math.sin(start_theta), start_r * math.cos(start_theta) + dx, dy = vector_len * math.sin(h_rad), vector_len * math.cos(h_rad) + x2, y2 = x1 + dx, y1 + dy + r2, th2 = math.sqrt(x2**2 + y2**2), math.atan2(x2, y2) + line, = self.ax.plot([start_theta, th2], [start_r, r2], color='red', linewidth=1.2) + self._preview_extra_artists.append(line) self.canvas.draw() return if len(thetas) < 2: diff --git a/target_simulator/gui/waypoint_editor_window.py b/target_simulator/gui/waypoint_editor_window.py index 68bf374..fa65313 100644 --- a/target_simulator/gui/waypoint_editor_window.py +++ b/target_simulator/gui/waypoint_editor_window.py @@ -148,6 +148,8 @@ class WaypointEditorWindow(tk.Toplevel): wp.target_azimuth_deg = self.t_az_var.get() wp.target_altitude_ft = self.t_alt_var.get() wp.duration_s = self.duration_var.get() + wp.target_velocity_fps = self.t_vel_var.get() * KNOTS_TO_FPS + wp.target_heading_deg = self.t_hdg_var.get() elif m_type == ManeuverType.FLY_FOR_DURATION: wp.duration_s = self.duration_var.get() wp.target_velocity_fps = self.t_vel_var.get() * KNOTS_TO_FPS