环境初始化,集成了lamptool、wbmoudle

master
剑古敛锋 2024-03-13 13:58:12 +08:00
parent d03edbefbd
commit f0eb787bd8
1355 changed files with 412881 additions and 1653 deletions

View File

@ -7,8 +7,8 @@ cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(FastCAE project(FastCAE
VERSION 2.5.0 VERSION 2.5.0
LANGUAGES CXX LANGUAGES CXX
DESCRIPTION "FastCAECAE仿" DESCRIPTION "LAMPCAE,FastCAE仿"
HOMEPAGE_URL "http://www.fastcae.com/" HOMEPAGE_URL "http://124.16.188.131:9699/web/server3/build/#/Guide/"
) )
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------

419
CMakeLists.txt.user Normal file
View File

@ -0,0 +1,419 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 12.0.2, 2024-03-12T16:41:22. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{d034e98c-d1df-4d65-be6b-a0d9f31abe3b}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="qlonglong">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.CTest">false</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<valuemap type="QVariantMap" key="ClangTools">
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
<value type="int" key="ClangTools.ParallelJobs">8</value>
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.15.2 MSVC2019 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.15.2 MSVC2019 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.5152.win64_msvc2019_64_kit</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="CMake.Build.Type">Debug</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-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="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\WBFZCPP\source\build-FastCAE-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug</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</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<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">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="CMake.Build.Type">Release</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-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="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\WBFZCPP\source\build-FastCAE-Desktop_Qt_5_15_2_MSVC2019_64bit-Release</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</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<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">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="CMake.Build.Type">RelWithDebInfo</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-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="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\WBFZCPP\source\build-FastCAE-Desktop_Qt_5_15_2_MSVC2019_64bit-RelWithDebInfo</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</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<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">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release with Debug Information</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.3">
<value type="QString" key="CMake.Build.Type">RelWithDebInfo</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-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="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\WBFZCPP\source\build-FastCAE-Desktop_Qt_5_15_2_MSVC2019_64bit-Profile</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</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<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">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.4">
<value type="QString" key="CMake.Build.Type">MinSizeRel</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-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="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\WBFZCPP\source\build-FastCAE-Desktop_Qt_5_15_2_MSVC2019_64bit-MinSizeRel</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</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<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">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Minimum Size Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">5</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">FastCAE</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.FastCAE</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">FastCAE</value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/WBFZCPP/source/build-FastCAE-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/Debug</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="qlonglong">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>

70
cmake/FindFFTW.cmake Normal file
View File

@ -0,0 +1,70 @@
## FFTW can be compiled and subsequently linked against
## various data types.
## There is a single set of include files, and then muttiple libraries,
## One for each type. I.e. libfftw.a-->double, libfftwf.a-->float
## The following logic belongs in the individual package
## mark_as_advanced(ITK_USE_FFTWD)
## option(ITK_USE_FFTWD "Use double precision FFTW if found" ON)
## mark_as_advanced(ITK_USE_FFTWF)
## option(ITK_USE_FFTWF "Use single precision FFTW if found" ON)
if(ITK_USE_FFTWD OR ITK_USE_FFTWF)
set(FFTW_INC_SEARCHPATH
/sw/include
/usr/include
/usr/local/include
/usr/include/fftw
/usr/local/include/fftw
)
find_path(FFTW_INCLUDE_PATH fftw3.h ${FFTW_INC_SEARCHPATH})
if(FFTW_INCLUDE_PATH)
file(TO_CMAKE_PATH "${FFTW_INCLUDE_PATH}" FFTW_INCLUDE_PATH)
set(FFTW_INCLUDE ${FFTW_INCLUDE_PATH})
endif()
if(FFTW_INCLUDE)
include_directories(${FFTW_INCLUDE})
endif()
get_filename_component(FFTW_INSTALL_BASE_PATH ${FFTW_INCLUDE_PATH} PATH)
set(FFTW_LIB_SEARCHPATH
${FFTW_INSTALL_BASE_PATH}/lib
${FFTW_INSTALL_BASE_PATH}/lib64
/usr/lib/fftw
/usr/local/lib/fftw
)
if(ITK_USE_FFTWD)
mark_as_advanced(FFTWD_LIB)
find_library(FFTWD_LIB fftw3 ${FFTW_LIB_SEARCHPATH}) #Double Precision Lib
find_library(FFTWD_THREADS_LIB fftw3_threads ${FFTW_LIB_SEARCHPATH}) #Double Precision Lib only if compiled with threads support
if(FFTWD_LIB)
set(FFTWD_FOUND 1)
get_filename_component(FFTW_LIBDIR ${FFTWD_LIB} PATH)
if(FFTWD_THREADS_LIB)
set(FFTWD_LIB ${FFTWD_LIB} ${FFTWD_THREADS_LIB} )
endif()
endif()
endif()
if(ITK_USE_FFTWF)
mark_as_advanced(FFTWF_LIB)
find_library(FFTWF_LIB fftw3f ${FFTW_LIB_SEARCHPATH}) #Single Precision Lib
find_library(FFTWF_THREADS_LIB fftw3f_threads ${FFTW_LIB_SEARCHPATH}) #Single Precision Lib only if compiled with threads support
if(FFTWF_LIB)
set(FFTWF_FOUND 1)
get_filename_component(FFTW_LIBDIR ${FFTWF_LIB} PATH)
if(FFTWF_THREADS_LIB)
set(FFTWF_LIB ${FFTWF_LIB} ${FFTWF_THREADS_LIB} )
endif()
endif()
endif()
endif()

View File

@ -3,7 +3,7 @@
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# #
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
list(APPEND _libraries Common PythonModule SARibbonBar Settings DataProperty MeshData SelfDefObject Material Geometry BCBase ConfigOptions ParaClassFactory ModelData ModuleBase PostAlgorithm PostRenderData PostInterface PostCurveDataManager PostPlotWidget PostWidgets GeometryDataExchange ProjectTree ProjectTreeExtend GeometryCommand GeometryWidgets PluginManager GmshModule IO SolverControl MainWidgets UserGuidence) list(APPEND _libraries qcustomplot json qscintilla2 qhexedit LAMPTool WBCLFZSystemModule Common PythonModule SARibbonBar Settings DataProperty MeshData SelfDefObject Material Geometry BCBase ConfigOptions ParaClassFactory ModelData ModuleBase PostAlgorithm PostRenderData PostInterface PostCurveDataManager PostPlotWidget PostWidgets GeometryDataExchange ProjectTree ProjectTreeExtend GeometryCommand GeometryWidgets PluginManager GmshModule IO SolverControl MainWidgets UserGuidence)
#[[if(_WIN_) #[[if(_WIN_)
list(APPEND _libraries XGenerateReport License) list(APPEND _libraries XGenerateReport License)

View File

@ -50,6 +50,8 @@
#include <wchar.h> #include <wchar.h>
#endif #endif
#include "Common/DebugLogger.h" // 日志文件
#define WELCOMETIME 1500 #define WELCOMETIME 1500
CommandPara::CommandPara(int argc, char *argv[]) CommandPara::CommandPara(int argc, char *argv[])
@ -131,7 +133,6 @@ bool CommandPara::exec(GUI::MainWindow *window)
window->show(); window->show();
window->showMaximized(); window->showMaximized();
} }
if (!_projectFile.isEmpty()) if (!_projectFile.isEmpty())
{ {
QFile sf(_projectFile); QFile sf(_projectFile);
@ -155,6 +156,7 @@ bool CommandPara::exec(GUI::MainWindow *window)
runSc = true; runSc = true;
} }
} }
if (_showGUI) if (_showGUI)
return true; return true;
else if (runSc) else if (runSc)

View File

@ -31,9 +31,11 @@
#include <QMessageBox> #include <QMessageBox>
#include <QOpenGLContext> #include <QOpenGLContext>
#include <QProcess> #include <QProcess>
// #include "ConfigOptions/ConfigDataReader.h"
// #include "ConfigOptions/ConfigOptions.h" #include "ConfigOptions/ConfigDataReader.h"
// #include "ConfigOptions/GlobalConfig.h" #include "ConfigOptions/ConfigOptions.h"
#include "ConfigOptions/GlobalConfig.h"
#include "Common/DebugLogger.h" #include "Common/DebugLogger.h"
#include "Settings/BusAPI.h" #include "Settings/BusAPI.h"
@ -44,6 +46,10 @@
#endif #endif
#endif #endif
#include "Common/DebugLogger.h" // 日志文件
#define CHECKINGMEMORY 0 #define CHECKINGMEMORY 0
bool testOpenGL() bool testOpenGL()
@ -92,12 +98,13 @@ int main(int argc, char* argv[])
if(!testOpenGL()) { if(!testOpenGL()) {
return 1; return 1;
} }
// QString path = qApp->applicationDirPath(); /*****************加载参数配置项 *****************************************/
// ConfigOption::ConfigDataReader reader(path + "/../ConfigFiles/", QString path = qApp->applicationDirPath();
// ConfigOption::ConfigOption::getInstance()); reader.read(); QString qUseRibbon = ConfigOption::ConfigDataReader reader(path + "/../ConfigFiles/", ConfigOption::ConfigOption::getInstance());
// ConfigOption::ConfigOption::getInstance()->getGlobalConfig()->getUseRibbon(); bool reader.read();
// bUseRibbon = qUseRibbon == "yes" ? true : false;
/******************************************************************************/
bool isRibbon = Setting::BusAPI::instance()->isUseRibbon(); bool isRibbon = Setting::BusAPI::instance()->isUseRibbon();
GUI::MainWindow mainwindow(isRibbon); GUI::MainWindow mainwindow(isRibbon);
@ -128,7 +135,6 @@ int main(int argc, char* argv[])
#endif #endif
//***************************************** //*****************************************
if(para.exec(&mainwindow)) if(para.exec(&mainwindow))
emit mainwindow.sendInfoToStatesBar(QString("Version: %1").arg(FASTCAE_VERSION)); emit mainwindow.sendInfoToStatesBar(QString("Version: %1").arg(FASTCAE_VERSION));
else else

View File

@ -11,7 +11,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# #
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
file(GLOB _header "*.h") file(GLOB _header "*.h*")
file(GLOB _source "*.cpp") file(GLOB _source "*.cpp")
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------

View File

@ -0,0 +1,38 @@
#pragma once
#ifndef BASECONSTVARIABLE_H
#define BASECONSTVARIABLE_H
#include <complex>
#include <math.h>
#define PI_180 180/3.141592653589793238462643383279
#define T180_PI 3.141592653589793238462643383279/180
#define LIGHTSPEED 299792458
#define Radians2Degrees(Radians) Radians*PI_180
#define Degrees2Radians(Degrees) Degrees*T180_PI
const double PI = 3.141592653589793238462643383279;
const double epsilon = 0.000000000000001;
const double pi = 3.14159265358979323846;
const double d2r = pi / 180;
const double r2d = 180 / pi;
const double a = 6378137.0; //椭球长半轴
const double ae = 6378137.0; //椭球长半轴
const double ee = 0.0818191910428;// 第一偏心率
const double f_inverse = 298.257223563; //扁率倒数
const double b = a - a / f_inverse;
const double eSquare = (a * a - b * b) / (a * a);
const double e = sqrt(eSquare);
const double earth_Re = 6378136.49;
const double earth_Rp = (1 - 1 / f_inverse) * earth_Re;
const double earth_We = 0.000072292115;
#endif

View File

@ -0,0 +1,256 @@
#pragma once
#include "BaseTool.h"
///
///
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
#include "referenceHeader.h"
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
//#include <mkl.h>
#include <string>
#include <omp.h>
#include < io.h >
#include < stdio.h >
#include < stdlib.h >
#include <gdal.h>
#include <gdal_priv.h>
#include <gdalwarper.h>
//#include <ogr_geos.h>
#include <ogrsf_frmts.h> //#include "ogrsf_frmts.h"
#include <fstream>
#include <proj.h>
#include "GeoOperator.h"
#include "baseTool.h"
using namespace std;
using namespace Eigen;
QString getCurrentTimeString() {
struct tm ConversionTime;
std::time_t t = std::time(NULL);
char mbstr[100];
_localtime64_s(&ConversionTime, &t);
std::strftime(mbstr, sizeof(mbstr), "%Y-%m-%d %H:%M:%S", &ConversionTime);
QString strTime = mbstr;
return strTime;
}
QString getCurrentShortTimeString() {
struct tm ConversionTime;
std::time_t t = std::time(NULL);
char mbstr[100];
_localtime64_s(&ConversionTime, &t);
std::strftime(mbstr, sizeof(mbstr), "%Y-%m-%d %H:%M:%S", &ConversionTime);
QString strTime = mbstr;
return strTime;
}
std::vector<QString> splitString(const QString& str, char delimiter)
{
QStringList tokens = str.split(delimiter);
return convertQStringListToStdVector(tokens);
}
complex<double> Cubic_Convolution_interpolation(double u, double v, Eigen::MatrixX<complex<double>> img)
{
if (img.rows() != 4 || img.cols() != 4) {
throw exception("the size of img's block is not right");
}
// 斤拷锟斤拷模锟斤拷
Eigen::MatrixX<complex<double>> wrc(1, 4);// 使锟斤拷 complex<double> 斤拷锟斤拷要原斤拷为锟剿伙拷取值
Eigen::MatrixX<complex<double>> wcr(4, 1);//
for (int i = 0; i < 4; i++) {
wrc(0, i) = Cubic_kernel_weight(u + 1 - i); // u+1,u,u-1,u-2
wcr(i, 0) = Cubic_kernel_weight(v + 1 - i);
}
Eigen::MatrixX<complex<double>> interValue = wrc * img * wcr;
return interValue(0, 0);
}
complex<double> Cubic_kernel_weight(double s)
{
s = abs(s);
if (s <= 1) {
return complex<double>(1.5 * s * s * s - 2.5 * s * s + 1, 0);
}
else if (s <= 2) {
return complex<double>(-0.5 * s * s * s + 2.5 * s * s - 4 * s + 2, 0);
}
else {
return complex<double>(0, 0);
}
}
/// <summary>
/// p11 p12 -- x
/// p0(u,v)
/// p21 p22
/// |
/// y
/// p11(0,0)
/// p21(0,1)
/// P12(1,0)
/// p22(1,1)
/// </summary>
/// <param name="p0">x,y,z</param>
/// <param name="p1">x,y,z</param>
/// <param name="p2">x,y,z</param>
/// <param name="p3">x,y,z</param>
/// <param name="p4">x,y,z</param>
/// <returns></returns>
double Bilinear_interpolation(Landpoint p0, Landpoint p11, Landpoint p21, Landpoint p12, Landpoint p22)
{
return p11.ati * (1 - p0.lon) * (1 - p0.lat) +
p12.ati * p0.lon * (1 - p0.lat) +
p21.ati * (1 - p0.lon) * p0.lat +
p22.ati * p0.lon * p0.lat;
}
bool onSegment(Point_3d Pi, Point_3d Pj, Point_3d Q)
{
if ((Q.x - Pi.x) * (Pj.y - Pi.y) == (Pj.x - Pi.x) * (Q.y - Pi.y) //叉乘
//保证Q点坐标在pi,pj之间
&& min(Pi.x, Pj.x) <= Q.x && Q.x <= max(Pi.x, Pj.x)
&& min(Pi.y, Pj.y) <= Q.y && Q.y <= max(Pi.y, Pj.y))
return true;
else
return false;
}
Point_3d invBilinear(Point_3d p, Point_3d a, Point_3d b, Point_3d c, Point_3d d)
{
Point_3d res;
Point_3d e = b - a;
Point_3d f = d - a;
Point_3d g = a - b + c - d;
Point_3d h = p - a;
double k2 = cross2d(g, f);
double k1 = cross2d(e, f) + cross2d(h, g);
double k0 = cross2d(h, e);
double u, v;
// if edges are parallel, this is a linear equation
if (abs(k2) < 0.001)
{
v = -k0 / k1;
u = (h.x - f.x * v) / (e.x + g.x * v);
p.z = a.z + (b.z - a.z) * u + (d.z - a.z) * v + (a.z - b.z + c.z - d.z) * u * v;
return p;
}
// otherwise, it's a quadratic
else
{
float w = k1 * k1 - 4.0 * k0 * k2;
if (w < 0.0) {
// 可能在边界上
if (onSegment(a, b, p)) {
Point_3d tt = b - a;
Point_3d ttpa = p - a;
double scater = ttpa / tt;
if (scater < 0 || scater>1) { return { -9999,-9999,-9999 }; }
p.z = a.z + scater * tt.z;
return p;
}
else if (onSegment(b, c, p)) {
Point_3d tt = c - b;
Point_3d ttpa = p - b;
double scater = ttpa / tt;
if (scater < 0 || scater>1) { return { -9999,-9999,-9999 }; }
p.z = b.z + scater * tt.z;
return p;
}
else if (onSegment(c, d, p)) {
Point_3d tt = d - c;
Point_3d ttpa = p - c;
double scater = ttpa / tt;
if (scater < 0 || scater>1) { return { -9999,-9999,-9999 }; }
p.z = c.z + scater * tt.z;
return p;
}
else if (onSegment(d, a, p)) {
Point_3d tt = a - d;
Point_3d ttpa = p - d;
double scater = ttpa / tt;
if (scater < 0 || scater>1) { return { -9999,-9999,-9999 }; }
p.z = d.z + scater * tt.z;
return p;
}
return { -9999,-9999,-9999 };
}
else {
w = sqrt(w);
float ik2 = 0.5 / k2;
float v = (-k1 - w) * ik2;
float u = (h.x - f.x * v) / (e.x + g.x * v);
if (u < 0.0 || u>1.0 || v < 0.0 || v>1.0)
{
v = (-k1 + w) * ik2;
u = (h.x - f.x * v) / (e.x + g.x * v);
}
p.z = a.z + (b.z - a.z) * u + (d.z - a.z) * v + (a.z - b.z + c.z - d.z) * u * v;
return p;
}
}
p.z = a.z + (b.z - a.z) * u + (d.z - a.z) * v + (a.z - b.z + c.z - d.z) * u * v;
return p;
}
double sind(double degree)
{
return sin(degree * d2r);
}
double cosd(double d)
{
return cos(d * d2r);
}
string Convert(float Num)
{
ostringstream oss;
oss << Num;
string str(oss.str());
return str;
}
QString JoinPath(const QString& path, const QString& filename)
{
QDir dir(path);
// Ensure the path ends with the appropriate separator
if (!QDir::isAbsolutePath(path))
dir.makeAbsolute();
return dir.filePath(filename);
}
std::vector<QString> convertQStringListToStdVector(const QStringList& qStringList)
{
std::vector<QString> stdVector;
for (const QString& str : qStringList) {
stdVector.push_back(str);
}
return stdVector;
};

View File

@ -0,0 +1,93 @@
#pragma once
#pragma once
#ifndef BASETOOL_H
#define BASETOOL_H
///
/// 基本类、基本函数
///
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
//#include <mkl.h>
#include <complex>
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include <string>
#include <omp.h>
#include "referenceHeader.h"
#include <gdal.h>
#include <gdal_priv.h>
#include <gdalwarper.h>
#include <ogrsf_frmts.h>
#include <fstream>
#include "GeoOperator.h"
#include <vector>
#include <string>
using namespace std;
using namespace Eigen;
///////////////////////////////////// 运行时间打印 //////////////////////////////////////////////////////////
QString getCurrentTimeString();
QString getCurrentShortTimeString();
std::vector<QString> splitString(const QString& str, char delimiter);
/////////////////////////////// 基本图像类 结束 //////////////////////////////////////////////////////////
string Convert(float Num);
QString JoinPath(const QString& path, const QString& filename);
////////////////////////////// 坐标部分基本方法 //////////////////////////////////////////
////////////////////////////// 坐标部分基本方法 //////////////////////////////////////////
////////////////////////////// 插值 ////////////////////////////////////////////
complex<double> Cubic_Convolution_interpolation(double u, double v, Eigen::MatrixX<complex<double>> img);
complex<double> Cubic_kernel_weight(double s);
double Bilinear_interpolation(Landpoint p0, Landpoint p11, Landpoint p21, Landpoint p12, Landpoint p22);
bool onSegment(Point_3d Pi, Point_3d Pj, Point_3d Q);
Point_3d invBilinear(Point_3d p, Point_3d a, Point_3d b, Point_3d c, Point_3d d);
//
// WGS84 到J2000 坐标系的变换
// 参考网址https://blog.csdn.net/hit5067/article/details/116894616
// 资料网址http://celestrak.org/spacedata/
// 参数文件:
// a. Earth Orientation Parameter 文件: http://celestrak.org/spacedata/EOP-Last5Years.csv
// b. Space Weather Data 文件: http://celestrak.org/spacedata/SW-Last5Years.csv
// 备注上述文件是自2017年-五年内
/**
wgs84 J2000 WGS t ,BLH
step 1: WGS 84
step 2:
step 3:
step 4:
step 5: J2000
**/
double sind(double degree);
double cosd(double d);
#endif

View File

@ -0,0 +1,188 @@
#include "FileOperator.h"
#include <boost/filesystem.hpp>
#include <string>
#include <memory.h>
#include <memory>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <QDebug>
std::vector<QString> getFilelist(const QString& folderpath, const QString& filenameExtension, int (*logfun)(QString logtext, int value))
{
QString filenameExtensionStr = filenameExtension;
filenameExtensionStr = filenameExtensionStr.remove(0, 1);
std::vector<QString> filenames(0);
if (isExists(folderpath) && isDirectory(folderpath)) {
QDir directory(folderpath);
if (directory.exists() && directory.isReadable()) {
QFileInfoList fileList = directory.entryInfoList(QDir::Files | QDir::NoDotAndDotDot);
for (const QFileInfo& fileInfo : fileList) {
qDebug() << fileInfo.filePath() + "\nExtension: (" + filenameExtensionStr + ", " + fileInfo.suffix() + ")";
if (filenameExtensionStr == u8"*" || filenameExtensionStr == fileInfo.suffix()) {
filenames.push_back(fileInfo.filePath());
}
if (logfun) {
logfun(fileInfo.filePath() + "\nExtension: (" + filenameExtensionStr + ", " + fileInfo.suffix() + ")", 4);
}
}
}
else {
qWarning() << "Folder does not exist or is not readable: " << folderpath;
}
return filenames;
}
else {
return std::vector<QString>(0);
}
}
QString getParantFolderNameFromPath(const QString& path)
{
QDir directory(path);
directory.cdUp();
QString parentPath = directory.absolutePath();
return directory.dirName();
}
QString getParantFromPath(const QString& path)
{
//qDebug() << path;
QDir directory(path);
directory.cdUp();
QString parentPath = directory.absolutePath();
//qDebug() << parentPath;
return parentPath;
}
QString getFileNameFromPath(const QString& path)
{
QFileInfo fileInfo(path);
return fileInfo.fileName();
}
bool isDirectory(const QString& path)
{
QFileInfo fileinfo(path);
return fileinfo.isDir();
}
bool isExists(const QString& path)
{
QFileInfo fileinfo(path);
return fileinfo.exists();
}
bool isFile(const QString& path)
{
QFileInfo fileinfo(path);
return fileinfo.isFile();
}
int write_binfile(char* filepath, char* data, size_t data_len)
{
FILE* pd = fopen(filepath, "w");
if (NULL == pd) {
return 2;
}
//数据块首地址: "&a",元素大小: "sizeof(unsigned __int8)" 元素个数: "10" 文件指针:"pd"
fwrite(data, sizeof(char), data_len, pd);
fclose(pd);
return -1;
}
char* read_textfile(char* text_path, int* length)
{
char* data = NULL;
FILE* fp1 = fopen(text_path, "r");
if (fp1 == NULL) {
return NULL;
}
else {}
// 读取文件
fseek(fp1, 0, SEEK_END);
int data_length = ftell(fp1);
data = (char*)malloc((data_length + 1) * sizeof(char));
rewind(fp1);
if (data_length == fread(data, sizeof(char), data_length, fp1)) {
data[data_length] = '\0'; // 文件尾
}
else {
free(data);
fclose(fp1);
return NULL;
}
fclose(fp1);
*length = data_length + 1;
return data;
}
bool exists_test(const QString& name)
{
return isExists(name);
}
size_t fsize(FILE* fp)
{
size_t n;
fpos_t fpos; // 当前位置
fgetpos(fp, &fpos); // 获取当前位置
fseek(fp, 0, SEEK_END);
n = ftell(fp);
fsetpos(fp, &fpos); // 恢复之前的位置
return n;
}
void removeFile(const QString& filePath)
{
QFile file(filePath);
if (file.exists()) {
if (file.remove()) {
qDebug() << "File removed successfully: " << filePath;
}
else {
qWarning() << "Failed to remove file: " << filePath;
}
}
else {
qDebug() << "File does not exist: " << filePath;
}
}
unsigned long convertToULong(const QString& input) {
bool ok; // Used to check if the conversion was successful
unsigned long result = input.toULong(&ok);
if (!ok) {
qWarning() << "Conversion to unsigned long failed for input: " << input;
}
return result;
}
void copyFile(const QString& sourcePath, const QString& destinationPath) {
QFile sourceFile(sourcePath);
QFile destinationFile(destinationPath);
if (sourceFile.exists()) {
if (sourceFile.copy(destinationPath)) {
// 复制成功
//QMessageBox::information(nullptr, u8"成功", u8"文件复制成功");
}
else {
// 复制失败
QMessageBox::critical(nullptr, u8"错误", u8"文件复制失败");
}
}
else {
// 源文件不存在
QMessageBox::warning(nullptr, u8"警告", u8"源文件不存在");
}
}

View File

@ -0,0 +1,50 @@
#pragma once
#ifndef FILEOPERATOR_H
#define FILEOPERATOR_H
#include "referenceHeader.h"
#include <string.h>
#include <memory.h>
#include <memory>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
#include <QString>
#include <QDir>
#include <QFile>
#include <QDebug>
bool isDirectory(const QString& path);
bool isExists(const QString& path);
bool isFile(const QString& path);
void removeFile(const QString& filePath);
unsigned long convertToULong(const QString& input);
/// <summary>
/// »ñÈ¡Îļþ(¾ø¶Ô·¾¶£©
/// </summary>
/// <param name="folderpath"></param>
/// <param name="FilenameExtension"></param>
/// <returns></returns>
std::vector<QString> getFilelist(const QString& folderpath, const QString& FilenameExtension = ".*",int (*logfun)(QString logtext,int value)=nullptr);
QString getParantFolderNameFromPath(const QString& path);
QString getFileNameFromPath(const QString& path);
int write_binfile(char* filepath, char* data, size_t data_len);
char* read_textfile(char* text_path, int* length);
bool exists_test(const QString& name);
size_t fsize(FILE* fp);
QString getParantFromPath(const QString& path);
void copyFile(const QString& sourcePath, const QString& destinationPath);
// QT FileOperator
#endif

View File

@ -0,0 +1,271 @@
#include "GeoOperator.h"
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
//#include <mkl.h>
#include <string>
#include <omp.h>
#include < io.h >
#include < stdio.h >
#include < stdlib.h >
#include <gdal.h>
#include <gdal_priv.h>
#include <gdalwarper.h>
//#include <ogr_geos.h>
#include <ogrsf_frmts.h> //#include "ogrsf_frmts.h"
#include <fstream>
#include <proj.h>
using namespace std;
using namespace Eigen;
Landpoint operator +(const Landpoint& p1, const Landpoint& p2)
{
return Landpoint{ p1.lon + p2.lon,p1.lat + p2.lat,p1.ati + p2.ati };
}
Landpoint operator -(const Landpoint& p1, const Landpoint& p2)
{
return Landpoint{ p1.lon - p2.lon,p1.lat - p2.lat,p1.ati - p2.ati };
}
bool operator ==(const Landpoint& p1, const Landpoint& p2)
{
return p1.lat == p2.lat && p1.lon == p2.lon && p1.ati == p2.ati;
}
Landpoint operator *(const Landpoint& p, double scale)
{
return Landpoint{
p.lon * scale,
p.lat * scale,
p.ati * scale
};
}
Landpoint LLA2XYZ(const Landpoint& LLA) {
double L = LLA.lon * d2r;
double B = LLA.lat * d2r;
double H = LLA.ati;
double sinB = sin(B);
double cosB = cos(B);
//double N = a / sqrt(1 - e * e * sin(B) * sin(B));
double N = a / sqrt(1 - eSquare * sinB * sinB);
Landpoint result = { 0,0,0 };
result.lon = (N + H) * cosB * cos(L);
result.lat = (N + H) * cosB * sin(L);
//result.z = (N * (1 - e * e) + H) * sin(B);
result.ati = (N * (1 - 1 / f_inverse) * (1 - 1 / f_inverse) + H) * sinB;
return result;
}
Eigen::MatrixXd LLA2XYZ(Eigen::MatrixXd landpoint)
{
landpoint.col(0) = landpoint.col(0).array() * d2r; // lon
landpoint.col(1) = landpoint.col(1).array() * d2r; // lat
Eigen::MatrixXd sinB = (landpoint.col(1).array().sin());//lat
Eigen::MatrixXd cosB = (landpoint.col(1).array().cos());//lat
Eigen::MatrixXd N = a / ((1 - sinB.array().pow(2) * eSquare).array().sqrt());
Eigen::MatrixXd result(landpoint.rows(), 3);
result.col(0) = (N.array() + landpoint.col(2).array()) * cosB.array() * Eigen::cos(landpoint.col(0).array()).array(); //x
result.col(1) = (N.array() + landpoint.col(2).array()) * cosB.array() * Eigen::sin(landpoint.col(0).array()).array(); //y
result.col(2) = (N.array() * (1 - 1 / f_inverse) * (1 - 1 / f_inverse) + landpoint.col(2).array()) * sinB.array(); //z
return result;
}
Landpoint XYZ2LLA(const Landpoint& XYZ) {
double tmpX = XYZ.lon;//
double temY = XYZ.lat;//
double temZ = XYZ.ati;
double curB = 0;
double N = 0;
double sqrtTempXY = sqrt(tmpX * tmpX + temY * temY);
double calB = atan2(temZ, sqrtTempXY);
int counter = 0;
double sinCurB = 0;
while (abs(curB - calB) * r2d > epsilon && counter < 25)
{
curB = calB;
sinCurB = sin(curB);
N = a / sqrt(1 - eSquare * sinCurB * sinCurB);
calB = atan2(temZ + N * eSquare * sinCurB, sqrtTempXY);
counter++;
}
Landpoint result = { 0,0,0 };
result.lon = atan2(temY, tmpX) * r2d;
result.lat = curB * r2d;
result.ati = temZ / sinCurB - N * (1 - eSquare);
return result;
}
double getAngle(const Landpoint& a, const Landpoint& b)
{
double c = dot(a, b) / (getlength(a) * getlength(b));
if (a.lon * b.lat - a.lat * b.lon >= 0) {
return acos(c > 1 ? 1 : c < -1 ? -1 : c) * r2d;
}
else {
return 360 - acos(c > 1 ? 1 : c < -1 ? -1 : c) * r2d;
}
}
double dot(const Landpoint& p1, const Landpoint& p2)
{
return p1.lat * p2.lat + p1.lon * p2.lon + p1.ati * p2.ati;
}
double getlength(const Landpoint& p1) {
return sqrt(dot(p1, p1));
}
Landpoint crossProduct(const Landpoint& a, const Landpoint& b) {
return Landpoint{
a.lat * b.ati - a.ati * b.lat,//x
a.ati * b.lon - a.lon * b.ati,//y
a.lon * b.lat - a.lat * b.lon//z
};
}
float cross2d(Point_3d a, Point_3d b)
{
return a.x * b.y - a.y * b.x;
}
Point_3d operator -(Point_3d a, Point_3d b)
{
return Point_3d{ a.x - b.x, a.y - b.y, a.z - b.z };
}
Point_3d operator +(Point_3d a, Point_3d b)
{
return Point_3d{ a.x + b.x, a.y + b.y, a.z + b.z };
}
double operator /(Point_3d a, Point_3d b)
{
return sqrt(pow(a.x, 2) + pow(a.y, 2)) / sqrt(pow(b.x, 2) + pow(b.y, 2));
}
Landpoint getSlopeVector(const Landpoint& p0, const Landpoint& p1, const Landpoint& p2, const Landpoint& p3, const Landpoint& p4) {
Landpoint n0 = LLA2XYZ(p0),
n1 = LLA2XYZ(p1),
n2 = LLA2XYZ(p2),
n3 = LLA2XYZ(p3),
n4 = LLA2XYZ(p4);
Landpoint n01 = n1 - n0, n02 = n2 - n0, n03 = n3 - n0, n04 = n4 - n0;
// <20><>n01Ϊ<31><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Landpoint np01 = p1 - p0, np02 = p2 - p0, np03 = p3 - p0, np04 = p4 - p0;
double a2 = getAngle(Landpoint{ np01.lon,np01.lat,0 }, Landpoint{ np02.lon,np02.lat,0 });// 01->02 <20><>ʱ<EFBFBD><CAB1>
double a3 = getAngle(Landpoint{ np01.lon,np01.lat,0 }, Landpoint{ np03.lon,np03.lat,0 });// 01->03 <20><>ʱ<EFBFBD><CAB1>
double a4 = getAngle(Landpoint{ np01.lon,np01.lat,0 }, Landpoint{ np04.lon,np04.lat,0 });// 01->04 <20><>ʱ<EFBFBD><CAB1>
//qDebug() << a2 << "\t" << a3 << "\t" << a4 << endl;
a2 = 360 - a2;
a3 = 360 - a3;
a4 = 360 - a4;
Landpoint N, W, S, E;
N = n01;
if (a2 >= a3 && a2 >= a4) {
W = n02;
if (a3 >= a4) {
S = n03;
E = n04;
}
else {
S = n04;
E = n03;
}
}
else if (a3 >= a2 && a3 >= a4) {
W = n03;
if (a2 >= a4) {
S = n02;
E = n04;
}
else {
S = n04;
E = n02;
}
}
else if (a4 >= a2 && a4 >= a3)
{
W = n04;
if (a2 >= a3) {
S = n02;
E = n03;
}
else {
S = n03;
E = n02;
}
}
return (crossProduct(N, W) + crossProduct(W, S) + crossProduct(S, E) + crossProduct(E, N)) * 0.25;
}
double distance(const Vector3D& p1, const Vector3D& p2)
{
double dx = p1.x - p2.x;
double dy = p1.y - p2.y;
double dz = p1.z - p2.z;
return std::sqrt(dx * dx + dy * dy + dz * dz);
}
double pointToLineDistance(const Vector3D& point, const Vector3D& linePoint, const Vector3D& lineDirection)
{
Vector3D pointToLine = { point.x - linePoint.x, point.y - linePoint.y, point.z - linePoint.z };
// 计算点到直线的投影点的位置
double t = (pointToLine.x * lineDirection.x + pointToLine.y * lineDirection.y + pointToLine.z * lineDirection.z) /
(lineDirection.x * lineDirection.x + lineDirection.y * lineDirection.y + lineDirection.z * lineDirection.z);
// 计算投影点
Vector3D projection = { linePoint.x + t * lineDirection.x, linePoint.y + t * lineDirection.y, linePoint.z + t * lineDirection.z };
// 计算点到直线的距离
return distance(point, projection);
}
SphericalCoordinates cartesianToSpherical(const CartesianCoordinates& cartesian)
{
SphericalCoordinates spherical;
spherical.r = std::sqrt(cartesian.x * cartesian.x + cartesian.y * cartesian.y + cartesian.z * cartesian.z);
spherical.theta = std::acos(cartesian.z / spherical.r);
spherical.phi = std::atan2(cartesian.y, cartesian.x);
return spherical;
}
CartesianCoordinates sphericalToCartesian(const SphericalCoordinates& spherical)
{
CartesianCoordinates cartesian;
cartesian.x = spherical.r * std::sin(spherical.theta) * std::cos(spherical.phi);
cartesian.y = spherical.r * std::sin(spherical.theta) * std::sin(spherical.phi);
cartesian.z = spherical.r * std::cos(spherical.theta);
return cartesian;
}

View File

@ -0,0 +1,111 @@
#pragma once
#ifndef GEOOPERATOR_H
#define GEOOPERATOR_H
#include "BaseConstVariable.h"
#include <Eigen/Core>
#include <Eigen/Dense>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <iostream>
/// <summary>
/// 三维向量,坐标表达
/// </summary>
struct Landpoint // 点 SAR影像的像素坐标
{
/// <summary>
/// 经度x
/// </summary>
double lon; // 经度x lon pixel_col
/// <summary>
/// 纬度y
/// </summary>
double lat; // 纬度y lat pixel_row
/// <summary>
/// 高度z
/// </summary>
double ati; // 高程z ati pixel_time
};
struct Point_3d {
double x;
double y;
double z;
};
/// <summary>
/// 将经纬度转换为地固参心坐标系
/// </summary>
/// <param name="XYZP">经纬度点--degree</param>
/// <returns>投影坐标系点</returns>
Landpoint LLA2XYZ(const Landpoint& LLA);
Eigen::MatrixXd LLA2XYZ(Eigen::MatrixXd landpoint);
/// <summary>
/// 将地固参心坐标系转换为经纬度
/// </summary>
/// <param name="XYZ">固参心坐标系</param>
/// <returns>经纬度--degree</returns>
Landpoint XYZ2LLA(const Landpoint& XYZ);
Landpoint operator +(const Landpoint& p1, const Landpoint& p2);
Landpoint operator -(const Landpoint& p1, const Landpoint& p2);
bool operator ==(const Landpoint& p1, const Landpoint& p2);
Landpoint operator *(const Landpoint& p, double scale);
double getAngle(const Landpoint& a, const Landpoint& b);
double dot(const Landpoint& p1, const Landpoint& p2);
double getlength(const Landpoint& p1);
Landpoint crossProduct(const Landpoint& a, const Landpoint& b);
Landpoint getSlopeVector(const Landpoint& p0, const Landpoint& p1, const Landpoint& p2, const Landpoint& p3, const Landpoint& p4);
float cross2d(Point_3d a, Point_3d b);
Point_3d operator -(Point_3d a, Point_3d b);
Point_3d operator +(Point_3d a, Point_3d b);
double operator /(Point_3d a, Point_3d b);
// 矢量计算
struct Vector3D {
double x, y, z;
};
// 计算两点之间的距离
double distance(const Vector3D& p1, const Vector3D& p2);
// 计算点到直线的最短距离
double pointToLineDistance(const Vector3D& point, const Vector3D& linePoint, const Vector3D& lineDirection);
struct CartesianCoordinates {
double x, y, z;
};
struct SphericalCoordinates {
double r, theta, phi;
};
SphericalCoordinates cartesianToSpherical(const CartesianCoordinates& cartesian);
CartesianCoordinates sphericalToCartesian(const SphericalCoordinates& spherical);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,190 @@
#pragma once
/**
*
* ENVI
* GDAL
* **/
#ifndef IMAGEOPERATORBASE_H
#define IMAGEOPERATORBASE_H
#include "BaseToollib/BaseConstVariable.h"
#include "BaseToollib/GeoOperator.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <complex>
#include <gdal.h>
#include <gdal_priv.h>
#include <gdalwarper.h>
#include <string>
#include <memory>
#include <QString>
#include <cpl_conv.h> // for CPLMalloc()
#include "referenceHeader.h"
using namespace std;
using namespace Eigen;
struct ImageGEOINFO {
int width;
int height;
int bandnum;
};
// 判断是否需要输出为DLL
#define DLLOUT
// 文件打开
std::shared_ptr<GDALDataset> OpenDataset(const QString& in_path, GDALAccess rwmode= GA_ReadOnly); // 当指令销毁时调用GDALClose 销毁类型
void CloseDataset(GDALDataset* ptr);
// 数据格式转换
int TIFF2ENVI(QString in_tiff_path,QString out_envi_path);
int ENVI2TIFF(QString in_envi_path,QString out_tiff_path);
// 保存影像数据 --直接保存 ENVI 文件
int CreateDataset(QString new_file_path, int height, int width, int band_num, double* gt, QString projection, GDALDataType gdal_dtype, bool need_gt); // 创建文件
int saveDataset(QString new_file_path, int start_line, int start_cols, int band_ids, int datacols, int datarows, void* databuffer);
// 根据限制条件估算分块大小
int block_num_pre_memory(int width, int height, GDALDataType gdal_dtype,double memey_size);
// 将结果转换为复数 或者 实数
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> ReadComplexMatrixData(int start_line,int width, int line_num, std::shared_ptr<GDALDataset> rasterDataset, GDALDataType gdal_datatype);
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> ReadMatrixDoubleData(int start_line, int width, int line_num, std::shared_ptr<GDALDataset> rasterDataset, GDALDataType gdal_datatype,int band_idx);
Eigen::MatrixXd getGeoTranslationArray(QString in_path);
ImageGEOINFO getImageINFO(QString in_path);
GDALDataType getGDALDataType(QString fileptah);
struct DemBox {
double min_lat; //纬度
double min_lon;//经度
double max_lat;//纬度
double max_lon;//经度
};
/// <summary>
/// gdalImage图像操作类
/// </summary>
class gdalImage
{
public: // 方法
gdalImage();
gdalImage(const QString& raster_path);
~gdalImage();
virtual void setHeight(int);
virtual void setWidth(int);
virtual void setTranslationMatrix(Eigen::MatrixXd gt);
virtual void setData(Eigen::MatrixXd,int data_band_ids=1);
virtual Eigen::MatrixXd getData(int start_row, int start_col, int rows_count, int cols_count, int band_ids);
virtual Eigen::MatrixXd getGeoTranslation();
virtual GDALDataType getDataType();
virtual void saveImage(Eigen::MatrixXd, int start_row, int start_col, int band_ids);
virtual void saveImage();
virtual void setNoDataValue(double nodatavalue, int band_ids);
virtual int InitInv_gt();
virtual Landpoint getRow_Col(double lon, double lat);
virtual Landpoint getLandPoint(double i, double j, double ati);
virtual double mean(int bandids = 1);
virtual double max(int bandids = 1);
virtual double min(int bandids = 1);
virtual GDALRPCInfo getRPC();
virtual Eigen::MatrixXd getLandPoint(Eigen::MatrixXd points);
virtual Eigen::MatrixXd getHist(int bandids);
public:
QString img_path; // 图像文件
int height; // 高
int width; // 宽
int band_num;// 波段数
int start_row;//
int start_col;//
int data_band_ids;
Eigen::MatrixXd gt; // 变换矩阵
Eigen::MatrixXd inv_gt; // 逆变换矩阵
Eigen::MatrixXd data;
QString projection;
};
/// <summary>
/// gdalImage图像操作类
/// </summary>
class gdalImageComplex:public gdalImage
{
public: // 方法
gdalImageComplex(const QString& raster_path);
~gdalImageComplex();
void setData(Eigen::MatrixXcd);
void saveImage(Eigen::MatrixXcd data, int start_row, int start_col, int band_ids);
Eigen::MatrixXcd getDataComplex(int start_row, int start_col, int rows_count, int cols_count, int band_ids);
void saveImage() override;
public:
Eigen::MatrixXcd data;
};
gdalImage CreategdalImage(const QString& img_path, int height, int width, int band_num, Eigen::MatrixXd gt, QString projection, bool need_gt = true, bool overwrite = false);
gdalImageComplex CreategdalImageComplex(const QString& img_path, int height, int width, int band_num, Eigen::MatrixXd gt, QString projection, bool need_gt = true, bool overwrite = false);
int ResampleGDAL(const char* pszSrcFile, const char* pszOutFile, double* gt, int new_width, int new_height, GDALResampleAlg eResample);
int ResampleGDALs(const char* pszSrcFile, int band_ids, GDALRIOResampleAlg eResample = GRIORA_Bilinear);
//--------------------- 保存文博 -------------------------------
int saveMatrixXcd2TiFF(Eigen::MatrixXcd data, QString out_tiff_path);
//----------------------------------------------------
#ifndef DLLOUT
#else
//#define DllExport __declspec( dllexport )
//double __declspec(dllexport) ProcessMGCMathX_MGC(int Xbetaidx, int Xbwidx, double XTao, double satH, char* sigma_path, char* output_path,
// double p1_x, double p1_y, double p2_x, double p2_y, double p3_x, double p3_y, double p4_x, double p4_y)
#endif
#endif

View File

@ -0,0 +1,13 @@
#include "BaseToolLib/interpolation.h"
#include <Eigen/Core>
#include <Eigen/Dense>
#include <stdio.h>
#include <stdlib.h>
#include <Eigen/Core>
#include <Eigen/Dense>
namespace LampInterpolation {
}

View File

@ -0,0 +1,69 @@
#pragma once
#ifndef INTERPOLATION_H
#define INTERPOLATION_H
#include <complex>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <stdio.h>
#include <stdlib.h>
#include <Eigen/Core>
#include <Eigen/Dense>
namespace LampInterpolation {
enum interpolationtype {
nearest,
linear,
cubic,
};
/// <summary>
/// 矩阵为 1xn
/// </summary>
template<typename T>
std::complex<T> interpolation(Eigen::MatrixX<std::complex<T>>& echo, double& index, interpolationtype methodtype)
{
assert(echo.rows() != 1 || echo.cols() >= index || index < 0); // 断言
if (methodtype == interpolationtype::linear) {
return interpolationLinear(echo, index);
}
else if (methodtype == interpolationtype::cubic) {
}
else if (methodtype == interpolationtype::nearest) {
return interpolationNearest(echo, index);
}
else {}
return std::complex<T>(0, 0);
};
template<typename T>
std::complex<T> interpolationLinear(Eigen::MatrixX<std::complex<T>>& echo, double& index)
{
size_t last_ids = size_t(std::floor(index));
size_t next_ids = size_t(std::ceil(index));
std::complex<T> last_value = echo(1, last_ids);
std::complex<T> next_value = echo(1, next_ids);
// 实部,虚部同时插值
double real = last_value.real() + ((next_value.real() - last_value.real()) / (next_ids - last_ids)) * (index - last_ids);
double imag = last_value.imag() + ((next_value.imag() - last_value.imag()) / (next_ids - last_ids)) * (index - last_ids);
return std::complex<T>(T(real), T(imag));
};
template<typename T>
std::complex<T> interpolationNearest(Eigen::MatrixX<std::complex<T>>& echo, double& index)
{
size_t nearest_ids = size_t(std::round(index));
return echo(1, nearest_ids);
};
}
#endif

View File

@ -0,0 +1,2 @@
# 说明
此模块主要是通用基础模块

View File

@ -0,0 +1,68 @@
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
#-----------------------------------------------------------------------------
# include
#-----------------------------------------------------------------------------
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
set(_qrc "${CMAKE_CURRENT_SOURCE_DIR}/../qrc/WBCLFZSystemModule.qrc")
qt5_add_resources(_resource ${_qrc} ${_lang})
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
file(GLOB _ui "*.ui")
file(GLOB _header "*.h*")
file(GLOB _source "*.cpp")
qt5_wrap_ui(_interface ${_ui})
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
add_library(LAMPTool
${_resource}
${_interface}
${_header}
${_source}
)
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
target_compile_definitions(LAMPTool PRIVATE "LAMPTool_API")
list(APPEND _depend_library qcustomplot)
list(APPEND _runtimes_libraries
Qt5::Core Qt5::Gui Qt5::Widgets
)
target_include_directories(LAMPTool PRIVATE ${Qwt_INCLUDE_DIRS})
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
target_link_libraries(LAMPTool PRIVATE
${_runtimes_libraries}
${_depend_library}
)
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
add_dependencies(LAMPTool ${_depend_library})
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
set(FastCAE_LAMPTool_Runtimes_Libraries ${_runtimes_libraries} PARENT_SCOPE)

View File

@ -0,0 +1,446 @@
#include "FEKOFarFieldFileClass.h"
FEKOBase::FEKOFarFieldFileClass::FEKOFarFieldFileClass()
{
}
FEKOBase::FEKOFarFieldFileClass::~FEKOFarFieldFileClass()
{
}
void FEKOBase::FEKOFarFieldFileClass::parseFarFieldFile(const QString& fileName)
{
QFile file(fileName);
// 加载文本文件中的所有数据到一个 QString 中
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug() << "Failed to open file for reading";
return;
}
QTextStream in(&file);
QString line;
bool dataSectionStarted = false;
QList<QString> dataBlockStrList;
dataBlockStrList.clear();
while (!in.atEnd()) {
line = in.readLine().trimmed();
if (line.startsWith(u8"##")) {
if (line.indexOf(u8"File Type:") != -1) {
this->FileType = line.split(":")[1].trimmed();
}
else if (line.indexOf(u8"File Format:") != -1) {
this->FileFormat = line.split(":")[1].trimmed();
}
else if (line.indexOf(u8"Source:") != -1) {
this->Sourcestr = line.split(":")[1].trimmed();
}
else if (line.indexOf(u8"Date:") != -1) {
this->Datestr = line.split(":")[1].trimmed();
}
else {
continue;
}
}
else if (line.startsWith("**")) {
dataBlockStrList.clear();
continue;
}
else {
if (line.length() < 5) {
if (dataBlockStrList.length() > 0) {
FEKOFARFIELDFEKODATABLOCK temp_dataBlock;
temp_dataBlock.paraseFEKOFarFieldDataBlockFromList(dataBlockStrList);
this->dataBlockList.push_back(temp_dataBlock);
}
else {
}
dataBlockStrList.clear();
}
else {
dataBlockStrList.append(line);
}
}
}
if (dataBlockStrList.length() > 0) {
FEKOFARFIELDFEKODATABLOCK temp_dataBlock;
temp_dataBlock.paraseFEKOFarFieldDataBlockFromList(dataBlockStrList);
this->dataBlockList.push_back(temp_dataBlock);
}
file.close();
}
void FEKOBase::FEKOFarFieldFileClass::outputToFile(const QString& fileName)
{
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
qDebug() << "Failed to open file for writing";
return;
}
QTextStream out(&file);
file.close();
}
FEKOBase::FEKOFARFIELDRESULTTYPE FEKOBase::FEKOFARFIELDRESULTTYPEString2Enum(QString str)
{
if (str.toUpper() == "GAIN") { return FEKOBase::GAIN; }
else if (str.toUpper() == "DIRECTIVITY") { return FEKOBase::DIRECTIVITY; }
else if (str.toUpper() == "RCS") { return FEKOBase::RCS; }
else if (str.toUpper() == "FARFIELDVALUES") { return FEKOBase::FARFIELDVALUES; }
else {
return FEKOBase::FEKOFARFIELDRESULTTYPEUNKOWN;
}
return FEKOBase::FEKOFARFIELDRESULTTYPE();
}
QString FEKOBase::QString2FEKOFARFIELDRESULTTYPE(FEKOBase::FEKOFARFIELDRESULTTYPE mode)
{
switch (mode) {
case FEKOBase::GAIN:
return "GAIN";
case FEKOBase::DIRECTIVITY:
return "DIRECTIVITY";
case FEKOBase::RCS:
return "RCS";
case FEKOBase::FARFIELDVALUES:
return "FARFIELDVALUES";
default:
return "FEKOFARFIELDRESULTTYPEUNKOWN";
}
}
FEKOBase::FEKOFARFIELDFEKODATABLOCK::FEKOFARFIELDFEKODATABLOCK()
{
this->dataList.clear();
this->thetaSamples = 0;
this->phiSamples = 0;
this->USamples = 0;
this->VSamples = 0;
this->configurationName.clear();
this->requestName.clear();
this->frequency = 0;
this->Origin = { 0,0,0 };
this->headerLines = 0;
this->coordinateSystem = FEKOBase::UNKONWFEKOCOORDINATESYSTEM;
this->resultType = FEKOBase::FEKOFARFIELDRESULTTYPEUNKOWN;
}
FEKOBase::FEKOFARFIELDFEKODATABLOCK::~FEKOFARFIELDFEKODATABLOCK()
{
}
int FEKOBase::FEKOFARFIELDFEKODATABLOCK::paraseFEKOFarFieldDataBlock(const QString& blockstr)
{
// 按行进行解析
QList<QString> lines= blockstr.split("\n");
return this->paraseFEKOFarFieldDataBlockFromList(lines);
return 1;
}
int FEKOBase::FEKOFARFIELDFEKODATABLOCK::paraseFEKOFarFieldDataBlockFromList(QList<QString>& lines)
{
bool in_readHeaderState = false;
size_t headerlineCount = 0;
std::vector<QString> headerLines;// 解析行列时保证结果
for (size_t i = 0; i < lines.size(); i++) {
if (lines[i].startsWith("#")) { // 参数项是以# 开头作为配置项
// 针对不同参数项提取参数
QString configName = normalizationHeaderString(lines[i]); // 获取参数的归一化名称
if (configName == u8"") { // 未知参数项
// 进入字段解析状态
if (in_readHeaderState) { // 解析字段
QList<QString> temp_headerLines=lines[i].split(FEKOFARFIELDSPLITCHAT);
for (size_t ii = 0; ii < temp_headerLines.size();ii++) {
if (temp_headerLines[ii].length() > 2) {
QString temp_header_str= this->normalizationHeaderString(temp_headerLines[ii]);
headerLines.push_back(temp_header_str);
}
else {
continue;
}
}
headerlineCount++;
if (headerlineCount >= this->headerLines) {
in_readHeaderState = false;
}
}
else {
continue;
}
}
else if (configName == u8"ConfigurationName") {
this->configurationName = lines[i].split(":")[1].trimmed();
}
else if (configName == u8"RequestName") {
this->requestName = lines[i].split(":")[1].trimmed();
}
else if (configName == u8"Frequency") {
this->frequency = lines[i].split(":")[1].trimmed().toDouble();
}
else if (configName == u8"CoordinateSystem") {
this->coordinateSystem = FEKOBase::FEKOCoordinateSystemString2Enum(lines[i].split(":")[1].trimmed());
}
else if (configName == u8"ThetaSamplePointsNumber") {
this->thetaSamples = lines[i].split(":")[1].trimmed().toInt();
}
else if (configName == u8"PhiSamplePointsNumber") {
this->phiSamples = lines[i].split(":")[1].trimmed().toInt();
}
else if (configName == u8"USamplePointNumber") {
this->USamples = lines[i].split(":")[1].trimmed().toInt();
}
else if (configName == u8"VSamplePointNumber") {
this->VSamples = lines[i].split(":")[1].trimmed().toInt();
}
else if (configName == u8"ORIGIN") {
QStringList originstrlist = lines[i].replace("(", "").replace(")", "").split(":")[1].trimmed().split(",");
this->Origin = { originstrlist[0].trimmed().toDouble(),originstrlist[1].trimmed().toDouble(),originstrlist[2].trimmed().toDouble() };
}
else if (configName == u8"ResultType") {
this->resultType = FEKOBase::FEKOFARFIELDRESULTTYPEString2Enum(lines[i].split(":")[1].trimmed());
}
else if (configName == u8"HeaderLines") {
this->headerLines = lines[i].split(":")[1].trimmed().toInt();
in_readHeaderState = true;
}
else {
continue;
}
}
else if (lines[i].size() > 10) { // 解析数据块
QList<QString> dataline = lines[i].split(FEKOFARFIELDSPLITCHAT);
FEKOBase::FEKOFarFieldFEKOFarFieldData temp_data;
long field_idx =-1;
for (size_t ii = 0; ii < dataline.count(); ii++) {
if (dataline[ii] == u8"") { continue; }
else { field_idx = field_idx + 1; }
if (headerLines[field_idx] == "theta") { temp_data.theta = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "phi") { temp_data.phi = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "re(etheta)") { temp_data.re_Etheta = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "im(etheta)") { temp_data.im_Etheta = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "re(ephi)") { temp_data.re_Ephi = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "im(ephi)") { temp_data.im_Ephi = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "gain(theta)") { temp_data.gain_Theta = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "gain(phi)") { temp_data.gain_Phi = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "gain(total)") { temp_data.gain_Total = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "radius") { temp_data.radius = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "x") { temp_data.X = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "y") { temp_data.Y = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "z") { temp_data.Z = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "re(ex)") { temp_data.re_Ex = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "re(ey)") { temp_data.re_Ey = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "re(ez)") { temp_data.re_Ez = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "im(ex)") { temp_data.im_Ex = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "im(ey)") { temp_data.im_Ey = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "im(ez)") { temp_data.im_Ez = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "re(er)") { temp_data.re_Er = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "im(er)") { temp_data.im_Er = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "u") { temp_data.U = dataline[ii].toDouble(); }
else if (headerLines[field_idx] == "v") { temp_data.V = dataline[ii].toDouble(); }
else {
continue;
}
}
this->dataList.push_back(temp_data);
}
else {
continue;
}
}
return 0;
}
QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::normalizationHeaderString(QString headerstr)
{
headerstr = headerstr.replace("'", "").replace(u8"\"",u8"");
if(headerstr.indexOf("#Configuration Name") != -1)
{
return u8"ConfigurationName";
}
else if (headerstr.indexOf("#Request Name") != -1)
{
return u8"RequestName";
}
else if (headerstr.indexOf("#Frequency") != -1)
{
return u8"Frequency";
}
else if (headerstr.indexOf("#Coordinate System:") != -1)
{
return u8"CoordinateSystem";
}
else if (headerstr.indexOf("#No. of Theta Samples:") != -1)
{
return u8"ThetaSamplePointsNumber";
}
else if (headerstr.indexOf("#No. of Phi Samples:") != -1)
{
return u8"PhiSamplePointsNumber";
}
else if (headerstr.indexOf("#No. of U Samples:") != -1)
{
return u8"USamplePointNumber";
}
else if (headerstr.indexOf("#No. of V Samples:") != -1)
{
return u8"VSamplePointNumber";
}
else if (headerstr.indexOf("#No. of X Samples:") != -1)
{
return u8"XSamplePointNumber";
}
else if (headerstr.indexOf("#No. of Y Samples:") != -1)
{
return u8"YSamplePointNumber";
}
else if (headerstr.indexOf("#No. of Z Samples:") != -1)
{
return u8"ZSamplePointNumber";
}
else if (headerstr.indexOf("#Origin:") != -1)
{
return u8"ORIGIN";
}
else if (headerstr.indexOf("#Result Type:") != -1)
{
return u8"ResultType";
}
else if (headerstr.indexOf("#No. of Header Lines:") != -1)
{
return u8"HeaderLines";
}
else if (headerstr.toLower().trimmed()==u8"theta"|| headerstr.toLower().trimmed() == u8"theta'") {
return u8"theta";
}
else if (headerstr.toLower().trimmed() == u8"phi"|| headerstr.toLower().trimmed() == u8"phi'") {
return u8"phi";
}
else if (headerstr.toLower().trimmed() == u8"re(etheta)"|| headerstr.toLower().trimmed() == u8"re(etheta')") {
return u8"re(etheta)";
}
else if (headerstr.toLower().trimmed() == u8"im(etheta)"|| headerstr.toLower().trimmed() == u8"im(etheta')") {
return u8"im(etheta)";
}
else if (headerstr.toLower().trimmed() == u8"re(ephi)"|| headerstr.toLower().trimmed() == u8"re(ephi')") {
return u8"re(ephi)";
}
else if (headerstr.toLower().trimmed() == u8"im(ephi)"|| headerstr.toLower().trimmed() == u8"im(ephi')") {
return u8"im(ephi)";
}
else if (headerstr.toLower().trimmed() == u8"re(er)"|| headerstr.toLower().trimmed() == u8"re(er')") {
return u8"re(ephi)";
}
else if (headerstr.toLower().trimmed() == u8"im(er)"|| headerstr.toLower().trimmed() == u8"im(er')") {
return u8"im(ephi)";
}
else if (headerstr.toLower().trimmed() == u8"gain(theta)"|| headerstr.toLower().trimmed() == u8"gain(theta')") {
return u8"gain(theta)";
}
else if (headerstr.toLower().trimmed() == u8"gain(phi)"|| headerstr.toLower().trimmed() == u8"gain(phi')") {
return u8"gain(phi)";
}
else if (headerstr.toLower().trimmed() == u8"gain(total)"|| headerstr.toLower().trimmed() == u8"gain(total')") {
return u8"gain(total)";
}
else if (headerstr.toLower().trimmed() == u8"radius"|| headerstr.toLower().trimmed() == u8"radius'") {
return u8"radius";
}
else if (headerstr.toLower().trimmed() == u8"x" || headerstr.toLower().trimmed() == "x'") {
return u8"x";
}
else if (headerstr.toLower().trimmed() == u8"y" || headerstr.toLower().trimmed() == "y'") {
return u8"y";
}
else if (headerstr.toLower().trimmed() == u8"z" || headerstr.toLower().trimmed() == "z'") {
return u8"z";
}
else if (headerstr.toLower().trimmed() == "re(ex)" || headerstr.toLower().trimmed() == "re(ex')") {
return u8"re(ex)";
}
else if (headerstr.toLower().trimmed() == "re(ey)" || headerstr.toLower().trimmed() == "re(ey')") {
return u8"re(ey)";
}
else if (headerstr.toLower().trimmed() == "re(ez)" || headerstr.toLower().trimmed() == "re(ez')") {
return u8"re(ez)";
}
else if (headerstr.toLower().trimmed() == "im(ex)" || headerstr.toLower().trimmed() == "im(ex')") {
return u8"im(ex)";
}
else if (headerstr.toLower().trimmed() == "im(ey)" || headerstr.toLower().trimmed() == "im(ey')") {
return u8"im(ey)";
}
else if (headerstr.toLower().trimmed() == "im(ez)" || headerstr.toLower().trimmed() == "im(ez')") {
return u8"im(ez)";
}
else if (headerstr.toLower().trimmed() == "re(er)" || headerstr.toLower().trimmed() == "re(er')") {
return u8"re(er)";
}
else if (headerstr.toLower().trimmed() == "im(er)" || headerstr.toLower().trimmed() == "im(er')") {
return u8"im(er)";
}
else if (headerstr.toLower().trimmed() == "u" || headerstr.toLower().trimmed() == "u'") {
return u8"u";
}
else if (headerstr.toLower().trimmed() == "v" || headerstr.toLower().trimmed() == "v'") {
return u8"v";
}
else {
return u8"";
}
;
}
QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock()
{
switch (this->resultType) {
case FEKOBase::GAIN:
return this->saveFEKOFarFieldDataBlock_Gain();
case FEKOBase::DIRECTIVITY:
return this->saveFEKOFarFieldDataBlock_Directivity();
case FEKOBase::RCS:
return this->saveFEKOFarFieldDataBlock_RCS();
case FEKOBase::FARFIELDVALUES:
return this->saveFEKOFarFieldDataBlock_FarFieldValues();
default:
return QString();
}
}
QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock_Gain()
{
return QString();
}
QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock_Directivity()
{
return QString();
}
QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock_RCS()
{
return QString();
}
QString FEKOBase::FEKOFARFIELDFEKODATABLOCK::saveFEKOFarFieldDataBlock_FarFieldValues()
{
return QString();
}

View File

@ -0,0 +1,138 @@
#pragma once
#ifndef FARFIELDFILECLASS_H
#define FARFIELDFILECLASS_H
#include "referenceHeader.h"
#include "SARImage/FEKOBaseToolClass.h"
namespace FEKOBase {
//
// 参数 altair feko user guide 2018.1
// 章节 A-10 summary of feko file formats
//
const QString FEKOFARFIELDSPLITCHAT = u8" ";
enum FEKOFARFIELDRESULTTYPE {
GAIN, // 增益
DIRECTIVITY,// 电场
RCS,// 后向散射系数
FARFIELDVALUES,// 远场值
FEKOFARFIELDRESULTTYPEUNKOWN
};
FEKOBase::FEKOFARFIELDRESULTTYPE FEKOFARFIELDRESULTTYPEString2Enum(QString str);
QString QString2FEKOFARFIELDRESULTTYPE(FEKOBase::FEKOFARFIELDRESULTTYPE mode);
//==========================================================
// FEKO 仿真结果文件 farfield 文件 ffe
// 解析ffe 文件
//==========================================================
struct FEKOFarFieldFEKOFarFieldData // 仿真结果的数据项 ,行
{
double X=0;// cartesian coordinate system
double Y=0;
double Z=0;
double U=0; // cartesian coordinate system
double V=0;
double radius=0; // nearfield
double theta=0; // spherical coordinate system
double phi=0;
double re_Er=0;
double im_Er=0;
double re_Etheta=0; // theta
double im_Etheta=0;
double re_Ephi=0; // phi
double im_Ephi=0;
double re_Ex=0;// X
double im_Ex=0;
double re_Ey=0; //y
double im_Ey=0;
double re_Ez=0; //z
double im_Ez=0;
double gain_Theta=0; // gain in spherical coordinate system
double gain_Phi=0;
double gain_Total=0;
double directivity_Theta=0; // directivity in spherical coordinate system
double directivity_Phi = 0;
double directivity_total = 0;
double RCS_theta = 0;// RCS in spherical coordinate system
double RCS_phi = 0;
double RCS_total = 0;
};
class FEKOFARFIELDFEKODATABLOCK { // 数据块
public:
FEKOFARFIELDFEKODATABLOCK();
~FEKOFARFIELDFEKODATABLOCK();
public: // 变量
QString configurationName;
QString requestName;
double frequency;
FEKOBase::FEKOCoordinateSystem coordinateSystem; //
FEKOBase::FEKOFARFIELDRESULTTYPE resultType;
long thetaSamples;
long phiSamples;
long USamples;
long VSamples;
CartesianCoordinates Origin; // 坐标系原点
long headerLines;
QList<FEKOBase::FEKOFarFieldFEKOFarFieldData> dataList;
public: // 相关函数
// 解析文件
int paraseFEKOFarFieldDataBlock(const QString& blockstr); // 解析数据块
int paraseFEKOFarFieldDataBlockFromList(QList<QString>& blockstr); // 解析数据块
QString normalizationHeaderString(QString headerstr);// 对数据块头名称进行标准化
// 保存文件
QString saveFEKOFarFieldDataBlock(); // 生成数据块字符串
QString saveFEKOFarFieldDataBlock_Gain(); // 根据类型生成数据块字符串
QString saveFEKOFarFieldDataBlock_Directivity();
QString saveFEKOFarFieldDataBlock_RCS();
QString saveFEKOFarFieldDataBlock_FarFieldValues();
};
class FEKOFarFieldFileClass: public QObject
{
Q_OBJECT
public:
FEKOFarFieldFileClass();
~FEKOFarFieldFileClass();
public:
QString FileType;
QString FileFormat;
QString Sourcestr;
QString Datestr;
QList<FEKOBase::FEKOFARFIELDFEKODATABLOCK> dataBlockList;
public:
void parseFarFieldFile(const QString& fileName);
void outputToFile(const QString& fileName);
};
//==========================================================
// FEKO 仿真结果文件 nearfield 文件 efe
// 解析efe 文件,
//==========================================================
}
#endif // ! FARFIELDFILECLASS_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,259 @@
#pragma once
/*
* FEKO_SIMULAION_SAR_CLASS FEKO
* FEKOSimulationSARClass
*
*/
#ifndef FEKO_SIMULATION_SAR_CLASS_H
#define FEKO_SIMULATION_SAR_CLASS_H
#include "referenceHeader.h"
#include "OCCTBase.h"
#include "BaseToollib/GeoOperator.h"
#include "SARImage/FEKOBaseToolClass.h"
#include "SARBaseToolLib/SARImageBase.h"
#include <QObject>
namespace FEKOBase {
//==========================================================
// FEKO成像仿真参数类
//==========================================================
class FEKOSimulationDataparams:public QObject
{ // 仿真参数类
Q_OBJECT
public:
FEKOSimulationDataparams(QObject* parent=nullptr);
~FEKOSimulationDataparams();
signals:
void FEKOSimulationDataparamsChanged(); // 响应时间,作为一个参数分发
public: // 频率更新
void CalFEKOSimulationFreqParams(double centerFreq, double resolution, double bandWidth, double scenceRange, bool isResolution = false);
void updateFEKOSimulationFreqParams(double startfreq, double endfreq, size_t freqpoints);
public:
void loadXml(const QString& fileName);
void saveXml(const QString& fileName);
public: // 属性字段
QString taskName; // 任务名称
FEKOImageMode imagemode; // 成像时间
QString AntennaRadiationFileName; // 远程天线等效辐射方向图文件地址
long farsource_thetaPoints;
long farsource_phiPoints;
bool isRight = false; // 是否为右视
double refRange;// 参考距离 m
double incangle; // 入射角 °
double centerFreq; // 中心频率
double rangeResolution;//分辨率
double bandwidth;// 带宽
double startfreq; // 频率参数
double endfreq;
double freqpoints;
//成像场景设置
double x_min;
double x_max;
double y_min;
double y_max;
double z_plane;
size_t imageheight; // 图像高度
size_t imagewidth; // 图像宽度
// 条带模式参数
size_t prfcount; // 脉冲数量
double start_x;
double end_x;
double start_y;
double end_y;
double start_z;
double end_z;
// 扫描模式参数
double start_az_angle; // 扫描起始角
double end_az_angle; // 扫描终止角
// ISAR模式参数 , 圆迹模式参数
double start_circle_angle; // 起始扫描角
double end_circle_angle; // 终止扫描角
double delta_angle;// 扫描角间隔
public:
void setTaskName(QString taskName);
QString getTaskName();
// 成像模式
void setImagemode(FEKOImageMode imagemode);
FEKOImageMode getImagemode();
// 是否为右视
void setIsRight(bool isRight);
bool getIsRight();
// 参考距离
void setRefRange(double refRange);
double getRefRange();
// 入射角
void setIncangle(double incangle);
double getIncangle();
// 中心频率
void setCenterFreq(double centerFreq);
double getCenterFreq();
// 分辨率
void setRangeResolution(double rangeResolution);
double getRangeResolution();
// 带宽
void setBandwidth(double bandwidth);
double getBandwidth();
// 频率参数
void setStartfreq(double startfreq);
double getStartfreq();
void setEndfreq(double endfreq);
double getEndfreq();
void setFreqpoints(double freqpoints);
double getFreqpoints();
// 成像范围
void setX_min(double x_min);
double getX_min();
void setX_max(double x_max);
double getX_max();
void setY_min(double y_min);
double getY_min();
void setY_max(double y_max);
double getY_max();
void setZ_plane(double z_plane);
double getZ_plane();
// 图像高度
void setImageheight(size_t imageheight);
size_t getImageheight();
// 图像宽度
void setImagewidth(size_t imagewidth);
size_t getImagewidth();
// 条带模式参数
void setPRFCount(size_t prfcount);
size_t getPRFCount();
void setStart_x(double start_x);
double getStart_x();
void setEnd_x(double end_x);
double getEnd_x();
void setStart_y(double start_y);
double getStart_y();
void setEnd_y(double end_y);
double getEnd_y();
void setStart_z(double start_z);
double getStart_z();
void setEnd_z(double end_z);
double getEnd_z();
double getStart_az_angle(); // 扫描起始角
double getEnd_az_angle(); // 扫描终止角
double getStart_circle_angle(); // 起始扫描角
double getEnd_circle_angle(); // 终止扫描角
double getDelta_angle();// 扫描角间隔
void setStart_az_angle(double Start_az_angle); // 扫描起始角
void setEnd_az_angle(double End_az_angle); // 扫描终止角
void setStart_circle_angle(double Start_circle_angle); // 起始扫描角
void setEnd_circle_angle(double End_circle_angle); // 终止扫描角
void setDelta_angle(double Delta_angle);// 扫描角间隔
QString getAntennaRadiationFileName();
void setAntennaRadiationFileName( QString path);
long getFarsourceThetaPoints();
void setFarsourceThetaPoints(long thetaPoints);
long getFarsourcePhiPoints();
void setFarsourcePhiPoints(long phiPoints);
};
class FEKOSimulationDataparamsHandler {
public:
FEKOSimulationDataparamsHandler();
~FEKOSimulationDataparamsHandler();
public:
std::shared_ptr<FEKOBase::FEKOSimulationDataparams> simulationparams;
void setFEKOSimulationDataparams(std::shared_ptr<FEKOBase::FEKOSimulationDataparams> simulationparams);
std::shared_ptr<FEKOBase::FEKOSimulationDataparams> getFEKOSimulationDataparams();
public:
virtual void bandingsetFEKOSimulationDataparams();
};
//==========================================================
// FEKO仿真成像参数类
// 解析成像参数xml
//==========================================================
class FEKOSimulationSARClass : public FEKOSimulationDataparamsHandler
{
public:
FEKOSimulationSARClass();
~FEKOSimulationSARClass();
public:
std::vector<FEKOBase::FEKOSatelliteParams> FEKOAntPoselist;// FEKO的天线参数设置
void setFEKOAntPoselist(std::vector<FEKOBase::FEKOSatelliteParams> FEKOAntPoselist); // FEKO的天线参数设置
std::vector<FEKOBase::FEKOSatelliteParams> getFEKOAntPoselist();
public:
void generator_STRIP_FEKOSatelliteParams();
void generator_SCAN_FEKOSatelliteParams();
void generator_ISAR_FEKOSatelliteParams();
void generator_CircleSAR_FEKOSatelliteParams();
void generator_FEKOSatelliteParams();
virtual void refreshFEKOSimulationParams();
public:
QString workSpace; // 工作空间
QString AntennaRadiationPath; // 远程天线等效辐射方向图文件地址
QString xmlpath;
public : // 初始化模型
void loadFEKOImageSettingXML(QString xmlpath);
void saveFEKOImageSettingXML();
QString createLuaSciptString(size_t startprfidx, size_t endprfidx);
};
//==========================================================
// FEKO成像
//==========================================================
bool FEKOImageProcess(EchoDataClass& echodata, FEKOImageSettingParams& imageSettingParams, QString& outPath, FEKOImageAlgorithm algmethod = FEKOImageAlgorithm::TBP_FREQ, ImageAlgWindowFun winfun = ImageAlgWindowFun::HANMMING);
class FEKOImageProcessAbstractClass {
public:
FEKOImageProcessAbstractClass();
~FEKOImageProcessAbstractClass();
private:
EchoDataClass echodata; // 原始回波数据 -
FEKOImageSettingParams imageSettingParams; // 成像参数
FEKOImageAlgorithm algmethod; // 成像算法
QString tiffPath;
public:
// 构建与成员变量有关的属性函数
void setEchoData(EchoDataClass echodata);
EchoDataClass getEchoData() const;
void setImageSettingParams(FEKOImageSettingParams imageSettingParams);
FEKOImageSettingParams getImageSettingParams();
void setAlgmethod(FEKOImageAlgorithm algmethod);
FEKOImageAlgorithm getAlgmethod();
void settiffPath(QString outtiffPath);
QString gettiffPath();
void LoadEchoDataPath(QString echoPath);
public: // 成像参数
bool Imageprocess();
};
};
#endif

27
src/LAMPTool/LAMPTool.cpp Normal file
View File

@ -0,0 +1,27 @@
#include "LAMPTool.h"
#include <io.h>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <sys/stat.h>
#include <Windows.h>
#include <WinBase.h>
#include <FileAPI.h>
#include <io.h>
#include <Windows.h>
#include <fileapi.h>
#include <tchar.h>
#include <stdio.h>
LAMPTool::LAMPTool(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
}
LAMPTool::~LAMPTool()
{}

21
src/LAMPTool/LAMPTool.h Normal file
View File

@ -0,0 +1,21 @@
#pragma once
#ifndef LAMPTOOL_H
#define LAMPTOOL_H
#include <QtWidgets/QMainWindow>
#include "ui_LAMPTool.h"
class LAMPTool : public QMainWindow
{
Q_OBJECT
public:
LAMPTool(QWidget *parent = nullptr);
~LAMPTool();
private:
Ui::LAMPToolClass ui;
};
#endif

56
src/LAMPTool/LAMPTool.ui Normal file
View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LAMPToolClass</class>
<widget class="QMainWindow" name="LAMPToolClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>LAMPTool</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>130</x>
<y>40</y>
<width>93</width>
<height>28</height>
</rect>
</property>
<property name="text">
<string>测试</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>26</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
<include location="LAMPTool.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,3 @@
#pragma once
int TestImageBP_main(int argc, char* argv[]); // BP成像函数测试

412
src/LAMPTool/OCCTBase.cpp Normal file
View File

@ -0,0 +1,412 @@
#include "OCCTBase.h"
#include "referenceHeader.h"
#include <opencascade\BRepPrimAPI_MakeBox.hxx>
// ===================================================================
// 常用函数方法
// ===================================================================
OCCTShapeType str2OCCTShapeType(QString str)
{
if (str.isEmpty()) {
return OCCTShapeType::NoneType;
}
else if (str.toUpper() == "STL") {
return OCCTShapeType::STL;
}
else if (str.toUpper() == "STEP") {
return OCCTShapeType::STEP;
}
else if (str.toUpper() == "IGES") {
return OCCTShapeType::IGES;
}
else {
return OCCTShapeType::NoneType;
}
return OCCTShapeType();
}
QStringList getOCCTShapeTypeEmnu()
{
QStringList list;
list.push_back(QString(u8"STL"));
list.push_back(QString(u8"STEP"));
list.push_back(QString(u8"IGES"));
return list;
}
QString getOCCTShapeTypeFilterString()
{
return QString(u8"STL Files (*.stl);;STL Files (*.stla);;step Files (*.stp);;step Files (*.step);;IGES Files (*.iges);;IGES Files (*.igs)");
}
QString get_STL_FilterString()
{
return QString(u8"STL Files (*.stl);;STL Files (*.stla)");
}
QString get_STEP_FilterString()
{
return QString(u8"step Files (*.stp);;step Files (*.step)");
}
QString get_IGES_FilterString()
{
return QString(u8"IGES Files (*.iges);;IGES Files (*.igs)");
}
QString getOCCTShapeTypeFilterString(OCCTShapeType switch_on)
{
switch (switch_on)
{
case(OCCTShapeType::STL): {return get_STL_FilterString(); }
case(OCCTShapeType::STEP): {return get_STEP_FilterString(); }
case(OCCTShapeType::IGES): {return get_IGES_FilterString(); }
default:
return getOCCTShapeTypeFilterString();
}
}
QString getOCCTShapeTypeFilterString(QString str)
{
return getOCCTShapeTypeFilterString(str2OCCTShapeType(str));
}
bool SaveTopoDs_Stl(QString FilePath, const TopoDS_Shape& shape) {
// 将形状保存为 STL 文件
qDebug() << u8"SaveTopoDs_Stl " << FilePath;
StlAPI_Writer writer;
writer.Write(shape, FilePath.toStdString().c_str()); // 保存为stl模型
return true;
}
bool SaveTopoDs_Step(QString FilePath, const TopoDS_Shape& shape) {
qDebug() << u8"SaveTopoDs_Step " << FilePath;
STEPControl_Writer writer;
writer.Transfer(shape, STEPControl_AsIs);
writer.Write(FilePath.toStdString().c_str());
return true;
}
bool SaveTopoDs_IGES(QString FilePath,const TopoDS_Shape& shape) {
qDebug() << u8"SaveTopoDs_IGES " << FilePath;
IGESControl_Writer writer;
writer.AddShape(shape);
writer.Write(FilePath.toStdString().c_str());
return true;
}
bool SaveTopoDs(QString FilePath,const TopoDS_Shape& DataShape, OCCTShapeType shapetype)
{
switch (shapetype)
{
case(OCCTShapeType::STL): { // 保存为stl
SaveTopoDs_Stl(FilePath, DataShape);
break;
}
case(OCCTShapeType::STEP): {
SaveTopoDs_Step(FilePath, DataShape);
break;
}
case(OCCTShapeType::IGES): {
SaveTopoDs_IGES(FilePath, DataShape);
break;
}
default:
break;
}
return true;
}
TopoDS_Shape ReadTopoDs_IGES(QString Filepath) {
IGESControl_Reader reader;
reader.ReadFile(Filepath.toStdString().c_str());
reader.TransferRoots();
TopoDS_Shape shape = reader.OneShape();
return shape;
}
TopoDS_Shape ReadTopoDs_Stl(QString Filepath) {
TopoDS_Shape shape_TopoDs;
StlAPI_Reader aReader_Stl;
aReader_Stl.Read(shape_TopoDs, Filepath.toStdString().c_str());
return shape_TopoDs;
}
TopoDS_Shape ReadTopoDs_Step(QString Filepath) {
TopoDS_Shape shape;
STEPControl_Reader reader;
IFSelect_ReturnStatus status = reader.ReadFile(Filepath.toStdString().c_str());
if (status == IFSelect_RetDone) {
reader.TransferRoots();
shape = reader.OneShape();
return shape;
}
else {
return shape;
}
}
OCCTShapeType ReadTopoDs_Shape(QString filepath, TopoDS_Shape& shape_TopoDs)
{
QFileInfo fileinfo(filepath);
QString filename = fileinfo.fileName();
QString fileSuffix = fileinfo.suffix();
OCCTShapeType shapetype;
if (fileSuffix.compare(u8"stl") == 0 || fileSuffix.compare(u8"stla") == 0) {
shapetype = OCCTShapeType::STL;
shape_TopoDs = ReadTopoDs_Stl(filepath);
return shapetype;
}
else if (fileSuffix.compare(u8"step") == 0 || fileSuffix.compare(u8"stp") == 0) {
shapetype = OCCTShapeType::STEP;
shape_TopoDs = ReadTopoDs_Step(filepath);
return shapetype;
}
else if (fileSuffix.compare(u8"iges") == 0 || fileSuffix.compare(u8"igs") == 0) {
shapetype = OCCTShapeType::IGES;
shape_TopoDs = ReadTopoDs_IGES(filepath);
return shapetype;
}
else {
qDebug() << QString(u8"=================open Model ====================\n");
qDebug() << QString(u8"don't open model\n");
qDebug() << filepath;
qDebug() << QString(u8"=====================================\n");
return OCCTShapeType::NoneType;
}
}
TopoDS_Shape MergedTopoShape(std::vector<TopoDS_Shape> TopoDS_Shapelist)
{
// 创建一个复合体
TopoDS_Compound compound;
BRep_Builder builder;
builder.MakeCompound(compound);
// 将所有的形状添加到复合体中
for (const TopoDS_Shape& shape : TopoDS_Shapelist) {
builder.Add(compound, shape);
}
// 返回合并后的复合体
return compound;
}
void ChangeModelColor(Handle(AIS_Shape)& aisShape, Quantity_Color& redColor)
{
// 将颜色应用到模型
aisShape->SetColor(redColor);
}
TopoDS_Shape CreateArrow(const gp_Dir& direction, Standard_Real length, Standard_Real radius) {
// 创建一个圆柱作为箭头的主体
gp_Pnt origin(0, 0, 0);
gp_Ax2 axis(origin, direction);
BRepPrimAPI_MakeCylinder cylinder(axis, radius, length - radius * 2);
// 创建一个圆锥作为箭头的尖端
gp_Pnt tip = origin.Translated(length * gp_Vec(direction));
gp_Ax2 coneAxis(tip, direction);
BRepPrimAPI_MakeCone cone(coneAxis, radius * 2, 0, radius * 2);
// 合并圆柱和圆锥
TopoDS_Compound compound;
BRep_Builder builder;
builder.MakeCompound(compound);
builder.Add(compound, cylinder.Shape());
builder.Add(compound, cone.Shape());
return compound;
}
gp_Trsf GetTransFormFromVector(const gp_Vec& vectorA, const gp_Vec& vectorB)
{
// 计算旋转轴和旋转角度
gp_Vec rotationAxis = vectorA.Crossed(vectorB);
Standard_Real rotationAngle = vectorA.Angle(vectorB);
if (rotationAxis.X() != 0 || rotationAxis.Y() != 0 || rotationAxis.Z() != 0) {
// 创建变换,绕旋转轴旋转指定角度
gp_Trsf transformation;
transformation.SetRotation(gp_Ax1(gp_Pnt(0, 0, 0), rotationAxis), rotationAngle);
return transformation;
}
else {
// 创建变换,绕旋转轴旋转指定角度
gp_Trsf transformation;
transformation.SetRotation(gp_Ax1(gp_Pnt(0, 0, 0), gp_Vec(0, 0, 1)), 0);
return transformation;
}
}
TopoDS_Shape Process_RotationThetaPhi_MoveXYZ(TopoDS_Shape shape, double theta, double phi, double X, double Y, double Z)
{
gp_Vec Position(gp_Pnt(0, 0, 0), gp_Pnt(X, Y, Z));
gp_Trsf rotationTransform_theta;
rotationTransform_theta.SetRotation(gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(0, 1, 0)), theta); // 绕 y 轴旋转
gp_Trsf rotationTransform_phi;
rotationTransform_phi.SetRotation(gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), phi); // 绕 z 轴旋转
gp_Trsf moveTransform_xyz;
moveTransform_xyz.SetTranslation(Position);
BRepBuilderAPI_Transform shapeTransform_theta(shape, rotationTransform_theta);
TopoDS_Shape tempShape_theta = shapeTransform_theta.Shape();
BRepBuilderAPI_Transform shapeTransform_phi(tempShape_theta, rotationTransform_phi);
TopoDS_Shape tempShape_phi = shapeTransform_phi.Shape();
BRepBuilderAPI_Transform shapeTransform_move(tempShape_phi, moveTransform_xyz);
TopoDS_Shape result = shapeTransform_move.Shape();
return result;
}
TopoDS_Shape CreateCartesianCoordinatesAxis(double xlength, double ylength, double zlength)
{
// 创建三个方向的箭头
TopoDS_Shape arrow1 = CreateArrow(gp_Dir(1, 0, 0), xlength, xlength*0.05); // X方向
TopoDS_Shape arrow2 = CreateArrow(gp_Dir(0, 1, 0), ylength, ylength*0.05); // Y方向
TopoDS_Shape arrow3 = CreateArrow(gp_Dir(0, 0, 1), zlength, zlength*0.05); // Z方向
// 创建雷达模型
gp_Ax2 modelCoor = gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(1, 0, 0));
// 创建一个包含所有箭头的复合体
TopoDS_Compound compound;
BRep_Builder builder;
builder.MakeCompound(compound);
builder.Add(compound, arrow1);
builder.Add(compound, arrow2);
builder.Add(compound, arrow3);
return compound;
}
TopoDS_Shape CreateBox(double x, double y, double z)
{
// 创建一个长方体
BRepPrimAPI_MakeBox box(gp_Pnt(-x / 2, -y / 2, -z / 2), gp_Pnt(x / 2, y / 2, z / 2));
return box.Shape();
}
TopoDS_Shape CreateCylinder(double radius, double height)
{
BRepPrimAPI_MakeCylinder makeCylinder(radius, height);
TopoDS_Shape cylinderShape = makeCylinder.Shape();
return cylinderShape;
}
TopoDS_Shape CreateCone(double radius1, double radius2, double height)
{
BRepPrimAPI_MakeCone mkCone = BRepPrimAPI_MakeCone::BRepPrimAPI_MakeCone(radius1, radius2, height);
TopoDS_Shape coneShape = mkCone.Shape();
return coneShape;
}
TopoDS_Shape CreateSphere(double radius)
{
return TopoDS_Shape();
}
TopoDS_Shape CreateTorus(double majorRadius, double minorRadius)
{
return TopoDS_Shape();
}
TopoDS_Shape Cut(TopoDS_Shape& shape1, TopoDS_Shape& shape2)
{
return TopoDS_Shape();
}
TopoDS_Shape Fuse(TopoDS_Shape& shape1, TopoDS_Shape& shape2)
{
return TopoDS_Shape();
}
TopoDS_Shape Rotate(TopoDS_Shape& shape, gp_Ax1 axis, double angle)
{
// 进行旋转
angle= angle * M_PI / 180;
gp_Trsf rotation;
rotation.SetRotation(axis, angle); // X
BRepBuilderAPI_Transform rotateTransform_X(shape, rotation);
return rotateTransform_X.Shape();
}
TopoDS_Shape Translate(TopoDS_Shape& shape, gp_Vec move_vec)
{
gp_Trsf translation;
translation.SetTranslation(move_vec);
BRepBuilderAPI_Transform translateTransform(shape, translation);
return translateTransform.Shape();
}
TopoDS_Shape Scale(TopoDS_Shape& shape, gp_Pnt refrenceCenter, double scale)
{
gp_Trsf scaleTransform;
scaleTransform.SetScale(refrenceCenter, scale);
BRepBuilderAPI_Transform scaleTransformBuilder(shape, scaleTransform);
return scaleTransformBuilder.Shape();
}
TopoDS_Shape createConicalHorn(double bottomRadius, double bottomHeight, double topRadius, double topHeight)
{
BRepPrimAPI_MakeCone mkCone = BRepPrimAPI_MakeCone::BRepPrimAPI_MakeCone(bottomRadius,topRadius,topHeight);
TopoDS_Shape coneShape = mkCone.Shape();
// 整体平移
gp_Vec trans_vec(gp_Pnt(0, 0, 0), gp_Pnt(0, 0, bottomHeight));
gp_Trsf move_trsf;
move_trsf.SetTranslation(trans_vec);
BRepBuilderAPI_Transform shapeTransform_move(coneShape, move_trsf); // fly_Z --> incidenceAngle
TopoDS_Shape tempShape = shapeTransform_move.Shape(); // 平移卫星模型
BRepPrimAPI_MakeCylinder makeCylinder(bottomRadius, bottomHeight);
TopoDS_Shape cylinderShape = makeCylinder.Shape();
// 创建一个包含所有箭头的复合体
TopoDS_Compound compound;
BRep_Builder builder;
builder.MakeCompound(compound);
builder.Add(compound, tempShape);
builder.Add(compound, cylinderShape);
return compound;
}
TopoDS_Shape createPyramidalHorn(double bottomWidth, double bottomHeight, double bottomAtl, double topWidth, double topHeight, double topAtl)
{
return TopoDS_Shape();
}
TopoDS_Shape CreateWedge(double x, double y, double z)
{
return TopoDS_Shape();
}

96
src/LAMPTool/OCCTBase.h Normal file
View File

@ -0,0 +1,96 @@
#pragma once
#ifndef OCCTBASELAMP_H
#define OCCTBASELAMP_H
#include "referenceHeader.h"
//====================
// 系统支持的模型导出类型
//=====================
enum OCCTShapeType
{
STL,
STEP,
IGES,
NoneType,
};
OCCTShapeType str2OCCTShapeType(QString str);
QStringList getOCCTShapeTypeEmnu();
QString getOCCTShapeTypeFilterString();
QString get_STL_FilterString();
QString get_STEP_FilterString();
QString get_IGES_FilterString();
QString getOCCTShapeTypeFilterString(OCCTShapeType t);
QString getOCCTShapeTypeFilterString(QString str);
// 常用静态函数
bool SaveTopoDs_Stl(QString FilePath, const TopoDS_Shape& shape);
bool SaveTopoDs_Step(QString FilePath, const TopoDS_Shape& shape);
bool SaveTopoDs_IGES(QString FilePath,const TopoDS_Shape& shape);
bool SaveTopoDs(QString FilePath,const TopoDS_Shape& shape, OCCTShapeType type);
TopoDS_Shape ReadTopoDs_IGES(QString Filepath);
TopoDS_Shape ReadTopoDs_Stl(QString Filepath);
TopoDS_Shape ReadTopoDs_Step(QString Filepath);
OCCTShapeType ReadTopoDs_Shape(QString FilePath, TopoDS_Shape& shape_TopoDs);
// 模型合并
TopoDS_Shape MergedTopoShape(std::vector<TopoDS_Shape> TopoDS_Shapelist);
// 修改模型显示
void ChangeModelColor(Handle(AIS_Shape)& aisShape, Quantity_Color& redColor);
//// 创建箭头
TopoDS_Shape CreateArrow(const gp_Dir& direction, Standard_Real length, Standard_Real radius);
//
// OCCT 根据向量A和B,计算变换矩阵
gp_Trsf GetTransFormFromVector(const gp_Vec& A, const gp_Vec& B);
TopoDS_Shape Process_RotationThetaPhi_MoveXYZ(TopoDS_Shape shape, double theta, double phi,double X,double Y,double Z);
//TopoDS_Shape Createpyramid(double width=10.0,double depth=5.0, double mouthWidth=1.0, double mouthHeight=0.5, double height = 15.0);
// 创建一个笛卡尔坐标系
TopoDS_Shape CreateCartesianCoordinatesAxis(double xlength,double ylength,double zlength);
// 常见模型创建
TopoDS_Shape CreateBox(double x, double y, double z);
TopoDS_Shape CreateCylinder(double radius, double height);
TopoDS_Shape CreateCone(double radius_bottom, double radius_top, double height);
TopoDS_Shape CreateSphere(double radius);
TopoDS_Shape CreateTorus(double majorRadius, double minorRadius);
// 常见模型操作
TopoDS_Shape Cut(TopoDS_Shape& shape1, TopoDS_Shape& shape2);
TopoDS_Shape Fuse(TopoDS_Shape& shape1, TopoDS_Shape& shape2);
// 常见操作 -- 模型旋转、平移、缩放
TopoDS_Shape Rotate(TopoDS_Shape& shape, gp_Ax1 axis, double angle);
TopoDS_Shape Translate(TopoDS_Shape& shape, gp_Vec move_vec);
TopoDS_Shape Scale(TopoDS_Shape& shape, gp_Pnt refrenceCenter, double scale);
// 创建散射体雷达
// 创建一个坐标原点为圆心的
TopoDS_Shape createConicalHorn(double bottomRadius,double bottomHeight,double topRadius,double topHeight);
TopoDS_Shape createPyramidalHorn(double bottomWidth, double bottomHeight, double bottomAtl, double topWidth, double topHeight, double topAtl);
#endif // OCCTBASELAMP_H

View File

@ -0,0 +1,14 @@
#include "BackScatterModel.h"
#include <complex>
#include <math.h>
double MuhlemanSimulationBackScatter(double incidentAngle)
{
return 0.0133*cos(incidentAngle)/pow(sin(incidentAngle)+0.1*cos(incidentAngle), 3);
}
Eigen::MatrixXd MuhlemanSimulationBackScatter(Eigen::MatrixXd incidentAngle)
{
return 0.0133 * (incidentAngle.array().cos()) / ((incidentAngle.array().sin()) + cos(incidentAngle.array().cos()*0.1).pow(3));
}

View File

@ -0,0 +1,12 @@
#pragma once
#include <Eigen/Core>
#include <Eigen/Dense>
double MuhlemanSimulationBackScatter(double incidentAngle);
Eigen::MatrixXd MuhlemanSimulationBackScatter(Eigen::MatrixXd incidentAngle);

View File

@ -0,0 +1,283 @@
// SARBaseTool.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include "BaseToollib/ImageOperatorBase.h"
#include "SARBaseTool.h"
#include <Eigen/Core>
#include <Eigen/Dense>
#include <omp.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <gdal.h>
#include <gdal_priv.h>
#include <gdalwarper.h>
#include <proj.h>
#include <string.h>
#include <memory.h>
#include <memory>
#include <fftw3.h>
int Complex2dB(QString in_tiff, QString out_dB_path)
{
GDALAllRegister();
std::shared_ptr<GDALDataset> rasterDataset = OpenDataset(in_tiff);
int width = rasterDataset->GetRasterXSize();
int height = rasterDataset->GetRasterYSize();
int band_num = rasterDataset->GetRasterCount();
double* gt = new double[6];
std::shared_ptr<double> gt_ptr(gt);
QString projectDef = rasterDataset->GetProjectionRef();
GDALDataType gdal_datatype = rasterDataset->GetRasterBand(1)->GetRasterDataType();
bool _nGt_flag = false;
if (projectDef == "") {
_nGt_flag = true;
}
else {
_nGt_flag = false;
}
CreateDataset(out_dB_path, height, width, 1, gt_ptr.get(), projectDef, GDT_Float64, _nGt_flag);
// 计算大小
if (gdal_datatype == 0) {
return 1;
}
else if (gdal_datatype < 8) {
if (band_num != 2) { return 1; }
}
else if (gdal_datatype < 12) {
if (band_num != 1) { return 1; }
}
int block_num = block_num_pre_memory(width, height, gdal_datatype, 1e9);//
block_num = block_num > height ? height : block_num; // 行数
int line_num = block_num;
for (int i = 0; i < height; i = block_num + i) {
if (height - i < block_num) {
line_num = height - i;
}
else {}
// 构建矩阵块使用eigen 进行矩阵计算,加速计算
bool _flag = false;
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> data_mat(line_num * width, 1);// 必须强制行优先
if (gdal_datatype == GDT_Byte) {
Eigen::MatrixX<char> real_mat(line_num * width, 1);
Eigen::MatrixX<char> imag_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = ((real_mat.array().cast<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
_flag = true;
}
else if (gdal_datatype == GDT_UInt16) {
Eigen::MatrixX<unsigned short > real_mat(line_num * width, 1);
Eigen::MatrixX<unsigned short > imag_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = ((real_mat.array().cast<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
_flag = true;
}
else if (gdal_datatype == GDT_Int16) {
Eigen::MatrixX<short > real_mat(line_num * width, 1);
Eigen::MatrixX<short > imag_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = ((real_mat.array().cast<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
_flag = true;
}
else if (gdal_datatype == GDT_UInt32) {
Eigen::MatrixX<unsigned int > real_mat(line_num * width, 1);
Eigen::MatrixX<unsigned int > imag_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = ((real_mat.array().cast<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
_flag = true;
}
else if (gdal_datatype == GDT_Int32) {
Eigen::MatrixX<int > real_mat(line_num * width, 1);
Eigen::MatrixX<int > imag_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = ((real_mat.array().cast<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
_flag = true;
}
//else if (gdal_datatype == GDT_UInt64) {
// Eigen::MatrixX<unsigned long> real_mat(line_num * width, 1);
// Eigen::MatrixX<unsigned long> imag_mat(line_num * width, 1);
// rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
// rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
// data_mat.col(0) = ((real_mat.array().cast<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
// _flag = true;
//}
//else if (gdal_datatype == GDT_Int64) {
// Eigen::MatrixX<long> real_mat(line_num * width, 1);
// Eigen::MatrixX<long> imag_mat(line_num * width, 1);
// rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
// rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
// data_mat.col(0) = ((real_mat.array().cast<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
// _flag = true;
//}
else if (gdal_datatype == GDT_Float32) {
Eigen::MatrixX<float> real_mat(line_num * width, 1);
Eigen::MatrixX<float> imag_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = ((real_mat.array().cast<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
_flag = true;
}
else if (gdal_datatype == GDT_Float64) {
Eigen::MatrixX<double> real_mat(line_num * width, 1);
Eigen::MatrixX<double> imag_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = ((real_mat.array().cast<double>()).array().pow(2) + (imag_mat.array().cast<double>()).array().pow(2)).log10() * 10.0;
_flag = true;
}
else if (gdal_datatype == GDT_CInt16) {
Eigen::MatrixX<complex<short>> complex_short_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, complex_short_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
data_mat.col(0) = (complex_short_mat.real().array().cast<double>().array().pow(2) + complex_short_mat.imag().array().cast<double>().pow(2)).log10() * 10.0;
_flag = true;
}
else if (gdal_datatype == GDT_CInt32) {
Eigen::MatrixX<complex<int>> complex_short_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, complex_short_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
data_mat.col(0) = (complex_short_mat.real().array().cast<double>().array().pow(2) + complex_short_mat.imag().array().cast<double>().pow(2)).log10() * 10.0;
_flag = true;
}
else if (gdal_datatype == GDT_CFloat32) {
Eigen::MatrixX<complex<float>> complex_short_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, complex_short_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
data_mat.col(0) = (complex_short_mat.real().array().cast<double>().array().pow(2) + complex_short_mat.imag().array().cast<double>().pow(2)).log10() * 10.0;
_flag = true;
}
else if (gdal_datatype == GDT_CFloat64) {
Eigen::MatrixX<complex<double>> complex_short_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, complex_short_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
data_mat.col(0) = (complex_short_mat.real().array().cast<double>().array().pow(2) + complex_short_mat.imag().array().cast<double>().pow(2)).log10() * 10.0;
_flag = true;
}
else {}
// 保存数据
if (_flag) {
// 定义赋值矩阵
saveDataset(out_dB_path, i, 0, 1, width, line_num, data_mat.data());
}
else {
}
}
return 0;
}
int Amplitude2dB(QString in_tiff, QString out_dB_path)
{
GDALAllRegister();
std::shared_ptr<GDALDataset> rasterDataset = OpenDataset(in_tiff);
int width = rasterDataset->GetRasterXSize();
int height = rasterDataset->GetRasterYSize();
int band_num = rasterDataset->GetRasterCount();
double* gt = new double[6];
std::shared_ptr<double> gt_ptr(gt);
QString projectDef = rasterDataset->GetProjectionRef();
GDALDataType gdal_datatype = rasterDataset->GetRasterBand(1)->GetRasterDataType();
bool _nGt_flag = false;
if (projectDef == "") {
_nGt_flag = true;
}
else {
_nGt_flag = false;
}
CreateDataset(out_dB_path, height, width, 1, gt_ptr.get(), projectDef, GDT_Float64, _nGt_flag);
// 计算大小
if (gdal_datatype == 0) {
return 1;
}
else if (gdal_datatype < 8) {
if (band_num != 1) { return 1; }
}
else { return 1; }
int block_num = block_num_pre_memory(width, height, gdal_datatype, 2e9);//
block_num = block_num > height ? height : block_num; // 行数
int line_num = block_num;
for (int i = 0; i < height; i = block_num + i) {
if (height - i < block_num) {
line_num = height - i;
}
else {}
// 构建矩阵块使用eigen 进行矩阵计算,加速计算
bool _flag = false;
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> data_mat = ReadMatrixDoubleData(i, width, line_num, rasterDataset, gdal_datatype, 1);
_flag = (data_mat.rows() > 0) && (data_mat.cols() > 0);
// 保存数据
if (_flag) {
// 定义赋值矩阵
saveDataset(out_dB_path, i, 0, 1, width, line_num, data_mat.data());
}
else {
}
}
return 0;
}
Eigen::MatrixXd Complex2dB(Eigen::MatrixXcd in_matrix)
{
return Complex2dB(in_matrix.real().array(), in_matrix.imag().array());
}
Eigen::MatrixXd Complex2dB(Eigen::MatrixXd in_matrix_real, Eigen::MatrixXd in_matrix_imag)
{
return (in_matrix_real.array().pow(2) + in_matrix_imag.array().pow(2)).log10() * 10;
}
double Complex2Amplitude(std::complex<double> sign)
{
return sqrt(pow(sign.real(),2)+pow(sign.imag(),2));
}
double Complex2phase(std::complex<double> sign)
{
//return (sign.real() == 0)*((sign.imag() < 0) * PI / 2)+ (sign.real() != 0)*(atan(sign.imag() / sign.real()) + (sign.real() < 0) * ((sign.imag() <= 0) * PI));
if (sign.real() != 0) {
return atan(sign.imag() / sign.real()) + (sign.real() < 0) * ((sign.imag() <= 0) * PI);
}
else {
return (sign.imag() < 0) * PI / 2;
}
}
Eigen::MatrixXd Complex2Amplitude(Eigen::MatrixXcd in_matrix)
{
return in_matrix.array().abs().cast<double>().array();
}
Eigen::MatrixXd Complex2phase(Eigen::MatrixXcd in_matrix)
{
// 复数转相位
Eigen::MatrixXd result = in_matrix.real().array();
int rows = in_matrix.rows();
int cols = in_matrix.cols();
for (int i = 0; i < rows; i++) { // 可能是性能瓶颈
for (int j = 0; j < cols; j++) {
result(i, j) = Complex2phase(in_matrix(i, j));
}
}
return result;
}
int Complex2dB_DLL(QString out_path, QString in_sar_path)
{
return Complex2dB(in_sar_path, out_path);
}
int Amplitude2dB_DLL(QString in_tiff, QString out_dB_path)
{
return Amplitude2dB(in_tiff, out_dB_path);
}

View File

@ -0,0 +1,65 @@
#pragma once
/**
* SARBaseTool
*
*/
#include <complex>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <omp.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <gdal.h>
#include <gdal_utils.h>
#include <gdal_priv.h>
#include <gdalwarper.h>
#include <proj.h>
#include <string.h>
#include <memory.h>
#include <memory>
#define PI 3.141592653589793238462643383279
#define PI_180 180/3.141592653589793238462643383279
#define T180_PI 3.141592653589793238462643383279/180
#define LIGHTSPEED 299792458
#define LIGHESPEEDGHZ 0.299792458
#define Radians2Degrees(Radians) Radians*PI_180
#define Degrees2Radians(Degrees) Degrees*T180_PI
// 判断是否需要输出为DLL
#define DLLOUT
int Complex2dB(QString in_tiff, QString out_dB_path);
int Amplitude2dB(QString in_tiff, QString out_dB_path);
Eigen::MatrixXd Complex2dB(Eigen::MatrixXcd in_matrix);
Eigen::MatrixXd Complex2dB(Eigen::MatrixXd in_matrix_real, Eigen::MatrixXd in_matrix_imag );
double Complex2Amplitude(std::complex<double> sign);
double Complex2phase(std::complex<double> sign);// 返回弧度制相位
Eigen::MatrixXd Complex2Amplitude(Eigen::MatrixXcd in_matrix);
Eigen::MatrixXd Complex2phase(Eigen::MatrixXcd in_matrix);
// ----------------------------------------------------------------------------------------------------------
// 后向散射系数系统仿真模型
#ifndef DLLOUT
#else
#ifdef __cplusplus
extern "C" {
#endif
#define DllExport __declspec( dllexport )
int __declspec(dllexport) Complex2dB_DLL(QString out_path, QString in_sar_path);
int __declspec(dllexport) Amplitude2dB_DLL(QString in_tiff, QString out_dB_path);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,384 @@
#include "SARCalibration.h"
#include "BaseToollib/ImageOperatorBase.h"
#include "SARBaseTool.h"
#include <Eigen/Core>
#include <Eigen/Dense>
#include <omp.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <gdal.h>
#include <gdal_priv.h>
#include <gdalwarper.h>
#include <proj.h>
#include <string.h>
#include <memory.h>
#include <memory>
using namespace std;
using namespace Eigen;
/**
* ENVI
*/
Eigen::Matrix2cd CalibrationMatrix(Eigen::MatrixXcd in_matrix, double calibrationValue)
{
return in_matrix.array() * calibrationValue;
}
int CalibrationSiglePolarSAR(QString out_path, QString in_sar_path, double calibrationValue)
{
return CalibrationComplex(out_path, in_sar_path, calibrationValue);
}
int CalibrationComplex(const QString& out_path, const QString& in_sar_path, double calibrationValue)
{
GDALAllRegister();
std::shared_ptr<GDALDataset> rasterDataset = OpenDataset(in_sar_path);
int width = rasterDataset->GetRasterXSize();
int height = rasterDataset->GetRasterYSize();
int band_num = rasterDataset->GetRasterCount();
double* gt = new double[6];
std::shared_ptr<double> gt_ptr(gt);
QString projectDef = rasterDataset->GetProjectionRef();
GDALDataType gdal_datatype = rasterDataset->GetRasterBand(1)->GetRasterDataType();
bool _nGt_flag = false;
if (projectDef == "") {
_nGt_flag = true;
}
else {
_nGt_flag = false;
}
CreateDataset(out_path, height, width, 1, gt_ptr.get(), projectDef, GDT_CFloat64, _nGt_flag);
// 计算大小
if (gdal_datatype == 0) {
return 1;
}
else if (gdal_datatype < 8) {
if (band_num != 2) { return 1; }
}
else if (gdal_datatype < 12) {
if (band_num != 1) { return 1; }
}
else {}
int block_num = block_num_pre_memory(width, height, gdal_datatype, 2e9);//
block_num = block_num > height ? height : block_num; // 行数
int line_num = block_num;
for (int i = 0; i < height; i= block_num+i) {
if (height - i < block_num) {
line_num = height - i;
}
else {}
// 构建矩阵块使用eigen 进行矩阵计算,加速计算
bool _flag = false;
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> data_mat(line_num * width, 2);// 必须强制行优先
if (gdal_datatype == GDT_Byte) {
Eigen::MatrixX<char> real_mat(line_num*width,1);
Eigen::MatrixX<char> imag_mat(line_num*width,1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_UInt16) {
Eigen::MatrixX<unsigned short > real_mat(line_num * width, 1);
Eigen::MatrixX<unsigned short > imag_mat(line_num*width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_Int16) {
Eigen::MatrixX<short > real_mat(line_num*width, 1);
Eigen::MatrixX<short > imag_mat(line_num*width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_UInt32) {
Eigen::MatrixX<unsigned int > real_mat(line_num*width, 1);
Eigen::MatrixX<unsigned int > imag_mat(line_num*width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_Int32) {
Eigen::MatrixX<int > real_mat(line_num*width, 1);
Eigen::MatrixX<int > imag_mat(line_num*width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
_flag = true;
}
//else if (gdal_datatype == GDT_UInt64) {
// Eigen::MatrixX<unsigned long> real_mat(line_num*width, 1);
// Eigen::MatrixX<unsigned long> imag_mat(line_num*width, 1);
// rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
// rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
// data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
// data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
// _flag = true;
//}
//else if (gdal_datatype == GDT_Int64) {
// Eigen::MatrixX<long> real_mat(line_num*width, 1);
// Eigen::MatrixX<long> imag_mat(line_num*width, 1);
// rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
// rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
// data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
// data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
// _flag = true;
//}
else if (gdal_datatype == GDT_Float32) {
Eigen::MatrixX<float> real_mat(line_num*width, 1);
Eigen::MatrixX<float> imag_mat(line_num*width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_Float64) {
Eigen::MatrixX<double> real_mat(line_num*width, 1);
Eigen::MatrixX<double> imag_mat(line_num*width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
data_mat.col(1) =( imag_mat.array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_CInt16) {
Eigen::MatrixX<complex<short>> complex_short_mat(line_num*width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, complex_short_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
data_mat.col(0) = (complex_short_mat.real().array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (complex_short_mat.imag().array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_CInt32) {
Eigen::MatrixX<complex<int>> complex_short_mat(line_num*width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, complex_short_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
data_mat.col(0) = (complex_short_mat.real().array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (complex_short_mat.imag().array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_CFloat32) {
Eigen::MatrixX<complex<float>> complex_short_mat(line_num*width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, complex_short_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
data_mat.col(0) = (complex_short_mat.real().array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (complex_short_mat.imag().array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_CFloat64) {
Eigen::MatrixX<complex<double>> complex_short_mat(line_num*width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, complex_short_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
data_mat.col(0) = (complex_short_mat.real().array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (complex_short_mat.imag().array().cast<double>() * calibrationValue).array();
_flag = true;
}
else {}
// 保存数据
if (_flag) {
// 定义赋值矩阵
saveDataset(out_path, i,0,1, width, line_num, data_mat.data());
}
else {
}
}
return -1;
}
int CalibrationComplex2dB(const QString& out_path, const QString& in_sar_path, double calibrationValue)
{
GDALAllRegister();
std::shared_ptr<GDALDataset> rasterDataset = OpenDataset(in_sar_path);
int width = rasterDataset->GetRasterXSize();
int height = rasterDataset->GetRasterYSize();
int band_num = rasterDataset->GetRasterCount();
double* gt = new double[6];
std::shared_ptr<double> gt_ptr(gt);
QString projectDef = rasterDataset->GetProjectionRef();
GDALDataType gdal_datatype = rasterDataset->GetRasterBand(1)->GetRasterDataType();
bool _nGt_flag = false;
if (projectDef == "") {
_nGt_flag = true;
}
else {
_nGt_flag = false;
}
CreateDataset(out_path, height, width, 1, gt_ptr.get(), projectDef, GDT_CFloat64, _nGt_flag);
// 计算大小
if (gdal_datatype == 0) {
return 1;
}
else if (gdal_datatype < 8) {
if (band_num != 2) { return 1; }
}
else if (gdal_datatype < 12) {
if (band_num != 1) { return 1; }
}
else {}
int block_num = block_num_pre_memory(width, height, gdal_datatype, 2e9);//
block_num = block_num > height ? height : block_num; // 行数
int line_num = block_num;
for (int i = 0; i < height; i = block_num + i) {
if (height - i < block_num) {
line_num = height - i;
}
else {}
// 构建矩阵块使用eigen 进行矩阵计算,加速计算
bool _flag = false;
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> data_mat(line_num * width, 2);// 必须强制行优先
if (gdal_datatype == GDT_Byte) {
Eigen::MatrixX<char> real_mat(line_num * width, 1);
Eigen::MatrixX<char> imag_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_UInt16) {
Eigen::MatrixX<unsigned short > real_mat(line_num * width, 1);
Eigen::MatrixX<unsigned short > imag_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_Int16) {
Eigen::MatrixX<short > real_mat(line_num * width, 1);
Eigen::MatrixX<short > imag_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_UInt32) {
Eigen::MatrixX<unsigned int > real_mat(line_num * width, 1);
Eigen::MatrixX<unsigned int > imag_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_Int32) {
Eigen::MatrixX<int > real_mat(line_num * width, 1);
Eigen::MatrixX<int > imag_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
_flag = true;
}
//else if (gdal_datatype == GDT_UInt64) {
// Eigen::MatrixX<unsigned long> real_mat(line_num * width, 1);
// Eigen::MatrixX<unsigned long> imag_mat(line_num * width, 1);
// rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
// rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
// data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
// data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
// _flag = true;
//}
//else if (gdal_datatype == GDT_Int64) {
// Eigen::MatrixX<long> real_mat(line_num * width, 1);
// Eigen::MatrixX<long> imag_mat(line_num * width, 1);
// rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
// rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
// data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
// data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
// _flag = true;
//}
else if (gdal_datatype == GDT_Float32) {
Eigen::MatrixX<float> real_mat(line_num * width, 1);
Eigen::MatrixX<float> imag_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_Float64) {
Eigen::MatrixX<double> real_mat(line_num * width, 1);
Eigen::MatrixX<double> imag_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, real_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
rasterDataset->GetRasterBand(2)->RasterIO(GF_Read, 0, i, width, line_num, imag_mat.data(), width, line_num, gdal_datatype, 0, 0); // imag
data_mat.col(0) = (real_mat.array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (imag_mat.array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_CInt16) {
Eigen::MatrixX<complex<short>> complex_short_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, complex_short_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
data_mat.col(0) = (complex_short_mat.real().array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (complex_short_mat.imag().array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_CInt32) {
Eigen::MatrixX<complex<int>> complex_short_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, complex_short_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
data_mat.col(0) = (complex_short_mat.real().array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (complex_short_mat.imag().array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_CFloat32) {
Eigen::MatrixX<complex<float>> complex_short_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, complex_short_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
data_mat.col(0) = (complex_short_mat.real().array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (complex_short_mat.imag().array().cast<double>() * calibrationValue).array();
_flag = true;
}
else if (gdal_datatype == GDT_CFloat64) {
Eigen::MatrixX<complex<double>> complex_short_mat(line_num * width, 1);
rasterDataset->GetRasterBand(1)->RasterIO(GF_Read, 0, i, width, line_num, complex_short_mat.data(), width, line_num, gdal_datatype, 0, 0); // real
data_mat.col(0) = (complex_short_mat.real().array().cast<double>() * calibrationValue).array();
data_mat.col(1) = (complex_short_mat.imag().array().cast<double>() * calibrationValue).array();
_flag = true;
}
else {}
// 保存数据
if (_flag) {
// 定义赋值矩阵
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> data_out(line_num* width, 1);// 必须强制行优先
data_out.col(0) = Complex2dB(data_mat.col(0).array(), data_mat.col(1).array()).array();
saveDataset(out_path, i, 0, 1, width, line_num, data_out.data());
}
else {
}
}
return -1;
return 0;
}
int CalibrationComplex_DLL(const QString& out_path, const QString& in_sar_path, double calibrationValue)
{
return 0;
}
int CalibrationComplex2dB_DLL(const QString& out_path, const QString& in_sar_path, double calibrationValue)
{
return 0;
}

View File

@ -0,0 +1,52 @@
#pragma once
#ifndef SARCALIBRATION_H
#define SARCALIBRATION_H
/**
* SAR
*
*/
#include "referenceHeader.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <complex.h>
#include <gdal.h>
#include <gdal_priv.h>
#include <gdalwarper.h>
using namespace std;
using namespace Eigen;
// 判断是否需要输出为DLL
#define DLLOUT
// 定标计算
// 输入定标系统,保证数据能够正常定标
Eigen::Matrix2cd CalibrationMatrix(Eigen::MatrixXcd in_matrix, double calibrationValue);
int CalibrationComplex(const QString& out_path, const QString& in_sar_path, double calibrationValue);
int CalibrationComplex2dB(const QString& out_path, const QString& in_sar_path, double calibrationValue);
#ifndef DLLOUT
#else
#ifdef __cplusplus
extern "C" {
#endif
#define DllExport __declspec( dllexport )
int __declspec(dllexport) CalibrationComplex_DLL(const QString& out_path, const QString& in_sar_path, double calibrationValue);
int __declspec(dllexport) CalibrationComplex2dB_DLL(const QString& out_path, const QString& in_sar_path, double calibrationValue);
#ifdef __cplusplus
}
#endif
#endif
#endif // !SARCALIBRATION_H

View File

@ -0,0 +1,86 @@
// SARCalibrationTool.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include "SARCalibration.h"
#include "SARBaseTool.h"
#include <iostream>
#include <string>
#include <memory>
int SiglePolarCalibration(int argc, char* argv[]) {
qDebug() << "mode : 1 "<< "\n";
QString in_tiff_path = "";
QString out_path = "";
double calibration = 0;
// params prase
for (int i = 0; i < argc; i++) {
if (string(argv[i]) == "-in")
{
in_tiff_path = argv[i + 1];
qDebug() << "in file : " << in_tiff_path << "\n";
}
else if (string(argv[i]) == "-out") {
out_path = argv[i + 1];
qDebug() << "out file : " << in_tiff_path << "\n";
}
else if (string(argv[i]) == "-calibrationConst") {
calibration = strtod(argv[i + 1], NULL);
qDebug() << "calibrationConst : " << calibration << "\n";
}
else {}
}
// excute tool
return CalibrationComplex(out_path, in_tiff_path, calibration);
}
int RasterComplex2dB(int argc, char* argv[]) {
qDebug() << "mode : 1 " << "\n";
QString in_tiff_path = "";
QString out_path = "";
// params prase
for (int i = 0; i < argc; i++) {
if (string(argv[i]) == "-in")
{
in_tiff_path = argv[i + 1];
qDebug() << "in file : " << in_tiff_path << "\n";
}
else if (string(argv[i]) == "-out") {
out_path = argv[i + 1];
qDebug() << "out file : " << in_tiff_path << "\n";
}
else {}
}
// excute tool
return Complex2dB(in_tiff_path, out_path);
}
int Test_SARCalibrationTool(int argc, char* argv[])
{
qDebug() << "calibration tool " << "\n";
qDebug() << "sigle polsar Amg: SARCalibrationTool.exe 1 -in filepath -out filepath -calibrationConst 43" << "\n";
qDebug() << "complex 2 dB : SARCalibrationTool.exe 1 -in filepath -out filepath" << "\n";
if (argc == 1) {
qDebug() << "the number of params should be than 2" << "\n";
return 2;
}
try {
int mode = atoi(argv[1]);
if (mode == 1) {
return SiglePolarCalibration(argc, argv);
}
else if (mode == 2) {
return RasterComplex2dB(argc, argv);
}
else {}
}
catch (std::exception ex) {
std::wcerr << ex.what() << "\n";
}
qDebug() << "Hello World!\n";
return 0;
}

View File

@ -0,0 +1,334 @@
#include "BaseToollib/ImageOperatorBase.h"
#include "SARBaseTool.h"
#include "SARImageBase.h"
#include <Eigen/Core>
#include <Eigen/Dense>
#include <omp.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <gdal.h>
#include <gdal_priv.h>
#include <gdalwarper.h>
#include <proj.h>
#include <string.h>
#include <memory.h>
#include <memory>
#include <fftw3.h>
#include <gsl/gsl_integration.h>
#include <gsl/gsl_spline.h>
#include "referenceHeader.h"
#include "OCCTBase.h"
#include "BaseToollib/GeoOperator.h"
#include "SARBaseToolLib/SARImageBase.h"
double getRangeResolution(double startfreq, double endfreq)
{
return LIGHTSPEED / 2 / std::abs(endfreq - startfreq);
}
double getAzimuthResolution(double AzAngleRange, double startFreq)
{
return LIGHTSPEED / 2 / (AzAngleRange * startFreq);
}
Eigen::MatrixXd hammingWindows(size_t num)
{
double alpha = 25. / 46;
double beta = 1 - alpha;
double scale = 1;
size_t m = num;
Eigen::MatrixXd x = Eigen::MatrixXd::Zero(m, 1);
for (int i = 0; i < m; i++) {
x(i, 0) = alpha - beta * std::cos(2 * PI * i / (num - 1));
}
x = x.array() * scale;
return x;
}
Eigen::MatrixXd Hanning(size_t Nf, size_t Nxa, double alpha)
{
// n1 = double ? DOUBLE(n1In[0]) : FLOAT(n1In[0])
double a = 2 * PI / Nf; // a = 2 * pi / N1 ;scale factor
double n2 = Nxa; // n2 = double ? DOUBLE(n2In[0]) : FLOAT(n2In[0])
double b = 2 * pi / n2; // dim 2 scale fact
double one = 1.0; // double ? 1d : 1.0
double temp_row = 0;
double temp_col = 0;
Eigen::MatrixXd result_arr = Eigen::MatrixXd::Zero(Nxa, Nf); // 结果
for (int i = 0; i < Nxa; i++) {
for (int j = 0; j < Nf; j++) {
// index = double ? DINDGEN(n1) : FINDGEN(n1) ; Nf
temp_row = (alpha - one) * cos(j * a) + alpha; // (alpha-one) * cos(index*a) + alpha ;One row
// index = double ? DINDGEN(n2) : FINDGEN(n2) ; Nxa
temp_col = (alpha - one) * cos(i * b) + alpha; // col = (alpha-one) * cos(index*b) + alpha ;One column
result_arr(i, j) = temp_row * temp_col;// RETURN,(row # col) ;DINDGEN(n1)#DINDGEN(n2)
}
}
return result_arr;
}
Eigen::MatrixXcd HammingWindows(Eigen::MatrixXcd FreqEcho)
{
size_t data_cols = FreqEcho.cols();
size_t data_rows = FreqEcho.rows();
// 进行进行hanmming windows
Eigen::MatrixXd hamming_Az = hammingWindows(data_cols);
Eigen::MatrixXd hamming_Rz = hammingWindows(data_rows);
for (int i = 0; i < data_cols; i++) {
for (int j = 0; j < data_rows; j++) {
FreqEcho(j, i) = FreqEcho(j, i) * hamming_Az(i, 0) * hamming_Rz(j, 0);
}
}
return FreqEcho;
}
Eigen::MatrixXcd InterpFreqEcho(Eigen::MatrixXcd freqEcho, Eigen::VectorXd SourceFreqlist, Eigen::VectorXd interpFreqlist)
{
assert(freqEcho.cols() == SourceFreqlist.rows());
size_t data_rows = freqEcho.rows();
size_t data_cols = freqEcho.cols();
size_t out_cols = interpFreqlist.rows();
Eigen::MatrixXcd resultECHO = Eigen::MatrixXcd::Zero(data_rows, out_cols);
#pragma omp parallel for // NEW ADD
for (int i = 0; i < data_rows; i++) { // 单脉冲
double* xs = new double[data_rows];
for (int i = 0; i < data_cols; i++) {
xs[i] = SourceFreqlist(i); // 原始回波
}
double* real_ys = new double[data_cols];
double* imag_ys = new double[data_cols];
gsl_interp_accel* acc = gsl_interp_accel_alloc();
const gsl_interp_type* t = gsl_interp_cspline_periodic;
gsl_spline* spline_real = gsl_spline_alloc(t, data_rows);
gsl_spline* spline_imag = gsl_spline_alloc(t, data_rows);
for (int jj = 0; jj < data_cols; jj++) {
real_ys[jj] = freqEcho(jj, i).real();
imag_ys[jj] = freqEcho(jj, i).imag();
}
gsl_spline_init(spline_real, xs, real_ys, data_rows);
gsl_spline_init(spline_imag, xs, imag_ys, data_rows);
for (int j = 0; j < out_cols; j++) { // 受限于当前函数只能逐点插值,或者后期可修改为 gsl 直接插值
double cx = interpFreqlist(j,0);
std::complex<double> result(
gsl_spline_eval(spline_real, cx, acc),// 插值实部
gsl_spline_eval(spline_imag, cx, acc)// 插值虚部
);
resultECHO(i, j) = result;
}
gsl_spline_free(spline_real);
gsl_spline_free(spline_imag);
gsl_interp_accel_free(acc);
delete[] xs;
delete[] real_ys, imag_ys;
}
return resultECHO;
}
int WriteComplexData2Amp_Arg(QString out_tiff_path, Eigen::MatrixXcd data)
{
Eigen::MatrixXd amp_data = Eigen::MatrixXd::Zero(data.rows(), data.cols());
Eigen::MatrixXd arg_data = Eigen::MatrixXd::Zero(data.rows(), data.cols());
size_t row_count = data.rows();
size_t col_count = data.cols();
for (int i = 0; i < row_count; i++) {
for (int j = 0; j < col_count; j++) {
amp_data(i, j) = std::abs(data(i, j));
arg_data(i, j) = std::arg(data(i, j));
}
}
Eigen::MatrixXd gt = Eigen::MatrixXd::Zero(2, 3);
gdalImage image_tiff = CreategdalImage(out_tiff_path, row_count, col_count, 2, gt, "", false, true);// 注意这里保留仿真结果
image_tiff.saveImage(amp_data, 0, 0, 1);
image_tiff.saveImage(arg_data, 0, 0, 2);
return 0;
}
int WriteComplexData2AmpdB_Arg(QString out_tiff_path, Eigen::MatrixXcd data)
{
Eigen::MatrixXd amp_data = Eigen::MatrixXd::Zero(data.rows(), data.cols());
Eigen::MatrixXd arg_data = Eigen::MatrixXd::Zero(data.rows(), data.cols());
size_t row_count = data.rows();
size_t col_count = data.cols();
for (int i = 0; i < row_count; i++) {
for (int j = 0; j < col_count; j++) {
amp_data(i, j) = 10.0*std::log10(std::abs(data(i, j)));
arg_data(i, j) = std::arg(data(i, j));
}
}
Eigen::MatrixXd gt = Eigen::MatrixXd::Zero(2, 3);
gdalImage image_tiff = CreategdalImage(out_tiff_path, row_count, col_count, 2, gt, "", false, true);// 注意这里保留仿真结果
image_tiff.saveImage(amp_data, 0, 0, 1);
image_tiff.saveImage(arg_data, 0, 0, 2);
return 0;
}
size_t nextpow2(size_t num)
{
double n = std::round(std::log10(num * 1.0) / std::log10(2.0));
return pow(2, (size_t)std::ceil(n) + 1);
}
Eigen::MatrixXcd IFFTW1D(Eigen::MatrixXcd ECHOdata)
{
size_t data_rows = ECHOdata.rows();
size_t data_cols = ECHOdata.cols();
// 频域 转换到 时域
size_t n2 = nextpow2(data_cols) ;
//qDebug() << data_rows << "," << data_cols << "," << n2 << "\n";
// 补零
Eigen::MatrixXcd ExpandECHO = Eigen::MatrixXcd::Zero(data_rows, n2);
for (int i = 0; i < data_rows; i++) {
for (int j = 0; j < data_cols; j++) {
ExpandECHO(i, j) = ECHOdata(i, j);
}
}
// 结果
Eigen::MatrixXcd echoTime = Eigen::MatrixXcd::Zero(data_rows, n2);
fftw_complex* din = (fftw_complex*)fftw_malloc(sizeof(double) * n2 * 2);
fftw_complex* dout = (fftw_complex*)fftw_malloc(sizeof(double) * n2 * 2);
fftw_plan p;
double n = 1.0 / n2; // 因为 fftw 的逆傅里叶变换没有除于N,所以实际上是原来的N倍
//逐行进行fftw
p = fftw_plan_dft_1d(n2, din, dout, FFTW_BACKWARD, FFTW_MEASURE);//FFTW_BACKWARD 逆,
fftw_execute(p); //FFTW_MEASURE 估计最优变换方法,后面复用变换方案
// 傅里叶 计算进度
for (int i = 0; i < data_rows; i++) {
for (int j = 0; j < n2; j++) { // 初始化输入
din[j][0] = std::real(ExpandECHO(i, j));
din[j][1] = std::imag(ExpandECHO(i, j));
}
// 构建fftw 任务
fftw_execute(p);
// 保存结果
for (int j = 0; j < n2; j++) { //读取结果
echoTime(i, j) = std::complex<double>(dout[j][0], dout[j][1]) * n; // 每次变换后都除于n
}
printf("\rIFFT[%.2lf%%]...:", i * 100.0 / (data_rows - 1));
}
fftw_destroy_plan(p);
fftw_free(din);
fftw_free(dout);
qDebug() << "\n";
qDebug() << "IFFT over" << "\n";
return echoTime;
}
Eigen::MatrixXcd FFTW1D(Eigen::MatrixXcd ECHO)
{
size_t data_rows = ECHO.rows();
size_t data_cols = ECHO.cols();
// 频域 转换到 时域
size_t n2 = data_cols;
// 补零
Eigen::MatrixXcd ExpandECHO = Eigen::MatrixXcd::Zero(data_rows, n2);
for (int i = 0; i < data_rows; i++) {
for (int j = 0; j < data_cols; j++) {
ExpandECHO(i, j) = ECHO(i, j);
}
}
// 结果
Eigen::MatrixXcd echofreq = Eigen::MatrixXcd::Zero(data_rows, n2);
fftw_complex* din = (fftw_complex*)fftw_malloc(sizeof(double) * n2 * 2);
fftw_complex* dout = (fftw_complex*)fftw_malloc(sizeof(double) * n2 * 2);
fftw_plan p;
//逐行进行fftw
p = fftw_plan_dft_1d(n2, din, dout, FFTW_FORWARD, FFTW_MEASURE);//FFTW_FORWARD 顺,
fftw_execute(p); //FFTW_MEASURE 估计最优变换方法,后面复用变换方案
for (int i = 0; i < data_rows; i++) {
for (int j = 0; j < n2; j++) { // 初始化输入
din[j][0] = std::real(ExpandECHO(i, j));
din[j][1] = std::imag(ExpandECHO(i, j));
}
// 构建fftw 任务
fftw_execute(p);
// 保存结果
for (int j = 0; j < n2; j++) { //读取结果
echofreq(i, j) = std::complex<double>(dout[j][0], dout[j][1]);
}
printf("\rFFT[%.2lf%%]...:", i * 100.0 / (data_rows - 1));
}
fftw_destroy_plan(p);
fftw_free(din);
fftw_free(dout);
qDebug() << "\n";
qDebug() << "FFT over" << "\n";
return echofreq;
}
Eigen::MatrixXcd FFTW2D(Eigen::MatrixXcd ECHO)
{
// 获取数据的尺寸
int rows = ECHO.rows();
int cols = ECHO.cols();
// 创建FFTW输入和输出数组
fftw_complex* in = reinterpret_cast<fftw_complex*>(ECHO.data());
fftw_complex* out = static_cast<fftw_complex*>(fftw_malloc(sizeof(fftw_complex) * rows * cols));
// 创建FFTW计划执行傅立叶变换
fftw_plan plan = fftw_plan_dft_2d(rows, cols, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
fftw_execute(plan);
// 打印傅立叶变换结果
Eigen::MatrixXcd result(rows, cols);
result = Map<Eigen::MatrixXcd>(reinterpret_cast<std::complex<double>*>(out), rows, cols);
//qDebug() << "Fourier Transform Result: " << "\n" << result << "\n";
// 销毁FFTW计划和内存
fftw_destroy_plan(plan);
fftw_free(out);
qDebug() << "\n";
qDebug() << "FFT over" << "\n";
return result;
}
Eigen::MatrixXcd fftshift(Eigen::MatrixXcd X) {
int rows = X.rows();
int cols = X.cols();
int rows_half = rows / 2;
int cols_half = cols / 2;
Eigen::MatrixXcd tmp = X.topLeftCorner(rows_half, cols_half);
X.topLeftCorner(rows_half, cols_half) = X.bottomRightCorner(rows_half, cols_half);
X.bottomRightCorner(rows_half, cols_half) = tmp;
tmp = X.topRightCorner(rows_half, cols_half);
X.topRightCorner(rows_half, cols_half) = X.bottomLeftCorner(rows_half, cols_half);
X.bottomLeftCorner(rows_half, cols_half) = tmp;
return X;
}

View File

@ -0,0 +1,95 @@
#pragma once
#ifndef SARIMAGEBASE_H
#define SARIMAGEBASE_H
/**
*
****/
#include "referenceHeader.h"
#include "SARBaseTool.h"
// ------------------------------------------- 成像 公用库----------------------------------------------------------
// SAR 常用计算的方法
double getRangeResolution(double startfreq, double endfreq);
/// <summary>
/// 方位向分辨率计算
/// </summary>
/// <param name="AzAngleRange">弧度制,方位角变化范围(>=0</param>
/// <param name="startFreq">起始频率</param>
/// <returns></returns>
double getAzimuthResolution(double AzAngleRange, double startFreq);
// 根据输入数量构建汉明窗
Eigen::MatrixXd hammingWindows(size_t num);
// 频率域汉明窗口
/// <summary>
/// 频率域汉明窗口
/// </summary>
/// <param name="Nf">频率点数</param>
/// <param name="Nxa">脉冲数量</param>
/// <param name="alpha">权重</param>
/// <returns>汉明窗权重</returns>
Eigen::MatrixXd Hanning(size_t Nf, size_t Nxa, double alpha = 0.54);
/// <summary>
/// 获取2的平方数,大于2
/// </summary>
/// <param name="num"></param>
/// <returns></returns>
size_t nextpow2(size_t num);
/// <summary>
/// 对回波沿着行进行一维傅里叶逆变换
/// </summary>
/// <param name="ECHO"></param>
/// <returns></returns>
Eigen::MatrixXcd IFFTW1D(Eigen::MatrixXcd ECHO);
/// <summary>
/// 对回波沿着行进行一维傅里叶变换
/// </summary>
/// <param name="echo"></param>
/// <returns></returns>
Eigen::MatrixXcd FFTW1D(Eigen::MatrixXcd echo);
Eigen::MatrixXcd FFTW2D(Eigen::MatrixXcd ECHO);
Eigen::MatrixXcd fftshift(Eigen::MatrixXcd X);
/// <summary>
/// 对回波 加 hamming 窗
/// </summary>
/// <param name="FreqEcho">频域的回波数据PRFnum,Freqnum)</param>
/// <returns></returns>
Eigen::MatrixXcd HammingWindows(Eigen::MatrixXcd FreqEcho);
/// <summary>
/// 对回波进行一维插值(并行),不能用来处理极坐标
/// 插值方式为 实部虚部分别进行线性插值
/// </summary>
/// <param name="freqEcho">回波数据,(行数,列数):PRFNUM,freqNUM</param>
/// <param name="SourceFreqlist">回波的 原始频率列表</param>
/// <param name="interpFreqlist">回波的 插值频率列表</param>
/// <returns></returns>
Eigen::MatrixXcd InterpFreqEcho(Eigen::MatrixXcd freqEcho, Eigen::VectorXd SourceFreqlist, Eigen::VectorXd interpFreqlist);
/// <summary>
/// 保存复数矩阵数据 为tiff 其中band 1: amp (linear) angle(radia)
/// </summary>
/// <param name="out_tiff_path"></param>
/// <param name="data"></param>
/// <returns></returns>
int WriteComplexData2Amp_Arg(QString out_tiff_path, Eigen::MatrixXcd data);
/// <summary>
/// 保存复数矩阵数据 为tiff 其中band 1: amp (dB) angle(radia)
/// </summary>
/// <param name="out_tiff_path"></param>
/// <param name="data"></param>
/// <returns></returns>
int WriteComplexData2AmpdB_Arg(QString out_tiff_path, Eigen::MatrixXcd data);
// ----------------------------------------------------------------------------------------------------------
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,338 @@
#pragma once
#include <complex>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <omp.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <gdal.h>
#include <gdal_utils.h>
#include <gdal_priv.h>
#include <gdalwarper.h>
#include <proj.h>
#include <string.h>
#include <memory.h>
#include <memory>
#include <vector>
#include "referenceHeader.h"
#include "BaseToollib/GeoOperator.h"
/**
* FEKO
* 1.
* 2. PRFPRF
* 3. PRF 90,
* 4.
***/
namespace FEKOBase {
//==========================================================
// FEKO常用坐标系
//==========================================================
enum FEKOCoordinateSystem {
Spherical, // 球坐标系
Cartesian, // 笛卡尔坐标系
UNKONWFEKOCOORDINATESYSTEM // 必须为最后一个表示未知
};
FEKOBase::FEKOCoordinateSystem FEKOCoordinateSystemString2Enum(QString str);
QString QString2FEKOCoordinateSystem(FEKOBase::FEKOCoordinateSystem mode);
//==========================================================
// FEKO成像模式枚举
//==========================================================
enum FEKOImageMode
{
Strip,
Scane,
ISAR,
CircleSAR,
UNKNOW
};
FEKOImageMode FEKOImageModeString2Enum(QString str);
QString FEKOImageModeenumToString(FEKOImageMode mode);
//==========================================================
// FEKO成像仿真参数类主要用来搭建统一的仿真成像模块
//==========================================================
//==========================================================
// 频率参数
//==========================================================
struct freqParams { // 频率参数
double startfreqs;
double endfreqs;
size_t freqpoint;
};
//==========================================================
// 输入的卫星参数
//==========================================================
struct SatellitePosition { // 卫星姿态
double Px = 0, Py = 0, Pz = 0;
};
struct SatelliteVelocity { // 卫星速度
double Vx = 0, Vy = 0, Vz = 0;
};
struct SatelliteState { // 卫星矢量
SatellitePosition pos;
SatelliteVelocity vel;
};
//==========================================================
// FEKO 远场等效源姿态参数
//==========================================================
struct FEKOantPitionDirect {
double x = 0;
double y = 0;
double z = 0;
double theta = 0;
double phi = 0;
};
//===========================================================
// FEKO成像设置参数
//===========================================================
struct FEKOImageSettingParams {
double min_x = 0;
double max_x = 0;
double min_y = 0;
double max_y = 0;
double plane_z = 0; // 平面高程
size_t ImageWidth = 0;
size_t ImageHeight = 0;
};
//==========================================================
// FEKO参数文件等效参数
//==========================================================
struct FEKOSatelliteParams { // FEKOPRF脉冲参数
size_t PRFidx = 0; // PRF 脉冲计数
SatelliteState pose;// 卫星矢量
double incidenceAngle = 0; // 入射角
double AzAngle = 0; // 姿态角
FEKOantPitionDirect antpos;// 天线实际姿态
bool isRight = false; // 判断左右视false 左right 右
};
/////////////////////////////////////////////////
///// 函数类
//////////////////////////////////////////////
/// <summary>
/// 频率Setting
/// </summary>
/// <param name="centerFreq">中心频率 GHZ</param>
/// <param name="resolution">分辨率 米</param>
/// <param name="bandWidth">带宽 GHz</param>
/// <param name="scenceRange">分辨率 米</param>
/// <param name="isResolution"></param>
/// <returns></returns>
freqParams getFreqSetting(double centerFreq, double resolution, double bandWidth, double scenceRange, bool isResolution = false);
FEKOSatelliteParams createFEKOSatelliteParams(double Px, double Py, double Pz, double Vx, double Vy, double Vz, double incidenceAngle, double AzAngle, double theta, double phi, bool isRight, size_t PRFIdx = 0);
FEKOSatelliteParams createFEKOSatelliteParams(SatelliteState pose, double incidenceAngle, double AzAngle, FEKOantPitionDirect antpos, size_t PRFIdx = 0);
SatelliteState FEKOSatelliteParams2SatelliteState(FEKOSatelliteParams parmas);
FEKOantPitionDirect FEKOSatelliteParams2FEKOantPitionDirect(FEKOSatelliteParams parmas);
/// <summary>
/// 将卫星姿态转换为 FEKO 天线坐标,
/// 注意默认模型的Z轴为天线的指向
/// </summary>
/// <param name="satepos">卫星矢量</param>
/// <param name="incidenceAngle">入射角</param>
/// <param name="AzAngle">侧视角</param>
/// <param name="isRIGHT">是否为右视</param>
/// <param name="antposition_Direct">结果文件</param>
/// <param name="inDs">输入模型</param>
/// <returns></returns>
TopoDS_Shape SatellitePos2FEKOAntPos(SatelliteState satepos, double incidenceAngle, double AzAngle, bool isRIGHT, FEKOantPitionDirect* antposition_Direct, TopoDS_Shape inDs);
//===============================================
// FEKO结果解析文件
//===============================================
struct ElectricFieldData {
QString fileType;
QString fileFormat;
QString source;
QString date;
double radius;
double theta;
double phi;
double reEr;
double imEr;
double reEtheta;
double imEtheta;
double reEphi;
double imEphi;
QString configurationName;
QString requestName;
double frequency;
QString coordinateSystem;
Point_3d origin;
int numRadiusSamples;
int numThetaSamples;
int numPhiSamples;
QString resultType;
int numHeaderLines;
size_t prfidx = -1; // 脉冲计数,>0
};
struct PRFPluseData { // 单个PRF脉冲数据格式
size_t prfidx; //脉冲次数
double freqstart;
double freqend;
size_t freqpoints;
double px, py, pz;
//double theta, phi;
//double incidence, azangle;
//std::vector<double> freqlist;
std::vector<ElectricFieldData> electricFieldDataList; // 单频点信息
};
bool compareElectricFieldDataInFreq(const ElectricFieldData& a, const ElectricFieldData& b);
bool comparePRFPluseDataInPRFIdx(const PRFPluseData& a, const PRFPluseData& b);
class NearFieldEchoCSVParser {
public:
NearFieldEchoCSVParser();
~NearFieldEchoCSVParser();
private:
bool usePRFCountMode = true;
//std::vector<ElectricFieldData> electricFieldDataList;
QMap<QString, std::vector<ElectricFieldData>> electricFieldDataList; // 电场数据
//QMap<QString, PRFPluseData> prfPluseMap;
std::vector<PRFPluseData> prfData;
size_t freqPoints;
double freqStart;
double freqEnd;
// 频率参数
private: // 内部检查函数
bool checkPRFModel();
bool resizePRFPluse(); //回波整理
public:
bool parseCSV(const QString& filePath); // 读取回波数据文件
void toThetapolar(const QString& filePath);// 输出theta 极化
void toPhiPolar(const QString& filePath);// 输出phi 极化
void toRPolar(const QString& filePath);// 输出phi 极化
void saveCSV(const QString& filePath);// 输出csv文件
private:
void toEchoData(const QString& filePath, size_t outDataName);// 输出回波数据
};
//========================================================================
// 成像回波格式
// file type:
// freqStart,freqEnd,freqPoint,isRight,
// PRF1,Pos,incidenceAngle,AzAngle,echoDatalist
// PRF2,Pos,incidenceAngle,AzAngle,echoDatalist
// 。
// 。
// 。
// 注意Bp并不关心脉冲的顺序只是关注脉冲的坐标位置默认按照脉冲的解析顺序进行组织
//========================================================================
class EchoDataClass {
private: // 成像变量
Eigen::MatrixXcd echoData; // 回波数据
Eigen::MatrixXd antPos;// 每个脉冲的坐标
double freqStart; // 起始频率
double freqEnd; // 终止频率
int freqpoints; // 频率点数
public:
EchoDataClass(const FEKOBase::EchoDataClass& inecho);
EchoDataClass();
~EchoDataClass();
public:
// 根据每个成员变量构建属性
void setEchoData(Eigen::MatrixXcd echoData);
Eigen::MatrixXcd getEchoData() const;
void setAntPos(Eigen::MatrixXd antPos);
Eigen::MatrixXd getAntPos() const;
void setFreqStart(double freqStart);
double getFreqStart() const;
void setFreqEnd(double freqEnd);
double getFreqEnd() const;
void setFreqpoints(int freqpoints);
int getFreqpoints() const;
void loadEchoData(const QString& filePath); // 加载回波数据文件
void SaveEchoData(const QString& filePath); // 保存回波数据文件
};
//==========================================================
// 仿真成像算法类
// BP成像算法
// 建议将所有的频率处理到 GHz 单位,避免频率过大导致的精度问题
// 回波矩阵:
// PRF1:f1,f2,f3,f4
// PRF2f1,f2,f3,f4
// PRF2f1,f2,f3,f4
//==========================================================
enum ImageAlgWindowFun // 成像方法加窗方法
{
NOWINDOWS,
HANMMING,
UNKONWWINDOW
};
/// <summary>
/// 加窗
/// </summary>
/// <param name="echo">行:脉冲,列:频点</param>
/// <returns></returns>
Eigen::MatrixXd WINDOWFun(Eigen::MatrixXcd& echo, ImageAlgWindowFun winfun = ImageAlgWindowFun::HANMMING);
enum FEKOImageAlgorithm
{
TBP_TIME,
TBP_FREQ,
UNKONW // 必须为最后一个表示未知
};
QList<QString> getFEKOImageAlgorithmList();
FEKOImageAlgorithm String2FEKOImageAlgorithm(QString str);
QString FEKOImageAlgorithm2String(FEKOImageAlgorithm alg);
// 请仿照FEKOImageAlgorithm枚举的写法构建QString 与 ImageAlgWindowFun 的转换函数
QList<QString> getImageAlgWindowFunList();
ImageAlgWindowFun String2ImageAlgWindowFun(QString str);
QString ImageAlgWindowFun2String(ImageAlgWindowFun alg);
bool BPImage_TIME(QString& restiffpath, Eigen::MatrixXcd& echoData, Eigen::MatrixXd& antPos, Eigen::MatrixXd& freqmatrix, Eigen::MatrixXd& X, Eigen::MatrixXd& Y, Eigen::MatrixXd& Z, ImageAlgWindowFun winfun = ImageAlgWindowFun::HANMMING); // BP成像
bool FBPImage_FREQ(QString& restiffpath, Eigen::MatrixXcd& echoData, Eigen::MatrixXd& antPos, Eigen::MatrixXd& freqmatrix, Eigen::MatrixXd& X, Eigen::MatrixXd& Y, Eigen::MatrixXd& Z, ImageAlgWindowFun winfun = ImageAlgWindowFun::HANMMING); // FBP成像
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,157 @@
#pragma once
/**
* FEKO BP
*
**/
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <memory>
#include <vector>
#include "referenceHeader.h"
// FEKO 几何关系处理
/// <summary>
/// 笛卡尔坐标系,转换为 极坐标系
/// </summary>
/// <param name="CartesianPoint">[X,Y,Z;X1,Y1,Z1]</param>
/// <returns></returns>
Eigen::MatrixXd Cartesian2Spherical(Eigen::MatrixXd CartesianPoint);
/// <summary>
/// 时域BP
/// </summary>
class BP2DProcessClass {
public:
size_t height;
size_t width;
Eigen::MatrixXcd echo;
Eigen::MatrixXd AntPosition;
Eigen::VectorXd Frequencylist;
size_t freqnum;
double f1;
double fc;
double Rref; // 成像中心的参考距离
double minX;
double maxX;
double minY;
double maxY;
double centerX;
double centerY;
double Zplane;
size_t ImageHeight;
size_t ImageWidth;
QString out_path;
public:
virtual int initProcess(QString in_path, QString out_path, double Rref, double minX, double maxX, double minY, double maxY, double PlaneZ, int ImageHeight, int ImageWidth);
virtual int readEchoFile(QString in_path);
virtual int saveTiFF(Eigen::MatrixXcd m);
virtual int start();
virtual int logFUN(int percent, QString logtext);
};
int BP2DProcess(QString in_path, QString out_path, double Rref, double minX, double maxX, double minY, double maxY, double PlaneZ,int ImageHeight,int ImageWidth);
// BP 成像时逐像素点计算计算速度慢回波PRFNUM,freqNUM)
template<typename T>
Eigen::MatrixXcd BP2DImageByPixel(Eigen::MatrixXcd timeEcho,Eigen::MatrixXd AntPosition,double minX,double maxX,double minY,double maxY,double PlaneZ ,double Rref,size_t ImageWidth,size_t ImageHeight,double startfreq,size_t timefreqnum,double timeFreqBandWidth, T* logclss=nullptr);
/// <summary>
/// 时域BP --- FBP
/// </summary>
class FBP2DProcessClass:public BP2DProcessClass {
public:
size_t height;
size_t width;
Eigen::MatrixXcd echo;
Eigen::MatrixXd AntPosition;
Eigen::VectorXd Frequencylist;
size_t freqnum;
double f1;
double fc;
double Rref; // 成像中心的参考距离
double minX;
double maxX;
double minY;
double maxY;
double centerX;
double centerY;
double Zplane;
size_t ImageHeight;
size_t ImageWidth;
QString out_path;
public:
virtual int initProcess(QString in_path, QString out_path, double Rref, double minX, double maxX, double minY, double maxY, double PlaneZ, int ImageHeight, int ImageWidth);
virtual int readEchoFile(QString in_path);
virtual int saveTiFF(Eigen::MatrixXcd m);
virtual int start();
virtual int logFUN(int percent, QString logtext);
};
// BP 成像时逐脉冲计算回波PRFNUM,freqNUM)
template<typename T>
Eigen::MatrixXcd BP2DImageByPluse(Eigen::MatrixXcd timeEcho, Eigen::MatrixXd AntPosition, double minX, double maxX, double minY, double maxY, double PlaneZ, double Rref, size_t ImageWidth, size_t ImageHeight, double startfreq, size_t timefreqnum, double timeFreqBandWidth, T* logclss = nullptr);
int FBP2DProcess(QString in_path, QString out_path, double Rref, double minX, double maxX, double minY, double maxY, double PlaneZ, int ImageHeight, int ImageWidth);
// 生成成像的数据文件
int build2Bin(QString path,int width,int height,std::vector<double> &freqs,Eigen::MatrixXd AntPositions,Eigen::MatrixXcd echo);
// 定义插值函数,以处理复数值
std::complex<double> InterpolateComplex(Eigen::MatrixXd& xi, Eigen::MatrixXd& yi, Eigen::MatrixXcd& data, double x, double y);
/// <summary>
/// 远场成像
/// </summary>
class FEKOFarFieldProcessClass :public BP2DProcessClass {
public:
size_t height;
size_t width;
Eigen::MatrixXcd echo;
Eigen::MatrixXd AntPosition; // theta phi 0
Eigen::VectorXd Frequencylist;
size_t freqnum;
double f1;
double fc;
double Rref; // 成像中心的参考距离
double minX;
double maxX;
double minY;
double maxY;
double centerX;
double centerY;
double Zplane;
size_t ImageHeight;
size_t ImageWidth;
QString out_path;
public:
virtual int initProcess(QString in_path, QString out_path, double Rref, double minX, double maxX, double minY, double maxY, double PlaneZ, int ImageHeight, int ImageWidth);
virtual int readEchoFile(QString in_path);
virtual int saveTiFF(Eigen::MatrixXcd m);
virtual int start();
virtual int logFUN(int percent, QString logtext);
// 平均频率间隔
double get_df() { return (this->Frequencylist(this->get_Nf() - 1) - this->Frequencylist(0)) / (this->get_Nf() - 1); };
// 脉冲数
size_t get_Nxa() { return this->AntPosition.rows(); };
// 频率点数
size_t get_Nf() { return this->Frequencylist.rows(); };
double get_minFreq() { this->Frequencylist(this->get_Nf() - 1) > this->Frequencylist(0) ? this->Frequencylist(0) : this->Frequencylist(this->get_Nf() - 1); };
};

View File

@ -0,0 +1,100 @@
// FEKONearBpBaseImage.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include "FEKONearBPBasic.h"
#include <string>
#include <iostream>
#include "LampToolTest.h"
int TestImageBP_main(int argc, char* argv[])
{
qDebug() << "process starting .......\n";
qDebug() << "-i in_echo.bin -o out_resule.bin -Rref 10 -minX -1 -maxX 1 -minY -1 -maxY 1 -PlaneZ 0 -ImageHeight 201 -ImageWidth 201" << "\n";
qDebug() << "BP mehtod for FEKO Near field (Cartesian) " << "\n";
qDebug() << "format: " << "\n";
qDebug() << "height[int32] width[int32] frequencylist[width*double] echoData " << "\n";
qDebug() << "echoData format: ant[x,y,z 3xdouble] real[width*double] imag[width*double]" << "\n";
qDebug() << "echodata [freqNUM,PRF_num]" << "\n";
qDebug() << "warnning:Eigen default matrix is row-major storage" << "\n";
qDebug() << "===============params list==============================" << "\n";
QString in_path = "";
QString out_path = "";
int mode = 1;
double Rref=0, minX=0, maxX = 0, minY = 0, maxY = 0, PlaneZ = 0, ImageHeight = 0, ImageWidth = 0;
for (int i = 0; i < argc; i++) {
qDebug() << argv[i] << "\n";
}
for (int i = 0; i < argc; i++) {
if (strcmp(argv[i], "-i")==0) {
if (i == argc - 1) { return 1; }
in_path = argv[i + 1];
qDebug() << argv[i] << " = " << argv[i + 1] << "\n";
}
else if (strcmp(argv[i], "-o") == 0) {
if (i == argc - 1) { return 1; }
out_path = argv[i + 1];
qDebug() << argv[i] << " = " << argv[i + 1] << "\n";
}
else if (strcmp(argv[i], "-Rref") == 0) {
if (i == argc - 1) { return 1; }
Rref =std::stod(argv[i+1]);
qDebug() << argv[i] << " = " << argv[i + 1] << "\n";
}
else if (strcmp(argv[i], "-minX") == 0) {
if (i == argc - 1) { return 1; }
minX = std::stod(argv[i + 1]);
qDebug() << argv[i] << " = " << argv[i + 1] << "\n";
}
else if (strcmp(argv[i], "-maxX") == 0) {
if (i == argc - 1) { return 1; }
maxX = std::stod(argv[i + 1]);
qDebug() << argv[i] << " = " << argv[i + 1] << "\n";
}
else if (strcmp(argv[i], "-minY") == 0) {
if (i == argc - 1) { return 1; }
minY = std::stod(argv[i + 1]);
qDebug() << argv[i] << " = " << argv[i + 1] << "\n";
}
else if (strcmp(argv[i], "-maxY") == 0) {
if (i == argc - 1) { return 1; }
maxY = std::stod(argv[i + 1]);
qDebug() << argv[i] << " = " << argv[i + 1] << "\n";
}
else if (strcmp(argv[i], "-PlaneZ") == 0) {
if (i == argc - 1) { return 1; }
PlaneZ = std::stod(argv[i + 1]);
qDebug() << argv[i] << " = " << argv[i + 1] << "\n";
}
else if (strcmp(argv[i], "-ImageHeight") == 0) {
if (i == argc - 1) { return 1; }
ImageHeight = std::stod(argv[i + 1]);
qDebug() << argv[i] << " = " << argv[i + 1] << "\n";
}
else if (strcmp(argv[i], "-ImageWidth")==0) {
if (i == argc - 1) { return 1; }
ImageWidth = std::stod(argv[i + 1]);
qDebug() << argv[i] << " = " << argv[i + 1] << "\n";
}
else if (strcmp(argv[i], "-mode") == 0) {
if (i == argc - 1) { return 1; }
mode = std::stoi(argv[i + 1]);
qDebug() << argv[i] << " = " << argv[i + 1] << "\n";
}
}
qDebug() << "======================================================" << "\n";
//qDebug() << Eigen::MatrixXd::LinSpaced(1, 10).array() << "\n";
if (mode == 0) {
//BP2DProcess(in_path, out_path, Rref, minX, maxX, minY, maxY, PlaneZ, ImageHeight, ImageWidth);
}
else if (mode == 1) {
//FBP2DProcess(in_path, out_path, Rref, minX, maxX, minY, maxY, PlaneZ, ImageHeight, ImageWidth);
}
else if (mode == 2) {
}
return 0;
}

4
src/LAMPTool/cpp.hint Normal file
View File

@ -0,0 +1,4 @@
// 提示文件帮助 Visual Studio IDE 解释 Visual C++ 标识符,
// 如函数和宏的名称。
// 有关详细信息,请参见 https://go.microsoft.com/fwlink/?linkid=865984

80
src/LAMPTool/main.cpp Normal file
View File

@ -0,0 +1,80 @@
#define __TEST_IMAGEPROCESS
//#define __TESTMATHGL
//#define __TEST_FARFIELDFILEREADPROCESS
#ifdef __TESTMATHGL
#include <mgl2/mgl.h>
int main()
{
mglGraph gr;
gr.FPlot("sin(pi*x)");
gr.WriteFrame("D:\\codestorage\\LAMPSARtool\\CPluseCpluse\\WBCLFZProgram\\WBCLFZProgram\\test.png");
}
#endif
#ifdef __TEST_IMAGEPROCESS
#include "LAMPTool.h"
#include <QtWidgets/QApplication>
#include "LampToolTest.h"
#include "FEKOSimulationSARClass.h"
#include <cmath>
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
//LAMPTool w;
//w.show();
//a.exec();
//TestImageBP_main(argc, argv);
//====================================
// 꿎桿FEKO친謹속潼써벎
//====================================
//QString antXmlPath = "D:\\codestorage\\LAMPSARtool\\CPluseCpluse\\WBCLFZProgram\\WBCLFZProgram\\help\\FEKOImageSettingTask.xml";
//QString echocsvpath = u8"D:\\돠헌桔씩牘속쵱\\淃커\\淃커匡도백도\\FEKO列街욋\\친謹\\陶끝係던\\ball_001\\ball001_X_strip.csv";
//QString thetafilepath = "";
QString phifilepath = u8"D:/codestorage/LAMPSARtool/tmp/antSpace/TESTIMageProject.phi";
QString tifffilepath = u8"D:/codestorage/LAMPSARtool/tmp/antSpace/TESTIMageProjectImage_phi.dat";
FEKOBase::FEKOImageSettingParams imageparams{ -2.0, 2.0, -2.0, 2.0, 0.0, 201, 201 };
//FEKOBase::NearFieldEchoCSVParser nearfilePraseclass;
//nearfilePraseclass.parseCSV(echocsvpath);
//nearfilePraseclass.toPhiPolar(phifilepath);
FEKOBase::EchoDataClass data;
data.loadEchoData(phifilepath);
FEKOBase::FEKOImageProcess(data, imageparams, tifffilepath);
return 0;
}
#endif
#ifdef __TEST_FARFIELDFILEREADPROCESS
#include "LAMPTool.h"
#include "SARImage/FEKOBaseToolClass.h"
#include "FEKOFarFieldFileClass.h"
#include "FEKOSimulationSARClass.h"
int main() {
QString ffe_filepath = u8"D:\\돠헌桔씩牘속쵱\\淃커\\淃커匡도백도\\FEKO列街욋\\친謹\\係던찧녑친謹\\trihedral\\ant_SAR_new\\ant_SAR_Move\\ant_SAR_new_Horn_conical1_FarField.ffe";
FEKOBase::FEKOFarFieldFileClass ffefile;
std::cout << ffe_filepath.toLocal8Bit().constData()<< std::endl;
ffefile.parseFarFieldFile(ffe_filepath);
std::cout << "__TEST_FARFIELDFILEREADPROCESS" << std::endl;
}
#endif

8
src/LAMPTool/readme.md Normal file
View File

@ -0,0 +1,8 @@
# BaseToollib
基础操作库
# SARBaseToolLib
SAR处理操作库

View File

@ -0,0 +1,175 @@
#pragma once
//==================================
// 线性计算库优化
//===============================
//#define EIGEN_NO_DEBUG
#ifndef REFERENCEHEADER_H
#define REFERENCEHEADER_H
#include <QFileDialog>
#include <QFile>
#include <QXmlStreamReader>
#include <QString>
#include <QDebug>
#include <QDialog>
#include <opencascade\BRepBuilderAPI_Copy.hxx>
#include <opencascade\AIS_Shape.hxx>
#include <QObject>
#include <opencascade\TopoDS.hxx>
#include <opencascade\TopoDS_Shape.hxx>
#include <opencascade\Standard_WarningsDisable.hxx>
#include <QListWidget>
#include <QList>
#include <opencascade\Standard_WarningsRestore.hxx>
#include <opencascade\AIS_TextLabel.hxx>
#include <opencascade\AIS_InteractiveContext.hxx>
#include <opencascade\Graphic3d_Texture2Dplane.hxx>
#include <opencascade\Graphic3d_Text.hxx>
#include <opencascade\V3d_View.hxx>
#include <opencascade\V3d_Viewer.hxx>
#include <vector>
#include <string>
#include <QMap>
#include <QUndoStack>
#include <QCheckBox>
#include <QMouseEvent>
#include <QDialog>
#include <opencascade\BRepGProp.hxx>
#include <opencascade\GProp_GProps.hxx>
#include <opencascade\AIS_ViewCube.hxx>
#include <opencascade\Geom_Axis2Placement.hxx>
#include <QApplication>
#include <QColor>
#include <QColorDialog>
#include <QStatusBar>
#include <opencascade\StepGeom_Axis2Placement3d.hxx>
#include <opencascade\AIS_InteractiveObject.hxx>
#include <opencascade\Aspect_DisplayConnection.hxx>
#include <opencascade\Graphic3d_NameOfMaterial.hxx>
#include <opencascade\OpenGl_GraphicDriver.hxx>
#include <opencascade\OSD_Environment.hxx>
#include <QFileDialog>
#include <opencascade\TCollection_AsciiString.hxx>
#include <opencascade\StlAPI_Reader.hxx>
#include <opencascade\AIS_Trihedron.hxx>
#include <QtWidgets>
#include <opencascade\BRepPrimAPI_MakePrism.hxx>
#include <opencascade\IGESControl_Reader.hxx>
#include <opencascade\STEPControl_Reader.hxx>
#include <opencascade\IGESControl_Writer.hxx>
#include <opencascade\STEPControl_Writer.hxx>
#include <opencascade\StlAPI_Writer.hxx>
#include <opencascade\BRep_Builder.hxx>
#include <opencascade\BRepBuilderAPI_Collect.hxx>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <opencascade\TopExp_Explorer.hxx>
#include <opencascade\gp_Pnt.hxx>
#include <opencascade\gp_Ax1.hxx>
#include <opencascade\gp_Dir.hxx>
#include <opencascade\BRepAlgoAPI_Fuse.hxx>
#include <opencascade\AIS_TexturedShape.hxx>
#include <opencascade\Prs3d_Arrow.hxx>
#include <opencascade\BRepPrimAPI_MakeCylinder.hxx>
#include <opencascade\BRepPrimAPI_MakeCone.hxx>
#include <opencascade\BRepBuilderAPI_Transform.hxx>
#include <QMessageBOx>
#include <opencascade\StlAPI_Writer.hxx>
#include <opencascade\AIS_ViewCube.hxx>
#include <opencascade\AIS_Shape.hxx>
#include <opencascade\Geom_Axis2Placement.hxx>
#include <opencascade\Standard_WarningsDisable.hxx>
#include <QApplication>
#include <QColor>
#include <QColorDialog>
#include <QStatusBar>
#include <opencascade\Standard_WarningsRestore.hxx>
#include <opencascade\StepGeom_Axis2Placement3d.hxx>
#include <QDebug>
#include <opencascade\AIS_InteractiveObject.hxx>
#include <opencascade\Aspect_DisplayConnection.hxx>
#include <opencascade\Graphic3d_NameOfMaterial.hxx>
#include <opencascade\OpenGl_GraphicDriver.hxx>
#include <opencascade\OSD_Environment.hxx>
#include <QFileDialog>
#include <opencascade\TCollection_AsciiString.hxx>
#include <opencascade\StlAPI_Reader.hxx>
#include <opencascade\AIS_Trihedron.hxx>
#include <QCheckBox>
#include <QtWidgets>
#include <opencascade\BRepPrimAPI_MakePrism.hxx>
#include <opencascade\BRepBuilderAPI_Copy.hxx>
#include <opencascade\IGESControl_Reader.hxx>
#include <opencascade\STEPControl_Reader.hxx>
#include <opencascade\IGESControl_Writer.hxx>
#include <opencascade\STEPControl_Writer.hxx>
#include <QMessageBox>
#include <QCoreApplication>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <iostream>
#include <Eigen/Dense>
#include <fftw3.h>
#include <opencascade\BRepBuilderAPI_MakeEdge.hxx>
#include <opencascade\BRepBuilderAPI_MakeWire.hxx>
#include <opencascade\BRepBuilderAPI_MakeFace.hxx>
#include <opencascade\BRepPrimAPI_MakeWedge.hxx>
#include <opencascade\gp_Pnt.hxx>
#include <opencascade\BRepBuilderAPI_MakeEdge.hxx>
#include <opencascade\BRepBuilderAPI_MakeWire.hxx>
#include <opencascade\BRepBuilderAPI_MakeFace.hxx>
#include <opencascade\TopoDS_Face.hxx>
#include <QRegularExpression>
#include <omp.h> // 并行计算库
#include <cmath>
//================================================
// 常用函数
//================================================
std::vector<QString> convertQStringListToStdVector(const QStringList& qStringList);
// =====================================================
// 常用宏定义
// __SHOWPROCESS : 展示进度条
// ======================================================
#define __SHOWPROCESS
//#define __SHOWMATPLOTLIBCPPTEST // 局部绘制结果调试
#define __IMAGEPARALLEL // 成像算法并行版本
#define __IMAGEWINDOWSPROCESS // 成像算法使用加窗函数
#ifdef __SHOWMATPLOTLIBCPPTEST
#include <matplot/matplot.h>
#include <matplot/matplot.h>
#include <mgl2/mgl.h>
//#define __SHOWECHOPARSE // 展示解析结果
//#define __SHOWIMAGEPROCESSING // 展示成像中间结果
//#define __SHOWIMAGEPROCESSRESULT// 展示成像结果
#endif
#endif // !REFERENCEHEADER_Hstd::vector<QString> convertQStringListToStdVector(const QStringList& qStringList)

BIN
src/LAMPTool/test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -33,14 +33,18 @@ namespace MainWidget
{ {
_ui = new Ui::ControlPanel(); _ui = new Ui::ControlPanel();
_ui->setupUi(this); _ui->setupUi(this);
_physicsWidget = new PhysicsWidget(mainwindow); // _physicsWidget = new PhysicsWidget(mainwindow); // 材料算例
_geometryWidget = new GeometryTreeWidget(mainwindow); _geometryWidget = new GeometryTreeWidget(mainwindow); // 几何模型
_meshWidget = new MeshWidget(mainwindow); _meshWidget = new MeshWidget(mainwindow); // 网格
_propTable = new PropertyTable(mainwindow, this); _propTable = new PropertyTable(mainwindow, this); // 属性窗口
_postTreeWidget = new Post::PostTreeWidget(mainwindow); _postTreeWidget = new Post::PostTreeWidget(mainwindow);
_postInfoWidget = new Post::PostInfoWidget(mainwindow); _postInfoWidget = new Post::PostInfoWidget(mainwindow);
_plotTreewidget = new PostPlot::PlotTreeWidget(mainwindow); _plotTreewidget = new PostPlot::PlotTreeWidget(mainwindow);
Init(); Init();
repaintTitleBar(); repaintTitleBar();
_ui->propTabWidget->tabBar()->hide(); _ui->propTabWidget->tabBar()->hide();

View File

@ -25,6 +25,9 @@ namespace MainWidget
_geoProvider = new GeometryViewProvider(mw, this); _geoProvider = new GeometryViewProvider(mw, this);
_meshProvider = new MeshViewProvider(mw, this); _meshProvider = new MeshViewProvider(mw, this);
_sketchProvider = new SketchViewProvider(mw, this); _sketchProvider = new SketchViewProvider(mw, this);
this->setWindowTitle(tr("Pre-Window")); this->setWindowTitle(tr("Pre-Window"));
connect(this, SIGNAL(closed()), mw, SIGNAL(closePreWindowSig())); connect(this, SIGNAL(closed()), mw, SIGNAL(closePreWindowSig()));
connect(mw, SIGNAL(clearAllHighLight()), this, SIGNAL(clearAllHighLight())); connect(mw, SIGNAL(clearAllHighLight()), this, SIGNAL(clearAllHighLight()));

View File

@ -26,6 +26,9 @@
#include <QMessageBox> #include <QMessageBox>
#include <QToolBar> #include <QToolBar>
//logger
#include "Common/DebugLogger.h"
namespace GUI { namespace GUI {
CustomizerHelper::CustomizerHelper(MainWindow* m, Ui::MainWindowRibbon* ui) CustomizerHelper::CustomizerHelper(MainWindow* m, Ui::MainWindowRibbon* ui)
: _mainWindow(m) : _mainWindow(m)
@ -147,7 +150,7 @@ namespace GUI {
ConfigOption::ConfigOption* option = ConfigOption::ConfigOption::getInstance(); ConfigOption::ConfigOption* option = ConfigOption::ConfigOption::getInstance();
ConfigOption::GeometryConfig* geometryOption = option->getGeometryConfig(); ConfigOption::GeometryConfig* geometryOption = option->getGeometryConfig();
ConfigOption::MeshConfig* meshOption = option->getMeshConfig(); ConfigOption::MeshConfig* meshOption = option->getMeshConfig();
if(!isUseRibbon()) { if(!isUseRibbon()) {
bool ok = geometryOption->isImportGeometryEnabled(); bool ok = geometryOption->isImportGeometryEnabled();
this->enableGeoImport(ok); this->enableGeoImport(ok);
@ -205,8 +208,8 @@ namespace GUI {
} else { } else {
// ribbon的设置方式 // ribbon的设置方式
} }
_mainWindow->getControlPanel()->registerEnabledModule();
_mainWindow->getControlPanel()->registerEnabledModule();
Py::PythonAgent::getInstance()->unLock(); Py::PythonAgent::getInstance()->unLock();
} }
@ -230,15 +233,21 @@ namespace GUI {
ConfigOption::GlobalConfig* globalConfig = options->getGlobalConfig(); ConfigOption::GlobalConfig* globalConfig = options->getGlobalConfig();
const QString lang = Setting::BusAPI::instance()->getLanguage(); const QString lang = Setting::BusAPI::instance()->getLanguage();
QString softName = "FastCAE"; QString softName = u8"微波测量仿真分系统专用软件";
if(lang.toLower() == "chinese") { if(lang.toLower() == "chinese") {
QString f = globalConfig->getChineseName(); QString f = globalConfig->getChineseName();
if(!f.isEmpty()) if(!f.isEmpty())
softName = f; softName = f;
} else { } else {
QString f = globalConfig->getSoftName(); QString f = globalConfig->getSoftName();
if(!f.isEmpty()) if (!f.isEmpty())
{
softName = f; softName = f;
}
else
{
softName = "MicrowaveMeasurementSimulationSubSystemCAE";
}
} }
_mainWindow->setWindowTitle(softName); _mainWindow->setWindowTitle(softName);

View File

@ -82,6 +82,10 @@
#include "Common/Types.h" #include "Common/Types.h"
#include "PostInterface/AnimationToolBar.h" #include "PostInterface/AnimationToolBar.h"
#include "PostInterface/RenderDirector.h" #include "PostInterface/RenderDirector.h"
//logger
#include "Common/DebugLogger.h"
namespace GUI { namespace GUI {
MainWindow::MainWindow(bool useRibbon): SARibbonMainWindow(nullptr, useRibbon), _ui(new Ui::MainWindowRibbon) MainWindow::MainWindow(bool useRibbon): SARibbonMainWindow(nullptr, useRibbon), _ui(new Ui::MainWindowRibbon)
{ {
@ -97,9 +101,9 @@ namespace GUI {
} }
this->setContextMenuPolicy(Qt::NoContextMenu); this->setContextMenuPolicy(Qt::NoContextMenu);
QString lang = Setting::BusAPI::instance()->getLanguage(); QString lang = Setting::BusAPI::instance()->getLanguage(); // 获取语言
registerMoudel(); // 控制面版 参数设置面板 控制台 进程 registerMoudel(); // 控制面版 参数设置面板、 日志输出面板、 进程面版
_signalHandler = new SignalHandler(this); _signalHandler = new SignalHandler(this);
_translator = new Translator(); _translator = new Translator();
_subWindowManager = new SubWindowManager(this, _ui->mdiArea, _signalHandler, _controlPanel); _subWindowManager = new SubWindowManager(this, _ui->mdiArea, _signalHandler, _controlPanel);
@ -136,21 +140,17 @@ namespace GUI {
Gmsh::GmshModule::getInstance(this); Gmsh::GmshModule::getInstance(this);
this->showGraphRange(0, 0); this->showGraphRange(0, 0);
Py::PythonAgent::getInstance()->initialize(this); // 初始界面参数设置
Py::PythonAgent::getInstance()->initialize(this);
Plugins::PluginManager::getInstance()->loadPlugs(this); Plugins::PluginManager::getInstance()->loadPlugs(this);
_customizerHelper = new CustomizerHelper(this, _ui); _customizerHelper = new CustomizerHelper(this, _ui);
_customizerHelper->registerInterface(); _customizerHelper->registerInterface();
_subWindowManager->openPreWindow(); // 前处理窗口展示
_subWindowManager->openPreWindow();
isLoadRecordScripFile(); isLoadRecordScripFile();
// ribbon customize // ribbon customize
// MainWindow的构造函数最后 // MainWindow的构造函数最后
if(useRibbon) { if(useRibbon) {
const QString strCostomizePath = const QString strCostomizePath =QApplication::applicationDirPath() + "/customization.xml";
QApplication::applicationDirPath() + "/customization.xml";
sa_apply_customize_from_xml_file(strCostomizePath, this, m_ribbonActionMgr); sa_apply_customize_from_xml_file(strCostomizePath, this, m_ribbonActionMgr);
} }
} }
@ -377,18 +377,18 @@ namespace GUI {
QString lang = Setting::BusAPI::instance()->getLanguage(); QString lang = Setting::BusAPI::instance()->getLanguage();
QString title; QString title;
ConfigOption::GlobalConfig* g = ConfigOption::GlobalConfig* g = ConfigOption::ConfigOption::getInstance()->getGlobalConfig();
ConfigOption::ConfigOption::getInstance()->getGlobalConfig();
title = g->getSoftName(); title = g->getSoftName();
if(lang.toLower() == "chinese") if(lang.toLower() == "chinese")
title = g->getChineseName(); title = g->getChineseName();
if(title.isEmpty()) if(title.isEmpty())
title = "FastCAE"; title = u8"MicrowaveMeasurementSimulationSubSystemCAE";
if(!_currentFile.isEmpty()) if(!_currentFile.isEmpty())
title = QString("%1-[%2]").arg(title).arg(_currentFile); title = QString("%1-[%2]").arg(title).arg(_currentFile);
this->setWindowTitle(title); this->setWindowTitle(title);
DebugInfo("setCurrentFile TitleName: %s\n", title.toStdU16String().c_str());
} }
void MainWindow::updatePreMeshActor() void MainWindow::updatePreMeshActor()
@ -463,9 +463,8 @@ namespace GUI {
if(_processWindow != nullptr) if(_processWindow != nullptr)
_processWindow->reTranslate(); _processWindow->reTranslate();
ConfigOption::GlobalConfig* g = ConfigOption::GlobalConfig* g =ConfigOption::ConfigOption::getInstance()->getGlobalConfig();
ConfigOption::ConfigOption::getInstance()->getGlobalConfig(); QString title = "MicrowaveMeasurementSimulationSubSystemCAE"; // 修改 标识 FastCAE
QString title = "WBCLFZCAE"; // 修改 标识 FastCAE
if(lang.toLower() == "chinese") { if(lang.toLower() == "chinese") {
QString f = g->getChineseName(); QString f = g->getChineseName();
if(!f.isEmpty()) if(!f.isEmpty())
@ -477,7 +476,6 @@ namespace GUI {
} }
if(!_currentFile.isEmpty()) if(!_currentFile.isEmpty())
title = QString("%1-[%2]").arg(title).arg(_currentFile); title = QString("%1-[%2]").arg(title).arg(_currentFile);
this->setWindowTitle(title); this->setWindowTitle(title);
} }

View File

@ -268,7 +268,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1678</width> <width>1678</width>
<height>22</height> <height>17</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
@ -284,6 +284,9 @@
<addaction name="actionImportGeometry"/> <addaction name="actionImportGeometry"/>
<addaction name="actionExportGeometry"/> <addaction name="actionExportGeometry"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionLoadPointCloud"/>
<addaction name="actionSavePointCloud"/>
<addaction name="separator"/>
<addaction name="actionSave"/> <addaction name="actionSave"/>
<addaction name="actionSaveAs"/> <addaction name="actionSaveAs"/>
<addaction name="separator"/> <addaction name="separator"/>
@ -495,10 +498,41 @@
</property> </property>
<addaction name="actionPluginManager"/> <addaction name="actionPluginManager"/>
</widget> </widget>
<widget class="QMenu" name="menuPointCloud">
<property name="title">
<string>&amp;PointCloud</string>
</property>
<widget class="QMenu" name="menuPCLFilter">
<property name="title">
<string>PCLFilter</string>
</property>
<property name="icon">
<iconset resource="../qrc/qianfan.qrc">
<normaloff>:/PointCloudProcess/PointCloudProcess/images/algorithm/filter.png</normaloff>:/PointCloudProcess/PointCloudProcess/images/algorithm/filter.png</iconset>
</property>
<addaction name="actionPCLStatisticalRemoveFilter"/>
<addaction name="actionPCLDBRemoveFilter"/>
<addaction name="actionPCLGuassFilter"/>
<addaction name="actionPCLAverageFilter"/>
</widget>
<widget class="QMenu" name="menureSurfaceMesh">
<property name="title">
<string>reSurfaceMesh</string>
</property>
<property name="icon">
<iconset resource="../qrc/qianfan.qrc">
<normaloff>:/PointCloudProcess/PointCloudProcess/images/algorithm/tree.png</normaloff>:/PointCloudProcess/PointCloudProcess/images/algorithm/tree.png</iconset>
</property>
<addaction name="actionPCLGPMesh"/>
</widget>
<addaction name="menuPCLFilter"/>
<addaction name="menureSurfaceMesh"/>
</widget>
<addaction name="menuFile"/> <addaction name="menuFile"/>
<addaction name="menuView"/> <addaction name="menuView"/>
<addaction name="menuGeometry"/> <addaction name="menuGeometry"/>
<addaction name="menuMesher"/> <addaction name="menuMesher"/>
<addaction name="menuPointCloud"/>
<addaction name="menuSolve"/> <addaction name="menuSolve"/>
<addaction name="menuWindows"/> <addaction name="menuWindows"/>
<addaction name="menuSettings"/> <addaction name="menuSettings"/>
@ -1838,6 +1872,84 @@
<string>SaveVideo</string> <string>SaveVideo</string>
</property> </property>
</action> </action>
<action name="actionLoadPointCloud">
<property name="icon">
<iconset resource="../qrc/qianfan.qrc">
<normaloff>:/PointCloudProcess/PointCloudProcess/images/files/cloud.png</normaloff>:/PointCloudProcess/PointCloudProcess/images/files/cloud.png</iconset>
</property>
<property name="text">
<string>Load PointCloud</string>
</property>
</action>
<action name="actionSavePointCloud">
<property name="icon">
<iconset resource="../qrc/qianfan.qrc">
<normaloff>:/PointCloudProcess/PointCloudProcess/images/files/pointCloud.png</normaloff>:/PointCloudProcess/PointCloudProcess/images/files/pointCloud.png</iconset>
</property>
<property name="text">
<string>Save PointCloud</string>
</property>
</action>
<action name="actionFilter">
<property name="text">
<string>Filter</string>
</property>
</action>
<action name="actionPointCloudStatisticalRemove">
<property name="text">
<string>StatisticalRemove</string>
</property>
</action>
<action name="actionPCLStatisticalRemoveFilter">
<property name="icon">
<iconset resource="../qrc/qianfan.qrc">
<normaloff>:/PointCloudProcess/PointCloudProcess/images/algorithm/Histogram.png</normaloff>:/PointCloudProcess/PointCloudProcess/images/algorithm/Histogram.png</iconset>
</property>
<property name="text">
<string>StatisticalRemoveFilter</string>
</property>
</action>
<action name="actionPCLDBRemoveFilter">
<property name="icon">
<iconset resource="../qrc/qianfan.qrc">
<normaloff>:/PointCloudProcess/PointCloudProcess/images/algorithm/DBSCAN.png</normaloff>:/PointCloudProcess/PointCloudProcess/images/algorithm/DBSCAN.png</iconset>
</property>
<property name="text">
<string>DBRemoveFilter</string>
</property>
</action>
<action name="actionPCLGuassFilter">
<property name="icon">
<iconset resource="../qrc/qianfan.qrc">
<normaloff>:/PointCloudProcess/PointCloudProcess/images/algorithm/nihe.png</normaloff>:/PointCloudProcess/PointCloudProcess/images/algorithm/nihe.png</iconset>
</property>
<property name="text">
<string>GuassFilter</string>
</property>
</action>
<action name="actionPCLAverageFilter">
<property name="icon">
<iconset resource="../qrc/qianfan.qrc">
<normaloff>:/PointCloudProcess/PointCloudProcess/images/algorithm/KMeans.png</normaloff>:/PointCloudProcess/PointCloudProcess/images/algorithm/KMeans.png</iconset>
</property>
<property name="text">
<string>AverageFilter</string>
</property>
</action>
<action name="actionPCLGPMesh">
<property name="icon">
<iconset resource="../qrc/qianfan.qrc">
<normaloff>:/PointCloudProcess/PointCloudProcess/images/grey.png</normaloff>:/PointCloudProcess/PointCloudProcess/images/grey.png</iconset>
</property>
<property name="text">
<string>GPMesh</string>
</property>
</action>
<action name="actionLoadFile">
<property name="text">
<string>LoadFile</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="../qrc/qianfan.qrc"/> <include location="../qrc/qianfan.qrc"/>

View File

@ -1637,6 +1637,8 @@ namespace GUI {
void MainWindowPy::createVTKTransform(const char* componentIds, const char* rotate, void MainWindowPy::createVTKTransform(const char* componentIds, const char* rotate,
const char* moveLocation, const char* scale) const char* moveLocation, const char* scale)
{ {
QStringList qCompontIds = QString(componentIds).split(','); QStringList qCompontIds = QString(componentIds).split(',');
QStringList qRotate = QString(rotate).split(','); QStringList qRotate = QString(rotate).split(',');
QStringList qMoveLocation = QString(moveLocation).split(','); QStringList qMoveLocation = QString(moveLocation).split(',');
@ -1672,14 +1674,14 @@ namespace GUI {
QString(meshSet->getName() + "_transform%1").arg(meshSet->getMaxID() + 1); QString(meshSet->getName() + "_transform%1").arg(meshSet->getMaxID() + 1);
setType = MeshData::MeshSet::setTypeToString(meshSet->getSetType()); setType = MeshData::MeshSet::setTypeToString(meshSet->getSetType());
ids.append(QString::number(meshKernal->getID()) + ":"); ids.append(QString::number(meshKernal->getID()) + ":");
emit _pyAgent->printInfo(Common::Message::Normal, "check setType = "+setType);
int nCount = 0; int nCount = 0;
if(setType == "Node") if(setType == "Node")
nCount = transformed->GetNumberOfPoints(); nCount = transformed->GetNumberOfPoints();
else if(setType == "Element") else if(setType == "Element")
nCount = transformed->GetNumberOfCells(); nCount = transformed->GetNumberOfCells();
if(nCount == 0) { if(nCount == 0) {
emit _pyAgent->printInfo(Common::Message::Error, "Transform Failed!"); emit _pyAgent->printInfo(Common::Message::Error, "nCount=0 Transform Failed!");
meshData->removeKernalByID(meshKernal->getID()); meshData->removeKernalByID(meshKernal->getID());
Py::PythonAgent::getInstance()->unLock(); Py::PythonAgent::getInstance()->unLock();
return; return;

File diff suppressed because it is too large Load Diff

View File

@ -44,6 +44,14 @@ namespace Ui {
SARibbonPannel* display_node_pannel{}; SARibbonPannel* display_node_pannel{};
SARibbonPannel* create_set_pannel{}; SARibbonPannel* create_set_pannel{};
SARibbonCategory* pointCloud_page{}; // 点云面板
SARibbonPannel* PCLFile_operator_pannel{};
SARibbonPannel* PCLFilter_pannel{};
SARibbonPannel* PCLReSurfaceMesh_pannel{};
SARibbonCategory* solve_page{}; SARibbonCategory* solve_page{};
SARibbonPannel* solver_management_pannel{}; SARibbonPannel* solver_management_pannel{};

View File

@ -25,55 +25,39 @@
#include <QToolBar> #include <QToolBar>
namespace GUI { namespace GUI {
SubWindowManager::SubWindowManager(MainWindow* mainwindow, QMdiArea* mdiArea, SubWindowManager::SubWindowManager(MainWindow* mainwindow, QMdiArea* mdiArea, SignalHandler* hander, MainWidget::ControlPanel* cp)
SignalHandler* hander, MainWidget::ControlPanel* cp)
: _mainWindow(mainwindow) : _mainWindow(mainwindow)
, _mdiArea(mdiArea) , _mdiArea(mdiArea)
, _signalHander(hander) , _signalHander(hander)
, _controlPanel(cp) , _controlPanel(cp)
{ {
connect(mainwindow, SIGNAL(closePreWindowSig()), this, SLOT(closePreWindow())); connect(mainwindow, SIGNAL(closePreWindowSig()), this, SLOT(closePreWindow()));
connect(mainwindow, SIGNAL(openPostWindowSig(Post::PostWindowBase*)), this, connect(mainwindow, SIGNAL(openPostWindowSig(Post::PostWindowBase*)), this, SLOT(openPostWindow(Post::PostWindowBase*)));
SLOT(openPostWindow(Post::PostWindowBase*))); connect(mainwindow, SIGNAL(openRealTimeWindowSig(Post::RealTimeWindowBase*, int)), this, SLOT(openRealTimeWindow(Post::RealTimeWindowBase*)));
connect(mainwindow, SIGNAL(openRealTimeWindowSig(Post::RealTimeWindowBase*, int)), this, connect(mainwindow, SIGNAL(showPostWindowInfoSig(int, int)), this, SLOT(showPostWindowInfo(int, int)));
SLOT(openRealTimeWindow(Post::RealTimeWindowBase*))); connect(mainwindow, SIGNAL(closePostWindowSig(Post::PostWindowBase*)), this, SLOT(closePostWindow(Post::PostWindowBase*)));
connect(mainwindow, SIGNAL(showPostWindowInfoSig(int, int)), this, connect(_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(subWindowActived(QMdiSubWindow*)));
SLOT(showPostWindowInfo(int, int))); connect(mainwindow, SIGNAL(closeRealTimeWindowSig(Post::RealTimeWindowBase*)), this, SLOT(closeRealTimeWindow(Post::RealTimeWindowBase*)));
connect(mainwindow, SIGNAL(closePostWindowSig(Post::PostWindowBase*)), this, connect(mainwindow, SIGNAL(openReportWindowSig(XReport::ReportWindow*)), this, SLOT(openReportWindow(XReport::ReportWindow*)));
SLOT(closePostWindow(Post::PostWindowBase*))); connect(mainwindow, SIGNAL(closeReportWindowSig(XReport::ReportWindow*)), this, SLOT(closeReportWindow(XReport::ReportWindow*)));
connect(_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, connect(mainwindow, SIGNAL(saveImageSig(QString, int, Post::PostWindowBase*, int, int)), this, SLOT(saveImage(QString, int, Post::PostWindowBase*, int, int)));
SLOT(subWindowActived(QMdiSubWindow*))); connect(mainwindow, SIGNAL(saveImage(int, int, QString)), this, SLOT(saveImage(int, int, QString)));
connect(mainwindow, SIGNAL(closeRealTimeWindowSig(Post::RealTimeWindowBase*)), this,
SLOT(closeRealTimeWindow(Post::RealTimeWindowBase*)));
connect(mainwindow, SIGNAL(openReportWindowSig(XReport::ReportWindow*)), this,
SLOT(openReportWindow(XReport::ReportWindow*)));
connect(mainwindow, SIGNAL(closeReportWindowSig(XReport::ReportWindow*)), this,
SLOT(closeReportWindow(XReport::ReportWindow*)));
connect(mainwindow, SIGNAL(saveImageSig(QString, int, Post::PostWindowBase*, int, int)),
this, SLOT(saveImage(QString, int, Post::PostWindowBase*, int, int)));
connect(mainwindow, SIGNAL(saveImage(int, int, QString)), this,
SLOT(saveImage(int, int, QString)));
connect(this, SIGNAL(setViewSig(int, QString, QString)), this, connect(this, SIGNAL(setViewSig(int, QString, QString)), this, SLOT(setView(int, QString, QString)));
SLOT(setView(int, QString, QString))); connect(this, SIGNAL(setViewValueSig(int, QString, int, int, int, int, int, int, int, int, int)), this, SLOT(setViewValue(int, QString, int, int, int, int, int, int, int, int, int)));
connect(this, connect(this, SIGNAL(saveImageSig(int, int, int, QString, QString)), this, SLOT(saveImage(int, int, int, QString, QString)));
SIGNAL(setViewValueSig(int, QString, int, int, int, int, int, int, int, int, int)),
this,
SLOT(setViewValue(int, QString, int, int, int, int, int, int, int, int, int)));
connect(this, SIGNAL(saveImageSig(int, int, int, QString, QString)), this,
SLOT(saveImage(int, int, int, QString, QString)));
connect(this, SIGNAL(openPreWindowSig()), this, SLOT(openPreWindow())); connect(this, SIGNAL(openPreWindowSig()), this, SLOT(openPreWindow()));
} }
SubWindowManager::~SubWindowManager() {} SubWindowManager::~SubWindowManager() {}
void SubWindowManager::openPreWindow() void SubWindowManager::openPreWindow()
{ {
if(isPreWindowOpened()) { if (isPreWindowOpened()) {
Py::PythonAgent::getInstance()->unLock(); Py::PythonAgent::getInstance()->unLock();
return; return;
} }
if(_preWindow.first == nullptr || _preWindow.second == nullptr) { if (_preWindow.first == nullptr || _preWindow.second == nullptr) {
_preWindow.second = new MainWidget::PreWindow(_mainWindow); _preWindow.second = new MainWidget::PreWindow(_mainWindow);
_preWindow.first = _mdiArea->addSubWindow(_preWindow.second); _preWindow.first = _mdiArea->addSubWindow(_preWindow.second);
_signalHander->updateActionsStates(); _signalHander->updateActionsStates();
Command::GeometryCommandPy::init(_mainWindow, _preWindow.second); Command::GeometryCommandPy::init(_mainWindow, _preWindow.second);
} }
@ -105,53 +89,54 @@ namespace GUI {
void SubWindowManager::add3dRenderPage(const QList<QToolBar*>& toolbars) void SubWindowManager::add3dRenderPage(const QList<QToolBar*>& toolbars)
{ {
if(_threeD_render_page || toolbars.size() != 4) if (_threeD_render_page || toolbars.size() != 4)
return; return;
QList<QAction*> actions; QList<QAction*> actions;
QAction* action{}; QAction* action{};
SARibbonBar* ribbon = _mainWindow->ribbonBar(); SARibbonBar* ribbon = _mainWindow->ribbonBar();
_threeD_render_page = ribbon->addCategoryPage(QObject::tr("3D Render")); _threeD_render_page = ribbon->addCategoryPage(QObject::tr("3D Render"));
SARibbonPannel* pannel0 = _threeD_render_page->addPannel(QString()); SARibbonPannel* pannel0 = _threeD_render_page->addPannel(QString());
QToolBar* toolbar0 = toolbars.at(0); QToolBar* toolbar0 = toolbars.at(0);
actions = toolbar0->actions(); actions = toolbar0->actions();
for(int j = 0; j < actions.size(); j++) { for (int j = 0; j < actions.size(); j++) {
action = actions.at(j); action = actions.at(j);
pannel0->addLargeAction(action); pannel0->addLargeAction(action);
} }
SARibbonPannel* pannel2 = _threeD_render_page->addPannel(QString()); SARibbonPannel* pannel2 = _threeD_render_page->addPannel(QString());
QToolBar* toolbar2 = toolbars.at(2); QToolBar* toolbar2 = toolbars.at(2);
actions = toolbar2->actions(); actions = toolbar2->actions();
for(int j = 0; j < actions.size(); j++) { for (int j = 0; j < actions.size(); j++) {
action = actions.at(j); action = actions.at(j);
pannel2->addLargeAction(action); pannel2->addLargeAction(action);
} }
SARibbonPannel* pannel3 = _threeD_render_page->addPannel(QString()); SARibbonPannel* pannel3 = _threeD_render_page->addPannel(QString());
QToolBar* toolbar3 = toolbars.at(3); QToolBar* toolbar3 = toolbars.at(3);
actions = toolbar3->actions(); actions = toolbar3->actions();
for(int j = 0; j < actions.size(); j++) { for (int j = 0; j < actions.size(); j++) {
action = actions.at(j); action = actions.at(j);
pannel3->addLargeAction(action); pannel3->addLargeAction(action);
} }
SARibbonPannel* pannel1 = _threeD_render_page->addPannel(QString()); SARibbonPannel* pannel1 = _threeD_render_page->addPannel(QString());
QToolBar* toolbar1 = toolbars.at(1); QToolBar* toolbar1 = toolbars.at(1);
actions = toolbar1->actions(); actions = toolbar1->actions();
QList<QAction*> realActions; QList<QAction*> realActions;
QList<QWidget*> comboxs; QList<QWidget*> comboxs;
QWidget* widget{}; QWidget* widget{};
for(int j = 0; j < actions.size(); j++) { for (int j = 0; j < actions.size(); j++) {
action = actions.at(j); action = actions.at(j);
if(action->objectName() == "QComboBox") { if (action->objectName() == "QComboBox") {
widget = toolbar1->widgetForAction(action); widget = toolbar1->widgetForAction(action);
widget->setVisible(true); widget->setVisible(true);
comboxs.append(widget); comboxs.append(widget);
} else if(action->objectName() == "QAction") }
else if (action->objectName() == "QAction")
realActions.append(action); realActions.append(action);
} }
if(realActions.size() != 4 && comboxs.size() != 3) if (realActions.size() != 4 && comboxs.size() != 3)
return; return;
pannel1->addLargeAction(realActions.at(0)); pannel1->addLargeAction(realActions.at(0));
pannel1->addLargeAction(realActions.at(1)); pannel1->addLargeAction(realActions.at(1));
@ -173,10 +158,10 @@ namespace GUI {
void SubWindowManager::remove3dRenderPage() void SubWindowManager::remove3dRenderPage()
{ {
if(_threeD_render_page == nullptr) if (_threeD_render_page == nullptr)
return; return;
auto pannels = _threeD_render_page->pannelList(); auto pannels = _threeD_render_page->pannelList();
for(SARibbonPannel* pannel : pannels) { for (SARibbonPannel* pannel : pannels) {
_threeD_render_page->removePannel(pannel); _threeD_render_page->removePannel(pannel);
pannel = nullptr; pannel = nullptr;
} }
@ -196,19 +181,19 @@ namespace GUI {
} }
void SubWindowManager::updatePreMeshActor() void SubWindowManager::updatePreMeshActor()
{ {
if(_preWindow.second != nullptr) { if (_preWindow.second != nullptr) {
emit _preWindow.second->updateMeshActorSig(); emit _preWindow.second->updateMeshActorSig();
} }
} }
void SubWindowManager::updatePreGeometryActor() void SubWindowManager::updatePreGeometryActor()
{ {
if(_preWindow.second != nullptr) { if (_preWindow.second != nullptr) {
_preWindow.second->updateGeometryActor(); _preWindow.second->updateGeometryActor();
} }
} }
void SubWindowManager::closePreWindow() void SubWindowManager::closePreWindow()
{ {
_preWindow.first = nullptr; _preWindow.first = nullptr;
_preWindow.second = nullptr; _preWindow.second = nullptr;
_mainWindow->getUi()->actionPre_Window->setEnabled(true); _mainWindow->getUi()->actionPre_Window->setEnabled(true);
@ -223,20 +208,21 @@ namespace GUI {
} }
void SubWindowManager::openPostWindow(Post::PostWindowBase* pw) void SubWindowManager::openPostWindow(Post::PostWindowBase* pw)
{ {
if(pw == nullptr) { if (pw == nullptr) {
assert(0); assert(0);
return; return;
} }
QMdiSubWindow* sw = nullptr; QMdiSubWindow* sw = nullptr;
QList<Post::PostWindowBase*> pwl = _postWindow.values(); QList<Post::PostWindowBase*> pwl = _postWindow.values();
if(pwl.contains(pw)) { if (pwl.contains(pw)) {
sw = _postWindow.key(pw); sw = _postWindow.key(pw);
} else { }
else {
sw = _mdiArea->addSubWindow(pw); sw = _mdiArea->addSubWindow(pw);
_mdiArea->cascadeSubWindows(); _mdiArea->cascadeSubWindows();
_postWindow[sw] = pw; _postWindow[sw] = pw;
} }
if(sw != nullptr) { if (sw != nullptr) {
sw->activateWindow(); sw->activateWindow();
sw->showMaximized(); sw->showMaximized();
sw->setFocus(); sw->setFocus();
@ -248,15 +234,16 @@ namespace GUI {
void SubWindowManager::openRealTimeWindow(Post::RealTimeWindowBase* pw) void SubWindowManager::openRealTimeWindow(Post::RealTimeWindowBase* pw)
{ {
QMdiSubWindow* sw = nullptr; QMdiSubWindow* sw = nullptr;
QList<Post::RealTimeWindowBase*> pwl = _realTimeWindow.values(); QList<Post::RealTimeWindowBase*> pwl = _realTimeWindow.values();
if(pwl.contains(pw)) { if (pwl.contains(pw)) {
sw = _realTimeWindow.key(pw); sw = _realTimeWindow.key(pw);
} else { }
sw = _mdiArea->addSubWindow(pw); else {
sw = _mdiArea->addSubWindow(pw);
_realTimeWindow[sw] = pw; _realTimeWindow[sw] = pw;
} }
if(sw != nullptr) { if (sw != nullptr) {
sw->showMaximized(); sw->showMaximized();
sw->setFocus(); sw->setFocus();
} }
@ -266,17 +253,18 @@ namespace GUI {
{ {
QMdiSubWindow* activeWindow = nullptr; QMdiSubWindow* activeWindow = nullptr;
auto subWins = _mdiArea->subWindowList(); auto subWins = _mdiArea->subWindowList();
if(subWins.size() == 1) { if (subWins.size() == 1) {
activeWindow = subWins.at(0); activeWindow = subWins.at(0);
} else { }
else {
activeWindow = _mdiArea->activeSubWindow(); activeWindow = _mdiArea->activeSubWindow();
} }
if(activeWindow == nullptr) if (activeWindow == nullptr)
return nullptr; return nullptr;
else if(activeWindow == _preWindow.first) else if (activeWindow == _preWindow.first)
return _preWindow.second; return _preWindow.second;
else if(_postWindow.contains(activeWindow)) else if (_postWindow.contains(activeWindow))
return _postWindow[activeWindow]; return _postWindow[activeWindow];
else else
return nullptr; return nullptr;
@ -284,13 +272,13 @@ namespace GUI {
Post::PostWindowBase* SubWindowManager::getPostWindowByIDType(int id, int type) Post::PostWindowBase* SubWindowManager::getPostWindowByIDType(int id, int type)
{ {
QList<Post::PostWindowBase*> pwl = _postWindow.values(); QList<Post::PostWindowBase*> pwl = _postWindow.values();
for(int i = 0; i < pwl.size(); ++i) { for (int i = 0; i < pwl.size(); ++i) {
Post::PostWindowBase* w = pwl.at(i); Post::PostWindowBase* w = pwl.at(i);
if(w == nullptr) if (w == nullptr)
continue; continue;
int wid = w->getID(); int wid = w->getID();
int wtype = (int)w->getPostWindowType(); int wtype = (int)w->getPostWindowType();
if(wid == id && wtype == type) if (wid == id && wtype == type)
return w; return w;
} }
return nullptr; return nullptr;
@ -298,7 +286,7 @@ namespace GUI {
void SubWindowManager::removeToolBars() void SubWindowManager::removeToolBars()
{ {
const int n = _currentToolBars.size(); const int n = _currentToolBars.size();
for(int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
QToolBar* t = _currentToolBars.at(i); QToolBar* t = _currentToolBars.at(i);
_mainWindow->removeToolBar(t); _mainWindow->removeToolBar(t);
} }
@ -307,28 +295,29 @@ namespace GUI {
void SubWindowManager::showPostWindowInfo(int id, int type) void SubWindowManager::showPostWindowInfo(int id, int type)
{ {
Post::PostWindowBase* pwb = getPostWindowByIDType(id, type); Post::PostWindowBase* pwb = getPostWindowByIDType(id, type);
if(pwb == nullptr) if (pwb == nullptr)
return; return;
// QWidget* ptree = pwb->getTreeWidget(); // QWidget* ptree = pwb->getTreeWidget();
// QWidget* pprop = pwb->getPropWidget(); // QWidget* pprop = pwb->getPropWidget();
QMdiSubWindow* subWin = _postWindow.key(pwb); QMdiSubWindow* subWin = _postWindow.key(pwb);
if(subWin != nullptr) { if (subWin != nullptr) {
subWin->showMaximized(); subWin->showMaximized();
subWin->setFocus(); subWin->setFocus();
} }
//_controlPanel->updatePostWidget(ptree, pprop); //_controlPanel->updatePostWidget(ptree, pprop);
if(type == 2) if (type == 2)
_controlPanel->updatePostWidget(); _controlPanel->updatePostWidget();
QList<QToolBar*> toolBars = pwb->getToolBarList(); QList<QToolBar*> toolBars = pwb->getToolBarList();
if(_mainWindow->isUseRibbon()) { if (_mainWindow->isUseRibbon()) {
if(_threeD_render_page) if (_threeD_render_page)
return; return;
add3dRenderPage(toolBars); add3dRenderPage(toolBars);
} else { }
else {
this->removeToolBars(); this->removeToolBars();
_mainWindow->addToolBarBreak(); _mainWindow->addToolBarBreak();
for(int i = 0; i < toolBars.size(); ++i) { for (int i = 0; i < toolBars.size(); ++i) {
_mainWindow->addToolBar(toolBars.at(i)); _mainWindow->addToolBar(toolBars.at(i));
(toolBars.at(i))->show(); (toolBars.at(i))->show();
_currentToolBars.append(toolBars.at(i)); _currentToolBars.append(toolBars.at(i));
@ -338,25 +327,25 @@ namespace GUI {
void SubWindowManager::closePostWindow(Post::PostWindowBase* w) void SubWindowManager::closePostWindow(Post::PostWindowBase* w)
{ {
QMdiSubWindow* subw = _postWindow.key(w); QMdiSubWindow* subw = _postWindow.key(w);
if(subw == nullptr) if (subw == nullptr)
return; return;
Post::PostWindowType type = w->getPostWindowType(); Post::PostWindowType type = w->getPostWindowType();
removeToolBars(); removeToolBars();
if(type == Post::PostWindowType::D3 if (type == Post::PostWindowType::D3
&& _mainWindow->isUseRibbon()) // 使用ribbon并且关闭的是3维窗口 && _mainWindow->isUseRibbon()) // 使用ribbon并且关闭的是3维窗口
remove3dRenderPage(); remove3dRenderPage();
if(_controlPanel != nullptr) if (_controlPanel != nullptr)
_controlPanel->updatePostWidget(nullptr, nullptr); _controlPanel->updatePostWidget(nullptr, nullptr);
emit _mainWindow->updateProperty(nullptr); emit _mainWindow->updateProperty(nullptr);
_postWindow.remove(subw); _postWindow.remove(subw);
QList<Post::PostWindowBase*> postsubwlist = _postWindow.values(); QList<Post::PostWindowBase*> postsubwlist = _postWindow.values();
if(_preWindow.first != nullptr) if (_preWindow.first != nullptr)
showPreWindow(); showPreWindow();
else if(postsubwlist.size() > 0) { else if (postsubwlist.size() > 0) {
Post::PostWindowBase* w = postsubwlist.at(0); Post::PostWindowBase* w = postsubwlist.at(0);
int id = w->getID(); int id = w->getID();
Post::PostWindowType type = w->getPostWindowType(); Post::PostWindowType type = w->getPostWindowType();
showPostWindowInfo(id, type); showPostWindowInfo(id, type);
} }
@ -365,10 +354,10 @@ namespace GUI {
void SubWindowManager::showPreWindow() void SubWindowManager::showPreWindow()
{ {
removeToolBars(); removeToolBars();
if(_controlPanel == nullptr) if (_controlPanel == nullptr)
return; return;
_controlPanel->updatePostWidget(nullptr, nullptr); _controlPanel->updatePostWidget(nullptr, nullptr);
if(_preWindow.first != nullptr) { if (_preWindow.first != nullptr) {
_preWindow.first->showMaximized(); _preWindow.first->showMaximized();
_preWindow.first->setFocus(); _preWindow.first->setFocus();
} }
@ -377,22 +366,22 @@ namespace GUI {
{ {
removeToolBars(); removeToolBars();
_controlPanel->updatePostWidget(nullptr, nullptr); _controlPanel->updatePostWidget(nullptr, nullptr);
if(_realTimeWindow.contains(w)) { if (_realTimeWindow.contains(w)) {
w->showMaximized(); w->showMaximized();
w->setFocus(); w->setFocus();
} }
} }
void SubWindowManager::subWindowActived(QMdiSubWindow* sw) void SubWindowManager::subWindowActived(QMdiSubWindow* sw)
{ {
if(sw == nullptr) if (sw == nullptr)
return; return;
if(sw == _preWindow.first) if (sw == _preWindow.first)
showPreWindow(); showPreWindow();
else if(_realTimeWindow.contains(sw)) else if (_realTimeWindow.contains(sw))
showRealTimeWindow(sw); showRealTimeWindow(sw);
else if(_postWindow.contains(sw)) { else if (_postWindow.contains(sw)) {
Post::PostWindowBase* pwb = _postWindow.value(sw); Post::PostWindowBase* pwb = _postWindow.value(sw);
int id = pwb->getID(); int id = pwb->getID();
Post::PostWindowType type = pwb->getPostWindowType(); Post::PostWindowType type = pwb->getPostWindowType();
showPostWindowInfo(id, type); showPostWindowInfo(id, type);
} }
@ -401,10 +390,10 @@ namespace GUI {
void SubWindowManager::closeRealTimeWindow(Post::RealTimeWindowBase* w) void SubWindowManager::closeRealTimeWindow(Post::RealTimeWindowBase* w)
{ {
QMdiSubWindow* subw = _realTimeWindow.key(w); QMdiSubWindow* subw = _realTimeWindow.key(w);
if(subw == nullptr) if (subw == nullptr)
return; return;
_realTimeWindow.remove(subw); _realTimeWindow.remove(subw);
if(_preWindow.first != nullptr) if (_preWindow.first != nullptr)
showPreWindow(); showPreWindow();
emit _mainWindow->updateActionStatesSig(); emit _mainWindow->updateActionStatesSig();
} }
@ -415,9 +404,9 @@ namespace GUI {
if (gwb == nullptr) return; if (gwb == nullptr) return;
gwb->setView(view);*/ gwb->setView(view);*/
ModuleBase::GraphWindowBase* gwb = getCurrentWindow(); ModuleBase::GraphWindowBase* gwb = getCurrentWindow();
if(gwb == nullptr) if (gwb == nullptr)
return; return;
const int id = gwb->getID(); const int id = gwb->getID();
QString win = gwb->getStringGraphWindowType(); QString win = gwb->getStringGraphWindowType();
qDebug() << win; qDebug() << win;
QString pycode = QString("MainWindow.setView(%1,\"%2\",\"%3\")").arg(id).arg(win).arg(view); QString pycode = QString("MainWindow.setView(%1,\"%2\",\"%3\")").arg(id).arg(win).arg(view);
@ -432,15 +421,16 @@ namespace GUI {
} }
void SubWindowManager::openReportWindow(XReport::ReportWindow* w) void SubWindowManager::openReportWindow(XReport::ReportWindow* w)
{ {
QMdiSubWindow* sw = nullptr; QMdiSubWindow* sw = nullptr;
QList<XReport::ReportWindow*> rws = _reportWindow.values(); QList<XReport::ReportWindow*> rws = _reportWindow.values();
if(rws.contains(w)) { if (rws.contains(w)) {
sw = _reportWindow.key(w); sw = _reportWindow.key(w);
} else { }
sw = _mdiArea->addSubWindow(w); else {
sw = _mdiArea->addSubWindow(w);
_reportWindow[sw] = w; _reportWindow[sw] = w;
} }
if(sw != nullptr) { if (sw != nullptr) {
sw->showMaximized(); sw->showMaximized();
sw->setFocus(); sw->setFocus();
} }
@ -449,19 +439,19 @@ namespace GUI {
void SubWindowManager::closeReportWindow(XReport::ReportWindow* w) void SubWindowManager::closeReportWindow(XReport::ReportWindow* w)
{ {
QMdiSubWindow* s = _reportWindow.key(w); QMdiSubWindow* s = _reportWindow.key(w);
if(s != nullptr) { if (s != nullptr) {
_reportWindow.remove(s); _reportWindow.remove(s);
} }
} }
bool SubWindowManager::isPreWindowOpened() bool SubWindowManager::isPreWindowOpened()
{ {
if(_preWindow.first == nullptr || _preWindow.second == nullptr) if (_preWindow.first == nullptr || _preWindow.second == nullptr)
return false; return false;
return true; return true;
} }
bool SubWindowManager::isPostWindowOpened() bool SubWindowManager::isPostWindowOpened()
{ {
if(_postWindow.size() > 0) if (_postWindow.size() > 0)
return true; return true;
return false; return false;
} }
@ -469,24 +459,25 @@ namespace GUI {
bool SubWindowManager::isPostWindowOpening() bool SubWindowManager::isPostWindowOpening()
{ {
QMdiSubWindow* activeWindow = _mdiArea->activeSubWindow(); QMdiSubWindow* activeWindow = _mdiArea->activeSubWindow();
if(activeWindow == nullptr) if (activeWindow == nullptr)
return false; return false;
else if(_postWindow.contains(activeWindow)) else if (_postWindow.contains(activeWindow))
return true; return true;
else else
return false; return false;
} }
void SubWindowManager::saveImage(QString fileName, int winType, Post::PostWindowBase* winhandle, void SubWindowManager::saveImage(QString fileName, int winType, Post::PostWindowBase* winhandle,
int w, int h) int w, int h)
{ {
if(winType == 0) { if (winType == 0) {
MainWidget::PreWindow* preW = _preWindow.second; MainWidget::PreWindow* preW = _preWindow.second;
if(preW == nullptr) if (preW == nullptr)
return; return;
preW->saveImage(fileName, w, h, false); preW->saveImage(fileName, w, h, false);
} else if(winType == 1) { }
if(_postWindow.key(winhandle) == nullptr) else if (winType == 1) {
if (_postWindow.key(winhandle) == nullptr)
return; return;
winhandle->saveImage(fileName, w, h, false); winhandle->saveImage(fileName, w, h, false);
} }
@ -495,18 +486,18 @@ namespace GUI {
void SubWindowManager::saveImage(int w, int h, QString f) void SubWindowManager::saveImage(int w, int h, QString f)
{ {
ModuleBase::GraphWindowBase* gw = this->getCurrentWindow(); ModuleBase::GraphWindowBase* gw = this->getCurrentWindow();
if(gw == nullptr) { if (gw == nullptr) {
_mainWindow->printMessage(Common::Message::Error, tr("No GraphWindow opened!")); _mainWindow->printMessage(Common::Message::Error, tr("No GraphWindow opened!"));
return; return;
} }
QString type = gw->getStringGraphWindowType(); QString type = gw->getStringGraphWindowType();
const int id = gw->getID(); const int id = gw->getID();
QString pycode = QString("MainWindow.saveImage(%1,%2,%3,\"%4\",\"%5\")") QString pycode = QString("MainWindow.saveImage(%1,%2,%3,\"%4\",\"%5\")")
.arg(w) .arg(w)
.arg(h) .arg(h)
.arg(id) .arg(id)
.arg(type) .arg(type)
.arg(f); .arg(f);
qDebug() << pycode; qDebug() << pycode;
Py::PythonAgent::getInstance()->submit(pycode); Py::PythonAgent::getInstance()->submit(pycode);
} }
@ -514,7 +505,7 @@ namespace GUI {
void SubWindowManager::saveImage(int w, int h, int id, QString winType, QString file) void SubWindowManager::saveImage(int w, int h, int id, QString winType, QString file)
{ {
ModuleBase::GraphWindowBase* win = this->getWindowByTypeID(winType, id); ModuleBase::GraphWindowBase* win = this->getWindowByTypeID(winType, id);
if(win == nullptr) if (win == nullptr)
return; return;
win->saveImage(file, w, h, false); win->saveImage(file, w, h, false);
Py::PythonAgent::getInstance()->unLock(); Py::PythonAgent::getInstance()->unLock();
@ -522,16 +513,16 @@ namespace GUI {
void SubWindowManager::setView(int id, QString winType, QString view) // liu void SubWindowManager::setView(int id, QString winType, QString view) // liu
{ {
ModuleBase::GraphWindowBase* gwb = getWindowByTypeID(winType, id); ModuleBase::GraphWindowBase* gwb = getWindowByTypeID(winType, id);
if(gwb == nullptr) if (gwb == nullptr)
return; return;
gwb->setView(view); gwb->setView(view);
Py::PythonAgent::getInstance()->unLock(); Py::PythonAgent::getInstance()->unLock();
} }
void SubWindowManager::setViewValue(int id, QString win, int x1, int x2, int x3, int y1, int y2, void SubWindowManager::setViewValue(int id, QString win, int x1, int x2, int x3, int y1, int y2,
int y3, int z1, int z2, int z3) int y3, int z1, int z2, int z3)
{ {
ModuleBase::GraphWindowBase* gwb = getWindowByTypeID(win, id); ModuleBase::GraphWindowBase* gwb = getWindowByTypeID(win, id);
if(gwb == nullptr) if (gwb == nullptr)
return; return;
gwb->setViewValue(x1, x2, x3, y1, y2, y3, z1, z2, z3); gwb->setViewValue(x1, x2, x3, y1, y2, y3, z1, z2, z3);
Py::PythonAgent::getInstance()->unLock(); Py::PythonAgent::getInstance()->unLock();
@ -546,37 +537,37 @@ namespace GUI {
void SubWindowManager::reTranslate() void SubWindowManager::reTranslate()
{ {
MainWidget::PreWindow* prew = _preWindow.second; MainWidget::PreWindow* prew = _preWindow.second;
if(prew != nullptr) if (prew != nullptr)
prew->reTranslate(); prew->reTranslate();
int n = 0; int n = 0;
QList<Post::PostWindowBase*> postWinList = _postWindow.values(); QList<Post::PostWindowBase*> postWinList = _postWindow.values();
n = postWinList.size(); n = postWinList.size();
for(int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
Post::PostWindowBase* pw = postWinList.at(i); Post::PostWindowBase* pw = postWinList.at(i);
if(pw != nullptr) if (pw != nullptr)
pw->reTranslate(); pw->reTranslate();
} }
QList<Post::RealTimeWindowBase*> rwList = _realTimeWindow.values(); QList<Post::RealTimeWindowBase*> rwList = _realTimeWindow.values();
n = rwList.size(); n = rwList.size();
for(int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
Post::RealTimeWindowBase* rw = rwList.at(i); Post::RealTimeWindowBase* rw = rwList.at(i);
if(rw != nullptr) if (rw != nullptr)
rw->reTranslate(); rw->reTranslate();
} }
QList<XReport::ReportWindow*> repWin = _reportWindow.values(); QList<XReport::ReportWindow*> repWin = _reportWindow.values();
n = repWin.size(); n = repWin.size();
for(int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
XReport::ReportWindow* w = repWin.at(i); XReport::ReportWindow* w = repWin.at(i);
w->reTranslate(); w->reTranslate();
} }
if(_threeD_render_page != nullptr) if (_threeD_render_page != nullptr)
_threeD_render_page->setWindowTitle(tr("3D Render")); _threeD_render_page->setWindowTitle(tr("3D Render"));
} }
void SubWindowManager::closeGeometryWindow() void SubWindowManager::closeGeometryWindow()
{ {
_geometryWindow.first = nullptr; _geometryWindow.first = nullptr;
_geometryWindow.second = nullptr; _geometryWindow.second = nullptr;
_signalHander->clearData(false); _signalHander->clearData(false);
@ -588,7 +579,7 @@ namespace GUI {
GenerateGeometry::GenerateGeometryWidget* SubWindowManager::getGeometryWindow() GenerateGeometry::GenerateGeometryWidget* SubWindowManager::getGeometryWindow()
{ {
if(!_geometryWindow.second) { if (!_geometryWindow.second) {
openGeometryWindow(); openGeometryWindow();
} }
return _geometryWindow.second; return _geometryWindow.second;
@ -600,7 +591,7 @@ namespace GUI {
// _mdiArea->setTabPosition(QTabWidget::North); // _mdiArea->setTabPosition(QTabWidget::North);
MainWidget::PreWindow* pre = _preWindow.second; MainWidget::PreWindow* pre = _preWindow.second;
if(pre != nullptr) { if (pre != nullptr) {
_preWindow.first->close(); _preWindow.first->close();
_mdiArea->removeSubWindow(pre); _mdiArea->removeSubWindow(pre);
pre->close(); pre->close();
@ -608,7 +599,7 @@ namespace GUI {
} }
QList<Post::PostWindowBase*> postlist = _postWindow.values(); QList<Post::PostWindowBase*> postlist = _postWindow.values();
for(int i = 0; i < postlist.size(); ++i) { for (int i = 0; i < postlist.size(); ++i) {
Post::PostWindowBase* p = postlist.at(i); Post::PostWindowBase* p = postlist.at(i);
_postWindow.key(p)->close(); _postWindow.key(p)->close();
_mdiArea->removeSubWindow(p); _mdiArea->removeSubWindow(p);
@ -617,7 +608,7 @@ namespace GUI {
} }
QList<Post::RealTimeWindowBase*> realtimelist = _realTimeWindow.values(); QList<Post::RealTimeWindowBase*> realtimelist = _realTimeWindow.values();
for(int i = 0; i < realtimelist.size(); ++i) { for (int i = 0; i < realtimelist.size(); ++i) {
Post::RealTimeWindowBase* r = realtimelist.at(i); Post::RealTimeWindowBase* r = realtimelist.at(i);
_realTimeWindow.key(r)->close(); _realTimeWindow.key(r)->close();
_mdiArea->removeSubWindow(r); _mdiArea->removeSubWindow(r);
@ -626,7 +617,7 @@ namespace GUI {
} }
QList<XReport::ReportWindow*> reportlist = _reportWindow.values(); QList<XReport::ReportWindow*> reportlist = _reportWindow.values();
for(int i = 0; i < reportlist.size(); ++i) { for (int i = 0; i < reportlist.size(); ++i) {
XReport::ReportWindow* r = reportlist.at(i); XReport::ReportWindow* r = reportlist.at(i);
_reportWindow.key(r)->close(); _reportWindow.key(r)->close();
_mdiArea->removeSubWindow(r); _mdiArea->removeSubWindow(r);
@ -638,35 +629,38 @@ namespace GUI {
ModuleBase::GraphWindowBase* SubWindowManager::getWindowByTypeID(QString type, int id) ModuleBase::GraphWindowBase* SubWindowManager::getWindowByTypeID(QString type, int id)
{ {
ModuleBase::GraphWindowBase* g = nullptr; ModuleBase::GraphWindowBase* g = nullptr;
type = type.toLower(); type = type.toLower();
if(type == "prewindow") { if (type == "prewindow") {
g = _preWindow.second; g = _preWindow.second;
} else if(type == "realtime") { }
else if (type == "realtime") {
QList<Post::RealTimeWindowBase*> wlist = _realTimeWindow.values(); QList<Post::RealTimeWindowBase*> wlist = _realTimeWindow.values();
for(int i = 0; i < wlist.size(); ++i) { for (int i = 0; i < wlist.size(); ++i) {
ModuleBase::GraphWindowBase* t = wlist.at(i); ModuleBase::GraphWindowBase* t = wlist.at(i);
const int d = t->getID(); const int d = t->getID();
if(id == d) { if (id == d) {
g = t; g = t;
break; break;
} }
} }
} else if(type == "post2d") { }
else if (type == "post2d") {
QList<Post::PostWindowBase*> wlist = _postWindow.values(); QList<Post::PostWindowBase*> wlist = _postWindow.values();
for(int i = 0; i < wlist.size(); ++i) { for (int i = 0; i < wlist.size(); ++i) {
ModuleBase::GraphWindowBase* t = wlist.at(i); ModuleBase::GraphWindowBase* t = wlist.at(i);
const int d = t->getID(); const int d = t->getID();
if(id == d && t->getGraphWindowType() == ModuleBase::Post2D) { if (id == d && t->getGraphWindowType() == ModuleBase::Post2D) {
g = t; g = t;
break; break;
} }
} }
} else if(type == "post3d") { }
else if (type == "post3d") {
QList<Post::PostWindowBase*> wlist = _postWindow.values(); QList<Post::PostWindowBase*> wlist = _postWindow.values();
for(int i = 0; i < wlist.size(); ++i) { for (int i = 0; i < wlist.size(); ++i) {
ModuleBase::GraphWindowBase* t = wlist.at(i); ModuleBase::GraphWindowBase* t = wlist.at(i);
const int d = t->getID(); const int d = t->getID();
if(id == d && t->getGraphWindowType() == ModuleBase::Post3D) { if (id == d && t->getGraphWindowType() == ModuleBase::Post3D) {
g = t; g = t;
break; break;
} }
@ -677,11 +671,11 @@ namespace GUI {
void SubWindowManager::setIcon(QString icon) void SubWindowManager::setIcon(QString icon)
{ {
if(_preWindow.first != nullptr) if (_preWindow.first != nullptr)
_preWindow.first->setWindowIcon(QIcon(icon)); _preWindow.first->setWindowIcon(QIcon(icon));
QList<QMdiSubWindow*> subw = QList<QMdiSubWindow*> subw =
_postWindow.keys() + _realTimeWindow.keys() + _reportWindow.keys(); _postWindow.keys() + _realTimeWindow.keys() + _reportWindow.keys();
for(auto w : subw) { for (auto w : subw) {
w->setWindowIcon(QIcon(icon)); w->setWindowIcon(QIcon(icon));
} }
} }

View File

@ -53,7 +53,7 @@ namespace Py {
{ {
_mainWindow = m; _mainWindow = m;
connectSignals(); connectSignals();
Py_SetProgramName(L"FastCAE_LAMP"); Py_SetProgramName(L"FastCAE_LAMP"); // 设置程序名称
Py_Initialize(); Py_Initialize();
if(!_interpreter->init(this)) if(!_interpreter->init(this))
emit printInfo(Common::Message::Error, tr("Python Initialize failed!")); emit printInfo(Common::Message::Error, tr("Python Initialize failed!"));

View File

@ -0,0 +1,58 @@
#include "AllHead.h"
QSettings* getQSetting()
{
QString fileName = QCoreApplication::applicationDirPath() + "/Config.ini";
QSettings* setting = new QSettings(fileName, QSettings::IniFormat);
setting->setIniCodec(QTextCodec::codecForName("UTF-8"));
if (QFile::exists(fileName))
{
return setting;
}
else {// 文件不存在,写入配置项,生成配置文件
setting->setValue("application", u8"微波测量仿真分系统");
setting->sync();
}
return setting;
}
QString getOpenFilePath(QWidget* parent, const QString& caption, const QString& filter)
{
QSettings* setting = getQSetting();
QString curpath = u8".";
if (setting->contains("FileSelectPath")) {
curpath = setting->value("FileSelectPath").toString();
}
else {
}
QString filepath = QFileDialog::getOpenFileName( parent,caption, curpath, filter);
if (!filepath.isEmpty()&&QFile::exists(filepath)) {
setting->setValue("FileSelectPath", getParantFromPath(filepath));
setting->sync();
}
return filepath;
}
QString getSaveFilePath(QWidget* parent, const QString& caption, const QString& filter)
{
QSettings* setting = getQSetting();
QString curpath = u8".";
if (setting->contains("FileSelectPath")) {
curpath = setting->value("FileSelectPath").toString();
}
else {
}
QString filepath = QFileDialog::getSaveFileName(parent, caption, curpath, filter);
if (!filepath.isEmpty() && isExists(getParantFromPath(filepath))) {
setting->setValue("FileSelectPath", getParantFromPath(filepath));
setting->sync();
}
return filepath;
}

View File

@ -0,0 +1,210 @@
#pragma once
#ifndef ALLHEAD_H
#define ALLHEAD_H
//==================================
// 线性计算库优化
//===============================
//#define EIGEN_NO_DEBUG
//=====================================================
// 内部库 LAMPTool
//=====================================================
#include "referenceHeader.h"
// Basetoollib
#include "Basetoollib/BaseConstVariable.h"
#include "Basetoollib/BaseTool.h"
#include "Basetoollib/FileOperator.h"
//#include "Basetoollib/GeoOperator.h"
#include "Basetoollib/ImageOperatorBase.h"
//#include "Basetoollib/interpolation.h"
// SARBaseToolLib
//#include "SARBaseToolLib/BackScatterModel.h"
//#include "SARBaseToolLib/SARBaseTool.h"
//#include "SARBaseToolLib/SARCalibration.h"
#include "SARBaseToolLib/SARImageBase.h"
// SARImage
#include "SARImage/FEKOBaseToolClass.h"
#include "SARImage/FEKONearBPBasic.h"
#include "FEKOSimulationSARClass.h"
#include "OCCTBase.h"
#include "FEKOFarFieldFileClass.h"
//=====================================================
// 内部库 SharedModuleLib
//=====================================================
//=====================================================
// 内置 command
//=====================================================
// =====================================================
// 其他工程库
//
// ======================================================
#include "qcustomplot.h"
//=======================================================
// 引用库
//=======================================================
#include <QDebug>
#include <QDialog>
#include <BRepBuilderAPI_Copy.hxx>
#include <AIS_Shape.hxx>
#include <QObject>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QListWidget>
#include <QList>
#include <Standard_WarningsRestore.hxx>
#include <AIS_TextLabel.hxx>
#include <AIS_InteractiveContext.hxx>
#include <Graphic3d_Texture2Dplane.hxx>
#include <Graphic3d_Text.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
#include <vector>
#include <string>
#include <QMap>
#include <QUndoStack>
#include <QCheckBox>
#include <QMouseEvent>
#include <QDialog>
#include <BRepGProp.hxx>
#include <GProp_GProps.hxx>
#include <AIS_ViewCube.hxx>
#include <Geom_Axis2Placement.hxx>
#include <QApplication>
#include <QColor>
#include <QColorDialog>
#include <QStatusBar>
#include <StepGeom_Axis2Placement3d.hxx>
#include <AIS_InteractiveObject.hxx>
#include <Aspect_DisplayConnection.hxx>
#include <Graphic3d_NameOfMaterial.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <OSD_Environment.hxx>
#include <QFileDialog>
#include <TCollection_AsciiString.hxx>
#include <StlAPI_Reader.hxx>
#include <AIS_Trihedron.hxx>
#include <QtWidgets>
#include <BRepPrimAPI_MakePrism.hxx>
#include <IGESControl_Reader.hxx>
#include <STEPControl_Reader.hxx>
#include <IGESControl_Writer.hxx>
#include <STEPControl_Writer.hxx>
#include <StlAPI_Writer.hxx>
#include <BRep_Builder.hxx>
#include <BRepBuilderAPI_Collect.hxx>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <TopExp_Explorer.hxx>
#include <gp_Pnt.hxx>
#include <gp_Ax1.hxx>
#include <gp_Dir.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <AIS_TexturedShape.hxx>
#include <Prs3d_Arrow.hxx>
#include <BRepPrimAPI_MakeCylinder.hxx>
#include <BRepPrimAPI_MakeCone.hxx>
#include <BRepBuilderAPI_Transform.hxx>
#include <QMessageBOx>
#include <StlAPI_Writer.hxx>
#include <AIS_ViewCube.hxx>
#include <AIS_Shape.hxx>
#include <Geom_Axis2Placement.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QApplication>
#include <QColor>
#include <QColorDialog>
#include <QStatusBar>
#include <Standard_WarningsRestore.hxx>
#include <StepGeom_Axis2Placement3d.hxx>
#include <QDebug>
#include <AIS_InteractiveObject.hxx>
#include <Aspect_DisplayConnection.hxx>
#include <Graphic3d_NameOfMaterial.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <OSD_Environment.hxx>
#include <QFileDialog>
#include <TCollection_AsciiString.hxx>
#include <StlAPI_Reader.hxx>
#include <AIS_Trihedron.hxx>
#include <QCheckBox>
#include <QtWidgets>
#include <BRepPrimAPI_MakePrism.hxx>
#include <BRepBuilderAPI_Copy.hxx>
#include <IGESControl_Reader.hxx>
#include <STEPControl_Reader.hxx>
#include <IGESControl_Writer.hxx>
#include <STEPControl_Writer.hxx>
#include <QMessageBox>
#include <QtXml>
#include <boost/filesystem.hpp>
#include <QCloseEvent>
#include <BRepPrimAPI_MakePrism.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <QCommandLineParser>
#include <QJSValueIterator>
#include <Geom_Plane.hxx>
#include <QSettings>
class QObject;
// =====================================================
// 常用宏定义
//
// ======================================================
#define __SHOWPROCESS
// =====================================================
//#include <OCCTopoShapeTreeViewer.h>
//
// ======================================================
//=======================================================
// 常用基础变量类型定义
//=======================================================
//=======================================================
// 常用基础函数
//======================================================= ]
QSettings* getQSetting();
QString getOpenFilePath(QWidget* parent = nullptr, const QString& caption = QString(), const QString& filter = QString());
QString getSaveFilePath(QWidget* parent = nullptr, const QString& caption = QString(), const QString& filter = QString());
/*
QString filepath = getOpenFilePath(
nullptr,
QString::fromUtf8(u8"导入雷达模型"),
".",
QString::fromUtf8(u8"STL Files (*.stl);;STL Files (*.stla);;step Files (*.stp);;step Files (*.step);;IGES Files (*.iges);;IGES Files (*.igs)"));
*/
#endif // ! ALLHEAD_H

View File

@ -0,0 +1,68 @@
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
#-----------------------------------------------------------------------------
# include
#-----------------------------------------------------------------------------
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
set(_qrc "${CMAKE_CURRENT_SOURCE_DIR}/../qrc/WBCLFZSystemModule.qrc")
qt5_add_resources(_resource ${_qrc} ${_lang})
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
file(GLOB _ui "*.ui")
file(GLOB _header "*.h*")
file(GLOB _source "*.cpp")
qt5_wrap_ui(_interface ${_ui})
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
add_library(WBCLFZSystemModule
${_resource}
${_interface}
${_header}
${_source}
)
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
target_compile_definitions(WBCLFZSystemModule PRIVATE "WBCLFZSystemModule_API")
list(APPEND _depend_library qcustomplot LAMPTool qscintilla2 qhexedit)
list(APPEND _runtimes_libraries
Qt5::Core Qt5::Gui Qt5::Widgets
)
target_include_directories(WBCLFZSystemModule PRIVATE ${Qwt_INCLUDE_DIRS})
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
target_link_libraries(WBCLFZSystemModule PRIVATE
${_runtimes_libraries}
${_depend_library}
)
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
add_dependencies(WBCLFZSystemModule ${_depend_library})
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
set(FastCAE_WBCLFZSystemModule_Runtimes_Libraries ${_runtimes_libraries} PARENT_SCOPE)

View File

@ -0,0 +1,195 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogBatchExport</class>
<widget class="QDialog" name="DialogBatchExport">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>739</width>
<height>133</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>250</height>
</size>
</property>
<property name="windowTitle">
<string>场景文件批量导出</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>导出路径</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton_saveFile">
<property name="minimumSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>选择</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QLineEdit" name="lineEdit">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_text">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>导出格式</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="pushButton_export">
<property name="minimumSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>导出</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QGroupBox" name="groupBox">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="title">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="radioButton_Merged">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>合并 </string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_Split">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>不合并</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,82 @@
#include "CMDExcuteApp.h"
#include <QProcess>
#include <QDebug>
#include <QThread>
#include <QTimer>
CMDExcuteApp::CMDExcuteApp(QWidget* parent)
{
this->ui.setupUi(this);
this->cmd = new QProcess();
connect(this->cmd, SIGNAL(readyReadStandardOutput()), this, SLOT(on_readoutput()));
connect(this->cmd, SIGNAL(readyReadStandardError()), this, SLOT(on_readerror()));
}
CMDExcuteApp::~CMDExcuteApp()
{
if (nullptr != this->cmd) {
delete this->cmd;
this->cmd = nullptr;
}
}
int CMDExcuteApp::excuteCmd(QString cmdText)
{
qDebug() << u8"执行命令:" << cmdText ;
this->ui.textEdit->append("cmd.exe\n");
this->cmd->start("cmd.exe");
this->cmd->waitForStarted(); //等待程序启动
this->ui.textEdit->append(QString::QString(cmdText));
this->ui.textEdit->append("\n");
this->cmd->write(cmdText.toUtf8().constData());
this->cmd->close();
this->waitExcutedFinish();
return 0;
}
int CMDExcuteApp::excuteCmd(QString exePath, QString params)
{
qDebug() << u8"执行命令:" << exePath<<u8" "<< params;
this->setWindowTitle(exePath);
QString program = QString::QString(exePath);
QStringList prams_txt;
prams_txt.append(QString::QString(params));
this->cmd->start(program, prams_txt);
//this->cmd->waitForFinished();
this->show();
this->waitExcutedFinish();
return 0;
}
int CMDExcuteApp::waitExcutedFinish()
{
while (!this->cmd->waitForFinished()) {
qDebug() << u8"运行状态:" << this->cmd->state();
QCoreApplication::processEvents();
}
qDebug() << u8"退出循环运行状态:" << this->cmd->state();
qDebug() << u8"退出循环码:" << this->cmd->exitCode();
this->on_readerror();
this->on_readoutput();
emit this->callbackExcuteResult();
return 0;
}
int CMDExcuteApp::on_readerror()
{
QString out = this->cmd->readAllStandardError().data();
qDebug()<<u8"on_readerror:\t" << out;
this->ui.textEdit->append(out);
return 0;
}
int CMDExcuteApp::on_readoutput()
{
QString out = this->cmd->readAllStandardOutput().data();
qDebug() << u8"on_readoutput:\t" << out;
this->ui.textEdit->append(out); //将输出信息读取到编辑框
return 0;
}

View File

@ -0,0 +1,34 @@
#pragma once
#ifndef CMDEXCUTEAPP_H
#define CMDEXCUTEAPP_H
#include <QtWidgets/QMainWindow>
#include <QProcess>
#include "ui_CMDExcuteApp.h"
class CMDExcuteApp : public QMainWindow
{
Q_OBJECT
public:
CMDExcuteApp(QWidget* parent = nullptr);
~CMDExcuteApp();
int excuteCmd(QString cmdText);
int excuteCmd(QString exePath,QString params);
int waitExcutedFinish();
private:
Ui::cmdExcuteWindows ui;
QProcess* cmd;
signals:
void callbackExcuteResult();
private slots:
int on_readoutput();
int on_readerror();
};
#endif

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cmdExcuteWindows</class>
<widget class="QMainWindow" name="cmdExcuteWindows">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>568</width>
<height>260</height>
</rect>
</property>
<property name="windowTitle">
<string>cmd</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTextEdit" name="textEdit"/>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,394 @@
#include "EchoTableEditWindow.h"
#include "TableProcess/TableMainWindow.h"
#include "TableProcess/TableViewModel.h"
#include "SharedModuleLib/BaseUiTool.h"
#include "LAMPImageCreateClass.h"
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <QFileDialog>
#include <QClipboard>
#include <QItemSelectionModel>
#include <QDebug>
EchoTableEditWindow::EchoTableEditWindow(QWidget* parent)
{
this->FILEOPENLOCK = false;
this->CheckFieldContextHasEmptyCeilLOCK = false;
this->ui.setupUi(this);
this->setWindowTitle(u8"FEKO回波数据解析与导出界面");
this->initTableViewContextMenu();
this->initTableViewStatusBarControl();
// 定标常数界面关闭
this->ui.tab_calibration->setEnabled(false);
this->ui.tabWidget->removeTab(1);// 删除定标常数界面
}
EchoTableEditWindow::~EchoTableEditWindow()
{
delete this->statusprogressBar;
delete this->tableViewContextMenu;
delete this->m_undoStack;
}
int EchoTableEditWindow::initTableViewContextMenu()
{
qDebug() << u8"正在初始化contextMenu";
m_undoStack = new QUndoStack(this); //存放命令的栈
this->ui.tableView->setContextMenuPolicy(Qt::CustomContextMenu);
//this->ui.tableView->setFocusPolicy(Qt::NoFocus); // 允许快捷键
this->tableViewContextMenu = new QMenu(this->ui.tableView); // 表格控件的右键菜单
QAction* m_undoAction = m_undoStack->createUndoAction(this, u8"撤销");//添加QActionCtrl-Z作为回撤的快捷键
m_undoAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Z));
QObject::connect(m_undoAction, SIGNAL(triggered()), this, SLOT(tableView_UndoAction()));
QAction* m_redoAction = m_undoStack->createRedoAction(this, u8"重做");//添加QActionCtrl-Y左右前进的快捷键
m_redoAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Y));
QObject::connect(m_redoAction, SIGNAL(triggered()), this, SLOT(tableView_RedoAction()));
this->tableViewContextMenu->addAction(m_undoAction);
this->tableViewContextMenu->addAction(m_redoAction);
QAction *copyAction= this->tableViewContextMenu->addAction(u8"复制"); // 复制
copyAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
QObject::connect(copyAction, SIGNAL(triggered()), this, SLOT(tableView_CopyAction()));
QAction* PasteAction = this->tableViewContextMenu->addAction(u8"粘贴"); // 粘贴
PasteAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_V));
QObject::connect(PasteAction, SIGNAL(triggered()), this, SLOT(tableView_PasteAction()));
QAction* CheckFieldHasEmptyCeilAction = this->tableViewContextMenu->addAction(u8"检查单元格为空");
QObject::connect(CheckFieldHasEmptyCeilAction, SIGNAL(triggered()), this, SLOT(tableView_CheckFieldHasEmptyCeilAction()));
qDebug() << u8"初始化contextMenu结束";
return 0;
}
void EchoTableEditWindow::ShowTableViewContextMenu(QPoint p)
{
qDebug() << u8"正在展示tableview 右键菜单";
//Q_UNUSED(pos);
this->tableViewContextMenu->exec(QCursor::pos());
}
void EchoTableEditWindow::tableView_CopyAction()
{
qDebug() << u8"正在启动tableview 右键复制代码";
QItemSelectionModel* selectionModel = this->ui.tableView->selectionModel();
QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
if (selectedIndexes.count() == 0) {
return;
}
QTableView* tableView = this->ui.tableView; // Your table view object
/*
* a\tb\tc\n
* d\tf\te\n
**/
int min_row, max_row, min_col, max_col;
min_row = selectedIndexes.at(0).row();
max_row = selectedIndexes.at(0).row();
min_col = selectedIndexes.at(0).column();
max_col = selectedIndexes.at(0).column();
for (int i = 0; i < selectedIndexes.count(); i++) {
min_row = min_row > selectedIndexes.at(i).row() ? selectedIndexes.at(i).row() : min_row;
max_row = max_row < selectedIndexes.at(i).row() ? selectedIndexes.at(i).row() : max_row;
min_col = min_col > selectedIndexes.at(i).column() ? selectedIndexes.at(i).column() : min_col;
max_col = max_col < selectedIndexes.at(i).column() ? selectedIndexes.at(i).column() : max_col;
}
std::vector<std::vector<QString>> copylist(max_row-min_row+1);
for (int i = min_row; i <= max_row; i++) {
copylist[i - min_row] = std::vector<QString>(max_col - min_col + 1);
}
qDebug() << u8"minRow"<<min_row;
qDebug() << u8"maxRow" << max_row;
qDebug() << u8"minCol" << min_col;
qDebug() << u8"maxCol" << max_col;
for (int i = 0; i < selectedIndexes.count(); i++) {
QString tempstring= selectedIndexes.at(i).data().toString();
copylist[selectedIndexes.at(i).row() - min_row]
[selectedIndexes.at(i).column() - min_col] = tempstring;
}
QString clipboardText = "";
for (int i = 0; i < copylist.size(); i++) {
for(int j=0;j<copylist[i].size()-1;j++){
clipboardText = clipboardText + copylist[i][j]+u8"\t";
}
clipboardText = clipboardText + copylist[i][copylist[i].size() - 1] + u8"\n";
//clipboardData.append("\n");
}
// Add header data
//QHeaderView* header = tableView->horizontalHeader();
//for (int i = 0; i < header->count(); i++) {
// QVariant headerData = header->model()->headerData(i, Qt::Horizontal);
// clipboardData.insert(i, headerData.toString());
//}
qDebug() << u8"============================";
qDebug() << clipboardText;
qDebug() << u8"============================";
QApplication::clipboard()->setText(clipboardText);
}
int EchoTableEditWindow::setDragDropOverwriteMode(bool flag) {
this->ui.tableView->setDragDropOverwriteMode(flag);
return 0;
}
int EchoTableEditWindow::setTablCalibrationTab(bool flag)
{
if (flag) {
this->ui.tab_calibration->setEnabled(true);
this->ui.tabWidget->insertTab(1, this->ui.tab_calibration, u8"定标常数");
}
else {
this->ui.tab_calibration->setEnabled(false);
this->ui.tabWidget->removeTab(1);// 删除定标常数界面
}
return 0;
}
void EchoTableEditWindow::tableView_PasteAction() {
qDebug() << u8"正在启动tableview 右键粘贴代码";
QTableView* tableview = this->ui.tableView;
QClipboard* clipboard = QApplication::clipboard();
QString clipboardData = QApplication::clipboard()->text();
QItemSelectionModel* selectionModel = this->ui.tableView->selectionModel();
QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
this->m_undoStack->push(new PasteCommand(this->ui.tableView, selectedIndexes, clipboardData));
tableview->show();
}
void EchoTableEditWindow::tableView_UndoAction()
{
qDebug() << u8"正在撤销命令";
int index = this->m_undoStack->index();
this->m_undoStack->setIndex(index);
}
void EchoTableEditWindow::tableView_RedoAction()
{
qDebug() << u8"正在重做命令";
int index = this->m_undoStack->index();
this->m_undoStack->setIndex(index );
}
// 检查存在空单元格的列,并修改展示
void EchoTableEditWindow::tableView_CheckFieldHasEmptyCeilAction()
{
this->ui.statusbar->showMessage(u8"正在检查存在空数据的单元列");
size_t colcount = this->ui.tableView->model()->columnCount();
size_t rowcount = this->ui.tableView->model()->rowCount();
this->statusprogressBar->setRange(0, colcount - 1);
this->statusprogressBar->setValue(0);
QList<QModelIndex> cellIndexes;
for (int j = 0; j < colcount; j++) {
for (int i = 0; i < rowcount; i++) {
if (this->ui.tableView->model()->index(i, j).data().toString().count() < 1) {
cellIndexes.append(this->ui.tableView->model()->index(i, j));
break;
}
}
this->statusprogressBar->setValue(j);
}
if (cellIndexes.count() == 0) {
return;
}
else {}
this->ui.statusbar->showMessage(u8"正在选择空格");
this->statusprogressBar->setRange(0, cellIndexes.count()-1);
this->statusprogressBar->setValue(0);
QItemSelectionModel* selectionModel = this->ui.tableView->selectionModel();
for (int i = 0; i < cellIndexes.count(); i++) {
selectionModel->select(cellIndexes[i], QItemSelectionModel::Select);
this->statusprogressBar->setValue(i);
}
this->ui.tableView->show();
this->ui.tableView->scrollTo(cellIndexes[0], QAbstractItemView::EnsureVisible);
}
void EchoTableEditWindow::on_actionOpen_triggered()
{
this->OpenCSVDialog();
}
void EchoTableEditWindow::on_actionSave_triggered()
{
this->SaveCSVDialog();
}
void EchoTableEditWindow::on_actionSaveAs_triggered()
{
this->SaveAsDialog();
}
void EchoTableEditWindow::on_actionEchoSplitExport_triggered()
{
// 在窗口关闭事件中询问用户是否关闭
QMessageBox::StandardButton reply;
qDebug() << u8"检查乱码文件所在位置";
reply = QMessageBox::question(this, u8"询问", u8"导出回波文件前,请保存文件", QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) {
// 用户点击了"Yes"按钮,关闭窗口
this->SaveCSVDialog();
}
else {
// 用户点击了"No"按钮,取消关闭操作
return;
}
// 保存并导出回波文件
this->ui.statusbar->showMessage(u8"正在分析回波文件");
this->statusprogressBar->setRange(0,100);
this->statusprogressBar->setValue(10);
FEKOBase::NearFieldEchoCSVParser nearfilePraseclass;
QString echocsvfilepath = this->model->getCSVPath();
if (!nearfilePraseclass.parseCSV(echocsvfilepath)) {
QMessageBox::warning(this, u8"警告", u8"回波文件结构解析错误,请检查文件");
return;
}
this->statusprogressBar->setValue(25);
QMessageBox::information(this, u8"信息", u8"请分别为theta极化、phi极化、R极化分量回波指定保存路径");
QString thetafilepath = getSaveFilePath(
this,
QString::fromUtf8(u8"另存为"),
QString::fromUtf8(u8"theta文件 (*.theta)"));//多组扩展名用双分号";;"隔开
QString phifilepath = getSaveFilePath(
this,
QString::fromUtf8(u8"另存为"),
QString::fromUtf8(u8"phi文件 (*.phi)"));//多组扩展名用双分号";;"隔开
QString Rfilepath = getSaveFilePath(
this,
QString::fromUtf8(u8"另存为"),
QString::fromUtf8(u8"R文件 (*.R)"));//多组扩展名用双分号";;"隔开
this->ui.statusbar->showMessage(u8"正在导出theta极化");
nearfilePraseclass.toThetapolar(thetafilepath);
this->statusprogressBar->setValue(50);
this->ui.statusbar->showMessage(u8"正在导出phi极化");
nearfilePraseclass.toPhiPolar(phifilepath);
this->statusprogressBar->setValue(75);
this->ui.statusbar->showMessage(u8"正在导出R极化");
nearfilePraseclass.toRPolar(Rfilepath);
this->statusprogressBar->setValue(99);
QMessageBox::information(this, u8"信息", u8"极化回波已经保存完毕");
// 询问用户是否关闭窗口
reply = QMessageBox::question(this, u8"提示", u8"是否直接进行成像?",QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) {
LAMPImageCreateClass* imagewindows = new LAMPImageCreateClass;
imagewindows->show();
}
else {
return;
}
}
void EchoTableEditWindow::on_actionCalibrationConst_triggered()
{
}
int EchoTableEditWindow::LockFileOpen(bool flag)
{
this->FILEOPENLOCK = flag;
return 0;
}
int EchoTableEditWindow::setCheckFieldContextHasEmptyCeilLOCK(bool flag)
{
this->CheckFieldContextHasEmptyCeilLOCK = flag;
return 0;
}
int EchoTableEditWindow::loadTablemode(std::shared_ptr<AbstractTableModel> mode)
{
this->model = mode;
this->ui.tableView->setModel(this->model.get());
if (this->model->rowCount() > 1e4) {
this->ui.tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
}
return 0;
}
int EchoTableEditWindow::setTableViewAutoSort(bool flag)
{
this->ui.tableView->setSortingEnabled(flag);
return flag;
}
int EchoTableEditWindow::initTableViewStatusBarControl()
{
this->statusprogressBar = new QProgressBar();
this->statusprogressBar->setRange(0, 100); // 设置进度条范围
this->statusprogressBar->setValue(0); // 设置当前进度
this->ui.statusbar->addPermanentWidget(this->statusprogressBar); // 在状态栏中添加进度条
return 0;
}
int EchoTableEditWindow::OpenCSVDialog()
{
if (this->FILEOPENLOCK) {
return 0;
}
else {}
QString tableFilepath = getOpenFilePath(
this,
QString::fromUtf8(u8"打开表格文件"),
QString::fromUtf8(u8"csv文件 (*.csv);;xls文件(*.xls)"));
this->ui.statusbar->showMessage(u8"正在打开文件....");
std::shared_ptr< FEKOResultCsvTableModel> tablemode = std::make_shared< FEKOResultCsvTableModel>();
tablemode->loadCSVFilePath(tableFilepath);
this->loadTablemode(tablemode);
this->setTableViewAutoSort(true);
this->LockFileOpen();
this->ui.statusbar->showMessage(u8"文件打开结束");
return -1;
}
int EchoTableEditWindow::SaveCSVDialog()
{
this->model->saveFilePath();
return 0;
}
int EchoTableEditWindow::SaveAsDialog()
{
QString filepath = getSaveFilePath(
this,
QString::fromUtf8(u8"另存为"),
QString::fromUtf8(u8"csv文件 (*.csv)"));//多组扩展名用双分号";;"隔开
this->model->saveAsFilePath(filepath);
return 0;
}

View File

@ -0,0 +1,96 @@
#pragma once
#ifndef ECHOTABLEEDITWINDOW_H
#define ECHOTABLEEDITWINDOW_H
#include "AllHead.h"
#include <QtWidgets/QMainWindow>
#include "ui_EchoTableEditWindow.h"
#include "TableProcess/TableViewModel.h"
#include <QUndoStack>
#include <QUndoCommand>
#include <qprogressbar.h>
#include <memory>
/*
*
***/
/*
*
****/
class EchoTableEditWindow : public QMainWindow
{
Q_OBJECT
public:
bool FILEOPENLOCK;
bool CheckFieldContextHasEmptyCeilLOCK;
private:
std::shared_ptr<AbstractTableModel> model;
QMenu* tableViewContextMenu;
QUndoStack* m_undoStack;
/*菜单*/
QProgressBar* statusprogressBar;
public:
EchoTableEditWindow(QWidget* parent = nullptr);
~EchoTableEditWindow();
int initTableViewStatusBarControl();
int initTableViewContextMenu(); // 初始化上下文菜单
int LockFileOpen(bool flag=true); // 锁定文件,不允许进行重新打开文件
int setCheckFieldContextHasEmptyCeilLOCK(bool flag=true);// 允许启动当前字段中存在空格检查,-- 提供给FEKOResult分析使用
int loadTablemode(std::shared_ptr<AbstractTableModel> mode); // 加载tableview 使用的model
int setTableViewAutoSort(bool flag);
int setDragDropOverwriteMode(bool flag); // 是否禁用列调换
int setTablCalibrationTab(bool flag);
private:
Ui::EchoTableEditWindow ui;
int OpenCSVDialog();
int SaveCSVDialog();
int SaveAsDialog();
public slots:
// tableview 右键菜单
void ShowTableViewContextMenu(QPoint p);
void tableView_CopyAction();
void tableView_PasteAction();
void tableView_UndoAction();
void tableView_RedoAction();
void tableView_CheckFieldHasEmptyCeilAction();
void on_actionOpen_triggered();
void on_actionSave_triggered();
void on_actionSaveAs_triggered();
void on_actionEchoSplitExport_triggered(); // 回波数据导出
void on_actionCalibrationConst_triggered(); // 计算定标常数
protected: // 重写函数
void closeEvent(QCloseEvent* event) override {
// 在窗口关闭事件中询问用户是否关闭
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, u8"Close", u8"您回波数据导出了吗?", QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) {
// 用户点击了"Yes"按钮,关闭窗口
event->accept();
}
else {
// 用户点击了"No"按钮,取消关闭操作
event->ignore();
}
};
};
#endif // !ECHOTABLEEDITWINDOW_H

View File

@ -0,0 +1,285 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EchoTableEditWindow</class>
<widget class="QMainWindow" name="EchoTableEditWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>752</width>
<height>520</height>
</rect>
</property>
<property name="windowTitle">
<string>回波表格处理</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabEcho">
<attribute name="title">
<string>回波文件</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTableView" name="tableView"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_calibration">
<attribute name="title">
<string>定标常数</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>定标球大小</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_ballSize">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>0.001</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QTableView" name="tableView_calibration"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>752</width>
<height>26</height>
</rect>
</property>
<widget class="QMenu" name="menu">
<property name="title">
<string>文件</string>
</property>
<addaction name="actionOpen"/>
<addaction name="actionSave"/>
<addaction name="actionSaveAs"/>
</widget>
<widget class="QMenu" name="menu_4">
<property name="title">
<string>回波工具</string>
</property>
<addaction name="actionFEKOCheck"/>
<addaction name="actionEchoSplitExport"/>
<addaction name="actionEchoCalibration"/>
</widget>
<widget class="QMenu" name="menu_2">
<property name="title">
<string>定标工具</string>
</property>
<addaction name="actionCalibrationConst"/>
<addaction name="actionImportCalibrationCons"/>
</widget>
<addaction name="menu"/>
<addaction name="menu_4"/>
<addaction name="menu_2"/>
</widget>
<action name="actionOpen">
<property name="text">
<string>打开文件</string>
</property>
</action>
<action name="actionSave">
<property name="text">
<string>保存文件</string>
</property>
</action>
<action name="actionSaveAs">
<property name="text">
<string>另存为</string>
</property>
</action>
<action name="actionShowAllField">
<property name="text">
<string>展示所有字段</string>
</property>
</action>
<action name="actionAddField">
<property name="text">
<string>添加字段</string>
</property>
</action>
<action name="actionRemoveField">
<property name="text">
<string>移除字段</string>
</property>
</action>
<action name="actionEditField">
<property name="text">
<string>编辑字段</string>
</property>
</action>
<action name="actionCreateNewDoc">
<property name="text">
<string>创建新文件</string>
</property>
</action>
<action name="actionFEKOCheck">
<property name="text">
<string>FEKO检查</string>
</property>
</action>
<action name="action_forestObjectives">
<property name="text">
<string>森林目标属性表检查</string>
</property>
</action>
<action name="action_cropObjectives">
<property name="text">
<string>农作物目标属性表检查</string>
</property>
</action>
<action name="action_grasslandObjectives">
<property name="text">
<string>草地目标属性表检查</string>
</property>
</action>
<action name="action_waterBodyObjectives">
<property name="text">
<string>水体目标属性表检查</string>
</property>
</action>
<action name="action_soilObjectives">
<property name="text">
<string>土壤目标属性表检查</string>
</property>
</action>
<action name="action_dynamicWaterBodyObjectives">
<property name="text">
<string>动态水体目标属性表检查</string>
</property>
</action>
<action name="action_roadObjectives">
<property name="text">
<string>道路目标属性表检查</string>
</property>
</action>
<action name="action_artificialObjectives">
<property name="text">
<string>人工目标属性表检查</string>
</property>
</action>
<action name="action_geometricCorrectionScene">
<property name="text">
<string>几何校正场景属性表检查</string>
</property>
</action>
<action name="action_radiometricCorrectionScene">
<property name="text">
<string>辐射校正场景属性表检查</string>
</property>
</action>
<action name="action_landSurfaceScene">
<property name="text">
<string>陆表场景属性表检查</string>
</property>
</action>
<action name="action_waterBodyScene">
<property name="text">
<string>水体场景属性表检查</string>
</property>
</action>
<action name="action_vegetationScene">
<property name="text">
<string>植被场景属性表检查</string>
</property>
</action>
<action name="actionExportThetaData">
<property name="text">
<string>ExportThetaData</string>
</property>
</action>
<action name="actionexportData">
<property name="text">
<string>exportData</string>
</property>
</action>
<action name="actionEchoSplitExport">
<property name="text">
<string>回波切分导出</string>
</property>
</action>
<action name="actionEchoCalibration">
<property name="text">
<string>回波定位</string>
</property>
</action>
<action name="actionCalibrationConst">
<property name="text">
<string>计算定标常数</string>
</property>
</action>
<action name="actionImportCalibrationCons">
<property name="text">
<string>导入定标常数表</string>
</property>
</action>
</widget>
<resources/>
<connections/>
<slots>
<slot>OpenCSVDialog()</slot>
<slot>SaveCSVDialog()</slot>
<slot>SaveAsDialog()</slot>
<slot>ShowTableViewContextMenu(QPoint)</slot>
</slots>
</ui>

View File

@ -0,0 +1,427 @@
#include "FEKOResultImport.h"
#include "BaseToolLib/FileOperator.h"
#include "SharedModuleLib/BaseUiTool.h"
#include "TaskXml/TaskTreeClass.h"
#include "EchoTableEditWindow.h"
#include <QFileDialog>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <memory>
#include <boost/filesystem.hpp>
#include <QStandardItemModel>
#include <QStringListModel>
#include <QMessageBox>
#include <unordered_set>
#include <QProcess>
#include <QDebug>
#include "CMDExcuteApp.h"
#include <QtCore>
#include <QtXml>
#include <QDomDocument>
FEKOResultImport::FEKOResultImport(QWidget* parent)
{
//this->setAttribute(Qt::WidgetAttribute::WA_DeleteOnClose);
//this->setWindowModality(Qt::WindowModality::WindowModal);
this->ui.setupUi(this);
this->ListViewmodel = new QStandardItemModel(this);
this->ui.listView->setModel(this->ListViewmodel);
this->selectListViewmodel = new QStandardItemModel(this);
this->selectListViewmodel->clear();
this->ListViewmodel->clear();
this->p = nullptr;
}
FEKOResultImport::~FEKOResultImport()
{
if (nullptr == this->ListViewmodel || NULL == this->ListViewmodel) {}
else {
this->ListViewmodel->clear();
delete this->ListViewmodel;
this->ListViewmodel = nullptr;
}
if (nullptr == this->selectListViewmodel || NULL == this->selectListViewmodel) {}
else {
this->selectListViewmodel->clear(); // 释放所有对象的内存
delete this->selectListViewmodel;
this->selectListViewmodel = nullptr;
}
if (nullptr == this->p) {}
else {
this->p->close();
//delete this->p;
this->p = nullptr;
}
}
QString FEKOResultImport::getFEKOPreFileName()
{
return this->FEKOPreFileName;
return QString();
}
int FEKOResultImport::setFEKOPreFileName(QString preFileName)
{
this->FEKOPreFileName = preFileName;
return 0;
}
int FEKOResultImport::setNearFieldNames(std::vector<QString> nearFieldNames)
{
this->nearFieldNames.clear();
this->nearFieldNames.shrink_to_fit();
this->nearFieldNames = nearFieldNames;
return 0;
}
std::vector<QString> FEKOResultImport::getNearFieldNames()
{
return this->nearFieldNames;
}
int FEKOResultImport::setFarFieldNames(std::vector<QString> farFieldNames)
{
this->farFieldNames.clear();
this->farFieldNames.shrink_to_fit();
this->farFieldNames = farFieldNames;
return 0;
}
std::vector<QString> FEKOResultImport::getFarFieldNames()
{
return this->farFieldNames;
}
int FEKOResultImport::setSelectFieldNames(std::vector<QString> SelectFieldNames, bool nearOrfar)
{
if (nearOrfar) {
this->ui.NearradioButton->setChecked(1);
this->ui.FarradioButton->setChecked(0);
}
else {
this->ui.NearradioButton->setChecked(0);
this->ui.FarradioButton->setChecked(1);
}
// 剔除数据
this->ListViewmodel->clear();
this->selectListViewmodel->clear();
// 重新分配数据
for (int i = 0; i < SelectFieldNames.size(); i++) {
QStandardItem* item = new QStandardItem(QString::QString(SelectFieldNames[i]));
this->selectListViewmodel->appendRow(item);
}
std::unordered_set<QString> selectSET;
for (int i = 0; i < SelectFieldNames.size(); i++) {
selectSET.insert(SelectFieldNames[i]);// 插入
}
if (nearOrfar) {
for (int i = 0; i < this->nearFieldNames.size(); i++)
{
if (selectSET.insert(this->nearFieldNames[i]).second)//判断是否能插入成功
{
QStandardItem* item = new QStandardItem(QString::QString(this->nearFieldNames[i]));
this->ListViewmodel->appendRow(item);
}
else {
}
}
}
else {
for (int i = 0; i < this->farFieldNames.size(); i++)
{
if (selectSET.insert(this->farFieldNames[i]).second)//判断是否能插入成功
{
QStandardItem* item = new QStandardItem(QString::QString(this->farFieldNames[i]));
this->ListViewmodel->appendRow(item);
}
else {
}
}
}
this->ui.listView->setModel(this->ListViewmodel);
this->ui.SelectlistView->setModel(this->selectListViewmodel);
return 0;
}
std::vector<QString> FEKOResultImport::getSelectFieldNames()
{
std::vector<QString> result(0);
this->selectListViewmodel = (QStandardItemModel*)(this->ui.SelectlistView->model());
int selectCount = this->ui.SelectlistView->model()->rowCount();
for (int i = 0; i < selectCount; i++) {
QStandardItem* listItem = this->selectListViewmodel->item(i);
result.push_back(listItem->text());
}
return result;
}
int FEKOResultImport::setFEKOResultCSVPath(QString csvPath)
{
this->FEKOResultCSVPath = csvPath;
return 0;
}
QString FEKOResultImport::getFEKOResultCSVPath()
{
return this->FEKOResultCSVPath;
}
int FEKOResultImport::setFEKOPreProjectFolderPath(QString FolderPath)
{
this->FEKOProjectFolderPath = FolderPath;
return 0;
}
QString FEKOResultImport::getFEKOPreProjectFolderPath()
{
return this->FEKOProjectFolderPath;
}
int FEKOResultImport::initView()
{
this->ui.FolderPathtextEdit->setText(this->FEKOProjectFolderPath);
this->ui.PreFileNametextEdit->setText(this->FEKOPreFileName);
this->ui.csvPathText->setText(this->FEKOResultCSVPath);
this->ui.NearradioButton->setChecked(this->getNearChecked());
this->ui.FarradioButton->setChecked(this->getFarChecked());
this->InitListView();
return 0;
}
int FEKOResultImport::InitListView()
{
this->ListViewmodel->clear();
this->selectListViewmodel->clear();
if (this->ui.FarradioButton->isChecked()) {
for (int i = 0; i < this->farFieldNames.size(); i++) {
QStandardItem* item = new QStandardItem(QString::QString(this->farFieldNames[i]));
this->ListViewmodel->appendRow(item);
}
}
else {
this->ui.NearradioButton->setChecked(true);
for (int i = 0; i < this->nearFieldNames.size(); i++) {
QStandardItem* item = new QStandardItem(QString::QString(this->nearFieldNames[i]));
this->ListViewmodel->appendRow(item);
}
}
this->ui.listView->setModel(this->ListViewmodel);
this->ui.SelectlistView->setModel(this->selectListViewmodel);
return 0;
}
bool FEKOResultImport::getNearChecked()
{
return this->ui.NearradioButton->isChecked();
}
bool FEKOResultImport::getFarChecked()
{
return this->ui.FarradioButton->isChecked();
}
bool FEKOResultImport::getSaveSucessfully()
{
return this->saveSucessfully;
}
QString FEKOResultImport::getSaveCsvFilePath()
{
return this->FEKOResultCSVPath;
}
// 打开文件并寻找pre文件
int FEKOResultImport::OpenPrejectFolderPath() {
//打开单个文件
QString prefileNamePath = getOpenFilePath(
this,
QString::fromUtf8(u8"选择.pre 文件"),
QString::fromUtf8(u8"pre文件 (*.pre)"));//多组扩展名用双分号";;"隔开
this->FEKOProjectFolderPath = getParantFromPath(prefileNamePath);
this->FEKOPreFileName = getFileNameFromPath(prefileNamePath);
this->farFieldNames = getFilelist(this->FEKOProjectFolderPath, ".ffe");
this->nearFieldNames = getFilelist(this->FEKOProjectFolderPath, ".efe");
// 修改显示
this->ListViewmodel->clear();
this->ui.FolderPathtextEdit->setText(this->FEKOProjectFolderPath);
this->ui.PreFileNametextEdit->setText(this->FEKOPreFileName);
if (this->ui.FarradioButton->isChecked()) {
for (int i = 0; i < this->farFieldNames.size(); i++) {
QStandardItem* item = new QStandardItem(QString::QString(this->farFieldNames[i]));
this->ListViewmodel->appendRow(item);
}
}
else {
this->ui.NearradioButton->setChecked(true);
for (int i = 0; i < this->nearFieldNames.size(); i++) {
QStandardItem* item = new QStandardItem(QString::QString(this->nearFieldNames[i]));
this->ListViewmodel->appendRow(item);
}
}
this->ui.listView->setModel(this->ListViewmodel);
qDebug()<<(u8"farField Number:"+QString::number(this->farFieldNames.size()) + "\n" + u8"NearField Number:" + QString::number(this->nearFieldNames.size()) + "\n");
return -1;
}
void FEKOResultImport::waitCMDExcute()
{
qDebug() << u8"转换程序执行结束";
if (isExists(this->FEKOResultCSVPath)) {
messageLog(u8"FEKOResult 保存成功\n路径:\t" + this->FEKOResultCSVPath, 1);
this->saveSucessfully = true;
this->p->close();
delete p;
this->p = nullptr;
}
else {
messageLog(u8"FEKOResult 保存失败\n路径:\t" + this->FEKOResultCSVPath, 1);
this->saveSucessfully = false;
}
// 触发结果时间
qDebug() << u8"准备执行转换结果编辑功能";
emit this->callbackFekoResultImport(this);
}
int FEKOResultImport::closeWindows()
{
this->close();
return 0;
}
int FEKOResultImport::NearRadioButtonSelect(bool selectTrue)
{
this->ui.NearradioButton->setChecked(selectTrue);
this->ui.FarradioButton->setChecked(!selectTrue);
this->InitListView();
return 0;
}
int FEKOResultImport::FarRadioButtonSelect(bool selectsign)
{
this->ui.NearradioButton->setChecked(!selectsign);
this->ui.FarradioButton->setChecked(selectsign);
this->InitListView();
return 0;
}
int FEKOResultImport::FEKOResultImportButtonClick()
{
if (isExists(this->FEKOResultCSVPath)) {
QFile file(this->FEKOResultCSVPath);
if (!file.open(QIODevice::ReadWrite)) {
QMessageBox::information(nullptr, u8"文件被占用", this->FEKOResultCSVPath);
return 2;
}
else {
file.close();
removeFile(this->FEKOResultCSVPath);
}
}
QString csvpramarPath = this->FEKOResultCSVPath;
csvpramarPath= csvpramarPath.replace(this->FEKOResultCSVPath.size() - 4, 4, ".params");
// 获取选择文件
std::vector<QString> selectfiles = this->getSelectFieldNames();
QString parmas_text = this->FEKOResultCSVPath +"\n";// 输出路径
for (int i = 0; i < selectfiles.size(); i++) {
parmas_text = parmas_text + selectfiles[i] + "\n";
}
if (isExists(csvpramarPath)) {
removeFile(csvpramarPath);
}
writeUTF8StringFile(csvpramarPath, (parmas_text));
// 拼接命令行
QString cmdtext = u8"";
if (this->ui.NearradioButton->isChecked()) {
cmdtext = cmdtext + u8"NearField2csvTool.exe";
}
else {
cmdtext = cmdtext + u8"FarField2csvTool.exe";
}
if (nullptr != this->p) {
this->p->close();
delete this->p;
this->p = nullptr;
}
this->p = new CMDExcuteApp();
QObject::connect(this->p, SIGNAL(callbackExcuteResult()), this, SLOT(waitCMDExcute()));
this->p->setAttribute(Qt::WA_DeleteOnClose);;
this->p->show();
this->p->excuteCmd(cmdtext, csvpramarPath);
return 0;
}
int FEKOResultImport::AddFekoResultClick()
{
QModelIndexList sourcelist=this->ui.listView->selectionModel()->selectedIndexes();
std::vector<int> deleteRowids(0);
for (int i = 0; i < sourcelist.count(); i++) {
deleteRowids.push_back(sourcelist[i].row());
qDebug() << ("deletaRowids add :"+QString::number(sourcelist[i].row())+"\n");
}
std::sort(deleteRowids.begin(), deleteRowids.end());
for (int i = deleteRowids.size() - 1; i >= 0; i--) {
int select_Idx = deleteRowids[i];
QList<QStandardItem*> listItem = this->ListViewmodel->takeRow(select_Idx);
int nRightCount = this->selectListViewmodel->rowCount();
this->selectListViewmodel->insertRow(nRightCount, listItem);
qDebug() << ("selectListViewmodel insertRow : "+ QString::number(select_Idx) +"-->" + QString::number(nRightCount) + "\n");
}
this->ui.listView->setModel(this->ListViewmodel);
this->ui.SelectlistView->setModel(this->selectListViewmodel);
return 0;
}
int FEKOResultImport::DeleteFekoResultClick()
{
QModelIndexList sourcelist = this->ui.SelectlistView->selectionModel()->selectedIndexes();
std::vector<int> deleteRowids(0);
for (int i = 0; i < sourcelist.count(); i++) {
deleteRowids.push_back(sourcelist[i].row());
}
std::sort(deleteRowids.begin(), deleteRowids.end());
for (int i = deleteRowids.size() - 1; i >= 0; i--) {
int select_Idx = deleteRowids[i];
QList<QStandardItem*> listItem = this->selectListViewmodel->takeRow(select_Idx);
int nRightCount = this->ListViewmodel->rowCount();
this->ListViewmodel->insertRow(nRightCount, listItem);
qDebug() << ("ListViewmodel insertRow : " + QString::number(select_Idx) + "-->" + QString::number(nRightCount) + "\n");
}
this->ui.listView->setModel(this->ListViewmodel);
this->ui.SelectlistView->setModel(this->selectListViewmodel);
return 0;
}
int FEKOResultImport::SaveCsvFilePath()
{
//打开单个文件
QString csvfileNamePath = getSaveFilePath(
this,
QString::fromUtf8(u8"保存FEKO解析结果 csv "),
QString::fromUtf8(u8"csv文件 (*.csv)"));//多组扩展名用双分号";;"隔开
this->FEKOResultCSVPath = csvfileNamePath;
this->ui.csvPathText->setPlainText(csvfileNamePath);
return 0;
}

View File

@ -0,0 +1,83 @@
#pragma once
#ifndef FEKORESULTIMPORT_H
#define FEKORESULTIMPORT_H
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QApplication>
#include "ui_FEKOResultImport.h"
#include "TaskXml/TaskTreeClass.h"
#include "CMDExcuteApp.h"
#include <QStandardItemModel>
#include <QStringListModel>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <QObject>
class FEKOResultImport : public QMainWindow
{
Q_OBJECT
public:
QString FEKOProjectFolderPath;
QString FEKOPreFileName;
std::vector<QString> nearFieldNames;
std::vector<QString> farFieldNames;
QString FEKOResultCSVPath;
private :
QStandardItemModel* ListViewmodel;
QStandardItemModel* selectListViewmodel;
bool saveSucessfully;
CMDExcuteApp* p;
public:
FEKOResultImport(QWidget* parent = nullptr);
~FEKOResultImport();
QString getFEKOPreFileName();
int setFEKOPreFileName(QString preFileName);
int setNearFieldNames(std::vector<QString> nearFieldNames);
std::vector<QString> getNearFieldNames();
int setFarFieldNames(std::vector<QString> farFieldNames);
std::vector<QString> getFarFieldNames();
int setSelectFieldNames(std::vector<QString> SelectFieldNames,bool nearOrfar);
std::vector<QString> getSelectFieldNames();
int setFEKOResultCSVPath(QString csvPath);
QString getFEKOResultCSVPath();
int setFEKOPreProjectFolderPath(QString FolderPath);
QString getFEKOPreProjectFolderPath();
int initView();
int InitListView();
bool getNearChecked();
bool getFarChecked();
bool getSaveSucessfully();
QString getSaveCsvFilePath();
private:
Ui::FEKOResultImportWindow ui;
signals:
void callbackFekoResultImport(FEKOResultImport* obj);
public slots: // 信号(或者事件)
int OpenPrejectFolderPath();
int closeWindows();
int NearRadioButtonSelect(bool);
int FarRadioButtonSelect(bool);
int FEKOResultImportButtonClick(); // 执行导入
int AddFekoResultClick();
int DeleteFekoResultClick();
int SaveCsvFilePath();
void waitCMDExcute(); // 导入完成
};
#endif

View File

@ -0,0 +1,425 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FEKOResultImportWindow</class>
<widget class="QMainWindow" name="FEKOResultImportWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>621</width>
<height>458</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>621</width>
<height>331</height>
</size>
</property>
<property name="windowTitle">
<string>FEKO近场文件导入</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>pre工程路径</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="FolderPathtextEdit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="OKpushButton">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>打开</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_3">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>FEKO结果输出地址</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="csvPathText">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>选择保存文件</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>.pre文件名</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="PreFileNametextEdit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="NearradioButton">
<property name="text">
<string>NearField</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="FarradioButton">
<property name="text">
<string>FarField</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QListView" name="listView">
<property name="minimumSize">
<size>
<width>0</width>
<height>200</height>
</size>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="AddpushButton">
<property name="text">
<string>&gt;&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="deletepushButton">
<property name="text">
<string>&lt;&lt;</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QListView" name="SelectlistView">
<property name="minimumSize">
<size>
<width>0</width>
<height>200</height>
</size>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="ImportpushButton">
<property name="text">
<string>导入FEKO结果</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="CancelpushButton">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>OKpushButton</sender>
<signal>clicked()</signal>
<receiver>FEKOResultImportWindow</receiver>
<slot>OpenPrejectFolderPath()</slot>
<hints>
<hint type="sourcelabel">
<x>802</x>
<y>52</y>
</hint>
<hint type="destinationlabel">
<x>519</x>
<y>99</y>
</hint>
</hints>
</connection>
<connection>
<sender>NearradioButton</sender>
<signal>clicked(bool)</signal>
<receiver>FEKOResultImportWindow</receiver>
<slot>NearRadioButtonSelect(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>728</x>
<y>175</y>
</hint>
<hint type="destinationlabel">
<x>471</x>
<y>112</y>
</hint>
</hints>
</connection>
<connection>
<sender>FarradioButton</sender>
<signal>clicked(bool)</signal>
<receiver>FEKOResultImportWindow</receiver>
<slot>FarRadioButtonSelect(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>802</x>
<y>175</y>
</hint>
<hint type="destinationlabel">
<x>504</x>
<y>86</y>
</hint>
</hints>
</connection>
<connection>
<sender>ImportpushButton</sender>
<signal>clicked()</signal>
<receiver>FEKOResultImportWindow</receiver>
<slot>FEKOResultImportButtonClick()</slot>
<hints>
<hint type="sourcelabel">
<x>721</x>
<y>435</y>
</hint>
<hint type="destinationlabel">
<x>514</x>
<y>158</y>
</hint>
</hints>
</connection>
<connection>
<sender>deletepushButton</sender>
<signal>clicked()</signal>
<receiver>FEKOResultImportWindow</receiver>
<slot>DeleteFekoResultClick()</slot>
<hints>
<hint type="sourcelabel">
<x>443</x>
<y>354</y>
</hint>
<hint type="destinationlabel">
<x>507</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>AddpushButton</sender>
<signal>clicked()</signal>
<receiver>FEKOResultImportWindow</receiver>
<slot>AddFekoResultClick()</slot>
<hints>
<hint type="sourcelabel">
<x>443</x>
<y>277</y>
</hint>
<hint type="destinationlabel">
<x>542</x>
<y>212</y>
</hint>
</hints>
</connection>
<connection>
<sender>CancelpushButton</sender>
<signal>clicked()</signal>
<receiver>FEKOResultImportWindow</receiver>
<slot>closeWindows()</slot>
<hints>
<hint type="sourcelabel">
<x>802</x>
<y>435</y>
</hint>
<hint type="destinationlabel">
<x>547</x>
<y>48</y>
</hint>
</hints>
</connection>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>FEKOResultImportWindow</receiver>
<slot>SaveCsvFilePath()</slot>
<hints>
<hint type="sourcelabel">
<x>757</x>
<y>106</y>
</hint>
<hint type="destinationlabel">
<x>767</x>
<y>136</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>OpenPrejectFolderPath()</slot>
<slot>closeWindows()</slot>
<slot>NearRadioButtonSelect(bool)</slot>
<slot>FarRadioButtonSelect(bool)</slot>
<slot>FEKOResultImportButtonClick()</slot>
<slot>AddFekoResultClick()</slot>
<slot>DeleteFekoResultClick()</slot>
<slot>SaveCsvFilePath()</slot>
</slots>
</ui>

View File

@ -0,0 +1,4 @@
#pragma once
#include "AllHead.h"
// 这里将系统环境中的文件默认先导入
#include <io.h>

View File

@ -0,0 +1,367 @@
#include "ImageShowDialogClass.h"
ImageShowDialogClass ::ImageShowDialogClass(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
ui.m_plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
connect(this->ui.m_plot, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(updateCursor(QMouseEvent*)));
this->graphclass=LAMPDATASHOWCLASS::NOWINDOWS;
this->menubar = new QMenuBar(this);
QMenu* windowsMenu = this->menubar->addMenu(u8"数据");
QAction* action_cursor_enable = windowsMenu->addAction(u8"打开游标");
QObject::connect(action_cursor_enable,SIGNAL(triggered()),this,SLOT(on_action_cursor_enable_trigged()));
this->tracer=new QCPItemTracer(this->ui.m_plot);
this->m_plot = ui.m_plot;
this->desCursor = nullptr;
this->HlineCursor = nullptr;
this->VlineCursor = nullptr;
this->desCursorflag=false;
this->HlineCursorflag=false;
this->VlineCursorflag = false;
this->statusbar=new QStatusBar(this);
this->statusbar->setMaximumHeight(20);
this->statusbar->setMinimumHeight(20);
ui.verticalLayout->setMenuBar(this->menubar);
ui.verticalLayout->addWidget(this->statusbar);
this->setLayout(ui.verticalLayout);
}
ImageShowDialogClass::~ImageShowDialogClass()
{}
void ImageShowDialogClass::on_action_cursor_enable_trigged()
{
this->desCursor = new ImageShowCursorDesClass();
QObject::connect(this->desCursor, SIGNAL(windowsClose()), this, SLOT(on_action_descursor_close_trigged()));
this->desCursorflag = true;
for (size_t i = 0; i < this->getGraphCount(); i++) {
if (this->getGraphClass(i) == LAMPDATASHOWCLASS::LAMPColorMap) {
this->HlineCursorflag = true;
this->VlineCursorflag = true;
}
}
//下面的代码就是设置游标的外观
this->setMouseTracking(true);
tracer->setInterpolating(false);//禁用插值
tracer->setPen(QPen(Qt::DashLine));//虚线游标
tracer->setStyle(QCPItemTracer::tsPlus);//游标样式:十字星、圆圈、方框
tracer->setBrush(Qt::red);//游标颜色
if (this->graphclass == LAMPDATASHOWCLASS::LAMPColorMap) {
this->HlineCursor = new ImageShowCursorLineClass();
this->VlineCursor = new ImageShowCursorLineClass();
QObject::connect(this->HlineCursor, SIGNAL(windowsClose()), this, SLOT(on_action_Hlinecursor_close_trigged()));
QObject::connect(this->VlineCursor, SIGNAL(windowsClose()), this, SLOT(on_action_VVlinecursor_close_trigged()));
QObject::connect(this->ui.m_plot->xAxis, SIGNAL(rangeChanged(QCPRange)), this->HlineCursor, SLOT(xAxisRangeChanged(QCPRange)));
QObject::connect(this->ui.m_plot->yAxis, SIGNAL(rangeChanged(QCPRange)), this->HlineCursor, SLOT(xAxisRangeChanged(QCPRange)));
this->HlineCursor->show();
this->VlineCursor->show();
}
this->desCursor->show();
}
void ImageShowDialogClass::load_double_MatrixX_data(Eigen::MatrixXd data, QString name)
{
int nx = data.rows(); // 行数
int ny = data.cols(); // 列数
// 创建 Color Map
QCPColorMap* colorMap = new QCPColorMap(ui.m_plot->xAxis, ui.m_plot->yAxis);
colorMap->data()->setSize(nx, ny); // 设置 Color Map 的大小
colorMap->data()->setRange(QCPRange(0, nx), QCPRange(0, ny)); // 设置坐标轴的范围
// 填充数据
for (int xIndex = 0; xIndex < nx; ++xIndex) {
for (int yIndex = 0; yIndex < ny; ++yIndex) {
double magnitude = data(xIndex, yIndex); // 或者使用 std::arg() 获取相位
colorMap->data()->setCell(xIndex, yIndex, magnitude);
}
}
colorMap->setGradient(QCPColorGradient::gpJet);
colorMap->rescaleDataRange(true);
ui.m_plot->rescaleAxes();
ui.m_plot->replot();
}
void ImageShowDialogClass::load_double_MatrixX_data(Eigen::MatrixXd X, Eigen::MatrixXd Y, Eigen::MatrixXd data, QString name)
{
int nx = data.cols(); // 行数
int ny = data.rows(); // 列数
// 创建 Color Map
ui.m_plot->xAxis->setRange(X(0, 0), X(0, nx - 1));
ui.m_plot->yAxis->setRange(Y(0, 0), Y(ny - 1, 0));
QCPColorMap* colorMap = new QCPColorMap(ui.m_plot->xAxis, ui.m_plot->yAxis);
colorMap->data()->setSize(ny, nx); // 设置 Color Map 的大小
colorMap->data()->setRange(QCPRange(X(0,0), X(0,nx-1)), QCPRange(Y(0,0),Y(ny-1,0))); // 设置坐标轴的范围
// 填充数据
for (int xIndex = 0; xIndex < nx; ++xIndex) {
for (int yIndex = 0; yIndex < ny; ++yIndex) {
double magnitude = data(yIndex, xIndex); // 或者使用 std::arg() 获取相位
colorMap->data()->setCell(yIndex, xIndex, magnitude);
}
}
colorMap->setGradient(QCPColorGradient::gpJet);
colorMap->rescaleDataRange(true);
ui.m_plot->rescaleAxes();
ui.m_plot->replot();
}
void ImageShowDialogClass::remove_Data(QString name)
{
for(size_t i=0;i<this->m_plot->graphCount();i++){
if (this->m_plot->graph(i)->name() == name) {
this->m_plot->removeGraph(i);
this->m_plot->replot();
return;
}
}
}
LAMPDATASHOWCLASS ImageShowDialogClass::getGraphClass(size_t i)
{
if (this->m_plot->graphCount() == 0 || i > this->m_plot->graphCount())
{
return LAMPDATASHOWCLASS::NOWINDOWS;
}
QCPAbstractPlottable* plottable = this->ui.m_plot->plottable(i);
if (dynamic_cast<QCPGraph*>(plottable)) {
return LAMPDATASHOWCLASS::LAMPGraph;
}
else if (dynamic_cast<QCPScatterStyle*>(plottable)) {
return LAMPDATASHOWCLASS::LAMPScatterStyle;
}
else if (dynamic_cast<QCPColorMap*>(plottable)) {
return LAMPDATASHOWCLASS::LAMPColorMap;
}
else {
return LAMPDATASHOWCLASS::NOWINDOWS;
}
}
size_t ImageShowDialogClass::getGraphCount()
{
return this->m_plot->graphCount();
}
void ImageShowDialogClass::on_action_descursor_close_trigged()
{
this->desCursorflag = false;
}
void ImageShowDialogClass::on_action_Hlinecursor_close_trigged()
{
this->HlineCursorflag = false;
}
void ImageShowDialogClass::on_action_VVlinecursor_close_trigged()
{
this->VlineCursorflag = false;
}
void ImageShowDialogClass::updateCursor(QMouseEvent *event)
{
if (this->desCursorflag &&this->HlineCursorflag &&this->VlineCursorflag) {
//下面的代码就是设置游标的外观
this->setMouseTracking(false);
}
else {
// 准备获取数据
QPoint pos = event->pos();
double x=this->m_plot->xAxis->pixelToCoord(pos.x()); // 将鼠标位置映射到图表坐标系中
double y = this->m_plot->yAxis->pixelToCoord(pos.y());
this->statusbar->showMessage(u8"X: "+QString::number(x,'f', 6)+" y: "+QString::number(y, 'f', 6));
if (this->desCursorflag) {
if (this->graphclass == LAMPDATASHOWCLASS::LAMPColorMap) {
QCPColorMap* colorMap = dynamic_cast<QCPColorMap*>(this->ui.m_plot->plottable(0));
double dataValue = colorMap->data()->data(x, y);
this->desCursor->updateCursorContent(u8"X: " + QString::number(x, 'f', 6) + " y: " + QString::number(y, 'f', 6) +u8"\n" +u8"DataValue: "+QString::number(dataValue));
}
else if (this->graphclass == LAMPDATASHOWCLASS::LAMPGraph) {
}
else if (this->graphclass == LAMPDATASHOWCLASS::LAMPScatterStyle) {
}
else {
this->desCursor->updateCursorContent(u8"无法识别图像类型");
}
}
if (this->HlineCursorflag) {
}
if (this->VlineCursorflag) {
}
}
}
ImageShowCursorDesClass::ImageShowCursorDesClass(QWidget* parent)
{
// 创建 QLabel
label = new QLabel(this);
// 创建布局
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(label);
// 设置布局
setLayout(layout);
}
ImageShowCursorDesClass::~ImageShowCursorDesClass()
{
}
void ImageShowCursorDesClass::closeEvent(QCloseEvent* event)
{
QDialog::closeEvent(event);
}
void ImageShowCursorDesClass::updateCursorContent(QString content) {
this->label->setText(content);
}
ImageShowCursorLineClass::ImageShowCursorLineClass(QWidget* parent)
{
this->menubar = new QMenuBar(this);
//QMenu* toolMenu = this->menubar->addMenu(u8"工具");
//QAction* action_add_compare_line = toolMenu->addAction(u8"添加对比数据");
//QObject::connect(action_add_compare_line, SIGNAL(triggered()), this, SLOT(load_new_compare_line()));
this->tracerEnable = false;
this->tracer = nullptr;
this->tracerXText = nullptr;
this->tracerYText = nullptr;
// 创建 QLabel
this->customPlot = new QCustomPlot(this);
// 创建布局
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(this->customPlot);
// 设置布局
setLayout(layout);
this->tracer = new QCPItemTracer(this->customPlot);
this->tracerYText = new QCPItemText(this->customPlot);
this->tracerXText = new QCPItemText(this->customPlot);
QObject::connect(this->customPlot, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(updateCursor(QMouseEvent*)));
this->customPlot->legend->setVisible(true);
}
ImageShowCursorLineClass::~ImageShowCursorLineClass()
{
}
void ImageShowCursorLineClass::loadPlotLine(QVector<double> xs, QVector<double> dataValues,QString Name)
{
if (dataValues.count() == 0) { return; }
QCPGraph* graph = this->customPlot->addGraph();
graph->setName(Name);
graph->setData(xs, dataValues);
double min_y = dataValues[0];
double max_y = dataValues[0];
for (size_t i = 0; i < dataValues.count(); i++) {
min_y = min_y > dataValues[i] ? dataValues[i] : min_y;
max_y = max_y < dataValues[i] ? dataValues[i] : max_y;
}
customPlot->yAxis->setRange(min_y, max_y);
customPlot->legend->setVisible(true);
customPlot->replot();
//下面的代码就是设置游标的外观
this->setMouseTracking(true);
tracer->setInterpolating(false);//禁用插值
tracer->setPen(QPen(Qt::DashLine));//虚线游标
tracer->setStyle(QCPItemTracer::tsPlus);//游标样式:十字星、圆圈、方框
tracer->setBrush(Qt::red);//游标颜色
tracer->setGraph(graph); // 确保游标跟随
this->m_graphMap.insert(Name, graph);
this->TrackName = Name;
}
void ImageShowCursorLineClass::updateCursor(QMouseEvent* event)
{
if (tracerEnable)//游标使能
{
double x = this->customPlot->xAxis->pixelToCoord(event->pos().x());//鼠标点的像素坐标转plot坐标
tracer->setGraphKey(x);//设置游标的X值这就是游标随动的关键代码
double traceX = tracer->position->key();
double traceY = tracer->position->value();
tracerXText->setText(QDateTime::fromMSecsSinceEpoch(traceX * 1000.0).toString("hh:mm:ss.zzz"));//游标文本框指示游标的X值
tracerYText->setText(QString::number(traceY));//游标文本框指示游标的Y值
////计算游标X值对应的所有曲线的Y值
//for (int i = 0; i < this->customPlot->graphCount(); i++)
//{
// QCPGraph* graph = dynamic_cast<QCPGraph*>(this->customPlot->plottable(i));
// //搜索左边离traceX最近的key对应的点详情参考findBegin函数的帮助
// QCPDataContainer<QCPGraphData>::const_iterator coorPoint = graph->data().data()->findBegin(traceX, true);//true代表向左搜索
// qDebug() << QString("graph%1对应的Y值是").arg(i) << coorPoint->value;
//}
}
}
void ImageShowCursorLineClass::closeEvent(QCloseEvent* event)
{
QDialog::closeEvent(event);
}
void ImageShowCursorLineClass::xAxisRangeChanged(QCPRange range) {
this->customPlot->xAxis->setRange(range);
customPlot->replot();
}
void ImageShowCursorLineClass::yAxisRangeChanged(QCPRange range) {
this->customPlot->yAxis->setRange(range);
customPlot->replot();
}
void ImageShowCursorLineClass::on_SwichTracerGraph_Name()
{
}
void ImageShowCursorLineClass::load_new_compare_line()
{
}

View File

@ -0,0 +1,139 @@
#pragma once
#ifndef IMAGESHOWDIALOGCLASS_H
#define IMAGESHOWDIALOGCLASS_H
#include "AllHead.h"
#include <QDialog>
#include "TaskXml/TaskTreeClass.h"
#include "ui_ImageShowDialogClass.h"
//===========================
// 定义需要绘制的图像的类型
//===========================
enum LAMPDATASHOWCLASS {
LAMPGraph,
LAMPColorMap,
LAMPScatterStyle,
NOWINDOWS
};
//===========================
// 构建游标类型
// 1. 单纯的描述游标,主要用来展示坐标,还有当前数据信息
// 2. 区域性描述游标,通过线,等用来展示某一个区域的信息
//===========================
class ImageShowCursorDesClass : public QDialog
{
Q_OBJECT
public:
QLabel* label;
public:
ImageShowCursorDesClass(QWidget* parent = nullptr);
~ImageShowCursorDesClass();
public slots:
void updateCursorContent(QString content);
signals:
bool windowsClose();
protected:
void closeEvent(QCloseEvent* event) override;
};
class ImageShowCursorLineClass :public QDialog {
Q_OBJECT
public:
QMenuBar* menubar;
QMenu* DataList;
QMenu* RemoveList;
QCustomPlot* customPlot;
bool tracerEnable;
QCPItemTracer* tracer; //游标
QCPItemText* tracerYText; //图标标签
QCPItemText* tracerXText; //游标标签
QMap<QString, QCPAbstractPlottable*> m_graphMap;
QMap<QString, QAction*> data_action_map;
QString TrackName;
public:
ImageShowCursorLineClass(QWidget* parent = nullptr);
~ImageShowCursorLineClass();
public:
void loadPlotLine(QVector<double> xs, QVector<double> dataValues, QString Name);
void updateCursor(QMouseEvent* event);
public slots:
void xAxisRangeChanged(QCPRange);
void yAxisRangeChanged(QCPRange);
void on_SwichTracerGraph_Name();
void load_new_compare_line();
signals:
bool windowsClose();
protected:
void closeEvent(QCloseEvent* event) override;
};
//===========================
// 构建数据展示窗口
// 1. 单纯的描述游标,主要用来展示坐标,还有当前数据信息
// 2. 区域性描述游标,通过线,等用来展示某一个区域的信息
//===========================
class ImageShowDialogClass : public QDialog
{
Q_OBJECT
private:
LAMPDATASHOWCLASS graphclass;
public:
QMenuBar* menubar;
QStatusBar* statusbar;
ImageShowCursorDesClass* desCursor; // 描述游标
ImageShowCursorLineClass* HlineCursor;// H 游标
ImageShowCursorLineClass* VlineCursor;// V 游标
bool desCursorflag;
bool HlineCursorflag;
bool VlineCursorflag;
QCustomPlot* m_plot;
QCPItemTracer* tracer; //游标
public:
QMap<QString, QCPAbstractPlottable*> m_graphMap;
public:
ImageShowDialogClass(QWidget *parent = nullptr);
~ImageShowDialogClass();
public:
void load_double_MatrixX_data(Eigen::MatrixXd data, QString name);
void load_double_MatrixX_data(Eigen::MatrixXd X,Eigen::MatrixXd Y,Eigen::MatrixXd data, QString name);
void remove_Data( QString name);
LAMPDATASHOWCLASS getGraphClass(size_t i = 0);
size_t getGraphCount();
private:
Ui::ImageShowDialogClass ui;
public slots:
void updateCursor(QMouseEvent* event);
public slots: // cursor
void on_action_cursor_enable_trigged();
void on_action_descursor_close_trigged();
void on_action_Hlinecursor_close_trigged();
void on_action_VVlinecursor_close_trigged();
};
#endif

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ImageShowDialogClass</class>
<widget class="QDialog" name="ImageShowDialogClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>复数展示</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCustomPlot" name="m_plot" native="true"/>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QCustomPlot</class>
<extends>QWidget</extends>
<header location="global">qcustomplot.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,111 @@
#include "LAMPDataShowClass.h"
LAMPDataShowClass::LAMPDataShowClass(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
// 添加菜单项
QMenu* FileOpenMenu = this->ui.menuFile->addMenu(u8"打开");
QAction* action_openfile_tiff = FileOpenMenu->addAction(u8"tiff文件"); // 添加菜单项
QObject::connect(action_openfile_tiff, SIGNAL(triggered()), this, SLOT(on_action_openfile_tiff_triggered()));
QMenu* ComplexFileOpenMenu = this->ui.menuFile->addMenu(u8"打开复数数据");
QAction* action_openfile_tiff_complex = ComplexFileOpenMenu->addAction(u8"tiff文件"); // 添加菜单项
QObject::connect(action_openfile_tiff_complex, SIGNAL(triggered()), this, SLOT(on_action_openfile_tiff_complex_triggered()));
QAction* action_openfile_envi_complex = ComplexFileOpenMenu->addAction(u8"envi文件"); // 添加菜单项
QObject::connect(action_openfile_envi_complex, SIGNAL(triggered()), this, SLOT(on_action_openfile_envi_complex_triggered()));
this->setContextMenuPolicy(Qt::CustomContextMenu);
this->ui.listWidgetContent->setContextMenuPolicy(Qt::CustomContextMenu);
}
LAMPDataShowClass::~LAMPDataShowClass()
{}
void LAMPDataShowClass::add_DataTree(TaskNode* node) {
QListWidgetItem* itemtemp = new QListWidgetItem(this->ui.listWidgetContent);
itemtemp->setSizeHint(node->sizeHint());
this->ui.listWidgetContent->setItemWidget(itemtemp, node);
this->ui.listWidgetContent->addItem(itemtemp);
}
void ShowComplexMatrixPlot(QCustomPlot* customPlot, const Eigen::MatrixXcd& complexMatrix) {
int nx = complexMatrix.rows(); // 行数
int ny = complexMatrix.cols(); // 列数
// 创建 Color Map
QCPColorMap* colorMap = new QCPColorMap(customPlot->xAxis, customPlot->yAxis);
colorMap->data()->setSize(nx, ny); // 设置 Color Map 的大小
colorMap->data()->setRange(QCPRange(0, nx), QCPRange(0, ny)); // 设置坐标轴的范围
// 填充数据
for (int xIndex = 0; xIndex < nx; ++xIndex) {
for (int yIndex = 0; yIndex < ny; ++yIndex) {
double magnitude = std::abs(complexMatrix(xIndex, yIndex)); // 或者使用 std::arg() 获取相位
colorMap->data()->setCell(xIndex, yIndex, magnitude);
}
}
colorMap->setGradient(QCPColorGradient::gpJet);
colorMap->rescaleDataRange(true);
customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
customPlot->rescaleAxes();
customPlot->replot();
}
void LAMPDataShowClass::on_action_openfile_tiff_triggered()
{
}
void LAMPDataShowClass::on_action_openfile_envi_triggered() {
}
void LAMPDataShowClass::on_action_openfile_tiff_complex_triggered()
{
ComplexDataShowNode* node = new ComplexDataShowNode();
node->bangdindWindows(this);
node->TaskXmlPath = getOpenFilePath(nullptr, u8"打开复数数据", u8" tiff文件(*.tiff ,*.tif)");
if (!isExists(node->TaskXmlPath)) {
return;
}
else {}
node->OpenData(node->TaskXmlPath);
this->add_DataTree(node);
node->ExcuteTask();
}
void LAMPDataShowClass::on_action_openfile_envi_complex_triggered()
{
ComplexDataShowNode* node = new ComplexDataShowNode();
node->bangdindWindows(this);
node->TaskXmlPath = getOpenFilePath(nullptr, u8"打开复数数据", u8"envi文件(*.dat ) ");
if (!isExists(node->TaskXmlPath)) {
return;
}
else {}
node->OpenData(node->TaskXmlPath);
this->add_DataTree(node);
node->ExcuteTask();
}
void LAMPDataShowClass::load_complex_data(QString path)
{
ComplexDataShowNode* node = new ComplexDataShowNode();
node->bangdindWindows(this);
node->TaskXmlPath = path;
if (!isExists(node->TaskXmlPath)) {
return;
}
else {}
node->OpenData(node->TaskXmlPath);
this->add_DataTree(node);
node->ExcuteTask();
}

View File

@ -0,0 +1,50 @@
#pragma once
#ifndef LAMPDATASHOWClASS_H
#define LAMPDATASHOWClASS_H
#include "AllHead.h"
#include <QMainWindow>
#include "ui_LAMPDataShowClass.h"
#include "TaskXml/TaskTreeClass.h"
#include "TaskNodeList.h"
#include "ImageShowDialogClass.h"
class LAMPDataShowClass : public QMainWindow
{
Q_OBJECT
public:
LAMPDataShowClass(QWidget *parent = nullptr);
~LAMPDataShowClass();
public:
QList<QDialog*> Dialog;
public slots: // ²Ëµ¥action ²Ûº¯Êý
void add_DataTree(TaskNode* node);
void on_action_openfile_tiff_triggered();
void on_action_openfile_envi_triggered();
void on_action_openfile_tiff_complex_triggered();
void on_action_openfile_envi_complex_triggered();
public:
void load_complex_data(QString path);
private:
Ui::LAMPDataShowClassClass ui;
};
///////////////////////////////////////////////////////
// »ù´¡º¯Êý
///////////////////////////////////////////////////////
void ShowComplexMatrixPlot(QCustomPlot* customPlot, const Eigen::MatrixXcd& complexMatrix);
#endif

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LAMPDataShowClassClass</class>
<widget class="QMainWindow" name="LAMPDataShowClassClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>285</width>
<height>426</height>
</rect>
</property>
<property name="windowTitle">
<string>数据展示窗口</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListWidget" name="listWidgetContent"/>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar_windows">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>285</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>文件</string>
</property>
</widget>
<addaction name="menuFile"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionOpen">
<property name="text">
<string>Open</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,196 @@
#include "LAMPImageCreateClass.h"
LAMPImageCreateClass::LAMPImageCreateClass(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
this->simulationparams = std::make_shared<FEKOBase::FEKOSimulationDataparams>();
this->ui.comboBox_ImageMode->addItem(FEKOBase::FEKOImageModeenumToString(FEKOBase::FEKOImageMode::Strip));
this->ui.comboBox_ImageMode->addItem(FEKOBase::FEKOImageModeenumToString(FEKOBase::FEKOImageMode::Scane));
this->ui.comboBox_ImageMode->addItem(FEKOBase::FEKOImageModeenumToString(FEKOBase::FEKOImageMode::ISAR));
this->ui.comboBox_ImageMode->addItem(FEKOBase::FEKOImageModeenumToString(FEKOBase::FEKOImageMode::CircleSAR));
// 限制lineedit输入为数值
QDoubleValidator* doubleValidator = new QDoubleValidator();
this->ui.lineEdit_minX->setValidator(doubleValidator);
this->ui.lineEdit__maxX->setValidator(doubleValidator);
this->ui.lineEdit__minY->setValidator(doubleValidator);
this->ui.lineEdit__maxY->setValidator(doubleValidator);
this->ui.lineEdit_planeZ->setValidator(doubleValidator);
QIntValidator* intValidator = new QIntValidator(1,100000000000000);
this->ui.lineEdit_height->setValidator(intValidator);
this->ui.lineEdit_width->setValidator(intValidator);
this->ui.lineEdit_minX->setText("-1.0");
this->ui.lineEdit__maxX->setText("1.0");
this->ui.lineEdit__minY->setText("-1.0");
this->ui.lineEdit__maxY->setText("1.0");
this->ui.lineEdit_planeZ->setText("0");
this->ui.lineEdit_height->setText("101");
this->ui.lineEdit_width->setText("101");
this->ui.checkBoxTheta->setChecked(true);
this->ui.checkBox_phi->setChecked(true);
}
LAMPImageCreateClass::~LAMPImageCreateClass()
{}
Q_INVOKABLE FEKOBase::FEKOImageSettingParams LAMPImageCreateClass::getFEKOImageSettingParams()
{
FEKOBase::FEKOImageSettingParams result;
result.min_x = this->ui.lineEdit_minX->text().toDouble();
result.max_x = this->ui.lineEdit__maxX->text().toDouble();
result.min_y = this->ui.lineEdit__minY->text().toDouble();
result.max_y = this->ui.lineEdit__maxY->text().toDouble();
result.plane_z = this->ui.lineEdit_planeZ->text().toDouble();
result.ImageHeight = this->ui.lineEdit_height->text().toDouble();
result.ImageWidth = this->ui.lineEdit_width->text().toDouble();
return Q_INVOKABLE result;
}
void LAMPImageCreateClass::on_pushButton_theta_clicked()
{
QString thetaechopath = getOpenFilePath(this, u8"打开theta回波文件", u8"theta Files (*.theta)");
this->ui.lineEdit_thetaechopath->setText(thetaechopath);
}
void LAMPImageCreateClass::on_pushButton_phi_clicked()
{
QString phiechopath = getOpenFilePath(this, u8"打开phi回波文件", u8"theta Files (*.phi)");
this->ui.lineEdit_phiechopath->setText(phiechopath);
}
void LAMPImageCreateClass::on_pushButton_thetaimage_clicked()
{
QString thetaimagePath = getSaveFilePath(this, u8"保存theta极化回波成像结果", u8"ENVI (*.dat)");
this->ui.lineEdit_thetaimagepath->setText(thetaimagePath);
}
void LAMPImageCreateClass::on_pushButton_phiImage_clicked()
{
QString phiimagePath = getSaveFilePath(this, u8"保存theta极化回波成像结果", u8"ENVI (*.dat)");
this->ui.lineEdit_phiimagepath->setText(phiimagePath);
}
void LAMPImageCreateClass::on_checkBoxTheta_toggled(bool flag)
{
this->ui.pushButton_theta->setEnabled(this->ui.checkBoxTheta->isChecked());
this->ui.pushButton_thetaimage->setEnabled(this->ui.checkBoxTheta->isChecked());
this->ui.lineEdit_thetaechopath->setEnabled(this->ui.checkBoxTheta->isChecked());
this->ui.lineEdit_thetaimagepath->setEnabled(this->ui.checkBoxTheta->isChecked());
}
void LAMPImageCreateClass::on_checkBox_phi_toggled(bool flag)
{
this->ui.pushButton_phi->setEnabled(this->ui.checkBox_phi->isChecked());
this->ui.pushButton_phiImage->setEnabled(this->ui.checkBox_phi->isChecked());
this->ui.lineEdit_phiechopath->setEnabled(this->ui.checkBox_phi->isChecked());
this->ui.lineEdit_phiimagepath->setEnabled(this->ui.checkBox_phi->isChecked());
}
void LAMPImageCreateClass::on_pushButton_OK_clicked()
{
FEKOBase::FEKOImageSettingParams imageparams = this->getFEKOImageSettingParams();
// 计算回波
if (this->ui.checkBoxTheta->isChecked()) { // theta
QString thetafileptah= this->ui.lineEdit_thetaechopath->text().trimmed();
QString theta_tiff_filepath=this->ui.lineEdit_thetaimagepath->text().trimmed();
FEKOBase::EchoDataClass data;
data.loadEchoData(thetafileptah);
if (this->simulationparams&&(this->simulationparams->imagemode==FEKOBase::FEKOImageMode::Strip|| this->simulationparams->imagemode == FEKOBase::FEKOImageMode::Scane)) {
FEKOBase::FEKOImageProcess(data, imageparams, theta_tiff_filepath,FEKOBase::FEKOImageAlgorithm::TBP_FREQ,FEKOBase::ImageAlgWindowFun::HANMMING);
}
else {
FEKOBase::FEKOImageProcess(data, imageparams, theta_tiff_filepath);
}
}
else {
}
if (this->ui.checkBox_phi->isChecked()) { // phi
QString phifileptah = this->ui.lineEdit_phiechopath->text().trimmed();
QString phi_tiff_filepath = this->ui.lineEdit_phiimagepath->text().trimmed();
FEKOBase::EchoDataClass data;
data.loadEchoData(phifileptah);
//FEKOBase::FEKOImageProcess(data, imageparams, phi_tiff_filepath);
if (this->simulationparams && (this->simulationparams->imagemode == FEKOBase::FEKOImageMode::Strip || this->simulationparams->imagemode == FEKOBase::FEKOImageMode::Scane)) {
FEKOBase::FEKOImageProcess(data, imageparams, phi_tiff_filepath, FEKOBase::FEKOImageAlgorithm::TBP_FREQ, FEKOBase::ImageAlgWindowFun::HANMMING);
}
else {
FEKOBase::FEKOImageProcess(data, imageparams, phi_tiff_filepath);
}
}
else {
}
QMessageBox::StandardButton reply = QMessageBox::question(this, u8"提示", u8"是否查看图像", QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) {
LAMPDataShowClass* datashow=new LAMPDataShowClass();
datashow->show();
if (this->ui.checkBoxTheta->isChecked()) { // theta
QString theta_tiff_filepath = this->ui.lineEdit_thetaimagepath->text().trimmed();
datashow->load_complex_data(theta_tiff_filepath);
}
if (this->ui.checkBox_phi->isChecked()) { // phi
QString phi_tiff_filepath = this->ui.lineEdit_phiimagepath->text().trimmed();
datashow->load_complex_data(phi_tiff_filepath);
}
}
else {
return;
}
}
void LAMPImageCreateClass::on_pushButton_cancel_clicked()
{
this->close();
}
void LAMPImageCreateClass::on_pushButton_loadfekosimulationxml_clicked()
{
QString xmlpath = getOpenFilePath(this, u8"仿真任务xml", u8"xml文件 (*.xml)");
if (isExists(xmlpath)) {
this->OpenFEKOSimulationImageSettingXml(xmlpath);
}
else {
}
}
void LAMPImageCreateClass::OpenFEKOSimulationImageSettingXml(QString& xmlpath)
{
this->simulationparams->loadXml(xmlpath);
this->ui.lineEdit_TaskName->setText(this->simulationparams->taskName);
this->ui.comboBox_ImageMode->setCurrentText(FEKOBase::FEKOImageModeenumToString(this->simulationparams->imagemode));
this->ui.lineEdit_minX->setText(QString::number(this->simulationparams->x_min));
this->ui.lineEdit__maxX->setText(QString::number(this->simulationparams->x_max));
this->ui.lineEdit__minY->setText(QString::number(this->simulationparams->y_min));
this->ui.lineEdit__maxY->setText(QString::number(this->simulationparams->y_max));
this->ui.lineEdit_planeZ->setText(QString::number(this->simulationparams->z_plane));
this->ui.lineEdit_height->setText(QString::number(this->simulationparams->imageheight));
this->ui.lineEdit_width->setText(QString::number(this->simulationparams->imagewidth));
}
void LAMPImageCreateClass::bandingsetFEKOSimulationDataparams()
{
}

View File

@ -0,0 +1,48 @@
#pragma once
#ifndef LAMPIMAGECREATECLASS_H
#define LAMPIMAGECREATECLASS_H
#include "AllHead.h"
#include <QDialog>
#include "ui_LAMPImageCreateClass.h"
#include "LAMPDataShowClass.h"
class LAMPImageCreateClass : public QDialog,public FEKOBase::FEKOSimulationDataparamsHandler
{
Q_OBJECT
public:
Q_INVOKABLE LAMPImageCreateClass(QWidget *parent = nullptr);
~LAMPImageCreateClass();
private:
Ui::LAMPImageCreateClassClass ui;
public:
Q_INVOKABLE FEKOBase::FEKOImageSettingParams getFEKOImageSettingParams();
public slots:
void on_pushButton_theta_clicked();
void on_pushButton_phi_clicked();
void on_pushButton_thetaimage_clicked();
void on_pushButton_phiImage_clicked();
void on_checkBoxTheta_toggled(bool flag);
void on_checkBox_phi_toggled(bool flag);
void on_pushButton_OK_clicked();
void on_pushButton_cancel_clicked();
void on_pushButton_loadfekosimulationxml_clicked();
public:
QString workspace;
QString xmlpath;
public:
void OpenFEKOSimulationImageSettingXml(QString& xmlpath);
void bandingsetFEKOSimulationDataparams() override;
};
#endif

View File

@ -0,0 +1,657 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LAMPImageCreateClassClass</class>
<widget class="QDialog" name="LAMPImageCreateClassClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>712</width>
<height>615</height>
</rect>
</property>
<property name="windowTitle">
<string>LAMPImageCreateClass</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>成像模式</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_ImageMode">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>任务名称</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_TaskName">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
<property name="title">
<string>成像极化选择</string>
</property>
<widget class="QCheckBox" name="checkBoxTheta">
<property name="geometry">
<rect>
<x>40</x>
<y>30</y>
<width>91</width>
<height>19</height>
</rect>
</property>
<property name="text">
<string>theta极化</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_phi">
<property name="geometry">
<rect>
<x>190</x>
<y>30</y>
<width>91</width>
<height>19</height>
</rect>
</property>
<property name="text">
<string>phi极化</string>
</property>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>theta回波文件</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_thetaechopath">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_theta">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>打开</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_5">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>phi回波文件</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_phiechopath">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_phi">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>打开</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_6">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>theta成像结果</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_thetaimagepath">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_thetaimage">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>打开</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_7">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>phi成像结果</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_phiimagepath">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_phiImage">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>打开</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>成像几何设置</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>X范围</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>Y范围</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_9">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>成像平面高程Z</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_10">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>最小值</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_11">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>最大值</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_minX">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="lineEdit__maxX">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit__minY">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="lineEdit__maxY">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QLineEdit" name="lineEdit_planeZ">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>图像设置</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>图像高像素Y</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_height"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>图像宽像素X)</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_width"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<property name="title">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_loadfekosimulationxml">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>加载仿真成像参数</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_OK">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_cancel">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,124 @@
#pragma once
#ifndef LAMP_SCATTERSETTINGCLASS_H
#define LAMP_SCATTERSETTINGCLASS_H
#include "AllHead.h"
#include <QDialog>
#include "ui_LAMP_ScatterSettingClass.h"
class LAMP_ScatterSettingXmlClass {
public:
QString taskName;
double startfre;
double endfre;
double freponts;
bool farfield;
bool nearfield;
bool A1;
double incidence_A1;
bool A2;
double incidence_A2;
bool enableScatter;
bool S1;
bool S3;
bool S5;
bool S8;
bool S10;
bool S12;
bool F1;
bool F2;
bool F3;
bool F4;
bool F5;
bool F6;
bool F7;
bool F8;
bool F9;
bool F10;
bool F11;
bool F12;
public:
LAMP_ScatterSettingXmlClass();
~LAMP_ScatterSettingXmlClass();
void loadxml(QString xmlpath);
void savexml(QString xmlpath);
};
class LAMP_ScatterSettingClass : public QDialog
{
Q_OBJECT
public:
LAMP_ScatterSettingClass(QWidget *parent = nullptr);
~LAMP_ScatterSettingClass();
public:
Handle(AIS_InteractiveContext) myContext; // 窗口交互 // 模型管理
QString xmlpath;
QString workpsace;
LAMP_ScatterSettingXmlClass* settingobj;
//QMap<QString, Handle(AIS_InteractiveObject)> DataAISMap;
std::map<std::string, Handle(AIS_InteractiveObject)> DataAISMap; // 构建雷达照射模型
std::map<std::string, SphericalCoordinates> AntSettingdict; // 构建雷达照射模型
std::map<std::string, QString> AntffePathDict;
public:
void loadxml(QString xmlpath);
void savexml();
void renderSettingObj();
void sycnSettingObj();
void createAntModel();
void initAntModelSettingParams(); // 模型设置参数
void closeWindows();
void setDocument3d(Handle(AIS_InteractiveContext) myContext);
void createFEKOLua();
void setTaskName(QString name);
void setWorkSpacePath(QString path);
public slots:
void on_radioButton_S1_toggled(bool flag);
void on_radioButton_S3_toggled(bool flag);
void on_radioButton_S5_toggled(bool flag);
void on_radioButton_S8_toggled(bool flag);
void on_radioButton_S10_toggled(bool flag);
void on_radioButton_S12_toggled(bool flag);
void on_radioButton_F1_toggled(bool flag);
void on_radioButton_F2_toggled(bool flag);
void on_radioButton_F3_toggled(bool flag);
void on_radioButton_F4_toggled(bool flag);
void on_radioButton_F5_toggled(bool flag);
void on_radioButton_F6_toggled(bool flag);
void on_radioButton_F7_toggled(bool flag);
void on_radioButton_F8_toggled(bool flag);
void on_radioButton_F9_toggled(bool flag);
void on_radioButton_F10_toggled(bool flag);
void on_radioButton_F11_toggled(bool flag);
void on_radioButton_F12_toggled(bool flag);
void on_checkBox_A1_toggled(bool flag);
void on_checkBox_A2_toggled(bool flag);
void on_checkBox_AllScatter_toggled(bool flag);
void on_lineEdit_A1_incAngle_editingFinished();
void on_lineEdit_A2_incAngle_editingFinished();
void on_pushButton_load_clicked();
void on_pushButton_apply_clicked();
void on_okButton_clicked();
void on_cancelButton_clicked();
void switchAntShowAndHide(std::string antName,bool isShow);
private:
SphericalCoordinates antsettingstring2Spherical(QString sphericalStr);
private:
Ui::LAMP_ScatterSettingClassClass ui;
};
#endif

View File

@ -0,0 +1,585 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LAMP_ScatterSettingClassClass</class>
<widget class="QDialog" name="LAMP_ScatterSettingClassClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>692</width>
<height>581</height>
</rect>
</property>
<property name="windowTitle">
<string>LAMP_ScatterSettingClass</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>任务名</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_TaskPath">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>任务地址:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_TaskName">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_xmlpath">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>这里假设波的方位向垂直90度</string>
</property>
<property name="title">
<string>雷达馈源设置</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="2">
<widget class="QLineEdit" name="lineEdit_endfreq">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>7</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>频率间隔MHz)</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLineEdit" name="lineEdit_freqdelta">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QGroupBox" name="groupBox_3">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<property name="title">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="checkBox_A1">
<property name="text">
<string>A1</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_A2">
<property name="text">
<string>A2</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>A2入射角(度)</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>A1入射角(度)</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>发射天线</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QLineEdit" name="lineEdit_A1_incAngle">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item row="10" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>120</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>120</height>
</size>
</property>
<property name="title">
<string>全散射装置天线</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="3" column="0">
<widget class="QRadioButton" name="radioButton_F7">
<property name="text">
<string>F7</string>
</property>
</widget>
</item>
<item row="3" column="5">
<widget class="QRadioButton" name="radioButton_F12">
<property name="text">
<string>F12</string>
</property>
</widget>
</item>
<item row="2" column="5">
<widget class="QRadioButton" name="radioButton_F6">
<property name="text">
<string>F6</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radioButton_S1">
<property name="text">
<string>S1</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox_AllScatter">
<property name="text">
<string>启动散射天线</string>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QRadioButton" name="radioButton_F11">
<property name="text">
<string>F11</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QRadioButton" name="radioButton_S8">
<property name="text">
<string>S8</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QRadioButton" name="radioButton_S10">
<property name="text">
<string>S10</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QRadioButton" name="radioButton_S5">
<property name="text">
<string>S5</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QRadioButton" name="radioButton_F4">
<property name="text">
<string>F4</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="radioButton_S3">
<property name="text">
<string>S3</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QRadioButton" name="radioButton_S12">
<property name="text">
<string>S12</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QRadioButton" name="radioButton_F5">
<property name="text">
<string>F5</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QRadioButton" name="radioButton_F9">
<property name="text">
<string>F9</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QRadioButton" name="radioButton_F3">
<property name="text">
<string>F3</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QRadioButton" name="radioButton_F8">
<property name="text">
<string>F8</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="radioButton_F1">
<property name="text">
<string>F1</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QRadioButton" name="radioButton_F2">
<property name="text">
<string>F2</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QRadioButton" name="radioButton_F10">
<property name="text">
<string>F10</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="lineEdit_startFreq">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>5</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="lineEdit_freqPoints">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>终止频率GHZ)</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>起始频率GHZ):</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>频率点数</string>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="QLineEdit" name="lineEdit_A2_incAngle">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>仿真方式</string>
</property>
</widget>
</item>
<item row="5" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="radioButton_farfield">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>远场</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_nearfield">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>近场</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<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>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>131</width>
<height>31</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_load">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>加载</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_apply">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>应用</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="okButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>退出</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,6 @@
#include "AllHead.h"
#include "OCCTBaseOperaorClass.h"

View File

@ -0,0 +1,19 @@
#pragma once
#ifndef OCCTBASEOPERAORCLASS_H
#define OCCTBASEOPERAORCLASS_H
#include <QFileDialog>
#include <qDebug>
#include "OCCViewer/CommonSample.h"
#include "allHead.h"
#endif

View File

@ -0,0 +1,465 @@
#include "OCCTModelOperator.h"
#include <BRepBuilderAPI_Transform.hxx>
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
OCCTModelOperator::OCCTModelOperator(QString TopoName,QWidget *parent, Handle(AIS_InteractiveContext) myContext)
: QDialog(parent)
{
ui.setupUi(this);
setWindowFlags(Qt::Window);
setWindowTitle(TopoName);
// 参数初设
this->ui.radioButton_NoCopy->setChecked(true);
this->ui.radioButton_Time->setChecked(true);
this->myContext = myContext;
this->ModelName = TopoName;
// 处理平移
QDoubleValidator* validator = new QDoubleValidator(); // 限制参数
ui.lineEdit_Move_From_X->setValidator(validator);
ui.lineEdit_Move_From_Z->setValidator(validator);
ui.lineEdit_Move_From_Y->setValidator(validator);
ui.lineEdit_Move_To_X->setValidator(validator);
ui.lineEdit_Move_To_Y->setValidator(validator);
ui.lineEdit_Move_To_Z->setValidator(validator);
ui.lineEdit_Rotation_Center_X->setValidator(validator);
ui.lineEdit_Rotation_Center_Y->setValidator(validator);
ui.lineEdit_Rotation_Center_Z->setValidator(validator);
ui.lineEdit_Rotation_Axis_X->setValidator(validator);
ui.lineEdit_Rotation_Axis_Y->setValidator(validator);
ui.lineEdit_Rotation_Axis_Z->setValidator(validator);
ui.lineEdit_Scale_refrence_point_X->setValidator(validator);
ui.lineEdit_Scale_refrence_point_Y->setValidator(validator);
ui.lineEdit_Scale_refrence_point_Z->setValidator(validator);
QDoubleValidator* validatorScale = new QDoubleValidator();
validatorScale->setBottom(0.0);
ui.lineEdit_ScaleValue->setValidator(validatorScale);
// 初始化
ui.lineEdit_Move_From_X->setText(u8"0.0");
ui.lineEdit_Move_From_Z->setText(u8"0.0");
ui.lineEdit_Move_From_Y->setText(u8"0.0");
ui.lineEdit_Move_To_X->setText(u8"0.0");
ui.lineEdit_Move_To_Y->setText(u8"0.0");
ui.lineEdit_Move_To_Z->setText(u8"0.0");
ui.lineEdit_Rotation_Center_X->setText(u8"0.0");
ui.lineEdit_Rotation_Center_Y->setText(u8"0.0");
ui.lineEdit_Rotation_Center_Z->setText(u8"0.0");
ui.lineEdit_Rotation_Axis_X->setText(u8"0.0");
ui.lineEdit_Rotation_Axis_Y->setText(u8"0.0");
ui.lineEdit_Rotation_Axis_Z->setText(u8"0.0");
ui.lineEdit_ScaleValue->setText(u8"1.0");
ui.lineEdit_Scale_refrence_point_X->setText(u8"0.0");
ui.lineEdit_Scale_refrence_point_Y->setText(u8"0.0");
ui.lineEdit_Scale_refrence_point_Z->setText(u8"0.0");
// 缩放中心参数化
ui.radioButton_Auto->setChecked(true);
// 参数初始化
this->UpdataVariable();
// 事件绑定
if (TopoName.isEmpty()) {
this->ui.radioButton_Copy->setChecked(true);
this->ui.radioButton_NoCopy->setEnabled(false);
}
}
OCCTModelOperator::~OCCTModelOperator()
{}
void OCCTModelOperator::setTopoDs_Shape(TopoDS_Shape ds)
{
// 创建一个复制模型
BRepBuilderAPI_Copy copyBuilder;
copyBuilder.Perform(ds);
this->Datashape = copyBuilder.Shape();
// 创建一个复制模型
BRepBuilderAPI_Copy copyBuilder2;
copyBuilder2.Perform(ds);
this->DataShapeBAK = copyBuilder2.Shape();
this->Data_AIS = new AIS_Shape(this->Datashape); // 计算
this->UpdateScaleRefrencepoint();
this->UpdataVariable();
}
TopoDS_Shape OCCTModelOperator::getTopoDs_Shape()
{
return this->Datashape;
}
TopoDS_Shape OCCTModelOperator::getTopoDs_ShapeBAK()
{
return this->DataShapeBAK;
}
void OCCTModelOperator::toString()
{
qDebug() << u8"move ";
qDebug() <<QString("X: %1 --> %1").arg(Move_From_X, 0, 'e', 8).arg(Move_To_X, 0, 'e', 8);
qDebug() <<QString("Y: %1 --> %1").arg(Move_From_Y, 0, 'e', 8).arg(Move_To_Y, 0, 'e', 8);
qDebug() <<QString("Z: %1 --> %1").arg(Move_From_Z, 0, 'e', 8).arg(Move_To_Z, 0, 'e', 8);
qDebug() << u8"Rotatino Center Point ";
qDebug() <<QString("X: %1").arg(Rotation_Center_X);
qDebug() <<QString("Y: %1").arg(Rotation_Center_Y);
qDebug() <<QString("Z: %1").arg(Rotation_Center_Z);
qDebug() << u8"Rotatino Axis Angle ";
qDebug() <<QString("%1").arg(Rotation_angle_X); // 绕X轴旋转角度
qDebug() <<QString("%1").arg(Rotation_angle_Y);
qDebug() <<QString("%1").arg(Rotation_angle_Z);
qDebug() << u8"Scale ";
qDebug() <<QString("%1").arg(ScaleDouble);
qDebug() <<QString("X%1").arg(this->ScaleRefrencePoint_X);
qDebug() <<QString("Y%1").arg(this->ScaleRefrencePoint_Y);
qDebug() <<QString("Z%1").arg(this->ScaleRefrencePoint_Z);
}
Handle(AIS_InteractiveObject) OCCTModelOperator::getAIS()
{
return new AIS_Shape(this->Datashape);
}
Handle(AIS_InteractiveObject) OCCTModelOperator::getAISBAK()
{
return new AIS_Shape(this->DataShapeBAK);
}
void OCCTModelOperator::ExcuteOperator()
{
this->ProcesssModel();
if (this->ui.radioButton_Copy->isChecked()) { // 复制模型
emit this->ResultExportCopyAndCreateNew(this);
}
else {
emit this->ResultExport(this);
}
}
void OCCTModelOperator::UpdataVariable()
{
this->Move_From_X = this->ui.lineEdit_Move_From_X->text().toDouble();
this->Move_From_Z = this->ui.lineEdit_Move_From_Z->text().toDouble();
this->Move_From_Y = this->ui.lineEdit_Move_From_Y->text().toDouble();
this->Move_To_X = this->ui.lineEdit_Move_To_X->text().toDouble();
this->Move_To_Y = this->ui.lineEdit_Move_To_Y->text().toDouble();
this->Move_To_Z = this->ui.lineEdit_Move_To_Z->text().toDouble();
this->Rotation_Center_X = this->ui.lineEdit_Rotation_Center_X->text().toDouble();
this->Rotation_Center_Y = this->ui.lineEdit_Rotation_Center_Y->text().toDouble();
this->Rotation_Center_Z = this->ui.lineEdit_Rotation_Center_Z->text().toDouble();
this->Rotation_angle_X = this->ui.lineEdit_Rotation_Axis_X->text().toDouble();
this->Rotation_angle_Y = this->ui.lineEdit_Rotation_Axis_Y->text().toDouble();
this->ScaleDouble = this->ui.lineEdit_ScaleValue->text().toDouble();
this->ScaleRefrencePoint_X=this->ui.lineEdit_Scale_refrence_point_X->text().toDouble();
this->ScaleRefrencePoint_Y=this->ui.lineEdit_Scale_refrence_point_Y->text().toDouble();
this->ScaleRefrencePoint_Z=this->ui.lineEdit_Scale_refrence_point_Z->text().toDouble();
}
void OCCTModelOperator::UpdateScaleRefrencepoint()
{
if (this->ui.radioButton_Auto->isChecked()) {
// 假设你有一个 TopoDS_Shape 对象,例如一个立方体
TopoDS_Shape myShape = this->DataShapeBAK; // 你需要将其替换为实际的形状对象
GProp_GProps volumeProperties;
// 计算几何特性
BRepGProp::VolumeProperties(myShape, volumeProperties, Standard_False, Standard_False, Standard_False);
//// 获取质心
gp_Pnt centerOfMass = volumeProperties.CentreOfMass();
this->ui.lineEdit_Scale_refrence_point_X->setText(QString("%1").arg(centerOfMass.X(), 0, 'e', 8));
this->ui.lineEdit_Scale_refrence_point_Y->setText(QString("%1").arg(centerOfMass.Y(), 0, 'e', 8));
this->ui.lineEdit_Scale_refrence_point_Z->setText(QString("%1").arg(centerOfMass.Z(), 0, 'e', 8));
}
}
void OCCTModelOperator::PreViewOperator()
{
this->UpdataVariable();
this->toString();
if (this->ui.radioButton_Time->isChecked()) {
this->ProcesssModel();
}
}
void OCCTModelOperator::ApplyModel()
{
if (this->myContext) {
qDebug() << u8"模型移除";
//this->myContext->Erase(this->Data_AIS, Standard_True);
this->myContext->Remove(this->Data_AIS, Standard_False);
this->myContext->UpdateCurrentViewer();
this->Datashape.Nullify();
//this->Data_AIS->Delete();
//this->myContext->Remove(this->Datashape, Standard_True);
}
// 平移模型
double move_x = this->Move_To_X - this->Move_From_X;
double move_y = this->Move_To_Y - this->Move_From_Y;
double move_z = this->Move_To_Z - this->Move_From_Z;
// 进行平移
gp_Trsf translation;
translation.SetTranslation(gp_Vec(move_x, move_y, move_z));
BRepBuilderAPI_Transform translateTransform(this->DataShapeBAK, translation);
TopoDS_Shape translatedShape = translateTransform.Shape();
double Rotation_centor_x = this->Rotation_Center_X;
double Rotation_centor_y = this->Rotation_Center_Y;
double Rotation_centor_z = this->Rotation_Center_Z;
// 确定旋转中心
gp_Pnt rotationCenter(Rotation_centor_x, Rotation_centor_y, Rotation_centor_z); // 中心点坐标
// 计算旋转轴
gp_Ax1 rotationAxis_X(rotationCenter, gp_Dir(1.0, 0.0, 0.0));
gp_Ax1 rotationAxis_Y(rotationCenter, gp_Dir(0.0, 1.0, 0.0));
gp_Ax1 rotationAxis_Z(rotationCenter, gp_Dir(0.0, 0.0, 1.0));
double angle_x = this->Rotation_angle_X / 180.0 * M_PI;
double angle_y = this->Rotation_angle_Y / 180.0 * M_PI;
double angle_z = this->Rotation_angle_Z / 180.0 * M_PI;
// 进行旋转
gp_Trsf rotation_X;
rotation_X.SetRotation(rotationAxis_X, angle_x); // X
BRepBuilderAPI_Transform rotateTransform_X(translatedShape, rotation_X);
TopoDS_Shape rotatedShape_X = rotateTransform_X.Shape();
// 进行旋转
gp_Trsf rotation_Y;
rotation_Y.SetRotation(rotationAxis_Y, angle_y); // Y
BRepBuilderAPI_Transform rotateTransform_Y(rotatedShape_X, rotation_Y);
TopoDS_Shape rotatedShape_Y = rotateTransform_Y.Shape();
// 进行旋转
gp_Trsf rotation_Z;
rotation_Z.SetRotation(rotationAxis_Z, angle_z); // Z
BRepBuilderAPI_Transform rotateTransform_Z(rotatedShape_Y, rotation_Z);
TopoDS_Shape rotatedShape = rotateTransform_Z.Shape();
// 创建一个 BRepBuilderAPI_Transform 对象来进行缩放
gp_Pnt refrenceCenter(ScaleRefrencePoint_X, ScaleRefrencePoint_Y, ScaleRefrencePoint_Z); // 中心点坐标
gp_Trsf scaleTransform;
scaleTransform.SetScale(refrenceCenter, ScaleDouble);
BRepBuilderAPI_Transform scaleTransformBuilder(rotatedShape, scaleTransform);
// 应用变换
if (scaleTransformBuilder.IsDone()) {
this->Datashape = scaleTransformBuilder.Shape();
}
else {
}
// 内存释放
translatedShape.Nullify();
rotatedShape_X.Nullify();
rotatedShape_Y.Nullify();
rotatedShape.Nullify();
if (this->myContext) {
qDebug() << u8"图像刷新";
this->Data_AIS.Nullify();
// 创建或获取对象的 AIS_Shape
Handle(AIS_Shape) aisShape = new AIS_Shape(this->Datashape);
// 创建一个颜色对象,例如红色
Quantity_Color redColor(1.0, 0.0, 0.0, Quantity_TOC_RGB); // RGB红色
ChangeModelColor(aisShape, redColor);
this->Data_AIS = aisShape;
this->myContext->Display(this->Data_AIS, Standard_True); // 立刻刷新
this->myContext->AddOrRemoveSelected(this->Data_AIS, Standard_True);
}
// 处理响应逻辑
emit this->RefreshResult(this);
}
void OCCTModelOperator::ProcesssModel()
{
this->ApplyModel();
}
void OCCTModelOperator::on_lineEdit_Move_From_X_returnPressed()
{
this->PreViewOperator();
}
void OCCTModelOperator::on_lineEdit_Move_From_Z_returnPressed()
{
this->PreViewOperator();
}
void OCCTModelOperator::on_lineEdit_Move_From_Y_returnPressed()
{
this->PreViewOperator();
}
void OCCTModelOperator::on_lineEdit_Move_To_X_returnPressed()
{
this->PreViewOperator();
}
void OCCTModelOperator::on_lineEdit_Move_To_Y_returnPressed()
{
this->PreViewOperator();
}
void OCCTModelOperator::on_lineEdit_Move_To_Z_returnPressed()
{
this->PreViewOperator();
}
void OCCTModelOperator::on_lineEdit_Rotation_Center_X_returnPressed()
{
this->PreViewOperator();
}
void OCCTModelOperator::on_lineEdit_Rotation_Center_Y_returnPressed()
{
this->PreViewOperator();
}
void OCCTModelOperator::on_lineEdit_Rotation_Center_Z_returnPressed()
{
this->PreViewOperator();
}
void OCCTModelOperator::on_lineEdit_Rotation_Axis_X_returnPressed()
{
this->PreViewOperator();
}
void OCCTModelOperator::on_lineEdit_Rotation_Axis_Y_returnPressed()
{
this->PreViewOperator();
}
void OCCTModelOperator::on_lineEdit_Rotation_Axis_Z_returnPressed()
{
this->PreViewOperator();
}
void OCCTModelOperator::on_lineEdit_Scale_returnPressed()
{
this->PreViewOperator();
}
void OCCTModelOperator::on_lineEdit_Scale_refrence_point_X_returnPressed()
{
this->PreViewOperator();
}
void OCCTModelOperator::on_lineEdit_Scale_refrence_point_Y_returnPressed()
{
this->PreViewOperator();
}
void OCCTModelOperator::on_lineEdit_Scale_refrence_point_Z_returnPressed()
{
this->PreViewOperator();
}
void OCCTModelOperator::on_lineEdit_ScaleValue_returnPressed()
{
this->PreViewOperator();
}
void OCCTModelOperator::on_radioButton_Auto_toggled(bool flag)
{
if (flag) {
this->ui.lineEdit_Scale_refrence_point_X->setEnabled(false);
this->ui.lineEdit_Scale_refrence_point_Y->setEnabled(false);
this->ui.lineEdit_Scale_refrence_point_Z->setEnabled(false);
this->UpdateScaleRefrencepoint();
}
}
void OCCTModelOperator::on_radioButton_NoAuto_toggled(bool flag)
{
if (flag) {
this->ui.lineEdit_Scale_refrence_point_X->setEnabled(true);
this->ui.lineEdit_Scale_refrence_point_Y->setEnabled(true);
this->ui.lineEdit_Scale_refrence_point_Z->setEnabled(true);
this->UpdateScaleRefrencepoint();
}
}
void OCCTModelOperator::on_pushButton_ok_clicked()
{
this->UpdataVariable();
this->ApplyModel();
if (this->myContext) {
qDebug() << u8"模型移除";
this->myContext->Remove(this->Data_AIS, Standard_False);
this->myContext->UpdateCurrentViewer();
}
// 创建一个复制模型
BRepBuilderAPI_Copy copyBuilder;
copyBuilder.Perform(this->Datashape);
this->DataShapeBAK = copyBuilder.Shape();
if (this->ui.radioButton_Copy->isChecked()) {
emit this->ResultExportCopyAndCreateNew(this);
}
else {
emit this->ResultExport(this);
}
this->close();
}
void OCCTModelOperator::on_pushButton_apply_clicked()
{
this->UpdataVariable();
this->ApplyModel();
if (this->myContext) {
qDebug() << u8"模型移除";
//this->myContext->Erase(this->Data_AIS, Standard_True);
this->myContext->Remove(this->Data_AIS, Standard_False);
this->myContext->UpdateCurrentViewer();
}
// 创建一个复制模型
BRepBuilderAPI_Copy copyBuilder;
copyBuilder.Perform(this->Datashape);
this->DataShapeBAK = copyBuilder.Shape();
if (this->ui.radioButton_Copy->isChecked()) {
emit this->ResultExportCopyAndCreateNew(this);
}
else {
emit this->ResultExport(this);
}
}
void OCCTModelOperator::on_pushButton_Cancel_clicked()
{
this->close();
}

View File

@ -0,0 +1,125 @@
#pragma once
///
/// 控制模型整体平移转换
/// 1. 平移方法
/// a. 矢量平移法
/// b. 重心设置
/// 2. 旋转方法
/// a. 重心转换方法,根据坐标系
/// b.
///
#ifndef OCCT_MODEL_OPERATOR_H
#define OCCT_MODEL_OPERATOR_H
#include "AllHead.h"
#include "ui_OCCTModelOperator.h"
#include "OCCTBaseOperaorClass.h"
class OCCTModelOperator : public QDialog
{
Q_OBJECT
public:
OCCTModelOperator(QString TopoName,QWidget *parent = nullptr, Handle(AIS_InteractiveContext) myContext = nullptr);
~OCCTModelOperator();
void setTopoDs_Shape(TopoDS_Shape ds);
TopoDS_Shape getTopoDs_Shape();
TopoDS_Shape getTopoDs_ShapeBAK();
Handle(AIS_InteractiveContext) myContext;
Handle(AIS_InteractiveObject) getAIS();
Handle(AIS_InteractiveObject) getAISBAK();
private:
Ui::OCCTModelOperatorClass ui;
public:
TopoDS_Shape Datashape; // 处理控制的模型
TopoDS_Shape DataShapeBAK;
Handle(AIS_InteractiveObject) Data_AIS; // 处理模型
QString ModelName;
double Move_From_X;
double Move_From_Y;
double Move_From_Z;
double Move_To_X;
double Move_To_Y;
double Move_To_Z;
double Rotation_Center_X;
double Rotation_Center_Y;
double Rotation_Center_Z;
double Rotation_angle_X; // 绕X轴旋转角度
double Rotation_angle_Y;
double Rotation_angle_Z;
double ScaleRefrencePoint_X;
double ScaleRefrencePoint_Y;
double ScaleRefrencePoint_Z;
double ScaleDouble;
signals: // 信号域
void ResultExportCopyAndCreateNew( OCCTModelOperator*); // 创建并复制模型
void ResultExport(OCCTModelOperator*); // 返回修改后的模型
void RefreshResult(OCCTModelOperator*); // 模型重新绘制
public slots:
void on_lineEdit_Move_From_X_returnPressed();
void on_lineEdit_Move_From_Z_returnPressed();
void on_lineEdit_Move_From_Y_returnPressed();
void on_lineEdit_Move_To_X_returnPressed();
void on_lineEdit_Move_To_Y_returnPressed();
void on_lineEdit_Move_To_Z_returnPressed();
void on_lineEdit_Rotation_Center_X_returnPressed();
void on_lineEdit_Rotation_Center_Y_returnPressed();
void on_lineEdit_Rotation_Center_Z_returnPressed();
void on_lineEdit_Rotation_Axis_X_returnPressed();
void on_lineEdit_Rotation_Axis_Y_returnPressed();
void on_lineEdit_Rotation_Axis_Z_returnPressed();
void on_lineEdit_Scale_returnPressed();
void on_lineEdit_Scale_refrence_point_X_returnPressed();
void on_lineEdit_Scale_refrence_point_Y_returnPressed();
void on_lineEdit_Scale_refrence_point_Z_returnPressed();
void on_lineEdit_ScaleValue_returnPressed();
void on_radioButton_Auto_toggled(bool flag);
void on_radioButton_NoAuto_toggled(bool flag);
// 按钮
void on_pushButton_ok_clicked();
void on_pushButton_apply_clicked();
void on_pushButton_Cancel_clicked();
//
void PreViewOperator(); // 预处理
void ApplyModel();
void ProcesssModel();
void ExcuteOperator(); // 执行替换操作
void UpdataVariable();
// 更新缩放参数
void UpdateScaleRefrencepoint();
void toString();
//
protected:
// 重写 closeEvent 函数来捕获关闭事件
void closeEvent(QCloseEvent* event) override {
// 在关闭事件发生时执行你想要的操作
qDebug() << u8"模型操作类 is closing!";
this->myContext->Remove(this->Data_AIS, Standard_False);
this->myContext->UpdateCurrentViewer();
this->Datashape.Nullify();
this->Data_AIS.Nullify();
// 调用父类的 closeEvent 函数,以确保正确处理窗口的关闭
QDialog::closeEvent(event);
};
};
#endif

View File

@ -0,0 +1,868 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OCCTModelOperatorClass</class>
<widget class="QDialog" name="OCCTModelOperatorClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>510</width>
<height>741</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>660</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>800</height>
</size>
</property>
<property name="windowTitle">
<string>模型操作控制台</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="title">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox_10">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>80</height>
</size>
</property>
<property name="title">
<string>模型生成结果</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="radioButton_NoCopy">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>不复制</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_Copy">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>复制</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_11">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>80</height>
</size>
</property>
<property name="title">
<string>处理实时性</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QRadioButton" name="radioButton_Time">
<property name="text">
<string>实时处理</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_NOTime">
<property name="text">
<string>非实时处理</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>150</height>
</size>
</property>
<property name="title">
<string>模型平移</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="1">
<widget class="QGroupBox" name="groupBox_8">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>200</height>
</size>
</property>
<property name="title">
<string>从</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>X</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>Y</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>Z</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="lineEdit_Move_From_X">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="lineEdit_Move_From_Z">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="lineEdit_Move_From_Y">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="2">
<widget class="QGroupBox" name="groupBox_9">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>200</height>
</size>
</property>
<property name="title">
<string>至</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>Z</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>Y</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>X</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_Move_To_X">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_Move_To_Y">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_Move_To_Z">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>150</height>
</size>
</property>
<property name="title">
<string>旋转</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>120</height>
</size>
</property>
<property name="title">
<string>旋转中心</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_Rotation_Center_X">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_Rotation_Center_Y">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="maximumSize">
<size>
<width>20</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>X</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_Rotation_Center_Z">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_10">
<property name="maximumSize">
<size>
<width>20</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>Z</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_9">
<property name="maximumSize">
<size>
<width>20</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>Y</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_7">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>120</height>
</size>
</property>
<property name="title">
<string>旋转矩阵</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_Rotation_Axis_X">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_12">
<property name="minimumSize">
<size>
<width>30</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>绕Y轴</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_Rotation_Axis_Y">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_Rotation_Axis_Z">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_11">
<property name="minimumSize">
<size>
<width>30</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>绕X轴</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_13">
<property name="minimumSize">
<size>
<width>30</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>绕Z轴</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>300</height>
</size>
</property>
<property name="title">
<string>模型缩放</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="2" column="0">
<widget class="QLabel" name="label_16">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>缩放因子</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_ScaleValue">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_12">
<property name="minimumSize">
<size>
<width>0</width>
<height>180</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>200</height>
</size>
</property>
<property name="title">
<string>参考中心</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="6" column="0">
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>Z</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_14">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>X</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_15">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>Y</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QRadioButton" name="radioButton_Auto">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>自动计算(模型重心)</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QRadioButton" name="radioButton_NoAuto">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>手动</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QLineEdit" name="lineEdit_Scale_refrence_point_X">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<widget class="QLineEdit" name="lineEdit_Scale_refrence_point_Y">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="6" column="1" colspan="2">
<widget class="QLineEdit" name="lineEdit_Scale_refrence_point_Z">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
<property name="title">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>308</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_ok">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_apply">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>预览</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_Cancel">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,43 @@
#include "OCCTopoShapeTreeViewer.h"
#include <qDebug>
#include "SharedModuleLib/BaseUiTool.h"
#include <BRep_Tool.hxx>
#include <TopoDS_Vertex.hxx>
OCCTopoShapeTreeViewer::OCCTopoShapeTreeViewer(QWidget* parent)
: QTreeWidget(parent)
{
// 构造函数
}
void OCCTopoShapeTreeViewer::setTopoShape(const TopoDS_Shape& shape)
{
this->displayTopoShape(shape);
}
void OCCTopoShapeTreeViewer::displayTopoShape(const TopoDS_Shape& shape)
{
// 清空QTreeWidget
clear();
// 调用递归函数来添加Topo_Shape的层次结构
addTopoShapeToTreeWidget(shape, nullptr);
// 展开所有项目
expandAll();
}
void OCCTopoShapeTreeViewer::addTopoShapeToTreeWidget(const TopoDS_Shape& shape, QTreeWidgetItem* parentItem)
{
// 获取当前Topo_Shape的类型
TopAbs_ShapeEnum shapeType = shape.ShapeType();
// 创建一个新的QTreeWidgetItem来表示当前Topo_Shape
QTreeWidgetItem* currentItem = new QTreeWidgetItem(parentItem);
currentItem->setText(0, TopAbs_ShapeEnum2QString(shapeType));
}

View File

@ -0,0 +1,25 @@
#ifndef OCCTOPOSHAPETREEVIEWER_H
#define OCCTOPOSHAPETREEVIEWER_H
#include "AllHead.h"
class OCCTopoShapeTreeViewer : public QTreeWidget
{
Q_OBJECT
public:
OCCTopoShapeTreeViewer(QWidget* parent = nullptr);
void setTopoShape(const TopoDS_Shape& shape);
// 显示Topo_Shape的层次结构
void displayTopoShape(const TopoDS_Shape& shape);
private:
// 递归函数用于在QTreeWidget中添加Topo_Shape的层次结构
void addTopoShapeToTreeWidget(const TopoDS_Shape& shape, QTreeWidgetItem* parentItem);
};
#endif // OCCTOPOSHAPETREEVIEWER_H

View File

@ -0,0 +1,43 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef COMMONSAMPLE_H
#define COMMONSAMPLE_H
#ifndef NO_COMMONSAMPLE_EXPORTS
#ifdef COMMONSAMPLE_EXPORTS
#ifdef _WIN32
#define COMMONSAMPLE_EXPORT __declspec( dllexport )
#else
#define COMMONSAMPLE_EXPORT
#endif
#else
#ifdef _WIN32
#define COMMONSAMPLE_EXPORT __declspec( dllimport )
#else
#define COMMONSAMPLE_EXPORT
#endif
#endif
#else
#define COMMONSAMPLE_EXPORT
#endif
#endif

View File

@ -0,0 +1,890 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "OCCT_Test/MakeBottle.h"
#include "DocumentCommon.h"
#include "Transparency.h"
#include "AllHead.h"
#include <BRepBndLib.hxx>
// =======================================================================
// function : Viewer
// purpose :
// =======================================================================
Handle(V3d_Viewer) DocumentCommon::Viewer(const Standard_ExtString,
const Standard_CString,
const Standard_Real theViewSize,
const V3d_TypeOfOrientation theViewProj,
const Standard_Boolean theComputedMode,
const Standard_Boolean theDefaultComputedMode)
{
static Handle(OpenGl_GraphicDriver) aGraphicDriver;
if (aGraphicDriver.IsNull())
{
Handle(Aspect_DisplayConnection) aDisplayConnection;
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
aDisplayConnection = new Aspect_DisplayConnection(OSD_Environment("DISPLAY").Value());
#endif
aGraphicDriver = new OpenGl_GraphicDriver(aDisplayConnection);
}
Handle(V3d_Viewer) aViewer = new V3d_Viewer(aGraphicDriver);
aViewer->SetDefaultViewSize(theViewSize);
aViewer->SetDefaultViewProj(theViewProj);
aViewer->SetComputedMode(theComputedMode);
aViewer->SetDefaultComputedMode(theDefaultComputedMode);
return aViewer;
}
void DocumentCommon::ShowOrHideActivateGridMesh() {
qDebug() << u8"切换平面网格显示 \n";
if (this->isActivateGridMesh) {
myViewer->DeactivateGrid();
this->isActivateGridMesh = false;
}
else {
// 设置XOY平面的网格
myViewer->SetGridEcho(Standard_True);
myViewer->ActivateGrid(Aspect_GT_Rectangular, Aspect_GDM_Lines);
this->isActivateGridMesh = true;
}
myViewer->Redraw();
}
void DocumentCommon::ShowOrHideActivateAxisGris()
{
qDebug() << u8"切换坐标轴网格显示 \n";
if (this->isActivateAxisGrid) {
for (NCollection_List<Handle(V3d_View)>::Iterator anIter(this->myViewer->ActiveViews());
anIter.More(); anIter.Next())
{
const Handle(V3d_View)& anObject = anIter.Value();
anObject->GraduatedTrihedronErase();
}
this->isActivateAxisGrid = false;
}
else {
for (NCollection_List<Handle(V3d_View)>::Iterator anIter(this->myViewer->ActiveViews());
anIter.More(); anIter.Next())
{
const Handle(V3d_View)& anObject = anIter.Value();
// 创建立方体网格对象
Graphic3d_GraduatedTrihedron grid;
anObject->GraduatedTrihedronDisplay(grid);
}
this->isActivateAxisGrid = true;
}
myViewer->Redraw();
}
bool DocumentCommon::getActivateGridMesh()
{
return this->isActivateGridMesh;
}
bool DocumentCommon::getActivateAxisGrid()
{
return this->isActivateAxisGrid;
}
Handle(AIS_InteractiveObject) DocumentCommon::ShowTopoDS_Shape(TopoDS_Shape& shape)
{
Handle(AIS_InteractiveObject) aShape = new AIS_Shape(shape);
this->myContext->Display(aShape, Standard_True);
return aShape;
}
bool DocumentCommon::HideTopoDS_Shape(Handle(AIS_InteractiveObject) aShape)
{
this->myContext->Erase(aShape, Standard_True);
return true;
}
bool DocumentCommon::ShowTopoDs_ShapeAIS(Handle(AIS_InteractiveObject) aShape)
{
this->myContext->Display(aShape, Standard_True);
return true;
}
bool DocumentCommon::RemoveTopoDS_Shape(Handle(AIS_InteractiveObject) aShape)
{
this->myContext->Remove(aShape, Standard_True);
return true;
}
DocumentCommon::DocumentCommon(QWidget* theApp)
:myContextIsEmpty(true),
QTreeWidget(theApp)
{
this->ShapeInfomationWindows = nullptr;
TCollection_ExtendedString a3DName("Visu3D");
myViewer = Viewer(a3DName.ToExtString(), "", 1000.0, V3d_XposYnegZpos, Standard_True, Standard_True);
myViewer->SetDefaultLights();
myViewer->SetLightOn();
myContext = new AIS_InteractiveContext(myViewer);
this->setColumnCount(1);
this->initTaskTreeRootNode();
this->initDocumentCommonContextMenu(); // 初始化右键菜单
}
void DocumentCommon::SetObjects(const NCollection_Vector<Handle(AIS_InteractiveObject)>& theObjects,
Standard_Boolean theDisplayShaded)
{
myContext->RemoveAll(Standard_False); // 清空对象
myContextIsEmpty = theObjects.IsEmpty();
for (NCollection_Vector<Handle(AIS_InteractiveObject)>::Iterator anIter(theObjects);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anObject = anIter.Value();
if (!theDisplayShaded)
{
myContext->Display(anObject, Standard_False);
}
else
{
myContext->Display(anObject, AIS_Shaded, 0, Standard_False);
}
}
myViewer->Redraw();
}
void DocumentCommon::ClearShape()
{
myContext->RemoveAll(Standard_True);
myContextIsEmpty = true;
}
void DocumentCommon::AppendCube()
{
qDebug() << u8"初始化坐标系 \n";
Handle(AIS_ViewCube) aViewCube = new AIS_ViewCube();
myObject3d.Append(aViewCube);
}
void DocumentCommon::InitAixs()
{
this->AppendCube();
myContext->RemoveAll(Standard_False);
myContextIsEmpty = this->myObject3d.IsEmpty();
for (NCollection_Vector<Handle(AIS_InteractiveObject)>::Iterator anIter(this->myObject3d);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anObject = anIter.Value();
myContext->Display(anObject, Standard_False);
}
this->isActivateAxisGrid = false;
this->isActivateGridMesh = false;
//this->ShowOrHideActivateAxisGris();
this->ShowOrHideActivateGridMesh();
myViewer->Redraw();
}
TaskNode* DocumentCommon::getItemByName(QString name)
{
if (this->dataMap.contains(name)) {
QTreeWidgetItem* item = this->dataMap.value(name);
TaskNode* obj = item->data(0, Qt::UserRole).value<TaskNode*>();
return obj;
}
else {
return nullptr;
}
}
std::shared_ptr<Bnd_Box> DocumentCommon::getSenceExtend()
{
std::shared_ptr<Bnd_Box> theOverallBox_ptr = std::make_shared<Bnd_Box>();;
AIS_ListOfInteractive aListOfObjects;
this->myContext->DisplayedObjects(aListOfObjects);
AIS_ListIteratorOfListOfInteractive anIter(aListOfObjects);
for (; anIter.More(); anIter.Next()) {
Handle(AIS_InteractiveObject) anIO = anIter.Value();
Handle_AIS_Shape aShape = Handle_AIS_Shape::DownCast(anIO);
if (!aShape.IsNull()) {
// Get the TopoDS_Shape
TopoDS_Shape aTopoShape = aShape->Shape();
BRepBndLib::Add(aTopoShape, *theOverallBox_ptr);
}
}
return theOverallBox_ptr;
}
std::shared_ptr<Bnd_Box> DocumentCommon::getSenceExtend(QString name)
{
TaskNode* temp = this->getItemByName(name);
if (temp) {
OCCTShapeModelNode* node= dynamic_cast<OCCTShapeModelNode*>(temp);
TopoDS_Shape aTopoShape = node->Shape();
std::shared_ptr<Bnd_Box> aBox_ptr = std::make_shared<Bnd_Box>();;
BRepBndLib::Add(aTopoShape, *aBox_ptr);
return aBox_ptr;
}
else {
std::shared_ptr<Bnd_Box> aBox_ptr(nullptr);
return aBox_ptr;
}
}
void DocumentCommon::OpenOCCTShapeFile()
{
qDebug() << u8"打开文件 \n";
QString stlpath = getOpenFilePath(
nullptr,
QString::fromUtf8(u8"导入模型"),
QString::fromUtf8(u8"STL Files (*.stl);;STL Files (*.stla);;step Files (*.stp);;step Files (*.step);;IGES Files (*.iges);;IGES Files (*.igs)"));
this->addShapeDsItem(stlpath);
}
// 打开模型
void DocumentCommon::addShapeDsItem(QString filepath)
{
OCCTShapeModelNode* checkBox = new OCCTShapeModelNode(this);
checkBox->setContext(this->myContext);
if (checkBox->setDataFile(filepath)) {
this->addOCCTObjectItem(checkBox);
}
else {
qDebug() << u8"没有打开文件:" << filepath << "\n";
}
}
void DocumentCommon::oncheckBoxStateChanged(int state) {
}
void DocumentCommon::initDocumentCommonContextMenu()
{
qDebug() << u8"初始化initDocumentCommonContextMenu模型编辑模块";
this->m_undoStack = new QUndoStack(this); //存放命令的栈
this->setContextMenuPolicy(Qt::CustomContextMenu);
this->ContentListContextMenu = new QMenu(this); // 表格控件的右键菜单
//QAction* m_undoAction = m_undoStack->createUndoAction(this, u8"撤销");//添加QActionCtrl-Z作为回撤的快捷键
//m_undoAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Z));
//QObject::connect(m_undoAction, SIGNAL(triggered()), this, SLOT(tableView_UndoAction()));
//QAction* m_redoAction = m_undoStack->createRedoAction(this, u8"重做");//添加QActionCtrl-Y左右前进的快捷键
//m_redoAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Y));
//QObject::connect(m_redoAction, SIGNAL(triggered()), this, SLOT(tableView_RedoAction()));
//this->ContentListContextMenu->addAction(m_undoAction);
//this->ContentListContextMenu->addAction(m_redoAction);
//QAction* TranslationdAction = this->ContentListContextMenu->addAction(u8"模型操作"); //
//QObject::connect(TranslationdAction, SIGNAL(triggered()), this, SLOT(TranslationObjectWindShow()));
//QAction* BatchExportAction = this->ContentListContextMenu->addAction(u8"模型批量导出"); //
//QObject::connect(BatchExportAction, SIGNAL(triggered()), this, SLOT(ContentListContextMenu_BatchExportAction()));
QObject::connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(ShowContentListContextMenu(QPoint)));
qDebug() << u8"初始化contextMenu结束";
}
void DocumentCommon::initTaskTreeRootNode()
{
this->clear(); //删除所有节点
this->setHeaderHidden(true); // 显示表头
// 创建2个根节点 数据 任务
dataRoot = new QTreeWidgetItem(this);
dataRoot->setText(0, u8"数据");
// 创建3个节点 模型 图像 点云
modelRoot = new QTreeWidgetItem(dataRoot);
modelRoot->setText(0, u8"模型");
imageRoot = new QTreeWidgetItem(dataRoot);
imageRoot->setText(0, u8"图像");
pointCloudRoot = new QTreeWidgetItem(dataRoot);
pointCloudRoot->setText(0, u8"属性数据库");
atriTableRoot = new QTreeWidgetItem(dataRoot);
atriTableRoot->setText(0, u8"属性数据库");
taskRoot = new QTreeWidgetItem(this);
taskRoot->setText(0, u8"任务");
// 创建3个节点 仿真图像任务、后向散射系数导出任务、仿真后向散射任务
fekoSimulationRoot = new QTreeWidgetItem(taskRoot);
fekoSimulationRoot->setText(0, u8"仿真任务");
exportScatteringRoot = new QTreeWidgetItem(taskRoot);
exportScatteringRoot->setText(0, u8"后向散射系数导出任务");
fekoScatteringRoot = new QTreeWidgetItem(taskRoot);
fekoScatteringRoot->setText(0, u8"仿真后向散射任务");
// 将根节点添加到 QTreeWidget 中
this->addTopLevelItem(dataRoot);
this->addTopLevelItem(taskRoot);
this->show();
}
void DocumentCommon::addTaskNode(TaskNode* node)
{
if (node) {
node->setParent(this);
if (dynamic_cast<OCCTShapeModelNode*>(node) != nullptr) { // 模型数据节点
this->addOCCTObjectItem(node);
}
else if (dynamic_cast<ComplexDataShowNode*>(node) != nullptr) { // 辅助图像节点
this->addImageObjectItem(node);
}
else if (dynamic_cast<DataShowNode*>(node) != nullptr) { // 辅助图像节点
this->addImageObjectItem(node);
}
else if (dynamic_cast<FEKOScatterSettingTaskNodeClass*>(node) != nullptr) { // 后向散射系数模拟任务节点
this->addScatterSettingTaskItem(node);
}
else if (dynamic_cast<FEKOResultImportTaskNode*>(node) != nullptr) { // 后向散射导入
this->addFEKOResultDataConvertItem(node);
}
else if (dynamic_cast<FEKOImageSettingTaskNodeClass*>(node) != nullptr) { // 仿真成像参数任务
this->addFEKOSimulationImageSettingItem(node);
}
else {
QMessageBox::warning(this, u8"警告", u8"未知任务节点");
delete node;
return;
}
// 添加信号连接
QObject::connect(node, SIGNAL(renameNode(QString, QString)), this, SLOT(renameTaskNode(QString, QString)));
QObject::connect(node, SIGNAL(deleteItem(QString)), this, SLOT(removeTaskNode(QString)));
QObject::connect(node, SIGNAL(deleteNode(QString)), this, SLOT(removeTaskNode(QString)));
}
else {
// nullptr
}
}
void DocumentCommon::addOCCTObjectItem(TaskNode* node)
{
QTreeWidgetItem* itemtemp = this->newQTaskTreeWidgetItem(node);
if (itemtemp) {
//if (this->addUniqueNode(itemtemp)) {
this->UpdateItemParantNode(itemtemp, modelRoot);
//}
}
else {
}
}
void DocumentCommon::addImageObjectItem(TaskNode* node)
{
QTreeWidgetItem* itemtemp = this->newQTaskTreeWidgetItem(node);
if (itemtemp) {
//if (this->addUniqueNode(itemtemp)) {
this->UpdateItemParantNode(itemtemp, imageRoot);
//}
}
else {
}
}
void DocumentCommon::addPointCloudObjectItem(TaskNode* node)
{
QTreeWidgetItem* itemtemp = this->newQTaskTreeWidgetItem(node);
if (itemtemp) {
//if (this->addUniqueNode(itemtemp)) {
this->UpdateItemParantNode(itemtemp, pointCloudRoot);
// }
}
else {
}
}
void DocumentCommon::addAtriTableObjectItem(TaskNode* node)
{
QTreeWidgetItem* itemtemp = this->newQTaskTreeWidgetItem(node);
if (itemtemp) {
//if (this->addUniqueNode(itemtemp)) {
this->UpdateItemParantNode(itemtemp, atriTableRoot);
//}
}
else {
}
}
void DocumentCommon::addScatterSettingTaskItem(TaskNode* node)
{
QTreeWidgetItem* itemtemp = this->newQTaskTreeWidgetItem(node);
if (itemtemp) {
//if (this->addUniqueNode(itemtemp)) {
this->UpdateItemParantNode(itemtemp, fekoScatteringRoot);
// }
}
else {
}
}
void DocumentCommon::addFEKOResultDataConvertItem(TaskNode* node)
{
QTreeWidgetItem* itemtemp = this->newQTaskTreeWidgetItem(node);
if (itemtemp) {
//if (this->addUniqueNode(itemtemp)) {
this->UpdateItemParantNode(itemtemp, exportScatteringRoot);
//}
}
else {
}
}
void DocumentCommon::addFEKOSimulationImageSettingItem(TaskNode* node)
{
QTreeWidgetItem* itemtemp = this->newQTaskTreeWidgetItem(node);
if (itemtemp) {
// if (this->addUniqueNode(itemtemp)) {
this->UpdateItemParantNode(itemtemp, fekoSimulationRoot);
// }
}
else {
}
}
void DocumentCommon::removeTaskNode(QTreeWidgetItem* node)
{
if (node) {
node->parent()->removeChild(node);
this->dataMap.remove(node->text(0));
}
else {
QMessageBox::warning(this, u8"警告", u8"未知节点");
}
}
void DocumentCommon::removeTaskNode(QString itemName)
{
if (this->dataMap.contains(itemName)) {
QTreeWidgetItem* item = this->dataMap.value(itemName);
TaskNode* obj = item->data(0, Qt::UserRole).value<TaskNode*>();
if (obj->status != TaskStatusEnum::finish) {
obj->FinishTask(); // 调用执行结束流程
}
this->removeTaskNode(item);
}
else {
QMessageBox::warning(this, u8"警告", u8"未找到节点:"+ itemName);
}
}
bool DocumentCommon::addUniqueNode(QTreeWidgetItem* item)
{
if (this->dataMap.contains(item->text(0))) {
QMessageBox::warning(this, u8"警告", u8"发现同名节点:"+ item->text(0));
return false;
}
else {
this->dataMap.insert(item->text(0), item);
return true;
}
}
QTreeWidgetItem* DocumentCommon::newQTaskTreeWidgetItem(TaskNode* node)
{
QTreeWidgetItem* itemtemp;
if (node) {
if (dynamic_cast<OCCTShapeModelNode*>(node) != nullptr) { // 模型数据节点
itemtemp = new QTreeWidgetItem(this->modelRoot);
}
else if (dynamic_cast<ComplexDataShowNode*>(node) != nullptr) { // 辅助图像节点
itemtemp = new QTreeWidgetItem(this->imageRoot);
}
else if (dynamic_cast<DataShowNode*>(node) != nullptr) { // 辅助图像节点
itemtemp = new QTreeWidgetItem(this->imageRoot);
}
else if (dynamic_cast<FEKOScatterSettingTaskNodeClass*>(node) != nullptr) { // 后向散射系数模拟任务节点
itemtemp = new QTreeWidgetItem(this->fekoScatteringRoot);
}
else if (dynamic_cast<FEKOResultImportTaskNode*>(node) != nullptr) { // 后向散射导入
itemtemp = new QTreeWidgetItem(this->exportScatteringRoot);
}
else if (dynamic_cast<FEKOImageSettingTaskNodeClass*>(node) != nullptr) { // 仿真成像参数任务
itemtemp = new QTreeWidgetItem(this->fekoSimulationRoot);
}
else {
QMessageBox::warning(this, u8"警告", u8"未知任务节点");
delete node;
return nullptr;
}
// 添加信号连接
QObject::connect(node, SIGNAL(renameNode(QString, QString)), this, SLOT(renameTaskNode(QString, QString)));
QObject::connect(node, SIGNAL(deleteItem(QString)), this, SLOT(removeTaskNode(QString)));
}
else {
QMessageBox::warning(this, u8"警告", u8"未知任务节点");
delete node;
return nullptr;
}
qDebug() << node->getTaskName();
itemtemp->setText(0, node->getTaskName());
itemtemp->setData(0, Qt::UserRole, QVariant::fromValue(node));
// 处理事件绑定
if (this->addUniqueNode(itemtemp)) {
return itemtemp;
}
else {
delete itemtemp;
return nullptr;
}
}
void DocumentCommon::renameTaskNode(QString olditemName, QString newitemName)
{
qDebug() << u8"正在执行重命名命令";
if (this->dataMap.contains(newitemName)) {
QMessageBox::warning(this, u8"警告", u8"存在同名节点");
}
else {
QTreeWidgetItem* item = this->dataMap.value(olditemName);
item->setText(0, newitemName);
this->dataMap.remove(olditemName);
this->dataMap.insert(newitemName, item);
TaskNode* obj = item->data(0, Qt::UserRole).value<TaskNode*>();
obj->setName(newitemName);
}
}
void DocumentCommon::copyNewNode(TaskNode* newNode)
{
if (newNode) {
QString newName = QInputDialog::getText(this, u8"重命名", u8"请输入新的名称", QLineEdit::Normal, newNode->getName() + u8"_1");
if (newName.isEmpty()) {
QMessageBox::warning(this, u8"警告", u8"无效名称");
delete newNode;// 无效对象,直接删除
}
else {
newNode->setName(newName);
this->addTaskNode(newNode);
}
}
else {
// nullptr
}
}
void DocumentCommon::UpdateItemParantNode(QTreeWidgetItem* n, QTreeWidgetItem* p)
{
if (n) {
QTreeWidgetItem * parentOfn =n->parent();//获取节点 n 的父节点
if (parentOfn) {
parentOfn->removeChild(n);
if (p) {
p->addChild(n);
}
else {
this->addTopLevelItem(n);
}
}
else {
if (p) {
int index=this->indexOfTopLevelItem(n);
this->takeTopLevelItem(index);
p->addChild(n);
}
else { // 本身就是节点就是根节点,无须再提升
return;
}
}
}
else {
// 不是根节点,直接返回
}
}
void DocumentCommon::addOCCTObjItem(TopoDS_Shape shape, QString name, bool ishow)
{
OCCTShapeModelNode* checkBox = new OCCTShapeModelNode(this);
checkBox->setContext(this->myContext);
checkBox->setShape(shape);
checkBox->setText(name);
//QObject::connect(checkBox, SIGNAL(copyNew()), this, SLOT(copyOCCTObjectCheckBoxItem()));
//QObject::connect(checkBox, SIGNAL(ShowFullExtend(const TopoDS_Shape&)), this, SLOT(SelectItemFullShow(const TopoDS_Shape&)));
//QObject::connect(checkBox, SIGNAL(ModelModify(OCCTShapeModelNode*)), this, SLOT(ShapeModifyShape(OCCTShapeModelNode*)));
this->addTaskNode(checkBox);
if (ishow) {
checkBox->ShowShape(); // 展示模型
}
else {
checkBox->HideShape(); // 隐藏模型
}
}
TopoDS_Shape DocumentCommon::MergeCOntextAllModels() {
TopoDS_Compound compound;
BRep_Builder builder;
builder.MakeCompound(compound);
this->myContext->InitSelected(); // 初始化模型
for (; myContext->MoreSelected(); myContext->NextSelected()) {
Handle(AIS_InteractiveObject) selectedObject = myContext->SelectedInteractive();
if (!selectedObject.IsNull()) {
TopoDS_Shape shape = this->getTopoDSShape(selectedObject);
// 将每个形状添加到 Compound
builder.Add(compound, shape);
}
}
return compound;
}
// 保存模型
void DocumentCommon::SaveModelFile() {
// 选择保存文件
qDebug() << u8"打开文件 \n";
QString filepath = getSaveFilePath(
nullptr,
QString::fromUtf8(u8"保存FEKO结果导入场景模型"),
QString::fromUtf8(u8"STL Files (*.stl);;STL Files (*.stla);;step Files (*.stp);;step Files (*.step);;IGES Files (*.iges);;IGES Files (*.igs)"));
QFileInfo fileinfo(filepath);
QString filename = fileinfo.fileName();
QString fileSuffix = fileinfo.suffix();
TopoDS_Shape shape_TopoDs = this->MergeCOntextAllModels(); // 合并所有模型
// 保存模型
if (fileSuffix.compare(u8"stl") == 0 || fileSuffix.compare(u8"stla") == 0) {
SaveTopoDs_Stl(filepath, shape_TopoDs);
}
else if (fileSuffix.compare(u8"step") == 0 || fileSuffix.compare(u8"stp") == 0) {
SaveTopoDs_Step(filepath, shape_TopoDs);
}
else if (fileSuffix.compare(u8"iges") == 0 || fileSuffix.compare(u8"igs") == 0) {
SaveTopoDs_IGES(filepath, shape_TopoDs);
}
else {
}
}
void DocumentCommon::ShowContentListContextMenu(QPoint p) {
qDebug() << u8"正在展示ShowContentListContextMenu 右键菜单";
QList < QTreeWidgetItem* > selectitems =this->selectedItems();
if (selectitems.count() == 0) {
// 初始化右键菜单
return;
}
else if (selectitems.count() == 1) {
TaskNode* obj=this->getItemByName(selectitems[0]->text(0));
if (obj) {
obj->ShowContentListContextMenu(p);
}
else {}
return;
}else if(selectitems.count()>1){
for (size_t i = 0; i < selectitems.count(); i++) {
TaskNode* obj = this->getItemByName(selectitems[i]->text(0));
obj->ContentListContextMenu->setTitle(obj->getTaskName());
this->ContentListContextMenu->addMenu(obj->ContentListContextMenu);
}
this->ContentListContextMenu->exec(QCursor::pos());
}
else {
return;
}
}
void DocumentCommon::ContentListContextMenu_UndoAction()
{
qDebug() << u8"正在撤销命令";
int index = this->m_undoStack->index();
this->m_undoStack->setIndex(index);
}
void DocumentCommon::ContentListContextMenu_RedoAction()
{
qDebug() << u8"正在重做命令";
int index = this->m_undoStack->index();
this->m_undoStack->setIndex(index);
}
void DocumentCommon::ContentListContextMenu_BatchExportAction()
{
qDebug() << u8"批量导出模型";
DialogBatchExport* exportWindows = new DialogBatchExport();
for (int i = 0; i < this->modelRoot->childCount(); ++i) {
QTreeWidgetItem* item = this->modelRoot->child(i);
TaskNode* obj = item->data(0, Qt::UserRole).value<TaskNode*>();
if (obj) {
OCCTShapeModelNode* checkBox = dynamic_cast<OCCTShapeModelNode*>(obj);
exportWindows->addDataShape(checkBox->text(), checkBox->Shape());
}
else {
QMessageBox::warning(this, u8"错误", u8"发现错误:" + item->text(0));
continue;
}
}
exportWindows->show();
}
///////////////////////////
// 窗口右键菜单
//////////////////////////
void DocumentCommon::VerticesSelect3dSample()
{
qDebug() << u8"切换选择模式为TopAbs_VERTEX";
myContext->Deactivate();
myContext->Activate(AIS_Shape::SelectionMode(TopAbs_VERTEX));
}
void DocumentCommon::EdgesSelect3dSample()
{
qDebug() << u8"切换选择模式为TopAbs_EDGE";
myContext->Deactivate();
myContext->Activate(AIS_Shape::SelectionMode(TopAbs_EDGE));
}
void DocumentCommon::FacesSelect3dSample()
{
qDebug() << u8"切换选择模式为TopAbs_FACE";
myContext->Deactivate();
myContext->Activate(AIS_Shape::SelectionMode(TopAbs_FACE));
}
void DocumentCommon::NeutralPointSelect3dSample()
{
qDebug() << u8"切换选择模式为TopAbs_COMPOUND";
myContext->Deactivate();
myContext->Activate(TopAbs_COMPOUND);
}
//void DocumentCommon::ShapeModifyShape(OCCTShapeModelNode* dataItem)
//{
// qDebug() << u8"模型操作";
// OCCTModelOperator* operatorWindows = new OCCTModelOperator(dataItem->text(), nullptr, this->myContext);
// operatorWindows->setModal(false);
// //operatorWindows->setTopoDs_Shape(dataItem->DataShape);
// // 绑定模型
// QObject::connect(operatorWindows, SIGNAL(ResultExportCopyAndCreateNew(OCCTModelOperator*)), this, SLOT(TranslationExportCopy(OCCTModelOperator*)));
// QObject::connect(operatorWindows, SIGNAL(ResultExport(OCCTModelOperator*)), this, SLOT(TranslationExport(OCCTModelOperator*)));
// QObject::connect(operatorWindows, SIGNAL(RefreshResult(OCCTModelOperator*)), this, SLOT(RefreshResult(OCCTModelOperator*)));
// operatorWindows->show();
//}
////////////////////////////////////////////////////////////
// 模型界面的选择事件
////////////////////////////////////////////////////////////
void DocumentCommon::ViewerMousePressEvent(QMouseEvent* theEvent) {
qDebug() << u8"view 窗体按键按下点击事件被激活 \n";
}
void DocumentCommon::ViewerMouseReleaseEvent(QMouseEvent* theEvent)
{
qDebug() << u8"view 窗体按键释放事件被激活 \n";
for (this->myContext->InitSelected(); this->myContext->MoreSelected(); this->myContext->NextSelected()) {
Handle(AIS_InteractiveObject) selectedObject = this->myContext->SelectedInteractive();
qDebug() << u8"view 发现选中对象 \n";
TopoDS_Shape selectShape = this->getTopoDSShape(selectedObject);
emit this->SelectObjectList(selectShape);
this->showSelectShape(selectShape);
}
}
void DocumentCommon::SelectItemFullShow(const TopoDS_Shape& shape)
{
emit this->ShowSelectItemFullExtend(shape);
}
void DocumentCommon::setShapeInfomationWindows(OCCTopoShapeTreeViewer* ShapeInfomationWindows)
{
this->ShapeInfomationWindows = ShapeInfomationWindows;
}
// Function to get TopoDS_Shape from AIS_InteractiveObject
TopoDS_Shape DocumentCommon::getTopoDSShape(const Handle(AIS_InteractiveObject)& aisObject)
{
if (aisObject.IsNull() || !aisObject->HasInteractiveContext())
return TopoDS_Shape(); // Return an empty shape if AIS_InteractiveObject is null or not associated with an interactive context
Handle(AIS_Shape) aisShape = Handle(AIS_Shape)::DownCast(aisObject);
if (aisShape.IsNull())
return TopoDS_Shape(); // Return an empty shape if AIS_InteractiveObject is not a shape
// Get the shape from AIS_Shape
TopoDS_Shape topoShape = aisShape->Shape();
return topoShape;
}
void DocumentCommon::showSelectShape(const TopoDS_Shape& selectShape)
{
qDebug() << u8"显示选中的对象 \n";
if (this->ShapeInfomationWindows) {
this->ShapeInfomationWindows->setTopoShape(selectShape);
}
else {}
}

View File

@ -0,0 +1,209 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef DOCUMENT_COMMON_OVERVIEW_H
#define DOCUMENT_COMMON_OVERVIEW_H
#include "AllHead.h"
#include <qDebug>
#include "TaskXml/TaskTreeClass.h"
#include "TaskNodeList.h"
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 文件模型控制
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//! Implements visualization of samples content
class DocumentCommon : public QTreeWidget
{
Q_OBJECT
public:
Q_INVOKABLE DocumentCommon(QWidget*);
~DocumentCommon() { }
//=========================================
// 任务节点管理
//=========================================
public: // 数据管理层次
QTreeWidgetItem* dataRoot; // 根节点
QTreeWidgetItem* taskRoot;
QTreeWidgetItem* modelRoot; // 数据类型
QTreeWidgetItem* imageRoot;
QTreeWidgetItem* pointCloudRoot;
QTreeWidgetItem* atriTableRoot;
QTreeWidgetItem* fekoSimulationRoot; // 任务类型
QTreeWidgetItem* exportScatteringRoot;
QTreeWidgetItem* fekoScatteringRoot;
QMap<QString, QTreeWidgetItem*> dataMap; // 数据名-节点项绑定
public slots:
void initTaskTreeRootNode(); //初始化任务树
TaskNode* getItemByName(QString name);// 场景节点
void addTaskNode(TaskNode*); // 添加节点
void removeTaskNode(QString itemName); // 移除节点
bool addUniqueNode(QTreeWidgetItem* item); // 添加唯一性节点
QTreeWidgetItem* newQTaskTreeWidgetItem(TaskNode* node); // 创建任务节点
void renameTaskNode(QString olditemName,QString newitemName); // 重命名节点
void copyNewNode(TaskNode* newNode);
void UpdateItemParantNode(QTreeWidgetItem* n, QTreeWidgetItem* p = nullptr);// 更变父节点,如果是空指针,标识提升为根节点
public slots: // 添加 文件节点分布
void addOCCTObjectItem(TaskNode*); // 加载数据
void addImageObjectItem(TaskNode*);
void addPointCloudObjectItem(TaskNode*); // 功能待实现
void addAtriTableObjectItem(TaskNode*); // 功能待实现
void addScatterSettingTaskItem(TaskNode*); // 加载任务
void addFEKOResultDataConvertItem(TaskNode*);
void addFEKOSimulationImageSettingItem(TaskNode*);
void addOCCTObjItem(TopoDS_Shape shape, QString name, bool ishow = true);// 添加模型
void addShapeDsItem(QString filepath); // 加载模型
public slots: // 移除节点
void removeTaskNode(QTreeWidgetItem*);
public slots: // 任务节点,共有内容
void ContentListContextMenu_UndoAction(); // 撤销
void ContentListContextMenu_RedoAction(); // 重做
void ContentListContextMenu_BatchExportAction();
public slots:
void initDocumentCommonContextMenu(); // 初始化右键菜单
void ShowContentListContextMenu(QPoint p);
//=========================================
// 模型操作
//=========================================
private:// 私有变量
bool isActivateGridMesh ;
bool isActivateAxisGrid;
Graphic3d_GraduatedTrihedron aTrihedron_aixs;
public:// 公开变量
Handle(V3d_Viewer) myViewer;
Handle(AIS_InteractiveContext) myContext;
bool myContextIsEmpty;
NCollection_Vector<Handle(AIS_InteractiveObject)> myObject3d; // 控制器列表
QUndoStack* m_undoStack;
QSet<QString> ItemSets;
QMenu* ContentListContextMenu;
OCCTopoShapeTreeViewer* ShapeInfomationWindows; //展示被选择的模型
public:
Handle(AIS_InteractiveObject) ShowTopoDS_Shape(TopoDS_Shape& shape); // 显示模型
bool HideTopoDS_Shape(Handle(AIS_InteractiveObject) aShape); // 隐藏模型
bool ShowTopoDs_ShapeAIS(Handle(AIS_InteractiveObject) aShape); // 显示模型
bool RemoveTopoDS_Shape(Handle(AIS_InteractiveObject) aShape); // 移除模型
const Handle(AIS_InteractiveContext)& getContext() { return myContext; }
const Handle(V3d_Viewer)& getViewer() { return myViewer; }
void setViewer(const Handle(V3d_Viewer)& theViewer) { myViewer = theViewer; }
void SetObjects(const NCollection_Vector<Handle(AIS_InteractiveObject)>& theObjects, Standard_Boolean theDisplayShaded = Standard_False);
void ClearShape(); // 清除模型
bool IsEmpty() const { return myContextIsEmpty; }
void AppendCube(); // 增加视觉立方体
void InitAixs(); // 增加三维坐标轴
std::shared_ptr<Bnd_Box> getSenceExtend(); // 场景数据获取
std::shared_ptr<Bnd_Box> getSenceExtend(QString name);
signals:
void selectionChanged();
void sendCloseDocument(DocumentCommon*);
private:
Handle(V3d_Viewer) Viewer(const Standard_ExtString theName,
const Standard_CString theDomain,
const Standard_Real theViewSize,
const V3d_TypeOfOrientation theViewProj,
const Standard_Boolean theComputedMode,
const Standard_Boolean theDefaultComputedMode);
public slots:
void ShowOrHideActivateGridMesh();
void ShowOrHideActivateAxisGris();
bool getActivateGridMesh();
bool getActivateAxisGrid();
void VerticesSelect3dSample();
void EdgesSelect3dSample();
void FacesSelect3dSample();
void NeutralPointSelect3dSample();
//void ShapeModifyShape(OCCTShapeModelNode* dataItem); // 模型修改
public:
void OpenOCCTShapeFile();
void SaveModelFile();
void oncheckBoxStateChanged(int state);
TopoDS_Shape MergeCOntextAllModels();
public slots: // 模型窗口右键菜单
///////////////////////////////////////////////////
// 获取view窗体中的 选择模型
///////////////////////////////////////////////////
signals:
void SelectObjectList(const TopoDS_Shape& selectShape);
void ShowSelectItemFullExtend(const TopoDS_Shape& shape);
public slots:
void ViewerMousePressEvent(QMouseEvent* theEvent);
void ViewerMouseReleaseEvent(QMouseEvent* theEvent);
void SelectItemFullShow(const TopoDS_Shape& shape);
void setShapeInfomationWindows(OCCTopoShapeTreeViewer* ShapeInfomationWindows);
public:
TopoDS_Shape getTopoDSShape(const Handle(AIS_InteractiveObject)& aisObject);
void showSelectShape(const TopoDS_Shape& selectShape);
};
#endif

View File

@ -0,0 +1,98 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "GeomWidget.h"
#include <Standard_WarningsDisable.hxx>
#include <QFrame>
#include <QBoxLayout>
#include <QTextEdit>
#include <QStackedLayout>
#include <QToolBar>
#include <QStackedWidget>
#include <Standard_WarningsRestore.hxx>
#include <Quantity_Color.hxx>
#include <AIS_Shape.hxx>
GeomWidget::GeomWidget (DocumentCommon* theDocument3d, QWidget* theParent)
: QWidget(theParent),
myDocument3d(theDocument3d)
{
QVBoxLayout* aMainLayout = new QVBoxLayout(this);
aMainLayout->setContentsMargins(0, 0, 0, 0);
this->my3dVidget = new QWidget;// 3D模型 显示
QVBoxLayout* a3dLayout = new QVBoxLayout(my3dVidget);
a3dLayout->setContentsMargins(0, 0, 0, 0);
a3dLayout->setSpacing(0);
myView3d = new View(myDocument3d->getContext(), true, my3dVidget); // 创建一个 3D 模型 View
QToolBar* aToolBar3d = new QToolBar;
aToolBar3d->addActions(myView3d->getViewActions());
aToolBar3d->addSeparator();
aToolBar3d->addActions(myView3d->getRaytraceActions());
a3dLayout->addWidget(aToolBar3d);
a3dLayout->addWidget(myView3d);
myStackWidget = new QStackedWidget(this);
aMainLayout->addWidget(myStackWidget);
myStackWidget->addWidget(my3dVidget);
this->initEvents();
FitAll();
}
void GeomWidget::FitAll()
{
Show3d();
}
void GeomWidget::Show3d()
{
myView3d->axo();
myView3d->fitAll();
QAction* aShadingAction = myView3d->getViewAction(ViewAction_Shading);
aShadingAction->trigger();
aShadingAction->setChecked(true);
QAction* aHlrOffAction = myView3d->getViewAction(ViewAction_HlrOff);
aHlrOffAction->trigger();
aHlrOffAction->setChecked(true);
myStackWidget->setCurrentWidget(my3dVidget);
setStatusTip("Mouse buttons: Right-Zoom, Middle-Pan, Left-Rotate");
}
void GeomWidget::initEvents()
{
QObject::connect(this->myView3d, SIGNAL(ViewMousePressEvent(QMouseEvent *)), this->myDocument3d, SLOT(ViewerMousePressEvent(QMouseEvent *)));
QObject::connect(this->myView3d, SIGNAL(ViewMouseReleaseEvent(QMouseEvent*)), this->myDocument3d, SLOT(ViewerMouseReleaseEvent(QMouseEvent*)));
QObject::connect(this->myDocument3d, SIGNAL(ShowSelectItemFullExtend(const TopoDS_Shape&)), this, SLOT(ShowExtend(const TopoDS_Shape&)));
}
void GeomWidget::ShowExtend(const TopoDS_Shape& Data_Shape) {
// 缩放到选定的模型
qDebug() << "缩放到选定的模型";
this->myDocument3d->myContext->FitSelected(this->Get3dView()); // 缩放到选择图层
this->myDocument3d->myContext->ClearSelected(Standard_True);
}

View File

@ -0,0 +1,68 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef GEOMWIDGET_H
#define GEOMWIDGET_H
#include "OCCViewer\View.h"
#include "OCCViewer\DocumentCommon.h"
#include <Standard_WarningsDisable.hxx>
#include <Standard_WarningsRestore.hxx>
#include <QGLWidget>
#include <AIS_InteractiveContext.hxx>
#include <QtWidgets>
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <V3d_View.hxx>
#include <AIS_InteractiveContext.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <QWidget>
#include <QObject>
//! Qt widget for organize 3D & 2D documents
class GeomWidget : public QWidget
{
Q_OBJECT
public:
GeomWidget(DocumentCommon* theDocument3d,
QWidget* theParent = nullptr);
void FitAll();
Handle(V3d_View) Get3dView() { return myView3d->getView(); }
void Show3d();
void initEvents();
public:
View* myView3d;
QWidget* my3dVidget;
QStackedWidget* myStackWidget;
DocumentCommon* myDocument3d;
public slots:
void ShowExtend(const TopoDS_Shape& Data_Shape);
};
#endif //GEOMWIDGET_H

View File

@ -0,0 +1,185 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "BaseSample.h"
#include <iostream>
#include <regex>
#include <exception>
#include <stack>
#include <AIS_ViewCube.hxx>
#include <Message.hxx>
#include <OSD_File.hxx>
#include <OSD_Path.hxx>
#include <OSD_Protection.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QDir>
#include <Standard_WarningsRestore.hxx>
const TCollection_AsciiString BaseSample::FILE_EXTENSION = "cxx";
void BaseSample::Clear()
{
myObject3d.Clear();
myObject2d.Clear();
myCode.Clear();
myResult.str("");
}
TCollection_AsciiString BaseSample::GetResult()
{
TCollection_AsciiString aResult(myResult.str().c_str());
myResult.str("");
return aResult;
}
void BaseSample::AppendCube()
{
Handle(AIS_ViewCube) aViewCube = new AIS_ViewCube();
myObject3d.Append(aViewCube);
}
void BaseSample::Process (const TCollection_AsciiString& theSampleName)
{
myObject3d.Clear();
myObject2d.Clear();
myCode.Clear();
myIsProcessed = Standard_False;
try
{
ExecuteSample(theSampleName);
if (!myObject3d.IsEmpty())
{
Handle(AIS_ViewCube) aViewCube = new AIS_ViewCube();
myObject3d.Append(aViewCube);
}
}
catch (...)
{
TraceError(TCollection_AsciiString("Error in sample: ") + theSampleName);
}
}
void BaseSample::TraceError (const TCollection_AsciiString& theErrorMessage)
{
Message::SendFail() << "\nERROR: " << theErrorMessage.ToCString() << "\n";
myResult << "\nERROR: " << theErrorMessage << "\n";
}
void BaseSample::FindSourceCode (const TCollection_AsciiString& theSampleName)
{
TCollection_AsciiString aClassName = DynamicType()->Name();
char aSeparator = QDir::separator().toLatin1();
TCollection_AsciiString aCxxFilePach = myCodePath + aSeparator + aClassName + '.' + FILE_EXTENSION;
OSD_File aCxxFile(aCxxFilePach);
try
{
const Standard_Integer aFileBufferSize = 100 * 1024;
TCollection_AsciiString aReadedText(aFileBufferSize);
aCxxFile.Open(OSD_ReadOnly, OSD_Protection());
aCxxFile.Read(aReadedText, aFileBufferSize);
TCollection_AsciiString aRegexpTemplate = aClassName + "::" + theSampleName + "[\\n\\s]*\\([\\n\\s]*\\)[\\n\\s]*\\{";
Standard_Integer aOpeningBracketPosition = findEndOfPhrase (aReadedText, aRegexpTemplate);
Standard_Integer aClosingBracketPosition = findClosingBracket (aReadedText, aOpeningBracketPosition, '}');
myCode = aReadedText.SubString(aOpeningBracketPosition + 1, aClosingBracketPosition - 1);
}
catch (...)
{
TraceError(TCollection_AsciiString("Cannot open file: ") + aCxxFilePach);
}
}
Standard_Integer BaseSample::findEndOfPhrase (const TCollection_AsciiString& theText,
const TCollection_AsciiString& theRegexpTemplate)
{
Standard_Integer aIndexOfLastFoundSymbol = -1;
std::string aStdText = theText.ToCString();
std::string aRegexpTemplate = theRegexpTemplate.ToCString();
try
{
std::regex aRegex(theRegexpTemplate.ToCString());
std::sregex_iterator aDetectIterator = std::sregex_iterator(aStdText.begin(), aStdText.end(), aRegex);
if (aDetectIterator != std::sregex_iterator())
{
std::smatch aMatch = *aDetectIterator;
std::string aFoundString = aMatch.str();
aIndexOfLastFoundSymbol = static_cast<Standard_Integer>(aStdText.find(aFoundString) + aFoundString.length());
}
else
{
TraceError(TCollection_AsciiString("No code found for template: ") + theRegexpTemplate);
}
}
catch (const std::regex_error& aRegError)
{
TraceError(TCollection_AsciiString("regex_error: ") + aRegError.what());
}
catch (const std::exception& aEx)
{
TraceError(TCollection_AsciiString("common error: ") + aEx.what());
}
catch (...)
{
TraceError("unknown error!");
}
return aIndexOfLastFoundSymbol;
}
Standard_Integer BaseSample::findClosingBracket (const TCollection_AsciiString& theText,
const Standard_Integer theOpeningBracketIndex,
Standard_Character theClosingBracketSymbol)
{
// TODO this function not implemented at least 2 cases:
// - brackets in strings & chars
// - brackets in comments
Standard_Integer aClosingBracketIndex = -1;
Standard_Character anOpeningBracketSymbol = theText.Value(theOpeningBracketIndex);
TCollection_AsciiString aBracketsSet(theClosingBracketSymbol);
aBracketsSet += anOpeningBracketSymbol;
Standard_Integer aBracketDepth = 1;
Standard_Integer aStartFindIndex = theOpeningBracketIndex + 1;
//Standard_Character aStartFindChar = theText.Value(aStartFindIndex-1);
while (aBracketDepth)
{
aStartFindIndex = theText.FirstLocationInSet(aBracketsSet, aStartFindIndex, theText.Length());
if (!aStartFindIndex)
{
TraceError("No closing bracket found!");
break;
}
TCollection_AsciiString aRSubstr = theText.SubString(aStartFindIndex, theText.Length());
if (theText.Value(aStartFindIndex) == anOpeningBracketSymbol)
aBracketDepth++;
else if (theText.Value(aStartFindIndex) == theClosingBracketSymbol)
aBracketDepth--;
if (!aBracketDepth)
{
aClosingBracketIndex = aStartFindIndex;
break;
}
aStartFindIndex++;
}
return aClosingBracketIndex;
}

View File

@ -0,0 +1,87 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef BASESAMPLE_H
#define BASESAMPLE_H
#include <sstream>
#include <AIS_InteractiveObject.hxx>
#include <NCollection_Vector.hxx>
#include <TCollection_AsciiString.hxx>
//! Base class for specified category classes
class BaseSample: public Standard_Transient
{
DEFINE_STANDARD_RTTI_INLINE(BaseSample, Standard_Transient)
public:
BaseSample (const TCollection_AsciiString& theSampleSourcePath,
const Handle(AIS_InteractiveContext)& theContext)
: myCodePath (theSampleSourcePath),
myContext (theContext)
{
//
}
void Clear();
void AppendCube();
Standard_Boolean IsProcessed() const { return myIsProcessed; }
const NCollection_Vector<Handle(AIS_InteractiveObject)>& Get2dObjects() const { return myObject2d; }
const NCollection_Vector<Handle(AIS_InteractiveObject)>& Get3dObjects() const { return myObject3d; }
TCollection_AsciiString GetResult();
TCollection_AsciiString GetCode() const { return myCode; }
virtual void Process (const TCollection_AsciiString& theSampleName);
protected:
virtual void ExecuteSample (const TCollection_AsciiString& theSampleName) = 0;
void FindSourceCode (const TCollection_AsciiString& theSampleName);
void TraceError (const TCollection_AsciiString& theErrorMessage);
protected:
Standard_Boolean myIsProcessed;
NCollection_Vector<Handle(AIS_InteractiveObject)> myObject2d;
NCollection_Vector<Handle(AIS_InteractiveObject)> myObject3d;
std::ostringstream myResult;
TCollection_AsciiString myCode;
TCollection_AsciiString myCodePath;
Handle(AIS_InteractiveContext) myContext;
protected:
static const TCollection_AsciiString FILE_EXTENSION;
private:
Standard_Integer findEndOfPhrase (const TCollection_AsciiString& theText,
const TCollection_AsciiString& theRegexpTemplate);
Standard_Integer findClosingBracket (const TCollection_AsciiString& theText,
Standard_Integer theOpeningBracketIndex,
Standard_Character theClosingBracketSymbol);
};
#endif //BASESAMPLE_H

Some files were not shown because too many files have changed in this diff Show More