归一化一些参数

This commit is contained in:
JackLee 2026-03-30 21:53:34 +08:00
parent 5f9af295f8
commit f65b6ed3f9
15 changed files with 275 additions and 196 deletions

View File

@ -44,7 +44,6 @@ add_library(opencax SHARED
NativeEGLOCCT/NativeRender.h NativeEGLOCCT/NativeRender.h
NativeEGLOCCT/NativeRenderThread.h NativeEGLOCCT/NativeRenderThread.h
NativeEGLOCCT/NativeManager.h NativeEGLOCCT/NativeManager.h
NativeEGLOCCT/V3d/Axis/Axis.h
NativeEGLOCCT/V3d/V3dOGD/V3dOGD.h NativeEGLOCCT/V3d/V3dOGD/V3dOGD.h
NativeEGLOCCT/V3d/V3dViewer/V3dViewer.h NativeEGLOCCT/V3d/V3dViewer/V3dViewer.h
NativeEGLOCCT/V3d/V3dCtx/V3dCtx.h NativeEGLOCCT/V3d/V3dCtx/V3dCtx.h
@ -52,6 +51,9 @@ add_library(opencax SHARED
NativeEGLOCCT/V3d/V3dWin/V3dWin.h NativeEGLOCCT/V3d/V3dWin/V3dWin.h
NativeEGLOCCT/V3d/V3dCa/V3dCa.h NativeEGLOCCT/V3d/V3dCa/V3dCa.h
NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.h NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.h
NativeEGLOCCT/V3d/V3dTri/V3dTri.h
NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.h
NativeEGLOCCT/V3d/V3dTri/V3dTriCube.h
# Cpp Src # Cpp Src
NativeEGLOCCT/EGLCore.cpp NativeEGLOCCT/EGLCore.cpp
NativeEGLOCCT/NativeRender.cpp NativeEGLOCCT/NativeRender.cpp
@ -62,10 +64,11 @@ add_library(opencax SHARED
NativeEGLOCCT/V3d/V3dCtx/V3dCtx.cpp NativeEGLOCCT/V3d/V3dCtx/V3dCtx.cpp
NativeEGLOCCT/V3d/V3dView/V3dView.cpp NativeEGLOCCT/V3d/V3dView/V3dView.cpp
NativeEGLOCCT/V3d/V3dCa/V3dCa.cpp NativeEGLOCCT/V3d/V3dCa/V3dCa.cpp
NativeEGLOCCT/V3d/Axis/Axis.cpp
NativeEGLOCCT/V3d/V3dWin/V3dWin.cpp NativeEGLOCCT/V3d/V3dWin/V3dWin.cpp
NativeEGLOCCT/V3d/V3dDrawer/V3dDrawer.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) find_library(EGL-lib EGL)

View File

@ -13,8 +13,8 @@ namespace NativeOpenCAX {
NativeRender::NativeRender(int w, int h): NativeRender::NativeRender(int w, int h):
width(0), width(0),
height(0), height(0),
mAxis(new Axis), v3dTri(new V3dTri),
nAxis(new Axis), v3dTriCube(new V3dTriCube),
v3dcr(new V3dCa), v3dcr(new V3dCa),
v3dctx(new V3dCtx), v3dctx(new V3dCtx),
v3dogd(new V3dOGD), v3dogd(new V3dOGD),
@ -65,13 +65,13 @@ bool NativeRender::init(EGLCore &_eglCore) {
HILOG_ERROR(NATIVE_TAG, "Init Camera Fail!"); HILOG_ERROR(NATIVE_TAG, "Init Camera Fail!");
return false; return false;
} }
//初始化世界坐标系
if (!mAxis->InitAxis(v3dctx->ctx)) { if (!v3dTri->InitV3dTri(v3dctx->ctx)) {
HILOG_ERROR(NATIVE_TAG, "Init AXIS Fail!"); HILOG_ERROR(NATIVE_TAG, "Init AXIS Fail!");
return false; return false;
} }
//初始化正方体视角切换指示器
if (!mAxis->InitAxisCube(v3dctx->ctx)) { if (!v3dTriCube->InitV3dTriCube(v3dctx->ctx)) {
HILOG_ERROR(NATIVE_TAG, "Init AXIS Cuba Fail!"); HILOG_ERROR(NATIVE_TAG, "Init AXIS Cuba Fail!");
return false; return false;
} }
@ -118,51 +118,12 @@ bool NativeRender::loadModel(const std::string &filePath) {
shape = transformer.Shape(); shape = transformer.Shape();
if (!shape.IsNull()) { if (!shape.IsNull()) {
Handle(AIS_Shape) aisShape = new AIS_Shape(shape); Handle(AIS_Shape) aisShape = new AIS_Shape(shape);
// 设置材质 // 设置材质
Handle(Prs3d_Drawer) drawer = aisShape->Attributes(); 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->SetFaceBoundaryDraw(true);
drawer->SetWireAspect(aLineAspect); drawer->SetWireAspect(v3ddrawer->v3d_LineAspect);
drawer->SetShadingAspect(shadingAspect); drawer->SetShadingAspect(v3ddrawer->v3d_ShadingAspect);
v3dctx->ctx->Display(aisShape, true); v3dctx->ctx->Display(aisShape, true);
// ctx->context->SetDisplayMode(AIS_WireFrame, Standard_False);
shapes_.push_back(aisShape); shapes_.push_back(aisShape);
} }
} }
@ -175,8 +136,8 @@ bool NativeRender::loadModel(const std::string &filePath) {
// setTranslation // setTranslation
void NativeRender::setTranslation(float tx, float ty) { void NativeRender::setTranslation(float tx, float ty) {
nAxis->SetTranslationX(tx); v3dTri->SetTranslationX(tx);
nAxis->SetTranslationY(ty); v3dTri->SetTranslationY(ty);
} }
void NativeRender::render() { 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::setRotation(float xAngle, float yAngle) { v3dcr->SetRotation(xAngle, yAngle); }
void NativeRender::setZoomLevel(float zoom) { 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::setClearColor(float r, float g, float b, float a) { v3dview->SetClearColor(r, g, b, a); }
void NativeRender::resetView() { v3dview->ResetView(); } void NativeRender::resetView() { v3dview->ResetView(); }

View File

@ -15,7 +15,8 @@
#include <BRepBndLib.hxx> #include <BRepBndLib.hxx>
#include <BRepBuilderAPI_Transform.hxx> #include <BRepBuilderAPI_Transform.hxx>
#include "V3d/Axis/Axis.h" #include "V3d/V3dTri/V3dTri.h"
#include "V3d/V3dTri/V3dTriCube.h"
#include "V3d/V3dCa/V3dCa.h" #include "V3d/V3dCa/V3dCa.h"
#include "V3d/V3dCtx/V3dCtx.h" #include "V3d/V3dCtx/V3dCtx.h"
#include "V3d/V3dOGD/V3dOGD.h" #include "V3d/V3dOGD/V3dOGD.h"
@ -48,8 +49,8 @@ private:
int width; int width;
int height; int height;
EGLCore eglCore; EGLCore eglCore;
Axis* mAxis; V3dTri* v3dTri;
Axis* nAxis; V3dTriCube* v3dTriCube;
V3dCa* v3dcr; V3dCa* v3dcr;
V3dCtx* v3dctx; V3dCtx* v3dctx;
V3dOGD* v3dogd; V3dOGD* v3dogd;

View File

@ -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<int>(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; }
}

View File

@ -23,6 +23,7 @@ V3dCtx::~V3dCtx() {
bool V3dCtx::InitV3dCtx(Handle(V3d_Viewer)& viewer) { bool V3dCtx::InitV3dCtx(Handle(V3d_Viewer)& viewer) {
ctx = new AIS_InteractiveContext(viewer); ctx = new AIS_InteractiveContext(viewer);
if(!ctx.IsNull()){ if(!ctx.IsNull()){
InitCtxOpts();
HILOG_INFO(NATIVE_TAG, "InitCtx Done"); HILOG_INFO(NATIVE_TAG, "InitCtx Done");
return true; return true;
}else{ }else{
@ -30,5 +31,10 @@ bool V3dCtx::InitV3dCtx(Handle(V3d_Viewer)& viewer) {
return false; return false;
} }
} }
void V3dCtx::InitCtxOpts(){
ctx->SetDisplayMode(AIS_Shaded,false);
}
void V3dCtx::ChangeDisplayMode(AIS_DisplayMode thisMode){
ctx->SetDisplayMode(thisMode,false);
}
} }

View File

@ -21,6 +21,8 @@ public:
V3dCtx(); V3dCtx();
~V3dCtx(); ~V3dCtx();
bool InitV3dCtx(Handle(V3d_Viewer)& viewer); bool InitV3dCtx(Handle(V3d_Viewer)& viewer);
void InitCtxOpts();
void ChangeDisplayMode(AIS_DisplayMode thieMode);
public: public:
Handle(AIS_InteractiveContext) ctx; Handle(AIS_InteractiveContext) ctx;
}; };

View File

@ -49,19 +49,28 @@ bool V3dDrawer::InitV3dAllAspect(Handle(AIS_InteractiveContext)& ctx) {
return false; return false;
} }
} }
void V3dDrawer::InitV3dDrawer(){
//所有面的边界线
drawer->SetFaceBoundaryDraw(true);
}
void V3dDrawer::InitV3dIsoAspectOpts() { void V3dDrawer::InitV3dIsoAspectOpts() {
v3d_IsoAspect->SetWidth(1.0); v3d_IsoAspect->SetWidth(1.0);
} }
void V3dDrawer::InitV3dLineAspectOpts() { 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() { void V3dDrawer::InitV3dTextAspectOpts() {
v3d_TextAspect->SetFont("HarmonyOS Sans"); v3d_TextAspect->SetFont("HarmonyOS Sans");
v3d_TextAspect->SetHeight(35); v3d_TextAspect->SetHeight(35);
} }
void V3dDrawer::InitV3dShadingAspectOpts() { void V3dDrawer::InitV3dShadingAspectOpts() {
v3d_ShadingAspect->SetColor(Quantity_NOC_YELLOW);
v3d_ShadingAspect->SetMaterial(Graphic3d_NOM_PLASTIC);
} }
void V3dDrawer::InitV3dPlaneAspectOpts() { void V3dDrawer::InitV3dPlaneAspectOpts() {
@ -73,6 +82,5 @@ void V3dDrawer::InitV3dDatumAspectOpts() {
} }
void V3dDrawer::InitV3dDimAspectOpts() { void V3dDrawer::InitV3dDimAspectOpts() {
} }
} }

