Переглянути джерело

opt:完善IR单例,添加IR探测组件动态添加删除

wzj 11 місяців тому
батько
коміт
49bca77571

+ 20 - 5
CMakeLists.txt.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 11.0.2, 2023-12-04T19:48:09. -->
+<!-- Written by QtCreator 11.0.2, 2023-12-05T18:33:25. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>
@@ -82,9 +82,6 @@
     <valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
     <value type="bool" key="ClangTools.UseGlobalSettings">true</value>
    </valuemap>
-   <valuemap type="QVariantMap" key="CppEditor.QuickFix">
-    <value type="bool" key="UseGlobalSettings">true</value>
-   </valuemap>
   </valuemap>
  </data>
  <data>
@@ -110,12 +107,13 @@
 -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
 -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
 -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}</value>
+    <value type="QString" key="CMake.Source.Directory">D:\project2023\PlatformDM\backup\PlatformDM-v0.5-back</value>
     <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\project2023\PlatformDM\backup\qRelease</value>
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
       <value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
       <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
-       <value type="QString">ALL_BUILD</value>
+       <value type="QString">all</value>
       </valuelist>
       <value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
       <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
@@ -171,6 +169,23 @@
     <value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
     <value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
     <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
+     <value type="QString">0</value>
+     <value type="QString">1</value>
+     <value type="QString">2</value>
+     <value type="QString">3</value>
+     <value type="QString">4</value>
+     <value type="QString">5</value>
+     <value type="QString">6</value>
+     <value type="QString">7</value>
+     <value type="QString">8</value>
+     <value type="QString">9</value>
+     <value type="QString">10</value>
+     <value type="QString">11</value>
+     <value type="QString">12</value>
+     <value type="QString">13</value>
+     <value type="QString">14</value>
+    </valuelist>
     <valuelist type="QVariantList" key="CustomOutputParsers"/>
     <value type="int" key="PE.EnvironmentAspect.Base">2</value>
     <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>

+ 36 - 10
src/IR/IRComputationPara.cpp

@@ -3,6 +3,7 @@
 #include "nlohmann/json.hpp"
 #include <iostream>
 #include <fstream>
+#include "IRdetectorWidget.h"
 
 namespace IR
 {
@@ -17,6 +18,8 @@ namespace IR
 		connect(ui->keJianGuang,&QCheckBox::clicked,this,&IRComputationPara::setWaveSpin);
 		connect(ui->zhongBo,&QCheckBox::clicked,this,&IRComputationPara::setWaveSpin);
 		connect(ui->changBo,&QCheckBox::clicked,this,&IRComputationPara::setWaveSpin);
+
+		connect(ui->tanCeZongMian,&QSpinBox::textChanged,this,&IRComputationPara::addDetectorWidget);
 	}
 
 	IRComputationPara::~IRComputationPara()
@@ -75,12 +78,6 @@ namespace IR
 			j["计算长波"]= 0;
 		}
 
-		// j["可见光最小"]= ui->keJianGuangMin->value();
-		// j["可见光最大"]= ui->keJianGuangMax->value();
-		// j["中波最小"]= ui->zhongBoMin->value();
-		// j["中波最大"]= ui->zhongBoMax->value();
-		// j["长波最小"]= ui->changBoMin->value();
-		// j["长波最大"]= ui->changBoMax->value();
 		j["射线步长"]= ui->sheXianBuChang->value();
 
 		j["热像图分辨率"]= ui->fenbianlv->currentIndex() + 1;
@@ -88,10 +85,7 @@ namespace IR
 		j["单个视场角"]= ui->shiChangJiao->value();
 		j["探测面总数"]= ui->tanCeZongMian->value();
 		j["探测点总数"]= ui->tanceDianShu->value();
-		j["探测面角度"]= ui->mianJiaoDu->value();
-		j["探测点角度"]= ui->dianJiaoDu->value();
-		j["经度"]= ui->jingDu->value();
-		j["维度"]= ui->weiDu->value();
+
 
 		std::ofstream outfile("D:/project2023/workspace/CFD/output.json");
 		if (!outfile.is_open())
