Przeglądaj źródła

opt:完善IR数据单例

wzj 11 miesięcy temu
rodzic
commit
70d63d750e

+ 0 - 112
src/GeometryDataExchange/STLdataExchange.cpp

@@ -1,112 +0,0 @@
-#include "STLdataExchange.h"
-#include "Geometry/geometrySet.h"
-#include "Geometry/geometryData.h"
-#include <QFileInfo>
-#include <vtkSTLReader.h>
-
-namespace Geometry
-{
-	STLdataExchange::STLdataExchange(const QString & fileName, GeometryOperation operation,
-		GUI::MainWindow * mw, QList<GeometrySet*>& res, int KernalId) :
-		GeometryThreadBase(mw, res),
-		_fileName(fileName),
-		_operation(operation)
-
-	{
-		Q_UNUSED(KernalId);
-	}
-
-	STLdataExchange::~STLdataExchange()
-	{
-	}
-
-	void STLdataExchange::run()
-	{
-		ModuleBase::ThreadTask::run();
-		switch (_operation)
-		{
-		case GEOMETRY_READ:
-			emit showInformation(tr("Import Geometry File From \"%1\"").arg(_fileName));
-			_isRead = readSTL();
-			break;
-		case GEOMETRY_WRITE:
-			emit showInformation(tr("Export Geometry File From \"%1\"").arg(_fileName));
-//			_isWrite = writeBrep();
-			break;
-		}
-		deriveGeometryTaskFinished();
-	}
-
-	bool STLdataExchange::readSTL()
-	{
-		std::string str = _fileName.toStdString();
-		const char* c_fn = str.c_str();
-		auto reader = vtkSTLReader::New();
-		reader->SetFileName(c_fn);
-		reader->Update();
-		auto stlTris = reader->GetOutput();
-		const int nt = stlTris->GetNumberOfCells();
-		if (nt > 0)
-		{
-			auto geoSet = new GeometrySet(STL);
-			vtkPolyData* p = vtkPolyData::New();
-			p->DeepCopy(stlTris);
-			geoSet->setPoly(p);
-			QFileInfo info(_fileName);
-			const QString name = info.fileName();
-			geoSet->setName(name);
-			GeometryData::getInstance()->appendGeometrySet(geoSet);
-			getResult().append(geoSet);
-		}
-		reader->Delete();
-
-		return nt > 0;
-	}
-
-	void STLdataExchange::deriveGeometryTaskFinished()
-	{
-		ModuleBase::Message msg;
-		if (_operation == GEOMETRY_READ)
-		{
-			if (_isRead)
-			{
-				emit updateActionsStates();
-				emit showInformation(QString("Successful Import Geometry From \"%1\"").arg(_fileName));
-				msg.type = Common::Message::Normal;
-				msg.message = QString("Successful Import Geometry From \"%1\"").arg(_fileName);
-				auto result = getResult();
-
-				for (auto set : result)
-				{
-					if (set != result.last())
-						emit ShowSetSig(set, false);
-					else
-						emit ShowSetSig(set);
-				}
-			}
-			else
-			{
-				emit showInformation(QString("Failed Import Geometry From \"%1\"").arg(_fileName));
-				msg.type = Common::Message::Error;
-				msg.message = QString("Failed Import Geometry From \"%1\"").arg(_fileName);
-			}
-		}
-		else if (_operation == GEOMETRY_WRITE)
-		{
-			if (_isWrite)
-			{
-				emit showInformation(QString("Successful Export Geometry From \"%1\"").arg(_fileName));
-			}
-			else
-			{
-				emit showInformation(QString("Failed Export Geometry From \"%1\"").arg(_fileName));
-				msg.type = Common::Message::Error;
-				msg.message = QString("Failed Export Geometry From \"%1\"").arg(_fileName);
-			}
-		}
-		emit showGeometryMessageSig(msg);
-		defaultGeometryFinished();
-	}
-
-}
-

+ 0 - 60
src/GeometryDataExchange/STLdataExchange.h

@@ -1,60 +0,0 @@
-//stl文件操作类头文件
-#ifndef _STLDATAEXCHANGE_H__
-#define _STLDATAEXCHANGE_H__
-
-#include "GeometryThreadBase.h"
-
-namespace GUI
-{
-	class MainWindow;
-}
-
-namespace Geometry
-{
-	class GeometrySet;
-
-	class GEOMETRYDATAEXCHANGEAPI STLdataExchange : public GeometryThreadBase
-	{
-	public:
-		STLdataExchange(const QString& fileName, GeometryOperation operation, GUI::MainWindow *mw,
-			            QList<GeometrySet*>& res, int KernalId = -1);
-
-		~STLdataExchange();
-
-		void run() override;
-
-	private:
-		bool readSTL();
-		
-		void deriveGeometryTaskFinished();
-
-	private:
-		/**
-		 * @brief 要操作的文件
-		 * @since 2.5.0
-		 */
-		const QString _fileName;
-		/**
-		 * @brief 要执行的操作
-		 * @since 2.5.0
-		 */
-		GeometryOperation _operation;
-		/**
-		 * @brief 是否为读操作
-		 * @since 2.5.0
-		 */
-		bool _isRead{ false };
-		/**
-		 * @brief 是否为写操作
-		 * @since 2.5.0
-		 */
-		bool _isWrite{ false };
-
-
-	};
-
- 
-}
-
-#endif // !_STLDATAEXCHANGE_H__
-

