增加开发模块
This commit is contained in:
parent
d091a99114
commit
ecae5dca40
@ -214,6 +214,9 @@ void NativeManager::OnMouseEvent(OH_NativeXComponent *component, void *window) {
|
|||||||
HILOG_WARN(NATIVE_TAG, "ALLTimestamp:%{public}d",event.timestamp);
|
HILOG_WARN(NATIVE_TAG, "ALLTimestamp:%{public}d",event.timestamp);
|
||||||
//鼠标按下并且事件为鼠标中键
|
//鼠标按下并且事件为鼠标中键
|
||||||
if(event.button==OH_NATIVEXCOMPONENT_LEFT_BUTTON&&event.action==OH_NATIVEXCOMPONENT_MOUSE_PRESS){
|
if(event.button==OH_NATIVEXCOMPONENT_LEFT_BUTTON&&event.action==OH_NATIVEXCOMPONENT_MOUSE_PRESS){
|
||||||
|
if(NativeManager::isMouseMiddleBtnPressed){
|
||||||
|
NativeManager::isMouseMiddleBtnPressed=false;
|
||||||
|
}
|
||||||
//记录按下时候的X.Y坐标
|
//记录按下时候的X.Y坐标
|
||||||
NativeManager::lastMouseX_=event.x;
|
NativeManager::lastMouseX_=event.x;
|
||||||
NativeManager::lastMouseY_=event.y;
|
NativeManager::lastMouseY_=event.y;
|
||||||
@ -244,10 +247,6 @@ void NativeManager::OnMouseEvent(OH_NativeXComponent *component, void *window) {
|
|||||||
HILOG_WARN(NATIVE_TAG, "MoveButtonAction:%{public}d",event.action);
|
HILOG_WARN(NATIVE_TAG, "MoveButtonAction:%{public}d",event.action);
|
||||||
HILOG_WARN(NATIVE_TAG, "MoveIsMouseMiddleBtnPressed:%{public}d",NativeManager::isMouseMiddleBtnPressed);
|
HILOG_WARN(NATIVE_TAG, "MoveIsMouseMiddleBtnPressed:%{public}d",NativeManager::isMouseMiddleBtnPressed);
|
||||||
}
|
}
|
||||||
else if(event.button==OH_NATIVEXCOMPONENT_LEFT_BUTTON&&event.action==OH_NATIVEXCOMPONENT_MOUSE_RELEASE){
|
|
||||||
//NativeManager::isMouseMiddleBtnPressed = false;
|
|
||||||
HILOG_WARN(NATIVE_TAG, "ReleaseIsMouseMiddleBtnPressed:%{public}d",NativeManager::isMouseMiddleBtnPressed);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
static std::string value2String(napi_env env, napi_value value) {
|
static std::string value2String(napi_env env, napi_value value) {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { hilog } from '@kit.PerformanceAnalysisKit';
|
|||||||
import { TitleButton } from "../LayoutInterface/Interface/ButtonInterface";
|
import { TitleButton } from "../LayoutInterface/Interface/ButtonInterface";
|
||||||
import { TitleModel } from "../LayoutInterface/Interface/ModelInterface";
|
import { TitleModel } from "../LayoutInterface/Interface/ModelInterface";
|
||||||
import { TitleData } from '../LayoutInterface/Layout/TabContent';
|
import { TitleData } from '../LayoutInterface/Layout/TabContent';
|
||||||
|
import { OCCTLoadModel } from '../modelView';
|
||||||
|
|
||||||
//单一功能按钮
|
//单一功能按钮
|
||||||
//图片->文本
|
//图片->文本
|
||||||
@ -22,6 +23,11 @@ export struct EventBtn {
|
|||||||
width: '80%', // 图片宽度占满按钮
|
width: '80%', // 图片宽度占满按钮
|
||||||
height: '80%' // 图片高度占满按钮
|
height: '80%' // 图片高度占满按钮
|
||||||
})
|
})
|
||||||
|
.onClick(()=>{
|
||||||
|
if(this.eventBtn?.eEvent=='Execute_LoadModel'){
|
||||||
|
OCCTLoadModel(undefined,undefined)
|
||||||
|
}
|
||||||
|
})
|
||||||
Text(this.eventBtn.eName)
|
Text(this.eventBtn.eName)
|
||||||
.fontSize('10fp')
|
.fontSize('10fp')
|
||||||
.width('45vp')
|
.width('45vp')
|
||||||
|
|||||||
6
entry/src/main/ets/pages/ExecuteCommand.ets
Normal file
6
entry/src/main/ets/pages/ExecuteCommand.ets
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import { OCCTLoadModel } from './modelView';
|
||||||
|
|
||||||
|
//该ets是一个映射指令表.主要是功能得Event事件和对应实现函数进行映射.
|
||||||
|
//要求Event的事件名必须与该事件对应实现功能的函数名一致.
|
||||||
|
// 定义一个函数类型别名,表示无参数无返回值的函数
|
||||||
|
//ActionMap相当于一个Event的事件列表和函数连接器
|
||||||
@ -3,7 +3,7 @@ import {TitleMainPage} from './MainPage'
|
|||||||
import {ModelType} from './ModelType'
|
import {ModelType} from './ModelType'
|
||||||
import { GroupOption } from "./GroupOption";
|
import { GroupOption } from "./GroupOption";
|
||||||
import { TitleGroup } from "../Interface/GroupInterface";
|
import { TitleGroup } from "../Interface/GroupInterface";
|
||||||
import { MatrixModel } from "./MatrixModel";
|
import { MatrixModel ,DevModel} from "./MatrixModel";
|
||||||
|
|
||||||
export let TitleCAD:Array<TitleModel>=[
|
export let TitleCAD:Array<TitleModel>=[
|
||||||
TitleMainPage[0],
|
TitleMainPage[0],
|
||||||
@ -98,5 +98,6 @@ export let TitleCAD:Array<TitleModel>=[
|
|||||||
],grpMenu:GroupOption}] as Array<TitleGroup>
|
],grpMenu:GroupOption}] as Array<TitleGroup>
|
||||||
]
|
]
|
||||||
]},
|
]},
|
||||||
MatrixModel
|
MatrixModel,
|
||||||
|
DevModel
|
||||||
]
|
]
|
||||||
@ -3,7 +3,7 @@ import {TitleMainPage} from './MainPage'
|
|||||||
import {ModelType} from './ModelType'
|
import {ModelType} from './ModelType'
|
||||||
import { GroupOption } from "./GroupOption";
|
import { GroupOption } from "./GroupOption";
|
||||||
import { TitleGroup } from "../Interface/GroupInterface";
|
import { TitleGroup } from "../Interface/GroupInterface";
|
||||||
import { MatrixModel } from "./MatrixModel";
|
import { MatrixModel ,DevModel} from "./MatrixModel";
|
||||||
import { TitleButton } from "../Interface/ButtonInterface";
|
import { TitleButton } from "../Interface/ButtonInterface";
|
||||||
|
|
||||||
export let TitleCAE:Array<TitleModel>=[
|
export let TitleCAE:Array<TitleModel>=[
|
||||||
@ -27,5 +27,6 @@ export let TitleCAE:Array<TitleModel>=[
|
|||||||
],grpMenu:GroupOption}] as Array<TitleGroup>
|
],grpMenu:GroupOption}] as Array<TitleGroup>
|
||||||
]
|
]
|
||||||
]},
|
]},
|
||||||
MatrixModel
|
MatrixModel,
|
||||||
|
DevModel
|
||||||
]
|
]
|
||||||
@ -3,7 +3,7 @@ import {TitleMainPage} from './MainPage'
|
|||||||
import {ModelType} from './ModelType'
|
import {ModelType} from './ModelType'
|
||||||
import { GroupOption } from "./GroupOption";
|
import { GroupOption } from "./GroupOption";
|
||||||
import { TitleGroup } from "../Interface/GroupInterface";
|
import { TitleGroup } from "../Interface/GroupInterface";
|
||||||
import { MatrixModel } from "./MatrixModel";
|
import { MatrixModel,DevModel } from "./MatrixModel";
|
||||||
import { TitleButton } from "../Interface/ButtonInterface";
|
import { TitleButton } from "../Interface/ButtonInterface";
|
||||||
|
|
||||||
export let TitleCAM:Array<TitleModel>=[TitleMainPage[0],
|
export let TitleCAM:Array<TitleModel>=[TitleMainPage[0],
|
||||||
@ -24,4 +24,7 @@ export let TitleCAM:Array<TitleModel>=[TitleMainPage[0],
|
|||||||
{eModel:[ModelType.BASE],eName:"帮助",eNamed:"",eIcon:"base_help_file",eTips:"",eEvent:""},
|
{eModel:[ModelType.BASE],eName:"帮助",eNamed:"",eIcon:"base_help_file",eTips:"",eEvent:""},
|
||||||
],grpMenu:GroupOption}] as Array<TitleGroup>
|
],grpMenu:GroupOption}] as Array<TitleGroup>
|
||||||
]
|
]
|
||||||
]},MatrixModel]
|
]},
|
||||||
|
MatrixModel,
|
||||||
|
DevModel
|
||||||
|
]
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import { TitleButton } from "../Interface/ButtonInterface";
|
import { TitleButton } from "../Interface/ButtonInterface";
|
||||||
import { TitleGroup } from "../Interface/GroupInterface";
|
import { TitleGroup } from "../Interface/GroupInterface";
|
||||||
import { MatrixModel } from "./MatrixModel";
|
import { DevModel, MatrixModel } from "./MatrixModel";
|
||||||
import { ModelType } from "./ModelType";
|
import { ModelType } from "./ModelType";
|
||||||
import { GroupOption } from "./GroupOption";
|
import { GroupOption } from "./GroupOption";
|
||||||
import { TitleModel } from "./TabContent";
|
import { TitleModel } from "./TabContent";
|
||||||
@ -22,5 +22,6 @@ export let TitleMainPage:Array<TitleModel>=
|
|||||||
{eModel:[ModelType.BASE],eName:"帮助",eNamed:"",eIcon:"base_help_file",eTips:"",eEvent:""},
|
{eModel:[ModelType.BASE],eName:"帮助",eNamed:"",eIcon:"base_help_file",eTips:"",eEvent:""},
|
||||||
],
|
],
|
||||||
grpMenu:GroupOption}] as Array<TitleGroup>]]},
|
grpMenu:GroupOption}] as Array<TitleGroup>]]},
|
||||||
MatrixModel
|
MatrixModel,
|
||||||
|
DevModel
|
||||||
]
|
]
|
||||||
|
|||||||
@ -13,3 +13,11 @@ export let MatrixModel:TitleModel= {
|
|||||||
],grpMenu:GroupOption}] as Array<TitleGroup>
|
],grpMenu:GroupOption}] as Array<TitleGroup>
|
||||||
]]
|
]]
|
||||||
}
|
}
|
||||||
|
//模块矩阵布局数据
|
||||||
|
export let DevModel:TitleModel= {
|
||||||
|
cmName:"开发模式",cmPage:"",cmTips:"",cmEvents:[
|
||||||
|
[[{grpName:'工具矩阵',grpBtn:[
|
||||||
|
{eModel:[ModelType.BASE],eName:"加载模型",eNamed:"",eIcon:"base_new_file",eTips:"",eEvent:"Execute_LoadModel"},
|
||||||
|
],grpMenu:GroupOption}] as Array<TitleGroup>
|
||||||
|
]]
|
||||||
|
}
|
||||||
@ -30,7 +30,7 @@ export struct TitleTabContent {
|
|||||||
MenuBtn({menuBtn:btn_item})
|
MenuBtn({menuBtn:btn_item})
|
||||||
}else{
|
}else{
|
||||||
//针对最后一个Bar特化处理.如果为最后一个Bar则在子组件Image真假onClick事件
|
//针对最后一个Bar特化处理.如果为最后一个Bar则在子组件Image真假onClick事件
|
||||||
if(mIndex==this.tabLayout.length-1){
|
if(mIndex==this.tabLayout.length-2){
|
||||||
SwitchModelBtn({eventBtn:btn_item})
|
SwitchModelBtn({eventBtn:btn_item})
|
||||||
}else{
|
}else{
|
||||||
EventBtn({eventBtn:btn_item})
|
EventBtn({eventBtn:btn_item})
|
||||||
|
|||||||
@ -5,16 +5,24 @@ import {NodeContent} from '@kit.ArkUI';
|
|||||||
import NativeOpenCAX from 'libopencax.so';
|
import NativeOpenCAX from 'libopencax.so';
|
||||||
|
|
||||||
const DOMAIN = 0x0000;
|
const DOMAIN = 0x0000;
|
||||||
|
let modelPath: string = '';
|
||||||
|
export function OCCTLoadModel(Command: undefined, Param:undefined) {
|
||||||
|
try {
|
||||||
|
NativeOpenCAX.loadModel(modelPath);
|
||||||
|
console.info('Model copied to:', modelPath);
|
||||||
|
} catch (e) {
|
||||||
|
hilog.error(0x0000, 'ModelView', `LoadModel Failed: ${JSON.stringify(e)}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
@Component
|
@Component
|
||||||
export struct ModelView {
|
export struct ModelView {
|
||||||
private displayController: XComponentController = new XComponentController();
|
private displayController: XComponentController = new XComponentController();
|
||||||
private displayContrId: string = 'OCCTRender';
|
private displayContrId: string = 'OCCTRender';
|
||||||
@State modelPath: string = '';
|
|
||||||
@State modelName:string='2027.stp';
|
@State modelName:string='2027.stp';
|
||||||
@State currentStatus: string = 'init';
|
@State currentStatus: string = 'init';
|
||||||
private nodeContent: NodeContent = new NodeContent();
|
private nodeContent: NodeContent = new NodeContent();
|
||||||
|
|
||||||
|
|
||||||
aboutToAppear() {
|
aboutToAppear() {
|
||||||
NativeOpenCAX.createNativeNode(this.nodeContent);
|
NativeOpenCAX.createNativeNode(this.nodeContent);
|
||||||
this.copyRawFileToSandbox();
|
this.copyRawFileToSandbox();
|
||||||
@ -22,19 +30,19 @@ export struct ModelView {
|
|||||||
async copyRawFileToSandbox() {
|
async copyRawFileToSandbox() {
|
||||||
try {
|
try {
|
||||||
const context = getContext(this);
|
const context = getContext(this);
|
||||||
this.modelPath = `${context.filesDir}/${this.modelName}`;
|
modelPath = `${context.filesDir}/${this.modelName}`;
|
||||||
const arrayBuffer:Uint8Array = await context.resourceManager.getRawFileContent(this.modelName);
|
const arrayBuffer:Uint8Array = await context.resourceManager.getRawFileContent(this.modelName);
|
||||||
const buffer = arrayBuffer.buffer;
|
const buffer = arrayBuffer.buffer;
|
||||||
console.log('Raw file size:', arrayBuffer.byteLength);
|
console.log('Raw file size:', arrayBuffer.byteLength);
|
||||||
if (fs.accessSync(this.modelPath)) {
|
if (fs.accessSync(modelPath)) {
|
||||||
fs.unlinkSync(this.modelPath);
|
fs.unlinkSync(modelPath);
|
||||||
}
|
}
|
||||||
const fd = fileIO.openSync(this.modelPath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE,0o666);
|
const fd = fileIO.openSync(modelPath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE,0o666);
|
||||||
const bytesWritten = fileIO.writeSync(fd, buffer);
|
const bytesWritten = fileIO.writeSync(fd, buffer);
|
||||||
console.log('Bytes written:', bytesWritten);
|
console.log('Bytes written:', bytesWritten);
|
||||||
fileIO.closeSync(fd);
|
fileIO.closeSync(fd);
|
||||||
console.log('SanBox File:', arrayBuffer.byteLength);
|
console.log('SanBox File:', arrayBuffer.byteLength);
|
||||||
console.log('WriteModelPath:', this.modelPath);
|
console.log('WriteModelPath:', modelPath);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
let msg = 'Unknown error';
|
let msg = 'Unknown error';
|
||||||
if (err instanceof Error) {
|
if (err instanceof Error) {
|
||||||
@ -48,21 +56,15 @@ export struct ModelView {
|
|||||||
}
|
}
|
||||||
build() {
|
build() {
|
||||||
Flex({ direction: FlexDirection.Column }) {
|
Flex({ direction: FlexDirection.Column }) {
|
||||||
Row(){
|
|
||||||
Button('加载模型').onClick(()=>{
|
|
||||||
try {
|
|
||||||
console.info('Model copied to:', this.modelPath);
|
|
||||||
NativeOpenCAX.loadModel(this.modelPath);
|
|
||||||
} catch (e) {
|
|
||||||
hilog.error(0x0000, 'ModelView', `LoadModel Failed: ${JSON.stringify(e)}`);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}.height('5%')
|
|
||||||
Row(){
|
Row(){
|
||||||
ContentSlot(this.nodeContent);
|
ContentSlot(this.nodeContent);
|
||||||
}.layoutWeight(1)
|
}.layoutWeight(1)
|
||||||
|
.borderWidth(1)
|
||||||
}
|
}
|
||||||
|
.borderWidth(1)
|
||||||
.width('100%')
|
.width('100%')
|
||||||
.height('100%');
|
.height('100%');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user