Compare commits
No commits in common. "6b259c684043a53a7c59a95b5bafaddb5f413947" and "DemTrain" have entirely different histories.
6b259c6840
...
DemTrain
@ -1,98 +0,0 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* @brief 进度条基类
|
||||
*
|
||||
* 提供进度条基类接口,来反映当前算法的进度值
|
||||
*/
|
||||
//源码:class IMGALG_API CProcessBase
|
||||
class CProcessBase
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief 构造函数
|
||||
*/
|
||||
CProcessBase()
|
||||
{
|
||||
m_dPosition = 0.0;
|
||||
m_iStepCount = 100;
|
||||
m_iCurStep = 0;
|
||||
m_bIsContinue = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 析构函数
|
||||
*/
|
||||
virtual ~CProcessBase() {}
|
||||
|
||||
/**
|
||||
* @brief 设置进度信息
|
||||
* @param pszMsg 进度信息
|
||||
*/
|
||||
virtual void SetMessage(const char* pszMsg) = 0;
|
||||
|
||||
/**
|
||||
* @brief 设置进度值
|
||||
* @param dPosition 进度值
|
||||
* @return 返回是否取消的状态,true为不取消,false为取消
|
||||
*/
|
||||
virtual bool SetPosition(double dPosition) = 0;
|
||||
|
||||
/**
|
||||
* @brief 进度条前进一步,返回true表示继续,false表示取消
|
||||
* @return 返回是否取消的状态,true为不取消,false为取消
|
||||
*/
|
||||
virtual bool StepIt() = 0;
|
||||
|
||||
/**
|
||||
* @brief 设置进度个数
|
||||
* @param iStepCount 进度个数
|
||||
*/
|
||||
virtual void SetStepCount(int iStepCount)
|
||||
{
|
||||
ReSetProcess();
|
||||
m_iStepCount = iStepCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取进度信息
|
||||
* @return 返回当前进度信息
|
||||
*/
|
||||
string GetMessage()
|
||||
{
|
||||
return m_strMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取进度值
|
||||
* @return 返回当前进度值
|
||||
*/
|
||||
double GetPosition()
|
||||
{
|
||||
return m_dPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 重置进度条
|
||||
*/
|
||||
void ReSetProcess()
|
||||
{
|
||||
m_dPosition = 0.0;
|
||||
m_iStepCount = 100;
|
||||
m_iCurStep = 0;
|
||||
m_bIsContinue = true;
|
||||
}
|
||||
|
||||
/*! 进度信息 */
|
||||
string m_strMessage;
|
||||
/*! 进度值 */
|
||||
double m_dPosition;
|
||||
/*! 进度个数 */
|
||||
int m_iStepCount;
|
||||
/*! 进度当前个数 */
|
||||
int m_iCurStep;
|
||||
/*! 是否取消,值为false时表示计算取消 */
|
||||
bool m_bIsContinue;
|
||||
};
|
@ -1,333 +0,0 @@
|
||||
#include "DEM_GeneRas.h"
|
||||
|
||||
#include <qgsrasterlayer.h>
|
||||
#include <qgsvectorlayer.h>
|
||||
#include <qgsmapcanvas.h>
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
VegePredict::VegePredict()
|
||||
{
|
||||
//ui.setupUi(this);
|
||||
}
|
||||
|
||||
VegePredict::~VegePredict()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString VegePredict::PannelName()
|
||||
{
|
||||
return QString::fromLocal8Bit("");
|
||||
}
|
||||
|
||||
QString VegePredict::CategoryName()
|
||||
{
|
||||
return QString::fromLocal8Bit("DEM模块");
|
||||
}
|
||||
|
||||
QString VegePredict::EnglishName()
|
||||
{
|
||||
return QString::fromLocal8Bit("DEM_Module");
|
||||
}
|
||||
|
||||
QString VegePredict::ChineseName()
|
||||
{
|
||||
return QString::fromLocal8Bit("植被预测");
|
||||
}
|
||||
|
||||
QString VegePredict::Information()
|
||||
{
|
||||
return QString::fromLocal8Bit("植被预测");
|
||||
}
|
||||
|
||||
QString VegePredict::IconPath()
|
||||
{
|
||||
return ":/DEM_GeneRas/resources/dem_ras.svg";
|
||||
}
|
||||
|
||||
QWidget* VegePredict::CenterWidget()
|
||||
{
|
||||
//QString str = QString("%1->%2,thread id:%3").arg(__FILE__).arg(__FUNCTION__).arg((int)QThread::currentThreadId());
|
||||
//qDebug() << str;
|
||||
|
||||
QString gdal_path = qApp->applicationDirPath().toLocal8Bit() + "/share/gdal";
|
||||
QString pro_lib_path = qApp->applicationDirPath().toLocal8Bit() + "/share/proj";
|
||||
qputenv("GDAL_DATA", gdal_path.toLocal8Bit());
|
||||
qputenv("PROJ_LIB", pro_lib_path.toLocal8Bit());
|
||||
|
||||
bool showWin = false;
|
||||
if (myWidget == nullptr)
|
||||
{
|
||||
myWidget = new QDialog();
|
||||
showWin = true;
|
||||
qDebug() << "new QDialog()";
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "already have myWidget";
|
||||
//激活窗口并提升至顶层
|
||||
myWidget->activateWindow();
|
||||
myWidget->raise();
|
||||
|
||||
return myWidget;
|
||||
}
|
||||
ui.setupUi(myWidget);
|
||||
|
||||
myWidget->setWindowTitle(QString::fromLocal8Bit("植被预测"));
|
||||
myWidget->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
|
||||
myWidget->setWindowIcon(QIcon(":/DEM_GeneRas/resources/dem_ras.svg"));
|
||||
myWidget->setAttribute(Qt::WA_QuitOnClose, false);
|
||||
|
||||
myWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(myWidget, &QDialog::destroyed, this, [=]() {
|
||||
qDebug() << "----DEM Predict window close----";
|
||||
|
||||
QDir pluginsDir = QDir(qApp->applicationDirPath());
|
||||
if (pluginsDir.cd("srsplugins\\DemModel"))
|
||||
{
|
||||
QString strConfigPath = pluginsDir.absoluteFilePath("dem_config.ini");
|
||||
QFile f(strConfigPath);
|
||||
if (f.exists())
|
||||
{
|
||||
WriteConfigPaths(strConfigPath);
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (mWorkThread != nullptr)
|
||||
{
|
||||
mWorkThread->requestInterruption();//请求线程中断
|
||||
mWorkThread->quit();
|
||||
mWorkThread->wait();//调用wait后先调用finished信号对应的槽函数,执行完成后再往下走
|
||||
mWorker->on_cancel();
|
||||
mWorkThread = nullptr;//mWorkThread, &QThread::finished, mWorkThread, &QObject::deleteLater,不需要delete
|
||||
mWorker = nullptr;//mWorkThread, &QThread::finished, mWorker, &QObject::deleteLater
|
||||
}
|
||||
myWidget->close();
|
||||
myWidget = nullptr;
|
||||
//qDebug() << "--destroyed";
|
||||
});
|
||||
|
||||
connect(ui.pbt_DOM, &QPushButton::clicked, this, &VegePredict::chooseDomPath);
|
||||
connect(ui.pbt_DSM, &QPushButton::clicked, this, &VegePredict::chooseDsmPath);
|
||||
//connect(ui.pbt_Label, &QPushButton::pressed, this, &VegePredict::chooseLabelPath);
|
||||
connect(ui.pbt_PRE, &QPushButton::clicked, this, &VegePredict::choosePreDir);
|
||||
connect(ui.pbt_Moudle, &QPushButton::clicked, this, &VegePredict::chooseMouleFile);
|
||||
|
||||
connect(ui.pushButton_ok, &QPushButton::clicked, this, &VegePredict::readAndStart);
|
||||
connect(ui.pushButton_cancel, &QPushButton::clicked, this, &VegePredict::pbCancel);
|
||||
|
||||
ui.progressBar->setTextVisible(true);
|
||||
ui.progressBar->setRange(0, 100);
|
||||
|
||||
QFile qssFile(":/DEM_GeneRas/DEM_GeneRas.qss");
|
||||
qssFile.open(QFile::ReadOnly); //以只读方式打开
|
||||
if (qssFile.isOpen())
|
||||
{
|
||||
QString qss = QLatin1String(qssFile.readAll());
|
||||
myWidget->setStyleSheet(qss);
|
||||
qssFile.close();
|
||||
}
|
||||
else
|
||||
qDebug() << "无法打开文件";
|
||||
|
||||
QDir pluginsDir = QDir(qApp->applicationDirPath());
|
||||
if (pluginsDir.cd("srsplugins\\DemModel"))
|
||||
{
|
||||
QString strConfigPath = pluginsDir.absoluteFilePath("dem_config.ini");
|
||||
QFile f(strConfigPath);
|
||||
if (f.exists())
|
||||
{
|
||||
ReadConfigHistoryPaths(strConfigPath);
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (showWin)
|
||||
myWidget->show();
|
||||
|
||||
return myWidget;
|
||||
}
|
||||
|
||||
void VegePredict::startWorkThread()
|
||||
{
|
||||
if (mWorker != nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
mWorkThread = new QThread();
|
||||
mWorker = new WorkThreadObject();
|
||||
mWorker->moveToThread(mWorkThread);
|
||||
connect(mWorkThread, &QThread::finished, mWorkThread, &QObject::deleteLater);
|
||||
connect(mWorkThread, &QThread::finished, mWorker, &QObject::deleteLater);
|
||||
connect(mWorker, &WorkThreadObject::process, myWidget, [=](int value) {ui.progressBar->setValue(value); });
|
||||
connect(mWorker, &WorkThreadObject::addDataToMap, this, &VegePredict::addMap);
|
||||
connect(mWorker, &WorkThreadObject::addShpDataToMap, this, &VegePredict::openResultData);
|
||||
connect(this, &VegePredict::killChildThread, mWorker, &WorkThreadObject::on_cancel);
|
||||
connect(this, &VegePredict::startTiffToShp, mWorker, &WorkThreadObject::runFormatConvert);
|
||||
|
||||
connect(this, &VegePredict::start, mWorker, &WorkThreadObject::runPredictWork);
|
||||
mWorkThread->start();
|
||||
}
|
||||
|
||||
void VegePredict::chooseDomPath()
|
||||
{
|
||||
QString dirDom = QFileDialog::getExistingDirectory(ui.pbt_DOM, QString::fromLocal8Bit("选择输入DOM文件路径"), "");
|
||||
if (dirDom != "")
|
||||
ui.line_DOM->setText(dirDom);
|
||||
}
|
||||
|
||||
void VegePredict::chooseDsmPath()
|
||||
{
|
||||
QString dirDsm = QFileDialog::getExistingDirectory(ui.pbt_DSM, QString::fromLocal8Bit("选择输入Slope文件路径"), "");
|
||||
if (dirDsm != "")
|
||||
ui.line_DSM->setText(dirDsm);
|
||||
}
|
||||
|
||||
void VegePredict::choosePreDir()
|
||||
{
|
||||
QString dirPre = QFileDialog::getExistingDirectory(ui.pbt_PRE, QString::fromLocal8Bit("选择预测结果输出文件路径"), "");
|
||||
if (dirPre != "")
|
||||
ui.line_PRE->setText(dirPre);
|
||||
}
|
||||
|
||||
void VegePredict::chooseMouleFile()
|
||||
{
|
||||
QString dirPre = QFileDialog::getOpenFileName(ui.pbt_Moudle, QString::fromLocal8Bit("选择模型文件"), "", "*.pth");
|
||||
if (dirPre != "")
|
||||
ui.line_Moudle->setText(dirPre);
|
||||
}
|
||||
|
||||
void VegePredict::addMap()
|
||||
{
|
||||
QMessageBox mess(QMessageBox::NoIcon,
|
||||
QString::fromLocal8Bit("植被预测结束"),
|
||||
QString::fromLocal8Bit("将对如下路径中结果进行转矢量处理:\n") + ui.line_PRE->text(),
|
||||
QMessageBox::Ok, NULL);
|
||||
mess.setWindowFlags(Qt::Drawer);
|
||||
mess.setButtonText(QMessageBox::Ok, QString::fromLocal8Bit("确认"));
|
||||
int result = mess.exec();
|
||||
switch (result)
|
||||
{
|
||||
case QMessageBox::Ok:
|
||||
emit startTiffToShp(ui.line_PRE->text(), ui.line_DSM->text());
|
||||
ui.label_process->setText(QString::fromLocal8Bit("转矢量进度:"));
|
||||
ui.progressBar->setValue(0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void VegePredict::ReadConfigHistoryPaths(QString strPath)
|
||||
{
|
||||
QSettings configIni(strPath, QSettings::IniFormat);
|
||||
|
||||
//打开标题为:[DemPredict] 的组
|
||||
configIni.beginGroup("DemPredict");
|
||||
|
||||
ui.line_DOM->setText(configIni.value("SrcDom").toString());
|
||||
ui.line_DSM->setText(configIni.value("SrcDsm").toString());
|
||||
ui.line_PRE->setText(configIni.value("PredictResult").toString());
|
||||
|
||||
configIni.endGroup();//关闭组
|
||||
}
|
||||
void VegePredict::WriteConfigPaths(QString strPath)
|
||||
{
|
||||
QSettings configIni(strPath, QSettings::IniFormat);
|
||||
configIni.setIniCodec("utf-8");
|
||||
//打开标题为:[DemPredict] 的组
|
||||
configIni.beginGroup("DemPredict");
|
||||
|
||||
//更新输入DOM路径
|
||||
QString temp = ui.line_DOM->text();
|
||||
if (temp != "")
|
||||
configIni.setValue("SrcDom", temp);
|
||||
//更新输入DSM路径
|
||||
temp = ui.line_DSM->text();
|
||||
if (temp != "")
|
||||
configIni.setValue("SrcDsm", temp);
|
||||
//更新输出结果路径
|
||||
temp = ui.line_PRE->text();
|
||||
if (temp != "")
|
||||
configIni.setValue("PredictResult", temp);
|
||||
|
||||
configIni.endGroup();//关闭组
|
||||
}
|
||||
|
||||
void VegePredict::readAndStart()
|
||||
{
|
||||
QString dirDOM = ui.line_DOM->text();
|
||||
QString dirDSM = ui.line_DSM->text();
|
||||
QString dirPRE = ui.line_PRE->text();
|
||||
QString fileMoudle = ui.line_Moudle->text();
|
||||
|
||||
ui.progressBar->setValue(0);
|
||||
|
||||
if (dirDOM == "" || dirDSM == "" || dirPRE == "" || fileMoudle == "")
|
||||
{
|
||||
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("请检查输入输出文件或路径"));
|
||||
mess.setWindowFlags(Qt::Drawer);
|
||||
int result = mess.exec();
|
||||
return;
|
||||
}
|
||||
//startObjThread();
|
||||
if (mWorkThread == nullptr)
|
||||
{
|
||||
qDebug() << "--startThread";
|
||||
startWorkThread();
|
||||
}
|
||||
//std::function<void(int)>processCallback = [=](int val) {
|
||||
// ui.progressBar->setValue(val);
|
||||
// qDebug() << val << endl;
|
||||
//};//类间回调函数;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//emit startTiffToShp(ui.line_PRE->text(), ui.line_Label->text());
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
ui.label_process->setText(QString::fromLocal8Bit("预测进度:"));
|
||||
emit start(fileMoudle, dirDOM, dirDSM, dirPRE);//, processCallback
|
||||
}
|
||||
|
||||
void VegePredict::pbCancel()
|
||||
{
|
||||
delete myWidget;//调起&QDialog::destroyed
|
||||
}
|
||||
|
||||
void VegePredict::openResultData(QStringList string_list)
|
||||
{
|
||||
if (string_list.isEmpty())
|
||||
return;
|
||||
QgsRasterLayer* rastLayer;
|
||||
QgsVectorLayer* vecLayer;
|
||||
for each (QString layerPath in string_list)
|
||||
{
|
||||
QFileInfo fileInfo(layerPath);
|
||||
QString layerBaseName = fileInfo.baseName(); // 图层名称
|
||||
if ("tif" == fileInfo.suffix() || "tiff" == fileInfo.suffix())
|
||||
{
|
||||
rastLayer = new QgsRasterLayer(fileInfo.filePath(), layerPath, "gdal");
|
||||
if (!rastLayer)
|
||||
return;
|
||||
QgsMapLayer* mapLayer = rastLayer;
|
||||
QgsRectangle myRectangle;
|
||||
rastLayer->setContrastEnhancement(QgsContrastEnhancement::StretchToMinimumMaximum
|
||||
, QgsRasterMinMaxOrigin::StdDev, myRectangle);
|
||||
QList<QgsMapLayer*> mapLayers;
|
||||
mapLayers << mapLayer;
|
||||
QgsProject::instance()->addMapLayers(mapLayers);
|
||||
//zoomToSelectedLayer(mapLayer);
|
||||
}
|
||||
else if ("shp" == fileInfo.suffix())
|
||||
{
|
||||
vecLayer = new QgsVectorLayer(fileInfo.filePath(), layerPath);
|
||||
if (!vecLayer)
|
||||
return;
|
||||
QgsMapLayer* mapLayer = vecLayer;
|
||||
QList<QgsMapLayer*> mapLayers;
|
||||
mapLayers << mapLayer;
|
||||
QgsProject::instance()->addMapLayers(mapLayers);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/DEM_GeneRas">
|
||||
<file>resources/dem_ras.svg</file>
|
||||
<file>DEM_GeneRas.qss</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -1,73 +0,0 @@
|
||||
QProgressBar#progressBar {
|
||||
border:0px solid white;
|
||||
text-align:center;
|
||||
color:black;
|
||||
}
|
||||
QProgressBar#progressBar:chunk {
|
||||
background-color:#3FABBA;
|
||||
width:20px;
|
||||
}
|
||||
QProgressBar#progressBar QLineEdit {
|
||||
border:none;
|
||||
color:black;
|
||||
padding-left:5px;
|
||||
font-size:16px;
|
||||
background-color:transparent;
|
||||
}
|
||||
|
||||
QLabel{
|
||||
color:black;
|
||||
font-family:'Microsoft YaHei';
|
||||
font-size:12px;
|
||||
}
|
||||
|
||||
/*----QPushButtonÑùʽ±í*/
|
||||
#pushButton_ok, #pushButton_cancel, #pbt_DOM, #pbt_DSM ,
|
||||
#pbt_Label, #pbt_PRE, #pbt_Moudle {
|
||||
font-family:'Microsoft YaHei';
|
||||
font-size:12px;
|
||||
background-color: #ffffff;
|
||||
border: 1px solid #dcdfe6;
|
||||
padding: 2px;
|
||||
border-radius: 5px;
|
||||
max-height:20px;
|
||||
}
|
||||
#pushButton_ok, #pushButton_cancel{
|
||||
min-width:36px;
|
||||
}
|
||||
#pushButton_ok:hover, #pushButton_cancel:hover, #pbt_DOM:hover, #pbt_DSM:hover
|
||||
,#pbt_Label:hover, #pbt_PRE:hover, #pbt_Moudle:hover {
|
||||
background-color: #ecf5ff;
|
||||
color: #409eff;
|
||||
}
|
||||
#pushButton_ok:pressed, #pushButton_cancel:pressed, #pbt_DOM:pressed, #pbt_DSM:pressed
|
||||
,#pbt_Label:pressed, #pbt_PRE:pressed, #pbt_Moudle:pressed {
|
||||
border: 1px solid #3a8ee6;
|
||||
color: #409eff;
|
||||
}
|
||||
#pushButton_ok:checked, #pushButton_cancel:checked, #pbt_DOM:checked, #pbt_DSM:checked
|
||||
,#pbt_Label:checked, #pbt_PRE:checked, #pbt_Moudle:checked{
|
||||
border: 1px solid #3a8ee6;
|
||||
color: #409eff;
|
||||
}
|
||||
#pushButton_ok:focus, #pushButton_cancel:focus, #pbt_DOM:focus, #pbt_DSM:focus
|
||||
,#pbt_Label:focus, #pbt_PRE:focus, #pbt_Moudle:focus{
|
||||
border: 1px solid #3a8ee6;
|
||||
color: #409eff;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/*----QLineEditÑùʽ*/
|
||||
#line_DOM, #line_DSM, #line_Label, #line_PRE, #line_Moudle{
|
||||
border:0px;
|
||||
border-bottom: 1px solid #B3B3B3;
|
||||
font-family:'Microsoft YaHei';
|
||||
font-size:12px;
|
||||
background-color:transparent;
|
||||
}
|
||||
#line_DOM:hover, #line_DSM:hover, #line_Label:hover, #line_PRE:hover, #line_Moudle:hover{
|
||||
border-bottom: 2px solid #66A3FF;
|
||||
}
|
||||
#line_DOM:focus, #line_DSM:focus, #line_Label:focus, #line_PRE:focus, #line_Moudle:focus{
|
||||
border-bottom: 2px solid #7666FF;
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
#include "QtGDALProcessBar.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
|
||||
QtGDALProcessBar::QtGDALProcessBar(QWidget *parent)
|
||||
: QProgressBar(parent)
|
||||
{
|
||||
//ui.setupUi(this);
|
||||
this->setTextVisible(true);
|
||||
m_dPosition = 0.0;
|
||||
m_iStepCount = 100;
|
||||
m_iCurStep = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
QtGDALProcessBar::~QtGDALProcessBar()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 设置进度信息
|
||||
* @param pszMsg 进度信息
|
||||
*/
|
||||
void QtGDALProcessBar::SetMessage(const char* pszMsg)
|
||||
{
|
||||
if (pszMsg != NULL)
|
||||
{
|
||||
m_strMessage = pszMsg;
|
||||
//setLabelText(QString(pszMsg));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 设置进度值
|
||||
* @param dPosition 进度值
|
||||
*/
|
||||
bool QtGDALProcessBar::SetPosition(double dPosition)
|
||||
{
|
||||
m_dPosition = dPosition;
|
||||
//cout << "m_dPosition " << m_dPosition << endl;
|
||||
//current_value = value();
|
||||
int temp_value = int(m_start_value +std::min(100u, (uint)(m_dPosition * 100.0 )) * m_scale);
|
||||
|
||||
setValue(temp_value);
|
||||
//setFormat(tr("%1%").arg(temp_value));
|
||||
//cout << "StepIt " << temp_value << "\t" << "current_value" << int(m_start_value + temp_value * m_scale) << endl;
|
||||
//QCoreApplication::instance()->processEvents();
|
||||
//this->update();
|
||||
//if (this->wasCanceled())
|
||||
// return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QtGDALProcessBar::SetStartEndValue(int i_start_value, int i_end_value)
|
||||
{
|
||||
if (i_end_value< i_start_value )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_start_value = i_start_value;
|
||||
m_end_value = i_end_value;
|
||||
m_scale = (m_end_value - m_start_value) / 100.0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 进度条前进一步,返回false表示终止操作
|
||||
*/
|
||||
bool QtGDALProcessBar::StepIt()
|
||||
{
|
||||
m_iCurStep++;
|
||||
m_dPosition = m_iCurStep * 1.0 / m_iStepCount;
|
||||
//current_value = value();
|
||||
int temp_value = std::min(100u, (uint)(m_dPosition * 100.0));
|
||||
setValue(int(m_start_value + temp_value * m_scale));
|
||||
//setFormat(QString("当前进度为:%1%").arg(temp_value));
|
||||
//cout << "StepIt " << temp_value <<"\t"<<"current_value"<< current_value << endl;
|
||||
|
||||
//QCoreApplication::instance()->processEvents();
|
||||
|
||||
//if (this->wasCanceled())
|
||||
// return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QtGDALProcessBar::updateProgress(int step)
|
||||
{
|
||||
this->setValue(step);
|
||||
//this->update();
|
||||
//cout << "updateProgress " << step << endl;
|
||||
//QCoreApplication::instance()->processEvents();
|
||||
}
|
||||
|
||||
|
@ -1,62 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <QProgressBar>
|
||||
#include "CProcessBase.h"
|
||||
|
||||
class QtGDALProcessBar : public QProgressBar,public CProcessBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtGDALProcessBar(QWidget *parent = Q_NULLPTR);
|
||||
~QtGDALProcessBar();
|
||||
|
||||
/**
|
||||
* @brief 设置进度信息
|
||||
* @param pszMsg 进度信息
|
||||
*/
|
||||
void SetMessage(const char* pszMsg);
|
||||
|
||||
/**
|
||||
* @brief 设置进度值
|
||||
* @param dPosition 进度值
|
||||
*/
|
||||
bool SetPosition(double dPosition);
|
||||
|
||||
/// <summary>
|
||||
/// 设置进度条开始结束值
|
||||
/// </summary>
|
||||
/// <param name="i_start_value"></param>
|
||||
/// <returns></returns>
|
||||
bool SetStartEndValue(int i_start_value,int i_end_value);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 进度条前进一步
|
||||
*/
|
||||
bool StepIt();
|
||||
|
||||
/// <summary>
|
||||
/// 当前进度值
|
||||
/// </summary>
|
||||
int current_value;
|
||||
|
||||
|
||||
public slots:
|
||||
void updateProgress(int);
|
||||
|
||||
|
||||
private:
|
||||
/// <summary>
|
||||
/// 进度条开始值
|
||||
/// </summary>
|
||||
int m_start_value;
|
||||
|
||||
/// <summary>
|
||||
/// 进度条结束值
|
||||
/// </summary>
|
||||
int m_end_value;
|
||||
|
||||
float m_scale;
|
||||
|
||||
};
|
@ -1,117 +0,0 @@
|
||||
#include <QProcess>
|
||||
#include <QDir>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "DEM_GeneRas.h"
|
||||
#include "ThreadObject.h"
|
||||
|
||||
#include "im2shp.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
WorkThreadObject::WorkThreadObject(QObject* parent) :QObject(parent)
|
||||
{
|
||||
qRegisterMetaType<std::function<void(int)> >("std::function<void(int)>");
|
||||
}
|
||||
|
||||
WorkThreadObject::~WorkThreadObject()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WorkThreadObject::runPredictWork(QString Moudle, QString DOM, QString DSM, QString PRE)//, std::function<void(int)>func
|
||||
{
|
||||
QString str = QString("%1->%2,thread id:%3").arg(__FILE__).arg(__FUNCTION__).arg((int)QThread::currentThreadId());
|
||||
QDir pluginsDir = QDir(qApp->applicationDirPath());
|
||||
qDebug() << str << "----" << pluginsDir.currentPath();
|
||||
if (!pluginsDir.cd("models\\envs"))
|
||||
{
|
||||
qDebug() << "no folder models\\envs";
|
||||
return;
|
||||
}
|
||||
QString exeDirName = pluginsDir.absoluteFilePath("predict_4c_vegetation.exe");
|
||||
qDebug() << "----" << exeDirName;
|
||||
|
||||
QString model = " --model_path " + Moudle;
|
||||
QString dom_path = " --dom_path " + DOM + "/";
|
||||
QString dsm_path = " --dsm_path " + DSM + "/";
|
||||
QString pre_dir = " --pre_path " + PRE + "/";
|
||||
QString ss = exeDirName + model + dom_path + dsm_path + pre_dir;
|
||||
qDebug() << ss;
|
||||
QProcess* pProces = new QProcess(this);
|
||||
connect(pProces, SIGNAL(readyReadStandardOutput()), this, SLOT(on_read()));
|
||||
|
||||
pProces->start(ss);
|
||||
emit process(2);
|
||||
}
|
||||
|
||||
void WorkThreadObject::on_read()
|
||||
{
|
||||
mProces = (QProcess*)sender();
|
||||
QString output = QString::fromLocal8Bit(mProces->readAllStandardOutput());
|
||||
if (output.toFloat() > 0)
|
||||
{
|
||||
qDebug() << "exe out:" << output.toFloat();
|
||||
emit process(output.toFloat());
|
||||
if (output.toFloat() == 100.0)
|
||||
emit addDataToMap();
|
||||
}
|
||||
else
|
||||
qDebug() << "Unresolved exe out:" << output;
|
||||
}
|
||||
|
||||
void WorkThreadObject::runFormatConvert(QString pre_path, QString DSM)
|
||||
{
|
||||
QDir dir(pre_path);
|
||||
QStringList nameFilters;
|
||||
nameFilters << "*.tif" << "*.tiff";
|
||||
QStringList pre_tiff_files = dir.entryList(nameFilters, QDir::Files | QDir::Readable, QDir::Name);
|
||||
int list_len = pre_tiff_files.size();
|
||||
for (int i = 0; i < list_len; i++)
|
||||
{
|
||||
emit process(float(i) / float(list_len) * 95);
|
||||
qDebug() << "TiffToShp progress:" << float(i) / float(list_len) * 100;
|
||||
QString file_path = pre_path + "\\" + pre_tiff_files[i];
|
||||
QString dsm_path = DSM + "\\" + pre_tiff_files[i];
|
||||
string path_preTiff = file_path.toStdString();
|
||||
string pathPureName = path_preTiff.substr(0, path_preTiff.rfind("."));
|
||||
string shp_path = pathPureName + ".shp";
|
||||
//调起栅格转矢量
|
||||
img2shp cc;
|
||||
QtGDALProcessBar* gb = new QtGDALProcessBar();
|
||||
bool returnval = cc.ImagePolygonize(path_preTiff.c_str(), shp_path.c_str(), "ESRI Shapefile", 1, gb, gb);
|
||||
if (returnval == true)
|
||||
{
|
||||
QStringList list;
|
||||
list << dsm_path << QString::fromStdString(shp_path);
|
||||
emit addShpDataToMap(list);
|
||||
}
|
||||
else
|
||||
{
|
||||
//QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("请检查输入数据"));
|
||||
//mess.setWindowFlags(Qt::Drawer);
|
||||
//int result = mess.exec();
|
||||
//return;
|
||||
}
|
||||
}
|
||||
emit process(100);
|
||||
}
|
||||
|
||||
void WorkThreadObject::on_cancel()
|
||||
{
|
||||
if (mProces == nullptr)
|
||||
{
|
||||
qDebug() << "--mProces null";
|
||||
}
|
||||
else
|
||||
{
|
||||
//py打包exe文件名
|
||||
QString KillStr = "taskkill /f /im predict_4c_vegetation.exe";
|
||||
mProces->startDetached(KillStr);
|
||||
qDebug() << "--kill Proces";
|
||||
}
|
||||
}
|
@ -1,154 +0,0 @@
|
||||
#include "im2shp.h"
|
||||
#include <ogrsf_frmts.h>
|
||||
#include "CProcessBase.h"
|
||||
/**
|
||||
* \brief 调用GDAL进度条接口
|
||||
*
|
||||
* 该函数用于将GDAL算法中的进度信息导出到CProcessBase基类中,供给界面显示
|
||||
*
|
||||
* @param dfComplete 完成进度值,其取值为 0.0 到 1.0 之间
|
||||
* @param pszMessage 进度信息
|
||||
* @param pProgressArg CProcessBase的指针
|
||||
*
|
||||
* @return 返回TRUE表示继续计算,否则为取消
|
||||
*/
|
||||
int STD_API ALGTermProgress(double dfComplete, const char* pszMessage, void* pProgressArg)
|
||||
{
|
||||
if (pProgressArg != NULL)
|
||||
{
|
||||
QtGDALProcessBar* pProcess = (QtGDALProcessBar*)pProgressArg;
|
||||
pProcess->m_bIsContinue = pProcess->SetPosition(dfComplete);
|
||||
|
||||
if (pProcess->m_bIsContinue)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
int img2shp::ImagePolygonize(const char* pszSrcFile, const char* pszDstFile, const char* pszFormat, int BandNum,
|
||||
QtGDALProcessBar* probar, QProgressBar* progressBar)
|
||||
{
|
||||
if (NULL == pszSrcFile || NULL == pszDstFile)
|
||||
{
|
||||
printf("待处理的栅格数据及输出矢量数据数据无效!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (GDALGetDriverCount() == 0)
|
||||
GDALAllRegister();
|
||||
OGRRegisterAll();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
|
||||
CPLSetConfigOption("SHAPE_ENCODING", "gb2312");
|
||||
|
||||
//打开输入图像,并判断是否正常
|
||||
GDALDataset* poSrcDS = (GDALDataset*)GDALOpen(pszSrcFile, GA_ReadOnly);
|
||||
if (NULL == poSrcDS)
|
||||
{
|
||||
printf("输入文件不能打开,请检查文件是否存在!");
|
||||
return false;
|
||||
}
|
||||
|
||||
//构造矢量文件驱动并创建矢量图层
|
||||
GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat);
|
||||
if (NULL == poDriver)
|
||||
{
|
||||
printf("不能创建指定类型的矢量文件驱动!");
|
||||
GDALClose((GDALDatasetH)poSrcDS);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*Create方法主要用于创建栅格文件的新数据集,其中nXSize,nYSize,nBands,都是对栅格文件的描述,**都置零后台会默认创建矢量数据集**
|
||||
*/
|
||||
//根据文件名创建输出矢量数据集
|
||||
|
||||
GDALDataset* poDstDs = poDriver->Create(pszDstFile, 0, 0, 0, GDT_Unknown, NULL);
|
||||
if (NULL == poDstDs)
|
||||
{
|
||||
printf("不能创建矢量文件!");
|
||||
GDALClose((GDALDatasetH)poSrcDS);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
OGRSpatialReference* poSpatialRef = new OGRSpatialReference(poSrcDS->GetProjectionRef());
|
||||
|
||||
OGRLayer* poLayer = poDstDs->CreateLayer("Target", poSpatialRef, wkbPolygon, NULL);
|
||||
if (NULL == poLayer)
|
||||
{
|
||||
printf("创建矢量图层失败!");
|
||||
GDALClose((GDALDatasetH)poSrcDS);
|
||||
GDALClose(poDstDs);
|
||||
poSpatialRef = NULL;
|
||||
|
||||
return false;
|
||||
}
|
||||
OGRFieldDefn ofieldDef("value", OFTInteger);
|
||||
if (OGRERR_NONE != poLayer->CreateField(&ofieldDef))
|
||||
{
|
||||
printf("创建矢量图层属性表失败!");
|
||||
GDALClose((GDALDatasetH)poSrcDS);
|
||||
GDALClose(poDstDs);
|
||||
poSpatialRef = NULL;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取图像的对应波段
|
||||
GDALRasterBandH hSrcBand = (GDALRasterBandH)poSrcDS->GetRasterBand(1);
|
||||
|
||||
GDALRasterBand* rasterband = poSrcDS->GetRasterBand(1);
|
||||
|
||||
GDALProgressFunc pfnProgress = ALGTermProgress;
|
||||
|
||||
if (!probar->SetStartEndValue(0, 100))
|
||||
{
|
||||
cout << "初始进度值设置失败!!!" << endl;
|
||||
}
|
||||
|
||||
|
||||
//if (GDALPolygonize(hSrcBand, NULL, (OGRLayerH)poLayer, 0, NULL, pfnProgress, probar) != CE_None)
|
||||
//if (GDALPolygonize(hSrcBand, NULL, (OGRLayerH)poLayer, 0, NULL, GDALTermProgress, NULL) != CE_None)
|
||||
//qDebug() << rasterband->GetNoDataValue() << endl;
|
||||
//if (0.0 == poSrcDS->GetRasterBand(1)->GetNoDataValue())
|
||||
//{
|
||||
// if (CE_None != GDALPolygonize(hSrcBand, hSrcBand, (OGRLayerH)poLayer, 0, NULL, pfnProgress, probar))
|
||||
// {
|
||||
// GDALClose((GDALDatasetH)poSrcDS);
|
||||
// GDALClose(poDstDs);
|
||||
// delete poSpatialRef;
|
||||
// poSpatialRef = NULL;
|
||||
// return 0;
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// if (CE_None != GDALPolygonize(hSrcBand, NULL, (OGRLayerH)poLayer, 0, NULL, pfnProgress, probar))
|
||||
// {
|
||||
// GDALClose((GDALDatasetH)poSrcDS);
|
||||
// GDALClose(poDstDs);
|
||||
// delete poSpatialRef;
|
||||
// poSpatialRef = NULL;
|
||||
// return 0;
|
||||
// }
|
||||
//}
|
||||
if (CE_None != GDALPolygonize(hSrcBand, hSrcBand, (OGRLayerH)poLayer, 0, NULL, pfnProgress, probar))
|
||||
{
|
||||
GDALClose((GDALDatasetH)poSrcDS);
|
||||
GDALClose(poDstDs);
|
||||
delete poSpatialRef;
|
||||
poSpatialRef = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
GDALClose((GDALDatasetH)poSrcDS);
|
||||
GDALClose(poDstDs);
|
||||
poSpatialRef = NULL;
|
||||
|
||||
return true;
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
#include "gdal_priv.h"
|
||||
#include "ogrsf_frmts.h" //for ogr
|
||||
#include "gdal_alg.h" //for GDALPolygonize
|
||||
#include "cpl_conv.h" //for CPLMalloc()
|
||||
#include "QtGDALProcessBar.h"
|
||||
#include <QDebug>
|
||||
/**
|
||||
* @brief 导出符号定义
|
||||
*/
|
||||
#ifndef STD_API
|
||||
#define STD_API __stdcall
|
||||
#endif
|
||||
/**
|
||||
* \brief 调用GDAL进度条接口
|
||||
*
|
||||
* 该函数用于将GDAL算法中的进度信息导出到CProcessBase基类中,供给界面显示
|
||||
*
|
||||
* @param dfComplete 完成进度值,其取值为 0.0 到 1.0 之间
|
||||
* @param pszMessage 进度信息
|
||||
* @param pProgressArg CProcessBase的指针
|
||||
*
|
||||
* @return 返回TRUE表示继续计算,否则为取消
|
||||
*/
|
||||
int STD_API ALGTermProgress(double dfComplete, const char* pszMessage, void* pProgressArg);
|
||||
|
||||
class img2shp
|
||||
{
|
||||
public:
|
||||
int ImagePolygonize(const char* pszSrcFile, const char* pszDstFile, const char* pszFormat, int BandNum, QtGDALProcessBar* probar, QProgressBar* progressBar);
|
||||
bool createChineseStringProperty(OGRLayer* poLayer, const char* filterFieldName, const char* createFieldName, vector<string> nameVal, float min, QProgressBar* progressBar);
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
|
@ -1,16 +0,0 @@
|
||||
#include "DEM_GeneRas.h"
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
QString gdal_path = qApp->applicationDirPath().toLocal8Bit() + "/share/gdal";
|
||||
QString pro_lib_path = qApp->applicationDirPath().toLocal8Bit() + "/share/proj";
|
||||
qputenv("GDAL_DATA", gdal_path.toLocal8Bit());
|
||||
qputenv("PROJ_LIB", pro_lib_path.toLocal8Bit());
|
||||
|
||||
VegePredict w;
|
||||
w.CenterWidget()->show();
|
||||
return a.exec();
|
||||
}
|
@ -1 +0,0 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1640758642809" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10193" xmlns:xlink="http://www.w3.org/1999/xlink" width="26" height="26"><defs><style type="text/css"></style></defs><path d="M633.417143 542.281143c-78.774857 0-142.848-52.736-142.848-117.613714 0-64.804571 64.073143-117.686857 142.848-117.686858s142.921143 52.809143 142.921143 117.76c0 64.877714-64.073143 117.540571-142.921143 117.540572z m0-172.397714c-43.958857 0-81.115429 25.161143-81.115429 54.857142s37.156571 54.784 81.188572 54.784c43.885714 0 81.042286-25.088 81.042285-54.857142 0-29.622857-37.083429-54.857143-81.115428-54.857143zM342.528 1024c-4.461714-106.569143 54.637714-293.302857 146.651429-390.948571 41.837714-44.397714 86.528-66.998857 132.681142-66.998858h64.365715c74.605714 0 135.314286-63.488 135.314285-141.385142s-60.708571-141.312-135.314285-141.312H590.994286c-74.605714 0-135.241143 63.414857-135.241143 141.312-9.362286 405.796571-400.091429 553.691429-404.114286 555.154285l-20.992-59.099428c14.482286-5.339429 354.889143-135.387429 363.300572-496.786286 0-111.908571 88.356571-203.483429 196.973714-203.483429h95.305143c108.617143 0 196.973714 91.574857 196.973714 204.141715 0 112.64-88.356571 204.214857-196.973714 204.214857h-64.365715c-28.672 0-58.294857 16.018286-88.064 47.616-78.994286 83.748571-133.485714 251.099429-129.536 344.795428L342.528 1024z m139.044571-0.146286C472.576 790.308571 559.689143 645.851429 714.605714 637.513143v-0.073143c131.072 0 240.274286-112.64 241.371429-246.272-16.749714-120.173714-97.645714-196.754286-247.369143-233.618286-43.446857-10.752-115.931429-10.971429-116.662857-10.971428-129.462857 0-230.765714 106.934857-230.765714 243.492571 0 343.698286-344.502857 423.862857-348.013715 424.667429L0 753.371429c12.214857-2.706286 299.373714-70.656 299.373714-363.227429 0-171.812571 128.585143-306.322286 292.571429-306.322286 3.291429 0 80.603429 0.146286 131.218286 12.653715 175.762286 43.446857 274.724571 140.507429 294.326857 288.475428l0.292571 4.169143c0 168.448-137.508571 310.710857-300.470857 311.149714-172.617143 9.728-176.786286 248.173714-174.006857 321.097143l-61.732572 2.486857zM6.582857 628.297143c60.416 0 204.653714-38.4 236.909714-394.24l0.731429-4.534857c24.868571-104.155429 95.744-228.205714 291.108571-228.205715 20.333714 0 270.482286-1.316571 270.482286-1.316571l5.558857 0.438857c6.582857 1.243429 161.792 30.866286 212.626286 162.157714l-57.490286 23.04C931.181714 94.354286 820.955429 66.779429 802.962286 62.829714c-28.964571 0.146286-248.685714 1.389714-266.678857 1.389715-46.811429-0.146286-187.684571 0-231.497143 178.029714C267.337143 647.314286 83.894857 691.126857 6.582857 691.126857V628.297143z m2.048-85.942857h-3.657143l3.218286-62.756572h0.877714c26.038857 0 102.107429-55.881143 129.243429-242.468571C156.306286 113.810286 217.088 60.562286 253.44 28.818286c7.314286-6.363429 16.384-14.336 18.285714-17.554286a13.165714 13.165714 0 0 0-1.316571 6.217143h61.732571c0 25.234286-18.651429 41.691429-38.4 58.88-31.744 27.794286-79.725714 69.778286-94.281143 169.984C167.570286 464.896 69.339429 542.354286 8.630857 542.354286z m660.918857 480.256h-61.805714c0-152.429714 67.291429-334.116571 387.510857-334.116572v62.829715c-219.209143 0-325.705143 88.795429-325.705143 271.36z m160.914286 0h-61.805714c0-123.684571 17.261714-235.373714 225.353143-243.931429l2.56 62.756572c-158.427429 6.509714-166.107429 69.851429-166.107429 181.174857z m123.611429 0h-61.805715c0-127.780571 78.848-137.654857 102.985143-137.654857v62.756571c-10.24 0-41.179429 0-41.179428 74.898286z" p-id="10194" fill="#2c2c2c"></path></svg>
|
Before Width: | Height: | Size: 3.7 KiB |
51
DEM_GeneVec/CProgressBar.cpp
Normal file
51
DEM_GeneVec/CProgressBar.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
#include "CProgressBar.h"
|
||||
|
||||
CProgressBar::CProgressBar(QWidget* parent) : QProgressBar(parent)
|
||||
{
|
||||
//this->setStyleSheet(
|
||||
// "QProgressBar {color:black;font-size:12px;font-weight:normal;font-family:'Microsoft YaHei'; text-align:center; }"
|
||||
// "QProgressBar::chunk {background-color: rgb(0, 160, 244);}");
|
||||
}
|
||||
|
||||
void CProgressBar::ShowTips(const QString& strTips)
|
||||
{
|
||||
if (this->isHidden())
|
||||
{
|
||||
this->show();
|
||||
}
|
||||
|
||||
this->resetFormat();
|
||||
this->setRange(0, 100);
|
||||
this->setFormat(strTips);
|
||||
this->setValue(100);
|
||||
}
|
||||
|
||||
double CProgressBar::GetDoubleFormatValue()
|
||||
{
|
||||
double dValue = 0.0;
|
||||
|
||||
QString strFormat = this->format();
|
||||
if (!strFormat.isEmpty())
|
||||
{
|
||||
int nIndex = strFormat.indexOf(":");
|
||||
if (nIndex != -1)
|
||||
{
|
||||
QString strFormatData = strFormat.mid(nIndex + 1, strFormat.length() - nIndex - 2);
|
||||
dValue = strFormatData.toDouble();
|
||||
}
|
||||
}
|
||||
|
||||
return dValue;
|
||||
}
|
||||
|
||||
void CProgressBar::SetDoubleFormatValue(const QString& strFormat, double dValue)
|
||||
{
|
||||
if (this->isHidden())
|
||||
{
|
||||
this->show();
|
||||
}
|
||||
|
||||
this->setFormat(strFormat + ":" + QString::number(dValue, 'f', 2) + "%");
|
||||
this->setValue(dValue);
|
||||
}
|
||||
|
18
DEM_GeneVec/CProgressBar.h
Normal file
18
DEM_GeneVec/CProgressBar.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include<QProgressBar>
|
||||
|
||||
class CProgressBar : public QProgressBar
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CProgressBar(QWidget* parent = 0);
|
||||
~CProgressBar() {}
|
||||
|
||||
public:
|
||||
void ShowTips(const QString& strTips);
|
||||
|
||||
void SetDoubleFormatValue(const QString& strFormat, double dValue);
|
||||
|
||||
double GetDoubleFormatValue();
|
||||
};
|
425
DEM_GeneVec/DEM_GeneVec.cpp
Normal file
425
DEM_GeneVec/DEM_GeneVec.cpp
Normal file
@ -0,0 +1,425 @@
|
||||
#include "DEM_GeneVec.h"
|
||||
#include<windows.h>
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
TrainMoudle::TrainMoudle()
|
||||
{
|
||||
//ui.setupUi(this);
|
||||
}
|
||||
|
||||
TrainMoudle::~TrainMoudle()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString TrainMoudle::PannelName()
|
||||
{
|
||||
return QString::fromLocal8Bit("");
|
||||
}
|
||||
|
||||
QString TrainMoudle::CategoryName()
|
||||
{
|
||||
return QString::fromLocal8Bit("DEM模块");
|
||||
}
|
||||
|
||||
QString TrainMoudle::EnglishName()
|
||||
{
|
||||
return QString::fromLocal8Bit("DEM_Module");
|
||||
}
|
||||
|
||||
QString TrainMoudle::ChineseName()
|
||||
{
|
||||
return QString::fromLocal8Bit("模型构建");
|
||||
}
|
||||
|
||||
QString TrainMoudle::Information()
|
||||
{
|
||||
return QString::fromLocal8Bit("模型构建");
|
||||
}
|
||||
|
||||
QString TrainMoudle::IconPath()
|
||||
{
|
||||
return ":/DEM_GeneVec/resources/dem_vec.svg";
|
||||
}
|
||||
|
||||
QWidget* TrainMoudle::CenterWidget()
|
||||
{
|
||||
QString gdal_path = qApp->applicationDirPath().toLocal8Bit() + "/share/gdal";
|
||||
QString pro_lib_path = qApp->applicationDirPath().toLocal8Bit() + "/share/proj";
|
||||
qputenv("GDAL_DATA", gdal_path.toLocal8Bit());
|
||||
qputenv("PROJ_LIB", pro_lib_path.toLocal8Bit());
|
||||
|
||||
bool showWin = false;
|
||||
if (myWidget == nullptr)
|
||||
{
|
||||
myWidget = new QDialog();
|
||||
showWin = true;
|
||||
qDebug() << "new QDialog()";
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "already have myWidget";
|
||||
myWidget->activateWindow();
|
||||
myWidget->raise();
|
||||
return myWidget;
|
||||
}
|
||||
ui.setupUi(myWidget);
|
||||
|
||||
myWidget->setWindowTitle(QString::fromLocal8Bit("模型构建"));
|
||||
myWidget->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
|
||||
myWidget->setWindowIcon(QIcon(":/DEM_GeneVec/resources/dem_vec.svg"));
|
||||
myWidget->setAttribute(Qt::WA_QuitOnClose, false);
|
||||
|
||||
myWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(myWidget, &QDialog::destroyed, this, [=] {
|
||||
qDebug() << "----DEM train window close----";
|
||||
|
||||
QDir pluginsDir = QDir(qApp->applicationDirPath());
|
||||
if (pluginsDir.cd("srsplugins\\DemModel"))
|
||||
{
|
||||
QString strConfigPath = pluginsDir.absoluteFilePath("dem_config.ini");
|
||||
QFile f(strConfigPath);
|
||||
if (f.exists())
|
||||
{
|
||||
WriteConfigPaths(strConfigPath);
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (mThread != nullptr)
|
||||
{
|
||||
mThread->requestInterruption();//请求线程中断
|
||||
mThread->quit();
|
||||
mThread->wait();//调用wait后先调用finished信号对应的槽函数,执行完成后再往下走
|
||||
mWorkObject->on_cancel();
|
||||
mThread = nullptr;//m_objThread, &QThread::finished, m_objThread, &QObject::deleteLater,不需要delete
|
||||
mWorkObject = nullptr;//m_objThread, &QThread::finished, m_obj, &QObject::deleteLater
|
||||
}
|
||||
myWidget->close();
|
||||
myWidget = nullptr;
|
||||
});
|
||||
connect(ui.pbtInModel, &QPushButton::pressed, this, &TrainMoudle::choseInModel);
|
||||
connect(ui.pbtInDom, &QPushButton::pressed, this, &TrainMoudle::choseInDom);
|
||||
connect(ui.pbtInDsm, &QPushButton::pressed, this, &TrainMoudle::choseInDsm);
|
||||
connect(ui.pbtInLabel, &QPushButton::pressed, this, &TrainMoudle::choseInLabel);
|
||||
connect(ui.pbtOutModel, &QPushButton::pressed, this, &TrainMoudle::choseOutModel);
|
||||
|
||||
connect(ui.pushButton_ok, &QPushButton::pressed, this, &TrainMoudle::readAndStart);
|
||||
connect(ui.pushButton_cancel, &QPushButton::pressed, this, &TrainMoudle::pbCancel);
|
||||
|
||||
connect(ui.checkBoxMid, &QCheckBox::clicked, this, [=](bool checked) {
|
||||
executeMid = checked;
|
||||
if (!executeMid && !executeTrain)
|
||||
ui.pushButton_ok->setEnabled(false);
|
||||
else
|
||||
ui.pushButton_ok->setEnabled(true);
|
||||
});
|
||||
connect(ui.checkBoxTrain, &QCheckBox::clicked, this, [=](bool checked) {
|
||||
executeTrain = checked;
|
||||
if (!executeMid && !executeTrain)
|
||||
ui.pushButton_ok->setEnabled(false);
|
||||
else
|
||||
ui.pushButton_ok->setEnabled(true);
|
||||
});
|
||||
|
||||
ui.progressBar->setTextVisible(true);
|
||||
ui.progressBar->setRange(0, 100);
|
||||
|
||||
ui.lineEpoch1->setValidator(new QIntValidator(0, 999, this));
|
||||
ui.lineEpoch2->setValidator(new QIntValidator(0, 999, this));
|
||||
ui.lineEpoch1->setText("100");
|
||||
ui.lineEpoch2->setText("100");
|
||||
|
||||
ui.pbtInModel->setFocus();
|
||||
|
||||
QFile qssFile(":/DEM_GeneVec/DEM_GeneVec.qss");
|
||||
qssFile.open(QFile::ReadOnly); //以只读方式打开
|
||||
if (qssFile.isOpen())
|
||||
{
|
||||
QString qss = QLatin1String(qssFile.readAll());
|
||||
myWidget->setStyleSheet(qss);
|
||||
qssFile.close();
|
||||
}
|
||||
else
|
||||
qDebug() << "无法打开文件";
|
||||
|
||||
QDir pluginsDir = QDir(qApp->applicationDirPath());
|
||||
if (pluginsDir.cd("srsplugins\\DemModel"))
|
||||
{
|
||||
QString strConfigPath = pluginsDir.absoluteFilePath("dem_config.ini");
|
||||
QFile f(strConfigPath);
|
||||
if (f.exists())
|
||||
{
|
||||
ReadConfigHistoryPaths(strConfigPath);
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (showWin)
|
||||
myWidget->show();
|
||||
|
||||
return myWidget;
|
||||
}
|
||||
|
||||
void TrainMoudle::startWorkThread()
|
||||
{
|
||||
if (mWorkObject != nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
mThread = new QThread();
|
||||
mWorkObject = new WorkThreadObject();
|
||||
mWorkObject->moveToThread(mThread);
|
||||
connect(mThread, &QThread::finished, mThread, &QObject::deleteLater);
|
||||
connect(mThread, &QThread::finished, mWorkObject, &QObject::deleteLater);
|
||||
connect(mWorkObject, &WorkThreadObject::process, myWidget, [=](double val) {ui.progressBar->SetDoubleFormatValue(QString::fromLocal8Bit("进度"), val); });
|
||||
connect(mWorkObject, &WorkThreadObject::addDataToMap, this, &TrainMoudle::addMap);
|
||||
//connect(this, &TrainMoudle::killChildThread, mWorkObject, &WorkThreadObject::on_cancel);
|
||||
|
||||
connect(this, &TrainMoudle::start, mWorkObject, &WorkThreadObject::runTrainWork);
|
||||
mThread->start();
|
||||
}
|
||||
//pbtDataset
|
||||
//pbtValName
|
||||
//pbtOutModel
|
||||
void TrainMoudle::choseInModel()
|
||||
{
|
||||
QString inModel = QFileDialog::getOpenFileName(ui.pbtInModel, QString::fromLocal8Bit("选择输入模型文件路径"), "", "*.pth");
|
||||
if (inModel != "")
|
||||
ui.lineInModel->setText(inModel);
|
||||
}
|
||||
void TrainMoudle::choseInDom()
|
||||
{
|
||||
QString dataset = QFileDialog::getExistingDirectory(ui.pbtInDom, QString::fromLocal8Bit("选择输入DOM文件路径"), "");
|
||||
if (dataset != "")
|
||||
ui.lineInDom->setText(dataset);
|
||||
}
|
||||
void TrainMoudle::choseInDsm()
|
||||
{
|
||||
QString valName = QFileDialog::getExistingDirectory(ui.pbtInDsm, QString::fromLocal8Bit("选择输入Slope文件路径"), "");
|
||||
if (valName != "")
|
||||
ui.lineInDsm->setText(valName);
|
||||
}
|
||||
void TrainMoudle::choseInLabel()
|
||||
{
|
||||
QString valName = QFileDialog::getExistingDirectory(ui.pbtInLabel, QString::fromLocal8Bit("选择输入Label文件路径"), "");
|
||||
if (valName != "")
|
||||
ui.lineInLabel->setText(valName);
|
||||
}
|
||||
void TrainMoudle::choseOutModel()
|
||||
{
|
||||
QString outModel = QFileDialog::getExistingDirectory(ui.pbtOutModel, QString::fromLocal8Bit("选择输出模型文件路径"), "");
|
||||
if (outModel != "")
|
||||
ui.lineOutModel->setText(outModel);
|
||||
}
|
||||
|
||||
void TrainMoudle::ReadConfigHistoryPaths(QString strPath)
|
||||
{
|
||||
QSettings configIni(strPath, QSettings::IniFormat);
|
||||
|
||||
//打开标题为:[DemTrain] 的组,并读取出port字段的值
|
||||
configIni.beginGroup("DemTrain");
|
||||
|
||||
ui.lineInModel->setText(configIni.value("RetrainModel").toString());
|
||||
ui.lineInDom->setText(configIni.value("SrcDom").toString());
|
||||
ui.lineInDsm->setText(configIni.value("SrcDsm").toString());
|
||||
ui.lineInLabel->setText(configIni.value("SrcLabel").toString());
|
||||
ui.lineOutModel->setText(configIni.value("TrainResult").toString());
|
||||
|
||||
configIni.endGroup();//关闭组
|
||||
}
|
||||
|
||||
void TrainMoudle::WriteConfigPaths(QString strPath)
|
||||
{
|
||||
QSettings configIni(strPath, QSettings::IniFormat);
|
||||
configIni.setIniCodec("utf-8");
|
||||
//打开标题为:[DemTrain] 的组
|
||||
configIni.beginGroup("DemTrain");
|
||||
|
||||
//更新输入模型路径
|
||||
QString temp = ui.lineInModel->text();
|
||||
if (temp != "")
|
||||
configIni.setValue("RetrainModel", temp);
|
||||
//更新输入DOM路径
|
||||
temp = ui.lineInDom->text();
|
||||
if (temp != "")
|
||||
configIni.setValue("SrcDom", temp);
|
||||
//更新输入DSM路径
|
||||
temp = ui.lineInDsm->text();
|
||||
if (temp != "")
|
||||
configIni.setValue("SrcDsm", temp);
|
||||
//更新输入Label路径
|
||||
temp = ui.lineInLabel->text();
|
||||
if (temp != "")
|
||||
configIni.setValue("SrcLabel", temp);
|
||||
//更新输出结果路径
|
||||
temp = ui.lineOutModel->text();
|
||||
if (temp != "")
|
||||
configIni.setValue("TrainResult", temp);
|
||||
|
||||
configIni.endGroup();//关闭组
|
||||
}
|
||||
|
||||
void TrainMoudle::addMap()
|
||||
{
|
||||
QMessageBox mess(QMessageBox::NoIcon,
|
||||
QString::fromLocal8Bit("运行结束"),
|
||||
QString::fromLocal8Bit("结果文件生成路径\n") + ui.lineOutModel->text(),
|
||||
QMessageBox::Ok, NULL);
|
||||
mess.setWindowFlags(Qt::Drawer);
|
||||
mess.setButtonText(QMessageBox::Ok, QString::fromLocal8Bit("确认"));
|
||||
int result = mess.exec();
|
||||
//switch (result)
|
||||
//{
|
||||
//case QMessageBox::Ok:
|
||||
// //string_list.append(ui.lineEdit_outras->text());
|
||||
// //string_list.append(ui.lineEdit_outshp->text());
|
||||
// //qDebug() << "----Yes:" << string_list;
|
||||
// //openResultData(string_list);
|
||||
// //emit addDataToCanvas(string_list);
|
||||
// break;
|
||||
//default:
|
||||
// break;
|
||||
//}
|
||||
pbCancel();
|
||||
}
|
||||
|
||||
void TrainMoudle::readAndStart()
|
||||
{
|
||||
QString inModel = ui.lineInModel->text();
|
||||
QString inDOM = ui.lineInDom->text();
|
||||
QString inDSM = ui.lineInDsm->text();
|
||||
QString inLabel = ui.lineInLabel->text();
|
||||
QString outModel = ui.lineOutModel->text();
|
||||
|
||||
ui.progressBar->SetDoubleFormatValue(QString::fromLocal8Bit("进度"), 0);
|
||||
|
||||
if (inModel == "" || inDOM == "" || inDSM == "" || inLabel == "" || outModel == "")
|
||||
{
|
||||
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("请检查输入输出文件夹或数据"));
|
||||
mess.setWindowFlags(Qt::Drawer);
|
||||
int result = mess.exec();
|
||||
return;
|
||||
}
|
||||
QDir inDOMdir(inDOM);
|
||||
if (!inDOMdir.exists())
|
||||
{
|
||||
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("DOM文件夹不存在"));
|
||||
mess.setWindowFlags(Qt::Drawer);
|
||||
int result = mess.exec();
|
||||
return;
|
||||
}
|
||||
QDir inDSMdir(inDSM);
|
||||
if (!inDSMdir.exists())
|
||||
{
|
||||
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("Slope文件夹不存在"));
|
||||
mess.setWindowFlags(Qt::Drawer);
|
||||
int result = mess.exec();
|
||||
return;
|
||||
}
|
||||
QDir inLabeldir(inLabel);
|
||||
if (!inLabeldir.exists())
|
||||
{
|
||||
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("Label文件夹不存在"));
|
||||
mess.setWindowFlags(Qt::Drawer);
|
||||
int result = mess.exec();
|
||||
return;
|
||||
}
|
||||
QDir outModeldir(outModel);
|
||||
if (!outModeldir.exists())
|
||||
{
|
||||
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("模型输出文件夹不存在"));
|
||||
mess.setWindowFlags(Qt::Drawer);
|
||||
int result = mess.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
if (executeMid && executeTrain)
|
||||
qDebug() << "executeMid & executeTrain";
|
||||
if (executeMid && (!executeTrain))
|
||||
qDebug() << "executeMid, not executeTrain";
|
||||
if ((!executeMid) && executeTrain)
|
||||
{
|
||||
//判断train文件夹下有无训练集文件夹
|
||||
QDir dirImage(outModel + "/Images");
|
||||
QDir dirLabel(outModel + "/Labels");
|
||||
if (!dirImage.exists() || !dirLabel.exists())
|
||||
{
|
||||
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"),
|
||||
QString::fromLocal8Bit("未找到训练集文件夹\n确保Images和Labels在以下路径中: \n") + outModel);
|
||||
mess.setWindowFlags(Qt::Drawer);
|
||||
int result = mess.exec();
|
||||
return;
|
||||
}
|
||||
//判断文件是否匹配
|
||||
QStringList imgList = getAllFiles(outModel + "/Images", "tif");
|
||||
QStringList labelList = getAllFiles(outModel + "/Labels", "tif");
|
||||
if (imgList.size() == 0 || labelList.size() == 0)
|
||||
{
|
||||
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"),
|
||||
QString::fromLocal8Bit("训练集文件夹内为空"));
|
||||
mess.setWindowFlags(Qt::Drawer);
|
||||
int result = mess.exec();
|
||||
return;
|
||||
}
|
||||
if (imgList.size() != labelList.size())
|
||||
{
|
||||
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"),
|
||||
QString::fromLocal8Bit("训练集Images、Labels文件夹内文件不匹配"));
|
||||
mess.setWindowFlags(Qt::Drawer);
|
||||
int result = mess.exec();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (ui.lineEpoch1->text() == "" || ui.lineEpoch2->text() == "")
|
||||
{
|
||||
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("请输入正确的训练轮数"));
|
||||
mess.setWindowFlags(Qt::Drawer);
|
||||
int result = mess.exec();
|
||||
return;
|
||||
}
|
||||
QString epoch1 = ui.lineEpoch1->text();
|
||||
QString epoch2 = ui.lineEpoch2->text();
|
||||
|
||||
if (mThread == nullptr)
|
||||
{
|
||||
qDebug() << "--startThread";
|
||||
startWorkThread();
|
||||
}
|
||||
|
||||
emit start(inModel, inDOM, inDSM, inLabel, outModel, executeMid, executeTrain, epoch1, epoch2);
|
||||
}
|
||||
|
||||
QStringList TrainMoudle::getAllFiles(QString path, QString fileType)
|
||||
{
|
||||
QDir dir(path);
|
||||
if (!dir.exists())
|
||||
return QStringList();
|
||||
dir.setFilter(QDir::Files | QDir::NoSymLinks);
|
||||
QFileInfoList list = dir.entryInfoList();
|
||||
|
||||
int file_count = list.count();
|
||||
if (file_count <= 0)
|
||||
return QStringList();
|
||||
QStringList files;
|
||||
for (int i = 0; i < file_count; i++)
|
||||
{
|
||||
QFileInfo file_info = list.at(i);
|
||||
QString suffix = file_info.suffix();
|
||||
if (QString::compare(suffix, QString(fileType), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
QString absolute_file_path = file_info.absoluteFilePath();
|
||||
files.append(absolute_file_path);
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
void TrainMoudle::pbCancel()
|
||||
{
|
||||
delete myWidget;//调起&QDialog::destroyed
|
||||
}
|
@ -11,23 +11,24 @@
|
||||
#include <QString>
|
||||
#include <QThread>
|
||||
#include <QVector>
|
||||
#include <QIntValidator>
|
||||
|
||||
#include "ui_DEM_GeneRas.h"
|
||||
#include "ui_DEM_GeneVec.h"
|
||||
#include "ThreadObject.h"
|
||||
#include "SrsMainPluginInterFace.h"
|
||||
|
||||
#include "gdal_priv.h"
|
||||
//#include "gdal_alg_priv.h"
|
||||
|
||||
class VegePredict : public SrsMainInterface
|
||||
class TrainMoudle : public SrsMainInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(SrsMainInterface)
|
||||
Q_PLUGIN_METADATA(IID MainInterface_iid)
|
||||
|
||||
public:
|
||||
VegePredict();
|
||||
~VegePredict();
|
||||
TrainMoudle();
|
||||
~TrainMoudle();
|
||||
|
||||
virtual QString PannelName() override;
|
||||
virtual QString CategoryName() override;
|
||||
@ -38,38 +39,41 @@ public:
|
||||
virtual QString IconPath() override;
|
||||
virtual QWidget* CenterWidget() override;
|
||||
|
||||
void startWorkThread();
|
||||
|
||||
//读json文件,获取历史存储的路径
|
||||
void ReadConfigHistoryPaths(QString strPath);
|
||||
//保存本次打开的路径到json文件
|
||||
void WriteConfigPaths(QString strPath);
|
||||
|
||||
void startWorkThread();
|
||||
|
||||
void openResultData(QStringList string_list);
|
||||
QStringList getAllFiles(QString path, QString fileType);
|
||||
|
||||
public slots:
|
||||
void chooseDomPath();
|
||||
void chooseDsmPath();
|
||||
void choosePreDir();
|
||||
void chooseMouleFile();
|
||||
void choseInModel();
|
||||
void choseInDom();
|
||||
void choseInDsm();
|
||||
void choseInLabel();
|
||||
void choseOutModel();
|
||||
|
||||
void addMap();
|
||||
|
||||
//pushbutton_OK
|
||||
void readAndStart();
|
||||
void pbCancel();
|
||||
|
||||
signals:
|
||||
void start(QString Moudle, QString DOM, QString DSM, QString PRE);//, std::function<void(int)>func
|
||||
void start(QString inModel, QString dom, QString dsm, QString label, QString outModel, bool mid, bool train, QString epoch1, QString epoch2);
|
||||
void killChildThread();
|
||||
void startTiffToShp(QString PRE, QString DSM);
|
||||
|
||||
private:
|
||||
Ui::DEM_GeneRasClass ui;
|
||||
Ui::DEM_GeneVecClass ui;
|
||||
|
||||
QDialog* myWidget = nullptr;
|
||||
|
||||
WorkThreadObject* mWorker = nullptr;
|
||||
WorkThreadObject* mWorkObject = nullptr;
|
||||
|
||||
QThread* mWorkThread = nullptr;
|
||||
QThread* mThread = nullptr;
|
||||
|
||||
bool executeMid = true;
|
||||
bool executeTrain = true;
|
||||
|
||||
};
|
6
DEM_GeneVec/DEM_GeneVec.qrc
Normal file
6
DEM_GeneVec/DEM_GeneVec.qrc
Normal file
@ -0,0 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/DEM_GeneVec">
|
||||
<file>resources/dem_vec.svg</file>
|
||||
<file>DEM_GeneVec.qss</file>
|
||||
</qresource>
|
||||
</RCC>
|
98
DEM_GeneVec/DEM_GeneVec.qss
Normal file
98
DEM_GeneVec/DEM_GeneVec.qss
Normal file
@ -0,0 +1,98 @@
|
||||
QProgressBar#progressBar {
|
||||
border:0px solid white;
|
||||
text-align:center;
|
||||
color:black;
|
||||
}
|
||||
QProgressBar#progressBar:chunk {
|
||||
background-color:#3FABBA;
|
||||
width:20px;
|
||||
}
|
||||
QProgressBar#progressBar QLineEdit {
|
||||
border:none;
|
||||
color:black;
|
||||
padding-left:5px;
|
||||
font-size:16px;
|
||||
background-color:transparent;
|
||||
}
|
||||
|
||||
QLabel{
|
||||
color:black;
|
||||
font-family:'Microsoft YaHei';
|
||||
font-size:12px;
|
||||
}
|
||||
|
||||
/*----QPushButtonÑùʽ±í*/
|
||||
#pushButton_ok, #pushButton_cancel, #pbtInModel, #pbtInDom, #pbtInDsm, #pbtInLabel, #pbtOutModel{
|
||||
font-family:'Microsoft YaHei';
|
||||
font-size:12px;
|
||||
background-color: #ffffff;
|
||||
border: 1px solid #dcdfe6;
|
||||
padding: 2px;
|
||||
border-radius: 5px;
|
||||
max-height:20px;
|
||||
}
|
||||
#pushButton_ok, #pushButton_cancel{
|
||||
min-width:36px;
|
||||
}
|
||||
#pushButton_ok:hover, #pushButton_cancel:hover, #pbtInModel:hover, #pbtInDom:hover, #pbtInDsm:hover,#pbtInLabel:hover,#pbtOutModel:hover{
|
||||
background-color: #ecf5ff;
|
||||
color: #409eff;
|
||||
}
|
||||
#pushButton_ok:pressed, #pushButton_cancel:pressed, #pbtInModel:pressed, #pbtInDom:pressed, #pbtInDsm:pressed,#pbtInLabel:pressed,#pbtOutModel:pressed{
|
||||
border: 1px solid #3a8ee6;
|
||||
color: #409eff;
|
||||
}
|
||||
#pushButton_ok:checked, #pushButton_cancel:checked, #pbtInModel:checked, #pbtInDom:checked, #pbtInDsm:checked,#pbtInLabel:checked,#pbtOutModel:checked{
|
||||
border: 1px solid #3a8ee6;
|
||||
color: #409eff;
|
||||
}
|
||||
#pushButton_ok:focus, #pushButton_cancel:focus, #pbtInModel:focus, #pbtInDom:focus, #pbtInDsm:focus,#pbtInLabel:focus,#pbtOutModel:focus{
|
||||
border: 1px solid #3a8ee6;
|
||||
color: #409eff;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/*----QLineEditÑùʽ*/
|
||||
#lineInModel, #lineInDsm, #lineInDom, #lineOutModel, #lineInLabel, #lineEpoch1, #lineEpoch2{
|
||||
border:0px;
|
||||
border-bottom: 1px solid #B3B3B3;
|
||||
font-family:'Microsoft YaHei';
|
||||
font-size:12px;
|
||||
background-color:transparent;
|
||||
}
|
||||
#lineInModel:hover, #lineInDsm:hover, #lineInDom:hover, #lineOutModel:hover, #lineInLabel:hover, #lineEpoch1:hover, #lineEpoch2:hover{
|
||||
border-bottom: 2px solid #66A3FF;
|
||||
}
|
||||
#lineInModel:focus, #lineInDsm:focus, #lineInDom:focus, #lineOutModel:focus, #lineInLabel:focus, #lineEpoch1:focus, #lineEpoch2:focus{
|
||||
border-bottom: 2px solid #7666FF;
|
||||
}
|
||||
|
||||
/*QCheckBox{
|
||||
background:transparent;
|
||||
border:0px;
|
||||
color:black;
|
||||
min-height: 20px;
|
||||
min-width: 60px;
|
||||
}
|
||||
QCheckBox::disabled{
|
||||
background:transparent;
|
||||
border:0px;
|
||||
color:#202020;
|
||||
min-height: 20px;
|
||||
min-width: 60px;
|
||||
}
|
||||
QCheckBox::indicator{
|
||||
margin-right:-10px;
|
||||
}
|
||||
QCheckBox::indicator:checked{
|
||||
image: url(:/RemoteSensingProcess/Resources/checkbox_checked.svg);
|
||||
width:25px;
|
||||
}
|
||||
QCheckBox::indicator:unchecked{
|
||||
image: url(:/RemoteSensingProcess/Resources/checkbox_unchecked.svg);
|
||||
width:25px;
|
||||
}
|
||||
QCheckBox::indicator:disabled{
|
||||
image: url(:/RemoteSensingProcess/Resources/checkbox_disabled.svg);
|
||||
width:25px;
|
||||
}*/
|
@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DEM_GeneRasClass</class>
|
||||
<widget class="QDialog" name="DEM_GeneRasClass">
|
||||
<class>DEM_GeneVecClass</class>
|
||||
<widget class="QDialog" name="DEM_GeneVecClass">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>300</height>
|
||||
<width>550</width>
|
||||
<height>320</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -18,87 +18,110 @@
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>300</height>
|
||||
<width>550</width>
|
||||
<height>320</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>300</height>
|
||||
<width>550</width>
|
||||
<height>320</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineInDom">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEpoch1">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>110</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>解冻训练次数</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEpoch2">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="lineOutModel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pbt_Moudle">
|
||||
<widget class="QPushButton" name="pbtInModel">
|
||||
<property name="text">
|
||||
<string>选择文件</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="lineInLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>输入模型文件路径</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>输入DSM文件路径</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="pbt_DOM">
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="pbtOutModel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
@ -116,26 +139,55 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="line_PRE"/>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineInModel"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineInDsm">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="pbtInLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>选择文件夹</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<width>110</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<width>110</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -143,12 +195,40 @@
|
||||
<string>输入DOM文件路径</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="pbt_DSM">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>110</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>110</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>输入DSM文件路径</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="pbtInDom">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
@ -167,38 +247,35 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<widget class="QLabel" name="label_mask">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<width>110</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<width>110</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>预测结果文件路径</string>
|
||||
<string>输入Label文件路径</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="line_Moudle"/>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="pbt_PRE">
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="pbtInDsm">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
@ -216,29 +293,75 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="line_DOM">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_mask_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>110</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>110</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>输出模型文件路径</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="line_DSM">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>输入初始模型文件路径</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>110</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>冻结训练次数</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
@ -246,6 +369,29 @@
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxMid">
|
||||
<property name="text">
|
||||
<string>生成训练集、验证集</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxTrain">
|
||||
<property name="text">
|
||||
<string>模型训练</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
@ -297,17 +443,10 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_process">
|
||||
<property name="text">
|
||||
<string>进度:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QProgressBar" name="progressBar">
|
||||
<widget class="CProgressBar" name="progressBar">
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@ -318,8 +457,29 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CProgressBar</class>
|
||||
<extends>QProgressBar</extends>
|
||||
<header>CProgressBar.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>lineInModel</tabstop>
|
||||
<tabstop>pbtInModel</tabstop>
|
||||
<tabstop>lineInDom</tabstop>
|
||||
<tabstop>pbtInDom</tabstop>
|
||||
<tabstop>lineInDsm</tabstop>
|
||||
<tabstop>pbtInDsm</tabstop>
|
||||
<tabstop>lineInLabel</tabstop>
|
||||
<tabstop>pbtInLabel</tabstop>
|
||||
<tabstop>lineOutModel</tabstop>
|
||||
<tabstop>pbtOutModel</tabstop>
|
||||
<tabstop>pushButton_ok</tabstop>
|
||||
<tabstop>pushButton_cancel</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="DEM_GeneRas.qrc"/>
|
||||
<include location="DEM_GeneVec.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
@ -7,11 +7,11 @@
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{AAEF388B-265D-4CF4-8832-9E6CD50B4644}</ProjectGuid>
|
||||
<ProjectGuid>{858826AD-BC7C-4B9D-8E48-626392904948}</ProjectGuid>
|
||||
<Keyword>QtVS_v304</Keyword>
|
||||
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0.19041.0</WindowsTargetPlatformVersion>
|
||||
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
|
||||
<ProjectName>DEM_Predict</ProjectName>
|
||||
<ProjectName>DEM_Train</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
|
||||
@ -23,7 +23,7 @@
|
||||
<Import Project="$(QtMsBuild)\qt_defaults.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
|
||||
<QtInstall>qt5.11.2</QtInstall>
|
||||
<QtInstall>QtQgis</QtInstall>
|
||||
<QtModules>core;gui;widgets</QtModules>
|
||||
<QtBuildConfig>release</QtBuildConfig>
|
||||
</PropertyGroup>
|
||||
@ -38,13 +38,13 @@
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<IncludePath>D:\qgis\osgeo4w\include;D:\qgis\osgeo4w\apps\Qt5\include;D:\qgis\osgeo4w\apps\qgis_build_sdk\include;D:\qgis\osgeo4w\apps\Qt5\include\QtXml;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\qgis\osgeo4w\lib;D:\qgis\osgeo4w\apps\Qt5\lib;D:\qgis\osgeo4w\apps\qgis_build_sdk\lib;$(LibraryPath)</LibraryPath>
|
||||
<TargetName>dem3-demPredict</TargetName>
|
||||
<IncludePath>D:\qgis\osgeo4w\include;D:\qgis\osgeo4w\apps\Qt5\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\qgis\osgeo4w\lib;D:\qgis\osgeo4w\apps\Qt5\lib;$(LibraryPath)</LibraryPath>
|
||||
<TargetName>dem1-$(ProjectName)</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>gdal_i.lib;qgis_gui.lib;qgis_analysis.lib;qgis_core.lib;qgis_native.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>gdal_i.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
|
||||
@ -61,27 +61,24 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="im2shp.cpp" />
|
||||
<ClCompile Include="QtGDALProcessBar.cpp" />
|
||||
<ClCompile Include="CProgressBar.cpp" />
|
||||
<ClCompile Include="ThreadObject.cpp" />
|
||||
<QtRcc Include="DEM_GeneRas.qrc" />
|
||||
<QtMoc Include="DEM_GeneRas.h" />
|
||||
<ClCompile Include="DEM_GeneRas.cpp" />
|
||||
<QtRcc Include="DEM_GeneVec.qrc" />
|
||||
<QtMoc Include="DEM_GeneVec.h" />
|
||||
<ClCompile Include="DEM_GeneVec.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtUic Include="DEM_GeneRas.ui" />
|
||||
<QtUic Include="DEM_GeneVec.ui" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="ThreadObject.h" />
|
||||
<QtMoc Include="SrsMainPluginInterFace.h" />
|
||||
<ClInclude Include="CProcessBase.h" />
|
||||
<ClInclude Include="im2shp.h" />
|
||||
<QtMoc Include="QtGDALProcessBar.h" />
|
||||
<ClInclude Include="x64\Release\uic\ui_DEM_GeneRas.h" />
|
||||
<QtMoc Include="CProgressBar.h" />
|
||||
<ClInclude Include="x64\Release\uic\ui_DEM_GeneVec.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="DEM_GeneRas.qss" />
|
||||
<None Include="DEM_GeneVec.qss" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
|
@ -22,17 +22,17 @@
|
||||
<Extensions>ts</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="process">
|
||||
<UniqueIdentifier>{8ac62ded-3917-412e-99b7-44350c87e7c8}</UniqueIdentifier>
|
||||
<UniqueIdentifier>{96222dac-cebd-43e4-bfdd-ebee13ab43e3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtRcc Include="DEM_GeneRas.qrc">
|
||||
<QtRcc Include="DEM_GeneVec.qrc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</QtRcc>
|
||||
<QtMoc Include="DEM_GeneRas.h">
|
||||
<QtMoc Include="DEM_GeneVec.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<ClCompile Include="DEM_GeneRas.cpp">
|
||||
<ClCompile Include="DEM_GeneVec.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
@ -40,45 +40,36 @@
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="im2shp.cpp">
|
||||
<Filter>process</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="QtGDALProcessBar.cpp">
|
||||
<Filter>process</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ThreadObject.cpp">
|
||||
<Filter>process</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CProgressBar.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtUic Include="DEM_GeneRas.ui">
|
||||
<QtUic Include="DEM_GeneVec.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="x64\Release\uic\ui_DEM_GeneRas.h">
|
||||
<ClInclude Include="x64\Release\uic\ui_DEM_GeneVec.h">
|
||||
<Filter>Form Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="im2shp.h">
|
||||
<Filter>process</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CProcessBase.h">
|
||||
<Filter>process</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="ThreadObject.h">
|
||||
<Filter>process</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="SrsMainPluginInterFace.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="QtGDALProcessBar.h">
|
||||
<Filter>process</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="ThreadObject.h">
|
||||
<QtMoc Include="CProgressBar.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="DEM_GeneRas.qss">
|
||||
<None Include="DEM_GeneVec.qss">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
97
DEM_GeneVec/ThreadObject.cpp
Normal file
97
DEM_GeneVec/ThreadObject.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
#include <QProcess>
|
||||
#include <QDir>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "DEM_GeneVec.h"
|
||||
#include "ThreadObject.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
WorkThreadObject::WorkThreadObject(QObject* parent) :QObject(parent)
|
||||
{
|
||||
qRegisterMetaType<std::function<void(double)> >("std::function<void(double)>");
|
||||
}
|
||||
|
||||
WorkThreadObject::~WorkThreadObject()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WorkThreadObject::runTrainWork(QString inModel, QString dom, QString dsm, QString label, QString outModel, bool mid, bool train, QString epoch1, QString epoch2)
|
||||
{
|
||||
QString str = QString("%1->%2,thread id:%3").arg(__FILE__).arg(__FUNCTION__).arg((int)QThread::currentThreadId());
|
||||
qDebug() << str;
|
||||
|
||||
QDir pluginsDir = QDir(qApp->applicationDirPath());
|
||||
if (!pluginsDir.cd("models\\envs"))
|
||||
{
|
||||
qDebug() << "no folder models\\envs";
|
||||
return;
|
||||
}
|
||||
QString exeDirName = pluginsDir.absoluteFilePath("train_4c_vegetaion.exe");
|
||||
|
||||
QString inDom = " --dom_path "+ dom + "/";
|
||||
QString inDsm = " --dsm_path " + dsm + "/";
|
||||
QString inLabel = " --label_path " + label + "/";
|
||||
QString trainedModel = " --retrained_model " + inModel;
|
||||
QString save_model = " --save_model " + outModel + "/";
|
||||
QString strMid, strTrain;
|
||||
if (mid)
|
||||
strMid = " --exe_mid True ";
|
||||
else
|
||||
strMid = " --exe_mid False ";
|
||||
if (train)
|
||||
strTrain = " --exe_train True";
|
||||
else
|
||||
strTrain = " --exe_train False";
|
||||
QString strEpoch1, strEpoch2;
|
||||
strEpoch1 = " --epoch1 " + epoch1;
|
||||
strEpoch2 = " --epoch2 " + epoch2;
|
||||
|
||||
//QString CUDA = " --CUDA False";
|
||||
QString ss = exeDirName + inDom + inDsm + inLabel + trainedModel + save_model+ strMid + strTrain + strEpoch1 + strEpoch2;// + CUDA
|
||||
qDebug() << ss;
|
||||
QProcess* pProces = new QProcess(this);
|
||||
connect(pProces, SIGNAL(readyReadStandardOutput()), this, SLOT(on_read()));
|
||||
|
||||
pProces->start(ss);
|
||||
}
|
||||
|
||||
void WorkThreadObject::on_read()
|
||||
{
|
||||
mProces = (QProcess*)sender();
|
||||
QString output = QString::fromLocal8Bit(mProces->readAllStandardOutput());
|
||||
//qDebug() << "out:" << output;
|
||||
if (output.toDouble() > 0)
|
||||
{
|
||||
qDebug() << "exe out:" << output.toDouble();
|
||||
emit process(output.toDouble());
|
||||
if (output.toDouble() == 100.0)
|
||||
{
|
||||
emit addDataToMap();
|
||||
}
|
||||
}
|
||||
else
|
||||
qDebug() << "Unresolved exe out:" << output;
|
||||
}
|
||||
|
||||
void WorkThreadObject::on_cancel()
|
||||
{
|
||||
QString str = QString("--1.%1->%2,thread id:%3").arg(__FILE__).arg(__FUNCTION__).arg((int)QThread::currentThreadId());
|
||||
qDebug() << str;
|
||||
|
||||
if (mProces == nullptr)
|
||||
{
|
||||
qDebug() << "--mProces null";
|
||||
}
|
||||
else
|
||||
{
|
||||
QString KillStr = "taskkill /f /im train_4c_vegetaion.exe";
|
||||
mProces->startDetached(KillStr);
|
||||
qDebug() << "--kill Proces";
|
||||
}
|
||||
}
|
@ -7,18 +7,19 @@
|
||||
#include <QProcess>
|
||||
#include <QThread>
|
||||
#include <QVector>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
//#include "MultiQProcess.h"
|
||||
|
||||
//#include "qtclasslibrary1_global.h"
|
||||
#include "SrsMainPluginInterFace.h"
|
||||
#include "ui_DEM_GeneRas.h"
|
||||
#include "ui_DEM_GeneVec.h"
|
||||
//#include "Extract.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class VegePredict;
|
||||
class TrainMoudle;
|
||||
|
||||
class WorkThreadObject :public QObject
|
||||
{
|
||||
@ -30,18 +31,18 @@ public:
|
||||
void on_cancel();
|
||||
|
||||
signals:
|
||||
void process(int value);
|
||||
void process(double value);
|
||||
void addDataToMap();
|
||||
void addShpDataToMap(QStringList list);
|
||||
|
||||
public slots:
|
||||
void runPredictWork(QString Moudle, QString DOM, QString DSM, QString PRE);//
|
||||
//void RunWork(QString landsat_file, QString gf_file, QString tvdi_file);
|
||||
//void RunWork(QString file1, QString file2, QString file_out, std::function<void(int)>progressCallback);
|
||||
//void RunWork(QString file1, QString file2, QString file_out);
|
||||
void runTrainWork(QString inModel, QString dom, QString dsm, QString label, QString outModel, bool mid, bool train, QString epoch1, QString epoch2);
|
||||
void on_read();
|
||||
void runFormatConvert(QString pre_path, QString DSM);
|
||||
|
||||
private:
|
||||
QProcess* mProces = nullptr;
|
||||
QString assess_txt_path;
|
||||
};
|
||||
|
||||
#endif
|
16
DEM_GeneVec/main.cpp
Normal file
16
DEM_GeneVec/main.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "DEM_GeneVec.h"
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
QString gdal_path = qApp->applicationDirPath().toLocal8Bit() + "/share/gdal";
|
||||
QString pro_lib_path = qApp->applicationDirPath().toLocal8Bit() + "/share/proj";
|
||||
qputenv("GDAL_DATA", gdal_path.toLocal8Bit());
|
||||
qputenv("PROJ_LIB", pro_lib_path.toLocal8Bit());
|
||||
|
||||
TrainMoudle w;
|
||||
w.CenterWidget()->show();
|
||||
return a.exec();
|
||||
}
|
2
DEM_GeneVec/resources/dem_vec.svg
Normal file
2
DEM_GeneVec/resources/dem_vec.svg
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1650520802998" class="icon" viewBox="0 0 1132 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5053" width="28.7421875" height="26" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><style type="text/css">@font-face { font-family: feedback-iconfont; src: url("//at.alicdn.com/t/font_1031158_u69w8yhxdu.woff2?t=1630033759944") format("woff2"), url("//at.alicdn.com/t/font_1031158_u69w8yhxdu.woff?t=1630033759944") format("woff"), url("//at.alicdn.com/t/font_1031158_u69w8yhxdu.ttf?t=1630033759944") format("truetype"); }
|
||||
</style></defs><path d="M1131.403629 583.018705c1.939725-47.361608-39.010016-64.495842-39.010017-64.495842l-226.408963-105.391702s0.538812-182.926804 0-232.120374a73.440128 73.440128 0 0 0-40.949741-66.651092S645.82591 35.80085 592.645128 6.974387c-27.694956-15.086747-56.5753 0-56.5753 0S367.529315 89.035513 315.480039 112.312208c-47.577133 21.229208-46.876677 66.651092-46.876677 66.651092V411.891892S120.160551 482.476314 57.873839 509.524696C-1.71881 535.333809 0.005389 589.592216 0.005389 589.592216s0.538812 185.890272 0 234.275623c-0.538812 52.264801 42.350653 68.806341 42.350654 68.806342s143.862906 80.06752 212.669247 114.713156c50.91777 25.539707 83.946969 0.646575 83.946969 0.646575l226.085675-122.525936s178.777948 92.67573 220.859195 121.879361c48.816402 33.729655 82.007245 5.65753 82.007245 5.65753s199.198938-111.156994 230.288412-126.836435c33.298605-16.703184 33.298605-58.030094 33.298605-58.030094s-2.047487-197.905788-0.107762-245.159633zM299.85448 675.371147l-206.903955-99.895816 206.903955-99.949696 210.783404 98.925953-210.783404 100.919559z m232.282018 148.335049l-199.091175 109.594438v-195.696657l199.091175-94.561573v180.663792z m32.705911-537.357589L340.911983 181.010787l223.930426-108.840101 232.766949 108.840101-232.766949 105.391702z m35.66938 64.38808l197.043688-94.561573v159.057415L600.511789 512.110995V350.790568z m235.137723 324.63446l-205.82633-99.895816 197.151451-99.949696 214.662853 99.949696-205.987974 99.895816z m227.378825 154.800797l-195.211725 103.12869v-195.696657l195.211725-94.561573v187.12954z" p-id="5054" fill="#2c2c2c"></path></svg>
|
After Width: | Height: | Size: 2.2 KiB |
@ -3,20 +3,21 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31911.196
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DEM_GeneRas", "DEM_GeneRas\DEM_GeneRas.vcxproj", "{AAEF388B-265D-4CF4-8832-9E6CD50B4644}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DEM_GeneVec", "DEM_GeneVec\DEM_GeneVec.vcxproj", "{858826AD-BC7C-4B9D-8E48-626392904948}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{AAEF388B-265D-4CF4-8832-9E6CD50B4644}.Release|x64.ActiveCfg = Release|x64
|
||||
{AAEF388B-265D-4CF4-8832-9E6CD50B4644}.Release|x64.Build.0 = Release|x64
|
||||
{858826AD-BC7C-4B9D-8E48-626392904948}.Release|x64.ActiveCfg = Release|x64
|
||||
{858826AD-BC7C-4B9D-8E48-626392904948}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {6D802BB4-76E8-4FE8-8FB7-04BCDE98FF27}
|
||||
Qt5Version = qt5.14.2
|
||||
SolutionGuid = {B8F00221-FFCF-43EE-B1EC-68EEC3E5BC58}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
Loading…
Reference in New Issue
Block a user