boundary_face_pane.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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() + 'data', cb => {
  31. console.log(cb);
  32. });*/
  33. model.deleteFile(model.getCurrentDirectory() + 'data/force');
  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 OnSave() {
  51. ui.pb_pass.enable = true;
  52. console.log(myStressArray[parseFloat(ui.listbox.index)]);
  53. var str = myStressArray[parseFloat(ui.listbox.index)];
  54. var str1 = str.split(',');
  55. var str2 = str1[0];
  56. str1 = str1.join(' ');
  57. model.write(str1, model.getCurrentDirectory() + '/data/force/force' + str2 + '.txt');
  58. }
  59. function OnChangeBox() {
  60. ui.pb_pass.enable = false;
  61. }
  62. function OnChangeStress() {
  63. ui.pb_pass.enable = false;
  64. }
  65. function OnChangeDirection() {
  66. ui.pb_pass.enable = false;
  67. }
  68. function OnDeleteFixFace() {
  69. ui.pb_pass.enable = false;
  70. myStressArray.splice(parseFloat(ui.listbox.index), 1);
  71. ui.listbox.list = [
  72. myStressArray
  73. ];
  74. }
  75. function OnAddFixFace() {
  76. ui.pb_pass.enable = false;
  77. var value = ui.pb_Id.value + ',' + parseFloat(ui.pb_Direction.value) + ',' + parseFloat(ui.pb_stress.value);
  78. if (ui.pb_Id.value != "--") {
  79. myStressArray.push(value);
  80. ui.listbox.list = [
  81. myStressArray
  82. ];
  83. }
  84. }
  85. //The message corresponding callback executed by the docker pane.
  86. // when calling [side_pane].fireEvent(type,para) in the main form.
  87. function OnParentDockerMessage(type, para) {
  88. }
  89. //////////////////////////////////////////////////////////////////////////
  90. // Utils Functions.
  91. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  92. function onDragFile(filepath) {
  93. }
  94. function PUI(cb) {
  95. if(pui){cb();}
  96. }
  97. CW_DeclareVariable("ID",
  98. val => {
  99. ui.pb_Id.value = val;
  100. }, () => {});
  101. /*Usage of BLOCK_EVENT
  102. BLOCK_EVENT(()=>{
  103. ui.[name].[var] = ...;
  104. });
  105. */
  106. function BLOCK_EVENT(cb) {
  107. ui.block_event = true;
  108. cb();
  109. ui.block_event = false;
  110. }
  111. //////////////////////////////////////////////////////////////////////////
  112. // template codes for cw callback js.
  113. function CW_DeclareVariable(name, setter, getter) {
  114. if(typeof(__DeclareVariable) === 'function') {
  115. __DeclareVariable(name, setter, getter);
  116. }
  117. }
  118. function CW_DeclareOuterVariable(name) {
  119. if(typeof(__DeclareOuterVariable) === 'function') {
  120. __DeclareOuterVariable(name);
  121. }
  122. }