172 lines
5.8 KiB
C++
172 lines
5.8 KiB
C++
#include "QtSimulationGeoSARSigma0Dialog.h"
|
|
#include "ui_QtSimulationGeoSARSigma0Dialog.h"
|
|
#include <QFileDialog>
|
|
#include <QMessageBox>
|
|
#include "BaseTool.h"
|
|
#include "SigmaDatabase.h"
|
|
#include <ImageOperatorBase.h>
|
|
|
|
|
|
QtSimulationGeoSARSigma0Dialog::QtSimulationGeoSARSigma0Dialog(QWidget *parent)
|
|
: QDialog(parent), ui(new Ui::QtSimulationGeoSARSigma0DialogClass)
|
|
{
|
|
ui->setupUi(this);
|
|
// 连接信号和槽
|
|
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(onbtnaccepted()));
|
|
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(onbtnrejected()));
|
|
connect(ui->InputIncAngleRasterBtn, SIGNAL(clicked(bool)), this, SLOT(onpushButtonIncAngleRasterClicked(bool)));
|
|
connect(ui->InputLandClsRasterBtn, SIGNAL(clicked(bool)), this, SLOT(onpushButtonLandClsRasterClicked(bool)));
|
|
connect(ui->InputClsWeightRasterBtn, SIGNAL(clicked(bool)), this, SLOT(onpushButtonClsWeightRasterClicked(bool)));
|
|
connect(ui->OutputTerrianRasterBtn, SIGNAL(clicked(bool)), this, SLOT(onpushButtonOutputTerrianRasterClicked(bool)));
|
|
connect(ui->OutputClsSARRasterBtn, SIGNAL(clicked(bool)), this, SLOT(onpushButtonOutputClsSARRasterClicked(bool)));
|
|
|
|
}
|
|
|
|
QtSimulationGeoSARSigma0Dialog::~QtSimulationGeoSARSigma0Dialog()
|
|
{}
|
|
|
|
void QtSimulationGeoSARSigma0Dialog::onpushButtonIncAngleRasterClicked(bool)
|
|
{
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
this, // 父窗口
|
|
tr(u8"选择影像"), // 标题
|
|
QString(), // 默认路径
|
|
tr(u8"tif Files (*.tif);;data Files (*.data);;bin Files (*.bin);;All Files (*)") // 文件过滤器
|
|
);
|
|
|
|
// 如果用户选择了文件
|
|
if (!fileName.isEmpty()) {
|
|
this->ui->InputIncAngleRasterLineEdit->setText(fileName);
|
|
|
|
}
|
|
else {
|
|
QMessageBox::information(this, tr(u8"没有选择文件"), tr(u8"没有选择任何文件。"));
|
|
}
|
|
}
|
|
|
|
void QtSimulationGeoSARSigma0Dialog::onpushButtonLandClsRasterClicked(bool)
|
|
{
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
this, // 父窗口
|
|
tr(u8"选择影像"), // 标题
|
|
QString(), // 默认路径
|
|
tr(u8"tif Files (*.tif);;data Files (*.data);;bin Files (*.bin);;All Files (*)") // 文件过滤器
|
|
);
|
|
|
|
// 如果用户选择了文件
|
|
if (!fileName.isEmpty()) {
|
|
this->ui->InputLandClsRasterLineEdit->setText(fileName);
|
|
|
|
}
|
|
else {
|
|
QMessageBox::information(this, tr(u8"没有选择文件"), tr(u8"没有选择任何文件。"));
|
|
}
|
|
}
|
|
|
|
void QtSimulationGeoSARSigma0Dialog::onpushButtonClsWeightRasterClicked(bool)
|
|
{
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
this, // 父窗口
|
|
tr(u8"选择影像"), // 标题
|
|
QString(), // 默认路径
|
|
tr(u8"tif Files (*.tif);;data Files (*.data);;bin Files (*.bin);;All Files (*)") // 文件过滤器
|
|
);
|
|
|
|
// 如果用户选择了文件
|
|
if (!fileName.isEmpty()) {
|
|
this->ui->InputClsWeightRasterLineEdit->setText(fileName);
|
|
|
|
}
|
|
else {
|
|
QMessageBox::information(this, tr(u8"没有选择文件"), tr(u8"没有选择任何文件。"));
|
|
}
|
|
}
|
|
|
|
void QtSimulationGeoSARSigma0Dialog::onpushButtonOutputTerrianRasterClicked(bool)
|
|
{
|
|
QString fileName = QFileDialog::getSaveFileName(
|
|
this, // 父窗口
|
|
tr(u8"选择影像"), // 标题
|
|
QString(), // 默认路径
|
|
tr(u8"tif Files (*.tif);;data Files (*.data);;bin Files (*.bin);;All Files (*)") // 文件过滤器
|
|
);
|
|
|
|
// 如果用户选择了文件
|
|
if (!fileName.isEmpty()) {
|
|
this->ui->OutputTerrianRasterLineEdit->setText(fileName);
|
|
|
|
}
|
|
else {
|
|
QMessageBox::information(this, tr(u8"没有选择文件"), tr(u8"没有选择任何文件。"));
|
|
}
|
|
}
|
|
|
|
void QtSimulationGeoSARSigma0Dialog::onpushButtonOutputClsSARRasterClicked(bool)
|
|
{
|
|
QString fileName = QFileDialog::getSaveFileName(
|
|
this, // 父窗口
|
|
tr(u8"选择影像"), // 标题
|
|
QString(), // 默认路径
|
|
tr(u8"tif Files (*.tif);;data Files (*.data);;bin Files (*.bin);;All Files (*)") // 文件过滤器
|
|
);
|
|
|
|
// 如果用户选择了文件
|
|
if (!fileName.isEmpty()) {
|
|
this->ui->OutputClsSARRasterLineEdit->setText(fileName);
|
|
|
|
}
|
|
else {
|
|
QMessageBox::information(this, tr(u8"没有选择文件"), tr(u8"没有选择任何文件。"));
|
|
}
|
|
}
|
|
|
|
|
|
void QtSimulationGeoSARSigma0Dialog::onbtnaccepted()
|
|
{
|
|
// 参数文件
|
|
QString IncAngleRaster = this->ui->InputIncAngleRasterLineEdit->text(); // 输入入射角文件
|
|
QString LandClsRaster = this->ui->InputLandClsRasterLineEdit->text(); // 输入地表覆盖分类文件
|
|
QString ClsWeightRaster = this->ui->InputClsWeightRasterLineEdit->text();// 输入 SigmaDatabase 权重文件
|
|
QString OutputTerrianRaster = this->ui->OutputTerrianRasterLineEdit->text(); // 输出入射角仿真SAR文件
|
|
QString OutputClsSARRaster = this->ui->OutputClsSARRasterLineEdit->text();// 输出地表覆盖分类仿真SAR文件
|
|
|
|
// 创建输出文件,其中输出文件的大小和输入文件的大小一致,复制输入文件到输出文件,并把文件置零
|
|
gdalImage IncAngle(IncAngleRaster);
|
|
gdalImage LandCls(LandClsRaster);
|
|
SigmaDatabase sigmads;
|
|
sigmads.readParamsFromFile(ClsWeightRaster.toStdString());
|
|
|
|
// 创建输出文件
|
|
QFile::copy(IncAngleRaster, OutputTerrianRaster);
|
|
QFile::copy(IncAngleRaster, OutputClsSARRaster);
|
|
|
|
gdalImage OutputTerrian(OutputTerrianRaster);
|
|
gdalImage OutputClsSAR(OutputClsSARRaster);
|
|
|
|
// 读取输入文件
|
|
Eigen::MatrixXd IncAngleData = IncAngle.getData(0, 0, IncAngle.height, IncAngle.width, 0);
|
|
Eigen::MatrixXd LandClsData = LandCls.getData(0, 0, LandCls.height, LandCls.width, 0);
|
|
|
|
Eigen::MatrixXd SigmaSARData = MuhlemanSigmaArray(IncAngleData);
|
|
Eigen::MatrixXd SigmaSARDataCls = SigmaSARData;
|
|
OutputTerrian.saveImage(SigmaSARData, 0, 0, 1);
|
|
|
|
for (long i = 0; i < LandClsData.rows(); i++)
|
|
{
|
|
for (long j = 0; j < LandClsData.cols(); j++)
|
|
{
|
|
double weight = sigmads.getAmpHH(LandClsData(i, j),IncAngleData(i,j)*d2r);
|
|
SigmaSARDataCls(i, j) = std::pow(10.0, weight/20.0);
|
|
}
|
|
}
|
|
OutputClsSAR.saveImage(SigmaSARDataCls, 0, 0, 1);
|
|
|
|
QMessageBox::information(nullptr, u8"提示", u8"completed!!!");
|
|
|
|
}
|
|
|
|
void QtSimulationGeoSARSigma0Dialog::onbtnrejected()
|
|
{
|
|
this->close();
|
|
}
|