软件总体参数,增加了关于FEKO软件相关的参数设置

pull/1/head
剑古敛锋 2024-07-23 10:33:31 +08:00
parent 84c298f009
commit bcb5b9e724
2 changed files with 82 additions and 0 deletions

View File

@ -20,10 +20,17 @@
* DISCLAIMED.
* ==================================================================================
*/
#include <QFileDialog>
#include "DialogGraphOption.h"
#include "GraphOption.h"
#include "ui_DialogGraphOption.h"
#include "MainWindow/MainWindow.h"
#include "BusAPI.h"
#include <QFile>
#include <QDir>
#include <QMap>
#include <QMessageBox>
#include <QDebug>
namespace Setting
{
@ -32,6 +39,7 @@ namespace Setting
{
_ui->setupUi(this);
connect(this, SIGNAL(updateGraph()), mainwindow, SIGNAL(updateGraphOptionsSig()));
connect(_ui->pushButtonSelectFekoInstallPath, SIGNAL(clicked()), this, SLOT(on_PushButtonSelectPath()));
init();
}
GraphOptionDialog::~GraphOptionDialog()
@ -141,6 +149,11 @@ namespace Setting
int trans = _graphOption->getTransparency();
_ui->TranspSlider->setValue(trans);
_ui->lineEditFEKOPath->setText(BusAPI::instance()->getFekoInstallPath());
_ui->lineEdit_CADFeko->setText(BusAPI::instance()->getFekocadPath());
_ui->lineEditPreFEKO->setText(BusAPI::instance()->getPreFekoPath());
_ui->lineEdit_RunFeko->setText(BusAPI::instance()->getRunFekoPath());
}
void GraphOptionDialog::accept()
{
@ -175,5 +188,71 @@ namespace Setting
accept();
QDialog::accept();
}
void GraphOptionDialog::on_PushButtonSelectPath() {
QString FEKOBinPath = QFileDialog::getExistingDirectory(
this, tr("Select FEKO Install Path"), BusAPI::instance()->getApplicationExePath());
if(QDir(FEKOBinPath).exists()) {
_ui->lineEditFEKOPath->setText(FEKOBinPath);
BusAPI::instance()->setFekoInstallPath(FEKOBinPath);
} else {
QMessageBox::warning(this, u8"警告", u8"检查Feko安装找不到cadFEKO");
return;
}
// 检查当前目录中是否存在cadfeko.exe、prefeko.exe、runfeko.exe
QMap<QString, QString> fekoexelist = this->checkFEKOExecutablesAndReturnPaths(FEKOBinPath);
//ccafeko
if(fekoexelist.contains("cadfeko.exe")) {
if(QFile(fekoexelist.value("cadfeko.exe")).exists()) {
BusAPI::instance()->setFekocadPath(fekoexelist.value("cadfeko.exe"));
_ui->lineEdit_CADFeko->setText(fekoexelist.value("cadfeko.exe"));
} else {
return;
}
} else {
QMessageBox::warning(this, u8"警告", "检查Feko安装找不到cadFEKO");
}
//prefeko
if(fekoexelist.contains("prefeko.exe")) {
if(QFile(fekoexelist.value("prefeko.exe")).exists()) {
BusAPI::instance()->setPreFekoPath(fekoexelist.value("prefeko.exe"));
_ui->lineEditPreFEKO->setText(fekoexelist.value("prefeko.exe"));
} else {
return;
}
} else {
QMessageBox::warning(this, u8"警告", "检查Feko安装prefeko");
}
//runfeko
if(fekoexelist.contains("runfeko.exe")) {
if(QFile(fekoexelist.value("runfeko.exe")).exists()) {
BusAPI::instance()->setRunFekoPath(fekoexelist.value("runfeko.exe"));
_ui->lineEdit_RunFeko->setText(fekoexelist.value("runfeko.exe"));
} else {
return;
}
} else {
QMessageBox::warning(this, u8"警告", "检查Feko安装runfeko");
}
}
QMap<QString, QString> GraphOptionDialog::checkFEKOExecutablesAndReturnPaths(const QString& directoryPath) {
QStringList fekoExecutables = {"cadfeko.exe", "prefeko.exe", "runfeko.exe"};
QMap<QString, QString> executablePaths;
qDebug()<<directoryPath;
for (const QString& executable : fekoExecutables) {
QString filePath = QDir(directoryPath).absoluteFilePath(executable);
qDebug()<<filePath;
if (QFile::exists(filePath)) {
executablePaths[executable] = filePath; // Executable exists, store its path
} else {
executablePaths[executable] = ""; // Executable does not exist, store an empty string
}
}
return executablePaths; // Return the map containing executable names and their paths
}
}

View File

@ -85,6 +85,7 @@ namespace Setting
*/
void on_out_CancelButton_clicked();
void on_PushButtonSelectPath();
private:
/**
* @brief _graphOptionupdateGraph()
@ -97,6 +98,8 @@ namespace Setting
*/
void init();
QMap<QString, QString> checkFEKOExecutablesAndReturnPaths(const QString& directoryPath);
private:
/**
* @brief ui