//////////////////////////////////////////////////////////////////////////// // 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. }); //unit.form.mainfrm.OnCueline('模型检测,检测模型水密性!'); } //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); } let myArray = []; ////////////////////////////////////////////////////////////////////////// // Callback Functions. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7 function OnError(){ myArray.forEach((item) => { console.log(item); unit.form.mainfrm.OnSend("BadFace " + item); }); } function OnReturnMeun(){ unit.form.mainfrm.menu(0); } function OnTestModel(){ unit.form.mainfrm.OnCueline('检测中...', 'Blue'); model.spawn(model.getCurrentDirectory() + "src/check4/demo1.exe", model.getStepPath(), cb =>{ //ui.cueline.value += cb + '\n'; //ui.cueline.row = -1; //const number = cb.match(/FaceIndex: (\d+)/)[1]; const numbers = cb.match(/FaceIndex: (\d+)/g).map(item => item.match(/\d+/)[0]); if (cb.indexOf("ssuccess!!!") !== -1) { ui.cueline.value += '成功!\n'; ui.cueline.row = -1; unit.form.mainfrm.OnChangePicture(1, 2); unit.form.mainfrm.OnCueline('通过!', 'green'); ui.pb_pass.enable = true; ui.pb_pass01.enable = true; } if(cb.indexOf("FaceIndex: ") !== -1){ ui.cueline.value += '您需要修改错误面:' + numbers[0] + '\n'; ui.cueline.row = -1; myArray.push(numbers[0]); unit.form.mainfrm.OnChangePicture(1, 3); unit.form.mainfrm.OnCueline('您需要修改错误面:' + numbers[0], 'red'); ui.pb_Error.enable = true; ui.pb_pass01.enable = false; } }); } //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();} } CW_DeclareVariable("path", val => { ui.pb_value.value = val; }, () => {}); /*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); } }