geometry_mark_pane.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. function OnSend(){
  32. if(!model.global_ctrl[0] || !model.global_ctrl[1] || !model.global_ctrl[2] || !model.global_ctrl[3]) {
  33. unit.form.mainfrm.OnCueline('未满足创建条件', 'red');
  34. return;
  35. }
  36. let workcondition_index = model.acax_app.view.GetCurrentWorkConditionIndex();
  37. let temp = unit.form.tree.GetCurUniqueName();
  38. let name = temp;
  39. //判断是否为空
  40. let j = 0;
  41. let i = 0;
  42. if(model.acax_app.view.GetProperty(workcondition_index) === undefined || model.acax_app.view.GetProperty(workcondition_index).mark === undefined) {
  43. name = name + "mark0";
  44. }else{
  45. let mark_arr = Object.keys(model.acax_app.view.GetProperty(workcondition_index).mark);
  46. name = name + "mark" + mark_arr.length;
  47. while(1){
  48. for( i = 0;i < mark_arr.length;++i) {
  49. if(model.acax_app.view.GetProperty(workcondition_index).mark[mark_arr[i]].name === name) {
  50. ++j;
  51. name = temp + "mark" + mark_arr.length + j;
  52. break;
  53. }
  54. }
  55. if(i === mark_arr.length) {
  56. break;
  57. }
  58. }
  59. }
  60. unit.form.mainfrm.OnSetMarks(ui.pb_x.value, ui.pb_y.value, ui.pb_z.value, ui.pb_R.value, ui.pb_G.value, ui.pb_B.value, ui.pb_size.value, ui.pb_name.value, name);
  61. let mark ={
  62. "x":ui.pb_x.value,
  63. "y":ui.pb_y.value,
  64. "z":ui.pb_z.value,
  65. "R":ui.pb_R.value,
  66. "G":ui.pb_G.value,
  67. "B":ui.pb_B.value,
  68. "字体大小":ui.pb_size.value,
  69. "标记命名":ui.pb_name.value,
  70. "name":name
  71. };
  72. unit.form.tree.SetMark(mark);
  73. unit.form.mainfrm.OnCueline('创建成功', 'green');
  74. }
  75. //The message corresponding callback executed by the docker pane.
  76. // when calling [side_pane].fireEvent(type,para) in the main form.
  77. function OnParentDockerMessage(type, para) {
  78. }
  79. //////////////////////////////////////////////////////////////////////////
  80. // Utils Functions.
  81. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  82. function onDragFile(filepath) {
  83. }
  84. function PUI(cb) {
  85. if(pui){cb();}
  86. }
  87. CW_DeclareVariable("pb_x",
  88. val => {
  89. ui.pb_x.value = val;
  90. }, () => {});
  91. CW_DeclareVariable("pb_y",
  92. val => {
  93. ui.pb_y.value = val;
  94. }, () => {});
  95. CW_DeclareVariable("pb_z",
  96. val => {
  97. ui.pb_z.value = val;
  98. }, () => {});
  99. /*Usage of BLOCK_EVENT
  100. BLOCK_EVENT(()=>{
  101. ui.[name].[var] = ...;
  102. });
  103. */
  104. function BLOCK_EVENT(cb) {
  105. ui.block_event = true;
  106. cb();
  107. ui.block_event = false;
  108. }
  109. //////////////////////////////////////////////////////////////////////////
  110. // template codes for cw callback js.
  111. function CW_DeclareVariable(name, setter, getter) {
  112. if(typeof(__DeclareVariable) === 'function') {
  113. __DeclareVariable(name, setter, getter);
  114. }
  115. }
  116. function CW_DeclareOuterVariable(name) {
  117. if(typeof(__DeclareOuterVariable) === 'function') {
  118. __DeclareOuterVariable(name);
  119. }
  120. }