//////////////////////////////////////////////////////////////////////////// // 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 OnChangeValue(){ model.setModelCode(0); if(parseFloat(ui.pb_2.value) < 0 || ui.pb_2.value === ''){ unit.form.mainfrm.OnChangePicture(3, 3); //unit.form.mainfrm.OnCueline('

非常抱歉,您输入的数据不在参数范围内!

'); unit.form.mainfrm.OnCueline('您输入的数据不在参数范围内!', 'red'); }else{ unit.form.mainfrm.OnChangePicture(3, 1); //unit.form.mainfrm.OnCueline('

恭喜您输入了正确的数据!

'); unit.form.mainfrm.OnCueline('您输入了正确的数据!', 'green'); } } function OnBPP(){ var str = 'BPP ' + ui.pb_1.value + ' ' + ui.pb_2.value; model.setBpp1(ui.pb_1.value); model.setBpp2(ui.pb_2.value); unit.form.mainfrm.OnSend(str); model.setModelCode(1); unit.form.mainfrm.OnChangePicture(3, 1); //unit.form.mainfrm.OnCueline('

恭喜您将数据成功添加,但需要注意的是均匀加密次数和网格尺寸大小越大,计算时间越长,计算精度越高!

'); unit.form.mainfrm.OnCueline('您将数据成功添加,但需要注意的是均匀加密次数和网格尺寸大小越大,计算时间越长,计算精度越高!', 'green'); } function OnYes() { ui.pb_pass.enable = true; var str = '0' + '\n' + '0' + '\n' + ui.aver_code_times.value + '\n' + ui.level_code_times.value + '\n' + ui.model_code_times.value; model.write(str, model.getCurrentDirectory() + '/data/BPP.txt'); unit.form.mainfrm.OnChangePicture(3, 1); //unit.form.mainfrm.OnCueline('

恭喜您将数据成功添加,但需要注意的是均匀加密次数和网格尺寸大小越大,计算时间越长,计算精度越高!

'); unit.form.mainfrm.OnCueline('您将数据成功添加,但需要注意的是均匀加密次数和网格尺寸大小越大,计算时间越长,计算精度越高!', 'green'); } function OnPeiDian(){ model.spawn(model.getCurrentDirectory() + "src/peidian/assemble_face_pei.exe", model.getCurrentDirectory() + 'data/faceID', cb => { console.log(cb); }); } function OnGenerateBrep(){ model.spawn(model.getCurrentDirectory() + "src/srcBrep/generateBrep.exe", model.getCurrentDirectory(), cb => { console.log(cb); }); } function OnBrep(){ var faceId; var str = ui.pb_Id.value; var hashCodes = model.getHash(); for(var i = 0; i < hashCodes.length; i++){ if(hashCodes[i] === parseInt(str)){ ui.pb_Id.value = i + 1; //model.write(str, model.getCurrentDirectory() + '/data/face/face' + (i + 1) + '.txt'); } } model.write(ui.pb_Id.value, model.getCurrentDirectory() + '/data/face/face' + ui.pb_Id.value + '.txt'); //model.write(str, model.getCurrentDirectory() + '/data/face/face' + str + '.txt'); } var pick = false; function OnPickUp() { pick = !pick; if (pick === true) { unit.form.mainfrm.pick(1); ui.pb_pick.valid = true; } if (pick === false) { unit.form.mainfrm.pick(2); ui.pb_pick.valid = false; } } function OnReturnMenu(){ unit.form.mainfrm.menu(4); } function OnLoadPeiDian(){ unit.form.mainfrm.OnChangeWindows(2); /* var id = parent.setTimeout(() => { unit.form.mainfrm.OnSend('load 0'); }, 100); unit.form.mainfrm.OnSend('load 1 ' + model.getCurrentDirectory() + '/data/faceID/pei.txt');*/ var id = parent.setTimeout(() => { unit.form.mainfrm.OnSend('0'); }, 100); unit.form.mainfrm.OnSend('HightLightPoint ' + model.getCurrentDirectory() + '/data/faceID/pei.txt'); } //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] = ...; }); */ CW_DeclareVariable("ID", val => { ui.pb_Id.value = val; }, () => {}); 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); } }