#include "QL1ASARProcessDialog.h"
#include "ui_QL1ASARProcessDialog.h"
#include "BaseConstVariable.h"
#include "BaseTool.h"
#include "RasterToolBase.h"
#include "LogInfoCls.h"
#include <QMessageBox>
#include <QFileDialog>
#include "ImageNetOperator.h"
#include "ImageOperatorBase.h"

QL1ASARProcessDialog::QL1ASARProcessDialog(QWidget *parent)
	: QDialog(parent)
	,ui(new Ui::QL1ASARProcessDialogClass)
{
	ui->setupUi(this);


	connect(ui->pushButtonL1BSelect, SIGNAL(clicked()), this, SLOT(onpushButtonL1BSelect_clicked()));
	connect(ui->pushButtonL1ASelect, SIGNAL(clicked()), this, SLOT(onpushButtonL1ASelect_clicked()));
	connect(ui->pushButtonS1ASelect, SIGNAL(clicked()), this, SLOT(onpushButtonS1ASelect_clicked()));
	connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(onbuttonBox_accepted()));
	connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(onbuttonBox_rejected()));




}

QL1ASARProcessDialog::~QL1ASARProcessDialog()
{



}

void QL1ASARProcessDialog::onpushButtonL1BSelect_clicked()
{

	QString  fileNames = QFileDialog::getSaveFileName(
		this,                            // 父窗口
		tr(u8"选择L1B数据文件"),               // 标题
		QString(),                       // 默认路径
		tr(ENVI_FILE_FORMAT_FILTER)  // 文件过滤器
	);
	// 如果用户选择了文件
	if (!fileNames.isEmpty()) {
		QString message = u8"选择的文件有：\n";
		this->ui->lineEditL1BDataPath->setText(fileNames);
	}
	else {
		QMessageBox::information(this, tr(u8"没有选择文件"), tr(u8"没有选择任何文件。"));
	}

}

void QL1ASARProcessDialog::onpushButtonL1ASelect_clicked()
{
	QString  fileNames = QFileDialog::getOpenFileName(
		this,                            // 父窗口
		tr(u8"选择L1A数据文件"),               // 标题
		QString(),                       // 默认路径
		tr(ENVI_FILE_FORMAT_FILTER)  // 文件过滤器
	);
	// 如果用户选择了文件
	if (!fileNames.isEmpty()) {
		QString message = u8"选择的文件有：\n";
		this->ui->lineEditL1ADataPath->setText(fileNames);
	}
	else {
		QMessageBox::information(this, tr(u8"没有选择文件"), tr(u8"没有选择任何文件。"));
	}
}

void QL1ASARProcessDialog::onpushButtonS1ASelect_clicked()
{
	QString  fileNames = QFileDialog::getSaveFileName(
		this,                            // 父窗口
		tr(u8"选择单视斜距振幅产品文件"),               // 标题
		QString(),                       // 默认路径
		tr(ENVI_FILE_FORMAT_FILTER)  // 文件过滤器
	);
	// 如果用户选择了文件
	if (!fileNames.isEmpty()) {
		QString message = u8"选择的文件有：\n";
		this->ui->lineSlAPath->setText(fileNames);
	}
	else {
		QMessageBox::information(this, tr(u8"没有选择文件"), tr(u8"没有选择任何文件。"));
	}
}

void QL1ASARProcessDialog::onbuttonBox_accepted()
{
	QString l1arasterpath = ui->lineEditL1ADataPath->text();
	QString s1arasterpath = ui->lineSlAPath->text();
	QString l1brasterpath = ui->lineEditL1BDataPath->text();

	long nlaz = ui->spinBoxLNAz->value();
	long nlra = ui->spinBoxLNRa->value();

	qDebug() << u8"单视斜距复数产品 转 单视斜距幅度产品";
	Complex2AmpRaster(l1arasterpath, s1arasterpath);

	qDebug() << u8"单视斜距幅度产品 转 多视斜距幅度产品";
	MultiLookRaster(s1arasterpath, l1brasterpath, nlaz, nlra);

	QMessageBox::information(this, tr(u8"提示"), tr(u8"多视处理完成"));
}

void QL1ASARProcessDialog::onbuttonBox_rejected()
{
	this->close();
}