Plik diff jest za duży
+ 1 - 1
src/IR/CMakeLists.txt


+ 2 - 0
src/IR/IRComputationPara.h

@@ -12,6 +12,7 @@ namespace Ui {
 namespace IR
 {
 	class IRDetectorWidget;
+	struct IRcomputationParaData;
 	class IRAPI IRComputationPara : public QWidget
 	{
 		Q_OBJECT
@@ -28,6 +29,7 @@ namespace IR
 	private:
 		Ui::IRComputationPara *ui;
 		QList<IRDetectorWidget*> _detectors;
+		IRcomputationParaData* _data;
 	};
 }
 

+ 2 - 0
src/IR/IRComputationParaEnviroment.h

@@ -10,6 +10,7 @@ namespace Ui {
 
 namespace IR
 {
+	struct IRcomputationParaEnvData;
 	class IRAPI IRComputationParaEnviroment : public QWidget
 	{
 		Q_OBJECT
@@ -22,6 +23,7 @@ namespace IR
 		void saveToJson();
 	private:
 		Ui::IRComputationParaEnviroment *ui;
+		IRcomputationParaEnvData *_data;
 	};
 }
 

+ 61 - 0
src/IR/IRdataSingleton.cpp

@@ -1,4 +1,12 @@
 #include "IRdataSingleton.h"
+#include <iostream>
+#include <istream>
+#include <fstream>
+#include "nlohmann/json.hpp"
+#include <QDebug> 
+#include <QFile>
+#include "Settings/BusAPI.h"
+#include <QDir>
 
 namespace IR
 {
@@ -43,6 +51,14 @@ namespace IR
 
 	void IRData::init()
 	{
+		// _paraData = new IRcomputationParaData;
+		_irWorkPath = Setting::BusAPI::instance()->getWorkingDir() + "/IR";
+		QDir dir;
+		dir.mkpath(_irWorkPath + IR_DB); //数据库文件夹
+		dir.mkpath(_irWorkPath + IR_Input); //输入文件夹
+		dir.mkpath(_irWorkPath + IR_Output); //输出文件夹
+		
+		
 
 	}
 
@@ -55,5 +71,50 @@ namespace IR
 	{
 		_irWorkPath = path;
 	}
+
+	void IRData::setIRComputationPara(IRcomputationParaData* data)
+	{
+		_paraData = data;
+	}
+
+	IRcomputationParaData* IRData::getIRComputationPara()
+	{
+		return _paraData;
+	}
+
+	void IRData::setIRComputationParaEnv(IRcomputationParaEnvData* data)
+	{
+		_envData = data;
+	}
+	
+	IRcomputationParaEnvData* IRData::getIRComputationParaEnv()
+	{
+		return _envData;
+	}
+
+	void IRData::readJson(QString path)
+	{
+		if(path.isEmpty())
+			return;
+		std::ifstream file(path.toStdString());
+		nlohmann::json jsonObj;
+		if(!file.is_open())
+		{
+			qDebug() << "readJson error";
+			return ;
+		}
+		file >> jsonObj;
+		file.close();
+	}
+
+	void IRData::writeJson()
+	{
+		if(_irWorkPath.isEmpty())
+			return;
+		nlohmann::json jsonObj;
+		std::ofstream outputFile(_irWorkPath.toStdString() + "/" + "IR.json");
+		outputFile << std::setw(4) << jsonObj << std::endl;
+		outputFile.close();
+	}
 	
 }

+ 27 - 1
src/IR/IRdataSingleton.h

@@ -8,6 +8,15 @@
 #define IR_DB "Database"
 #define IR_Input "Input"
 #define IR_Output "Output"
+#define IR_Para "IR_Computation_parameters_file.dat"
+#define IR_EnvPara "IR_Computation_parameters_file_enviroment.dat"
+
+#define IR_MATERIAL_DB "典型材料发射率数据库.dat"
+#define IR_CO_DB "IR_CO-ALL-abs.dat"
+#define IR_CO2_DB "IR_CO2-ALL-abs.dat"
+#define IR_H2O_DB "IR_H2O-ALL-abs.dat"
+
+
 
 namespace IR
 {
@@ -140,6 +149,18 @@ namespace IR
 		QString getIrWorkPath();
 		//设置IR工作路径
 		void setIrWorkPath(QString path);
+		//设置IR参数
+		void setIRComputationPara(IRcomputationParaData* data);
+		//设置IR环境参数
+		void setIRComputationParaEnv(IRcomputationParaEnvData* data);
+		//获取IR参数
+		IRcomputationParaData* getIRComputationPara();
+		//获取IR环境参数
+	    IRcomputationParaEnvData* getIRComputationParaEnv();
+		//读取json文件
+		void readJson(QString path);
+		//写入json文件
+		void writeJson();
 
 	private:
 		IRData() = default;
@@ -159,8 +180,13 @@ namespace IR
 		QStringList _irGasDB;
 
 		//IR设置参数
-		
+		IRcomputationParaData* _paraData;
 		//IR环境设置参数
+		IRcomputationParaEnvData* _envData;
+
+		//求解器安装路径
+		QString _solverPath;
+
 	};
 }
 

+ 1 - 0
src/MainWidgets/TreeWidget.cpp

@@ -221,6 +221,7 @@ namespace MainWidget
 			// _irGuangpuQiangdu->setText(0,"光谱强度效果图");
 			// _irFusheWendu = new QTreeWidgetItem(_irResultItem);
 			// _irFusheWendu->setText(0,"辐射温度图");
+			//红外热成像\直角坐标图\极坐标图\
 
 		setStyleSheet("QTreeWidget::item{height:20px;}");
 	}

