增加视图切换功能,但是需要归一化操作.
目前只是实现了功能.需要对初始世界坐标进行标定
This commit is contained in:
parent
dc2d4d0b26
commit
6a4e702dbd
@ -1,6 +1,7 @@
|
||||
{
|
||||
"app": {
|
||||
"signingConfigs": [],
|
||||
|
||||
"products": [
|
||||
{
|
||||
"name": "default",
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
"buildOptionSet": [
|
||||
{
|
||||
"name": "release",
|
||||
|
||||
@ -63,7 +63,7 @@ find_library(GLES-lib GLESv3)
|
||||
#System so
|
||||
set(SYSTEM_LIBS
|
||||
libace_napi.z.so libnative_window.so libnative_display_manager.so
|
||||
hilog_ndk.z ace_ndk.z uv z
|
||||
hilog_ndk.z ace_ndk.z libohinput.so uv z
|
||||
)
|
||||
|
||||
# 链接系统库
|
||||
|
||||
@ -12,16 +12,96 @@
|
||||
|
||||
namespace NativeOpenCAX {
|
||||
|
||||
bool InitCamera(RenderOption& opt) {
|
||||
bool InitCamera(RenderOption &opt) {
|
||||
if (opt.camera.IsNull()) {
|
||||
// 设置相机参数
|
||||
opt.camera = opt.view->Camera();
|
||||
opt.camera->SetFOVy(45.0); // 使用正确的FOV设置API
|
||||
opt.camera->SetZRange(1.0, 1000.0);
|
||||
HILOG_INFO(NATIVE_TAG,"InitCamera Done");
|
||||
HILOG_INFO(NATIVE_TAG, "InitCamera Done");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 主视图 (Front View)
|
||||
void FrontView(RenderOption &opt) {
|
||||
opt.view->SetProj(V3d_XposYposZneg); // 先设置坐标系,Y向上是常用选择
|
||||
opt.view->SetAt(0, 0, 0); // 设置目标点为中心
|
||||
opt.view->SetEye(0, 0, 1);
|
||||
opt.view->FitAll();
|
||||
opt.view->Redraw();
|
||||
}
|
||||
|
||||
// 俯视图 (Top View)
|
||||
void TopView(RenderOption &opt) {
|
||||
opt.view->SetProj(V3d_XposYnegZpos);
|
||||
opt.view->SetAt(0, 0, 0);
|
||||
opt.view->SetEye(0, -1, 0);
|
||||
opt.view->FitAll();
|
||||
opt.view->Redraw();
|
||||
}
|
||||
|
||||
// 左视图 (Left View)
|
||||
// 观察方向为 -X, Z轴向上
|
||||
void LeftSideView(RenderOption &opt) {
|
||||
opt.view->SetProj(V3d_XnegYnegZpos);
|
||||
opt.view->SetAt(0, 0, 0);
|
||||
opt.view->SetEye(1, 0, 0); // 从 X 轴正方向向左看
|
||||
opt.view->FitAll();
|
||||
opt.view->Redraw();
|
||||
}
|
||||
|
||||
// 右视图 (Right View)
|
||||
// 观察方向为 +X, Z轴向上
|
||||
void RightSideView(RenderOption &opt) {
|
||||
opt.view->SetProj(V3d_XposYnegZpos);
|
||||
opt.view->SetAt(0, 0, 0);
|
||||
opt.view->SetEye(-1, 0, 0); // 从 X 轴负方向向右看
|
||||
opt.view->FitAll();
|
||||
opt.view->Redraw();
|
||||
}
|
||||
|
||||
// 仰视图 (Bottom View)
|
||||
// 观察方向为 +Y, Z轴向上
|
||||
void BottomView(RenderOption &opt) {
|
||||
opt.view->SetProj(V3d_XposYposZpos);
|
||||
opt.view->SetAt(0, 0, 0);
|
||||
opt.view->SetEye(0, 1, 0);
|
||||
opt.view->FitAll();
|
||||
opt.view->Redraw();
|
||||
}
|
||||
|
||||
// 后视图 (Back View)
|
||||
// 观察方向为 +Z, Y轴向上
|
||||
void RearView(RenderOption &opt) {
|
||||
opt.view->SetProj(V3d_XnegYposZpos);
|
||||
opt.view->SetAt(0, 0, 0);
|
||||
opt.view->SetEye(0, 0, -1); // 从 Z 轴负方向向前看
|
||||
opt.view->FitAll();
|
||||
opt.view->Redraw();
|
||||
}
|
||||
|
||||
// 正等轴测图 (Isometric View)
|
||||
void ISOView(RenderOption &opt) {
|
||||
opt.view->SetProj(V3d_XposYposZpos); // 先重置一个标准方向作为参考
|
||||
opt.view->SetAt(0, 0, 0); // 观察目标点
|
||||
// 经典的等轴测视角,从 (1, 1, 1) 方向看过去
|
||||
double dist = 1000.0; // 距离,影响缩放
|
||||
opt.view->SetEye(dist, dist, dist);
|
||||
// 为了美观,通常还需要将视角调整为框满模型
|
||||
opt.view->FitAll();
|
||||
opt.view->Redraw();
|
||||
}
|
||||
|
||||
// 正二等轴测图 (Diametric View)
|
||||
void DIMView(RenderOption &opt) {
|
||||
opt.view->SetAt(0, 0, 0);
|
||||
double dist = 1000.0;
|
||||
opt.view->SetEye(-dist, -dist, dist * 0.5);
|
||||
opt.view->FitAll();
|
||||
opt.view->Redraw();
|
||||
}
|
||||
|
||||
void ChangeCarmera() {}
|
||||
}
|
||||
@ -9,10 +9,18 @@
|
||||
|
||||
#include "../RenderStruct.h"
|
||||
|
||||
namespace NativeOpenCAX{
|
||||
namespace NativeOpenCAX {
|
||||
|
||||
bool InitCamera(RenderOption& opt);
|
||||
bool InitCamera(RenderOption &opt);
|
||||
void ChangeCamera();
|
||||
}
|
||||
void FrontView(RenderOption &opt);
|
||||
void TopView(RenderOption &opt);
|
||||
void LeftSideView(RenderOption &opt);
|
||||
void RightSideView(RenderOption &opt);
|
||||
void BottomView(RenderOption &opt);
|
||||
void RearView(RenderOption &opt);
|
||||
void ISOView(RenderOption &opt);
|
||||
void DIMView(RenderOption &opt);
|
||||
} // namespace NativeOpenCAX
|
||||
|
||||
#endif //OPENCAX_CAMERA_H
|
||||
#endif // OPENCAX_CAMERA_H
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#ifndef NATIVE_TAG
|
||||
#define NATIVE_TAG "NativeManager"
|
||||
#endif
|
||||
#include "arkui/ui_input_event.h"
|
||||
|
||||
namespace NativeOpenCAX {
|
||||
// [Start plugin_manager_cpp]
|
||||
@ -31,13 +32,13 @@ ArkUI_NativeNodeAPI_1 *nodeAPI = reinterpret_cast<ArkUI_NativeNodeAPI_1 *>(
|
||||
NativeManager NativeManager::pluginManager_;
|
||||
OH_NativeXComponent_Callback NativeManager::xSurfaceTouchEventCallBack;
|
||||
OH_NativeXComponent_MouseEvent_Callback NativeManager::xMouseEventCallBack;
|
||||
|
||||
std::string comId;
|
||||
std::string nodeId;
|
||||
int32_t NativeManager::hasDraw_ = 0;
|
||||
int32_t NativeManager::hasChangeColor_ = 0;
|
||||
static std::map<int64_t, std::shared_ptr<NativeRenderThread>> renderThreadMap;
|
||||
static std::mutex mapMutex;
|
||||
|
||||
|
||||
NativeManager::~NativeManager() {
|
||||
OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Callback", "~NativeManager");
|
||||
@ -140,6 +141,7 @@ void NativeManager::OnSurfaceCreated(OH_NativeXComponent *component, void *windo
|
||||
"ERROR: window is NULL in OnSurfaceCreated!");
|
||||
return;
|
||||
}
|
||||
|
||||
OH_NativeXComponent_GetXComponentSize(component, window, &width_, &height_);
|
||||
int64_t id = 0;
|
||||
std::lock_guard<std::mutex> lock(mapMutex);
|
||||
@ -162,7 +164,7 @@ void NativeManager::OnSurfaceDestroyed(OH_NativeXComponent *component, void *win
|
||||
}
|
||||
void NativeManager::OnSurfaceChanged(OH_NativeXComponent *component, void *window) {
|
||||
OH_NativeXComponent_GetXComponentSize(component, window, &width_, &height_);
|
||||
|
||||
|
||||
int64_t id = 0;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mapMutex);
|
||||
@ -191,16 +193,28 @@ void OnMouseEventCB(OH_NativeXComponent* component, void* window) {
|
||||
auto *pluginManger = NativeManager::GetInstance();
|
||||
pluginManger->OnMouseEvent(component, window);
|
||||
}
|
||||
void NativeManager::OnMouseEvent(OH_NativeXComponent *component, void *window) {
|
||||
OH_NativeXComponent_MouseEvent event;
|
||||
void NativeManager::OnMouseEvent(OH_NativeXComponent *comp, void *win) {
|
||||
int32_t ret;
|
||||
ret=OH_NativeXComponent_GetMouseEvent(component, window, &event);
|
||||
std::lock_guard<std::mutex> lock(mapMutex);
|
||||
//通过时间戳判断事件唯一性.保证单一时间戳只触发一次事件
|
||||
if(event.timestamp==NativeManager::timestamp){
|
||||
OH_NativeXComponent_MouseEvent mouseEvent;
|
||||
ret = OH_NativeXComponent_GetMouseEvent(comp, win, &mouseEvent);
|
||||
if (ret != OH_NATIVEXCOMPONENT_RESULT_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
NativeManager::timestamp=event.timestamp;
|
||||
OH_NativeXComponent_ExtraMouseEventInfo* extra = NULL;
|
||||
|
||||
ret = OH_NativeXComponent_GetExtraMouseEventInfo(comp, &extra);
|
||||
|
||||
if (ret != OH_NATIVEXCOMPONENT_RESULT_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
//Test Mouse MIDDLE_BUTTON Long Press
|
||||
//HILOG_WARN(NATIVE_TAG, "ExtraMouseEventInfo:%{public}s",extra);
|
||||
std::lock_guard<std::mutex> lock(mapMutex);
|
||||
//通过时间戳判断事件唯一性.保证单一时间戳只触发一次事件
|
||||
if(mouseEvent.timestamp==NativeManager::timestamp){
|
||||
return;
|
||||
}
|
||||
NativeManager::timestamp=mouseEvent.timestamp;
|
||||
int64_t id = 0;
|
||||
auto it = renderThreadMap.find(id);
|
||||
if (it == renderThreadMap.end()) {
|
||||
@ -209,25 +223,27 @@ void NativeManager::OnMouseEvent(OH_NativeXComponent *component, void *window) {
|
||||
}
|
||||
auto renderThread = it->second;
|
||||
float curtX,curtY;
|
||||
HILOG_WARN(NATIVE_TAG, "ALLButton:%{public}d",event.button);
|
||||
HILOG_WARN(NATIVE_TAG, "ALLAction:%{public}d",event.action);
|
||||
HILOG_WARN(NATIVE_TAG, "ALLTimestamp:%{public}d",event.timestamp);
|
||||
//HILOG_WARN(NATIVE_TAG, "ALLButton:%{public}d",mouseEvent.button);
|
||||
//HILOG_WARN(NATIVE_TAG, "ALLAction:%{public}d",mouseEvent.action);
|
||||
//HILOG_WARN(NATIVE_TAG, "ALLTimestamp:%{public}d",mouseEvent.timestamp);
|
||||
|
||||
|
||||
//鼠标按下并且事件为鼠标中键
|
||||
if(event.button==OH_NATIVEXCOMPONENT_LEFT_BUTTON&&event.action==OH_NATIVEXCOMPONENT_MOUSE_PRESS){
|
||||
if(mouseEvent.button==OH_NATIVEXCOMPONENT_LEFT_BUTTON&&mouseEvent.action==OH_NATIVEXCOMPONENT_MOUSE_PRESS){
|
||||
if(NativeManager::isMouseMiddleBtnPressed){
|
||||
NativeManager::isMouseMiddleBtnPressed=false;
|
||||
return;
|
||||
}
|
||||
//记录按下时候的X.Y坐标
|
||||
NativeManager::lastMouseX_=event.x;
|
||||
NativeManager::lastMouseY_=event.y;
|
||||
NativeManager::lastMouseX_=mouseEvent.x;
|
||||
NativeManager::lastMouseY_=mouseEvent.y;
|
||||
NativeManager::isMouseMiddleBtnPressed = true;
|
||||
HILOG_WARN(NATIVE_TAG, "AtlastMouseX:%{public}d",NativeManager::lastMouseX_);
|
||||
HILOG_WARN(NATIVE_TAG, "AtlastMouseY:%{public}d",NativeManager::lastMouseY_);
|
||||
HILOG_WARN(NATIVE_TAG, "AtButton:%{public}d",event.button);
|
||||
HILOG_WARN(NATIVE_TAG, "AtButtonAction:%{public}d",event.action);
|
||||
HILOG_WARN(NATIVE_TAG, "AtisMouseMiddleBtnPressed:%{public}d",NativeManager::isMouseMiddleBtnPressed);
|
||||
}else if(event.action==OH_NATIVEXCOMPONENT_MOUSE_MOVE&&NativeManager::isMouseMiddleBtnPressed){
|
||||
//HILOG_WARN(NATIVE_TAG, "AtlastMouseX:%{public}d",NativeManager::lastMouseX_);
|
||||
//HILOG_WARN(NATIVE_TAG, "AtlastMouseY:%{public}d",NativeManager::lastMouseY_);
|
||||
//HILOG_WARN(NATIVE_TAG, "AtButton:%{public}d",mouseEvent.button);
|
||||
//HILOG_WARN(NATIVE_TAG, "AtButtonAction:%{public}d",mouseEvent.action);
|
||||
//HILOG_WARN(NATIVE_TAG, "AtisMouseMiddleBtnPressed:%{public}d",NativeManager::isMouseMiddleBtnPressed);
|
||||
}else if(mouseEvent.action==OH_NATIVEXCOMPONENT_MOUSE_MOVE&&NativeManager::isMouseMiddleBtnPressed){
|
||||
// 计算鼠标移动距离
|
||||
float deltaX = curtX - NativeManager::lastMouseX_;
|
||||
float deltaY = curtY - NativeManager::lastMouseY_;
|
||||
@ -242,11 +258,11 @@ void NativeManager::OnMouseEvent(OH_NativeXComponent *component, void *window) {
|
||||
// 更新最后的位置
|
||||
//NativeManager::lastMouseX_ = deltaX;
|
||||
//NativeManager::lastMouseY_ = deltaY;
|
||||
HILOG_WARN(NATIVE_TAG, "MoveAngleX:%{public}d",angleX);
|
||||
HILOG_WARN(NATIVE_TAG, "MoveAngleY:%{public}d",angleY);
|
||||
HILOG_WARN(NATIVE_TAG, "MoveButton:%{public}d",event.button);
|
||||
HILOG_WARN(NATIVE_TAG, "MoveButtonAction:%{public}d",event.action);
|
||||
HILOG_WARN(NATIVE_TAG, "MoveIsMouseMiddleBtnPressed:%{public}d",NativeManager::isMouseMiddleBtnPressed);
|
||||
//HILOG_WARN(NATIVE_TAG, "MoveAngleX:%{public}d",angleX);
|
||||
//HILOG_WARN(NATIVE_TAG, "MoveAngleY:%{public}d",angleY);
|
||||
//HILOG_WARN(NATIVE_TAG, "MoveButton:%{public}d",mouseEvent.button);
|
||||
//HILOG_WARN(NATIVE_TAG, "MoveButtonAction:%{public}d",mouseEvent.action);
|
||||
//HILOG_WARN(NATIVE_TAG, "MoveIsMouseMiddleBtnPressed:%{public}d",NativeManager::isMouseMiddleBtnPressed);
|
||||
}
|
||||
|
||||
}
|
||||
@ -258,6 +274,16 @@ static std::string value2String(napi_env env, napi_value value) {
|
||||
napi_get_value_string_utf8(env, value, &valueString[0], stringSize + 1, &stringSize);
|
||||
return valueString;
|
||||
}
|
||||
struct AxisEvent {
|
||||
int32_t axisAction;
|
||||
float displayX;
|
||||
float displayY;
|
||||
std::map<int32_t, double> axisValues;
|
||||
int64_t actionTime { -1 };
|
||||
int32_t sourceType;
|
||||
int32_t axisEventType { -1 };
|
||||
};
|
||||
|
||||
// XComponent回调事件
|
||||
NativeManager::NativeManager() {
|
||||
xSurfaceTouchEventCallBack.OnSurfaceCreated = OnSurfaceCreatedCB;
|
||||
@ -313,6 +339,43 @@ ArkUI_NodeHandle CreateNodeHandle(const std::string &tag) {
|
||||
OH_NativeXComponent_RegisterCallback(nativeXComponent, &NativeManager::xSurfaceTouchEventCallBack);
|
||||
//注册XComponent组件鼠标回调事件
|
||||
OH_NativeXComponent_RegisterMouseEventCallback(nativeXComponent, &NativeManager::xMouseEventCallBack);
|
||||
// nodeAPI->registerNodeEvent(xc, NODE_ON_MOUSE, 1, &xc);
|
||||
// nodeAPI->registerNodeEvent(xc, NODE_ON_AXIS, 1, &xc);
|
||||
// nodeAPI->addNodeEventReceiver(xc, [](ArkUI_NodeEvent *event) {
|
||||
// auto *inputEvent = OH_ArkUI_NodeEvent_GetInputEvent(event);
|
||||
// auto eventType = OH_ArkUI_UIInputEvent_GetType(inputEvent);
|
||||
// if (OH_ArkUI_NodeEvent_GetEventType(event) == NODE_ON_AXIS ) {
|
||||
// HILOG_WARN(NATIVE_TAG, "NODE_ON_AXIS:%{public}d",OH_ArkUI_NodeEvent_GetEventType(event));
|
||||
// }
|
||||
// if (eventType == ARKUI_UIINPUTEVENT_TYPE_MOUSE) {
|
||||
// auto action = OH_ArkUI_MouseEvent_GetMouseAction(inputEvent);
|
||||
// auto button= OH_ArkUI_MouseEvent_GetMouseButton(inputEvent);
|
||||
// //HILOG_WARN(NATIVE_TAG, "MouseAction:%{public}d",action);
|
||||
// //HILOG_WARN(NATIVE_TAG, "MouseButton:%{public}d",button);
|
||||
//
|
||||
// int32_t buttonArray[10];
|
||||
// int32_t arraySize = sizeof(buttonArray) / sizeof(buttonArray[0]);
|
||||
// int32_t actualCount = arraySize; // 将数组大小存入actualCount,作为输入值
|
||||
// int32_t ret = OH_ArkUI_MouseEvent_GetPressedButtons(inputEvent, buttonArray, &actualCount);
|
||||
//
|
||||
// // --- 步骤 3: 检查API调用结果 ---
|
||||
// if (ret != 0) {
|
||||
// HILOG_WARN(NATIVE_TAG, "Error getting pressed mouse buttons. Error code: %{public}d\n", ret);
|
||||
// return;
|
||||
// }
|
||||
// for (int i = 0; i < actualCount; ++i) {
|
||||
// HILOG_WARN(NATIVE_TAG, "Curt code: %{public}d\n", buttonArray[i]);
|
||||
// // 根据常见的鼠标按钮ID进行解释 (具体ID定义请查阅官方文档)
|
||||
// // 通常 1=主按钮(左键), 2=辅助按钮(右键), 3=中间按钮(滚轮)
|
||||
// switch (buttonArray[i]) {
|
||||
// case 1: HILOG_WARN(NATIVE_TAG, "MouseButton:Left");break;
|
||||
// case 2: HILOG_WARN(NATIVE_TAG, "MouseButton:Right");break;
|
||||
// case 3: HILOG_WARN(NATIVE_TAG, "MouseButton:Middle"); break;
|
||||
// default: printf("(Other_%d) ", buttonArray[i]); break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// 组件类型
|
||||
auto comTypeRet = nodeAPI->getAttribute(xc, NODE_XCOMPONENT_TYPE);
|
||||
HILOG_INFO(NATIVE_TAG,"XCom type: %{public}d",comTypeRet->value[0].i32);
|
||||
@ -424,4 +487,34 @@ napi_value NativeManager::NapiLoadModel(napi_env env, napi_callback_info info) {
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//切换视图
|
||||
napi_value NativeManager::SwitchView(napi_env env, napi_callback_info info){
|
||||
size_t argc = 1;
|
||||
napi_value args[1];
|
||||
napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
|
||||
std::string viewName = value2String(env, args[0]);
|
||||
int64_t id = 0;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mapMutex);
|
||||
if (renderThreadMap.find(id) != renderThreadMap.end()) {
|
||||
renderThreadMap[id]->swicthView(viewName);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//显示模型边界
|
||||
napi_value NativeManager::displayModelEdges(napi_env env, napi_callback_info info){
|
||||
|
||||
}
|
||||
//显示模型线框
|
||||
napi_value NativeManager::displayHLR(napi_env env, napi_callback_info info){
|
||||
|
||||
}
|
||||
//显示隐藏线
|
||||
napi_value NativeManager::displayHL(napi_env env, napi_callback_info info){
|
||||
|
||||
}
|
||||
|
||||
} // namespace NativeOpenCAX
|
||||
|
||||
@ -27,6 +27,12 @@
|
||||
#include "arkui/native_node_napi.h"
|
||||
#include "NativeRenderThread.h"
|
||||
|
||||
#include "arkui/ui_input_event.h"
|
||||
#include <multimodalinput/oh_input_manager.h>
|
||||
#include <arkui/native_key_event.h>
|
||||
#include <arkui/native_node.h>
|
||||
#include <arkui/native_type.h>
|
||||
|
||||
namespace NativeOpenCAX {
|
||||
|
||||
constexpr const int FIRST_ARG = 1;
|
||||
@ -41,6 +47,7 @@ public:
|
||||
static OH_NativeXComponent_Callback xSurfaceTouchEventCallBack;
|
||||
//鼠标事件回调
|
||||
static OH_NativeXComponent_MouseEvent_Callback xMouseEventCallBack;
|
||||
|
||||
NativeManager();
|
||||
~NativeManager();
|
||||
|
||||
@ -52,6 +59,15 @@ public:
|
||||
static napi_value SetFrameRate(napi_env env, napi_callback_info info);
|
||||
static napi_value SetNeedSoftKeyboard(napi_env env, napi_callback_info info);
|
||||
static napi_value NapiLoadModel(napi_env env, napi_callback_info info);
|
||||
//切换视图
|
||||
static napi_value SwitchView(napi_env env, napi_callback_info info);
|
||||
//显示模型边界
|
||||
static napi_value displayModelEdges(napi_env env, napi_callback_info info);
|
||||
//显示模型线框
|
||||
static napi_value displayHLR(napi_env env, napi_callback_info info);
|
||||
//显示隐藏线
|
||||
static napi_value displayHL(napi_env env, napi_callback_info info);
|
||||
|
||||
// CApi XComponent
|
||||
void OnSurfaceChanged(OH_NativeXComponent* component, void* window);
|
||||
void OnSurfaceDestroyed(OH_NativeXComponent* component, void* window);
|
||||
|
||||
@ -235,5 +235,28 @@ void NativeRender::setClearColor(float r, float g, float b, float a) {
|
||||
rendOption.view->SetBackgroundColor(rendOption.clearColor);
|
||||
}
|
||||
}
|
||||
|
||||
void NativeRender::SetFrontView(){
|
||||
FrontView(rendOption);
|
||||
}
|
||||
void NativeRender::SetTopView(){
|
||||
TopView(rendOption);
|
||||
}
|
||||
void NativeRender::SetLeftSideView(){
|
||||
LeftSideView(rendOption);
|
||||
}
|
||||
void NativeRender::SetRightSideView(){
|
||||
RightSideView(rendOption);
|
||||
}
|
||||
void NativeRender::SetBottomView(){
|
||||
BottomView(rendOption);
|
||||
}
|
||||
void NativeRender::SetRearView(){
|
||||
RearView(rendOption);
|
||||
}
|
||||
void NativeRender::SetISOView(){
|
||||
ISOView(rendOption);
|
||||
}
|
||||
void NativeRender::SetDIMView(){
|
||||
DIMView(rendOption);
|
||||
}
|
||||
} // namespace NativeRenderer
|
||||
@ -35,6 +35,15 @@ public:
|
||||
void setZoomLevel(float zoom);
|
||||
void setTranslation(float x, float y);
|
||||
void setCameraRotationMode(bool state);
|
||||
//视图
|
||||
void SetFrontView();
|
||||
void SetTopView();
|
||||
void SetLeftSideView();
|
||||
void SetRightSideView();
|
||||
void SetBottomView();
|
||||
void SetRearView();
|
||||
void SetISOView();
|
||||
void SetDIMView();
|
||||
private:
|
||||
RenderOption rendOption;
|
||||
AxisOption axis;
|
||||
|
||||
@ -98,6 +98,30 @@ void NativeRenderThread::renderLoop() {
|
||||
windowHeight_ = static_cast<int>(command.param3);
|
||||
renderer_.resize(windowWidth_, windowHeight_);
|
||||
break;
|
||||
case CMD_VIEW_FRONT:
|
||||
renderer_.SetFrontView();
|
||||
break;
|
||||
case CMD_VIEW_TOP:
|
||||
renderer_.SetFrontView();
|
||||
break;
|
||||
case CMD_VIEW_LEFT_SIDE:
|
||||
renderer_.SetFrontView();
|
||||
break;
|
||||
case CMD_VIEW_RIGHT_SIDE:
|
||||
renderer_.SetFrontView();
|
||||
break;
|
||||
case CMD_VIEW_BOTTOM:
|
||||
renderer_.SetFrontView();
|
||||
break;
|
||||
case CMD_VIEW_REAR:
|
||||
renderer_.SetFrontView();
|
||||
break;
|
||||
case CMD_VIEW_ISO:
|
||||
renderer_.SetFrontView();
|
||||
break;
|
||||
case CMD_VIEW_DIM:
|
||||
renderer_.SetFrontView();
|
||||
break;
|
||||
case CMD_EXIT:
|
||||
isRunning_ = false;
|
||||
break;
|
||||
@ -157,7 +181,36 @@ void NativeRenderThread::resetView() {
|
||||
commandQueue_.push(RenderCommand(CMD_RESET_VIEW));
|
||||
commandCondition_.notify_one();
|
||||
}
|
||||
|
||||
void NativeRenderThread::swicthView(std::string strView) {
|
||||
std::lock_guard<std::mutex> lock(commandMutex_);
|
||||
CommandType cmdType;
|
||||
if(strView=="CMD_VIEW_FRONT"){
|
||||
cmdType=CMD_VIEW_FRONT;
|
||||
}
|
||||
if(strView=="CMD_VIEW_TOP"){
|
||||
cmdType=CMD_VIEW_TOP;
|
||||
}
|
||||
if(strView=="CMD_VIEW_LEFT_SIDE"){
|
||||
cmdType=CMD_VIEW_LEFT_SIDE;
|
||||
}
|
||||
if(strView=="CMD_VIEW_RIGHT_SIDE"){
|
||||
cmdType=CMD_VIEW_RIGHT_SIDE;
|
||||
}
|
||||
if(strView=="CMD_VIEW_BOTTOM"){
|
||||
cmdType=CMD_VIEW_BOTTOM;
|
||||
}
|
||||
if(strView=="CMD_VIEW_REAR"){
|
||||
cmdType=CMD_VIEW_REAR;
|
||||
}
|
||||
if(strView=="CMD_VIEW_ISO"){
|
||||
cmdType=CMD_VIEW_ISO;
|
||||
}
|
||||
if(strView=="CMD_VIEW_DIM"){
|
||||
cmdType=CMD_VIEW_DIM;
|
||||
}
|
||||
commandQueue_.push(RenderCommand(cmdType));
|
||||
commandCondition_.notify_one();
|
||||
}
|
||||
void NativeRenderThread::setClearColor(float r, float g, float b, float a) {
|
||||
std::lock_guard<std::mutex> lock(commandMutex_);
|
||||
RenderCommand cmd(CMD_SET_CLEAR_COLOR);
|
||||
|
||||
@ -27,7 +27,7 @@ public:
|
||||
void resetView();
|
||||
void setClearColor(float r, float g, float b, float a);
|
||||
void resizeWindow(int width, int height);
|
||||
|
||||
void swicthView(std::string strView);
|
||||
using Callback = std::function<void()>;
|
||||
void registerRenderCompleteCallback(Callback callback);
|
||||
|
||||
@ -51,6 +51,15 @@ private:
|
||||
CMD_RESET_VIEW,
|
||||
CMD_SET_CLEAR_COLOR,
|
||||
CMD_RESIZE,
|
||||
//视图枚举
|
||||
CMD_VIEW_FRONT,
|
||||
CMD_VIEW_TOP,
|
||||
CMD_VIEW_LEFT_SIDE,
|
||||
CMD_VIEW_RIGHT_SIDE,
|
||||
CMD_VIEW_BOTTOM,
|
||||
CMD_VIEW_REAR,
|
||||
CMD_VIEW_ISO,
|
||||
CMD_VIEW_DIM,
|
||||
CMD_EXIT
|
||||
};
|
||||
|
||||
|
||||
@ -45,6 +45,8 @@ static napi_value Init(napi_env env, napi_value exports) {
|
||||
{"setFrameRate", nullptr, NativeManager::SetFrameRate, nullptr, nullptr, nullptr, napi_default, nullptr},
|
||||
{"setNeedSoftKeyboard", nullptr, NativeManager::SetNeedSoftKeyboard, nullptr, nullptr, nullptr, napi_default,nullptr},
|
||||
{"nativeLoadTest", nullptr, NativeLoadSoTest, nullptr, nullptr, nullptr, napi_default, nullptr},
|
||||
//切换视图
|
||||
{"switchView", nullptr, NativeManager::SwitchView, nullptr, nullptr, nullptr,napi_default, nullptr },
|
||||
};
|
||||
napi_status status = napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
|
||||
if (status != napi_ok) {
|
||||
|
||||
@ -3,4 +3,5 @@ export interface NativeXOpenCAX {
|
||||
setNeedSoftKeyboard(nodeId: string, need: boolean): void;
|
||||
}
|
||||
export function createNativeNode(nodeContent: any): void;
|
||||
export function loadModel(stepFilePath: string): void;
|
||||
export function loadModel(stepFilePath: string): void;
|
||||
export function switchView(viewName: string): void;
|
||||
@ -1,4 +1,5 @@
|
||||
import { mwInfo } from "../AppStorageV2Class";
|
||||
import { ExecuteCommand } from "../EventSubWindow/ExecuteCommand";
|
||||
import { TitleButton } from "../LayoutInterface/Interface/ButtonInterface";
|
||||
import {SwitchView} from "../LayoutInterface/Layout/SwitchView"
|
||||
|
||||
@ -21,9 +22,10 @@ export struct ViewDialog {
|
||||
.backgroundImageSize({
|
||||
width: '100%', // 图片宽度占满按钮
|
||||
height: '100%' // 图片高度占满按钮
|
||||
}).width(ebWidth).height(ebWidth)
|
||||
.onClick(()=>{
|
||||
ExecuteCommand(item);
|
||||
})
|
||||
.width(ebWidth)
|
||||
.height(ebWidth)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { TitleButton } from '../LayoutInterface/Interface/ButtonInterface';
|
||||
import { OCCTLoadModel } from '../modelView';
|
||||
import { CloseSubWindow, CreateAndShowSubWindow} from './SWBase';
|
||||
import NativeOpenCAX from 'libopencax.so';
|
||||
|
||||
export function ExecuteCommand(event:TitleButton){
|
||||
if(event?.eEvent=='Execute_LoadModel'){
|
||||
@ -10,4 +11,22 @@ export function ExecuteCommand(event:TitleButton){
|
||||
}else if(event?.eEvent=='Execute_ExitSubWindow'){
|
||||
CloseSubWindow();
|
||||
}
|
||||
|
||||
if(event?.eEvent=='CMD_VIEW_FRONT'){
|
||||
NativeOpenCAX.switchView("CMD_VIEW_FRONT");
|
||||
}else if(event?.eEvent=='CMD_VIEW_TOP'){
|
||||
NativeOpenCAX.switchView("CMD_VIEW_TOP");
|
||||
}else if(event?.eEvent=='CMD_VIEW_LEFT_SIDE'){
|
||||
NativeOpenCAX.switchView("CMD_VIEW_LEFT_SIDE");
|
||||
}else if(event?.eEvent=='CMD_VIEW_RIGHT_SIDE'){
|
||||
NativeOpenCAX.switchView("CMD_VIEW_RIGHT_SIDE");
|
||||
}else if(event?.eEvent=='CMD_VIEW_BOTTOM'){
|
||||
NativeOpenCAX.switchView("CMD_VIEW_BOTTOM");
|
||||
}else if(event?.eEvent=='CMD_VIEW_REAR'){
|
||||
NativeOpenCAX.switchView("CMD_VIEW_REAR");
|
||||
}else if(event?.eEvent=='CMD_VIEW_ISO'){
|
||||
NativeOpenCAX.switchView("CMD_VIEW_ISO");
|
||||
}else if(event?.eEvent=='CMD_VIEW_DIM'){
|
||||
NativeOpenCAX.switchView("CMD_VIEW_DIM");
|
||||
}
|
||||
}
|
||||
@ -3,14 +3,14 @@ import { ModelType } from "./ModelType";
|
||||
|
||||
//视图选择布局数据
|
||||
export let SwitchView:Array<TitleButton>=[
|
||||
{eModel:[ModelType.BASE],eName:"正三轴测图",eNamed:"",ePage:'',eIcon:"base_view_tfr_tri",eTips:"正三轴测图",eEvent:""},
|
||||
{eModel:[ModelType.BASE],eName:"俯视图",eNamed:"",ePage:'',eIcon:"base_view_top",eTips:"俯视图",eEvent:""},
|
||||
{eModel:[ModelType.BASE],eName:"正等测图",eNamed:"",ePage:'',eIcon:"base_view_tfr_iso",eTips:"正等测图",eEvent:""},
|
||||
{eModel:[ModelType.BASE],eName:"正二轴测图",eNamed:"",ePage:'',eIcon:"base_view_tfr_tri",eTips:"正二轴测图",eEvent:"CMD_VIEW_DIM"},
|
||||
{eModel:[ModelType.BASE],eName:"俯视图",eNamed:"",ePage:'',eIcon:"base_view_top",eTips:"俯视图",eEvent:"CMD_VIEW_TOP"},
|
||||
{eModel:[ModelType.BASE],eName:"正等测图",eNamed:"",ePage:'',eIcon:"base_view_tfr_iso",eTips:"正等测图",eEvent:"CMD_VIEW_ISO"},
|
||||
|
||||
{eModel:[ModelType.BASE],eName:"左视图",eNamed:"",ePage:'',eIcon:"base_view_left",eTips:"左视图",eEvent:""},
|
||||
{eModel:[ModelType.BASE],eName:"前视图",eNamed:"",ePage:'',eIcon:"base_view_front",eTips:"前视图",eEvent:""},
|
||||
{eModel:[ModelType.BASE],eName:"右视图",eNamed:"",ePage:'',eIcon:"base_view_right",eTips:"右视图",eEvent:""},
|
||||
{eModel:[ModelType.BASE],eName:"左视图",eNamed:"",ePage:'',eIcon:"base_view_left",eTips:"左视图",eEvent:"CMD_VIEW_LEFT_SIDE"},
|
||||
{eModel:[ModelType.BASE],eName:"前视图",eNamed:"",ePage:'',eIcon:"base_view_front",eTips:"前视图",eEvent:"CMD_VIEW_FRONT"},
|
||||
{eModel:[ModelType.BASE],eName:"右视图",eNamed:"",ePage:'',eIcon:"base_view_right",eTips:"右视图",eEvent:"CMD_VIEW_RIGHT_SIDE"},
|
||||
|
||||
{eModel:[ModelType.BASE],eName:"后视图",eNamed:"",ePage:'',eIcon:"base_view_back",eTips:"后视图",eEvent:""},
|
||||
{eModel:[ModelType.BASE],eName:"仰视图",eNamed:"",ePage:'',eIcon:"base_view_bottom",eTips:"仰视图",eEvent:""},
|
||||
{eModel:[ModelType.BASE],eName:"后视图",eNamed:"",ePage:'',eIcon:"base_view_back",eTips:"后视图",eEvent:"CMD_VIEW_REAR"},
|
||||
{eModel:[ModelType.BASE],eName:"仰视图",eNamed:"",ePage:'',eIcon:"base_view_bottom",eTips:"仰视图",eEvent:"CMD_VIEW_BOTTOM"},
|
||||
]
|
||||
@ -10,6 +10,11 @@
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": false,
|
||||
"pages": "$profile:main_pages",
|
||||
"requestPermissions": [
|
||||
{
|
||||
"name": "ohos.permission.INPUT_MONITORING"
|
||||
}
|
||||
],
|
||||
"abilities": [
|
||||
{
|
||||
"name": "EntryAbility",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user