boundary_force_pane.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. //ui.stack_force.index = 1;
  12. }
  13. //Callback after UI is fully loaded and displayed.
  14. function OnReady(reload, preview) {
  15. PUI(()=>{
  16. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  17. //The 'pui' variable is valid in all functions of this document.
  18. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  19. });
  20. }
  21. function OnCloseForm() {
  22. }
  23. function OnException(err) {
  24. //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
  25. }
  26. //////////////////////////////////////////////////////////////////////////
  27. // Callback Functions.
  28. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  29. function OnModify(idx){
  30. if(idx ===0){
  31. let Load = {
  32. "constraint":"集中载荷压力",
  33. "压力方向xn":ui.pb_xn.value,
  34. "压力方向yn":ui.pb_yn.value,
  35. "压力方向zn":ui.pb_zn.value,
  36. "压力大小xr":ui.pb_xr.value,
  37. "压力大小yr":ui.pb_yr.value,
  38. "压力大小zr":ui.pb_zr.value
  39. };
  40. unit.form.tree.ModifyMConstraint(Load);
  41. }else if(idx === 1){
  42. let Load = {
  43. "constraint":"分布载荷压力",
  44. "压力方向fa_x":ui.fa_x.value,
  45. "压力方向fa_y":ui.fa_y.value,
  46. "压力方向fa_z":ui.fa_z.value,
  47. "压力大小fa_xr":ui.fa_xr.value,
  48. "压力大小fa_yr":ui.fa_yr.value,
  49. "压力大小fa_zr":ui.fa_zr.value,
  50. "框选范围":ui.fa_radius.value
  51. };
  52. unit.form.tree.ModifyMConstraint(Load);
  53. }
  54. }
  55. function OnValueChange2(){
  56. if(ui.fa_x.value === '' || ui.fa_y.value === '' || ui.fa_z.value === '' || ui.fa_xr.value === '' || ui.fa_yr.value === '' || ui.fa_zr.value === '' || parseFloat(ui.fa_radius.value) <= 0){
  57. unit.form.mainfrm.OnChangePicture(3, 3);
  58. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: red;font-size:20px;">非常抱歉,您输入的数据不在范围内</h4>');
  59. unit.form.mainfrm.OnCueline('您输入的数据不在范围内!!!', 'red');
  60. }else{
  61. unit.form.mainfrm.OnChangePicture(3, 1);
  62. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">恭喜您,您输入了正确的数据</h4>');
  63. unit.form.mainfrm.OnCueline('您输入了正确的数据!', 'green');
  64. }
  65. }
  66. function OnChangeValue(){
  67. if(ui.pb_xn.value === '' || ui.pb_yn.value === '' || ui.pb_zn.value === '' || ui.pb_xr.value === '' || ui.pb_yr.value === '' || ui.pb_zr.value === ''){
  68. unit.form.mainfrm.OnChangePicture(3, 3);
  69. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: red;font-size:20px;">非常抱歉,您输入的数据不在范围内</h4>');
  70. unit.form.mainfrm.OnCueline('您输入的数据不在范围内!!!', 'red');
  71. }else{
  72. unit.form.mainfrm.OnChangePicture(3, 1);
  73. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">恭喜您,您输入了正确的数据</h4>');
  74. unit.form.mainfrm.OnCueline('您输入了正确的数据!', 'green');
  75. }
  76. }
  77. function OnReturn(){
  78. unit.form.mainfrm.menu(4);
  79. }
  80. function OnFrameSelect(){
  81. //comx.ply.setArrows();
  82. unit.form.mainfrm.OnSend('frameHightLight ' + ui.fa_x.value + ' ' + ui.fa_y.value + ' ' + ui.fa_z.value + ' ' + ui.fa_xr.value + ' ' + ui.fa_yr.value + ' ' + ui.fa_zr.value + ' ' + + ui.fa_radius.value);
  83. unit.form.mainfrm.OnChangePicture(3, 2);
  84. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">恭喜您,您已将压力数据进行保存,请按鼠标右键选中您要施加约束的物体,并按快捷键R或者r进行添加!</h4>');
  85. let Load = {
  86. "constraint":"分布载荷压力",
  87. "压力方向fa_x":ui.fa_x.value,
  88. "压力方向fa_y":ui.fa_y.value,
  89. "压力方向fa_z":ui.fa_z.value,
  90. "压力大小fa_xr":ui.fa_xr.value,
  91. "压力大小fa_yr":ui.fa_yr.value,
  92. "压力大小fa_zr":ui.fa_zr.value,
  93. "框选范围":ui.fa_radius.value
  94. };
  95. let name = "箭头100";
  96. unit.form.tree.CreateBoundary(Load, name);
  97. unit.form.mainfrm.OnCueline('您已将压力数据进行保存,请按鼠标右键选中您要施加约束的物体,并按快捷键R或者r进行添加!', 'green');
  98. }
  99. function OnArrowFrame(){
  100. }
  101. function OnArrow(){
  102. unit.form.mainfrm.OnSend('arrowHighLight ' + ui.pb_xn.value + ' ' + ui.pb_yn.value + ' ' + ui.pb_zn.value + ' ' + ui.pb_xr.value + ' ' + ui.pb_yr.value + ' ' + ui.pb_zr.value);
  103. unit.form.mainfrm.OnChangePicture(3, 2);
  104. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">恭喜您,您已将压力数据和框选范围进行保存,请按鼠标右键选中您要施加约束的物体,并按快捷键R或者r进行添加以及快捷键U或u者进行框选!</h4>');
  105. let Load = {
  106. "constraint":"集中载荷压力",
  107. "压力方向xn":ui.pb_xn.value,
  108. "压力方向yn":ui.pb_yn.value,
  109. "压力方向zn":ui.pb_zn.value,
  110. "压力大小xr":ui.pb_xr.value,
  111. "压力大小yr":ui.pb_yr.value,
  112. "压力大小zr":ui.pb_zr.value
  113. };
  114. let name = "箭头2";
  115. unit.form.tree.CreateBoundary(Load, name);
  116. unit.form.mainfrm.OnCueline('您已将压力数据和框选范围进行保存,请按鼠标右键选中您要施加约束的物体,并按快捷键R或者r进行添加以及快捷键U或u者进行框选!', 'green');
  117. }
  118. function OnChangeForce(idx){
  119. ui.stack_force.index = parseInt(idx);
  120. }
  121. //The message corresponding callback executed by the docker pane.
  122. // when calling [side_pane].fireEvent(type,para) in the main form.
  123. function OnParentDockerMessage(type, para) {
  124. }
  125. //////////////////////////////////////////////////////////////////////////
  126. // Utils Functions.
  127. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  128. function onDragFile(filepath) {
  129. }
  130. function PUI(cb) {
  131. if(pui){cb();}
  132. }
  133. /*Usage of BLOCK_EVENT
  134. BLOCK_EVENT(()=>{
  135. ui.[name].[var] = ...;
  136. });
  137. */
  138. CW_DeclareVariable("index",
  139. val => {
  140. ui.stack_force.index = val;
  141. }, () => {});
  142. CW_DeclareVariable("setConstraint0",
  143. val => {
  144. ui.pb_xn.value = val["压力方向xn"];
  145. ui.pb_yn.value = val["压力方向yn"];
  146. ui.pb_zn.value = val["压力方向zn"];
  147. ui.pb_xr.value = val["压力大小xr"];
  148. ui.pb_yr.value = val["压力大小yr"];
  149. ui.pb_zr.value = val["压力大小zr"];
  150. }, () => {});
  151. CW_DeclareVariable("setConstraint1",
  152. val => {
  153. ui.fa_x.value = val["压力方向fa_x"];
  154. ui.fa_y.value = val["压力方向fa_y"];
  155. ui.fa_z.value = val["压力方向fa_z"];
  156. ui.fa_xr.value = val["压力大小fa_xr"];
  157. ui.fa_yr.value = val["压力大小fa_yr"];
  158. ui.fa_zr.value = val["压力大小fa_zr"];
  159. ui.fa_radius.value = val["框选范围"];
  160. }, () => {});
  161. function BLOCK_EVENT(cb) {
  162. ui.block_event = true;
  163. cb();
  164. ui.block_event = false;
  165. }
  166. //////////////////////////////////////////////////////////////////////////
  167. // template codes for cw callback js.
  168. function CW_DeclareVariable(name, setter, getter) {
  169. if(typeof(__DeclareVariable) === 'function') {
  170. __DeclareVariable(name, setter, getter);
  171. }
  172. }
  173. function CW_DeclareOuterVariable(name) {
  174. if(typeof(__DeclareOuterVariable) === 'function') {
  175. __DeclareOuterVariable(name);
  176. }
  177. }