@@ -143,6 +137,38 @@ namespace IR
 		
 	}
 
+	void IRComputationPara::addDetectorWidget()
+	{
+		int n = ui->tanCeZongMian->value();
+		int m = _detectors.size();
+		if(m<n)
+		{
+			for(int i = m; i < n ; ++i)
+			{
+				IRDetectorWidget* widget = new IRDetectorWidget();
+				_detectors.push_back(widget);
+			}
+			for(int i =0; i<_detectors.size() ;i++)
+			{
+				ui->detectorLayout->addWidget(_detectors[i]);
+			}
+		}
+		else if(m>n)
+		{
+			for(int i = m; i > n ; --i)
+			{
+				ui->detectorLayout->removeWidget(_detectors[i-1]);
+				IRDetectorWidget* widget = _detectors[i-1];
+				_detectors.removeAt(i-1);
+				delete widget;
+			}
+		}
+		else
+		{
+			return;
+		}
+	}
+
 }
 
 

+ 3 - 0
src/IR/IRComputationPara.h

@@ -11,6 +11,7 @@ namespace Ui {
 
 namespace IR
 {
+	class IRDetectorWidget;
 	class IRAPI IRComputationPara : public QWidget
 	{
 		Q_OBJECT
@@ -22,9 +23,11 @@ namespace IR
 	private slots:
 		void saveToJson();
 		void setWaveSpin();
+		void addDetectorWidget();
 
 	private:
 		Ui::IRComputationPara *ui;
+		QList<IRDetectorWidget*> _detectors;
 	};
 }
 

+ 30 - 63
src/IR/IRComputationPara.ui

@@ -47,9 +47,9 @@
       <property name="geometry">
        <rect>
         <x>0</x>
-        <y>-441</y>
+        <y>-252</y>
         <width>335</width>
-        <height>1128</height>
+        <height>1012</height>
        </rect>
       </property>
       <layout class="QVBoxLayout" name="verticalLayout_2">
@@ -348,70 +348,38 @@
         </widget>
        </item>
        <item>
-        <widget class="QGroupBox" name="groupBox_7">
+        <widget class="QGroupBox" name="detectorGroup">
          <property name="title">
           <string>探测参数</string>
          </property>
-         <layout class="QGridLayout" name="gridLayout_6">
-          <item row="4" column="1">
-           <widget class="QDoubleSpinBox" name="jingDu"/>
-          </item>
-          <item row="1" column="0">
-           <widget class="QLabel" name="label_23">
-            <property name="text">
-             <string>探测面探测点数</string>
-            </property>
-           </widget>
-          </item>
-          <item row="3" column="0">
-           <widget class="QLabel" name="label_25">
-            <property name="text">
-             <string>探测点α角</string>
-            </property>
-           </widget>
-          </item>
-          <item row="3" column="1">
-           <widget class="QDoubleSpinBox" name="dianJiaoDu"/>
-          </item>
-          <item row="2" column="0">
-           <widget class="QLabel" name="label_24">
-            <property name="text">
-             <string>探测面β角</string>
-            </property>
-           </widget>
-          </item>
-          <item row="1" column="1">
-           <widget class="QSpinBox" name="tanceDianShu"/>
-          </item>
-          <item row="2" column="1">
-           <widget class="QDoubleSpinBox" name="mianJiaoDu"/>
-          </item>
-          <item row="0" column="1">
-           <widget class="QSpinBox" name="tanCeZongMian"/>
-          </item>
-          <item row="0" column="0">
-           <widget class="QLabel" name="label_22">
-            <property name="text">
-             <string>探测面总数</string>
-            </property>
-           </widget>
-          </item>
-          <item row="4" column="0">
-           <widget class="QLabel" name="label_26">
-            <property name="text">
-             <string>经度</string>
-            </property>
-           </widget>
-          </item>
-          <item row="5" column="0">
-           <widget class="QLabel" name="label_27">
-            <property name="text">
-             <string>纬度</string>
-            </property>
-           </widget>
+         <layout class="QVBoxLayout" name="detectorLayout">
+          <item>
+           <layout class="QHBoxLayout" name="horizontalLayout_2">
+            <item>
+             <widget class="QLabel" name="label_22">
+              <property name="text">
+               <string>探测面总数</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QSpinBox" name="tanCeZongMian"/>
+            </item>
+           </layout>
           </item>
-          <item row="5" column="1">
-           <widget class="QDoubleSpinBox" name="weiDu"/>
+          <item>
+           <layout class="QHBoxLayout" name="horizontalLayout_3">
+            <item>
+             <widget class="QLabel" name="label_23">
+              <property name="text">
+               <string>探测面探测点数</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QSpinBox" name="tanceDianShu"/>
+            </item>
+           </layout>
           </item>
          </layout>
         </widget>
@@ -490,7 +458,6 @@
   <include location="../qrc/qianfan.qrc"/>
   <include location="../qrc/qianfan.qrc"/>
   <include location="../qrc/qianfan.qrc"/>
-  <include location="../qrc/qianfan.qrc"/>
  </resources>
  <connections/>
 </ui>

+ 20 - 1
src/IR/IRdataSingleton.cpp

@@ -15,7 +15,10 @@ namespace IR
 
 	IRData::~IRData()
 	{
-
+		if(_instance != nullptr)
+		{
+			delete _instance;
+		}
 	}
 
 	QString IRData::getPreItem()
@@ -37,4 +40,20 @@ namespace IR
 	{
 		_data = data;
 	}
+
+	void IRData::init()
+	{
+
+	}
+
+	QString IRData::getIrWorkPath()
+	{
+		return _irWorkPath;
+	}
+
+	void IRData::setIrWorkPath(QString path)
+	{
+		_irWorkPath = path;
+	}
+	
 }

