boundary_load_pane.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. let str = ui.pb_1.value + ' ' + ui.pb_2.value;
  42. let BPP = {
  43. "BPP":str
  44. };
  45. //在model中添加BPP
  46. unit.form.tree.SetBPPProperty(BPP);
  47. //model.setBpp1(ui.pb_1.value);
  48. //model.setBpp2(ui.pb_2.value);
  49. // unit.form.mainfrm.OnSend(str);
  50. // model.setModelCode(1);
  51. // unit.form.mainfrm.OnChangePicture(3, 1);
  52. ////unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">恭喜您将数据成功添加,但需要注意的是均匀加密次数和网格尺寸大小越大,计算时间越长,计算精度越高!</h4>');
  53. unit.form.mainfrm.OnCueline('您将数据成功添加,但需要注意的是均匀加密次数和网格尺寸大小越大,计算时间越长,计算精度越高!', 'green');
  54. }
  55. function OnYes() {
  56. ui.pb_pass.enable = true;
  57. var str = '0' + '\n' + '0' + '\n' + ui.aver_code_times.value + '\n' + ui.level_code_times.value + '\n' + ui.model_code_times.value;
  58. model.write(str, model.getCurrentDirectory() + '/data/BPP.txt');
  59. unit.form.mainfrm.OnChangePicture(3, 1);
  60. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">恭喜您将数据成功添加,但需要注意的是均匀加密次数和网格尺寸大小越大,计算时间越长,计算精度越高!</h4>');
  61. unit.form.mainfrm.OnCueline('您将数据成功添加,但需要注意的是均匀加密次数和网格尺寸大小越大,计算时间越长,计算精度越高!', 'green');
  62. }
  63. function OnPeiDian(){
  64. model.spawn(model.getCurrentDirectory() + "src/peidian/assemble_face_pei.exe", model.getCurrentDirectory() + 'data/faceID', cb => {
  65. console.log(cb);
  66. });
  67. }
  68. function OnGenerateBrep(){
  69. model.spawn(model.getCurrentDirectory() + "src/srcBrep/generateBrep.exe", model.getCurrentDirectory(), cb => {
  70. console.log(cb);
  71. });
  72. }
  73. function OnBrep(){
  74. var faceId;
  75. var str = ui.pb_Id.value;
  76. var hashCodes = model.getHash();
  77. for(var i = 0; i < hashCodes.length; i++){
  78. if(hashCodes[i] === parseInt(str)){
  79. ui.pb_Id.value = i + 1;
  80. //model.write(str, model.getCurrentDirectory() + '/data/face/face' + (i + 1) + '.txt');
  81. }
  82. }
  83. model.write(ui.pb_Id.value, model.getCurrentDirectory() + '/data/face/face' + ui.pb_Id.value + '.txt');
  84. //model.write(str, model.getCurrentDirectory() + '/data/face/face' + str + '.txt');
  85. }
  86. var pick = false;
  87. function OnPickUp() {
  88. pick = !pick;
  89. if (pick === true) {
  90. unit.form.mainfrm.pick(1);
  91. ui.pb_pick.valid = true;
  92. }
  93. if (pick === false) {
  94. unit.form.mainfrm.pick(2);
  95. ui.pb_pick.valid = false;
  96. }
  97. }
  98. function OnReturnMenu(){
  99. unit.form.mainfrm.menu(4);
  100. }
  101. function OnLoadPeiDian(){
  102. unit.form.mainfrm.OnChangeWindows(2);
  103. /*
  104. var id = parent.setTimeout(() => {
  105. unit.form.mainfrm.OnSend('load 0');
  106. }, 100);
  107. unit.form.mainfrm.OnSend('load 1 ' + model.getCurrentDirectory() + '/data/faceID/pei.txt');*/
  108. var id = parent.setTimeout(() => {
  109. unit.form.mainfrm.OnSend('0');
  110. }, 100);
  111. unit.form.mainfrm.OnSend('HightLightPoint ' + model.getCurrentDirectory() + '/data/faceID/pei.txt');
  112. }
  113. //The message corresponding callback executed by the docker pane.
  114. // when calling [side_pane].fireEvent(type,para) in the main form.
  115. function OnParentDockerMessage(type, para) {
  116. }
  117. //////////////////////////////////////////////////////////////////////////
  118. // Utils Functions.
  119. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  120. function onDragFile(filepath) {
  121. }
  122. function PUI(cb) {
  123. if(pui){cb();}
  124. }
  125. /*Usage of BLOCK_EVENT
  126. BLOCK_EVENT(()=>{
  127. ui.[name].[var] = ...;
  128. });
  129. */
  130. CW_DeclareVariable("ID",
  131. val => {
  132. ui.pb_Id.value = val;
  133. }, () => {});
  134. function BLOCK_EVENT(cb) {
  135. ui.block_event = true;
  136. cb();
  137. ui.block_event = false;
  138. }
  139. //////////////////////////////////////////////////////////////////////////
  140. // template codes for cw callback js.
  141. function CW_DeclareVariable(name, setter, getter) {
  142. if(typeof(__DeclareVariable) === 'function') {
  143. __DeclareVariable(name, setter, getter);
  144. }
  145. }
  146. function CW_DeclareOuterVariable(name) {
  147. if(typeof(__DeclareOuterVariable) === 'function') {
  148. __DeclareOuterVariable(name);
  149. }
  150. }