#include "QLookTableResampleFromWGS84ToRange.h"
#include "BaseConstVariable.h"
#include "BaseTool.h"
#include <QMessageBox>
#include <QFileDialog>
#include "ui_QLookTableResampleFromWGS84ToRange.h"
#include "ImageNetOperator.h"

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

	connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(onaccepted()));
	connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(onrejected()));
	connect(ui->pushButtonLookTableWGS84Select, SIGNAL(clicked(bool)), this, SLOT(onpushButtonLookTableWGS84SelectClicked(bool)));
	connect(ui->pushButtonLookTableRangeSelect, SIGNAL(clicked(bool)), this, SLOT(onpushButtonLookTableRangeSelectClicked(bool)));
	connect(ui->pushButtonLookTableCountSelect, SIGNAL(clicked(bool)), this, SLOT(onpushButtonLookTableCountSelectClicked(bool)));
}

QLookTableResampleFromWGS84ToRange::~QLookTableResampleFromWGS84ToRange()
{}

void QLookTableResampleFromWGS84ToRange::onaccepted()
{
	QString looktableWGS84Ptah = ui->lineEditLookTableWGS84Path->text();
	QString looktableRangePtah = ui->lineEditLookTableRangePath->text();
	QString looktableCountPtah = ui->lineEditLookTableCountPath->text();

	long Oriheight = ui->spinBoxRowCount->value();
	long OriWidth = ui->spinBoxColCount->value();

	ReflectTable_WGS2Range(looktableWGS84Ptah, looktableRangePtah, looktableCountPtah, Oriheight, OriWidth);
	QMessageBox::information(nullptr, u8"提示", u8"完成");
}

void QLookTableResampleFromWGS84ToRange::onrejected()
{
	this->close();
}

void QLookTableResampleFromWGS84ToRange::onpushButtonLookTableWGS84SelectClicked(bool)
{
	QString  fileNames = QFileDialog::getOpenFileName(
		this,
		tr(u8"选择WGS84文件"),
		QString(),
		tr(ENVI_FILE_FORMAT_FILTER)
	);

	if (!fileNames.isEmpty()) {
		QString message = "选中文件\n";
		this->ui->lineEditLookTableWGS84Path->setText(fileNames);
	}
	else {
		QMessageBox::information(this, tr(u8"提示"), tr(u8"没有选中文件"));
	}
}

void QLookTableResampleFromWGS84ToRange::onpushButtonLookTableRangeSelectClicked(bool)
{
	QString  fileNames = QFileDialog::getSaveFileName(
		this,
		tr(u8"保存斜距平面文件"),
		QString(),
		tr(ENVI_FILE_FORMAT_FILTER)
	);

	if (!fileNames.isEmpty()) {
		QString message = "选中文件\n";
		this->ui->lineEditLookTableRangePath->setText(fileNames);
	}
	else {
		QMessageBox::information(this, tr(u8"提示"), tr(u8"没有选中文件"));
	}
}

void QLookTableResampleFromWGS84ToRange::onpushButtonLookTableCountSelectClicked(bool)
{
	QString  fileNames = QFileDialog::getSaveFileName(
		this,
		tr(u8"保存统计采样平面文件"),
		QString(),
		tr(ENVI_FILE_FORMAT_FILTER)
	);

	if (!fileNames.isEmpty()) {
		QString message = "选中文件\n";
		this->ui->lineEditLookTableCountPath->setText(fileNames);
	}
	else {
		QMessageBox::information(this, tr(u8"提示"), tr(u8"没有选中文件"));
	}
}