+ 128 - 1
src/IR/IRdataSingleton.h

@@ -4,8 +4,113 @@
 #include "IRAPI.h"
 #include <QList>
 
+#define IR_INDEX_FILE "IR_Files_Index.dat"
+#define IR_DB "Database"
+#define IR_Input "Input"
+#define IR_Output "Output"
+
 namespace IR
 {
+    struct IRAPI IRcomputationParaData
+	{
+		//计算任务 (1-"喷流+蒙皮",2-"蒙皮",3-"喷流")
+		int calcTask;
+		
+		//出口截面坐标
+		double exportFacePos;
+		//飞机重心坐标
+		double planeGravityPos;
+		//探测距离
+		double detectDistance;
+		//高度
+		double height;
+		
+		//流体轴向分段
+		int flowAxisSegment;
+		//流体周向分段
+		int flowCircumferenceSegment;
+		//流体径向分段
+		int flowRadiusSegment;
+		//气体类型
+		int gasType = 3;
+
+		//计算短波
+		int calcShortWave;
+		//计算中波
+		int calcMiddleWave;
+		//计算长波
+		int calcLongWave;
+		//短波最小
+		double shortWaveMin;
+		//短波最大 
+		double shortWaveMax;
+		//中波最小 
+		double middleWaveMin;
+		//中波最大 
+		double middleWaveMax;
+		//长波最小 
+		double longWaveMin;
+		//长波最大  
+		double longWaveMax;
+
+		//射线步长
+		double rayStep;
+		
+		//热图像分辨率(0-320*240,1-640*480,2-800*600,3-1280*960,4-320*180,5-640*360,6-800*450,7-1280*720)
+		int heatResolution;
+		//每个像素上的射线数
+		int rayCount;
+		//单个视场角
+		double fieldAngle;
+
+		//探测面总数
+		int detectFaceCount;
+		//每个探测面上探测点总数
+		int detectPointCount;
+
+		//探测面角度
+		QList<double> detectFaceAngle;
+		//探测点角度
+		QList<double> detectPointAngle;
+		//经度
+		QList<double> longitude;
+		//纬度
+		QList<double> latitude;
+	};
+	struct IRAPI IRcomputationParaEnvData
+	{
+		//地理经度 
+		double longitude;
+		//地理维度
+		double latitude;
+		
+		//月
+		int month;
+		//日
+		int day;
+		//时
+		int hour;
+		//分
+		int minute;
+		
+		//太阳(0-不计算 1-计算)
+		int sun;
+		//大气(0-不计算 1-计算)
+		int atmosphere;
+		//地表(0-不计算 1-计算)
+		int surface;
+
+		//地表温度(K, >0)
+		int surfaceTemp;
+		//地表材料编号
+		int surfaceMaterialID;
+		//地表形状编号(0-平面)
+		int surfaceShapeID;
+		
+		//太阳相对目标的旋转角
+		double sunRotate;
+	};
+
 	struct IRAPI IRComponetData
 	{
 		QString name;
@@ -19,12 +124,22 @@ namespace IR
 	class IRAPI IRData
 	{
 	public:
+		//获取单例指针
 		static IRData* getInstance();
+		//获取IR前处理Item
 		QString getPreItem();
+		//设置IR前处理Item
 		void setPreItem(QString item);
+		//设置组件数据
 		void setComponentData(QList<IRComponetData> data);
+		//获取组件数据
 		QList<IRComponetData> getComponentData();
-		
+		//初始化IR相关设置
+		void init();
+		//获取IR工作路径
+		QString getIrWorkPath();
+		//设置IR工作路径
+		void setIrWorkPath(QString path);
 
 	private:
 		IRData() = default;
@@ -32,8 +147,20 @@ namespace IR
 
 	private:
 		static IRData* _instance;
+		//IR前处理对象
 		QString _preGridItem;
 		QList<IRComponetData> _data;
+		
+		//IR工作路径
+		QString _irWorkPath;
+
+		//IR数据库设置
+		QString _irMatrialDB;
+		QStringList _irGasDB;
+
+		//IR设置参数
+		
+		//IR环境设置参数
 	};
 }
 

+ 18 - 0
src/IR/IRdetectorWidget.cpp

@@ -0,0 +1,18 @@
+#include "IRdetectorWidget.h"
+#include "ui_IRdetectorWidget.h"
+
+namespace IR
+{
+	IRDetectorWidget::IRDetectorWidget(QWidget *parent) :
+		QWidget(parent),
+		ui(new Ui::IRDetectorWidget)
+	{
+		ui->setupUi(this);
+	}
+
+	IRDetectorWidget::~IRDetectorWidget()
+	{
+		delete ui;
+	}
+
+}

+ 27 - 0
src/IR/IRdetectorWidget.h

@@ -0,0 +1,27 @@
+#ifndef IRDETECTORWIDGET_H
+#define IRDETECTORWIDGET_H
+
+#include <QWidget>
+#include "IRAPI.h"
+
+namespace Ui {
+	class IRDetectorWidget;
+}
+
+namespace IR
+{
+	class IRAPI IRDetectorWidget : public QWidget
+	{
+		Q_OBJECT
+
+	public:
+		explicit IRDetectorWidget(QWidget *parent = nullptr);
+		~IRDetectorWidget();
+
+	private:
+		Ui::IRDetectorWidget *ui;
+	};
+
+}
+
+#endif // IRDETECTORWIDGET_H

+ 128 - 0
src/IR/IRdetectorWidget.ui

@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>IRDetectorWidget</class>
+ <widget class="QWidget" name="IRDetectorWidget">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>293</width>
+    <height>105</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <property name="leftMargin">
+    <number>0</number>
+   </property>
+   <property name="topMargin">
+    <number>0</number>
+   </property>
+   <property name="rightMargin">
+    <number>0</number>
+   </property>
+   <property name="bottomMargin">
+    <number>0</number>
+   </property>
+   <property name="spacing">
+    <number>0</number>
+   </property>
+   <item row="0" column="0">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>探测点α</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1">
+    <widget class="QDoubleSpinBox" name="angleA1"/>
+   </item>
+   <item row="0" column="2">
+    <widget class="QLabel" name="label_7">
+     <property name="text">
+      <string>~</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="3">
+    <widget class="QDoubleSpinBox" name="angleA2"/>
+   </item>
+   <item row="0" column="4">
+    <widget class="QLabel" name="label_3">
+     <property name="text">
+      <string>Δ</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="5">
+    <widget class="QDoubleSpinBox" name="resultA"/>
+   </item>
+   <item row="1" column="0">
+    <widget class="QLabel" name="label_2">
+     <property name="text">
+      <string>探测面β</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1">
+    <widget class="QDoubleSpinBox" name="angleB1"/>
+   </item>
+   <item row="1" column="2">
+    <widget class="QLabel" name="label_8">
+     <property name="text">
+      <string>~</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="3">
+    <widget class="QDoubleSpinBox" name="angleB2"/>
+   </item>
+   <item row="1" column="4">
+    <widget class="QLabel" name="label_4">
+     <property name="text">
+      <string>Δ</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="5">
+    <widget class="QDoubleSpinBox" name="resultB"/>
+   </item>
+   <item row="2" column="0">
+    <widget class="QLabel" name="label_5">
+     <property name="text">
+      <string>经度</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="1">
+    <widget class="QDoubleSpinBox" name="longitudeSpin"/>
+   </item>
+   <item row="2" column="3">
+    <widget class="QLabel" name="label_6">
+     <property name="text">
+      <string>维度</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="4" colspan="2">
+    <widget class="QDoubleSpinBox" name="latitudeSpin"/>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 1 - 1
src/MainWidgets/ControlPanel.ui

@@ -20,7 +20,7 @@
    <string>Control Panel</string>
   </property>
   <widget class="QWidget" name="dockWidgetContents">
-   <layout class="QHBoxLayout" name="horizontalLayout_2">
+   <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="2,3">
     <item>
      <layout class="QVBoxLayout" name="verticalLayout_2">
       <item>

+ 1 - 30
src/MainWindow/SignalHandler.cpp

@@ -95,7 +95,7 @@ namespace GUI {
 		connect(mainwindow, SIGNAL(treeMouseEvent(int, QTreeWidgetItem*, int)), this,
 				SLOT(handleTreeMouseEvent(int, QTreeWidgetItem*, int)));
 		connect(mainwindow, SIGNAL(solveProjectSig(int, int)), this,
-				SLOT(solveProjectPy(int, int))); // liu
+				SLOT(solveProjectPy(int, int))); 
 		connect(mainwindow->getUi()->actionSurfaceMesh, SIGNAL(triggered()), this,
 				SLOT(generateSurfaceMesh()));
 		connect(mainwindow->getUi()->actionSolidMesh, SIGNAL(triggered()), this,
@@ -770,12 +770,6 @@ namespace GUI {
 		}
 		if(!show)
 			return;
-		/*
-					if (!_launched) _launched = true;
-					else return;
-					*/
-
-
 	}
 
 	void SignalHandler::undo()
@@ -1034,28 +1028,6 @@ namespace GUI {
 		this->showDialog(dlg);
 	}
 
-	/*void SignalHandler::CreateCylindricalComplex()
-			{
-					SubWindowManager* sw = _mainWindow->getSubWindowManager();
-					if (!sw->isPreWindowOpened())
-							this->openPreWinPy();
-					MainWidget::PreWindow* p = sw->getPreWindow();
-
-					GeometryWidget::CreateCylindricalComplexDialog* dlg = new
-	   GeometryWidget::CreateCylindricalComplexDialog(_mainWindow, p); this->showDialog(dlg);
-			}
-
-			void SignalHandler::CreateBoxComplex()
-			{
-					SubWindowManager* sw = _mainWindow->getSubWindowManager();
-					if (!sw->isPreWindowOpened())
-							this->openPreWinPy();
-					MainWidget::PreWindow* p = sw->getPreWindow();
-
-					GeometryWidget::CreateBoxComplexDialog* dlg = new
-	   GeometryWidget::CreateBoxComplexDialog(_mainWindow, p); this->showDialog(dlg);
-			}*/
-
 	void SignalHandler::DrawGraphicsLine()
 	{
 		SubWindowManager*	   sw = _mainWindow->getSubWindowManager();
@@ -1064,7 +1036,6 @@ namespace GUI {
 		// 		if (action->isChecked())
 		p->setSketchType(ModuleBase::SketchLine);
 		// 		else
-		// 			p->setSketchType(ModuleBase::SketchNone);
 	}
 
 	void SignalHandler::DrawGraphicsRectangle()