geometry_check_pane.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. //unit.form.mainfrm.OnCueline('模型检测,检测模型水密性!');
  12. }
  13. //Callback after UI is fully loaded and displayed.
  14. function OnReady(reload, preview) {
  15. PUI(()=>{
  16. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  17. //The 'pui' variable is valid in all functions of this document.
  18. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  19. });
  20. }
  21. function OnCloseForm() {
  22. }
  23. function OnException(err) {
  24. //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
  25. }
  26. let myArray = [];
  27. //////////////////////////////////////////////////////////////////////////
  28. // Callback Functions.
  29. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  30. function OnError(){
  31. myArray.forEach((item) => {
  32. console.log(item);
  33. unit.form.mainfrm.OnSend("BadFace " + item);
  34. });
  35. }
  36. function OnReturnMeun(){
  37. unit.form.mainfrm.menu(0);
  38. }
  39. function OnTestModel(){
  40. unit.form.mainfrm.OnCueline('检测中...', 'Blue');
  41. model.spawn(model.getCurrentDirectory() + "src/check4/demo1.exe", model.getStepPath(), cb =>{
  42. //ui.cueline.value += cb + '\n';
  43. //ui.cueline.row = -1;
  44. //const number = cb.match(/FaceIndex: (\d+)/)[1];
  45. const numbers = cb.match(/FaceIndex: (\d+)/g).map(item => item.match(/\d+/)[0]);
  46. if (cb.indexOf("ssuccess!!!") !== -1) {
  47. ui.cueline.value += '成功!\n';
  48. ui.cueline.row = -1;
  49. unit.form.mainfrm.OnChangePicture(1, 2);
  50. unit.form.mainfrm.OnCueline('通过!', 'green');
  51. ui.pb_pass.enable = true;
  52. ui.pb_pass01.enable = true;
  53. }
  54. if(cb.indexOf("FaceIndex: ") !== -1){
  55. ui.cueline.value += '您需要修改错误面:' + numbers[0] + '\n';
  56. ui.cueline.row = -1;
  57. myArray.push(numbers[0]);
  58. unit.form.mainfrm.OnChangePicture(1, 3);
  59. unit.form.mainfrm.OnCueline('您需要修改错误面:' + numbers[0], 'red');
  60. ui.pb_Error.enable = true;
  61. ui.pb_pass01.enable = false;
  62. }
  63. });
  64. }
  65. //The message corresponding callback executed by the docker pane.
  66. // when calling [side_pane].fireEvent(type,para) in the main form.
  67. function OnParentDockerMessage(type, para) {
  68. }
  69. //////////////////////////////////////////////////////////////////////////
  70. // Utils Functions.
  71. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  72. function onDragFile(filepath) {
  73. }
  74. function PUI(cb) {
  75. if(pui){cb();}
  76. }
  77. CW_DeclareVariable("path",
  78. val => {
  79. ui.pb_value.value = val;
  80. }, () => {});
  81. /*Usage of BLOCK_EVENT
  82. BLOCK_EVENT(()=>{
  83. ui.[name].[var] = ...;
  84. });
  85. */
  86. function BLOCK_EVENT(cb) {
  87. ui.block_event = true;
  88. cb();
  89. ui.block_event = false;
  90. }
  91. //////////////////////////////////////////////////////////////////////////
  92. // template codes for cw callback js.
  93. function CW_DeclareVariable(name, setter, getter) {
  94. if(typeof(__DeclareVariable) === 'function') {
  95. __DeclareVariable(name, setter, getter);
  96. }
  97. }
  98. function CW_DeclareOuterVariable(name) {
  99. if(typeof(__DeclareOuterVariable) === 'function') {
  100. __DeclareOuterVariable(name);
  101. }
  102. }