boundary_load_pane.js 6.4 KB

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