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.
105 lines
3.8 KiB
105 lines
3.8 KiB
from PyQt5.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QLabel,
|
|
QPushButton, QGroupBox, QFormLayout, QComboBox,
|
|
QSpinBox, QDoubleSpinBox, QCheckBox, QMessageBox)
|
|
from PyQt5.QtCore import Qt
|
|
|
|
class AlgorithmConfigView(QWidget):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.init_ui()
|
|
|
|
def init_ui(self):
|
|
# 创建主布局
|
|
main_layout = QVBoxLayout()
|
|
|
|
# 创建A*算法配置组
|
|
astar_group = QGroupBox("A*算法配置")
|
|
astar_layout = QFormLayout()
|
|
|
|
self.astar_heuristic = QComboBox()
|
|
self.astar_heuristic.addItems(["欧几里得距离", "曼哈顿距离", "对角线距离"])
|
|
|
|
self.astar_weight = QDoubleSpinBox()
|
|
self.astar_weight.setRange(0.1, 10.0)
|
|
self.astar_weight.setValue(1.0)
|
|
self.astar_weight.setSingleStep(0.1)
|
|
|
|
astar_layout.addRow("启发函数:", self.astar_heuristic)
|
|
astar_layout.addRow("权重:", self.astar_weight)
|
|
|
|
astar_group.setLayout(astar_layout)
|
|
main_layout.addWidget(astar_group)
|
|
|
|
# 创建遗传算法配置组
|
|
ga_group = QGroupBox("遗传算法配置")
|
|
ga_layout = QFormLayout()
|
|
|
|
self.ga_population = QSpinBox()
|
|
self.ga_population.setRange(10, 1000)
|
|
self.ga_population.setValue(100)
|
|
|
|
self.ga_generations = QSpinBox()
|
|
self.ga_generations.setRange(10, 1000)
|
|
self.ga_generations.setValue(100)
|
|
|
|
self.ga_mutation_rate = QDoubleSpinBox()
|
|
self.ga_mutation_rate.setRange(0.01, 1.0)
|
|
self.ga_mutation_rate.setValue(0.1)
|
|
self.ga_mutation_rate.setSingleStep(0.01)
|
|
|
|
ga_layout.addRow("种群大小:", self.ga_population)
|
|
ga_layout.addRow("迭代次数:", self.ga_generations)
|
|
ga_layout.addRow("变异率:", self.ga_mutation_rate)
|
|
|
|
ga_group.setLayout(ga_layout)
|
|
main_layout.addWidget(ga_group)
|
|
|
|
# 创建RRT算法配置组
|
|
rrt_group = QGroupBox("RRT算法配置")
|
|
rrt_layout = QFormLayout()
|
|
|
|
self.rrt_step_size = QDoubleSpinBox()
|
|
self.rrt_step_size.setRange(0.1, 10.0)
|
|
self.rrt_step_size.setValue(1.0)
|
|
self.rrt_step_size.setSingleStep(0.1)
|
|
|
|
self.rrt_goal_bias = QDoubleSpinBox()
|
|
self.rrt_goal_bias.setRange(0.0, 1.0)
|
|
self.rrt_goal_bias.setValue(0.1)
|
|
self.rrt_goal_bias.setSingleStep(0.01)
|
|
|
|
self.rrt_smooth_path = QCheckBox("平滑路径")
|
|
self.rrt_smooth_path.setChecked(True)
|
|
|
|
rrt_layout.addRow("步长:", self.rrt_step_size)
|
|
rrt_layout.addRow("目标偏向:", self.rrt_goal_bias)
|
|
rrt_layout.addRow("", self.rrt_smooth_path)
|
|
|
|
rrt_group.setLayout(rrt_layout)
|
|
main_layout.addWidget(rrt_group)
|
|
|
|
# 创建控制按钮
|
|
button_layout = QHBoxLayout()
|
|
self.save_config_btn = QPushButton("保存配置")
|
|
self.reset_config_btn = QPushButton("重置配置")
|
|
|
|
button_layout.addWidget(self.save_config_btn)
|
|
button_layout.addWidget(self.reset_config_btn)
|
|
|
|
main_layout.addLayout(button_layout)
|
|
|
|
self.setLayout(main_layout)
|
|
|
|
# 连接信号
|
|
self.save_config_btn.clicked.connect(self.save_config)
|
|
self.reset_config_btn.clicked.connect(self.reset_config)
|
|
|
|
def save_config(self):
|
|
QMessageBox.information(self, "功能确认", "保存配置 (功能待实现)")
|
|
# TODO: Implement save config logic
|
|
pass
|
|
|
|
def reset_config(self):
|
|
QMessageBox.information(self, "功能确认", "重置配置 (功能待实现)")
|
|
# TODO: Implement reset config logic (reset UI fields to default)
|
|
pass |