+ 0 - 23
src/Settings/BusAPI.cpp

@@ -3,11 +3,7 @@
 #include "BusAPI.h"
 #include "MainSetting.h"
 #include "DialogWorkingDir.h"
-// #include "DialogSolver.h"
-// #include "SolverManager.h"
-// #include "SolveOption.h"
 #include "GraphOption.h"
-//#include "DialogSolveOption.h"
 #include "DialogGraphOption.h"
 #include "MessageSetting.h"
 #include <QSettings>
@@ -29,8 +25,6 @@ namespace Setting
 	BusAPI::BusAPI()
 	{
 		_mainSetting = new MainSetting;
-		// 		_solvers = new SolverManager;
-		// 		_solveOption = new SolveOption;
 		_graphOption = new GraphOption;
 		_messageSetting = new MessageSetting;
 		readINI();
@@ -38,8 +32,6 @@ namespace Setting
 	BusAPI::~BusAPI()
 	{
 		delete _mainSetting;
-		// 		delete _solvers;
-		// 		delete _solveOption;
 		delete _graphOption;
 	}
 	void BusAPI::setWorkingDir()
@@ -58,7 +50,6 @@ namespace Setting
 
 		QSettings settingwriter(path + "/FastCAE.ini", QSettings::IniFormat);
 		_mainSetting->writeINI(&settingwriter);
-		//		_solveOption->writeINI(&settingwriter);
 		_graphOption->writeINI(&settingwriter);
 		_messageSetting->writeINI(&settingwriter);
 	}
@@ -68,7 +59,6 @@ namespace Setting
 
 		QSettings settingReader(path + "/FastCAE.ini", QSettings::IniFormat);
 		_mainSetting->readINI(&settingReader);
-		//		_solveOption->readINI(&settingReader);
 		_graphOption->readINI(&settingReader);
 		_messageSetting->readINI(&settingReader);
 	}
@@ -91,19 +81,6 @@ namespace Setting
 	{
 		return _mainSetting->getGeomFile();
 	}
-	// 	SolverManager* BusAPI::getSolverManager()
-	// 	{
-	// 		return _solvers;
-	// 	}
-	// 	void BusAPI::setSolverOptions()
-	// 	{
-	// 		SolveOptionDialog dlg(_mainWindow, _solveOption);
-	// 		dlg.exec();
-	// 	}
-	// 	SolveOption* BusAPI::getSolveOptions()
-	// 	{
-	// 		return _solveOption;
-	// 	}
 	QStringList BusAPI::getRencetFiles()
 	{
 		return _mainSetting->getRencentFile();

+ 0 - 13
src/Settings/BusAPI.h

@@ -11,15 +11,9 @@ namespace GUI
 	class MainWindow;
 }
 
-/**
- * @brief 跟设置有关的命名空间
- * @since 2.5.0
- */
 namespace Setting
 {
 	class MainSetting;
-	// 	class SolverManager;
-	// 	class SolveOption;
 	class GraphOption;
 	class MessageSetting;
 	class WorkingDirDialog;
@@ -46,15 +40,12 @@ namespace Setting
 		 * @since 2.5.0
 		 */
 		void setWorkingDir();
-		// 		void setDesignModel(bool m);
-		// 		bool isDesignModel();
 		/**
 		 * @brief 获取工作空间
 		 * @return QString 返回工作空间的路径
 		 * @since 2.5.0
 		 */
 		QString getWorkingDir();
-		//		void setSolver();
 		/**
 		 * @brief 设置本地化语言(“Chinese”或者“English”)
 		 * @param lang 要设置的本地化语言
@@ -208,8 +199,6 @@ namespace Setting
 		 * @since 2.5.0
 		 */
 		MainSetting *_mainSetting{};
-		// 		SolverManager* _solvers{};
-		// 		SolveOption* _solveOption{};
 		/**
 		 * @brief 绘图选项配置信息类对象
 		 * @since 2.5.0
@@ -225,9 +214,7 @@ namespace Setting
 		 * @since 2.5.0
 		 */
 		GUI::MainWindow *_mainWindow{};
-
 		WorkingDirDialog* _workDialog{};
-		//		bool _isDesignModel{ false };
 	};
 }