//////////////////////////////////////////////////////////////////////////// // System Pre-define Functions // 95099372-ef3e-11ea-9c81-bf848405c62e //Callback of data preparation stage before UI is fully loaded. function OnInitializeData(reload, preview) { PUI(()=>{ //you can access the 'ui' namespace in the parent form using the variable 'pui' here. //The 'pui' variable is valid in all functions of this document. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable. }); } //Callback after UI is fully loaded and displayed. function OnReady(reload, preview) { PUI(()=>{ //you can access the 'ui' namespace in the parent form using the variable 'pui' here. //The 'pui' variable is valid in all functions of this document. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable. }); } function OnCloseForm() { } function OnException(err) { //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok); } ////////////////////////////////////////////////////////////////////////// // Callback Functions. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7 function OnGetFaceName(){ const str = unit.form.mainfrm.OnGetFaceName(); // 匹配type对应内容的正则表达式,以type:开头,后面跟着非冒号的内容直到遇到空格或者字符串结束 const typeRegex = /type:([^point]+)/; // 匹配center坐标对应内容的正则表达式 //const centerRegex = /point:([\d. ]+)/; const typeMatch = str.match(typeRegex); const typeInfo = typeMatch? typeMatch[1] : null; const match = str.match(/point:([-\d.]+)\s+([-\d.]+)\s+([-\d.]+)/); const centerCoords = match.slice(1, 4); ui.type1.value = typeInfo; ui.x1.value = centerCoords[0]; ui.y1.value = centerCoords[1]; ui.z1.value = centerCoords[2]; } function OnCenz(){ if(ui.pbc_z.value <= 0){ unit.form.mainfrm.OnChangePicture(1, 3); unit.form.mainfrm.OnCueline('您输入的参数不符合常理,请您重新输入!!!', 'red'); } if(ui.pbc_z.value > 0){ unit.form.mainfrm.OnChangePicture(1, 1); unit.form.mainfrm.OnCueline('您输入了正确的数据!', 'green'); } } function OnCeny(){ if(ui.pbc_y.value <= 0){ unit.form.mainfrm.OnChangePicture(1, 3); unit.form.mainfrm.OnCueline('您输入的参数不符合常理,请您重新输入!!!', 'red'); } if(ui.pbc_y.value > 0){ unit.form.mainfrm.OnChangePicture(1, 1); unit.form.mainfrm.OnCueline('您输入了正确的数据!', 'green'); } } function OnCenx(){ if(ui.pbc_x.value <= 0){ unit.form.mainfrm.OnChangePicture(1, 3); unit.form.mainfrm.OnCueline('您输入的参数不符合常理,请您重新输入!!!', 'red'); } if(ui.pbc_x.value > 0){ unit.form.mainfrm.OnChangePicture(1, 1); unit.form.mainfrm.OnCueline('您输入了正确的数据!', 'green'); } } function OnDetermine(){ if(!model.global_ctrl[0] || !model.global_ctrl[1] || !model.global_ctrl[2] || !model.global_ctrl[3]) { unit.form.mainfrm.OnCueline('未满足创建条件', 'red'); return; } let workcondition_index = model.acax_app.view.GetCurrentWorkConditionIndex(); let temp = unit.form.tree.GetCurUniqueName(); let name = temp; //判断是否为空 let j = 0; let i = 0; if(model.acax_app.view.GetProperty(workcondition_index) === undefined || model.acax_app.view.GetProperty(workcondition_index).point === undefined) { name = name + " P 0 0"; }else{ let point_arr = Object.keys(model.acax_app.view.GetProperty(workcondition_index).point); name = name + " P 0 " + point_arr.length; while(1){ for( i = 0;i < point_arr.length;++i) { if(model.acax_app.view.GetProperty(workcondition_index).point[point_arr[i]].name === name) { ++j; name = temp + " P 0 " + point_arr.length + j; break; } } if(i === point_arr.length) { break; } } } //unit.form.mainfrm.OnSetPoints(ui.pb_x.value, ui.pb_y.value, ui.pb_z.value, ui.pb_radius.value, name); unit.form.mainfrm.OnSetPoints(ui.x1.value, ui.y1.value, ui.z1.value, ui.radius.value, name); //++i; let node ={ "x":ui.x1.value, "y":ui.y1.value, "z":ui.z1.value, "radius":ui.radius.value, "name":name }; unit.form.tree.SetPoint(node); unit.form.mainfrm.OnCueline('创建成功', 'green'); unit.form.mainfrm.OnChangePicture(1, 2); } function OnReturn(){ unit.form.mainfrm.menu(0); } //The message corresponding callback executed by the docker pane. // when calling [side_pane].fireEvent(type,para) in the main form. function OnParentDockerMessage(type, para) { } ////////////////////////////////////////////////////////////////////////// // Utils Functions. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe function onDragFile(filepath) { } function PUI(cb) { if(pui){cb();} } /*Usage of BLOCK_EVENT BLOCK_EVENT(()=>{ ui.[name].[var] = ...; }); */ function BLOCK_EVENT(cb) { ui.block_event = true; cb(); ui.block_event = false; } ////////////////////////////////////////////////////////////////////////// // template codes for cw callback js. function CW_DeclareVariable(name, setter, getter) { if(typeof(__DeclareVariable) === 'function') { __DeclareVariable(name, setter, getter); } } function CW_DeclareOuterVariable(name) { if(typeof(__DeclareOuterVariable) === 'function') { __DeclareOuterVariable(name); } }