99 lines
3.7 KiB
C++
99 lines
3.7 KiB
C++
#include "VolumeParamsDialog.hpp"
|
||
|
||
#include <QComboBox>
|
||
#include <QDialogButtonBox>
|
||
#include <QDoubleSpinBox>
|
||
#include <QFormLayout>
|
||
#include <QLabel>
|
||
#include <QLineEdit>
|
||
#include <QStandardItemModel>
|
||
#include <QVBoxLayout>
|
||
|
||
#include "FormKit.hpp"
|
||
#include "Theme.hpp"
|
||
|
||
namespace geopro::app {
|
||
|
||
namespace {
|
||
// 默认值与 data::VolumeBuildParams 同口径(保持单一真相)。
|
||
constexpr double kDefCellXY = 1.0;
|
||
constexpr double kDefCellZ = 0.5;
|
||
constexpr double kDefPower = 2.0;
|
||
constexpr double kDefMaxDist = 4.0;
|
||
} // namespace
|
||
|
||
VolumeParamsDialog::VolumeParamsDialog(int sourceCount, QWidget* parent) : QDialog(parent) {
|
||
setWindowTitle(QStringLiteral("生成三维体"));
|
||
setModal(true);
|
||
|
||
auto* root = formkit::dialogRoot(this);
|
||
|
||
auto* intro = new QLabel(QStringLiteral("由 %1 个源数据集插值生成三维体").arg(sourceCount));
|
||
geopro::app::applyTokenizedStyleSheet(intro, QStringLiteral("color:{{text/secondary}};"));
|
||
root->addWidget(intro);
|
||
|
||
// 统一外壳:表单卡片 + 分组标题(与「数据详情 / 属性面板」同款),编辑态/只读态一致。
|
||
auto* card = formkit::formCard(this);
|
||
auto* cardLay = formkit::cardBody(card);
|
||
formkit::addSection(cardLay, QStringLiteral("参数"), card, false);
|
||
|
||
auto* form = formkit::makeEditForm();
|
||
|
||
name_ = new QLineEdit(QStringLiteral("三维体"));
|
||
formkit::capField(name_);
|
||
form->addRow(formkit::editLabel(QStringLiteral("名称")), name_);
|
||
|
||
model_ = new QComboBox();
|
||
model_->addItem(QStringLiteral("反距离加权 (IDW)"),
|
||
static_cast<int>(geopro::data::VolumeBuildParams::Model::Idw));
|
||
model_->addItem(QStringLiteral("克里金 (Kriging)"),
|
||
static_cast<int>(geopro::data::VolumeBuildParams::Model::Kriging));
|
||
// 克里金本期未实现(core 仅 IDW)→ 禁用该项,默认选 IDW。
|
||
if (auto* m = qobject_cast<QStandardItemModel*>(model_->model())) {
|
||
if (auto* it = m->item(1)) it->setEnabled(false);
|
||
}
|
||
model_->setCurrentIndex(0);
|
||
formkit::capField(model_);
|
||
form->addRow(formkit::editLabel(QStringLiteral("插值模型")), model_);
|
||
|
||
auto makeSpin = [this](double val, double min, double max, double step, int decimals) {
|
||
auto* s = new QDoubleSpinBox();
|
||
s->setRange(min, max);
|
||
s->setSingleStep(step);
|
||
s->setDecimals(decimals);
|
||
s->setValue(val);
|
||
formkit::capField(s);
|
||
return s;
|
||
};
|
||
cellXY_ = makeSpin(kDefCellXY, 0.01, 1000.0, 0.5, 2);
|
||
cellZ_ = makeSpin(kDefCellZ, 0.01, 1000.0, 0.5, 2);
|
||
power_ = makeSpin(kDefPower, 0.5, 6.0, 0.5, 1);
|
||
maxDist_ = makeSpin(kDefMaxDist, 0.1, 10000.0, 1.0, 2);
|
||
form->addRow(formkit::editLabel(QStringLiteral("水平间距 (米)")), cellXY_);
|
||
form->addRow(formkit::editLabel(QStringLiteral("竖向间距 (米)")), cellZ_);
|
||
form->addRow(formkit::editLabel(QStringLiteral("IDW 幂次")), power_);
|
||
form->addRow(formkit::editLabel(QStringLiteral("最大影响距离 (米)")), maxDist_);
|
||
|
||
cardLay->addLayout(form);
|
||
root->addWidget(card);
|
||
|
||
formkit::addDialogButtons(root, this, QStringLiteral("生成"), QStringLiteral("取消"));
|
||
}
|
||
|
||
QString VolumeParamsDialog::volumeName() const {
|
||
const QString n = name_->text().trimmed();
|
||
return n.isEmpty() ? QStringLiteral("三维体") : n;
|
||
}
|
||
|
||
geopro::data::VolumeBuildParams VolumeParamsDialog::params() const {
|
||
geopro::data::VolumeBuildParams p;
|
||
p.interpModel = static_cast<geopro::data::VolumeBuildParams::Model>(model_->currentData().toInt());
|
||
p.cellXY = cellXY_->value();
|
||
p.cellZ = cellZ_->value();
|
||
p.power = power_->value();
|
||
p.maxDist = maxDist_->value();
|
||
return p;
|
||
}
|
||
|
||
} // namespace geopro::app
|