145 lines
5.6 KiB
C++
145 lines
5.6 KiB
C++
|
|
#include "DialogAlgoConfig.h"
|
||
|
|
#include "ui_dialogalgoconfig.h"
|
||
|
|
#include "TunnelChannelPresenter.h"
|
||
|
|
#include "VrLog.h"
|
||
|
|
#include <QMessageBox>
|
||
|
|
|
||
|
|
DialogAlgoConfig::DialogAlgoConfig(TunnelChannelPresenter* presenter, QWidget *parent)
|
||
|
|
: QDialog(parent)
|
||
|
|
, ui(new Ui::DialogAlgoConfig)
|
||
|
|
, m_presenter(presenter)
|
||
|
|
{
|
||
|
|
ui->setupUi(this);
|
||
|
|
|
||
|
|
// 连接信号槽
|
||
|
|
connect(ui->btn_apply, &QPushButton::clicked, this, &DialogAlgoConfig::onBtnApplyClicked);
|
||
|
|
connect(ui->btn_cancel, &QPushButton::clicked, this, &DialogAlgoConfig::onBtnCancelClicked);
|
||
|
|
|
||
|
|
loadParameters();
|
||
|
|
}
|
||
|
|
|
||
|
|
DialogAlgoConfig::~DialogAlgoConfig()
|
||
|
|
{
|
||
|
|
delete ui;
|
||
|
|
}
|
||
|
|
|
||
|
|
void DialogAlgoConfig::loadParameters()
|
||
|
|
{
|
||
|
|
if (!m_presenter) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 获取当前参数
|
||
|
|
SSG_cornerParam cornerParam;
|
||
|
|
SSG_outlierFilterParam filterParam;
|
||
|
|
SSG_treeGrowParam treeParam;
|
||
|
|
SSX_channelParam channelParam;
|
||
|
|
bool horizonScan;
|
||
|
|
|
||
|
|
m_presenter->GetAlgoParams(cornerParam, filterParam, treeParam, channelParam, horizonScan);
|
||
|
|
|
||
|
|
// 加载角点检测参数
|
||
|
|
ui->edit_minEndingGap->setText(QString::number(cornerParam.minEndingGap, 'f', 2));
|
||
|
|
ui->edit_minEndingGapZ->setText(QString::number(cornerParam.minEndingGap_z, 'f', 2));
|
||
|
|
ui->edit_scale->setText(QString::number(cornerParam.scale, 'f', 2));
|
||
|
|
ui->edit_cornerTh->setText(QString::number(cornerParam.cornerTh, 'f', 2));
|
||
|
|
ui->edit_jumpCornerTh1->setText(QString::number(cornerParam.jumpCornerTh_1, 'f', 2));
|
||
|
|
ui->edit_jumpCornerTh2->setText(QString::number(cornerParam.jumpCornerTh_2, 'f', 2));
|
||
|
|
|
||
|
|
// 加载离群点过滤参数
|
||
|
|
ui->edit_continuityTh->setText(QString::number(filterParam.continuityTh, 'f', 2));
|
||
|
|
ui->edit_outlierTh->setText(QString::number(filterParam.outlierTh, 'f', 2));
|
||
|
|
|
||
|
|
// 加载树生长参数
|
||
|
|
ui->edit_yDeviationMax->setText(QString::number(treeParam.yDeviation_max, 'f', 2));
|
||
|
|
ui->edit_zDeviationMax->setText(QString::number(treeParam.zDeviation_max, 'f', 2));
|
||
|
|
ui->edit_maxLineSkipNum->setText(QString::number(treeParam.maxLineSkipNum));
|
||
|
|
ui->edit_maxSkipDistance->setText(QString::number(treeParam.maxSkipDistance, 'f', 2));
|
||
|
|
ui->edit_minLTypeTreeLen->setText(QString::number(treeParam.minLTypeTreeLen, 'f', 2));
|
||
|
|
ui->edit_minVTypeTreeLen->setText(QString::number(treeParam.minVTypeTreeLen, 'f', 2));
|
||
|
|
|
||
|
|
// 加载通道参数
|
||
|
|
ui->edit_channelWidthMin->setText(QString::number(channelParam.channelWidthRng.min, 'f', 2));
|
||
|
|
ui->edit_channelWidthMax->setText(QString::number(channelParam.channelWidthRng.max, 'f', 2));
|
||
|
|
ui->edit_channelSpaceMin->setText(QString::number(channelParam.channleSpaceRng.min, 'f', 2));
|
||
|
|
ui->edit_channelSpaceMax->setText(QString::number(channelParam.channleSpaceRng.max, 'f', 2));
|
||
|
|
|
||
|
|
// 加载扫描方向
|
||
|
|
ui->chk_horizonScan->setChecked(horizonScan);
|
||
|
|
}
|
||
|
|
|
||
|
|
bool DialogAlgoConfig::saveParameters()
|
||
|
|
{
|
||
|
|
if (!m_presenter) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 验证参数
|
||
|
|
double channelWidthMin = ui->edit_channelWidthMin->text().toDouble();
|
||
|
|
double channelWidthMax = ui->edit_channelWidthMax->text().toDouble();
|
||
|
|
if (channelWidthMin >= channelWidthMax) {
|
||
|
|
QMessageBox::warning(this, tr("参数错误"), tr("通道宽度最小值必须小于最大值"));
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
double channelSpaceMin = ui->edit_channelSpaceMin->text().toDouble();
|
||
|
|
double channelSpaceMax = ui->edit_channelSpaceMax->text().toDouble();
|
||
|
|
if (channelSpaceMin >= channelSpaceMax) {
|
||
|
|
QMessageBox::warning(this, tr("参数错误"), tr("通道间距最小值必须小于最大值"));
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 构建参数结构体
|
||
|
|
SSG_cornerParam cornerParam;
|
||
|
|
cornerParam.minEndingGap = ui->edit_minEndingGap->text().toDouble();
|
||
|
|
cornerParam.minEndingGap_z = ui->edit_minEndingGapZ->text().toDouble();
|
||
|
|
cornerParam.scale = ui->edit_scale->text().toDouble();
|
||
|
|
cornerParam.cornerTh = ui->edit_cornerTh->text().toDouble();
|
||
|
|
cornerParam.jumpCornerTh_1 = ui->edit_jumpCornerTh1->text().toDouble();
|
||
|
|
cornerParam.jumpCornerTh_2 = ui->edit_jumpCornerTh2->text().toDouble();
|
||
|
|
|
||
|
|
SSG_outlierFilterParam filterParam;
|
||
|
|
filterParam.continuityTh = ui->edit_continuityTh->text().toDouble();
|
||
|
|
filterParam.outlierTh = ui->edit_outlierTh->text().toDouble();
|
||
|
|
|
||
|
|
SSG_treeGrowParam treeParam;
|
||
|
|
treeParam.yDeviation_max = ui->edit_yDeviationMax->text().toDouble();
|
||
|
|
treeParam.zDeviation_max = ui->edit_zDeviationMax->text().toDouble();
|
||
|
|
treeParam.maxLineSkipNum = ui->edit_maxLineSkipNum->text().toInt();
|
||
|
|
treeParam.maxSkipDistance = ui->edit_maxSkipDistance->text().toDouble();
|
||
|
|
treeParam.minLTypeTreeLen = ui->edit_minLTypeTreeLen->text().toDouble();
|
||
|
|
treeParam.minVTypeTreeLen = ui->edit_minVTypeTreeLen->text().toDouble();
|
||
|
|
|
||
|
|
SSX_channelParam channelParam;
|
||
|
|
channelParam.channelWidthRng.min = channelWidthMin;
|
||
|
|
channelParam.channelWidthRng.max = channelWidthMax;
|
||
|
|
channelParam.channleSpaceRng.min = channelSpaceMin;
|
||
|
|
channelParam.channleSpaceRng.max = channelSpaceMax;
|
||
|
|
|
||
|
|
bool horizonScan = ui->chk_horizonScan->isChecked();
|
||
|
|
|
||
|
|
// 设置参数
|
||
|
|
m_presenter->SetAlgoParams(cornerParam, filterParam, treeParam, channelParam, horizonScan);
|
||
|
|
|
||
|
|
// 保存到配置文件
|
||
|
|
if (!m_presenter->SaveAlgoParamsToConfig()) {
|
||
|
|
QMessageBox::warning(this, tr("保存失败"), tr("参数保存到配置文件失败"));
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
LOG_INFO("Algorithm parameters saved successfully\n");
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
void DialogAlgoConfig::onBtnApplyClicked()
|
||
|
|
{
|
||
|
|
if (saveParameters()) {
|
||
|
|
accept();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void DialogAlgoConfig::onBtnCancelClicked()
|
||
|
|
{
|
||
|
|
reject();
|
||
|
|
}
|