From 649196d624da0e4a13ac6cf54656fa0eef188a1a Mon Sep 17 00:00:00 2001 From: keyeslll Date: Mon, 13 Mar 2023 16:14:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LandslideTrain.sln | 22 + LandslideTrain/CProgressBar.cpp | 51 ++ LandslideTrain/CProgressBar.h | 18 + LandslideTrain/LandslideTrain.cpp | 455 ++++++++++++++++++ LandslideTrain/LandslideTrain.h | 96 ++++ LandslideTrain/LandslideTrain.qrc | 6 + LandslideTrain/LandslideTrain.qss | 68 +++ LandslideTrain/LandslideTrain.ui | 324 +++++++++++++ LandslideTrain/LandslideTrain.vcxproj | 81 ++++ LandslideTrain/LandslideTrain.vcxproj.filters | 65 +++ LandslideTrain/SrsMainPluginInterFace.h | 58 +++ LandslideTrain/main.cpp | 10 + LandslideTrain/resources/dem_vec.svg | 2 + 13 files changed, 1256 insertions(+) create mode 100644 LandslideTrain.sln create mode 100644 LandslideTrain/CProgressBar.cpp create mode 100644 LandslideTrain/CProgressBar.h create mode 100644 LandslideTrain/LandslideTrain.cpp create mode 100644 LandslideTrain/LandslideTrain.h create mode 100644 LandslideTrain/LandslideTrain.qrc create mode 100644 LandslideTrain/LandslideTrain.qss create mode 100644 LandslideTrain/LandslideTrain.ui create mode 100644 LandslideTrain/LandslideTrain.vcxproj create mode 100644 LandslideTrain/LandslideTrain.vcxproj.filters create mode 100644 LandslideTrain/SrsMainPluginInterFace.h create mode 100644 LandslideTrain/main.cpp create mode 100644 LandslideTrain/resources/dem_vec.svg diff --git a/LandslideTrain.sln b/LandslideTrain.sln new file mode 100644 index 0000000..a2097ab --- /dev/null +++ b/LandslideTrain.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32630.194 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LandslideTrain", "LandslideTrain\LandslideTrain.vcxproj", "{1D23BAC7-1D1A-48BE-9796-93F34E435A5A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1D23BAC7-1D1A-48BE-9796-93F34E435A5A}.Release|x64.ActiveCfg = Release|x64 + {1D23BAC7-1D1A-48BE-9796-93F34E435A5A}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9DAFCFF4-8408-40F6-A160-95047A99BB28} + EndGlobalSection +EndGlobal diff --git a/LandslideTrain/CProgressBar.cpp b/LandslideTrain/CProgressBar.cpp new file mode 100644 index 0000000..f568f04 --- /dev/null +++ b/LandslideTrain/CProgressBar.cpp @@ -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); +} + diff --git a/LandslideTrain/CProgressBar.h b/LandslideTrain/CProgressBar.h new file mode 100644 index 0000000..ffbc76d --- /dev/null +++ b/LandslideTrain/CProgressBar.h @@ -0,0 +1,18 @@ +#pragma once +#include + +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(); +}; diff --git a/LandslideTrain/LandslideTrain.cpp b/LandslideTrain/LandslideTrain.cpp new file mode 100644 index 0000000..c463b88 --- /dev/null +++ b/LandslideTrain/LandslideTrain.cpp @@ -0,0 +1,455 @@ +#include "LandslideTrain.h" + +#include + +LandslideTrain::LandslideTrain() +{ + //ui.setupUi(this); +} + +QString LandslideTrain::PannelName() +{ + return QString::fromLocal8Bit("ģ"); +} + +QString LandslideTrain::CategoryName() +{ + return QString::fromLocal8Bit("ģ"); +} + +QString LandslideTrain::EnglishName() +{ + return QString::fromLocal8Bit("LandslideTrain"); +} + +QString LandslideTrain::ChineseName() +{ + return QString::fromLocal8Bit("ģ͹"); +} + +QString LandslideTrain::Information() +{ + return QString::fromLocal8Bit("ģ͹"); +} + +QString LandslideTrain::IconPath() +{ + return ":/LandslideTrain/resources/dem_vec.svg"; +} + +QWidget* LandslideTrain::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(":/LandslideTrain/resources/dem_vec.svg")); + myWidget->setAttribute(Qt::WA_QuitOnClose, false); + + myWidget->setAttribute(Qt::WA_DeleteOnClose); + connect(myWidget, &QDialog::destroyed, this, [=] { + qDebug() << "----Landslide train window close----"; + + QDir pluginsDir = QDir(qApp->applicationDirPath()); + if (pluginsDir.cd("srsplugins\\SldModel")) + { + QString strConfigPath = pluginsDir.absoluteFilePath("sld_config.ini"); + QFile f(strConfigPath); + if (f.exists()) + { + WriteConfigPaths(strConfigPath); + f.close(); + } + } + + if (mWorkThread != nullptr) + { + mWorkThread->requestInterruption(); + mWorkThread->quit(); + mWorkThread->wait();//waitȵfinishedźŶӦIJۺִɺ + mWorkObject->on_cancel(); + mWorkThread = nullptr;//mWorkThread, &QThread::finished, mWorkThread, &QObject::deleteLaterҪdelete + mWorkObject = nullptr;//mWorkThread, &QThread::finished, mWorker, &QObject::deleteLater + } + + myWidget->close(); + myWidget = nullptr; + }); + connect(ui.pbtInModel, &QPushButton::clicked, this, &LandslideTrain::chooseInModel); + connect(ui.pbtInDataset, &QPushButton::clicked, this, &LandslideTrain::chooseInDataset); + connect(ui.pbtInLabel, &QPushButton::clicked, this, &LandslideTrain::chooseInLabel); + connect(ui.pbtOutResult, &QPushButton::clicked, this, &LandslideTrain::chooseResultPath); + + connect(ui.pushButton_ok, &QPushButton::clicked, this, &LandslideTrain::readAndStart); + connect(ui.pushButton_cancel, &QPushButton::clicked, this, &LandslideTrain::pbCancel); + + 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(); + + connect(ui.checkBoxGenData, &QCheckBox::clicked, this, [=](bool checked) { + executeGenData = checked; + if (!executeGenData && !executeTrain) + ui.pushButton_ok->setEnabled(false); + else + ui.pushButton_ok->setEnabled(true); + }); + connect(ui.checkBoxTrain, &QCheckBox::clicked, this, [=](bool checked) { + executeTrain = checked; + if (!executeGenData && !executeTrain) + ui.pushButton_ok->setEnabled(false); + else + ui.pushButton_ok->setEnabled(true); + }); + + ui.progressBar->setTextVisible(true); + ui.progressBar->setRange(0, 100); + + QFile qssFile(":/LandslideTrain/LandslideTrain.qss"); + qssFile.open(QFile::ReadOnly); //ֻʽ + if (qssFile.isOpen()) + { + QString qss = QLatin1String(qssFile.readAll()); + myWidget->setStyleSheet(qss); + qssFile.close(); + } + else + qDebug() << "-- no qssFile"; + + QDir pluginsDir = QDir(qApp->applicationDirPath()); + if (pluginsDir.cd("srsplugins\\SldModel")) + { + QString strConfigPath = pluginsDir.absoluteFilePath("sld_config.ini"); + QFile f(strConfigPath); + if (f.exists()) + { + ReadConfigHistoryPaths(strConfigPath); + f.close(); + } + } + + if (showWin) + myWidget->show(); + + return myWidget; +} + +void LandslideTrain::startWorkThread() +{ + if (mWorkObject != nullptr) + { + return; + } + mWorkThread = new QThread(); + mWorkObject = new WorkObject(); + mWorkObject->moveToThread(mWorkThread); + connect(mWorkThread, &QThread::finished, mWorkThread, &QObject::deleteLater); + connect(mWorkThread, &QThread::finished, mWorkObject, &QObject::deleteLater); + connect(mWorkObject, &WorkObject::progress, myWidget, [=](double val) {ui.progressBar->SetDoubleFormatValue(QString::fromLocal8Bit(""), val); }); + connect(mWorkObject, &WorkObject::trainFinished, this, &LandslideTrain::finished); + + connect(this, &LandslideTrain::start, mWorkObject, &WorkObject::runTrainWork); + mWorkThread->start(); +} + +void LandslideTrain::ReadConfigHistoryPaths(QString strPath) +{ + QSettings configIni(strPath, QSettings::IniFormat); + + //򿪱Ϊ[SldTrain] 飬ȡportֶεֵ + configIni.beginGroup("SldTrain"); + + ui.lineInModel->setText(configIni.value("RetrainModel").toString()); + ui.lineInDataset->setText(configIni.value("SrcDom").toString()); + ui.lineInLabel->setText(configIni.value("SrcLabel").toString()); + ui.lineOutResult->setText(configIni.value("TrainResult").toString()); + + configIni.endGroup();//ر +} + +void LandslideTrain::WriteConfigPaths(QString strPath) +{ + QSettings configIni(strPath, QSettings::IniFormat); + configIni.setIniCodec("utf-8"); + //򿪱Ϊ[SldTrain] + configIni.beginGroup("SldTrain"); + + //ģ· + QString temp = ui.lineInModel->text(); + if (temp != "") + configIni.setValue("RetrainModel", temp); + //DOM· + temp = ui.lineInDataset->text(); + if (temp != "") + configIni.setValue("SrcDom", temp); + //Label· + temp = ui.lineInLabel->text(); + if (temp != "") + configIni.setValue("SrcLabel", temp); + //· + temp = ui.lineOutResult->text(); + if (temp != "") + configIni.setValue("TrainResult", temp); + + configIni.endGroup();//ر +} + +void LandslideTrain::readAndStart() +{ + QString inDataset = ui.lineInDataset->text(); + QString inLabel=ui.lineInLabel->text(); + QString inModel=ui.lineInModel->text(); + QString outResult=ui.lineOutResult->text(); + + if (inDataset == "" || inLabel == "" || inModel == "" || outResult == "") + { + QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit(""), QString::fromLocal8Bit("·")); + mess.setWindowFlags(Qt::Drawer); + int result = mess.exec(); + return; + } + ui.progressBar->SetDoubleFormatValue(QString::fromLocal8Bit(""), 0); + + QDir inDatasetDir(inDataset); + if (!inDatasetDir.exists()) + { + QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit(""), QString::fromLocal8Bit("ѵļв")); + mess.setWindowFlags(Qt::Drawer); + int result = mess.exec(); + return; + } + QDir inLabelDir(inLabel); + if (!inLabelDir.exists()) + { + QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit(""), QString::fromLocal8Bit("ǩļв")); + mess.setWindowFlags(Qt::Drawer); + int result = mess.exec(); + return; + } + QDir outModelDir(outResult); + if (!outModelDir.exists()) + { + QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit(""), QString::fromLocal8Bit("ģļв")); + mess.setWindowFlags(Qt::Drawer); + int result = mess.exec(); + return; + } + + if (executeGenData && executeTrain) + qDebug() << "executeGenData & executeTrain"; + if (executeGenData && (!executeTrain)) + qDebug() << "executeGenData, not executeTrain"; + if ((!executeGenData) && executeTrain) + { + //жtrainļѵļ + QDir dirImage(outResult + "/Images"); + QDir dirLabel(outResult + "/Labels"); + if (!dirImage.exists() || !dirLabel.exists()) + { + QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit(""), + QString::fromLocal8Bit("δҵѵļ\nȷImagesLabels·: \n") + outResult); + mess.setWindowFlags(Qt::Drawer); + int result = mess.exec(); + return; + } + //жļǷƥ + QStringList imgList = getAllFiles(outResult + "/Images", "tif"); + QStringList labelList = getAllFiles(outResult + "/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("ѵImagesLabelsļļƥ")); + 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 (mWorkThread == nullptr) + { + qDebug() << "--startThread"; + startWorkThread(); + } + + emit start(inModel, inDataset, inLabel, outResult, executeGenData, executeTrain, epoch1, epoch2); +} + +QStringList LandslideTrain::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 LandslideTrain::finished() +{ + QMessageBox mess(QMessageBox::NoIcon, + QString::fromLocal8Bit("н"), + QString::fromLocal8Bit("ļ·\n") + ui.lineOutResult->text(), + QMessageBox::Ok, NULL); + mess.setWindowFlags(Qt::Drawer); + mess.setButtonText(QMessageBox::Ok, QString::fromLocal8Bit("ȷ")); + int result = mess.exec(); + + pbCancel(); +} + +void LandslideTrain::pbCancel() +{ + //qDebug() << "--pbtCancel"; + delete myWidget;//&QDialog::destroyed +} + +void LandslideTrain::chooseInModel() +{ + QString dirModel = QFileDialog::getOpenFileName(ui.pbtInModel, QString::fromLocal8Bit("ѡʼѵģļ"), "", "*.pth"); + if (dirModel != "") + ui.lineInModel->setText(dirModel); +} + +void LandslideTrain::chooseInDataset() +{ + QString dirDataset = QFileDialog::getExistingDirectory(ui.pbtInDataset, QString::fromLocal8Bit("ѡѵ·"), ""); + if (dirDataset != "") + ui.lineInDataset->setText(dirDataset); +} + +void LandslideTrain::chooseInLabel() +{ + QString dirLabel = QFileDialog::getExistingDirectory(ui.pbtInLabel, QString::fromLocal8Bit("ѡǩ·"), ""); + if (dirLabel != "") + ui.lineInLabel->setText(dirLabel); +} + +void LandslideTrain::chooseResultPath() +{ + QString dirResult = QFileDialog::getExistingDirectory(ui.pbtOutResult, QString::fromLocal8Bit("ѡģļ·"), ""); + if (dirResult != "") + ui.lineOutResult->setText(dirResult); +} + +void WorkObject::runTrainWork(QString inModel, QString dataset, QString label, QString outModel, bool gen, bool train, QString epoch1, QString epoch2) +{ + QDir pluginsDir = QDir(qApp->applicationDirPath()); + if (!pluginsDir.cd("models\\envs")) + { + qDebug() << "no folder models\\envs"; + return; + } + QString exeDirName = pluginsDir.absoluteFilePath("train_3c_landslide.exe"); + + QString inDom = " --dom_path " + dataset + "/"; + QString inLabel = " --label_path " + label + "/"; + QString trainedModel = " --retrained_model " + inModel; + QString save_model = " --save_model " + outModel + "/"; + QString strMid, strTrain; + if (gen) + 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 ss = exeDirName + inDom + inLabel + trainedModel + save_model + strMid + strTrain + strEpoch1 + strEpoch2; + qDebug() << ss; + QProcess* pProces = new QProcess(this); + connect(pProces, SIGNAL(readyReadStandardOutput()), this, SLOT(on_read())); + + pProces->start(ss); +} + +void WorkObject::on_read() +{ + mProcess = (QProcess*)sender(); + QString output = QString::fromLocal8Bit(mProcess->readAllStandardOutput()); + if (output.toDouble() > 0) + { + qDebug() << "exe out:" << output.toDouble(); + emit progress(output.toDouble()); + if (output.toDouble() == 100.0) + { + delete mProcess; + mProcess = nullptr; + emit trainFinished(); + } + } + else + qDebug() << "Unresolved exe out:" << output; +} + +void WorkObject::on_cancel() +{ + if (mProcess == nullptr) + { + qDebug() << "--mProcess null"; + } + else + { + QString KillStr = "taskkill /f /im train_3c_landslide.exe"; + mProcess->startDetached(KillStr); + qDebug() << "--kill Process"; + } +} diff --git a/LandslideTrain/LandslideTrain.h b/LandslideTrain/LandslideTrain.h new file mode 100644 index 0000000..04cac8d --- /dev/null +++ b/LandslideTrain/LandslideTrain.h @@ -0,0 +1,96 @@ +#pragma once + +#include +#include "ui_LandslideTrain.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "SrsMainPluginInterFace.h" + +#include +#include + +using namespace std; + + +class WorkObject :public QObject +{ + Q_OBJECT + +public: + void on_cancel(); + +public slots: + void runTrainWork(QString inModel, QString inDataset, QString label, QString outModel, bool gen, bool train, QString epoch1, QString epoch2); + void on_read(); + +signals: + void progress(double value); + void trainFinished(); + +private: + QProcess* mProcess = nullptr; + +}; + +class LandslideTrain : public SrsMainInterface +{ + Q_OBJECT + Q_INTERFACES(SrsMainInterface) + Q_PLUGIN_METADATA(IID MainInterface_iid) + +public: + LandslideTrain(); + + virtual QString PannelName() override; + virtual QString CategoryName() override; + + virtual QString EnglishName() override; + virtual QString ChineseName() override; + virtual QString Information() override; + virtual QString IconPath() override; + virtual QWidget* CenterWidget() override; + + void startWorkThread(); + + QStringList getAllFiles(QString path, QString fileType); + + //jsonļȡʷ洢· + void ReadConfigHistoryPaths(QString strPath); + //汾δ򿪵·jsonļ + void WriteConfigPaths(QString strPath); + +public slots: + void readAndStart(); + void pbCancel(); + + void chooseInModel(); + void chooseInDataset(); + void chooseInLabel(); + void chooseResultPath(); + + void finished(); + +signals: + void start(QString inModel, QString inDataset, QString label, QString outModel, bool gen, bool train, QString epoch1, QString epoch2); + +private: + Ui::LandslideTrainClass ui; + + QDialog* myWidget = nullptr; + + QThread* mWorkThread = nullptr; + WorkObject* mWorkObject = nullptr; + + bool executeGenData = true; + bool executeTrain = true; + +}; diff --git a/LandslideTrain/LandslideTrain.qrc b/LandslideTrain/LandslideTrain.qrc new file mode 100644 index 0000000..9fe2d2c --- /dev/null +++ b/LandslideTrain/LandslideTrain.qrc @@ -0,0 +1,6 @@ + + + resources/dem_vec.svg + LandslideTrain.qss + + diff --git a/LandslideTrain/LandslideTrain.qss b/LandslideTrain/LandslideTrain.qss new file mode 100644 index 0000000..387ca68 --- /dev/null +++ b/LandslideTrain/LandslideTrain.qss @@ -0,0 +1,68 @@ +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, #pbtInDataset, #pbtInDsm, #pbtInLabel, #pbtOutResult{ + 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, #pbtInDataset:hover, #pbtInLabel:hover,#pbtOutResult:hover{ + background-color: #ecf5ff; + color: #409eff; +} +#pushButton_ok:pressed, #pushButton_cancel:pressed, #pbtInModel:pressed, #pbtInDataset:pressed, #pbtInLabel:pressed,#pbtOutResult:pressed{ + border: 1px solid #3a8ee6; + color: #409eff; +} +#pushButton_ok:checked, #pushButton_cancel:checked, #pbtInModel:checked, #pbtInDataset:checked, #pbtInLabel:checked,#pbtOutResult:checked{ + border: 1px solid #3a8ee6; + color: #409eff; +} +#pushButton_ok:focus, #pushButton_cancel:focus, #pbtInModel:focus, #pbtInDataset:focus, #pbtInLabel:focus,#pbtOutResult:focus{ + border: 1px solid #3a8ee6; + color: #409eff; + outline: none; +} + +/*----QLineEditʽ*/ +#lineInModel, #lineInDataset, #lineOutResult, #lineInLabel, #lineEpoch1, #lineEpoch2{ + border:0px; + border-bottom: 1px solid #B3B3B3; + font-family:'Microsoft YaHei'; + font-size:12px; + background-color:transparent; +} +#lineInModel:hover, #lineInDataset:hover, #lineOutResult:hover, #lineInLabel:hover, #lineEpoch1:hover, #lineEpoch2:hover{ + border-bottom: 2px solid #66A3FF; +} +#lineInModel:focus, #lineInDataset:focus, #lineOutResult:focus, #lineInLabel:focus, #lineEpoch1:focus, #lineEpoch2:focus{ + border-bottom: 2px solid #7666FF; +} diff --git a/LandslideTrain/LandslideTrain.ui b/LandslideTrain/LandslideTrain.ui new file mode 100644 index 0000000..a38eb5d --- /dev/null +++ b/LandslideTrain/LandslideTrain.ui @@ -0,0 +1,324 @@ + + + LandslideTrainClass + + + + 0 + 0 + 500 + 300 + + + + + 500 + 300 + + + + + 500 + 300 + + + + LandslideTrain + + + + + + + + + + + + + + + 0 + 0 + + + + 输入训练数据路径 + + + + + + + + + + + 75 + 0 + + + + + 75 + 16777215 + + + + 打开文件夹 + + + + + + + + 75 + 0 + + + + + 75 + 16777215 + + + + 打开文件 + + + + + + + + 0 + 0 + + + + 输入初始训练模型路径 + + + + + + + + 0 + 0 + + + + 输入标签数据路径 + + + + + + + + 0 + 0 + + + + 输出模型文件路径 + + + + + + + + 75 + 0 + + + + + 75 + 16777215 + + + + 打开文件夹 + + + + + + + + + + + 75 + 0 + + + + + 75 + 16777215 + + + + 打开文件夹 + + + + + + + + + + 80 + 16777215 + + + + + + + + 解冻训练次数 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 80 + 16777215 + + + + + + + + + + 冻结训练次数 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + 40 + + + + + 生成训练集、验证集 + + + true + + + + + + + 模型训练 + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 确认 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + 取消 + + + + + + + + + 0 + + + + + + + + + CProgressBar + QProgressBar +
CProgressBar.h
+
+
+ + lineInModel + pbtInModel + lineInDataset + pbtInDataset + lineInLabel + pbtInLabel + lineOutResult + pbtOutResult + lineEpoch1 + lineEpoch2 + checkBoxGenData + checkBoxTrain + pushButton_ok + pushButton_cancel + + + + + +
diff --git a/LandslideTrain/LandslideTrain.vcxproj b/LandslideTrain/LandslideTrain.vcxproj new file mode 100644 index 0000000..d2dee47 --- /dev/null +++ b/LandslideTrain/LandslideTrain.vcxproj @@ -0,0 +1,81 @@ + + + + + Release + x64 + + + + {1D23BAC7-1D1A-48BE-9796-93F34E435A5A} + QtVS_v304 + 10.0 + $(MSBuildProjectDirectory)\QtMsBuild + + + + DynamicLibrary + v142 + + + + + + + QtQgis + core;gui;widgets + release + + + + + + + + + + + + + D:\qgis\osgeo4w\include;D:\qgis\osgeo4w\apps\Qt5\include;$(IncludePath) + D:\qgis\osgeo4w\lib;D:\qgis\osgeo4w\apps\Qt5\lib;$(LibraryPath) + landslide1_train + + + + true + true + EditAndContinue + Disabled + MultiThreadedDLL + + + Console + true + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LandslideTrain/LandslideTrain.vcxproj.filters b/LandslideTrain/LandslideTrain.vcxproj.filters new file mode 100644 index 0000000..a89c76d --- /dev/null +++ b/LandslideTrain/LandslideTrain.vcxproj.filters @@ -0,0 +1,65 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {99349809-55BA-4b9d-BF79-8FDBB0286EB3} + ui + + + {639EADAA-A684-42e4-A9AD-28FC9BCB8F7C} + ts + + + + + Resource Files + + + Form Files + + + Header Files + + + Source Files + + + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + + + Form Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/LandslideTrain/SrsMainPluginInterFace.h b/LandslideTrain/SrsMainPluginInterFace.h new file mode 100644 index 0000000..9130479 --- /dev/null +++ b/LandslideTrain/SrsMainPluginInterFace.h @@ -0,0 +1,58 @@ +#pragma once +//#if _MSC_VER >=1600 // MSVC2015>1899, msvc_ver=14.0 +//#pragma execution_character_set("utf-8") +//#endif +//#include "qtclasslibrary1_global.h" +#include +#include +#include +#include + +struct SPluginMetaData +{ + QVector qvsReturnFilePaths; + QVector qvsSendFilePaths; + bool isAdd2Map; + +}; +class SrsMainInterface : public QObject +{ + Q_OBJECT +public: + virtual ~SrsMainInterface() {} + + /// + /// pannel + /// + virtual QString PannelName() = 0; + + /// + /// Category + /// + /// + virtual QString CategoryName() = 0; + + /// + /// زӢ + /// + /// + virtual QString EnglishName() = 0; + /// + /// ز + /// + /// + virtual QString ChineseName() = 0; + virtual QString Information() = 0; + virtual QString IconPath() = 0; + virtual QWidget* CenterWidget() = 0; + // + //public slots: + // virtual void test(QWidget* parent) = 0; + +signals: + void AddDataToMap(QStringList string_list); + //void addDataToCanvas(QStringList string_list); +}; + +#define MainInterface_iid "com.Srs.MainInterface" +Q_DECLARE_INTERFACE(SrsMainInterface, MainInterface_iid) diff --git a/LandslideTrain/main.cpp b/LandslideTrain/main.cpp new file mode 100644 index 0000000..acac301 --- /dev/null +++ b/LandslideTrain/main.cpp @@ -0,0 +1,10 @@ +#include "LandslideTrain.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + LandslideTrain w; + w.CenterWidget()->show(); + return a.exec(); +} diff --git a/LandslideTrain/resources/dem_vec.svg b/LandslideTrain/resources/dem_vec.svg new file mode 100644 index 0000000..e7e2365 --- /dev/null +++ b/LandslideTrain/resources/dem_vec.svg @@ -0,0 +1,2 @@ + \ No newline at end of file