boundary_load_pane.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. ////////////////////////////////////////////////////////////////////////////
  2. // System Pre-define Functions
  3. // 95099372-ef3e-11ea-9c81-bf848405c62e
  4. //Callback of data preparation stage before UI is fully loaded.
  5. function OnInitializeData(reload, preview) {
  6. PUI(()=>{
  7. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  8. //The 'pui' variable is valid in all functions of this document.
  9. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  10. });
  11. }
  12. //Callback after UI is fully loaded and displayed.
  13. function OnReady(reload, preview) {
  14. PUI(()=>{
  15. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  16. //The 'pui' variable is valid in all functions of this document.
  17. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  18. });
  19. }
  20. function OnCloseForm() {
  21. }
  22. function OnException(err) {
  23. //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
  24. }
  25. //////////////////////////////////////////////////////////////////////////
  26. // Callback Functions.
  27. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  28. function OnChangeValue(){
  29. model.setModelCode(0);
  30. if(parseFloat(ui.pb_2.value) < 0 || ui.pb_2.value === ''){
  31. unit.form.mainfrm.OnChangePicture(3, 3);
  32. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: red;font-size:20px;">非常抱歉,您输入的数据不在参数范围内!</h4>');
  33. unit.form.mainfrm.OnCueline('您输入的数据不在参数范围内!', 'red');
  34. }else{
  35. unit.form.mainfrm.OnChangePicture(3, 1);
  36. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">恭喜您输入了正确的数据!</h4>');
  37. unit.form.mainfrm.OnCueline('您输入了正确的数据!', 'green');
  38. }
  39. }
  40. function OnBPP(){
  41. var str = 'BPP ' + ui.pb_1.value + ' ' + ui.pb_2.value;
  42. model.setBpp1(ui.pb_1.value);
  43. model.setBpp2(ui.pb_2.value);
  44. unit.form.mainfrm.OnSend(str);
  45. model.setModelCode(1);
  46. unit.form.mainfrm.OnChangePicture(3, 1);
  47. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">恭喜您将数据成功添加,但需要注意的是均匀加密次数和网格尺寸大小越大,计算时间越长,计算精度越高!</h4>');
  48. unit.form.mainfrm.OnCueline('您将数据成功添加,但需要注意的是均匀加密次数和网格尺寸大小越大,计算时间越长,计算精度越高!', 'green');
  49. }
  50. function OnYes() {
  51. ui.pb_pass.enable = true;
  52. var str = '0' + '\n' + '0' + '\n' + ui.aver_code_times.value + '\n' + ui.level_code_times.value + '\n' + ui.model_code_times.value;
  53. model.write(str, model.getCurrentDirectory() + '/data/BPP.txt');
  54. unit.form.mainfrm.OnChangePicture(3, 1);
  55. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">恭喜您将数据成功添加,但需要注意的是均匀加密次数和网格尺寸大小越大,计算时间越长,计算精度越高!</h4>');
  56. unit.form.mainfrm.OnCueline('您将数据成功添加,但需要注意的是均匀加密次数和网格尺寸大小越大,计算时间越长,计算精度越高!', 'green');
  57. }
  58. function OnPeiDian(){
  59. model.spawn(model.getCurrentDirectory() + "src/peidian/assemble_face_pei.exe", model.getCurrentDirectory() + 'data/faceID', cb => {
  60. console.log(cb);
  61. });
  62. }
  63. function OnGenerateBrep(){
  64. model.spawn(model.getCurrentDirectory() + "src/srcBrep/generateBrep.exe", model.getCurrentDirectory(), cb => {
  65. console.log(cb);
  66. });
  67. }
  68. function OnBrep(){
  69. var faceId;
  70. var str = ui.pb_Id.value;
  71. var hashCodes = model.getHash();
  72. for(var i = 0; i < hashCodes.length; i++){
  73. if(hashCodes[i] === parseInt(str)){
  74. ui.pb_Id.value = i + 1;
  75. //model.write(str, model.getCurrentDirectory() + '/data/face/face' + (i + 1) + '.txt');
  76. }
  77. }
  78. model.write(ui.pb_Id.value, model.getCurrentDirectory() + '/data/face/face' + ui.pb_Id.value + '.txt');
  79. //model.write(str, model.getCurrentDirectory() + '/data/face/face' + str + '.txt');
  80. }
  81. var pick = false;
  82. function OnPickUp() {
  83. pick = !pick;
  84. if (pick === true) {
  85. unit.form.mainfrm.pick(1);
  86. ui.pb_pick.valid = true;
  87. }
  88. if (pick === false) {
  89. unit.form.mainfrm.pick(2);
  90. ui.pb_pick.valid = false;
  91. }
  92. }
  93. function OnReturnMenu(){
  94. unit.form.mainfrm.menu(4);
  95. }
  96. function OnLoadPeiDian(){
  97. unit.form.mainfrm.OnChangeWindows(2);
  98. /*
  99. var id = parent.setTimeout(() => {
  100. unit.form.mainfrm.OnSend('load 0');
  101. }, 100);
  102. unit.form.mainfrm.OnSend('load 1 ' + model.getCurrentDirectory() + '/data/faceID/pei.txt');*/
  103. var id = parent.setTimeout(() => {
  104. unit.form.mainfrm.OnSend('0');
  105. }, 100);
  106. unit.form.mainfrm.OnSend('HightLightPoint ' + model.getCurrentDirectory() + '/data/faceID/pei.txt');
  107. }
  108. //The message corresponding callback executed by the docker pane.
  109. // when calling [side_pane].fireEvent(type,para) in the main form.
  110. function OnParentDockerMessage(type, para) {
  111. }
  112. //////////////////////////////////////////////////////////////////////////
  113. // Utils Functions.
  114. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  115. function onDragFile(filepath) {
  116. }
  117. function PUI(cb) {
  118. if(pui){cb();}
  119. }
  120. /*Usage of BLOCK_EVENT
  121. BLOCK_EVENT(()=>{
  122. ui.[name].[var] = ...;
  123. });
  124. */
  125. CW_DeclareVariable("ID",
  126. val => {
  127. ui.pb_Id.value = val;
  128. }, () => {});
  129. function BLOCK_EVENT(cb) {
  130. ui.block_event = true;
  131. cb();
  132. ui.block_event = false;
  133. }
  134. //////////////////////////////////////////////////////////////////////////
  135. // template codes for cw callback js.
  136. function CW_DeclareVariable(name, setter, getter) {
  137. if(typeof(__DeclareVariable) === 'function') {
  138. __DeclareVariable(name, setter, getter);
  139. }
  140. }
  141. function CW_DeclareOuterVariable(name) {
  142. if(typeof(__DeclareOuterVariable) === 'function') {
  143. __DeclareOuterVariable(name);
  144. }
  145. }