From f65b6ed3f90a51c72eee6ae2dac8a2bdc31e159b Mon Sep 17 00:00:00 2001 From: JackLee <809262979@qq.com> Date: Mon, 30 Mar 2026 21:53:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=92=E4=B8=80=E5=8C=96=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/cpp/CMakeLists.txt | 9 +- .../main/cpp/NativeEGLOCCT/NativeRender.cpp | 61 ++-------- .../src/main/cpp/NativeEGLOCCT/NativeRender.h | 7 +- .../main/cpp/NativeEGLOCCT/V3d/Axis/Axis.cpp | 111 ------------------ .../cpp/NativeEGLOCCT/V3d/V3dCtx/V3dCtx.cpp | 8 +- .../cpp/NativeEGLOCCT/V3d/V3dCtx/V3dCtx.h | 2 + .../NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.cpp | 16 ++- .../NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.h | 1 + .../cpp/NativeEGLOCCT/V3d/V3dTri/README.md | 0 .../cpp/NativeEGLOCCT/V3d/V3dTri/V3dTri.cpp | 79 +++++++++++++ .../V3d/{Axis/Axis.h => V3dTri/V3dTri.h} | 42 +++---- .../NativeEGLOCCT/V3d/V3dTri/V3dTriCube.cpp | 51 ++++++++ .../cpp/NativeEGLOCCT/V3d/V3dTri/V3dTriCube.h | 37 ++++++ .../NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.cpp | 25 ++++ .../cpp/NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.h | 22 ++++ 15 files changed, 275 insertions(+), 196 deletions(-) delete mode 100644 entry/src/main/cpp/NativeEGLOCCT/V3d/Axis/Axis.cpp create mode 100644 entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/README.md create mode 100644 entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTri.cpp rename entry/src/main/cpp/NativeEGLOCCT/V3d/{Axis/Axis.h => V3dTri/V3dTri.h} (51%) create mode 100644 entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTriCube.cpp create mode 100644 entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTriCube.h create mode 100644 entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.cpp create mode 100644 entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.h diff --git a/entry/src/main/cpp/CMakeLists.txt b/entry/src/main/cpp/CMakeLists.txt index e6fd2174..c219b1c7 100644 --- a/entry/src/main/cpp/CMakeLists.txt +++ b/entry/src/main/cpp/CMakeLists.txt @@ -44,7 +44,6 @@ add_library(opencax SHARED NativeEGLOCCT/NativeRender.h NativeEGLOCCT/NativeRenderThread.h NativeEGLOCCT/NativeManager.h - NativeEGLOCCT/V3d/Axis/Axis.h NativeEGLOCCT/V3d/V3dOGD/V3dOGD.h NativeEGLOCCT/V3d/V3dViewer/V3dViewer.h NativeEGLOCCT/V3d/V3dCtx/V3dCtx.h @@ -52,6 +51,9 @@ add_library(opencax SHARED NativeEGLOCCT/V3d/V3dWin/V3dWin.h NativeEGLOCCT/V3d/V3dCa/V3dCa.h NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.h + NativeEGLOCCT/V3d/V3dTri/V3dTri.h + NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.h + NativeEGLOCCT/V3d/V3dTri/V3dTriCube.h # Cpp Src NativeEGLOCCT/EGLCore.cpp NativeEGLOCCT/NativeRender.cpp @@ -62,10 +64,11 @@ add_library(opencax SHARED NativeEGLOCCT/V3d/V3dCtx/V3dCtx.cpp NativeEGLOCCT/V3d/V3dView/V3dView.cpp NativeEGLOCCT/V3d/V3dCa/V3dCa.cpp - NativeEGLOCCT/V3d/Axis/Axis.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) # 查找系统库 find_library(EGL-lib EGL) diff --git a/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp b/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp index 1e81a746..2a7bc51f 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp @@ -13,8 +13,8 @@ namespace NativeOpenCAX { NativeRender::NativeRender(int w, int h): width(0), height(0), -mAxis(new Axis), -nAxis(new Axis), +v3dTri(new V3dTri), +v3dTriCube(new V3dTriCube), v3dcr(new V3dCa), v3dctx(new V3dCtx), v3dogd(new V3dOGD), @@ -65,13 +65,13 @@ bool NativeRender::init(EGLCore &_eglCore) { HILOG_ERROR(NATIVE_TAG, "Init Camera Fail!"); return false; } - - if (!mAxis->InitAxis(v3dctx->ctx)) { + //初始化世界坐标系 + if (!v3dTri->InitV3dTri(v3dctx->ctx)) { HILOG_ERROR(NATIVE_TAG, "Init AXIS Fail!"); return false; } - - if (!mAxis->InitAxisCube(v3dctx->ctx)) { + //初始化正方体视角切换指示器 + if (!v3dTriCube->InitV3dTriCube(v3dctx->ctx)) { HILOG_ERROR(NATIVE_TAG, "Init AXIS Cuba Fail!"); return false; } @@ -118,51 +118,12 @@ bool NativeRender::loadModel(const std::string &filePath) { shape = transformer.Shape(); if (!shape.IsNull()) { Handle(AIS_Shape) aisShape = new AIS_Shape(shape); - // 设置材质 Handle(Prs3d_Drawer) drawer = aisShape->Attributes(); - Handle(Prs3d_ShadingAspect) shadingAspect = new Prs3d_ShadingAspect(); - // aisShape->SetDisplayMode(1); - Handle(Prs3d_LineAspect) aLineAspect = new Prs3d_LineAspect(Quantity_NOC_BLACK, // 颜色,例如黑色 - Aspect_TOL_DASH, // 线型 - 3.0 // 线宽 - ); - - // 随机颜色 - int colorIndex = i % 7; - Quantity_Color color; - switch (colorIndex) { - case 0: - color = Quantity_NOC_RED; - break; - case 1: - color = Quantity_NOC_GREEN; - break; - case 2: - color = Quantity_NOC_BLUE1; - break; - case 3: - color = Quantity_NOC_YELLOW; - break; - case 4: - color = Quantity_NOC_MAGENTA1; - break; - case 5: - color = Quantity_NOC_CYAN1; - break; - case 6: - color = Quantity_NOC_ORANGE; - break; - default: - color = Quantity_NOC_WHITE; - } - shadingAspect->SetColor(color); - shadingAspect->SetMaterial(Graphic3d_NOM_PLASTIC); drawer->SetFaceBoundaryDraw(true); - drawer->SetWireAspect(aLineAspect); - drawer->SetShadingAspect(shadingAspect); + drawer->SetWireAspect(v3ddrawer->v3d_LineAspect); + drawer->SetShadingAspect(v3ddrawer->v3d_ShadingAspect); v3dctx->ctx->Display(aisShape, true); - // ctx->context->SetDisplayMode(AIS_WireFrame, Standard_False); shapes_.push_back(aisShape); } } @@ -175,8 +136,8 @@ bool NativeRender::loadModel(const std::string &filePath) { // setTranslation void NativeRender::setTranslation(float tx, float ty) { - nAxis->SetTranslationX(tx); - nAxis->SetTranslationY(ty); + v3dTri->SetTranslationX(tx); + v3dTri->SetTranslationY(ty); } void NativeRender::render() { @@ -196,7 +157,7 @@ void NativeRender::resize(int w, int h) { void NativeRender::setRotation(float xAngle, float yAngle) { v3dcr->SetRotation(xAngle, yAngle); } void NativeRender::setZoomLevel(float zoom) { - nAxis->SetZoomLevel(std::max(0.1f, std::min(zoom, 5.0f))); // 限制缩放范围 + v3dTri->SetZoomLevel(std::max(0.1f, std::min(zoom, 5.0f))); // 限制缩放范围 } void NativeRender::setClearColor(float r, float g, float b, float a) { v3dview->SetClearColor(r, g, b, a); } void NativeRender::resetView() { v3dview->ResetView(); } diff --git a/entry/src/main/cpp/NativeEGLOCCT/NativeRender.h b/entry/src/main/cpp/NativeEGLOCCT/NativeRender.h index abd18376..4c29e861 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/NativeRender.h +++ b/entry/src/main/cpp/NativeEGLOCCT/NativeRender.h @@ -15,7 +15,8 @@ #include #include -#include "V3d/Axis/Axis.h" +#include "V3d/V3dTri/V3dTri.h" +#include "V3d/V3dTri/V3dTriCube.h" #include "V3d/V3dCa/V3dCa.h" #include "V3d/V3dCtx/V3dCtx.h" #include "V3d/V3dOGD/V3dOGD.h" @@ -48,8 +49,8 @@ private: int width; int height; EGLCore eglCore; - Axis* mAxis; - Axis* nAxis; + V3dTri* v3dTri; + V3dTriCube* v3dTriCube; V3dCa* v3dcr; V3dCtx* v3dctx; V3dOGD* v3dogd; diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/Axis/Axis.cpp b/entry/src/main/cpp/NativeEGLOCCT/V3d/Axis/Axis.cpp deleted file mode 100644 index 5e3263a8..00000000 --- a/entry/src/main/cpp/NativeEGLOCCT/V3d/Axis/Axis.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// -// Created on 2026/3/23. -// -// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found, -// please include "napi/native_api.h". - -#include "Axis.h" -#include "Aspect_TypeOfTriedronPosition.hxx" -#include "Graphic3d_NameOfMaterial.hxx" -#include "Prs3d_DatumMode.hxx" -#include "Quantity_NameOfColor.hxx" - -#ifndef NATIVE_TAG -#define NATIVE_TAG "AXIS" -#endif - -namespace NativeOpenCAX { -Axis::Axis() : axiPlacement(nullptr), axiTrihedron(nullptr), axiViewCube(nullptr) {} -Axis::~Axis() {} - -bool Axis::InitAxis(Handle(AIS_InteractiveContext) & ctx) { - try { - //坐标显示文本 - const char16_t x_Axis[] = u"X"; - const char16_t y_Axis[] = u"Y"; - const char16_t z_Axis[] = u"Z"; - // 创建场景中心参考坐标系 - gp_Ax2 theAxis; - double theSize =250; // 大小 - // 设置原点 - theAxis.SetLocation(gp_Pnt(0, 0, 0)); - // 以世界坐标轴为准,设置Z,X轴方向 - theAxis.SetDirection(gp_Dir(0, 0, 1)); - theAxis.SetXDirection(gp_Dir(1, 0, 0)); - gp_Pnt anOrg = theAxis.Location(); - axiPlacement = new Geom_Axis2Placement(theAxis); - axiPlacement->SetLocation(gp::Origin()); - axiTrihedron = new AIS_Trihedron(axiPlacement); - axiTrihedron->SetDatumDisplayMode(Prs3d_DM_WireFrame); - axiTrihedron->SetDrawArrows(true); - axiTrihedron->Attributes()->DatumAspect()->LineAspect(Prs3d_DP_XArrow)->SetWidth(2); - axiTrihedron->Attributes()->DatumAspect()->LineAspect(Prs3d_DP_YArrow)->SetWidth(2); - axiTrihedron->Attributes()->DatumAspect()->LineAspect(Prs3d_DP_ZArrow)->SetWidth(2); - axiTrihedron->Attributes()->DatumAspect()->LineAspect(Prs3d_DP_XAxis)->SetWidth(1.5); - axiTrihedron->Attributes()->DatumAspect()->LineAspect(Prs3d_DP_YAxis)->SetWidth(1.5); - axiTrihedron->Attributes()->DatumAspect()->LineAspect(Prs3d_DP_ZAxis)->SetWidth(1.5); - axiTrihedron->SetDatumPartColor(Prs3d_DP_XArrow, Quantity_NOC_GRAY85); - axiTrihedron->SetDatumPartColor(Prs3d_DP_YArrow, Quantity_NOC_GRAY85); - axiTrihedron->SetDatumPartColor(Prs3d_DP_ZArrow, Quantity_NOC_GRAY85); - axiTrihedron->SetDatumPartColor(Prs3d_DP_XAxis, Quantity_NOC_GRAY85); - axiTrihedron->SetDatumPartColor(Prs3d_DP_YAxis, Quantity_NOC_GRAY85); - axiTrihedron->SetDatumPartColor(Prs3d_DP_ZAxis, Quantity_NOC_GRAY85); - axiTrihedron->SetLabel(Prs3d_DP_XAxis, x_Axis); - axiTrihedron->SetLabel(Prs3d_DP_YAxis, y_Axis); - axiTrihedron->SetLabel(Prs3d_DP_ZAxis, z_Axis); - axiTrihedron->SetSize(theSize); - axiTrihedron->SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TMF_ZoomPers, anOrg)); - axiTrihedron->Attributes()->DatumAspect()->SetTextAspect(ctx->DefaultDrawer()->TextAspect()); - axiTrihedron->Attributes()->SetZLayer(Graphic3d_ZLayerId_Topmost); - ctx->Display(axiTrihedron, true); - HILOG_INFO(NATIVE_TAG, "InitLocalAxis Done"); - return true; - } catch (std::exception &e) { - HILOG_INFO(NATIVE_TAG, "InitLocalAxis Fail:%s", e.what()); - return false; - } -} -bool Axis::InitAxisCube(Handle(AIS_InteractiveContext) & context) { - try { - //立方体面显示文本 - const char16_t rightCube[] = u"右视图"; - const char16_t backCube[] = u"后视图"; - const char16_t topCube[] = u"俯视图"; - const char16_t leftCube[] = u"左视图"; - const char16_t frontCube[] = u"前视图"; - const char16_t bottomCube[] = u"仰视图"; - // 视图立方体 - axiViewCube = new AIS_ViewCube(); - axiViewCube->SetBoxSideLabel(V3d_Xpos, TCollection_AsciiString(rightCube)); - axiViewCube->SetBoxSideLabel(V3d_Ypos, TCollection_AsciiString(backCube)); - axiViewCube->SetBoxSideLabel(V3d_Zpos, TCollection_AsciiString(topCube)); - axiViewCube->SetBoxSideLabel(V3d_Xneg, TCollection_AsciiString(leftCube)); - axiViewCube->SetBoxSideLabel(V3d_Yneg, TCollection_AsciiString(frontCube)); - axiViewCube->SetBoxSideLabel(V3d_Zneg, TCollection_AsciiString(bottomCube)); - axiViewCube->SetDrawAxes(true); - axiViewCube->SetSize(100, true); - axiViewCube->SetTransparency(0.0); - axiViewCube->SetFixedAnimationLoop(true); - axiViewCube->SetTextColor(Quantity_Color(Quantity_NOC_YELLOW2)); - axiViewCube->SetFontHeight(30); - axiViewCube->SetMaterial(Graphic3d_MaterialAspect(Graphic3d_NOM_ALUMINIUM)); - axiViewCube->SetTransformPersistence( - new Graphic3d_TransformPers(Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_UPPER, NCollection_Vec2(125, 125))); - context->Display(axiViewCube, true); - HILOG_INFO(NATIVE_TAG, "Init Axi View Cube Done"); - return true; - } catch (std::exception &e) { - HILOG_INFO(NATIVE_TAG, "Init Axi View Cube Fail:%{public}d", e.what()); - return false; - } - -} - -void Axis::SetRotationX(float rx) { rotationX = rx; } -void Axis::SetRotationY(float ry) { rotationX = ry; } -void Axis::SetRotationZ(float rz) { rotationX = rz; } -void Axis::SetTranslationX(float tx) { translationX = tx; } -void Axis::SetTranslationY(float ty) { translationX = ty; } -void Axis::SetTranslationZ(float tz) { translationX = tz; } -void Axis::SetZoomLevel(float level) { zoomLevel = level; } -} \ No newline at end of file diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCtx/V3dCtx.cpp b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCtx/V3dCtx.cpp index d24412d5..7cfc7c8d 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCtx/V3dCtx.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCtx/V3dCtx.cpp @@ -23,6 +23,7 @@ V3dCtx::~V3dCtx() { bool V3dCtx::InitV3dCtx(Handle(V3d_Viewer)& viewer) { ctx = new AIS_InteractiveContext(viewer); if(!ctx.IsNull()){ + InitCtxOpts(); HILOG_INFO(NATIVE_TAG, "InitCtx Done"); return true; }else{ @@ -30,5 +31,10 @@ bool V3dCtx::InitV3dCtx(Handle(V3d_Viewer)& viewer) { return false; } } - +void V3dCtx::InitCtxOpts(){ + ctx->SetDisplayMode(AIS_Shaded,false); +} +void V3dCtx::ChangeDisplayMode(AIS_DisplayMode thisMode){ + ctx->SetDisplayMode(thisMode,false); +} } \ No newline at end of file diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCtx/V3dCtx.h b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCtx/V3dCtx.h index eaeb01cd..57165d5a 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCtx/V3dCtx.h +++ b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dCtx/V3dCtx.h @@ -21,6 +21,8 @@ public: V3dCtx(); ~V3dCtx(); bool InitV3dCtx(Handle(V3d_Viewer)& viewer); + void InitCtxOpts(); + void ChangeDisplayMode(AIS_DisplayMode thieMode); public: Handle(AIS_InteractiveContext) ctx; }; diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.cpp b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.cpp index 9148117d..e90ebf67 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.cpp @@ -49,19 +49,28 @@ bool V3dDrawer::InitV3dAllAspect(Handle(AIS_InteractiveContext)& ctx) { return false; } } - +void V3dDrawer::InitV3dDrawer(){ + //所有面的边界线 + drawer->SetFaceBoundaryDraw(true); +} void V3dDrawer::InitV3dIsoAspectOpts() { v3d_IsoAspect->SetWidth(1.0); } void V3dDrawer::InitV3dLineAspectOpts() { - v3d_LineAspect->SetWidth(1.0); + //线宽 + v3d_LineAspect->SetWidth(5.0); + //线颜色 + v3d_LineAspect->SetColor(Quantity_NOC_BLACK); + //线型 + v3d_LineAspect->SetTypeOfLine(Aspect_TOL_DOTDASH); } void V3dDrawer::InitV3dTextAspectOpts() { v3d_TextAspect->SetFont("HarmonyOS Sans"); v3d_TextAspect->SetHeight(35); } void V3dDrawer::InitV3dShadingAspectOpts() { - + v3d_ShadingAspect->SetColor(Quantity_NOC_YELLOW); + v3d_ShadingAspect->SetMaterial(Graphic3d_NOM_PLASTIC); } void V3dDrawer::InitV3dPlaneAspectOpts() { @@ -73,6 +82,5 @@ void V3dDrawer::InitV3dDatumAspectOpts() { } void V3dDrawer::InitV3dDimAspectOpts() { - } } \ No newline at end of file diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.h b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.h index f95391b4..2768a063 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.h +++ b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.h @@ -28,6 +28,7 @@ public: ~V3dDrawer(); bool InitV3dAllAspect(Handle(AIS_InteractiveContext)& ctx); private: + void InitV3dDrawer(); void InitV3dIsoAspectOpts(); void InitV3dLineAspectOpts(); void InitV3dTextAspectOpts(); diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/README.md b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/README.md new file mode 100644 index 00000000..e69de29b diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTri.cpp b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTri.cpp new file mode 100644 index 00000000..f33ad6af --- /dev/null +++ b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTri.cpp @@ -0,0 +1,79 @@ +// +// Created on 2026/3/30. +// +// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found, +// please include "napi/native_api.h". + +#include "V3dTri.h" + +#ifndef NATIVE_TAG +#define NATIVE_TAG "V3DTRI" +#endif +namespace NativeOpenCAX { + +V3dTri::V3dTri(): +axiPlam(nullptr), +axiTri(nullptr) +{ + +} +V3dTri::~V3dTri(){ + +} +bool V3dTri::InitV3dTri(Handle(AIS_InteractiveContext)& ctx){ + try { + //坐标显示文本 + const char16_t x_Axis[] = u"X"; + const char16_t y_Axis[] = u"Y"; + const char16_t z_Axis[] = u"Z"; + // 创建场景中心参考坐标系 + gp_Ax2 theAxis; + double theSize =250; // 大小 + // 设置原点 + theAxis.SetLocation(gp_Pnt(0, 0, 0)); + // 以世界坐标轴为准,设置Z,X轴方向 + theAxis.SetDirection(gp_Dir(0, 0, 1)); + theAxis.SetXDirection(gp_Dir(1, 0, 0)); + gp_Pnt anOrg = theAxis.Location(); + axiPlam = new Geom_Axis2Placement(theAxis); + axiPlam->SetLocation(gp::Origin()); + axiTri = new AIS_Trihedron(axiPlam); + axiTri->SetDatumDisplayMode(Prs3d_DM_WireFrame); + axiTri->SetDrawArrows(true); + axiTri->Attributes()->DatumAspect()->LineAspect(Prs3d_DP_XArrow)->SetWidth(2); + axiTri->Attributes()->DatumAspect()->LineAspect(Prs3d_DP_YArrow)->SetWidth(2); + axiTri->Attributes()->DatumAspect()->LineAspect(Prs3d_DP_ZArrow)->SetWidth(2); + axiTri->Attributes()->DatumAspect()->LineAspect(Prs3d_DP_XAxis)->SetWidth(1.5); + axiTri->Attributes()->DatumAspect()->LineAspect(Prs3d_DP_YAxis)->SetWidth(1.5); + axiTri->Attributes()->DatumAspect()->LineAspect(Prs3d_DP_ZAxis)->SetWidth(1.5); + axiTri->SetDatumPartColor(Prs3d_DP_XArrow, Quantity_NOC_GRAY85); + axiTri->SetDatumPartColor(Prs3d_DP_YArrow, Quantity_NOC_GRAY85); + axiTri->SetDatumPartColor(Prs3d_DP_ZArrow, Quantity_NOC_GRAY85); + axiTri->SetDatumPartColor(Prs3d_DP_XAxis, Quantity_NOC_GRAY85); + axiTri->SetDatumPartColor(Prs3d_DP_YAxis, Quantity_NOC_GRAY85); + axiTri->SetDatumPartColor(Prs3d_DP_ZAxis, Quantity_NOC_GRAY85); + axiTri->SetLabel(Prs3d_DP_XAxis, x_Axis); + axiTri->SetLabel(Prs3d_DP_YAxis, y_Axis); + axiTri->SetLabel(Prs3d_DP_ZAxis, z_Axis); + axiTri->SetSize(theSize); + axiTri->SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TMF_ZoomPers, anOrg)); + axiTri->Attributes()->DatumAspect()->SetTextAspect(ctx->DefaultDrawer()->TextAspect()); + axiTri->Attributes()->SetZLayer(Graphic3d_ZLayerId_Topmost); + ctx->Display(axiTri, true); + HILOG_INFO(NATIVE_TAG, "Init 3dTri Axis Done"); + return true; + } catch (std::exception &e) { + HILOG_INFO(NATIVE_TAG, "Init 3dTri Axis Fail:%s", e.what()); + return false; + } + +} +void V3dTri::SetRotationX(float rx) { rotationX = rx; } +void V3dTri::SetRotationY(float ry) { rotationX = ry; } +void V3dTri::SetRotationZ(float rz) { rotationX = rz; } +void V3dTri::SetTranslationX(float tx) { translationX = tx; } +void V3dTri::SetTranslationY(float ty) { translationX = ty; } +void V3dTri::SetTranslationZ(float tz) { translationX = tz; } +void V3dTri::SetZoomLevel(float level) { zoomLevel = level; } + +} \ No newline at end of file diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/Axis/Axis.h b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTri.h similarity index 51% rename from entry/src/main/cpp/NativeEGLOCCT/V3d/Axis/Axis.h rename to entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTri.h index 1dc28ebf..77288a80 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/V3d/Axis/Axis.h +++ b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTri.h @@ -1,38 +1,32 @@ // -// Created on 2026/3/23. +// Created on 2026/3/30. // // 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_AXIS_H -#define OPENCAX_AXIS_H - -#include "AIS_ViewCube.hxx" +#ifndef OPENCAX_V3DTRIEDRON_H +#define OPENCAX_V3DTRIEDRON_H #include "NativeEGLOCCT/common.h" #include #include #include - namespace NativeOpenCAX { -class Axis { +class V3dTri { public: - Axis(); - ~Axis(); - bool InitAxis(Handle(AIS_InteractiveContext)& context); - bool InitAxisCube(Handle(AIS_InteractiveContext) & context); - void SetRotationX(float x); - void SetRotationY(float y); - void SetRotationZ(float z); - void SetTranslationX(float x); - void SetTranslationY(float y); - void SetTranslationZ(float z); + V3dTri(); + ~V3dTri(); + bool InitV3dTri(Handle(AIS_InteractiveContext)& ctx); + void SetRotationX(float rx); + void SetRotationY(float ry); + void SetRotationZ(float rz); + void SetTranslationX(float tx); + void SetTranslationY(float ty); + void SetTranslationZ(float tz); void SetZoomLevel(float level); -private: - Handle(Geom_Axis2Placement) axiPlacement; - Handle(AIS_Trihedron) axiTrihedron; - //定义三面体 - Handle(AIS_ViewCube) axiViewCube; +public: + Handle(Geom_Axis2Placement) axiPlam; + Handle(AIS_Trihedron) axiTri; private: //旋转X轴 float rotationX=0.0f; @@ -48,7 +42,7 @@ private: float translationY=0.0f; //翻转Z轴 float translationZ=0.0f; + }; } - -#endif //OPENCAX_AXIS_H +#endif //OPENCAX_V3DTRIEDRON_H diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTriCube.cpp b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTriCube.cpp new file mode 100644 index 00000000..dd4ab774 --- /dev/null +++ b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTriCube.cpp @@ -0,0 +1,51 @@ +// +// Created on 2026/3/30. +// +// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found, +// please include "napi/native_api.h". + +#include "V3dTriCube.h" +#include "Graphic3d_TransModeFlags.hxx" + +#ifndef NATIVE_TAG +#define NATIVE_TAG "V3DTRICUBE" +#endif +namespace NativeOpenCAX { + +V3dTriCube::V3dTriCube(): +triCube(nullptr) +{ + +} +V3dTriCube::~V3dTriCube(){ + +} + +bool V3dTriCube::InitV3dTriCube(Handle(AIS_InteractiveContext)& ctx){ + try { + // 视图立方体 + triCube = new AIS_ViewCube(); + triPers=new Graphic3d_TransformPers( + Graphic3d_TMF_TriedronPers, // 随缩放保持大小 + Aspect_TOTP_LEFT_UPPER, // 固定在左下角 + NCollection_Vec2(150, 150) // 离左下角偏移 10 像素 + ); + triCube->SetTransformPersistence(triPers); + triCube->SetBoxSideLabel(V3d_Xpos, TCollection_AsciiString(rightCube.c_str())); + triCube->SetBoxSideLabel(V3d_Ypos, TCollection_AsciiString(backCube.c_str())); + triCube->SetBoxSideLabel(V3d_Zpos, TCollection_AsciiString(topCube.c_str())); + triCube->SetBoxSideLabel(V3d_Xneg, TCollection_AsciiString(leftCube.c_str())); + triCube->SetBoxSideLabel(V3d_Yneg, TCollection_AsciiString(frontCube.c_str())); + triCube->SetBoxSideLabel(V3d_Zneg, TCollection_AsciiString(bottomCube.c_str())); + triCube->SetSize(100, true); + triCube->SetFontHeight(30); + triCube->AcceptDisplayMode(true); + ctx->Display(triCube, true); + HILOG_INFO(NATIVE_TAG, "Init V3dTriCube Done"); + return true; + } catch (std::exception &e) { + HILOG_INFO(NATIVE_TAG, "Init V3dTriCube Fail:%s", e.what()); + return false; + } +} +} \ No newline at end of file diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTriCube.h b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTriCube.h new file mode 100644 index 00000000..e797b956 --- /dev/null +++ b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTriCube.h @@ -0,0 +1,37 @@ +// +// Created on 2026/3/30. +// +// 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_V3DTRICUBE_H +#define OPENCAX_V3DTRICUBE_H + +#include "NativeEGLOCCT/common.h" +#include +#include +#include + +namespace NativeOpenCAX { + +class V3dTriCube { +public: + V3dTriCube(); + ~V3dTriCube(); + bool InitV3dTriCube(Handle(AIS_InteractiveContext)& ctx); +private: + Handle(AIS_ViewCube) triCube; + Handle(Graphic3d_TransformPers) triPers; + //立方体面显示文本 + std::u16string rightCube = u"右视图"; + std::u16string backCube = u"后视图"; + std::u16string topCube = u"俯视图"; + std::u16string leftCube = u"左视图"; + std::u16string frontCube = u"前视图"; + std::u16string bottomCube = u"仰视图"; + +private: + +}; +} +#endif //OPENCAX_V3DTRICUBE_H diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.cpp b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.cpp new file mode 100644 index 00000000..cd0dcfbd --- /dev/null +++ b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.cpp @@ -0,0 +1,25 @@ +// +// Created on 2026/3/30. +// +// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found, +// please include "napi/native_api.h". + +#include "V3dWCSTri.h" + +#ifndef NATIVE_TAG +#define NATIVE_TAG "V3DWCSTRI" +#endif +namespace NativeOpenCAX { + +V3dWCSTri::V3dWCSTri() +{ + +} +V3dWCSTri::~V3dWCSTri(){ + +} +bool V3dWCSTri::InitV3dWCSTri(Handle(AIS_InteractiveContext)& ctx){ + + +} +} \ No newline at end of file diff --git a/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.h b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.h new file mode 100644 index 00000000..15ce5673 --- /dev/null +++ b/entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.h @@ -0,0 +1,22 @@ +// +// Created on 2026/3/30. +// +// 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_V3DTRIEDRON_H +#define OPENCAX_V3DTRIEDRON_H +#include "NativeEGLOCCT/common.h" +#include +#include +#include +namespace NativeOpenCAX { + +class V3dWCSTri { +public: + V3dWCSTri(); + ~V3dWCSTri(); + bool InitV3dWCSTri(Handle(AIS_InteractiveContext)& ctx); +}; +} +#endif //OPENCAX_V3DTRIEDRON_H