diff --git a/entry/src/main/cpp/NativeEGLOCCT/Axis/Axis.cpp b/entry/src/main/cpp/NativeEGLOCCT/Axis/Axis.cpp index 27f67824..dd4d0089 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/Axis/Axis.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/Axis/Axis.cpp @@ -16,14 +16,21 @@ namespace NativeOpenCAX { Axis::Axis() : axiPlacement(nullptr), axiTrihedron(nullptr), axiViewCube(nullptr) {} Axis::~Axis() {} +void Axis::SetAxisTextStyle(Handle(Prs3d_TextAspect) _textStyle){ + textStyle=_textStyle; +} bool Axis::InitAxis(Handle(AIS_InteractiveContext) & context) { 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 =200; // 大小 -// 设置原点 + // 设置原点 theAxis.SetLocation(gp_Pnt(0, 0, 0)); -// 以世界坐标轴为准,设置Z,X轴方向 + // 以世界坐标轴为准,设置Z,X轴方向 theAxis.SetDirection(gp_Dir(0, 0, 1)); theAxis.SetXDirection(gp_Dir(1, 0, 0)); gp_Pnt anOrg = theAxis.Location(); @@ -44,21 +51,15 @@ bool Axis::InitAxis(Handle(AIS_InteractiveContext) & context) { 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"); - axiTrihedron->SetLabel(Prs3d_DP_YAxis, "Y"); - axiTrihedron->SetLabel(Prs3d_DP_ZAxis, "Z"); + axiTrihedron->SetLabel(Prs3d_DP_XAxis, x_Axis); + axiTrihedron->SetLabel(Prs3d_DP_YAxis, y_Axis); + axiTrihedron->SetLabel(Prs3d_DP_ZAxis, z_Axis); axiTrihedron->SetSize(theSize); - textAspect = axiTrihedron->Attributes()->TextAspect(); - if(textAspect.IsNull()){ - textAspect=new Prs3d_TextAspect(); - //textAspect->SetFont("HarmonyOS Sans"); - textAspect->SetHeight(3000.0); - textAspect->SetColor(Quantity_NOC_GRAY85); - axiTrihedron->Attributes()->DatumAspect()->SetTextAspect(textAspect); + if(!textStyle.IsNull()){ + axiTrihedron->Attributes()->DatumAspect()->SetTextAspect(textStyle); } axiTrihedron->SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TMF_ZoomPers, anOrg)); axiTrihedron->Attributes()->SetZLayer(Graphic3d_ZLayerId_Topmost); - //axiTrihedron->SetInfiniteState(true); context->Display(axiTrihedron, true); HILOG_INFO(NATIVE_TAG, "InitLocalAxis Done"); return true; @@ -69,23 +70,31 @@ bool Axis::InitAxis(Handle(AIS_InteractiveContext) & context) { } 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, "Right"); - axiViewCube->SetBoxSideLabel(V3d_Ypos, "Back"); - axiViewCube->SetBoxSideLabel(V3d_Zpos, "Top"); - axiViewCube->SetBoxSideLabel(V3d_Xneg, "Left"); - axiViewCube->SetBoxSideLabel(V3d_Yneg, "Front"); - axiViewCube->SetBoxSideLabel(V3d_Zneg, "Bottom"); + 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(false); - axiViewCube->SetSize(60, true); + axiViewCube->SetSize(100, true); axiViewCube->SetTransparency(0.0); axiViewCube->SetFixedAnimationLoop(true); - axiViewCube->SetTextColor(Quantity_Color(Quantity_NOC_BLUE1)); - axiViewCube->SetFontHeight(20); + axiViewCube->SetTextColor(Quantity_Color(Quantity_NOC_YELLOW2)); + axiViewCube->SetFontHeight(2000); + axiViewCube->SetFont("HarmonyOS Sans"); axiViewCube->SetMaterial(Graphic3d_MaterialAspect(Graphic3d_NOM_ALUMINIUM)); axiViewCube->SetTransformPersistence( - new Graphic3d_TransformPers(Graphic3d_TMF_TriedronPers, Aspect_TOTP_RIGHT_UPPER, NCollection_Vec2(100, 100))); + new Graphic3d_TransformPers(Graphic3d_TMF_TriedronPers, Aspect_TOTP_RIGHT_UPPER, NCollection_Vec2(125, 125))); context->Display(axiViewCube, true); HILOG_INFO(NATIVE_TAG, "Init Axi View Cube Done"); return true; diff --git a/entry/src/main/cpp/NativeEGLOCCT/Axis/Axis.h b/entry/src/main/cpp/NativeEGLOCCT/Axis/Axis.h index 733eab49..f0f2f126 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/Axis/Axis.h +++ b/entry/src/main/cpp/NativeEGLOCCT/Axis/Axis.h @@ -21,6 +21,7 @@ public: ~Axis(); bool InitAxis(Handle(AIS_InteractiveContext)& context); bool InitAxisCube(Handle(AIS_InteractiveContext) & context); + void SetAxisTextStyle(Handle(Prs3d_TextAspect) textStyle); void SetRotationX(float x); void SetRotationY(float y); void SetRotationZ(float z); @@ -33,7 +34,7 @@ private: Handle(AIS_Trihedron) axiTrihedron; //定义三面体 Handle(AIS_ViewCube) axiViewCube; - Handle(Prs3d_TextAspect) textAspect; + Handle(Prs3d_TextAspect) textStyle; private: //旋转X轴 float rotationX=0.0f; diff --git a/entry/src/main/cpp/NativeEGLOCCT/Camera/Camera.cpp b/entry/src/main/cpp/NativeEGLOCCT/Camera/Camera.cpp index 8c11b755..82f51e3f 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/Camera/Camera.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/Camera/Camera.cpp @@ -17,9 +17,11 @@ Camera::~Camera() {} bool Camera::InitCamera(Handle(V3d_View)& view) { try { camera = new Graphic3d_Camera; + // 将角度转换为弧度并计算对应的缩放因子 camera->SetFOVy(45.0); - camera->SetZRange(1.0, 1000.0); + camera->SetZRange(1, 10.0); view->SetCamera(camera); + HILOG_ERROR(NATIVE_TAG,"Camera Scale:%{public}f",camera->Scale()); HILOG_INFO(NATIVE_TAG, "InitCamera Done"); return true; } catch (std::exception &e) { diff --git a/entry/src/main/cpp/NativeEGLOCCT/NativeManager.cpp b/entry/src/main/cpp/NativeEGLOCCT/NativeManager.cpp index f8669667..9e8704d1 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/NativeManager.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/NativeManager.cpp @@ -142,11 +142,13 @@ void NativeManager::OnSurfaceCreated(OH_NativeXComponent *component, void *windo return; } - OH_NativeXComponent_GetXComponentSize(component, window, &width_, &height_); + OH_NativeXComponent_GetXComponentSize(component, window, &bfWidth, &bfHeight); int64_t id = 0; std::lock_guard lock(mapMutex); if (renderThreadMap.find(id) == renderThreadMap.end()) { auto renderThread = std::make_shared(); + renderThread->initNativeReader(bfWidth, bfHeight); + HILOG_ERROR(NATIVE_TAG,"uint64_t bfSize:%{public}dX%{public}d",bfWidth,bfHeight); renderThreadMap[id] = renderThread; renderThread->start(reinterpret_cast(window)); } @@ -162,21 +164,21 @@ void NativeManager::OnSurfaceDestroyed(OH_NativeXComponent *component, void *win } } } -uint64_t width,height; + void NativeManager::OnSurfaceChanged(OH_NativeXComponent *component, void *window) { - OH_NativeXComponent_GetXComponentSize(component, window, &width_, &height_); + OH_NativeXComponent_GetXComponentSize(component, window, &afWidth, &afHeight); int64_t id = 0; { - if(width==width_ && height==height_){ + if(bfWidth==afWidth && bfHeight==afHeight){ return; } std::lock_guard lock(mapMutex); if (renderThreadMap.find(id) != renderThreadMap.end()) { - HILOG_ERROR(NATIVE_TAG,"uint32_t Size:%{public}dX%{public}d",width_,height_); - renderThreadMap[id]->resizeWindow(width_, height_); - width=width_; - height=height_; + HILOG_ERROR(NATIVE_TAG,"uint64_t Size:%{public}dX%{public}d",bfWidth,bfHeight); + bfWidth=afWidth; + bfHeight=afHeight; + renderThreadMap[id]->resizeWindow(bfWidth, bfHeight); } } } diff --git a/entry/src/main/cpp/NativeEGLOCCT/NativeManager.h b/entry/src/main/cpp/NativeEGLOCCT/NativeManager.h index 96f03645..7a36dd7c 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/NativeManager.h +++ b/entry/src/main/cpp/NativeEGLOCCT/NativeManager.h @@ -81,9 +81,15 @@ private: public: // [StartExclude plugin_manager_h_part] OH_NativeXComponent_TouchEvent touchEvent_; + std::string modelPath_; - uint64_t width_; - uint64_t height_; + //窗体Size改变前 + uint64_t bfWidth; + uint64_t bfHeight; + //窗体Size改变后 + uint64_t afWidth; + uint64_t afHeight; + int64_t timestamp; static int32_t hasDraw_; static int32_t hasChangeColor_; diff --git a/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp b/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp index 2bc4caf6..d800aed2 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp @@ -26,7 +26,9 @@ bool NativeRender::init(EGLCore &_eglCore) { HILOG_ERROR(NATIVE_TAG, "Init GraphicDriver Fail!"); return false; } - if (!ts->InitTextStyle()) { + if (ts->InitTextStyle()) { + mAxis->SetAxisTextStyle(ts->text); + }else{ HILOG_ERROR(NATIVE_TAG, "Init TextSyle Fail!"); return false; } @@ -54,6 +56,7 @@ bool NativeRender::init(EGLCore &_eglCore) { HILOG_ERROR(NATIVE_TAG, "Init Camera Fail!"); return false; } + if (!mAxis->InitAxis(ctx->context)) { HILOG_ERROR(NATIVE_TAG, "Init AXIS Fail!"); return false; @@ -187,103 +190,7 @@ void NativeRender::setZoomLevel(float zoom) { } void NativeRender::setClearColor(float r, float g, float b, float a) { vw->SetClearColor(r, g, b, a); } void NativeRender::resetView() { vw->ResetView(); } -void NativeRender::SwitchView(std::string view) { - fontDev(); +void NativeRender::SwitchView(std::string view) { vw->SwitchView(view); } -// 字体测试 -void NativeRender::fontDev() { - //获取鸿蒙系统字体管理信息 -// OH_Drawing_FontConfigInfoErrorCode fontConfigInfoErrorCode; // 用于接收错误代码 -// OH_Drawing_FontConfigInfo *fontConfigInfo = OH_Drawing_GetSystemFontConfigInfo(&fontConfigInfoErrorCode); -// if (fontConfigInfoErrorCode != SUCCESS_FONT_CONFIG_INFO) { -// OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_DOMAIN, "PrintSysFontMetrics", "获取系统信息失败,错误代码为: %{public}d", -// fontConfigInfoErrorCode); -// } -// // 获取系统字体配置信息示例 -// if (fontConfigInfo != nullptr) { -// // 获取字体文件路径数量,打印日志 -// size_t fontDirCount = fontConfigInfo->fontDirSize; -// OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "PrintSysFontMetrics", "字体文件路径数量为: %{public}zu\n", -// fontDirCount); -// // 遍历字体文件路径列表,打印日志 -// for (size_t i = 0; i < fontDirCount; ++i) { -// OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "PrintSysFontMetrics", "字体文件路径为: %{public}s\n", -// fontConfigInfo->fontDirSet[i]); -// } -// // 获取通用字体集数量,打印日志 -// size_t genericCount = fontConfigInfo->fontGenericInfoSize; -// OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "PrintSysFontMetrics", "通用字体集数量为: %{public}zu\n", -// genericCount); -// // 遍历获取每个通用字体集中的字体家族名(例如 HarmonyOS Sans),打印日志 -// for (size_t i = 0; i < genericCount; ++i) { -// OH_Drawing_FontGenericInfo &genericInfo = fontConfigInfo->fontGenericInfoSet[i]; -// OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "PrintSysFontMetrics", -// "获取第%{public}zu个通用字体集中的字体家族名为: %{public}s", i, genericInfo.familyName); -// for(size_t i = 0; i < genericInfo.adjustInfoSize; ++i){ -// OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "PrintSysFontMetrics", -// "获取第%{public}zu个通用字体集中的字体别名: %{public}s", i, genericInfo.aliasInfoSet->familyName); -// } -// -// } -// -// } - //OCCT字体管理信息获取 -// auto mgr=Font_FontMgr::GetInstance(); -// Handle(Font_SystemFont) sysFont=new Font_SystemFont("HarmonyOS_Sans_Regular"); -// sysFont->SetFontPath(Font_FontAspect_Regular, "/data/storage/el1/bundle/entry/resources/rawfile/fonts/HarmonyOS_Sans_Regular.ttf"); -// TCollection_ExtendedString aFontName("HarmonyOS_Sans_Regular"); // 为你自定义的字体起一个名称,后续绘制时会用到 -// -// // 注册字体。第二个参数如果是 Standard_True,表示强制注册,即使同名也覆盖。 -// bool isRegistered = mgr->RegisterFont(sysFont, Standard_True); -// -// if (!isRegistered) { -// OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","Error: Cannot register font: %{public}s",sysFont->FontName().ToCString()); -// return; // 或者进行错误处理 -// } else { -// OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","Successfully registered font: %{public}s",sysFont->FontName().ToCString()); -// } -// mgr->InitFontDataBase(); -// mgr->AddFontAlias("HarmonyOS-Sans", "HarmonyOS-Sans"); -// Font_FontAspect aspect = Font_FA_Regular; -// // 查找sans别名,优先匹配HarmonyOS Sans -// Handle(Font_SystemFont) font = mgr->FindFont("HarmonyOS_Sans_Regular", aspect); -// if (!font.IsNull()) { -// // 打印实际匹配到的字体名,若为HarmonyOS Sans则生效 -// OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","SO库匹配到的字体名:%{public}s",font->FontName().ToCString()); -// } -// Handle(Font_SystemFont) sysFont=new Font_SystemFont("HarmonyOS-Sans"); -// sysFont->SetFontPath(Font_FontAspect_Regular, "/data/storage/el1/bundle/entry/resources/rawfile/fonts"); -// bool err=mgr->RegisterFont(sysFont,true); -// if(err){ -// OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT RegisterFont Done"); -// } -// NCollection_Sequence> theAliases; -// mgr->GetAllAliases(theAliases); -// for(auto ft:theAliases){ -// OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT Aliases: %{public}s", ft->ToCString()); -// } - - //Handle(Font_SystemFont)sFont = mgr->GetFont("HarmonyOS-Sans"); - //OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT sysFont: %{public}s", sFont->FontName().ToCString()); - //查找指定的字体 -// const TCollection_AsciiString theFontName='HarmonyOS-Sans'; -// Font_FontAspect theFontAspect; -// mgr->FindFont(theFontName, theFontAspect); -// OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT Font_FontAspect: %{public}s", theFontAspect); - - //字体示例 - Handle(AIS_TextLabel) aTextLabel = new AIS_TextLabel(); - //TCollection_ExtendedString tostr; - //const char* str = "\xC4\xE3\xBA\xC3"; - //Resource_Unicode::ConvertGBToUnicode(str, tostr); - const char16_t chinese_array[] = u"新时代社会主义新中国接班人"; - aTextLabel->SetText(chinese_array); - aTextLabel->Attributes()->SetTextAspect(ts->text); - gp_Pnt position(0.0, 0.0, 0.0); // 例如,在原点 - aTextLabel->SetPosition(position); - ctx->context->Display(aTextLabel, Standard_True); - HILOG_ERROR(NATIVE_TAG, "aTextLabel字体名字:%{public}s", aTextLabel->FontName().ToCString()); - HILOG_ERROR(NATIVE_TAG, "aTextLabel字体名字:%{public}s", aTextLabel->Attributes()->TextAspect()->Aspect()->Font().ToCString()); -} } // namespace NativeOpenCAX \ No newline at end of file diff --git a/entry/src/main/cpp/NativeEGLOCCT/NativeRender.h b/entry/src/main/cpp/NativeEGLOCCT/NativeRender.h index c36b0343..3207ff86 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/NativeRender.h +++ b/entry/src/main/cpp/NativeEGLOCCT/NativeRender.h @@ -49,17 +49,8 @@ public: void setZoomLevel(float zoom); void setTranslation(float x, float y); void setCameraRotationMode(bool state); - void fontDev(); //视图 void SwitchView(std::string); - void SetFrontView(); - void SetTopView(); - void SetLeftSideView(); - void SetRightSideView(); - void SetBottomView(); - void SetRearView(); - void SetISOView(); - void SetDIMView(); private: int width; int height; diff --git a/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.cpp b/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.cpp index 9a28a50a..00fb981d 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.cpp @@ -8,18 +8,17 @@ namespace NativeOpenCAX { NativeRenderThread::NativeRenderThread() : isRunning_(false), - nativeWindow_(nullptr), - windowWidth_(1280), - windowHeight_(720) + nativeWindow_(nullptr) { eglCore_ = new EGLCore(); - renderer_= new NativeRender(windowWidth_,windowHeight_); } NativeRenderThread::~NativeRenderThread() { stop(); } - +void NativeRenderThread::initNativeReader(int width,int height){ + renderer_= new NativeRender(width,height); +} bool NativeRenderThread::start(OHNativeWindow* window) { if (isRunning_) { return true; @@ -57,39 +56,6 @@ void NativeRenderThread::renderLoop() { if (!eglCore_->init(nativeWindow_)) { OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "EGLCoreInit","Failed to initialize EGL"); } - ftMgr=Font_FontMgr::GetInstance(); - ftMgr->InitFontDataBase(); - ftMgr->SetPrintErrors(true); - ftMgr->SetTraceAliases(true); - Handle(Font_SystemFont) sysFont=new Font_SystemFont("HarmonyOS_Sans_Medium"); - sysFont->SetFontPath(Font_FontAspect_Regular, "/data/storage/el2/base/haps/entry/files/fonts/"); - // 注册字体。第二个参数如果是 Standard_True,表示强制注册,即使同名也覆盖。 - bool isRegistered = ftMgr->RegisterFont(sysFont, Standard_True); - - if (!isRegistered) { - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","Error: Cannot register font: %{public}s",sysFont->FontName().ToCString()); - return; // 或者进行错误处理 - } else { - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","Successfully registered font: %{public}s",sysFont->FontName().ToCString()); - } - - Handle(Font_SystemFont) fsf; - fsf=ftMgr->GetFont("HarmonyOS_Sans_Medium"); - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT Path: %{public}s", fsf->FontPath(Font_FontAspect_Regular).ToCString()); - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT GetFont: %{public}s", fsf->FontName().ToCString()); - //输出所有字体 - NCollection_Sequence> theAliases; - ftMgr->GetAllAliases(theAliases); - for(auto ft:theAliases){ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT Aliases: %{public}s", ft->ToCString()); - } - //checkfont - NCollection_List> fsfs; - fsfs=ftMgr->GetAvailableFonts(); - for(auto fta:fsfs){ - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT Font: %{public}s", fta->FontName().ToCString()); - OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT Font Path: %{public}s", fta->FontPath(Font_FontAspect_Regular).ToCString()); - } // 初始化OCCT渲染器 if (!renderer_->init(*eglCore_)) { OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "NativeRenderInit","Failed to initialize OCCT renderer"); @@ -129,9 +95,9 @@ void NativeRenderThread::renderLoop() { renderer_->setClearColor(command.param2, command.param3, command.param4, command.param5); break; case CMD_RESIZE: - windowWidth_ = static_cast(command.param2); - windowHeight_ = static_cast(command.param3); - renderer_->resize(windowWidth_, windowHeight_); + rdWidth = static_cast(command.param2); + rdHeight = static_cast(command.param3); + renderer_->resize(rdWidth, rdHeight); break; case CMD_SWITCH_VIEW: renderer_->SwitchView(command.param1); diff --git a/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.h b/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.h index 55eaf8b3..d03e26e9 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.h +++ b/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.h @@ -23,7 +23,7 @@ public: bool start(OHNativeWindow* window); void stop(); - + void initNativeReader(int width,int height); void loadModel(const std::string& filePath); void setCameraRotationMode(bool state); void setRotation(float xAngle, float yAngle); @@ -73,8 +73,8 @@ private: std::mutex callbackMutex_; Callback renderCompleteCallback_; Handle(Font_FontMgr) ftMgr ; - int windowWidth_; - int windowHeight_; + int rdWidth=0; + int rdHeight=0; }; } // namespace NaitveRenderThread #endif //NATIVE_RENDER_THREAD_H \ No newline at end of file diff --git a/entry/src/main/cpp/NativeEGLOCCT/TextStyle/TextStyle.cpp b/entry/src/main/cpp/NativeEGLOCCT/TextStyle/TextStyle.cpp index 62dee5b5..9fb8a808 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/TextStyle/TextStyle.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/TextStyle/TextStyle.cpp @@ -21,7 +21,8 @@ bool TextStyle::InitTextStyle() { try { text = new Prs3d_TextAspect(); text->SetFont("HarmonyOS Sans"); - text->SetHeight(5000); + //缩放比例计算.根据XComp的对角线大小.按照Camera的缩放 + text->SetHeight(2000); text->Aspect()->SetColor(Quantity_NOC_GRAY95); text->Aspect()->SetColorSubTitle(Quantity_NOC_BLACK); text->Aspect()->SetDisplayType(Aspect_TODT_SHADOW); diff --git a/entry/src/main/cpp/NativeEGLOCCT/View/View.cpp b/entry/src/main/cpp/NativeEGLOCCT/View/View.cpp index 66a5ce91..a749c84c 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/View/View.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/View/View.cpp @@ -40,12 +40,13 @@ void View::SetViewOption() { Aspect_GFM_VER, // 垂直渐变 false); // 设置默认相机位置 + view->SetSize(0.1); view->SetProj(V3d_XposYnegZpos); - view->FitAll(0.05, false); + view->FitAll(0.02, false); // 可选:显示坐标轴 view->ZBufferTriedronSetup(); // 调整相机视角 - view->Camera()->SetProjectionType(Graphic3d_Camera::Projection_Perspective); + view->Camera()->SetProjectionType(Graphic3d_Camera::Projection_Orthographic); view->SetBackgroundColor(Quantity_NOC_GRAY90); //左下角默认坐标系 view->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_ANTIQUEWHITE, 0.3, V3d_ZBUFFER); @@ -54,7 +55,7 @@ void View::SetViewOption() { if(!tri.IsNull()){ HILOG_INFO(NATIVE_TAG, "V3d_Trihedron X"); tri->LabelAspect(V3d_X)->SetFont("HarmonyOS Sans"); - tri->LabelAspect(V3d_X)->SetHeight(20.0); + tri->LabelAspect(V3d_X)->SetHeight(1500.0); tri->LabelAspect(V3d_X)->SetColor(Quantity_Color(Quantity_NOC_YELLOW)); } } @@ -80,7 +81,8 @@ void View::Redraw() { void View::ResetView() { if (!view.IsNull()) { view->SetProj(V3d_XposYnegZpos); - view->FitAll(0.05, false); + //view->FitAll(0.05, false); + view->AutoZFit(); } }