增加首选项界面,设置等文本

This commit is contained in:
JackLee 2026-03-24 18:34:01 +08:00
parent 818662eb96
commit 578c486238
25 changed files with 466 additions and 136 deletions

View File

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

View File

@ -7,21 +7,19 @@
#ifndef OPENCAX_AXIS_H
#define OPENCAX_AXIS_H
#include "AIS_ViewCube.hxx"
#include "NativeEGLOCCT/common.h"
#include <AIS_Trihedron.hxx>
#include <AIS_InteractiveContext.hxx>
#include <Geom_Axis2Placement.hxx>
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;

View File

@ -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");

View File

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

View File

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

View File

@ -7,9 +7,13 @@
#ifndef OPENCAX_VIEW_H
#define OPENCAX_VIEW_H
#include "NativeEGLOCCT/Context/Context.h"
#include "NativeEGLOCCT/common.h"
#include <V3d_View.hxx>
#include <Aspect_NeutralWindow.hxx>
#include <AIS_AnimationCamera.hxx>
#include <V3d.hxx>
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;

View File

@ -9,11 +9,13 @@
#ifndef NATIVE_TAG
#define NATIVE_TAG "VIEWER"
#endif
#include <V3d_DirectionalLight.hxx>
#include <V3d_AmbientLight.hxx>
namespace NativeOpenCAX {
Viewer::Viewer() : viewer(nullptr) {}
Viewer::~Viewer() {}
bool Viewer::InitViewer(Handle(OpenGl_GraphicDriver)& graphicDriver) {
try {
viewer = new V3d_Viewer(graphicDriver);

View File

@ -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>(MainScreenDisplayInfo, () => new MainScreenDisplayInfo(
screenDisplayId,screenWidth,screenHeight
))!;
const mainWinInfo=AppStorageV2.connect<MainWindowInfo>(MainWindowInfo, () => new MainWindowInfo(
mainWindowWidth,mainWindowHeight
))!;
const mainWinStage=AppStorageV2.connect<MainWindowStageInfo>(MainWindowStageInfo, () => new MainWindowStageInfo(
windowStage
))!;
const mainDisplayInfo = AppStorageV2.connect<MainScreenDisplayInfo>(MainScreenDisplayInfo, () => new MainScreenDisplayInfo())!;
const mainWinInfo=AppStorageV2.connect<MainWindowInfo>(MainWindowInfo, () => new MainWindowInfo())!;
const mainWinStage=AppStorageV2.connect<MainWindowStageInfo>(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) => {

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,18 @@
import { TitleButton } from "../../LayoutInterface/Interface/ButtonInterface";
export interface OptsBase{
//子模块TabBar头
exName:string;
exIcon:string;
exOtions:Array<Array<string>|string|number|TitleButton>
}
export interface OptsInter {
//设置左侧边名字
sName:string
//设置左侧边加载布局页面
sPage:string
//设置Icon图标
sIcon:string
//设置子栏
sOptions:Array<OptsBase>
}

View File

@ -0,0 +1,153 @@
import { OptsInter } from "./OptsInter";
import { ModelType } from "../../LayoutInterface/Layout/ModelType";
export let OptionsStrData:Array<OptsInter>=[
{
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:""},
]},
]
}
]

View File

@ -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<OptsBase> = [];
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%')
}
}

View File

@ -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<winInfo.width||subWinData.height<winInfo.height){
subWindow?.resize(winInfo.width,winInfo.height);
}
});
})
} catch (error) {
console.error('Failed to create or show sub window:', (error as BusinessError).message);

View File

@ -27,7 +27,7 @@ struct Index {
TitleColumnSub();
}
.width('100%')
.height(mwInfo.mainWindowHeight * 0.03)
.height(mwInfo.mainWindowHeight * 0.02)
.align(Alignment.Start)
//分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
@ -58,7 +58,7 @@ struct Index {
}.layoutWeight(1)
.align(Alignment.Center)
}.width('100%')
.height(mwInfo.mainWindowHeight * 0.36)
.height(mwInfo.mainWindowHeight * 0.39)
//分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
///状态栏
@ -67,7 +67,7 @@ struct Index {
}.width('100%')
.align(Alignment.End)
.alignItems(HorizontalAlign.Start)
.height(mwInfo.mainWindowHeight * 0.05)
.height(mwInfo.mainWindowHeight * 0.01)
}.backgroundColor('#f3f3f0')
.width('100%')
.height('100%')

View File

@ -29,6 +29,10 @@ export let DevModel:TitleModel= {
[
{eModel:[ModelType.BASE],eName:"创建子窗体",eNamed:"",ePage:'pages/EventSubWindow/SWExtrude',eIcon:"base_new_file",eTips:"",eEvent:"Execute_CreateSubWindow"},
{eModel:[ModelType.BASE],eName:"关闭子窗体",eNamed:"",ePage:'pages/EventSubWindow/SWExtrude',eIcon:"base_new_file",eTips:"",eEvent:"Execute_ExitSubWindow"},
],
[
{eModel:[ModelType.BASE],eName:"首选项",eNamed:"",ePage:'pages/EventSubWindow/Options',eIcon:"base_new_file",eTips:"",eEvent:"Execute_CreateSubWindow_Options"},
{eModel:[ModelType.BASE],eName:"关闭",eNamed:"",ePage:'pages/EventSubWindow/Options',eIcon:"base_new_file",eTips:"",eEvent:"Execute_ExitSubWindow_Options"},
]
],grpMenu:GroupActionMenu}] as Array<TitleGroup>
]]

View File

@ -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%')
}
}

View File

@ -37,10 +37,10 @@ export struct TitleColumnSub {
menus:FileMenuData.aMenus as Array<TitleButton>, 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({

View File

@ -2,6 +2,7 @@
"src": [
"pages/Index",
"pages/EventSubWindow/SWLine",
"pages/EventSubWindow/SWExtrude"
"pages/EventSubWindow/SWExtrude",
"pages/EventSubWindow/Options"
]
}