diff --git a/entry/src/main/cpp/NativeEGLOCCT/Axis/Axis.cpp b/entry/src/main/cpp/NativeEGLOCCT/Axis/Axis.cpp index dbe76823..4a8a00ce 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/Axis/Axis.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/Axis/Axis.cpp @@ -5,87 +5,91 @@ // please include "napi/native_api.h". #include "Axis.h" +#include "Quantity_NameOfColor.hxx" #ifndef NATIVE_TAG #define NATIVE_TAG "AXIS" #endif namespace NativeOpenCAX { -Axis::Axis() : axisPlacement(nullptr), axisTrihedron(nullptr) { } -Axis::~Axis() { - -} +Axis::Axis() : axiPlacement(nullptr), axiTrihedron(nullptr), axiViewCube(nullptr) {} +Axis::~Axis() {} -bool Axis::InitAxis(Handle(AIS_InteractiveContext)& context,AXIS_TYPE _axisType) { - axisType = _axisType; - switch (axisType) { - case WORLD_AXIS: - return InitWorldAxis(context); - break; - case LOCAL_AXIS: - return InitLocalAxis(context); - break; - } -} -bool Axis::InitWorldAxis(Handle(AIS_InteractiveContext)& context) { +bool Axis::InitAxis(Handle(AIS_InteractiveContext) & context) { try { - // 添加世界坐标系(左下角) - axisPlacement = new Geom_Axis2Placement(gp::XOY()); - axisTrihedron = new AIS_Trihedron(axisPlacement); - axisTrihedron->SetSize(100.0); // 小一点,作为指示器 - axisTrihedron->SetZLayer(Graphic3d_ZLayerId_TopOSD); - axisTrihedron->SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TMF_2d, // 2D 模式 - Aspect_TOTP_LEFT_LOWER, // 左下角对齐 - Graphic3d_Vec2i(100, 100) // 偏移量(像素) - )); - axisTrihedron->SetDatumPartColor(Prs3d_DP_XAxis, Quantity_NOC_RED); - axisTrihedron->SetDatumPartColor(Prs3d_DP_YAxis, Quantity_NOC_GREEN); - axisTrihedron->SetDatumPartColor(Prs3d_DP_ZAxis, Quantity_NOC_BLUE); - context->Display(axisTrihedron, 0, 0, false); - HILOG_INFO(NATIVE_TAG, "InitWorldAxis Done"); - return true; - } catch (std::exception &e) { - HILOG_INFO(NATIVE_TAG, "InitWorldAxis Fail:%{public}d",e.what()); - return false; - } - -} -bool Axis::InitLocalAxis(Handle(AIS_InteractiveContext)& context) { - try { - // 创建场景中心参考坐标系 - axisPlacement = new Geom_Axis2Placement(gp::XOY()); - axisTrihedron = new AIS_Trihedron(axisPlacement); - axisTrihedron->SetSize(50.0); - axisTrihedron->SetDatumPartColor(Prs3d_DP_XAxis, Quantity_NOC_RED); - axisTrihedron->SetDatumPartColor(Prs3d_DP_YAxis, Quantity_NOC_GREEN); - axisTrihedron->SetDatumPartColor(Prs3d_DP_ZAxis, Quantity_NOC_BLUE); - context->Display(axisTrihedron, 0, 0, true); + // 创建场景中心参考坐标系 + gp_Ax2 theAxis; + double theSize = 60; // 大小 +// 设置原点 + theAxis.SetLocation(gp_Pnt(10, 10, 10)); +// 以世界坐标轴为准,设置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_Shaded); + 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_RED2); + axiTrihedron->SetDatumPartColor(Prs3d_DP_YArrow, Quantity_NOC_GREEN2); + axiTrihedron->SetDatumPartColor(Prs3d_DP_ZArrow, Quantity_NOC_BLUE2); + axiTrihedron->SetDatumPartColor(Prs3d_DP_XAxis, Quantity_NOC_RED2); + axiTrihedron->SetDatumPartColor(Prs3d_DP_YAxis, Quantity_NOC_GREEN2); + axiTrihedron->SetDatumPartColor(Prs3d_DP_ZAxis, Quantity_NOC_BLUE2); + axiTrihedron->SetLabel(Prs3d_DP_XAxis, "X"); + axiTrihedron->SetLabel(Prs3d_DP_YAxis, "Y"); + axiTrihedron->SetLabel(Prs3d_DP_ZAxis, "Z"); + axiTrihedron->SetSize(theSize); + 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; } catch (std::exception &e) { - HILOG_INFO(NATIVE_TAG, "InitLocalAxis Fail:%{public}d",e.what()); + HILOG_INFO(NATIVE_TAG, "InitLocalAxis 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; +bool Axis::InitAxisCube(Handle(AIS_InteractiveContext) & context) { + try { + // 视图立方体 + 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->SetDrawAxes(false); + axiViewCube->SetSize(60, true); + axiViewCube->SetTransparency(0.5); + axiViewCube->SetTextColor(Quantity_Color(Quantity_NOC_BLUE1)); + axiViewCube->SetFontHeight(30); + axiViewCube->SetMaterial(Graphic3d_MaterialAspect(Graphic3d_NOM_ALUMINIUM)); + axiViewCube->SetTransformPersistence( + new Graphic3d_TransformPers(Graphic3d_TMF_TriedronPers, Aspect_TOTP_RIGHT_UPPER, Graphic3d_Vec2i(100, 100))); + context->Display(axiViewCube, Standard_True); + HILOG_INFO(NATIVE_TAG, "Init Axi View Cube Done"); + return true; + } catch (std::exception &e) { + HILOG_INFO(NATIVE_TAG, "Init Axi View Cube Fail:%{public}d", e.what()); + return false; + } } + +void Axis::SetRotationX(float rx) { rotationX = rx; } +void Axis::SetRotationY(float ry) { rotationX = ry; } +void Axis::SetRotationZ(float rz) { rotationX = rz; } +void Axis::SetTranslationX(float tx) { translationX = tx; } +void Axis::SetTranslationY(float ty) { translationX = ty; } +void Axis::SetTranslationZ(float tz) { translationX = tz; } +void Axis::SetZoomLevel(float level) { zoomLevel = level; } } \ No newline at end of file diff --git a/entry/src/main/cpp/NativeEGLOCCT/Axis/Axis.h b/entry/src/main/cpp/NativeEGLOCCT/Axis/Axis.h index e7587f0f..6193605b 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/Axis/Axis.h +++ b/entry/src/main/cpp/NativeEGLOCCT/Axis/Axis.h @@ -7,21 +7,19 @@ #ifndef OPENCAX_AXIS_H #define OPENCAX_AXIS_H +#include "AIS_ViewCube.hxx" #include "NativeEGLOCCT/common.h" #include #include #include - namespace NativeOpenCAX { -enum AXIS_TYPE{ - WORLD_AXIS, - LOCAL_AXIS -}; + class Axis { public: Axis(); ~Axis(); - bool InitAxis(Handle(AIS_InteractiveContext)& context,AXIS_TYPE _axisType); + bool InitAxis(Handle(AIS_InteractiveContext)& context); + bool InitAxisCube(Handle(AIS_InteractiveContext) & context); void SetRotationX(float x); void SetRotationY(float y); void SetRotationZ(float z); @@ -30,12 +28,10 @@ public: void SetTranslationZ(float z); void SetZoomLevel(float level); private: - bool InitWorldAxis(Handle(AIS_InteractiveContext)& context); - bool InitLocalAxis(Handle(AIS_InteractiveContext)& context); -private: - AXIS_TYPE axisType; - Handle(Geom_Axis2Placement) axisPlacement; - Handle(AIS_Trihedron) axisTrihedron; + Handle(Geom_Axis2Placement) axiPlacement; + Handle(AIS_Trihedron) axiTrihedron; + //定义三面体 + Handle(AIS_ViewCube) axiViewCube; 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 19709369..8c11b755 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/Camera/Camera.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/Camera/Camera.cpp @@ -17,7 +17,7 @@ Camera::~Camera() {} bool Camera::InitCamera(Handle(V3d_View)& view) { try { camera = new Graphic3d_Camera; - camera->SetFOVy(30.0); + camera->SetFOVy(45.0); camera->SetZRange(1.0, 1000.0); view->SetCamera(camera); HILOG_INFO(NATIVE_TAG, "InitCamera Done"); diff --git a/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp b/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp index 7bbb7ae5..549d51ac 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp @@ -1,4 +1,5 @@ #include "NativeRender.h" +#include "Aspect_TypeOfLine.hxx" #include "STEPControl_Reader.hxx" #ifndef NATIVE_TAG @@ -47,14 +48,16 @@ bool NativeRender::init(EGLCore& _eglCore) { HILOG_ERROR(NATIVE_TAG,"Init Ctx Fail!"); return false; } - if(!mAxis->InitAxis(ctx->context, AXIS_TYPE::WORLD_AXIS)){ - HILOG_ERROR(NATIVE_TAG,"Init WORLD_AXIS Fail!"); + if(!mAxis->InitAxis(ctx->context)){ + HILOG_ERROR(NATIVE_TAG,"Init AXIS Fail!"); return false; } - if(!nAxis->InitAxis(ctx->context, AXIS_TYPE::LOCAL_AXIS)){ - HILOG_ERROR(NATIVE_TAG,"Init LOCAL_AXIS Fail!"); + + if(!mAxis->InitAxisCube(ctx->context)){ + HILOG_ERROR(NATIVE_TAG,"Init AXIS Cuba Fail!"); return false; } + if(!win->InitWindow(width,height)){ HILOG_ERROR(NATIVE_TAG,"Init Window Fail!"); return false; @@ -71,6 +74,7 @@ bool NativeRender::init(EGLCore& _eglCore) { HILOG_ERROR(NATIVE_TAG,"Init Camera Fail!"); return false; } + vw->ResetView(); return true; } @@ -116,11 +120,11 @@ bool NativeRender::loadModel(const std::string& filePath) { // 设置材质 Handle(Prs3d_Drawer) drawer = aisShape->Attributes(); Handle(Prs3d_ShadingAspect) shadingAspect = new Prs3d_ShadingAspect(); - aisShape->SetDisplayMode(1); + //aisShape->SetDisplayMode(1); Handle(Prs3d_LineAspect) aLineAspect = new Prs3d_LineAspect( Quantity_NOC_BLACK, // 颜色,例如黑色 - Aspect_TOL_SOLID, // 线型 - 2.0 // 线宽 + Aspect_TOL_DASH, // 线型 + 3.0 // 线宽 ); // 随机颜色 @@ -142,6 +146,7 @@ bool NativeRender::loadModel(const std::string& filePath) { drawer->SetWireAspect(aLineAspect); drawer->SetShadingAspect(shadingAspect); ctx->context->Display(aisShape, Standard_True); + //ctx->context->SetDisplayMode(AIS_WireFrame, Standard_False); shapes_.push_back(aisShape); } } diff --git a/entry/src/main/cpp/NativeEGLOCCT/View/View.cpp b/entry/src/main/cpp/NativeEGLOCCT/View/View.cpp index faedd4d0..dccb434e 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/View/View.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/View/View.cpp @@ -32,19 +32,21 @@ void View::SetViewOption() { view->ChangeRenderingParams().IsShadowEnabled = Standard_False; view->ChangeRenderingParams().IsReflectionEnabled = Standard_False; view->ChangeRenderingParams().IsAntialiasingEnabled = Standard_True; - view->ChangeRenderingParams().Resolution = 2; - + view->ChangeRenderingParams().Resolution = 1; // 设置背景渐变 view->SetBgGradientColors(Quantity_Color(Quantity_NOC_GRAY), Quantity_Color(Quantity_NOC_BLACK), Aspect_GFM_VER, // 垂直渐变 Standard_False); // 设置默认相机位置 view->SetProj(V3d_XposYnegZpos); + view->FitAll(0.05, Standard_False); // 可选:显示坐标轴 view->ZBufferTriedronSetup(); // 调整相机视角 view->Camera()->SetProjectionType(Graphic3d_Camera::Projection_Perspective); view->SetBackgroundColor(Quantity_NOC_GRAY90); + //左下角默认坐标系 + view->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_ALICEBLUE, 0.3, V3d_ZBUFFER); } void View::SetText(Handle(Prs3d_TextAspect) & text) { diff --git a/entry/src/main/cpp/NativeEGLOCCT/View/View.h b/entry/src/main/cpp/NativeEGLOCCT/View/View.h index 7f99f17a..d1855e84 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/View/View.h +++ b/entry/src/main/cpp/NativeEGLOCCT/View/View.h @@ -7,9 +7,13 @@ #ifndef OPENCAX_VIEW_H #define OPENCAX_VIEW_H +#include "NativeEGLOCCT/Context/Context.h" #include "NativeEGLOCCT/common.h" #include #include +#include +#include + namespace NativeOpenCAX{ class View{ @@ -25,14 +29,6 @@ public: void Redraw(); void ResetView(); void SwitchView(std::string view); -// void FrontView(); -// void TopView(); -// void LeftSideView(); -// void RightSideView(); -// void BottomView(); -// void RearView(); -// void ISOView(); -// void DIMView(); public: Handle(V3d_View) view; Quantity_Color clearColor; diff --git a/entry/src/main/cpp/NativeEGLOCCT/Viewer/Viewer.cpp b/entry/src/main/cpp/NativeEGLOCCT/Viewer/Viewer.cpp index 358d5d8b..916b8715 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/Viewer/Viewer.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/Viewer/Viewer.cpp @@ -9,11 +9,13 @@ #ifndef NATIVE_TAG #define NATIVE_TAG "VIEWER" #endif - +#include +#include namespace NativeOpenCAX { Viewer::Viewer() : viewer(nullptr) {} Viewer::~Viewer() {} + bool Viewer::InitViewer(Handle(OpenGl_GraphicDriver)& graphicDriver) { try { viewer = new V3d_Viewer(graphicDriver); diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index b1a48578..0ac2fa37 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -33,15 +33,15 @@ export default class EntryAbility extends UIAbility { const mainWindowHeight: number = screenHeight-200; console.error(`main window Width: mainWindowWidth, Height: mainWindowHeight`); //Init&&Save AppStorageV2 - const mainDisplayInfo = AppStorageV2.connect(MainScreenDisplayInfo, () => new MainScreenDisplayInfo( - screenDisplayId,screenWidth,screenHeight - ))!; - const mainWinInfo=AppStorageV2.connect(MainWindowInfo, () => new MainWindowInfo( - mainWindowWidth,mainWindowHeight - ))!; - const mainWinStage=AppStorageV2.connect(MainWindowStageInfo, () => new MainWindowStageInfo( - windowStage - ))!; + const mainDisplayInfo = AppStorageV2.connect(MainScreenDisplayInfo, () => new MainScreenDisplayInfo())!; + const mainWinInfo=AppStorageV2.connect(MainWindowInfo, () => new MainWindowInfo())!; + const mainWinStage=AppStorageV2.connect(MainWindowStageInfo, () => new MainWindowStageInfo())!; + mainDisplayInfo.mainScreenDisplayId=screenDisplayId; + mainDisplayInfo.mainScreenWidth=screenWidth; + mainDisplayInfo.mainScreenHeight=screenHeight; + mainWinInfo.mainWindowWidth=mainWindowWidth; + mainWinInfo.mainWindowHeight=mainWindowHeight; + mainWinStage.ws=windowStage; //Get Main Window windowStage.getMainWindow((err, data) => { diff --git a/entry/src/main/ets/pages/CustomStyle/Button.ets b/entry/src/main/ets/pages/CustomStyle/Button.ets index b6cfe1ba..56e25511 100644 --- a/entry/src/main/ets/pages/CustomStyle/Button.ets +++ b/entry/src/main/ets/pages/CustomStyle/Button.ets @@ -180,15 +180,15 @@ export struct SubColumnMenu { Button(){ Row(){ Image($r('app.media.'+(this.icon!=undefined ? this.icon:(this.menus[this.curtIndex]as TitleButton).eIcon))) + .height(mwInfo.mainWindowWidth*0.01) if(this.name!=undefined){ - Text(this.name).fontSize(20) + Text(this.name).fontSize(16) } } - }.width(ebWidth) - .height(ebWidth) + }.height(mwInfo.mainWindowWidth*0.01) .backgroundColor(Color.Transparent) .bindMenu(this.BaseMenu) .type(ButtonType.Normal) - }.width(this.name!=undefined ?mwInfo.mainWindowWidth*0.03:ebWidth) + }.width(this.name!=undefined ?mwInfo.mainWindowWidth*0.02:mwInfo.mainWindowWidth*0.01) } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/CustomStyle/ComboBox.ets b/entry/src/main/ets/pages/CustomStyle/ComboBox.ets index a1413dce..bfd87df5 100644 --- a/entry/src/main/ets/pages/CustomStyle/ComboBox.ets +++ b/entry/src/main/ets/pages/CustomStyle/ComboBox.ets @@ -27,17 +27,17 @@ export struct TextComboBox { build() { Row() { Text(this.name!=undefined?this.name:'') - .fontSize(18) + .fontSize(16) .width('auto') Text(this.menu[this.selectIndex].eName) .bindMenu(this.EventMenu) .width('50%') - .fontSize(18) + .fontSize(16) .backgroundColor('#ffe6e6e3') - .height(mwInfo.mainWindowHeight*0.022) + .height(mwInfo.mainWindowHeight*0.02) .margin({ top:0, left: 5, bottom: 0, right: 0 }) }.width(ebWidth) - .height(ebHeigth) + .height(mwInfo.mainWindowWidth*0.01) } } @ComponentV2 @@ -61,6 +61,6 @@ export struct TextInputComboBox { TextInput({placeholder:this.selectIndex.toString()}) .bindMenu(this.EventMenu) .type(InputType.Number) - } + }.height(mwInfo.mainWindowWidth*0.01) } } diff --git a/entry/src/main/ets/pages/EventSubWindow/ExecuteCommand.ets b/entry/src/main/ets/pages/EventSubWindow/ExecuteCommand.ets index 6622174f..e901f4d0 100644 --- a/entry/src/main/ets/pages/EventSubWindow/ExecuteCommand.ets +++ b/entry/src/main/ets/pages/EventSubWindow/ExecuteCommand.ets @@ -1,17 +1,27 @@ import { TitleButton } from '../LayoutInterface/Interface/ButtonInterface'; import { OCCTLoadModel } from '../modelView'; -import { CloseSubWindow, CreateAndShowSubWindow} from './SWBase'; +import { CloseSubWindow, CreateAndShowSubWindow, WinInfo} from './SWBase'; import NativeOpenCAX from 'libopencax.so'; +import { mwInfo } from '../AppStorageV2Class'; export function ExecuteCommand(event:TitleButton){ + //事件处理 if(event?.eEvent=='Execute_LoadModel'){ OCCTLoadModel(undefined,undefined) - }else if(event?.eEvent=='Execute_CreateSubWindow'){ - CreateAndShowSubWindow(event.eName,event.ePage); + } + //窗体打开 + if(event?.eEvent=='Execute_CreateSubWindow'){ + const winInfo:WinInfo=new WinInfo(event.eName,event.ePage,mwInfo.mainWindowWidth*0.3,mwInfo.mainWindowHeight*0.9); + CreateAndShowSubWindow(winInfo); }else if(event?.eEvent=='Execute_ExitSubWindow'){ CloseSubWindow(); + } else if(event?.eEvent=='Execute_CreateSubWindow_Options'){ + const winInfo:WinInfo=new WinInfo(event.eName,event.ePage,mwInfo.mainWindowWidth*0.6,mwInfo.mainWindowHeight*0.9); + CreateAndShowSubWindow(winInfo); + }else if(event?.eEvent=='Execute_ExitSubWindow_Options'){ + CloseSubWindow(); } - + //视图切换 if(event?.eEvent=='CMD_VIEW_FRONT'){ NativeOpenCAX.switchView("CMD_VIEW_FRONT"); }else if(event?.eEvent=='CMD_VIEW_TOP'){ diff --git a/entry/src/main/ets/pages/EventSubWindow/Options.ets b/entry/src/main/ets/pages/EventSubWindow/Options.ets new file mode 100644 index 00000000..7f33ddf6 --- /dev/null +++ b/entry/src/main/ets/pages/EventSubWindow/Options.ets @@ -0,0 +1,77 @@ +import { OptsBase, OptsInter } from './Opts/OptsInter'; +import { OptionsStrData } from './Opts/OptsStr'; +import { OptsSub } from './Opts/OptsSub'; + +//选项设置页面 +@Entry +@ComponentV2 +export struct Options { + private mainBarTabs: TabsController = new TabsController(); + @Local mainBarFocusIndex: number = 0; + + build() { + Row({ space: 5 }) { + Column({ space: 0 }) { + Scroll() { + Flex({ direction: FlexDirection.Column }) { + Column({ space: 5 }) { + ForEach(OptionsStrData, (item: OptsInter, index: number) => { + Button(item.sName) + .backgroundImagePosition({ x: '5%', y: '5%' }) + .backgroundImageSize({ + width: '90%', // 图片宽度占满按钮 + height: '90%' // 图片高度占满按钮 + }) + .width('100%') + .backgroundImage($r('app.media.' + item.sIcon)) + .fontWeight(index === this.mainBarFocusIndex ? FontWeight.Bold : FontWeight.Normal) + .type(ButtonType.Normal) + .onClick(() => { + this.mainBarTabs.changeIndex(index); + this.mainBarFocusIndex = index; + }) + }) + } + Blank().height('95%') + } + } + .align(Alignment.Start) + .scrollable(ScrollDirection.Vertical) + .scrollBar(BarState.Off) + .height('100%') + }.width('10%') + .margin({ + top: '0.5%', + left: 0, + bottom: '0.5%', + right: 0 + }) + + Divider() + .vertical(true) + .strokeWidth(1) + .lineCap(LineCapStyle.Round) + .height('99%') + .backgroundColor(Color.Gray) + Column({ space: 1 }) { + Tabs({ barPosition: BarPosition.Start,index: this.mainBarFocusIndex, controller: this.mainBarTabs }) { + ForEach(OptionsStrData, (item: OptsInter, index: number) => { + OptsSub({ subOptions: item.sOptions }) + }) + } + }.width('90%') + .margin({ + top: '0.5%', + left: 0, + bottom: '0.5%', + right: 0 + }) + } + .margin({ + top: 5, + left: 5, + bottom: 5, + right: 5 + }) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/EventSubWindow/Opts/OptFeature.ets b/entry/src/main/ets/pages/EventSubWindow/Opts/OptFeature.ets new file mode 100644 index 00000000..e69de29b diff --git a/entry/src/main/ets/pages/EventSubWindow/Opts/OptisModeling.ets b/entry/src/main/ets/pages/EventSubWindow/Opts/OptisModeling.ets new file mode 100644 index 00000000..e69de29b diff --git a/entry/src/main/ets/pages/EventSubWindow/Opts/OptsInter.ets b/entry/src/main/ets/pages/EventSubWindow/Opts/OptsInter.ets new file mode 100644 index 00000000..2c711622 --- /dev/null +++ b/entry/src/main/ets/pages/EventSubWindow/Opts/OptsInter.ets @@ -0,0 +1,18 @@ +import { TitleButton } from "../../LayoutInterface/Interface/ButtonInterface"; + +export interface OptsBase{ + //子模块TabBar头 + exName:string; + exIcon:string; + exOtions:Array|string|number|TitleButton> +} +export interface OptsInter { + //设置左侧边名字 + sName:string + //设置左侧边加载布局页面 + sPage:string + //设置Icon图标 + sIcon:string + //设置子栏 + sOptions:Array +} diff --git a/entry/src/main/ets/pages/EventSubWindow/Opts/OptsStr.ets b/entry/src/main/ets/pages/EventSubWindow/Opts/OptsStr.ets new file mode 100644 index 00000000..05f07687 --- /dev/null +++ b/entry/src/main/ets/pages/EventSubWindow/Opts/OptsStr.ets @@ -0,0 +1,153 @@ +import { OptsInter } from "./OptsInter"; +import { ModelType } from "../../LayoutInterface/Layout/ModelType"; + +export let OptionsStrData:Array=[ + { + sName:'用户设置', + sPage:'', + sIcon:'string', + sOptions:[ + {exName:'用户基础设置',exIcon:'',exOtions: + [ + {eModel:[ModelType.BASE],eName:"导入用户设置",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"导出用户设置",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"恢复默认用户设置",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ] + }, + {exName:'用户界面布局',exIcon:'',exOtions: + [ + {eModel:[ModelType.BASE],eName:"导入用户界面布局",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"导出用户界面布局",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"恢复默认用户布局",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ] + } + ] + }, + { + sName:'基本环境', + sPage:'', + sIcon:'string', + sOptions:[ + {exName:'默认单位',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"英寸",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"毫米",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"自动保存间隔",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'目录',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"默认其实目录",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"默认文档名",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'表达式',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"表达式前缀",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"表达式后缀",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'大模型接口',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"大模型地址",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"Key",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"模型选择",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"知识库设定",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"MCP设定",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"Skills",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + ] + }, + { + sName:'对象', + sPage:'', + sIcon:'string', + sOptions:[ + {exName:'默认',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"颜色",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线型",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线宽",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'直线',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"颜色",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线型",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线宽",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'圆弧',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"颜色",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线型",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线宽",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'二次曲线',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"颜色",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线型",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线宽",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'样条',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"颜色",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线型",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线宽",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'实体',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"颜色",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线型",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线宽",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'片体',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"颜色",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线型",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线宽",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'基准平面',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"颜色",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线型",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线宽",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'点',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"颜色",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线型",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线宽",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'无限长直线',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"颜色",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线型",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线宽",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'坐标系',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"颜色",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线型",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线宽",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'实体和片体',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"颜色",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线型",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线宽",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'基准坐标系',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"颜色",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线型",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线宽",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + ] + }, + { + sName:'可视化', + sPage:'', + sIcon:'string', + sOptions:[ + {exName:'显示',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"颜色",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线型",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线宽",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'图形',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"颜色",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线型",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线宽",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'光顺边',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"颜色",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线型",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线宽",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + {exName:'收敛体',exIcon:'',exOtions:[ + {eModel:[ModelType.BASE],eName:"颜色",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线型",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + {eModel:[ModelType.BASE],eName:"线宽",eNamed:"",ePage:'',eIcon:"base_new_file",eTips:"",eEvent:""}, + ]}, + ] + } +] \ No newline at end of file diff --git a/entry/src/main/ets/pages/EventSubWindow/Opts/OptsSub.ets b/entry/src/main/ets/pages/EventSubWindow/Opts/OptsSub.ets new file mode 100644 index 00000000..32409ec1 --- /dev/null +++ b/entry/src/main/ets/pages/EventSubWindow/Opts/OptsSub.ets @@ -0,0 +1,42 @@ +import { OptsBase } from './OptsInter'; + +//选项设置页面 +@Entry +@ComponentV2 +export struct OptsSub { + private subBarTabs: TabsController = new TabsController(); + @Local subBarFocusIndex: number = 0; + @Param subOptions: Array = []; + + build() { + Column() { + Scroll() { + Flex({ direction: FlexDirection.Row }) { + if (this.subOptions.length > 0) { + Row({ space: 5 }) { + ForEach(this.subOptions, (item: OptsBase, index: number) => { + Button(item.exName) + .backgroundImagePosition({ x: '5%', y: '5%' }) + .backgroundImageSize({ + width: '90%', // 图片宽度占满按钮 + height: '90%' // 图片高度占满按钮 + }) + .backgroundImage($r('app.media.' + item.exIcon)) + .fontWeight(index === this.subBarFocusIndex ? FontWeight.Bold : FontWeight.Normal) + .type(ButtonType.Normal) + }) + } + } + } + }.scrollable(ScrollDirection.Vertical) + .scrollBar(BarState.Off) + + Column({ space: 1 }) { + Tabs({ barPosition: BarPosition.Start, index:this.subBarFocusIndex,controller: this.subBarTabs }) { + + } + } + }.width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/EventSubWindow/Opts/OptsUser.ets b/entry/src/main/ets/pages/EventSubWindow/Opts/OptsUser.ets new file mode 100644 index 00000000..e69de29b diff --git a/entry/src/main/ets/pages/EventSubWindow/Opts/OptsUserLayout.ets b/entry/src/main/ets/pages/EventSubWindow/Opts/OptsUserLayout.ets new file mode 100644 index 00000000..e69de29b diff --git a/entry/src/main/ets/pages/EventSubWindow/SWBase.ets b/entry/src/main/ets/pages/EventSubWindow/SWBase.ets index ac906fbb..e2605caf 100644 --- a/entry/src/main/ets/pages/EventSubWindow/SWBase.ets +++ b/entry/src/main/ets/pages/EventSubWindow/SWBase.ets @@ -4,14 +4,27 @@ import { mwInfo, mwsInfo } from '../AppStorageV2Class'; let subWindow: window.Window | undefined = undefined; -export async function CreateAndShowSubWindow(name:string,pages:string) { +export class WinInfo{ + name:string|undefined=undefined; + page:string|undefined=undefined; + width:number=0; + height:number=0; + constructor(name?: string, page?: string,width?: number,height?: number) { + this.name = name??undefined; + this.page = page ?? undefined; + this.width = width ?? 0; + this.height = height ?? 0; + } +} + +export async function CreateAndShowSubWindow(winInfo:WinInfo) { try { if(mwsInfo.ws==null){ console.error('Failed to create the subwindow. Cause: windowStage is null'); return; } let options: window.SubWindowOptions = { - title: name, + title: winInfo.name as string, decorEnabled: true, isModal: false, maximizeSupported: false, @@ -27,8 +40,9 @@ export async function CreateAndShowSubWindow(name:string,pages:string) { //子窗口创建成功后,设置子窗口的位置、大小及相关属性等。 subWindow.moveWindowTo(25, 25) //子窗口重置大小 - subWindow.resize(mwInfo.mainWindowWidth*0.3, mwInfo.mainWindowHeight*0.9); - subWindow.setUIContent(pages, (err: BusinessError) => { + console.info("页面路径:", winInfo.page); + subWindow.resize(winInfo.width,winInfo.height); + subWindow.setUIContent(winInfo.page, (err: BusinessError) => { if (err.code) { console.error("加载页面失败:", err); return; @@ -40,6 +54,13 @@ export async function CreateAndShowSubWindow(name:string,pages:string) { console.error("显示窗口失败:", err); } }); + //不允许窗口小于默认尺寸 + subWindow.on('windowSizeChange', (subWinData) => { + // if Size Change save to AppStorage + if(subWinData.width ]] diff --git a/entry/src/main/ets/pages/LeftSideLayout/LeftSideTab.ets b/entry/src/main/ets/pages/LeftSideLayout/LeftSideTab.ets index 8316e4b8..1a61653d 100644 --- a/entry/src/main/ets/pages/LeftSideLayout/LeftSideTab.ets +++ b/entry/src/main/ets/pages/LeftSideLayout/LeftSideTab.ets @@ -36,8 +36,8 @@ export struct LeftSideTab { }).margin({ top: 2,left:1,bottom:0,right:2}) Scroll() { Flex({ direction: FlexDirection.Column}) { + Column({ space: 5 }) { ForEach(LeftSideBars, (item: TitleButton, index: number) => { - Column({ space: 0 }) { Button() .borderWidth(1) .borderColor(Color.Grey) @@ -57,8 +57,7 @@ export struct LeftSideTab { this.leftSideBarTabs.changeIndex(index); this.leftSideBarFocusIndex = index; }) - }.margin({ top: 2,left:0,bottom:0,right:0}) - }) + })} Blank().height('95%') } } diff --git a/entry/src/main/ets/pages/TitleLayout/TitleColumnSub.ets b/entry/src/main/ets/pages/TitleLayout/TitleColumnSub.ets index fad8bb5e..9d70b6b2 100644 --- a/entry/src/main/ets/pages/TitleLayout/TitleColumnSub.ets +++ b/entry/src/main/ets/pages/TitleLayout/TitleColumnSub.ets @@ -37,10 +37,10 @@ export struct TitleColumnSub { menus:FileMenuData.aMenus as Array, icon:'base_shortcut_menu',name:'菜单'}) .margin({ top:0, left: 5, bottom: 0, right: 0 }) Text('|') - .fontSize(20) + .fontSize(16) TextComboBox({name:'拾取类型:',menu:SelectionFilter}) Text('图层:') - .fontSize(20) + .fontSize(16) TextInputComboBox({menu:this.layerArray}).width('10%') SubColumnMenu({menus:LayoutSwitch}) //视角弹窗 @@ -51,8 +51,8 @@ export struct TitleColumnSub { this.viewDialog=this.ViewDialog(); } this.viewDialog.open(); - }).width(mwInfo.mainWindowWidth*0.014) - .height(mwInfo.mainWindowWidth*0.014) + }).width(mwInfo.mainWindowWidth*0.01) + .height(mwInfo.mainWindowWidth*0.01) .backgroundColor(Color.Transparent) .backgroundImage($r('app.media.' + SwitchView[0].eIcon)) .backgroundImageSize({ diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json index c5fe2f42..f708ed7a 100644 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -2,6 +2,7 @@ "src": [ "pages/Index", "pages/EventSubWindow/SWLine", - "pages/EventSubWindow/SWExtrude" + "pages/EventSubWindow/SWExtrude", + "pages/EventSubWindow/Options" ] } \ No newline at end of file