geometry_node_pane.js 4.0 KB

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