geometry_linepoint_pane.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. 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 cutLineEqually(startX, startY, startZ, endX, endY, endZ, numSegments) {
  29. const segments = [];
  30. const deltaX = (endX - startX) / numSegments;
  31. const deltaY = (endY - startY) / numSegments;
  32. const deltaZ = (endZ - startZ) / numSegments;
  33. for (let i = 1; i < numSegments; i++) {
  34. const x = startX + i * deltaX;
  35. const y = startY + i * deltaY;
  36. const z = startZ + i * deltaZ;
  37. segments.push({ x, y, z });
  38. }
  39. return segments;
  40. }
  41. function OnRet(){
  42. unit.form.mainfrm.menu(0);
  43. }
  44. function OnDetermin(){
  45. //unit.form.mainfrm.OnSend('addLinePoints ' + ui.x1.value + ' ' + ui.y1.value + ' ' + ui.z1.value + ' '+ ui.x2.value + ' '+ ui.y2.value + ' '+ ui.z2.value + ' '+ ui.pb_s.value);
  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. const result = cutLineEqually(ui.x1.value, ui.y1.value, ui.z1.value, ui.x2.value, ui.y2.value, ui.z2.value, parseInt(ui.pb_s.value) + 1);
  51. for (let k = 0; k < result.length; k++) {
  52. let workcondition_index = model.acax_app.view.GetCurrentWorkConditionIndex();
  53. let temp = unit.form.tree.GetCurUniqueName();
  54. let name = temp;
  55. //判断是否为空
  56. let j = 0;
  57. let i = 0;
  58. if(model.acax_app.view.GetProperty(workcondition_index) === undefined || model.acax_app.view.GetProperty(workcondition_index).point === undefined) {
  59. name = name + " P 0 0";
  60. }else{
  61. let point_arr = Object.keys(model.acax_app.view.GetProperty(workcondition_index).point);
  62. name = name + " P 0 " + point_arr.length;
  63. while(1){
  64. for( i = 0;i < point_arr.length;++i) {
  65. if(model.acax_app.view.GetProperty(workcondition_index).point[point_arr[i]].name === name) {
  66. ++j;
  67. name = temp + " P 0 " + point_arr.length + j;
  68. break;
  69. }
  70. }
  71. if(i === point_arr.length) {
  72. break;
  73. }
  74. }
  75. }
  76. unit.form.mainfrm.OnSetPoints(result[k].x, result[k].y, result[k].z, ui.radius.value, name);
  77. // unit.form.mainfrm.OnSetPoints(ui.x1.value, ui.y1.value, ui.z1.value, ui.radius.value, name);
  78. let node ={
  79. "x":result[k].x,
  80. "y":result[k].y,
  81. "z":result[k].z,
  82. "radius": ui.radius.value,
  83. "name":name
  84. };
  85. unit.form.tree.SetPoint(node);
  86. }
  87. unit.form.mainfrm.OnCueline('创建成功', 'green');
  88. }
  89. function OnReturn(){
  90. unit.form.mainfrm.menu(0);
  91. }
  92. function OnDetermine(){
  93. unit.form.mainfrm.OnSend('addLinePoints2 ' + + ui.x1_1.value + ' ' + ui.y1_1.value + ' ' + ui.z1_1.value + ' '+ ui.x2_2.value + ' '+ ui.y2_2.value + ' '+ ui.z2_2.value + ' '+ ui.pb_n.value);
  94. //unit.form.mainfrm.OnCueline('第一个参数为空', 'red');
  95. //unit.form.mainfrm.OnChangePicture(1, 2);
  96. }
  97. function OnNode(){
  98. ui.select_stk.index = 1;
  99. }
  100. function OnSegment(){
  101. ui.select_stk.index = 0;
  102. }
  103. //The message corresponding callback executed by the docker pane.
  104. // when calling [side_pane].fireEvent(type,para) in the main form.
  105. function OnParentDockerMessage(type, para) {
  106. }
  107. //////////////////////////////////////////////////////////////////////////
  108. // Utils Functions.
  109. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  110. function onDragFile(filepath) {
  111. }
  112. function PUI(cb) {
  113. if(pui){cb();}
  114. }
  115. /*Usage of BLOCK_EVENT
  116. BLOCK_EVENT(()=>{
  117. ui.[name].[var] = ...;
  118. });
  119. */
  120. function BLOCK_EVENT(cb) {
  121. ui.block_event = true;
  122. cb();
  123. ui.block_event = false;
  124. }
  125. //////////////////////////////////////////////////////////////////////////
  126. // template codes for cw callback js.
  127. function CW_DeclareVariable(name, setter, getter) {
  128. if(typeof(__DeclareVariable) === 'function') {
  129. __DeclareVariable(name, setter, getter);
  130. }
  131. }
  132. function CW_DeclareOuterVariable(name) {
  133. if(typeof(__DeclareOuterVariable) === 'function') {
  134. __DeclareOuterVariable(name);
  135. }
  136. }