result_ZhenDong_pane.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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 OnReturnMenu(){
  29. unit.form.mainfrm.menu(8);
  30. }
  31. function OnEnd(){
  32. unit.form.mainfrm.OnSend('endModel');
  33. }
  34. function OnPlay(){
  35. unit.form.mainfrm.OnSend('playModel ' + model.getCurrentDirectory());
  36. }
  37. function getChart1(val) {
  38. const xvalue = [];
  39. const yvalue = [];
  40. val.forEach((value, index) => {
  41. const cubeRoot = Math.sqrt(parseFloat(value)) / (2 * 3.1415926);
  42. //res.push([index + 1, value, cubeRoot]);
  43. xvalue.push(`第${index + 1}阶`);
  44. yvalue.push(cubeRoot);
  45. // 在这里可以执行其他操作
  46. });
  47. return {
  48. xAxis: {
  49. type: 'category',
  50. //data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  51. data: xvalue
  52. },
  53. yAxis: {
  54. type: 'value'
  55. },
  56. series: [
  57. {
  58. //data: [150, 230, 224, 218, 135, 147, 260],
  59. data: yvalue,
  60. type: 'line'
  61. }
  62. ]
  63. };
  64. }
  65. async function OnLoad(val){
  66. model.updateLineChart(getChart1(val));
  67. }
  68. function OnNextModel(){
  69. if(parseInt(ui.frame2.value) === parseInt(ui.frame1.value)){
  70. ui.frame2.value = 1;
  71. }else{
  72. ui.frame2.value = parseInt(ui.frame2.value) + 1;
  73. }
  74. //ui.list.color[0/*row*/, parseInt(ui.frame2.value)/*column*/, "#FF0000"]; //设置cell颜色
  75. unit.form.mainfrm.OnRendererMoTi(parseInt(ui.frame2.value) - 1, ui.pb_size.value);
  76. unit.form.mainfrm.OnPostBar(1, 1);
  77. unit.form.mainfrm.OnChangePicture(5, 2);
  78. unit.form.mainfrm.OnCueline(`当前阶数为${ui.frame2.value}`, 'green');
  79. }
  80. function OnLastModel(){
  81. if(parseInt(ui.frame2.value) === 1){
  82. ui.frame2.value = parseInt(ui.frame1.value);
  83. }else{
  84. ui.frame2.value = parseInt(ui.frame2.value) - 1;
  85. }
  86. unit.form.mainfrm.OnRendererMoTi(parseInt(ui.frame2.value) - 1, ui.pb_size.value);
  87. unit.form.mainfrm.OnPostBar(1, 1);
  88. unit.form.mainfrm.OnChangePicture(5, 2);
  89. unit.form.mainfrm.OnCueline(`当前阶数为${ui.frame2.value}`, 'green');
  90. }
  91. function OnAnsys(){
  92. unit.form.mainfrm.OnClear();
  93. var res = unit.form.mainfrm.OnLoad2();
  94. ui.frame1.value = res;
  95. if(res){
  96. unit.form.mainfrm.OnRendererMoTi(1, ui.pb_size.value);
  97. unit.form.mainfrm.OnPostBar(1, 1);
  98. ui.frame2.value = 2;
  99. }
  100. unit.form.mainfrm.OnChangePicture(5, 2);
  101. unit.form.mainfrm.OnCueline('自由振动结果加载成功!', 'green');
  102. /*
  103. model.readMoTi(model.getCurrentDirectory() + 'data/modelAnsys/eigenvalues.txt', cb => {
  104. var res = [["阶数", "特征值", "频率"]];
  105. cb.forEach((value, index) => {
  106. const cubeRoot = Math.sqrt(parseFloat(value)) / (2 * 3.1415926);
  107. res.push([index + 1, value, cubeRoot]);
  108. // 在这里可以执行其他操作
  109. });
  110. //console.log('Resulting Array:', res);
  111. ui.list.table = res;
  112. ui.list.head_size = [0, 0, 0];
  113. OnLoad(cb);
  114. });
  115. unit.form.mainfrm.isEnablePost(false);
  116. unit.form.mainfrm.OnChangePicture(5, 2);
  117. unit.form.mainfrm.OnCueline('模态分析结果加载成功!', 'green');*/
  118. }
  119. //The message corresponding callback executed by the docker pane.
  120. // when calling [side_pane].fireEvent(type,para) in the main form.
  121. function OnParentDockerMessage(type, para) {
  122. }
  123. //////////////////////////////////////////////////////////////////////////
  124. // Utils Functions.
  125. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  126. function onDragFile(filepath) {
  127. }
  128. function PUI(cb) {
  129. if(pui){cb();}
  130. }
  131. /*Usage of BLOCK_EVENT
  132. BLOCK_EVENT(()=>{
  133. ui.[name].[var] = ...;
  134. });
  135. */
  136. function BLOCK_EVENT(cb) {
  137. ui.block_event = true;
  138. cb();
  139. ui.block_event = false;
  140. }
  141. //////////////////////////////////////////////////////////////////////////
  142. // template codes for cw callback js.
  143. function CW_DeclareVariable(name, setter, getter) {
  144. if(typeof(__DeclareVariable) === 'function') {
  145. __DeclareVariable(name, setter, getter);
  146. }
  147. }
  148. function CW_DeclareOuterVariable(name) {
  149. if(typeof(__DeclareOuterVariable) === 'function') {
  150. __DeclareOuterVariable(name);
  151. }
  152. }