fix scale between ppi_display and main_view
This commit is contained in:
parent
7a9c530f25
commit
8eaa604a7d
@ -146,28 +146,52 @@ class PPIDisplay(ttk.Frame):
|
|||||||
self.canvas.draw()
|
self.canvas.draw()
|
||||||
|
|
||||||
def draw_trajectory_preview(self, initial_state: dict, waypoints: List[Waypoint]):
|
def draw_trajectory_preview(self, initial_state: dict, waypoints: List[Waypoint]):
|
||||||
# (This method is unchanged)
|
"""Simulates and draws a trajectory preview without auto-zooming."""
|
||||||
self.clear_previews()
|
self.clear_previews()
|
||||||
if not waypoints: self.canvas.draw(); return
|
|
||||||
|
# --- NUOVA LOGICA ---
|
||||||
|
# Assicura che l'asse Y sia sincronizzato con la combobox prima di disegnare.
|
||||||
|
self._on_range_selected()
|
||||||
|
|
||||||
|
if not waypoints:
|
||||||
|
# Disegna solo il punto di partenza se non ci sono waypoint
|
||||||
|
start_r, start_theta = initial_state['initial_range_nm'], math.radians(initial_state['initial_azimuth_deg'])
|
||||||
|
self._start_plot.set_data([start_theta], [start_r])
|
||||||
|
self.canvas.draw()
|
||||||
|
return
|
||||||
|
|
||||||
temp_target = Target(target_id=0, **initial_state, trajectory=copy.deepcopy(waypoints))
|
temp_target = Target(target_id=0, **initial_state, trajectory=copy.deepcopy(waypoints))
|
||||||
path_thetas, path_rs = [], []; wp_thetas, wp_rs = [], []
|
|
||||||
|
path_thetas, path_rs = [], []
|
||||||
|
wp_thetas, wp_rs = [], []
|
||||||
|
|
||||||
total_duration = sum(wp.duration_s for wp in waypoints)
|
total_duration = sum(wp.duration_s for wp in waypoints)
|
||||||
sim_time, time_step = 0.0, 0.5
|
sim_time, time_step = 0.0, 0.5
|
||||||
path_thetas.append(math.radians(temp_target.current_azimuth_deg)); path_rs.append(temp_target.current_range_nm)
|
|
||||||
|
path_thetas.append(math.radians(temp_target.current_azimuth_deg))
|
||||||
|
path_rs.append(temp_target.current_range_nm)
|
||||||
|
|
||||||
while sim_time < total_duration:
|
while sim_time < total_duration:
|
||||||
wp_index_before = temp_target._current_waypoint_index
|
wp_index_before = temp_target._current_waypoint_index
|
||||||
temp_target.update_state(time_step)
|
temp_target.update_state(time_step)
|
||||||
path_thetas.append(math.radians(temp_target.current_azimuth_deg)); path_rs.append(temp_target.current_range_nm)
|
path_thetas.append(math.radians(temp_target.current_azimuth_deg))
|
||||||
|
path_rs.append(temp_target.current_range_nm)
|
||||||
|
|
||||||
if temp_target._current_waypoint_index > wp_index_before:
|
if temp_target._current_waypoint_index > wp_index_before:
|
||||||
wp_thetas.append(path_thetas[-2]); wp_rs.append(path_rs[-2])
|
wp_thetas.append(path_thetas[-2])
|
||||||
|
wp_rs.append(path_rs[-2])
|
||||||
sim_time += time_step
|
sim_time += time_step
|
||||||
|
|
||||||
start_r, start_theta = initial_state['initial_range_nm'], math.radians(initial_state['initial_azimuth_deg'])
|
start_r, start_theta = initial_state['initial_range_nm'], math.radians(initial_state['initial_azimuth_deg'])
|
||||||
self._start_plot.set_data([start_theta], [start_r])
|
self._start_plot.set_data([start_theta], [start_r])
|
||||||
self._waypoints_plot.set_data(wp_thetas, wp_rs)
|
self._waypoints_plot.set_data(wp_thetas, wp_rs)
|
||||||
self._path_plot.set_data(path_thetas, path_rs)
|
self._path_plot.set_data(path_thetas, path_rs)
|
||||||
max_r = max(path_rs) if path_rs else start_r
|
|
||||||
self.ax.set_ylim(0, max_r * 1.1)
|
# --- LOGICA DI AUTO-ZOOM RIMOSSA ---
|
||||||
self._update_scan_lines() # Also update scan lines to fit preview if it zooms out
|
# max_r = max(path_rs) if path_rs else start_r
|
||||||
|
# self.ax.set_ylim(0, max_r * 1.1)
|
||||||
|
|
||||||
|
self._update_scan_lines()
|
||||||
self.canvas.draw()
|
self.canvas.draw()
|
||||||
|
|
||||||
def clear_previews(self):
|
def clear_previews(self):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user