boundary_fix_pane.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. let myStressArray = [];
  26. //////////////////////////////////////////////////////////////////////////
  27. // Callback Functions.
  28. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  29. function OnDelete(){
  30. /*model.spawn(model.getCurrentDirectory() + 'src_exe/deleteFiles.exe', model.getCurrentDirectory(), cb => {
  31. console.log(cb);
  32. });*/
  33. model.deleteFile(model.getCurrentDirectory() + 'data/restraint');
  34. }
  35. var pick = false;
  36. function OnPickUp() {
  37. pick = !pick;
  38. if (pick === true) {
  39. unit.form.mainfrm.pick(1);
  40. ui.pb_pick.valid = true;
  41. }
  42. if (pick === false) {
  43. unit.form.mainfrm.pick(2);
  44. ui.pb_pick.valid = false;
  45. }
  46. }
  47. function OnReturnMenu(){
  48. unit.form.mainfrm.menu(5);
  49. }
  50. function OnYes() {
  51. ui.pb_pass.enable = true;
  52. var str = myStressArray[parseFloat(ui.listbox.index)];
  53. var str1 = str.split(',');
  54. var str2 = str1[0];
  55. str1 = str1.join(' ');
  56. model.write(str1, model.getCurrentDirectory() + '/data/restraint/restrant' + str2 + '.txt');
  57. }
  58. function OnDeleteFixFace() {
  59. ui.pb_pass.enable = false;
  60. myStressArray.splice(parseFloat(ui.listbox.index), 1);
  61. ui.listbox.list = [
  62. myStressArray
  63. ];
  64. }
  65. function OnAddFixFace() {
  66. ui.pb_pass.enable = false;
  67. var value = ui.pb_Id.value + ',' + parseFloat(ui.pb_Xd.value) + ',' + parseFloat(ui.pb_Yd.value) + ',' + parseFloat(ui.pb_Zd.value) + ',' + parseFloat(ui.pb_Xr.value) + ',' + parseFloat(ui.pb_Yr.value) + ',' + parseFloat(ui.pb_Zr.value);
  68. if (ui.pb_Id.value != "-") {
  69. myStressArray.push(value);
  70. ui.listbox.list = [
  71. myStressArray
  72. ];
  73. }
  74. }
  75. function OnChangeDirection05() {
  76. ui.pb_pass.enable = false;
  77. }
  78. function OnChangeDirection04() {
  79. ui.pb_pass.enable = false;
  80. }
  81. function OnChangeDirection03() {
  82. ui.pb_pass.enable = false;
  83. }
  84. function OnChangeDirection02() {
  85. ui.pb_pass.enable = false;
  86. }
  87. function OnChangeDirection01() {
  88. ui.pb_pass.enable = false;
  89. }
  90. function OnChangeDirection() {
  91. ui.pb_pass.enable = false;
  92. }
  93. //The message corresponding callback executed by the docker pane.
  94. // when calling [side_pane].fireEvent(type,para) in the main form.
  95. function OnParentDockerMessage(type, para) {
  96. }
  97. //////////////////////////////////////////////////////////////////////////
  98. // Utils Functions.
  99. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  100. function onDragFile(filepath) {
  101. }
  102. function PUI(cb) {
  103. if(pui){cb();}
  104. }
  105. /*Usage of BLOCK_EVENT
  106. BLOCK_EVENT(()=>{
  107. ui.[name].[var] = ...;
  108. });
  109. */
  110. CW_DeclareVariable("ID",
  111. val => {
  112. ui.pb_Id.value = val;
  113. }, () => {});
  114. function BLOCK_EVENT(cb) {
  115. ui.block_event = true;
  116. cb();
  117. ui.block_event = false;
  118. }
  119. //////////////////////////////////////////////////////////////////////////
  120. // template codes for cw callback js.
  121. function CW_DeclareVariable(name, setter, getter) {
  122. if(typeof(__DeclareVariable) === 'function') {
  123. __DeclareVariable(name, setter, getter);
  124. }
  125. }
  126. function CW_DeclareOuterVariable(name) {
  127. if(typeof(__DeclareOuterVariable) === 'function') {
  128. __DeclareOuterVariable(name);
  129. }
  130. }