From 2379b94633d6382d2960765acbc59acd85dd9bdd Mon Sep 17 00:00:00 2001 From: JackLee <809262979@qq.com> Date: Mon, 20 Apr 2026 05:09:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=9C=E7=A8=8Bgit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/cpp/CMakeLists.txt | 42 ++--- .../main/cpp/NativeEGLOCCT/OCCTMgr/Render.cpp | 3 +- .../main/cpp/NativeEGLOCCT/OCCTMgr/Render.h | 18 ++- .../ViewController/V3dViewController.cpp | 18 +++ .../ViewController/V3dViewController.h | 20 +++ .../Camera}/README.md | 0 .../Camera}/V3dCamera.cpp | 0 .../Camera}/V3dCamera.h | 0 .../Context}/V3dCtx.cpp | 0 .../V3dCtx => Visualization/Context}/V3dCtx.h | 2 +- .../Drawer}/V3dDrawer.cpp | 0 .../Drawer}/V3dDrawer.h | 0 .../V3dOGD => Visualization/OGD}/V3dOGD.cpp | 0 .../V3dOGD => Visualization/OGD}/V3dOGD.h | 0 .../V3dTri => Visualization/Tri}/README.md | 0 .../V3dTri => Visualization/Tri}/V3dTri.cpp | 0 .../V3dTri => Visualization/Tri}/V3dTri.h | 0 .../Tri}/V3dTriCube.cpp | 0 .../V3dTri => Visualization/Tri}/V3dTriCube.h | 0 .../Tri}/V3dWCSTri.cpp | 0 .../V3dTri => Visualization/Tri}/V3dWCSTri.h | 0 .../View}/V3dView.cpp | 0 .../V3dView => Visualization/View}/V3dView.h | 2 +- .../Viewer}/V3dViewer.cpp | 0 .../Viewer}/V3dViewer.h | 0 .../V3dWin => Visualization/Win}/V3dWin.cpp | 0 .../V3dWin => Visualization/Win}/V3dWin.h | 0 .../main/ets/entryability/EntryAbility.ets | 22 ++- .../ets/pages/CustomController/Button.ets | 2 +- .../ets/pages/CustomController/Dialog.ets | 2 +- .../main/ets/pages/CustomController/Menu.ets | 2 +- .../ets/pages/DispWinInfo/DispWinInfo.ets | 17 +- .../src/main/ets/pages/EventHub/EventBase.ets | 41 +++++ .../main/ets/pages/EventHub/EventExecute.ets | 31 ++++ .../src/main/ets/pages/EventHub/EventPage.ets | 38 +++++ .../src/main/ets/pages/EventHub/XCompMgr.ets | 67 ++++++++ .../src/main/ets/pages/EventSubWin/ExCom.ets | 152 ------------------ .../src/main/ets/pages/EventSubWin/SWBase.ets | 71 -------- .../LayoutInterface/Layout/MatrixModel.ets | 18 +-- .../Layout/TitleDefaultBars.ets | 12 +- entry/src/main/ets/pages/ModelViewTab.ets | 2 +- .../File/FileInter.ets | 0 .../File/FileStr.ets | 0 .../File/SWExportFile.ets | 0 .../File/SWImportFile.ets | 0 .../File/SWNewFile.ets | 62 +++---- .../File/SWOpenFile.ets | 0 .../File/SWSaveAsFile.ets | 0 .../{EventSubWin => SubWindow}/Options.ets | 0 .../Opts/OptFeature.ets | 0 .../Opts/OptsInter.ets | 0 .../Opts/OptsModeling.ets | 0 .../Opts/OptsStr.ets | 0 .../Opts/OptsSub.ets | 0 .../Opts/OptsUser.ets | 0 .../Opts/OptsUserLayout.ets | 0 .../{EventSubWin => SubWindow}/README.md | 0 entry/src/main/ets/pages/SubWindow/SWBase.ets | 75 +++++++++ .../{EventSubWin => SubWindow}/SWExtrude.ets | 0 .../{EventSubWin => SubWindow}/SWLine.ets | 0 .../resources/base/profile/main_pages.json | 16 +- 61 files changed, 404 insertions(+), 331 deletions(-) create mode 100644 entry/src/main/cpp/NativeEGLOCCT/ViewController/V3dViewController.cpp create mode 100644 entry/src/main/cpp/NativeEGLOCCT/ViewController/V3dViewController.h rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dCamera => Visualization/Camera}/README.md (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dCamera => Visualization/Camera}/V3dCamera.cpp (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dCamera => Visualization/Camera}/V3dCamera.h (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dCtx => Visualization/Context}/V3dCtx.cpp (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dCtx => Visualization/Context}/V3dCtx.h (94%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dDrawer => Visualization/Drawer}/V3dDrawer.cpp (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dDrawer => Visualization/Drawer}/V3dDrawer.h (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dOGD => Visualization/OGD}/V3dOGD.cpp (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dOGD => Visualization/OGD}/V3dOGD.h (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dTri => Visualization/Tri}/README.md (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dTri => Visualization/Tri}/V3dTri.cpp (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dTri => Visualization/Tri}/V3dTri.h (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dTri => Visualization/Tri}/V3dTriCube.cpp (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dTri => Visualization/Tri}/V3dTriCube.h (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dTri => Visualization/Tri}/V3dWCSTri.cpp (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dTri => Visualization/Tri}/V3dWCSTri.h (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dView => Visualization/View}/V3dView.cpp (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dView => Visualization/View}/V3dView.h (96%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dViewer => Visualization/Viewer}/V3dViewer.cpp (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dViewer => Visualization/Viewer}/V3dViewer.h (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dWin => Visualization/Win}/V3dWin.cpp (100%) rename entry/src/main/cpp/NativeEGLOCCT/{V3d/V3dWin => Visualization/Win}/V3dWin.h (100%) create mode 100644 entry/src/main/ets/pages/EventHub/EventBase.ets create mode 100644 entry/src/main/ets/pages/EventHub/EventExecute.ets create mode 100644 entry/src/main/ets/pages/EventHub/EventPage.ets create mode 100644 entry/src/main/ets/pages/EventHub/XCompMgr.ets delete mode 100644 entry/src/main/ets/pages/EventSubWin/ExCom.ets delete mode 100644 entry/src/main/ets/pages/EventSubWin/SWBase.ets rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/File/FileInter.ets (100%) rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/File/FileStr.ets (100%) rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/File/SWExportFile.ets (100%) rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/File/SWImportFile.ets (100%) rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/File/SWNewFile.ets (68%) rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/File/SWOpenFile.ets (100%) rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/File/SWSaveAsFile.ets (100%) rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/Options.ets (100%) rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/Opts/OptFeature.ets (100%) rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/Opts/OptsInter.ets (100%) rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/Opts/OptsModeling.ets (100%) rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/Opts/OptsStr.ets (100%) rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/Opts/OptsSub.ets (100%) rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/Opts/OptsUser.ets (100%) rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/Opts/OptsUserLayout.ets (100%) rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/README.md (100%) create mode 100644 entry/src/main/ets/pages/SubWindow/SWBase.ets rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/SWExtrude.ets (100%) rename entry/src/main/ets/pages/{EventSubWin => SubWindow}/SWLine.ets (100%) diff --git a/entry/src/main/cpp/CMakeLists.txt b/entry/src/main/cpp/CMakeLists.txt index 6efb6869..50917c54 100644 --- a/entry/src/main/cpp/CMakeLists.txt +++ b/entry/src/main/cpp/CMakeLists.txt @@ -52,16 +52,16 @@ add_library(opencax SHARED NativeEGLOCCT/OCCTMgr/Render.h NativeEGLOCCT/OCCTMgr/RenderThread.h NativeEGLOCCT/NativeMgr.h - NativeEGLOCCT/V3d/V3dOGD/V3dOGD.h - NativeEGLOCCT/V3d/V3dViewer/V3dViewer.h - NativeEGLOCCT/V3d/V3dCtx/V3dCtx.h - NativeEGLOCCT/V3d/V3dView/V3dView.h - NativeEGLOCCT/V3d/V3dWin/V3dWin.h - NativeEGLOCCT/V3d/V3dCamera/V3dCamera.h - NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.h - NativeEGLOCCT/V3d/V3dTri/V3dTri.h - NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.h - NativeEGLOCCT/V3d/V3dTri/V3dTriCube.h + NativeEGLOCCT/Visualization/OGD/V3dOGD.h + NativeEGLOCCT/Visualization/Viewer/V3dViewer.h + NativeEGLOCCT/Visualization/Context/V3dCtx.h + NativeEGLOCCT/Visualization/View/V3dView.h + NativeEGLOCCT/Visualization/Win/V3dWin.h + NativeEGLOCCT/Visualization/Camera/V3dCamera.h + NativeEGLOCCT/Visualization/Drawer/V3dDrawer.h + NativeEGLOCCT/Visualization/Tri/V3dTri.h + NativeEGLOCCT/Visualization/Tri/V3dWCSTri.h + NativeEGLOCCT/Visualization/Tri/V3dTriCube.h # Cpp Src NativeEGLOCCT/EGLMgr/EGLCore.cpp @@ -70,17 +70,17 @@ add_library(opencax SHARED NativeEGLOCCT/OCCTMgr/Render.cpp NativeEGLOCCT/OCCTMgr/RenderThread.cpp NativeEGLOCCT/NativeMgr.cpp - NativeEGLOCCT/V3d/V3dOGD/V3dOGD.cpp - NativeEGLOCCT/V3d/V3dViewer/V3dViewer.cpp - NativeEGLOCCT/V3d/V3dCtx/V3dCtx.cpp - NativeEGLOCCT/V3d/V3dView/V3dView.cpp - NativeEGLOCCT/V3d/V3dCamera/V3dCamera.cpp - NativeEGLOCCT/V3d/V3dWin/V3dWin.cpp - NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.cpp - NativeEGLOCCT/V3d/V3dTri/V3dTri.cpp - NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.cpp - NativeEGLOCCT/V3d/V3dTri/V3dTriCube.cpp - ) + NativeEGLOCCT/Visualization/OGD/V3dOGD.cpp + NativeEGLOCCT/Visualization/Viewer/V3dViewer.cpp + NativeEGLOCCT/Visualization/Context/V3dCtx.cpp + NativeEGLOCCT/Visualization/View/V3dView.cpp + NativeEGLOCCT/Visualization/Camera/V3dCamera.cpp + NativeEGLOCCT/Visualization/Win/V3dWin.cpp + NativeEGLOCCT/Visualization/Drawer/V3dDrawer.cpp + NativeEGLOCCT/Visualization/Tri/V3dTri.cpp + NativeEGLOCCT/Visualization/Tri/V3dWCSTri.cpp + NativeEGLOCCT/Visualization/Tri/V3dTriCube.cpp + NativeEGLOCCT/ViewController/V3dViewController.h NativeEGLOCCT/ViewController/V3dViewController.cpp) # 查找系统库 diff --git a/entry/src/main/cpp/NativeEGLOCCT/OCCTMgr/Render.cpp b/entry/src/main/cpp/NativeEGLOCCT/OCCTMgr/Render.cpp index c5b7b8b8..c18d9863 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/OCCTMgr/Render.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/OCCTMgr/Render.cpp @@ -21,7 +21,8 @@ v3dOgd(new V3dOGD), v3dView(new V3dView), v3dDrawer(new V3dDrawer), v3dViewer(new V3dViewer), -v3dWin(new V3dWin) +v3dWin(new V3dWin), +v3dViewContr(new V3dViewController) { width = w; height = h; diff --git a/entry/src/main/cpp/NativeEGLOCCT/OCCTMgr/Render.h b/entry/src/main/cpp/NativeEGLOCCT/OCCTMgr/Render.h index 54eaed74..f9c7dfd5 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/OCCTMgr/Render.h +++ b/entry/src/main/cpp/NativeEGLOCCT/OCCTMgr/Render.h @@ -14,14 +14,15 @@ #include #include -#include "../V3d/V3dTri/V3dTri.h" -#include "../V3d/V3dTri/V3dTriCube.h" -#include "../V3d/V3dCamera/V3dCamera.h" -#include "../V3d/V3dCtx/V3dCtx.h" -#include "../V3d/V3dOGD/V3dOGD.h" -#include "../V3d/V3dWin/V3dWin.h" -#include "../V3d/V3dView/V3dView.h" -#include "../V3d/V3dViewer/V3dViewer.h" +#include "../Visualization/Tri/V3dTri.h" +#include "../Visualization/Tri/V3dTriCube.h" +#include "../Visualization/Camera/V3dCamera.h" +#include "../Visualization/Context/V3dCtx.h" +#include "../Visualization/OGD/V3dOGD.h" +#include "../Visualization/Win/V3dWin.h" +#include "../Visualization/View/V3dView.h" +#include "../Visualization/Viewer/V3dViewer.h" +#include "../ViewController/V3dViewController.h" //TextLabel_Dev #include namespace NativeOpenCAX { @@ -56,6 +57,7 @@ private: V3dView* v3dView; V3dViewer* v3dViewer; V3dWin* v3dWin; + V3dViewController* v3dViewContr; std::vector shapes_; }; } // namespace NativeRender diff --git a/entry/src/main/cpp/NativeEGLOCCT/ViewController/V3dViewController.cpp b/entry/src/main/cpp/NativeEGLOCCT/ViewController/V3dViewController.cpp new file mode 100644 index 00000000..998387de --- /dev/null +++ b/entry/src/main/cpp/NativeEGLOCCT/ViewController/V3dViewController.cpp @@ -0,0 +1,18 @@ +// +// Created on 2026/4/19. +// +// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found, +// please include "napi/native_api.h". + +#include "V3dViewController.h" +namespace NativeOpenCAX { + +V3dViewController::V3dViewController() +{ + +} +V3dViewController::~V3dViewController(){ + +} +} + diff --git a/entry/src/main/cpp/NativeEGLOCCT/ViewController/V3dViewController.h b/entry/src/main/cpp/NativeEGLOCCT/ViewController/V3dViewController.h new file mode 100644 index 00000000..7e3ab3c9 --- /dev/null +++ b/entry/src/main/cpp/NativeEGLOCCT/ViewController/V3dViewController.h @@ -0,0 +1,20 @@ +// +// Created on 2026/4/19. +// +// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found, +// please include "napi/native_api.h". + +#ifndef OPENCAX_V3DVIEWCONTROLLER_H +#define OPENCAX_V3DVIEWCONTROLLER_H +#include "AIS_ViewController.hxx" +namespace NativeOpenCAX { +class V3dViewController { +public: + V3dViewController(); + ~V3dViewController(); +private: + Handle(AIS_ViewController) viewController; +}; +} + +#endif //OPENCAX_V3DVIEWCONTROLLER_H diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCamera/README.md b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Camera/README.md similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCamera/README.md rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Camera/README.md diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCamera/V3dCamera.cpp b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Camera/V3dCamera.cpp similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCamera/V3dCamera.cpp rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Camera/V3dCamera.cpp diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCamera/V3dCamera.h b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Camera/V3dCamera.h similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCamera/V3dCamera.h rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Camera/V3dCamera.h diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCtx/V3dCtx.cpp b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Context/V3dCtx.cpp similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCtx/V3dCtx.cpp rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Context/V3dCtx.cpp diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCtx/V3dCtx.h b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Context/V3dCtx.h similarity index 94% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCtx/V3dCtx.h rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Context/V3dCtx.h index 57165d5a..8667e018 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCtx/V3dCtx.h +++ b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Context/V3dCtx.h @@ -12,7 +12,7 @@ #include -#include "../V3dDrawer/V3dDrawer.h" +#include "../Drawer/V3dDrawer.h" namespace NativeOpenCAX{ diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.cpp b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Drawer/V3dDrawer.cpp similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.cpp rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Drawer/V3dDrawer.cpp diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.h b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Drawer/V3dDrawer.h similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.h rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Drawer/V3dDrawer.h diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dOGD/V3dOGD.cpp b/entry/src/main/cpp/NativeEGLOCCT/Visualization/OGD/V3dOGD.cpp similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dOGD/V3dOGD.cpp rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/OGD/V3dOGD.cpp diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dOGD/V3dOGD.h b/entry/src/main/cpp/NativeEGLOCCT/Visualization/OGD/V3dOGD.h similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dOGD/V3dOGD.h rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/OGD/V3dOGD.h diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/README.md b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Tri/README.md similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/README.md rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Tri/README.md diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTri.cpp b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Tri/V3dTri.cpp similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTri.cpp rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Tri/V3dTri.cpp diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTri.h b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Tri/V3dTri.h similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTri.h rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Tri/V3dTri.h diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTriCube.cpp b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Tri/V3dTriCube.cpp similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTriCube.cpp rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Tri/V3dTriCube.cpp diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTriCube.h b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Tri/V3dTriCube.h similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTriCube.h rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Tri/V3dTriCube.h diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.cpp b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Tri/V3dWCSTri.cpp similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.cpp rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Tri/V3dWCSTri.cpp diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.h b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Tri/V3dWCSTri.h similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.h rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Tri/V3dWCSTri.h diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dView/V3dView.cpp b/entry/src/main/cpp/NativeEGLOCCT/Visualization/View/V3dView.cpp similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dView/V3dView.cpp rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/View/V3dView.cpp diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dView/V3dView.h b/entry/src/main/cpp/NativeEGLOCCT/Visualization/View/V3dView.h similarity index 96% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dView/V3dView.h rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/View/V3dView.h index 19ceebff..b6d15018 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dView/V3dView.h +++ b/entry/src/main/cpp/NativeEGLOCCT/Visualization/View/V3dView.h @@ -7,7 +7,7 @@ #ifndef OPENCAX_VIEW_H #define OPENCAX_VIEW_H -#include "../V3dCtx/V3dCtx.h" +#include "../Context/V3dCtx.h" #include "NativeEGLOCCT/common.h" #include #include diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dViewer/V3dViewer.cpp b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Viewer/V3dViewer.cpp similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dViewer/V3dViewer.cpp rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Viewer/V3dViewer.cpp diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dViewer/V3dViewer.h b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Viewer/V3dViewer.h similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dViewer/V3dViewer.h rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Viewer/V3dViewer.h diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dWin/V3dWin.cpp b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Win/V3dWin.cpp similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dWin/V3dWin.cpp rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Win/V3dWin.cpp diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dWin/V3dWin.h b/entry/src/main/cpp/NativeEGLOCCT/Visualization/Win/V3dWin.h similarity index 100% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/V3dWin/V3dWin.h rename to entry/src/main/cpp/NativeEGLOCCT/Visualization/Win/V3dWin.h diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 55cbdf9d..34c41d39 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -3,12 +3,10 @@ import { hilog } from '@kit.PerformanceAnalysisKit'; import { window, display, AppStorageV2, ColorMetrics } from '@kit.ArkUI'; import { IBestInit } from "@ibestservices/ibest-ui-v2" import {ExtractDir,CheckExistDir,HilogSadboxFontDirFile} from "../pages/ExtractDir/ExtractDir" -import {MainWindowStageInfo,InitGlobalDisplayWindowInfo,mwInfo, mwsInfo}from '../pages/DispWinInfo/DispWinInfo' +import {MainWindowStageInfo,InitGlobalDisplayWindowInfo,mwInfo}from '../pages/DispWinInfo/DispWinInfo' const DOMAIN = 0x0000; export default class EntryAbility extends UIAbility { - private mainWindow: window.Window | undefined; - private subWindow: window.Window | undefined = undefined; onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { //InitFont->Copy Res/resfile/font to sandbox @@ -64,12 +62,12 @@ export default class EntryAbility extends UIAbility { console.error(`Failed to obtain the main window. Code: ${err.code}, message: ${err.message}`); return; } - this.mainWindow = data; - mwInfo.id = this.mainWindow.getWindowProperties().id; + mwInfo.mainWin = data; + mwInfo.id =data.getWindowProperties().id; //moveWindowTo - this.mainWindow.moveWindowTo(50, 50) + data.moveWindowTo(50, 50) //resize mainWindow Size - this.mainWindow.resize(mwInfo.width, mwInfo.height, (err) => { + data.resize(mwInfo.width, mwInfo.height, (err) => { if (err.code) { console.error(`Failed to resize the window. Code: ${err.code}, message: ${err.message}`); return; @@ -78,7 +76,7 @@ export default class EntryAbility extends UIAbility { }); // windowSizeChangeListener to Change mainWindowWidth&&mainWindowHeight in AppStorage - this.mainWindow.on('windowSizeChange', (ChangeData) => { + data.on('windowSizeChange', (ChangeData) => { // if Size Change save to AppStorage mwInfo.width = ChangeData.width; mwInfo.height = ChangeData.height; @@ -87,8 +85,8 @@ export default class EntryAbility extends UIAbility { }); let color: string = '#00000000'; try { - this.mainWindow.setWindowBackgroundColor(color); - this.mainWindow.setWindowShadowEnabled(true); + data.setWindowBackgroundColor(color); + data.setWindowShadowEnabled(true); } catch (exception) { console.error(`Failed to set the background color. Cause code: ${exception.code}, message: ${exception.message}`); }; @@ -97,8 +95,8 @@ export default class EntryAbility extends UIAbility { onWindowStageDestroy(): void { AppStorageV2.remove(MainWindowStageInfo); - if (this.mainWindow) { - this.mainWindow = undefined; + if (mwInfo.mainWin) { + mwInfo.mainWin = undefined; } // Main window is destroyed, release UI related resources hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); diff --git a/entry/src/main/ets/pages/CustomController/Button.ets b/entry/src/main/ets/pages/CustomController/Button.ets index d3ff6d76..1b2a4d4f 100644 --- a/entry/src/main/ets/pages/CustomController/Button.ets +++ b/entry/src/main/ets/pages/CustomController/Button.ets @@ -1,5 +1,5 @@ import { hilog } from '@kit.PerformanceAnalysisKit'; -import { Execute } from '../EventSubWin/ExCom'; +import { Execute } from '../EventHub/EventBase'; import { TitleButton } from "../LayoutInterface/Interface/ButtonInterface"; import { TitleModel } from "../LayoutInterface/Interface/ModelInterface"; import { TitleTabData } from '../LayoutInterface/Layout/TitleTabData'; diff --git a/entry/src/main/ets/pages/CustomController/Dialog.ets b/entry/src/main/ets/pages/CustomController/Dialog.ets index 8caf1951..1ac81241 100644 --- a/entry/src/main/ets/pages/CustomController/Dialog.ets +++ b/entry/src/main/ets/pages/CustomController/Dialog.ets @@ -1,5 +1,5 @@ import { mwInfo } from '../DispWinInfo/DispWinInfo' -import { Execute } from "../EventSubWin/ExCom"; +import { Execute } from "../EventHub/EventBase"; import { TitleButton } from "../LayoutInterface/Interface/ButtonInterface"; import {SwitchView} from "../LayoutInterface/Layout/SwitchView" diff --git a/entry/src/main/ets/pages/CustomController/Menu.ets b/entry/src/main/ets/pages/CustomController/Menu.ets index 1e66ced4..14da6331 100644 --- a/entry/src/main/ets/pages/CustomController/Menu.ets +++ b/entry/src/main/ets/pages/CustomController/Menu.ets @@ -1,6 +1,6 @@ import { TitleGroup } from "../LayoutInterface/Interface/GroupInterface"; import { TitleButton } from "../LayoutInterface/Interface/ButtonInterface"; -import { Execute } from "../EventSubWin/ExCom"; +import { Execute } from "../EventHub/EventBase"; import { mwInfo } from '../DispWinInfo/DispWinInfo' import { BaseMenuData } from "../LayoutInterface/Interface/MenuInterface"; diff --git a/entry/src/main/ets/pages/DispWinInfo/DispWinInfo.ets b/entry/src/main/ets/pages/DispWinInfo/DispWinInfo.ets index 9d900b27..fd45a37a 100644 --- a/entry/src/main/ets/pages/DispWinInfo/DispWinInfo.ets +++ b/entry/src/main/ets/pages/DispWinInfo/DispWinInfo.ets @@ -1,7 +1,7 @@ -import { AppStorageV2, display,window} from '@kit.ArkUI'; +import { AppStorageV2, display,window ,UIContext} from '@kit.ArkUI'; + //该文档主要储存屏幕信息,主窗口信息,窗口管理信息 //底部有全局信息变量,已导出,其他page只需要import该文件即可调用let变量 - @ObservedV2 export class MainDisplayInfo { @Trace public id: number; @@ -18,23 +18,24 @@ export class MainDisplayInfo { @ObservedV2 export class MainWindowInfo { @Trace public id: number; + @Trace public mainWin: window.Window|undefined; @Trace public width: number; @Trace public height: number; - constructor(_id?:number,_width?: number, _height?: number) { + constructor(_id?:number,_mainWin?:window.Window,_width?: number, _height?: number) { this.id = _width ?? 0; + this.mainWin=_mainWin ?? undefined; this.width = _height ?? 0; - this.height=_id?? 0; + this.height=_id ?? 0; } } @ObservedV2 export class MainWindowStageInfo { - @Trace public winStage: window.WindowStage| undefined; - + @Trace public winStage?: window.WindowStage; constructor(_ws?: window.WindowStage) { - this.winStage = _ws ?? undefined; + this.winStage = _ws; } } @@ -45,8 +46,10 @@ export async function InitGlobalDisplayWindowInfo(windowStage: window.WindowStag mainDisplayInfo.id = display.getDefaultDisplaySync().id; mainDisplayInfo.width = display.getDefaultDisplaySync().width; mainDisplayInfo.height = display.getDefaultDisplaySync().height; + mainWindowInfo.width = mainDisplayInfo.width-100; mainWindowInfo.height = mainDisplayInfo.height-200; + mainWindowStage.winStage = windowStage; console.error(`Display Size:`,mainDisplayInfo.width,mainDisplayInfo.height); console.error(`MainWindow Size:`,mainWindowInfo.width,mainWindowInfo.height); diff --git a/entry/src/main/ets/pages/EventHub/EventBase.ets b/entry/src/main/ets/pages/EventHub/EventBase.ets new file mode 100644 index 00000000..2cbd6de5 --- /dev/null +++ b/entry/src/main/ets/pages/EventHub/EventBase.ets @@ -0,0 +1,41 @@ +import { TitleButton } from '../LayoutInterface/Interface/ButtonInterface'; +import { EventType } from '../LayoutInterface/Interface/BaseTypeInterface' +import {EventExecute} from './EventExecute' +import {EventPage} from './EventPage' + +//执行事件 +export function Execute(event:TitleButton){ + if(event.btnEvent.type==EventType.EVENT){ + EventExecute(event); + }else{ + EventPage(event); + } +} +//随机ID +export function RndId(): string { + // 获取当前时间戳(毫秒) + const now = Date.now(); + // 取时间戳的最后几位(例如4位)作为基础部分 + const timePart = parseInt(now.toString().slice(-4)); + // 生成剩余的4位随机数 + const randomPart = Math.floor(Math.random() * 10000); + // 组合两部分,并取模和偏移以确保在8位数范围内 + // 例如: timePart (0-9999) + randomPart (0-9999) -> sum (0-19998) + // 需要将其映射到 [10000000, 99999999] + // 结果在 [0, 89999999] + const combined = (timePart * 10000 + randomPart) % 90000000; + // 调整范围到 [10000000, 99999999] + return (combined + 10000000).toString(); +} +//当前时间 +export function CurrentTime():string { + let now = new Date(); + // 格式化时间字符串 + let year = now.getFullYear().toString(); + let month = (now.getMonth() + 1).toString().padStart(2, '0'); // padStart 确保月份是两位数 + let date = now.getDate().toString().padStart(2, '0'); + let hours = now.getHours().toString().padStart(2, '0'); + let minutes = now.getMinutes().toString().padStart(2, '0'); + let seconds = now.getSeconds().toString().padStart(2, '0'); + return`${year}-${month}-${date} ${hours}:${minutes}:${seconds}`; +} diff --git a/entry/src/main/ets/pages/EventHub/EventExecute.ets b/entry/src/main/ets/pages/EventHub/EventExecute.ets new file mode 100644 index 00000000..c430a2c7 --- /dev/null +++ b/entry/src/main/ets/pages/EventHub/EventExecute.ets @@ -0,0 +1,31 @@ +import { TitleButton } from '../LayoutInterface/Interface/ButtonInterface'; +import { CreateXCompNode } from './XCompMgr'; +import NativeOpenCAX from 'libopencax.so'; +//事件类型:纯指令 +export function EventExecute(event:TitleButton){ + //事件处理 + if(event?.btnEvent.command=='Execute_LoadModel'){ + NativeOpenCAX.loadModel("/data/storage/el2/base/haps/entry/files/example/2027.stp"); + } + if(event?.btnEvent.command=='Create_New'){ + CreateXCompNode(""); + } + //视图切换 + if(event?.btnEvent.command=='CMD_VIEW_FRONT'){ + NativeOpenCAX.switchView("CMD_VIEW_FRONT"); + }else if(event?.btnEvent.command=='CMD_VIEW_TOP'){ + NativeOpenCAX.switchView("CMD_VIEW_TOP"); + }else if(event?.btnEvent.command=='CMD_VIEW_LEFT_SIDE'){ + NativeOpenCAX.switchView("CMD_VIEW_LEFT_SIDE"); + }else if(event?.btnEvent.command=='CMD_VIEW_RIGHT_SIDE'){ + NativeOpenCAX.switchView("CMD_VIEW_RIGHT_SIDE"); + }else if(event?.btnEvent.command=='CMD_VIEW_BOTTOM'){ + NativeOpenCAX.switchView("CMD_VIEW_BOTTOM"); + }else if(event?.btnEvent.command=='CMD_VIEW_REAR'){ + NativeOpenCAX.switchView("CMD_VIEW_REAR"); + }else if(event?.btnEvent.command=='CMD_VIEW_ISO'){ + NativeOpenCAX.switchView("CMD_VIEW_ISO"); + }else if(event?.btnEvent.command=='CMD_VIEW_DIM'){ + NativeOpenCAX.switchView("CMD_VIEW_DIM"); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/EventHub/EventPage.ets b/entry/src/main/ets/pages/EventHub/EventPage.ets new file mode 100644 index 00000000..3e217a8b --- /dev/null +++ b/entry/src/main/ets/pages/EventHub/EventPage.ets @@ -0,0 +1,38 @@ +import { mwInfo } from '../DispWinInfo/DispWinInfo'; +import { CloseSubWindow, CreateAndShowSubWindow, SubWinInfo } from '../SubWindow/SWBase'; +import { TitleButton } from '../LayoutInterface/Interface/ButtonInterface'; +//事件类型:页面 +export function EventPage(event:TitleButton){ + //打开文件 + if(event?.btnEvent.command=='Execute_OpenFile') { + const winInfo: SubWinInfo = new SubWinInfo(event.btnName, event.btnEvent.page, mwInfo.width * 0.5, mwInfo.height * 0.3); + CreateAndShowSubWindow(winInfo); + } + //窗体打开 + if(event?.btnEvent.command=='Execute_CreateSubWindow'){ + const winInfo:SubWinInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.3,mwInfo.height*0.9); + CreateAndShowSubWindow(winInfo); + }else if(event?.btnEvent.command=='Execute_ExitSubWindow'){ + CloseSubWindow(); + } else if(event?.btnEvent.command=='Execute_CreateSubWindow_Options'){ + const winInfo:SubWinInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.6,mwInfo.height*0.9); + CreateAndShowSubWindow(winInfo); + } else if(event?.btnEvent.command=='Execute_NewFileWindow'){ + const winInfo:SubWinInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.4,mwInfo.height*0.4); + CreateAndShowSubWindow(winInfo); + }else if(event?.btnEvent.command=='Execute_SaveAsFileWindow'){ + const winInfo:SubWinInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.4,mwInfo.height*0.4); + CreateAndShowSubWindow(winInfo); + }else if(event?.btnEvent.command=='Execute_ImportFileWindow'){ + const winInfo:SubWinInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.4,mwInfo.height*0.4); + CreateAndShowSubWindow(winInfo); + }else if(event?.btnEvent.command=='Execute_ExportFileWindow'){ + const winInfo:SubWinInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.4,mwInfo.height*0.4); + CreateAndShowSubWindow(winInfo); + } else if(event?.btnEvent.command=='Open_NewModel'){ + const winInfo:SubWinInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.6,mwInfo.height*0.9); + CreateAndShowSubWindow(winInfo); + } else if(event?.btnEvent.command=='Execute_ExitSubWindow_Options'){ + CloseSubWindow(); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/EventHub/XCompMgr.ets b/entry/src/main/ets/pages/EventHub/XCompMgr.ets new file mode 100644 index 00000000..6a076ae5 --- /dev/null +++ b/entry/src/main/ets/pages/EventHub/XCompMgr.ets @@ -0,0 +1,67 @@ +import { AppStorageV2, NodeContent } from "@kit.ArkUI"; +import {RndId} from './EventBase' +import NativeOpenCAX from 'libopencax.so'; + +@ObservedV2 +export class XCompInfo{ + @Trace nId?:string; + @Trace xId?:string; + @Trace name?:string; + @Trace icon?:string; + @Trace node?:NodeContent; + constructor(_nId?:string,_xId?: string, _name?: string,_icon?:string,_node?:NodeContent) { + this.nId = _nId ?? undefined; + this.xId = _xId ?? undefined; + this.name=_name?? undefined; + this.icon=_icon?? undefined; + this.node=_node?? undefined; + } +} + +@ObservedV2 +export class XCompInfos{ + @Trace infos?:Array; + constructor(_infos?:Array) { + this.infos = _infos ?? undefined; + } +} + +export let xcInfos:XCompInfos = AppStorageV2.connect(XCompInfos, () => new XCompInfos)!; +export let ctInfo: XCompInfo = AppStorageV2.connect(XCompInfo, () => new XCompInfo)!; + + +//初始化全局XComp管理 +export function InitXCompNode(){ + //数组为0表示初始化,Native侧这初始化主上下文,否则Native侧初始化共享上下文 + const xcIs:XCompInfos = AppStorageV2.connect(XCompInfos, () => new XCompInfos)!; + xcIs.infos=new Array; +} + +//创建XComp组件 +export function CreateXCompNode(name:string){ + const xcIs:XCompInfos = AppStorageV2.connect(XCompInfos, () => new XCompInfos)!; + let xInfo:XCompInfo=new XCompInfo; + let initType:boolean=true; + xInfo.nId='n_'+RndId(); + xInfo.xId='x_'+RndId(); + xInfo.name=name+xInfo.xId; + xInfo.node=new NodeContent(); + + if((xcIs.infos as Array).length>0) + { + initType=true; + }else{ + initType=false; + } + NativeOpenCAX.InitNativeNode(xInfo.nId,xInfo.xId,initType,xInfo.node); + (xcIs.infos as Array).push(xInfo); + console.log(`ArkUI Node ID: ${xInfo.nId}`); + console.log(`ArkUI XComp ID: ${xInfo.xId}`); +} +//获取当前XComp组件 +export function CurrentXCompIndex(id:number):XCompInfo{ + const xcIs:XCompInfos = AppStorageV2.connect(XCompInfos, () => new XCompInfos)!; + return ctInfo=(xcIs.infos as Array)[id]; +} + + diff --git a/entry/src/main/ets/pages/EventSubWin/ExCom.ets b/entry/src/main/ets/pages/EventSubWin/ExCom.ets deleted file mode 100644 index 96670f8a..00000000 --- a/entry/src/main/ets/pages/EventSubWin/ExCom.ets +++ /dev/null @@ -1,152 +0,0 @@ -import { TitleButton } from '../LayoutInterface/Interface/ButtonInterface'; -import { CloseSubWindow, CreateAndShowSubWindow, WinInfo} from './SWBase'; -import NativeOpenCAX from 'libopencax.so'; -import { mwInfo } from '../DispWinInfo/DispWinInfo' -import { AppStorageV2, NodeContent} from '@kit.ArkUI'; -import { ModelViewTab } from '../ModelViewTab'; -import {EventType} from '../LayoutInterface/Interface/BaseTypeInterface' - -@ObservedV2 -export class XCompInfo{ - @Trace nId?:string; - @Trace xId?:string; - @Trace name?:string; - @Trace icon?:string; - @Trace node?:NodeContent; - constructor(_nId?:string,_xId?: string, _name?: string,_icon?:string,_node?:NodeContent) { - this.nId = _nId ?? undefined; - this.xId = _xId ?? undefined; - this.name=_name?? undefined; - this.icon=_icon?? undefined; - this.node=_node?? undefined; - } -} - -@ObservedV2 -export class XCompInfos{ - @Trace infos?:Array; - constructor(_infos?:Array) { - this.infos = _infos ?? undefined; - } -} - -export let xcInfos:XCompInfos = AppStorageV2.connect(XCompInfos, () => new XCompInfos)!; -export let ctInfo: XCompInfo = AppStorageV2.connect(XCompInfo, () => new XCompInfo)!; - -export function XNRandomId(): string { - // 获取当前时间戳(毫秒) - const now = Date.now(); - // 取时间戳的最后几位(例如4位)作为基础部分 - const timePart = parseInt(now.toString().slice(-4)); - // 生成剩余的4位随机数 - const randomPart = Math.floor(Math.random() * 10000); - // 组合两部分,并取模和偏移以确保在8位数范围内 - // 例如: timePart (0-9999) + randomPart (0-9999) -> sum (0-19998) - // 需要将其映射到 [10000000, 99999999] - // 结果在 [0, 89999999] - const combined = (timePart * 10000 + randomPart) % 90000000; - // 调整范围到 [10000000, 99999999] - return (combined + 10000000).toString(); -} -//初始化全局XComp管理 -export function InitXCompNode(){ - //数组为0表示初始化,Native侧这初始化主上下文,否则Native侧初始化共享上下文 - const xcIs:XCompInfos = AppStorageV2.connect(XCompInfos, () => new XCompInfos)!; - xcIs.infos=new Array; -} -//创建XComp组件 -export function CreateXCompNode(name:string){ - const xcIs:XCompInfos = AppStorageV2.connect(XCompInfos, () => new XCompInfos)!; - let xInfo:XCompInfo=new XCompInfo; - xInfo.nId='n_'+XNRandomId(); - xInfo.xId='x_'+XNRandomId(); - xInfo.name=name+xInfo.xId; - xInfo.node=new NodeContent(); - if((xcIs.infos as Array).length>0) - { - NativeOpenCAX.InitNativeNode(xInfo.nId,xInfo.xId,true,xInfo.node); - }else{ - NativeOpenCAX.InitNativeNode(xInfo.nId,xInfo.xId,false,xInfo.node); - } - (xcIs.infos as Array).push(xInfo); - console.log(`ArkUI Node ID: ${xInfo.nId}`); - console.log(`ArkUI XComp ID: ${xInfo.xId}`); -} -//获取当前XComp组件 -export function CurrentXCompIndex(id:number):XCompInfo{ - const xcIs:XCompInfos = AppStorageV2.connect(XCompInfos, () => new XCompInfos)!; - return ctInfo=(xcIs.infos as Array)[id]; -} - -//执行事件 -export function Execute(event:TitleButton){ - if(event.btnEvent.type==EventType.EVENT){ - ExecuteCommand(event); - }else{ - ExecutePage(event); - } -} -//事件类型:页面 -export function ExecutePage(event:TitleButton){ - //打开文件 - if(event?.btnEvent.command=='Execute_OpenFile') { - const winInfo: WinInfo = new WinInfo(event.btnName, event.btnEvent.page, mwInfo.width * 0.5, mwInfo.height * 0.3); - CreateAndShowSubWindow(winInfo); - } - //窗体打开 - if(event?.btnEvent.command=='Execute_CreateSubWindow'){ - const winInfo:WinInfo=new WinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.3,mwInfo.height*0.9); - CreateAndShowSubWindow(winInfo); - }else if(event?.btnEvent.command=='Execute_ExitSubWindow'){ - CloseSubWindow(); - } else if(event?.btnEvent.command=='Execute_CreateSubWindow_Options'){ - const winInfo:WinInfo=new WinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.6,mwInfo.height*0.9); - CreateAndShowSubWindow(winInfo); - } else if(event?.btnEvent.command=='Execute_NewFileWindow'){ - const winInfo:WinInfo=new WinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.4,mwInfo.height*0.4); - CreateAndShowSubWindow(winInfo); - }else if(event?.btnEvent.command=='Execute_SaveAsFileWindow'){ - const winInfo:WinInfo=new WinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.4,mwInfo.height*0.4); - CreateAndShowSubWindow(winInfo); - }else if(event?.btnEvent.command=='Execute_ImportFileWindow'){ - const winInfo:WinInfo=new WinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.4,mwInfo.height*0.4); - CreateAndShowSubWindow(winInfo); - }else if(event?.btnEvent.command=='Execute_ExportFileWindow'){ - const winInfo:WinInfo=new WinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.4,mwInfo.height*0.4); - CreateAndShowSubWindow(winInfo); - } else if(event?.btnEvent.command=='Open_NewModel'){ - const winInfo:WinInfo=new WinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.6,mwInfo.height*0.9); - CreateAndShowSubWindow(winInfo); - } else if(event?.btnEvent.command=='Execute_ExitSubWindow_Options'){ - CloseSubWindow(); - } -} -//事件类型:纯指令 -export function ExecuteCommand(event:TitleButton){ - - //事件处理 - if(event?.btnEvent.command=='Execute_LoadModel'){ - NativeOpenCAX.loadModel("/data/storage/el2/base/haps/entry/files/example/2027.stp"); - } - if(event?.btnEvent.command=='Create_New'){ - CreateXCompNode(""); - } - //视图切换 - if(event?.btnEvent.command=='CMD_VIEW_FRONT'){ - NativeOpenCAX.switchView("CMD_VIEW_FRONT"); - }else if(event?.btnEvent.command=='CMD_VIEW_TOP'){ - NativeOpenCAX.switchView("CMD_VIEW_TOP"); - }else if(event?.btnEvent.command=='CMD_VIEW_LEFT_SIDE'){ - NativeOpenCAX.switchView("CMD_VIEW_LEFT_SIDE"); - }else if(event?.btnEvent.command=='CMD_VIEW_RIGHT_SIDE'){ - NativeOpenCAX.switchView("CMD_VIEW_RIGHT_SIDE"); - }else if(event?.btnEvent.command=='CMD_VIEW_BOTTOM'){ - NativeOpenCAX.switchView("CMD_VIEW_BOTTOM"); - }else if(event?.btnEvent.command=='CMD_VIEW_REAR'){ - NativeOpenCAX.switchView("CMD_VIEW_REAR"); - }else if(event?.btnEvent.command=='CMD_VIEW_ISO'){ - NativeOpenCAX.switchView("CMD_VIEW_ISO"); - }else if(event?.btnEvent.command=='CMD_VIEW_DIM'){ - NativeOpenCAX.switchView("CMD_VIEW_DIM"); - } -} \ No newline at end of file diff --git a/entry/src/main/ets/pages/EventSubWin/SWBase.ets b/entry/src/main/ets/pages/EventSubWin/SWBase.ets deleted file mode 100644 index 47fad6d5..00000000 --- a/entry/src/main/ets/pages/EventSubWin/SWBase.ets +++ /dev/null @@ -1,71 +0,0 @@ -import { BusinessError } from '@kit.BasicServicesKit'; -import { window} from '@kit.ArkUI'; -import { mwInfo, mwsInfo } from '../DispWinInfo/DispWinInfo' -let subWindow: window.Window | undefined = undefined; - -export class WinInfo{ - name:string|undefined=undefined; - page:string|undefined=undefined; - width:number=0; - height:number=0; - constructor(name?: string, page?: string,width?: number,height?: number) { - this.name = name??undefined; - this.page = page ?? undefined; - this.width = width ?? 0; - this.height = height ?? 0; - } -} - -export async function CreateAndShowSubWindow(winInfo:WinInfo) { - try { - if(mwsInfo.winStage==null){ - console.error('Failed to create the subwindow. Cause: windowStage is null'); - return; - } - let options: window.SubWindowOptions = { - title: winInfo.name as string, - decorEnabled: true, - isModal: false, - maximizeSupported: false, - outlineEnabled:true, - }; - - console.info('SubWindow Size:',winInfo.width,winInfo.height) - await mwsInfo.winStage.createSubWindowWithOptions('subWindow', options).then((data) => { - subWindow = data; - //子窗口创建成功后,设置子窗口的位置、大小及相关属性等。 - subWindow.moveWindowTo(200, 200) - //子窗口重置大小 - console.info("页面路径:", winInfo.page); - subWindow.resize(winInfo.width,winInfo.height); - subWindow.setUIContent(winInfo.page, (err: BusinessError) => { - if (err.code) { - console.error("加载页面失败:", err); - return; - } - }) - // 显示窗口 - subWindow.showWindow((err) => { - if (err.code) { - console.error("显示窗口失败:", err); - } - }); - subWindow.setResizeByDragEnabled(false); - }) - } catch (error) { - console.error('Failed to create or show sub window:', (error as BusinessError).message); - } -} - -export function CloseSubWindow() { - if (subWindow) { - try { - subWindow.destroy(); - subWindow = undefined; - console.info('Sub window closed.'); - } catch (error) { - console.error('Failed to close sub window:', (error as BusinessError).message); - } - } -} - diff --git a/entry/src/main/ets/pages/LayoutInterface/Layout/MatrixModel.ets b/entry/src/main/ets/pages/LayoutInterface/Layout/MatrixModel.ets index e7efaf30..e110284c 100644 --- a/entry/src/main/ets/pages/LayoutInterface/Layout/MatrixModel.ets +++ b/entry/src/main/ets/pages/LayoutInterface/Layout/MatrixModel.ets @@ -20,7 +20,7 @@ export let DevModel:TitleModel= { {btnModel:[ModelType.BASE],btnName:'新建建模实例',btnNamed:'',btnIcon:'base_new_file',btnTips:'新建建模实例',btnEvent:{uid:'',command:'Create_New',page:'',type:EventType.EVENT,args:[]}}, [ {btnModel:[ModelType.BASE],btnName:'加载模型',btnNamed:'',btnIcon:'base_new_file',btnTips:'加载模型',btnEvent:{uid:'',command:'Execute_LoadModel',type:EventType.EVENT,args:[]}}, - {btnModel:[ModelType.BASE],btnName:'选择加载模型',btnNamed:'',btnIcon:'base_new_file',btnTips:'选择加载模型',btnEvent:{uid:'',command:'Execute_OpenFile',page:'pages/EventSubWin/File/SWOpenFile',type:EventType.PAGE,args:[]}}, + {btnModel:[ModelType.BASE],btnName:'选择加载模型',btnNamed:'',btnIcon:'base_new_file',btnTips:'选择加载模型',btnEvent:{uid:'',command:'Execute_OpenFile',page:'pages/SubWindow/File/SWOpenFile',type:EventType.PAGE,args:[]}}, ], [ {btnModel:[ModelType.BASE],btnName:'正等轴测图',btnNamed:'',btnIcon:'base_new_file',btnTips:'正等轴测图',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}}, @@ -33,14 +33,14 @@ export let DevModel:TitleModel= { {btnModel:[ModelType.BASE],btnName:'仰视图',btnNamed:'',btnIcon:'base_new_file',btnTips:'仰视图',btnEvent:{uid:'',command:'CMD_VIEW_BOTTOM',page:'',type:EventType.EVENT,args:[]}}, ], [ - {btnModel:[ModelType.BASE],btnName:'创建文件',btnNamed:'',btnIcon:'base_new_file',btnTips:'创建文件',btnEvent:{uid:'',command:'Execute_NewFileWindow',page:'pages/EventSubWin/File/SWNewFile',type:EventType.PAGE,args:[]}}, - {btnModel:[ModelType.BASE],btnName:'另存为',btnNamed:'',btnIcon:'base_new_file',btnTips:'另存为',btnEvent:{uid:'',command:'Execute_SaveAsFileWindow',page:'pages/EventSubWin/File/SWSaveAsFile',type:EventType.PAGE,args:[]}}, - {btnModel:[ModelType.BASE],btnName:'导入文件',btnNamed:'',btnIcon:'base_new_file',btnTips:'导入文件',btnEvent:{uid:'',command:'Execute_ImportFileWindow',page:'pages/EventSubWin/File/SWImportFile',type:EventType.PAGE,args:[]}}, - {btnModel:[ModelType.BASE],btnName:'导出文件',btnNamed:'',btnIcon:'base_new_file',btnTips:'导出文件',btnEvent:{uid:'',command:'Execute_ExportFileWindow',page:'pages/EventSubWin/File/SWExportFile',type:EventType.PAGE,args:[]}}, - {btnModel:[ModelType.BASE],btnName:'创建子窗体',btnNamed:'',btnIcon:'base_new_file',btnTips:'创建子窗体',btnEvent:{uid:'',command:'Execute_CreateSubWindow',page:'pages/EventSubWin/SWExtrude',type:EventType.PAGE,args:[]}}, - {btnModel:[ModelType.BASE],btnName:'关闭子窗体',btnNamed:'',btnIcon:'base_new_file',btnTips:'关闭子窗体',btnEvent:{uid:'',command:'Execute_ExitSubWindow',page:'pages/EventSubWin/SWExtrude',type:EventType.PAGE,args:[]}}, - {btnModel:[ModelType.BASE],btnName:'首选项',btnNamed:'',btnIcon:'base_new_file',btnTips:'首选项',btnEvent:{uid:'',command:'Execute_CreateSubWindow_Options',page:'pages/EventSubWin/Options',type:EventType.PAGE,args:[]}}, - {btnModel:[ModelType.BASE],btnName:'关闭',btnNamed:'',btnIcon:'base_new_file',btnTips:'关闭',btnEvent:{uid:'',command:'Execute_ExitSubWindow_Options',page:'pages/EventSubWin/Options',type:EventType.PAGE,args:[]}}, + {btnModel:[ModelType.BASE],btnName:'创建文件',btnNamed:'',btnIcon:'base_new_file',btnTips:'创建文件',btnEvent:{uid:'',command:'Execute_NewFileWindow',page:'pages/SubWindow/File/SWNewFile',type:EventType.PAGE,args:[]}}, + {btnModel:[ModelType.BASE],btnName:'另存为',btnNamed:'',btnIcon:'base_new_file',btnTips:'另存为',btnEvent:{uid:'',command:'Execute_SaveAsFileWindow',page:'pages/SubWindow/File/SWSaveAsFile',type:EventType.PAGE,args:[]}}, + {btnModel:[ModelType.BASE],btnName:'导入文件',btnNamed:'',btnIcon:'base_new_file',btnTips:'导入文件',btnEvent:{uid:'',command:'Execute_ImportFileWindow',page:'pages/SubWindow/File/SWImportFile',type:EventType.PAGE,args:[]}}, + {btnModel:[ModelType.BASE],btnName:'导出文件',btnNamed:'',btnIcon:'base_new_file',btnTips:'导出文件',btnEvent:{uid:'',command:'Execute_ExportFileWindow',page:'pages/SubWindow/File/SWExportFile',type:EventType.PAGE,args:[]}}, + {btnModel:[ModelType.BASE],btnName:'创建子窗体',btnNamed:'',btnIcon:'base_new_file',btnTips:'创建子窗体',btnEvent:{uid:'',command:'Execute_CreateSubWindow',page:'pages/SubWindow/SWExtrude',type:EventType.PAGE,args:[]}}, + {btnModel:[ModelType.BASE],btnName:'关闭子窗体',btnNamed:'',btnIcon:'base_new_file',btnTips:'关闭子窗体',btnEvent:{uid:'',command:'Execute_ExitSubWindow',page:'pages/SubWindow/SWExtrude',type:EventType.PAGE,args:[]}}, + {btnModel:[ModelType.BASE],btnName:'首选项',btnNamed:'',btnIcon:'base_new_file',btnTips:'首选项',btnEvent:{uid:'',command:'Execute_CreateSubWindow_Options',page:'pages/SubWindow/Options',type:EventType.PAGE,args:[]}}, + {btnModel:[ModelType.BASE],btnName:'关闭',btnNamed:'',btnIcon:'base_new_file',btnTips:'关闭',btnEvent:{uid:'',command:'Execute_ExitSubWindow_Options',page:'pages/SubWindow/Options',type:EventType.PAGE,args:[]}}, ] ],grpMenu:GroupActionMenu}] as Array diff --git a/entry/src/main/ets/pages/LayoutInterface/Layout/TitleDefaultBars.ets b/entry/src/main/ets/pages/LayoutInterface/Layout/TitleDefaultBars.ets index 455970b4..b907d6b1 100644 --- a/entry/src/main/ets/pages/LayoutInterface/Layout/TitleDefaultBars.ets +++ b/entry/src/main/ets/pages/LayoutInterface/Layout/TitleDefaultBars.ets @@ -10,17 +10,17 @@ export let TitleDefaultBars:Array= {cmName:'主页',cmPage:'',cmTips:'',cmEvents: [[[{ grpName:'文件', grpBtn: [ - {btnModel:[ModelType.BASE],btnName:'新建',btnNamed:'',btnIcon:'base_new_file',btnTips:'新建',btnEvent:{uid:'',command:'Execute_NewFileWindow',page:'pages/EventSubWin/File/SWNewFile',type:EventType.PAGE,args:[]}}, - {btnModel:[ModelType.BASE],btnName:'打开',btnNamed:'',btnIcon:'base_open_file',btnTips:'打开',btnEvent:{uid:'',command:'Execute_OpenFile',page:'pages/EventSubWin/File/SWOpenFile',type:EventType.PAGE,args:[]}}, + {btnModel:[ModelType.BASE],btnName:'新建',btnNamed:'',btnIcon:'base_new_file',btnTips:'新建',btnEvent:{uid:'',command:'Execute_NewFileWindow',page:'pages/SubWindow/File/SWNewFile',type:EventType.PAGE,args:[]}}, + {btnModel:[ModelType.BASE],btnName:'打开',btnNamed:'',btnIcon:'base_open_file',btnTips:'打开',btnEvent:{uid:'',command:'Execute_OpenFile',page:'pages/SubWindow/File/SWOpenFile',type:EventType.PAGE,args:[]}}, [ {btnModel:[ModelType.BASE],btnName:'保存',btnNamed:'',btnIcon:'base_save_file',btnTips:'保存',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}}, - {btnModel:[ModelType.BASE],btnName:'另存为',btnNamed:'',btnIcon:'base_saveas_file',btnTips:'另存为',btnEvent:{uid:'',command:'Execute_SaveAsFileWindow',page:'pages/EventSubWin/File/SWSaveAsFile',type:EventType.EVENT,args:[]}}, + {btnModel:[ModelType.BASE],btnName:'另存为',btnNamed:'',btnIcon:'base_saveas_file',btnTips:'另存为',btnEvent:{uid:'',command:'Execute_SaveAsFileWindow',page:'pages/SubWindow/File/SWSaveAsFile',type:EventType.EVENT,args:[]}}, {btnModel:[ModelType.BASE],btnName:'保存全部',btnNamed:'',btnIcon:'base_saveall_file',btnTips:'保存全部',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}}, ] as Array, {btnModel:[ModelType.BASE],btnName:'关闭',btnNamed:'',btnIcon:'base_close_file',btnTips:'关闭',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}}, - {btnModel:[ModelType.BASE],btnName:'导入',btnNamed:'',btnIcon:'base_import_file',btnTips:'导入',btnEvent:{uid:'',command:'Execute_ImportFileWindow',page:'pages/EventSubWin/File/SWImportFile',type:EventType.PAGE,args:[]}}, - {btnModel:[ModelType.BASE],btnName:'导出',btnNamed:'',btnIcon:'base_export_file',btnTips:'导出',btnEvent:{uid:'',command:'Execute_ExportFileWindow',page:'pages/EventSubWin/File/SWExportFile',type:EventType.PAGE,args:[]}}, - {btnModel:[ModelType.BASE],btnName:'选项',btnNamed:'',btnIcon:'base_properties',btnTips:'选项',btnEvent:{uid:'',command:'Execute_CreateSubWindow_Options',page:'pages/EventSubWin/Options',type:EventType.PAGE,args:[]}}, + {btnModel:[ModelType.BASE],btnName:'导入',btnNamed:'',btnIcon:'base_import_file',btnTips:'导入',btnEvent:{uid:'',command:'Execute_ImportFileWindow',page:'pages/SubWindow/File/SWImportFile',type:EventType.PAGE,args:[]}}, + {btnModel:[ModelType.BASE],btnName:'导出',btnNamed:'',btnIcon:'base_export_file',btnTips:'导出',btnEvent:{uid:'',command:'Execute_ExportFileWindow',page:'pages/SubWindow/File/SWExportFile',type:EventType.PAGE,args:[]}}, + {btnModel:[ModelType.BASE],btnName:'选项',btnNamed:'',btnIcon:'base_properties',btnTips:'选项',btnEvent:{uid:'',command:'Execute_CreateSubWindow_Options',page:'pages/SubWindow/Options',type:EventType.PAGE,args:[]}}, {btnModel:[ModelType.BASE],btnName:'帮助',btnNamed:'',btnIcon:'base_help_file',btnTips:'帮助',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}}, ], grpMenu:GroupActionMenu }] as Array]]}, MatrixModel, diff --git a/entry/src/main/ets/pages/ModelViewTab.ets b/entry/src/main/ets/pages/ModelViewTab.ets index 03ecba20..f686b7f2 100644 --- a/entry/src/main/ets/pages/ModelViewTab.ets +++ b/entry/src/main/ets/pages/ModelViewTab.ets @@ -1,7 +1,7 @@ import { hilog } from '@kit.PerformanceAnalysisKit'; import { mwInfo } from './DispWinInfo/DispWinInfo' import { AppStorageV2 } from '@kit.ArkUI'; -import {InitXCompNode,XCompInfos,XCompInfo,CurrentXCompIndex} from './EventSubWin/ExCom' +import {InitXCompNode,XCompInfos,XCompInfo,CurrentXCompIndex} from './EventHub/XCompMgr' @ComponentV2 diff --git a/entry/src/main/ets/pages/EventSubWin/File/FileInter.ets b/entry/src/main/ets/pages/SubWindow/File/FileInter.ets similarity index 100% rename from entry/src/main/ets/pages/EventSubWin/File/FileInter.ets rename to entry/src/main/ets/pages/SubWindow/File/FileInter.ets diff --git a/entry/src/main/ets/pages/EventSubWin/File/FileStr.ets b/entry/src/main/ets/pages/SubWindow/File/FileStr.ets similarity index 100% rename from entry/src/main/ets/pages/EventSubWin/File/FileStr.ets rename to entry/src/main/ets/pages/SubWindow/File/FileStr.ets diff --git a/entry/src/main/ets/pages/EventSubWin/File/SWExportFile.ets b/entry/src/main/ets/pages/SubWindow/File/SWExportFile.ets similarity index 100% rename from entry/src/main/ets/pages/EventSubWin/File/SWExportFile.ets rename to entry/src/main/ets/pages/SubWindow/File/SWExportFile.ets diff --git a/entry/src/main/ets/pages/EventSubWin/File/SWImportFile.ets b/entry/src/main/ets/pages/SubWindow/File/SWImportFile.ets similarity index 100% rename from entry/src/main/ets/pages/EventSubWin/File/SWImportFile.ets rename to entry/src/main/ets/pages/SubWindow/File/SWImportFile.ets diff --git a/entry/src/main/ets/pages/EventSubWin/File/SWNewFile.ets b/entry/src/main/ets/pages/SubWindow/File/SWNewFile.ets similarity index 68% rename from entry/src/main/ets/pages/EventSubWin/File/SWNewFile.ets rename to entry/src/main/ets/pages/SubWindow/File/SWNewFile.ets index f42d7b05..2fefc690 100644 --- a/entry/src/main/ets/pages/EventSubWin/File/SWNewFile.ets +++ b/entry/src/main/ets/pages/SubWindow/File/SWNewFile.ets @@ -2,23 +2,11 @@ import { common } from '@kit.AbilityKit'; import { picker } from '@kit.CoreFileKit'; import type { BusinessError } from '@kit.BasicServicesKit'; import { TextComboBox } from "../../CustomController/ComboBox"; -import {XNRandomId} from '../ExCom' import { CreateModelType,DocUnitsType } from './FileStr'; -import { mwInfo } from '../../DispWinInfo/DispWinInfo' +import { mwInfo,mwsInfo } from '../../DispWinInfo/DispWinInfo' +import {CurrentTime,RndId} from '../../EventHub/EventBase' import { window } from '@kit.ArkUI'; -function CurrentTime():string { - let now = new Date(); - // 格式化时间字符串 - let year = now.getFullYear().toString(); - let month = (now.getMonth() + 1).toString().padStart(2, '0'); // padStart 确保月份是两位数 - let date = now.getDate().toString().padStart(2, '0'); - let hours = now.getHours().toString().padStart(2, '0'); - let minutes = now.getMinutes().toString().padStart(2, '0'); - let seconds = now.getSeconds().toString().padStart(2, '0'); - - return`${year}-${month}-${date} ${hours}:${minutes}:${seconds}`; -} @Entry @ComponentV2 export struct SWNewFile { @@ -29,9 +17,36 @@ export struct SWNewFile { @Local scaleBtn:number=0.05; //文本宽度统一缩放系数 @Local scalingText:number=0.04; + @Local subWin: window.Window | undefined = undefined; aboutToAppear(): void { this.docCreateTime=CurrentTime(); } + + async initSubWindow(){ + this.subWin= await mwsInfo.winStage?.createSubWindow('dirPicker'); + this.subWin?.loadContent('pages/SubWindow/File/SWNewFile'); + } + + async selectDir(): Promise{ + let selectDirStr=''; + let context =this.getUIContext().getHostContext() as common.Context; + if(this.subWin){ + this.subWin.destroyWindow(); + } + await this.initSubWindow(); + try { + let documentSelectOptions = new picker.DocumentSelectOptions(); + let documentPicker = new picker.DocumentViewPicker(context,this.subWin as window.Window); + documentSelectOptions.selectMode=picker.DocumentSelectMode.FOLDER; + documentPicker.select(documentSelectOptions,(err: BusinessError,documentSelectResult: Array) => { + selectDirStr =documentSelectResult.toString(); + }) + } catch (error) { + const err: BusinessError = error as BusinessError; + console.error(`DocumentViewPicker failed with err: ${err.code}, ${err.message}`); + } + return selectDirStr; + } build() { Column({space:5}) { Row({space:5}){ @@ -54,21 +69,8 @@ export struct SWNewFile { .fontColor($r('sys.color.font_emphasize')) .fontWeight(FontWeight.Medium) .fontSize($r('sys.float.Body_L')) - .onClick(() => { - let context = getContext(this) as common.Context; - try { - let documentSelectOptions = new picker.DocumentSelectOptions(); - let documentPicker = new picker.DocumentViewPicker(context); - documentPicker.select(documentSelectOptions,(err: BusinessError,documentSelectResult: Array) => { - this.dir =documentSelectResult.toString(); - if (documentSelectResult.length === 0) { - return; - } - }) - } catch (error) { - const err: BusinessError = error as BusinessError; - console.error(`DocumentViewPicker failed with err: ${err.code}, ${err.message}`); - } + .onClick(async () => { + this.dir= await this.selectDir(); }) }.height('10%') Row({space:5}){ @@ -81,7 +83,7 @@ export struct SWNewFile { .fontWeight(FontWeight.Medium) .fontSize($r('sys.float.Body_L')) .onClick(() => { - this.fileName='OpenCAX_'+XNRandomId(); + this.fileName='OpenCAX_'+RndId(); }) }.height('10%') Row({space:5}){ diff --git a/entry/src/main/ets/pages/EventSubWin/File/SWOpenFile.ets b/entry/src/main/ets/pages/SubWindow/File/SWOpenFile.ets similarity index 100% rename from entry/src/main/ets/pages/EventSubWin/File/SWOpenFile.ets rename to entry/src/main/ets/pages/SubWindow/File/SWOpenFile.ets diff --git a/entry/src/main/ets/pages/EventSubWin/File/SWSaveAsFile.ets b/entry/src/main/ets/pages/SubWindow/File/SWSaveAsFile.ets similarity index 100% rename from entry/src/main/ets/pages/EventSubWin/File/SWSaveAsFile.ets rename to entry/src/main/ets/pages/SubWindow/File/SWSaveAsFile.ets diff --git a/entry/src/main/ets/pages/EventSubWin/Options.ets b/entry/src/main/ets/pages/SubWindow/Options.ets similarity index 100% rename from entry/src/main/ets/pages/EventSubWin/Options.ets rename to entry/src/main/ets/pages/SubWindow/Options.ets diff --git a/entry/src/main/ets/pages/EventSubWin/Opts/OptFeature.ets b/entry/src/main/ets/pages/SubWindow/Opts/OptFeature.ets similarity index 100% rename from entry/src/main/ets/pages/EventSubWin/Opts/OptFeature.ets rename to entry/src/main/ets/pages/SubWindow/Opts/OptFeature.ets diff --git a/entry/src/main/ets/pages/EventSubWin/Opts/OptsInter.ets b/entry/src/main/ets/pages/SubWindow/Opts/OptsInter.ets similarity index 100% rename from entry/src/main/ets/pages/EventSubWin/Opts/OptsInter.ets rename to entry/src/main/ets/pages/SubWindow/Opts/OptsInter.ets diff --git a/entry/src/main/ets/pages/EventSubWin/Opts/OptsModeling.ets b/entry/src/main/ets/pages/SubWindow/Opts/OptsModeling.ets similarity index 100% rename from entry/src/main/ets/pages/EventSubWin/Opts/OptsModeling.ets rename to entry/src/main/ets/pages/SubWindow/Opts/OptsModeling.ets diff --git a/entry/src/main/ets/pages/EventSubWin/Opts/OptsStr.ets b/entry/src/main/ets/pages/SubWindow/Opts/OptsStr.ets similarity index 100% rename from entry/src/main/ets/pages/EventSubWin/Opts/OptsStr.ets rename to entry/src/main/ets/pages/SubWindow/Opts/OptsStr.ets diff --git a/entry/src/main/ets/pages/EventSubWin/Opts/OptsSub.ets b/entry/src/main/ets/pages/SubWindow/Opts/OptsSub.ets similarity index 100% rename from entry/src/main/ets/pages/EventSubWin/Opts/OptsSub.ets rename to entry/src/main/ets/pages/SubWindow/Opts/OptsSub.ets diff --git a/entry/src/main/ets/pages/EventSubWin/Opts/OptsUser.ets b/entry/src/main/ets/pages/SubWindow/Opts/OptsUser.ets similarity index 100% rename from entry/src/main/ets/pages/EventSubWin/Opts/OptsUser.ets rename to entry/src/main/ets/pages/SubWindow/Opts/OptsUser.ets diff --git a/entry/src/main/ets/pages/EventSubWin/Opts/OptsUserLayout.ets b/entry/src/main/ets/pages/SubWindow/Opts/OptsUserLayout.ets similarity index 100% rename from entry/src/main/ets/pages/EventSubWin/Opts/OptsUserLayout.ets rename to entry/src/main/ets/pages/SubWindow/Opts/OptsUserLayout.ets diff --git a/entry/src/main/ets/pages/EventSubWin/README.md b/entry/src/main/ets/pages/SubWindow/README.md similarity index 100% rename from entry/src/main/ets/pages/EventSubWin/README.md rename to entry/src/main/ets/pages/SubWindow/README.md diff --git a/entry/src/main/ets/pages/SubWindow/SWBase.ets b/entry/src/main/ets/pages/SubWindow/SWBase.ets new file mode 100644 index 00000000..fb8bd567 --- /dev/null +++ b/entry/src/main/ets/pages/SubWindow/SWBase.ets @@ -0,0 +1,75 @@ +import { BusinessError } from '@kit.BasicServicesKit'; +import { window } from '@kit.ArkUI'; +import { mwsInfo } from '../DispWinInfo/DispWinInfo' + +//窗体信息 +export class SubWinInfo{ + name?:string; + page?:string; + subWin?:window.Window; + subOpt?:window.SubWindowOptions; + subPointX?:number=200; + subPointY?:number=200; + width?:number=0; + height?:number=0; + constructor(name?: string, page?: string,width?: number,height?: number) { + this.name = name; + this.page = page; + this.width = width; + this.height = height; + } +} + +//窗体保存容器 +let subWins:Map=new Map; + +export async function CreateAndShowSubWindow(subWinInfo:SubWinInfo) { + try { + if(mwsInfo.winStage==null){ + console.error('Failed to create the subwindow. Cause: windowStage is null'); + return; + } + let options: window.SubWindowOptions = { + title: subWinInfo.name as string, + decorEnabled: true, + isModal: false, + maximizeSupported: false, + outlineEnabled:true, + }; + + console.info('SubWindow Size:',subWinInfo.width,subWinInfo.height) + await mwsInfo.winStage.createSubWindowWithOptions(subWinInfo.name as string, options).then((data) => { + console.info("页面路径:", subWinInfo.page); + subWinInfo.subWin = data; + //子窗口显示位置 + data.moveWindowTo(subWinInfo.subPointX, subWinInfo.subPointY) + //子窗口重置大小 + data.resize(subWinInfo.width,subWinInfo.height); + data.setUIContent(subWinInfo.page, (err: BusinessError) => { + if (err.code) { + console.error("加载页面失败:", err); + return; + } + }) + // 显示窗口 + data.showWindow((err) => { + if (err.code) { + console.error("显示窗口失败:", err); + } + }); + data.setResizeByDragEnabled(false); + }) + subWins[subWinInfo.name as string]=subWinInfo; + } catch (error) { + console.error('Failed to create or show sub window:', (error as BusinessError).message); + } +} + +export function CloseSubWindow() { + try { + console.info('Sub window closed.'); + } catch (error) { + console.error('Failed to close sub window:', (error as BusinessError).message); + } +} + diff --git a/entry/src/main/ets/pages/EventSubWin/SWExtrude.ets b/entry/src/main/ets/pages/SubWindow/SWExtrude.ets similarity index 100% rename from entry/src/main/ets/pages/EventSubWin/SWExtrude.ets rename to entry/src/main/ets/pages/SubWindow/SWExtrude.ets diff --git a/entry/src/main/ets/pages/EventSubWin/SWLine.ets b/entry/src/main/ets/pages/SubWindow/SWLine.ets similarity index 100% rename from entry/src/main/ets/pages/EventSubWin/SWLine.ets rename to entry/src/main/ets/pages/SubWindow/SWLine.ets diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json index 30569f7f..2ac74c25 100644 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -1,13 +1,13 @@ { "src": [ "pages/Index", - "pages/EventSubWin/SWLine", - "pages/EventSubWin/SWExtrude", - "pages/EventSubWin/Options", - "pages/EventSubWin/File/SWNewFile", - "pages/EventSubWin/File/SWSaveAsFile", - "pages/EventSubWin/File/SWImportFile", - "pages/EventSubWin/File/SWExportFile", - "pages/EventSubWin/File/SWOpenFile" + "pages/SubWindow/SWLine", + "pages/SubWindow/SWExtrude", + "pages/SubWindow/Options", + "pages/SubWindow/File/SWNewFile", + "pages/SubWindow/File/SWSaveAsFile", + "pages/SubWindow/File/SWImportFile", + "pages/SubWindow/File/SWExportFile", + "pages/SubWindow/File/SWOpenFile" ] } \ No newline at end of file