boundary_beam_pane.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. force_fixed(true);
  12. ui.pb_addPoint.enable = false;
  13. }
  14. //Callback after UI is fully loaded and displayed.
  15. function OnReady(reload, preview) {
  16. PUI(()=>{
  17. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  18. //The 'pui' variable is valid in all functions of this document.
  19. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  20. });
  21. }
  22. function OnCloseForm() {
  23. }
  24. function OnException(err) {
  25. //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
  26. }
  27. var myStressArray = [];
  28. var myArray = [];
  29. //////////////////////////////////////////////////////////////////////////
  30. // Callback Functions.
  31. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  32. function OnAddPoint(){
  33. ui.pb_point.value = parseInt(ui.pb_point.value) + 1;
  34. var str = myStressArray[parseInt(ui.listbox.index)].split(',');
  35. if(ui.pb_judge.value === '1'){
  36. var id = parent.setTimeout(() => {
  37. unit.form.mainfrm.OnSend('0');
  38. }, 100);
  39. unit.form.mainfrm.OnSend('arrowBeam ' + ui.pb_force_xd.value + ' ' + (parseFloat(ui.pb_force_xd.value)) + ' ' + ui.pb_force_yd.value + ' ' + ui.pb_force_zd.value);
  40. var value = ui.pb_point.value + ',' + '*' + ',' + parseFloat(ui.pb_force_id.value) + ',' + parseFloat(ui.pb_force_xd.value) + ',' + parseFloat(ui.pb_force_yd.value) + ',' + parseFloat(ui.pb_force_zd.value) + ',' + parseFloat(ui.pb_force_xr.value) + ',' + parseFloat(ui.pb_force_yr.value) + ',' + parseFloat(ui.pb_force_zr.value) + ',' + str[0];
  41. }
  42. if(ui.pb_judge.value === '0'){
  43. var id = parent.setTimeout(() => {
  44. unit.form.mainfrm.OnSend('0');
  45. }, 100);
  46. unit.form.mainfrm.OnSend('fixBeam 1');
  47. var value = ui.pb_point.value + ',' + '#' + ',' + parseFloat(ui.pb_fix_id.value) + ',' + parseFloat(ui.pb_fix_xd.value) + ',' + parseFloat(ui.pb_fix_yd.value) + ',' + parseFloat(ui.pb_fix_zd.value) + ',' + parseFloat(ui.pb_fix_xr.value) + ',' + parseFloat(ui.pb_fix_yr.value) + ',' + parseFloat(ui.pb_fix_zr.value) + ',' + str[0];
  48. }
  49. myArray.push(value);
  50. ui.pointbox.list = [
  51. myArray
  52. ];
  53. ui.pb_addPoint.enable = false;
  54. }
  55. function OnForce(){
  56. force_fixed(true);
  57. ui.pb_addPoint.enable = true;
  58. }
  59. function force_fixed(idx){
  60. if(idx){
  61. ui.pb_judge.value = 1;
  62. }else{
  63. ui.pb_judge.value = 0;
  64. }
  65. ui.pb_force.valid = idx;
  66. ui.pb_force_id.enable = idx;
  67. ui.pb_force_xd.enable = idx;
  68. ui.pb_force_yd.enable = idx;
  69. ui.pb_force_zd.enable = idx;
  70. ui.pb_force_xr.enable = idx;
  71. ui.pb_force_yr.enable = idx;
  72. ui.pb_force_zr.enable = idx;
  73. ui.pb_fix.valid = !idx;
  74. ui.pb_fix_id.enable = !idx;
  75. ui.pb_fix_xd.enable = !idx;
  76. ui.pb_fix_yd.enable = !idx;
  77. ui.pb_fix_zd.enable = !idx;
  78. ui.pb_fix_xr.enable = !idx;
  79. ui.pb_fix_yr.enable = !idx;
  80. ui.pb_fix_zr.enable = !idx;
  81. }
  82. function OnFixed(){
  83. force_fixed(false);
  84. ui.pb_addPoint.enable = true;
  85. }
  86. function OnShowPoint(){
  87. var str = myStressArray[parseFloat(ui.listbox.index)];
  88. var str1 = str.split(',');
  89. var id = parent.setTimeout(() => {
  90. unit.form.mainfrm.OnSend('0');
  91. }, 100);
  92. unit.form.mainfrm.OnSend('showPoint ' + (parseInt(str1[0]) - 1) + ' 1 0 0 1');
  93. }
  94. function OnLineGenerate(){
  95. ui.pb_add.enable = true;
  96. var id = parent.setTimeout(() => {
  97. unit.form.mainfrm.OnSend('0');
  98. }, 100);
  99. unit.form.mainfrm.OnSend('beamMesh ' + ui.pb_size.value + ' ' + ui.pb_length.value + ' ' + ui.pb_xDiration.value + ' ' + ui.pb_yDiration.value + ' ' + ui.pb_zDiration.value + ' ' + ui.pb_xCoord.value + ' ' + ui.pb_yCoord.value + ' ' + ui.pb_zCoord.value);
  100. }
  101. var pick = false;
  102. function OnPickUp() {
  103. pick = !pick;
  104. if (pick === true) {
  105. var id = parent.setTimeout(() => {
  106. unit.form.mainfrm.OnSend('0');
  107. }, 100);
  108. unit.form.mainfrm.OnSend('arrowOpen');
  109. ui.pb_pick.valid = true;
  110. }
  111. if (pick === false) {
  112. var id = parent.setTimeout(() => {
  113. unit.form.mainfrm.OnSend('0');
  114. }, 100);
  115. unit.form.mainfrm.OnSend('arrowClose');
  116. ui.pb_pick.valid = false;
  117. }
  118. }
  119. function OnReturnMenu(){
  120. unit.form.mainfrm.menu(5);
  121. }
  122. function OnYes() {
  123. ui.pb_pass.enable = true;
  124. var str = myStressArray[parseFloat(ui.listbox.index)];
  125. var str1 = str.split(',');
  126. var str2 = str1[0];
  127. str1 = str1.join(' ');
  128. model.write(str1, model.getCurrentDirectory() + '/data/restraint/restrant' + str2 + '.txt');
  129. }
  130. function OnDeleteFixFace() {
  131. var str = myStressArray[parseFloat(ui.listbox.index)];
  132. var str1 = str.split(',');
  133. var id = parent.setTimeout(() => {
  134. unit.form.mainfrm.OnSend('0');
  135. }, 100);
  136. unit.form.mainfrm.OnSend('closeBeam ' + (parseInt(str1[0]) - 1) + ' 0 1 0 0' );
  137. myStressArray.splice(parseFloat(ui.listbox.index), 1);
  138. ui.listbox.list = [
  139. myStressArray
  140. ];
  141. unit.form.mainfrm.OnDeleteBeam(parseFloat(ui.listbox.index));
  142. }
  143. function OnAddFixFace() {
  144. unit.form.mainfrm.OnChangeWindows(2);
  145. var id = parent.setTimeout(() => {
  146. unit.form.mainfrm.OnSend('0');
  147. }, 100);
  148. var id = parent.setTimeout(() => {
  149. if(ui.message.value === 'add line'){
  150. ui.pb_ID.value = parseInt(ui.pb_ID.value) + 1;
  151. var value = ui.pb_ID.value + ',' + parseFloat(ui.pb_xDiration.value) + ',' + parseFloat(ui.pb_yDiration.value) + ',' + parseFloat(ui.pb_zDiration.value) + ',' + parseFloat(ui.pb_xCoord.value) + ',' + parseFloat(ui.pb_yCoord.value) + ',' + parseFloat(ui.pb_zCoord.value) + ',' + parseFloat(ui.pb_zhijing.value)+ ',' + parseFloat(ui.pb_length.value) + ',' + parseFloat(ui.pb_size.value) + ',' + parseFloat(ui.pb_m.value) + ',' + parseFloat(ui.pb_poi.value);
  152. myStressArray.push(value);
  153. ui.listbox.list = [
  154. myStressArray
  155. ];
  156. ui.pb_add.enable = false;
  157. unit.form.mainfrm.OnGetBeam(ui.pb_ID.value);
  158. }
  159. }, 110);
  160. unit.form.mainfrm.OnSend('showBeam');
  161. /*
  162. ui.pb_ID.value = parseInt(ui.pb_ID.value) + 1;
  163. var value = ui.pb_ID.value + ',' + parseFloat(ui.pb_xDiration.value) + ',' + parseFloat(ui.pb_yDiration.value) + ',' + parseFloat(ui.pb_zDiration.value) + ',' + parseFloat(ui.pb_xCoord.value) + ',' + parseFloat(ui.pb_yCoord.value) + ',' + parseFloat(ui.pb_zCoord.value) + ',' + parseFloat(ui.pb_zhijing.value)+ ',' + parseFloat(ui.pb_length.value) + ',' + parseFloat(ui.pb_size.value) + ',' + parseFloat(ui.pb_m.value) + ',' + parseFloat(ui.pb_poi.value);
  164. myStressArray.push(value);
  165. ui.listbox.list = [
  166. myStressArray
  167. ];
  168. ui.pb_add.enable = false;*/
  169. }
  170. function OnLoad(){
  171. var value = '';
  172. for (var i = 0; i < myStressArray.length; i++) {
  173. var str = myStressArray[i].split(',');
  174. value += '* ' + str[7] + ' ' + str[8] + ' ' + str[9] + '\n'
  175. + '# ' + str[10] + ' ' + str[11] + '\n'
  176. + '$ ' + str[1] + ' ' + str[2] + ' ' + str[3] + ' ' + str[4] + ' ' + str[5] + ' ' + str[6] + '\n';
  177. }
  178. model.write(value, model.getCurrentDirectory() + '/data/beam/beam.txt');
  179. var value1 = '';
  180. var value2 = '';
  181. for (var i = 0; i < myArray.length; i++) {
  182. var str = myArray[i].split(',');
  183. if(str[1] === '*'){
  184. value1 += '* ' + str[2] + ' ' + str[3] + ' ' + str[4] + ' ' + str[5] + ' ' + str[6] + ' ' + str[7] + ' ' + str[8] + ' ' + str[9] + '\n';
  185. }
  186. if(str[1] === '#'){
  187. value2 += '* ' + str[2] + ' ' + str[3] + ' ' + str[4] + ' ' + str[5] + ' ' + str[6] + ' ' + str[7] + ' ' + str[8] + ' ' + str[9] + '\n';
  188. }
  189. }
  190. model.write(value1, model.getCurrentDirectory() + '/data/beam/beam_force.txt');
  191. model.write(value2, model.getCurrentDirectory() + '/data/beam/beam_fix.txt');
  192. }
  193. //The message corresponding callback executed by the docker pane.
  194. // when calling [side_pane].fireEvent(type,para) in the main form.
  195. function OnParentDockerMessage(type, para) {
  196. }
  197. //////////////////////////////////////////////////////////////////////////
  198. // Utils Functions.
  199. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  200. CW_DeclareVariable("ID",
  201. val => {
  202. ui.pb_fix_id.value = val;
  203. ui.pb_force_id.value = val;
  204. }, () => {});
  205. CW_DeclareVariable("message",
  206. val => {
  207. ui.message.value = val;
  208. }, () => {});
  209. function onDragFile(filepath) {
  210. }
  211. function PUI(cb) {
  212. if(pui){cb();}
  213. }
  214. /*Usage of BLOCK_EVENT
  215. BLOCK_EVENT(()=>{
  216. ui.[name].[var] = ...;
  217. });
  218. */
  219. function BLOCK_EVENT(cb) {
  220. ui.block_event = true;
  221. cb();
  222. ui.block_event = false;
  223. }
  224. //////////////////////////////////////////////////////////////////////////
  225. // template codes for cw callback js.
  226. function CW_DeclareVariable(name, setter, getter) {
  227. if(typeof(__DeclareVariable) === 'function') {
  228. __DeclareVariable(name, setter, getter);
  229. }
  230. }
  231. function CW_DeclareOuterVariable(name) {
  232. if(typeof(__DeclareOuterVariable) === 'function') {
  233. __DeclareOuterVariable(name);
  234. }
  235. }