geometry_node_pane.js 4.3 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. }
  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 OnReturn(){
  29. unit.form.mainfrm.menu(0);
  30. }
  31. //var i = 0;
  32. function OnSendPoint(){
  33. if(!model.global_ctrl[0] || !model.global_ctrl[1] || !model.global_ctrl[2] || !model.global_ctrl[3]) {
  34. unit.form.mainfrm.OnCueline('未满足创建条件', 'red');
  35. return;
  36. }
  37. let workcondition_index = model.acax_app.view.GetCurrentWorkConditionIndex();
  38. let temp = unit.form.tree.GetCurUniqueName();
  39. let name = temp;
  40. //判断是否为空
  41. let j = 0;
  42. let i = 0;
  43. if(model.acax_app.view.GetProperty(workcondition_index) === undefined || model.acax_app.view.GetProperty(workcondition_index).point === undefined) {
  44. name = name + " P 0 0";
  45. }else{
  46. let point_arr = Object.keys(model.acax_app.view.GetProperty(workcondition_index).point);
  47. name = name + " P 0 " + point_arr.length;
  48. while(1){
  49. for( i = 0;i < point_arr.length;++i) {
  50. if(model.acax_app.view.GetProperty(workcondition_index).point[point_arr[i]].name === name) {
  51. ++j;
  52. name = temp + " P 0 " + point_arr.length + j;
  53. break;
  54. }
  55. }
  56. if(i === point_arr.length) {
  57. break;
  58. }
  59. }
  60. }
  61. unit.form.mainfrm.OnSetPoints(ui.pb_x.value, ui.pb_y.value, ui.pb_z.value, ui.pb_radius.value, name);
  62. //++i;
  63. let node ={
  64. "x":ui.pb_x.value,
  65. "y":ui.pb_y.value,
  66. "z":ui.pb_z.value,
  67. "radius":ui.pb_radius.value,
  68. "name":name
  69. };
  70. unit.form.tree.SetPoint(node);
  71. unit.form.mainfrm.OnCueline('创建成功', 'green');
  72. }
  73. //The message corresponding callback executed by the docker pane.
  74. // when calling [side_pane].fireEvent(type,para) in the main form.
  75. function OnParentDockerMessage(type, para) {
  76. }
  77. //////////////////////////////////////////////////////////////////////////
  78. // Utils Functions.
  79. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  80. function onDragFile(filepath) {
  81. }
  82. function PUI(cb) {
  83. if(pui){cb();}
  84. }
  85. /*Usage of BLOCK_EVENT
  86. BLOCK_EVENT(()=>{
  87. ui.[name].[var] = ...;
  88. });
  89. */
  90. function BLOCK_EVENT(cb) {
  91. ui.block_event = true;
  92. cb();
  93. ui.block_event = false;
  94. }
  95. //////////////////////////////////////////////////////////////////////////
  96. // template codes for cw callback js.
  97. function CW_DeclareVariable(name, setter, getter) {
  98. if(typeof(__DeclareVariable) === 'function') {
  99. __DeclareVariable(name, setter, getter);
  100. }
  101. }
  102. function CW_DeclareOuterVariable(name) {
  103. if(typeof(__DeclareOuterVariable) === 'function') {
  104. __DeclareOuterVariable(name);
  105. }
  106. }