143 lines
4.5 KiB
C++
143 lines
4.5 KiB
C++
|
|
#include "dialogalgoarg.h"
|
||
|
|
#include "ui_dialogalgoarg.h"
|
||
|
|
#include "BagThreadPositionPresenter.h"
|
||
|
|
#include "StyledMessageBox.h"
|
||
|
|
|
||
|
|
DialogAlgoArg::DialogAlgoArg(QWidget *parent)
|
||
|
|
: QDialog(parent)
|
||
|
|
, ui(new Ui::DialogAlgoArg)
|
||
|
|
, m_presenter(nullptr)
|
||
|
|
{
|
||
|
|
ui->setupUi(this);
|
||
|
|
setWindowTitle("算法参数设置");
|
||
|
|
}
|
||
|
|
|
||
|
|
DialogAlgoArg::~DialogAlgoArg()
|
||
|
|
{
|
||
|
|
delete ui;
|
||
|
|
}
|
||
|
|
|
||
|
|
void DialogAlgoArg::SetPresenter(BagThreadPositionPresenter* presenter)
|
||
|
|
{
|
||
|
|
m_presenter = presenter;
|
||
|
|
loadParams();
|
||
|
|
}
|
||
|
|
|
||
|
|
void DialogAlgoArg::loadParams()
|
||
|
|
{
|
||
|
|
if (!m_presenter) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
auto params = m_presenter->GetAlgoParams();
|
||
|
|
|
||
|
|
// 拆线参数
|
||
|
|
ui->chkHorizonScan->setChecked(params.threadParam.isHorizonScan);
|
||
|
|
|
||
|
|
// 角点检测参数 (VrCornerParam)
|
||
|
|
ui->spinCornerTh->setValue(params.cornerParam.cornerTh);
|
||
|
|
ui->spinScale->setValue(params.cornerParam.scale);
|
||
|
|
ui->spinMinEndingGap->setValue(params.cornerParam.minEndingGap);
|
||
|
|
ui->spinMinEndingGapZ->setValue(params.cornerParam.minEndingGap_z);
|
||
|
|
ui->spinJumpCornerTh1->setValue(params.cornerParam.jumpCornerTh_1);
|
||
|
|
ui->spinJumpCornerTh2->setValue(params.cornerParam.jumpCornerTh_2);
|
||
|
|
|
||
|
|
// 滤波参数 (VrOutlierFilterParam)
|
||
|
|
ui->spinContinuityTh->setValue(params.filterParam.continuityTh);
|
||
|
|
ui->spinOutlierTh->setValue(params.filterParam.outlierTh);
|
||
|
|
|
||
|
|
// 树生长参数 (VrTreeGrowParam)
|
||
|
|
ui->spinMaxLineSkipNum->setValue(params.growParam.maxLineSkipNum);
|
||
|
|
ui->spinYDeviationMax->setValue(params.growParam.yDeviation_max);
|
||
|
|
ui->spinMaxSkipDistance->setValue(params.growParam.maxSkipDistance);
|
||
|
|
ui->spinZDeviationMax->setValue(params.growParam.zDeviation_max);
|
||
|
|
ui->spinMinLTypeTreeLen->setValue(params.growParam.minLTypeTreeLen);
|
||
|
|
ui->spinMinVTypeTreeLen->setValue(params.growParam.minVTypeTreeLen);
|
||
|
|
}
|
||
|
|
|
||
|
|
void DialogAlgoArg::saveParams()
|
||
|
|
{
|
||
|
|
if (!m_presenter) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
auto params = m_presenter->GetAlgoParams();
|
||
|
|
|
||
|
|
// 拆线参数
|
||
|
|
params.threadParam.isHorizonScan = ui->chkHorizonScan->isChecked();
|
||
|
|
|
||
|
|
// 角点检测参数 (VrCornerParam)
|
||
|
|
params.cornerParam.cornerTh = ui->spinCornerTh->value();
|
||
|
|
params.cornerParam.scale = ui->spinScale->value();
|
||
|
|
params.cornerParam.minEndingGap = ui->spinMinEndingGap->value();
|
||
|
|
params.cornerParam.minEndingGap_z = ui->spinMinEndingGapZ->value();
|
||
|
|
params.cornerParam.jumpCornerTh_1 = ui->spinJumpCornerTh1->value();
|
||
|
|
params.cornerParam.jumpCornerTh_2 = ui->spinJumpCornerTh2->value();
|
||
|
|
|
||
|
|
// 滤波参数 (VrOutlierFilterParam)
|
||
|
|
params.filterParam.continuityTh = ui->spinContinuityTh->value();
|
||
|
|
params.filterParam.outlierTh = ui->spinOutlierTh->value();
|
||
|
|
|
||
|
|
// 树生长参数 (VrTreeGrowParam)
|
||
|
|
params.growParam.maxLineSkipNum = ui->spinMaxLineSkipNum->value();
|
||
|
|
params.growParam.yDeviation_max = ui->spinYDeviationMax->value();
|
||
|
|
params.growParam.maxSkipDistance = ui->spinMaxSkipDistance->value();
|
||
|
|
params.growParam.zDeviation_max = ui->spinZDeviationMax->value();
|
||
|
|
params.growParam.minLTypeTreeLen = ui->spinMinLTypeTreeLen->value();
|
||
|
|
params.growParam.minVTypeTreeLen = ui->spinMinVTypeTreeLen->value();
|
||
|
|
|
||
|
|
m_presenter->SetAlgoParams(params);
|
||
|
|
}
|
||
|
|
|
||
|
|
void DialogAlgoArg::resetParams()
|
||
|
|
{
|
||
|
|
// 重置为默认值
|
||
|
|
ui->chkHorizonScan->setChecked(true);
|
||
|
|
|
||
|
|
// 角点检测参数默认值
|
||
|
|
ui->spinCornerTh->setValue(60.0);
|
||
|
|
ui->spinScale->setValue(50.0);
|
||
|
|
ui->spinMinEndingGap->setValue(20.0);
|
||
|
|
ui->spinMinEndingGapZ->setValue(20.0);
|
||
|
|
ui->spinJumpCornerTh1->setValue(10.0);
|
||
|
|
ui->spinJumpCornerTh2->setValue(60.0);
|
||
|
|
|
||
|
|
// 滤波参数默认值
|
||
|
|
ui->spinContinuityTh->setValue(20.0);
|
||
|
|
ui->spinOutlierTh->setValue(5.0);
|
||
|
|
|
||
|
|
// 树生长参数默认值
|
||
|
|
ui->spinMaxLineSkipNum->setValue(10);
|
||
|
|
ui->spinYDeviationMax->setValue(10.0);
|
||
|
|
ui->spinMaxSkipDistance->setValue(10.0);
|
||
|
|
ui->spinZDeviationMax->setValue(10.0);
|
||
|
|
ui->spinMinLTypeTreeLen->setValue(100.0);
|
||
|
|
ui->spinMinVTypeTreeLen->setValue(100.0);
|
||
|
|
}
|
||
|
|
|
||
|
|
void DialogAlgoArg::on_btnOK_clicked()
|
||
|
|
{
|
||
|
|
saveParams();
|
||
|
|
accept();
|
||
|
|
}
|
||
|
|
|
||
|
|
void DialogAlgoArg::on_btnCancel_clicked()
|
||
|
|
{
|
||
|
|
reject();
|
||
|
|
}
|
||
|
|
|
||
|
|
void DialogAlgoArg::on_btnApply_clicked()
|
||
|
|
{
|
||
|
|
saveParams();
|
||
|
|
StyledMessageBox::information(this, "提示", "参数已应用");
|
||
|
|
}
|
||
|
|
|
||
|
|
void DialogAlgoArg::on_btnReset_clicked()
|
||
|
|
{
|
||
|
|
auto ret = StyledMessageBox::question(this, "确认重置",
|
||
|
|
"确定要重置为默认参数吗?");
|
||
|
|
if (ret == QMessageBox::Yes) {
|
||
|
|
resetParams();
|
||
|
|
}
|
||
|
|
}
|