View File

@ -28,6 +28,7 @@ public:
~V3dDrawer(); ~V3dDrawer();
bool InitV3dAllAspect(Handle(AIS_InteractiveContext)& ctx); bool InitV3dAllAspect(Handle(AIS_InteractiveContext)& ctx);
private: private:
void InitV3dDrawer();
void InitV3dIsoAspectOpts(); void InitV3dIsoAspectOpts();
void InitV3dLineAspectOpts(); void InitV3dLineAspectOpts();
void InitV3dTextAspectOpts(); void InitV3dTextAspectOpts();

View File

@ -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; }
}

View File

@ -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, // Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
// please include "napi/native_api.h". // please include "napi/native_api.h".
#ifndef OPENCAX_AXIS_H #ifndef OPENCAX_V3DTRIEDRON_H
#define OPENCAX_AXIS_H #define OPENCAX_V3DTRIEDRON_H
#include "AIS_ViewCube.hxx"
#include "NativeEGLOCCT/common.h" #include "NativeEGLOCCT/common.h"
#include <AIS_Trihedron.hxx> #include <AIS_Trihedron.hxx>
#include <AIS_InteractiveContext.hxx> #include <AIS_InteractiveContext.hxx>
#include <Geom_Axis2Placement.hxx> #include <Geom_Axis2Placement.hxx>
namespace NativeOpenCAX { namespace NativeOpenCAX {
class Axis { class V3dTri {
public: public:
Axis(); V3dTri();
~Axis(); ~V3dTri();
bool InitAxis(Handle(AIS_InteractiveContext)& context); bool InitV3dTri(Handle(AIS_InteractiveContext)& ctx);
bool InitAxisCube(Handle(AIS_InteractiveContext) & context); void SetRotationX(float rx);
void SetRotationX(float x); void SetRotationY(float ry);
void SetRotationY(float y); void SetRotationZ(float rz);
void SetRotationZ(float z); void SetTranslationX(float tx);
void SetTranslationX(float x); void SetTranslationY(float ty);
void SetTranslationY(float y); void SetTranslationZ(float tz);
void SetTranslationZ(float z);
void SetZoomLevel(float level); void SetZoomLevel(float level);
private: public:
Handle(Geom_Axis2Placement) axiPlacement; Handle(Geom_Axis2Placement) axiPlam;
Handle(AIS_Trihedron) axiTrihedron; Handle(AIS_Trihedron) axiTri;
//定义三面体
Handle(AIS_ViewCube) axiViewCube;
private: private:
//旋转X轴 //旋转X轴
float rotationX=0.0f; float rotationX=0.0f;
@ -48,7 +42,7 @@ private:
float translationY=0.0f; float translationY=0.0f;
//翻转Z轴 //翻转Z轴
float translationZ=0.0f; float translationZ=0.0f;
}; };
} }
#endif //OPENCAX_V3DTRIEDRON_H
#endif //OPENCAX_AXIS_H

View File

@ -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<int>(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;
}
}
}

View File

@ -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 <AIS_InteractiveContext.hxx>
#include <Graphic3d_TransformPers.hxx>
#include <AIS_ViewCube.hxx>
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

View File

@ -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){
}
}

View File

@ -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 <AIS_Trihedron.hxx>
#include <AIS_InteractiveContext.hxx>
#include <Geom_Axis2Placement.hxx>
namespace NativeOpenCAX {
class V3dWCSTri {
public:
V3dWCSTri();
~V3dWCSTri();
bool InitV3dWCSTri(Handle(AIS_InteractiveContext)& ctx);
};
}
#endif //OPENCAX_V3DTRIEDRON_H