You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
4.0 KiB
109 lines
4.0 KiB
from PyQt5.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QLabel,
|
|
QPushButton, QGroupBox, QFormLayout, QProgressBar,
|
|
QSpinBox, QDoubleSpinBox)
|
|
from PyQt5.QtCore import Qt, QTimer
|
|
|
|
class PathSimulationView(QWidget):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.init_ui()
|
|
self.simulation_timer = QTimer()
|
|
self.simulation_timer.timeout.connect(self.update_simulation)
|
|
self.simulation_progress = 0
|
|
|
|
def init_ui(self):
|
|
# 创建主布局
|
|
main_layout = QVBoxLayout()
|
|
|
|
# 创建模拟控制组
|
|
control_group = QGroupBox("模拟控制")
|
|
control_layout = QFormLayout()
|
|
|
|
self.speed_spinbox = QDoubleSpinBox()
|
|
self.speed_spinbox.setRange(0.1, 10.0)
|
|
self.speed_spinbox.setValue(1.0)
|
|
self.speed_spinbox.setSingleStep(0.1)
|
|
|
|
self.interval_spinbox = QSpinBox()
|
|
self.interval_spinbox.setRange(10, 1000)
|
|
self.interval_spinbox.setValue(100)
|
|
self.interval_spinbox.setSingleStep(10)
|
|
|
|
control_layout.addRow("模拟速度:", self.speed_spinbox)
|
|
control_layout.addRow("更新间隔(ms):", self.interval_spinbox)
|
|
|
|
control_group.setLayout(control_layout)
|
|
main_layout.addWidget(control_group)
|
|
|
|
# 创建模拟进度条
|
|
self.progress_bar = QProgressBar()
|
|
self.progress_bar.setRange(0, 100)
|
|
self.progress_bar.setValue(0)
|
|
main_layout.addWidget(self.progress_bar)
|
|
|
|
# 创建控制按钮
|
|
button_layout = QHBoxLayout()
|
|
self.start_btn = QPushButton("开始模拟")
|
|
self.pause_btn = QPushButton("暂停")
|
|
self.stop_btn = QPushButton("停止")
|
|
self.reset_btn = QPushButton("重置")
|
|
|
|
button_layout.addWidget(self.start_btn)
|
|
button_layout.addWidget(self.pause_btn)
|
|
button_layout.addWidget(self.stop_btn)
|
|
button_layout.addWidget(self.reset_btn)
|
|
|
|
main_layout.addLayout(button_layout)
|
|
|
|
# 创建状态显示组
|
|
status_group = QGroupBox("模拟状态")
|
|
status_layout = QFormLayout()
|
|
|
|
self.time_label = QLabel("0.0s")
|
|
self.distance_label = QLabel("0.0m")
|
|
self.altitude_label = QLabel("0.0m")
|
|
self.speed_label = QLabel("0.0m/s")
|
|
|
|
status_layout.addRow("已用时间:", self.time_label)
|
|
status_layout.addRow("飞行距离:", self.distance_label)
|
|
status_layout.addRow("当前高度:", self.altitude_label)
|
|
status_layout.addRow("当前速度:", self.speed_label)
|
|
|
|
status_group.setLayout(status_layout)
|
|
main_layout.addWidget(status_group)
|
|
|
|
self.setLayout(main_layout)
|
|
|
|
# 连接信号
|
|
self.start_btn.clicked.connect(self.start_simulation)
|
|
self.pause_btn.clicked.connect(self.pause_simulation)
|
|
self.stop_btn.clicked.connect(self.stop_simulation)
|
|
self.reset_btn.clicked.connect(self.reset_simulation)
|
|
|
|
def start_simulation(self):
|
|
self.simulation_timer.start(self.interval_spinbox.value())
|
|
|
|
def pause_simulation(self):
|
|
self.simulation_timer.stop()
|
|
|
|
def stop_simulation(self):
|
|
self.simulation_timer.stop()
|
|
self.simulation_progress = 0
|
|
self.progress_bar.setValue(0)
|
|
|
|
def reset_simulation(self):
|
|
self.simulation_progress = 0
|
|
self.progress_bar.setValue(0)
|
|
self.time_label.setText("0.0s")
|
|
self.distance_label.setText("0.0m")
|
|
self.altitude_label.setText("0.0m")
|
|
self.speed_label.setText("0.0m/s")
|
|
|
|
def update_simulation(self):
|
|
# TODO: 实现模拟更新逻辑
|
|
self.simulation_progress += self.speed_spinbox.value()
|
|
if self.simulation_progress > 100:
|
|
self.simulation_progress = 100
|
|
self.simulation_timer.stop()
|
|
|
|
self.progress_bar.setValue(int(self.simulation_progress)) |