归一化一些参数
This commit is contained in:
parent
5f9af295f8
commit
f65b6ed3f9
@ -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)
|
||||
|
||||
@ -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(); }
|
||||
|
||||
@ -15,7 +15,8 @@
|
||||
#include <BRepBndLib.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/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;
|
||||
|
||||
@ -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; }
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
};
|
||||
|
||||
@ -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() {
|
||||
|
||||
}
|
||||
}
|
||||
@ -28,6 +28,7 @@ public:
|
||||
~V3dDrawer();
|
||||
bool InitV3dAllAspect(Handle(AIS_InteractiveContext)& ctx);
|
||||
private:
|
||||
void InitV3dDrawer();
|
||||
void InitV3dIsoAspectOpts();
|
||||
void InitV3dLineAspectOpts();
|
||||
void InitV3dTextAspectOpts();
|
||||
|
||||
79
entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTri.cpp
Normal file
79
entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTri.cpp
Normal 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; }
|
||||
|
||||
}
|
||||
@ -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 <AIS_Trihedron.hxx>
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <Geom_Axis2Placement.hxx>
|
||||
|
||||
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
|
||||
51
entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTriCube.cpp
Normal file
51
entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTriCube.cpp
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
37
entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTriCube.h
Normal file
37
entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dTriCube.h
Normal 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
|
||||
25
entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.cpp
Normal file
25
entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.cpp
Normal 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){
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
22
entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.h
Normal file
22
entry/src/main/cpp/NativeEGLOCCT/V3d/V3dTri/V3dWCSTri.h
Normal 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
|
||||
Loading…
Reference in New Issue
Block a user