//////////////////////////////////////////////////////////////////////////// // 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() { console.log(33); } function OnException(err) { //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok); } var txt = 1; ////////////////////////////////////////////////////////////////////////// // Callback Functions. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7 function OnPosi(){ var id = parent.setTimeout(() => { unit.form.mainfrm.OnSend('0'); }, 100); unit.form.mainfrm.OnSend('sphere 2 ' + ui.pb_range.value + ' ' + ui.pb_a.value + ' ' + ui.pb_b.value + ' ' + ui.pb_c.value +' ' + ui.pb_x.value + ' ' + ui.pb_y.value + ' ' + ui.pb_z.value); } function OnDelete(){ model.deleteFile(model.getCurrentDirectory() + 'data/face'); } function OnGenerateFile(){ var id = parent.setTimeout(() => { unit.form.mainfrm.OnSend('0'); }, 100); unit.form.mainfrm.OnSend('txt ' + model.getCurrentDirectory() + 'data/peidian/demo' + txt + '.txt'); txt = txt + 1; } function OnConnect(){ var id = parent.setTimeout(() => { unit.form.mainfrm.OnSend('0'); }, 100); unit.form.mainfrm.OnSend('connect'); } function OnJudge(){ var id = parent.setTimeout(() => { unit.form.mainfrm.OnSend('0'); }, 100); unit.form.mainfrm.OnSend('judge'); } function OnSendRange(){ var id = parent.setTimeout(() => { unit.form.mainfrm.OnSend('0'); }, 100); unit.form.mainfrm.OnSend('sphere 1 ' + ui.pb_range.value); } function OnSendArrow(){ var str = "arrow " + ui.pb_x.value + ' ' + ui.pb_y.value + ' ' + ui.pb_z.value + ' ' + ui.pb_size.value; unit.form.mainfrm.OnSend(str); } function OnCloseArrow(){ ui.stack_pickup.index = 0; var id = parent.setTimeout(() => { unit.form.mainfrm.OnSend('0'); }, 100); unit.form.mainfrm.OnSend('arrowClose'); } function OnOpenArrow(){ ui.stack_pickup.index = 1; var id = parent.setTimeout(() => { unit.form.mainfrm.OnSend('0'); }, 100); unit.form.mainfrm.OnSend('arrowOpen'); } //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("message", val => { ui.message.value += val + '\n'; ui.message.row = -1; }, () => {}); 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); } }