boundary_constraint_pane.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  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_constraint.index = 1;
  12. // ui.stack_menu.index = 2;
  13. //control(true);
  14. //controls(true);
  15. //ui.stack_constraint.index = 2;
  16. //ui.stack_menu.index = 2;
  17. }
  18. //Callback after UI is fully loaded and displayed.
  19. function OnReady(reload, preview) {
  20. PUI(()=>{
  21. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  22. //The 'pui' variable is valid in all functions of this document.
  23. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  24. });
  25. }
  26. function OnCloseForm() {
  27. }
  28. function OnException(err) {
  29. //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
  30. }
  31. //////////////////////////////////////////////////////////////////////////
  32. // Callback Functions.
  33. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  34. /*
  35. function OnGetFaceName(){
  36. const str = unit.form.mainfrm.OnGetFaceName();
  37. // 匹配type对应内容的正则表达式,以type:开头,后面跟着非冒号的内容直到遇到空格或者字符串结束
  38. const typeRegex = /type:([^point]+)/;
  39. // 匹配center坐标对应内容的正则表达式
  40. const centerRegex = /point:([\d. ]+)/;
  41. const typeMatch = str.match(typeRegex);
  42. const typeInfo = typeMatch? typeMatch[1] : null;
  43. const centerMatch = str.match(centerRegex);
  44. const centerCoords = centerMatch? centerMatch[1].split(' ').map(x => x.trim()) : null;
  45. ui.type.value = typeInfo;
  46. ui.xc.value = centerCoords[0];
  47. ui.yc.value = centerCoords[1];
  48. ui.zc.value = centerCoords[2];
  49. }*/
  50. function OnGetFaceName(){
  51. const str = unit.form.mainfrm.OnGetFaceName();
  52. console.log(str);
  53. // 匹配type对应内容的正则表达式,以type:开头,后面跟着非冒号的内容直到遇到空格或者字符串结束
  54. const typeRegex = /type:([^point]+)/;
  55. // 匹配center坐标对应内容的正则表达式
  56. //const centerRegex = /point:([\d. ]+)/;
  57. const typeMatch = str.match(typeRegex);
  58. const typeInfo = typeMatch? typeMatch[1] : null;
  59. //const centerMatch = str.match(centerRegex);
  60. //const centerCoords = centerMatch? centerMatch[1].split(' ').map(x => x.trim()) : null;
  61. const match = str.match(/point:([-\d.]+)\s+([-\d.]+)\s+([-\d.]+)/);
  62. const centerCoords = match.slice(1, 4);
  63. ui.type.value = typeInfo;
  64. ui.xc.value = centerCoords[0];
  65. ui.yc.value = centerCoords[1];
  66. ui.zc.value = centerCoords[2];
  67. }
  68. function OnCPointAddEnd(){
  69. const str = unit.form.mainfrm.OnGetName();
  70. // 匹配center坐标对应内容的正则表达式
  71. const centerRegex = /center:([\d. ]+)/;
  72. const typeInfo = str.split(' ').slice(1, 4).join(' ');
  73. const centerMatch = str.match(centerRegex);
  74. const centerCoords = centerMatch? centerMatch[1].split(' ').map(x => x.trim()) : null;
  75. ui.ctpyee.value = typeInfo;
  76. ui.cxe.value = centerCoords[0];
  77. ui.cye.value = centerCoords[1];
  78. ui.cze.value = centerCoords[2];
  79. }
  80. function OnCPointAddStart(){
  81. const str = unit.form.mainfrm.OnGetName();
  82. // 匹配center坐标对应内容的正则表达式
  83. const centerRegex = /center:([\d. ]+)/;
  84. const typeInfo = str.split(' ').slice(1, 4).join(' ');
  85. const centerMatch = str.match(centerRegex);
  86. const centerCoords = centerMatch? centerMatch[1].split(' ').map(x => x.trim()) : null;
  87. ui.ctypes.value = typeInfo;
  88. ui.cxs.value = centerCoords[0];
  89. ui.cys.value = centerCoords[1];
  90. ui.czs.value = centerCoords[2];
  91. }
  92. function OnSPointAddEnd(){
  93. const str = unit.form.mainfrm.OnGetName();
  94. // 匹配center坐标对应内容的正则表达式
  95. const centerRegex = /center:([\d. ]+)/;
  96. const typeInfo = str.split(' ').slice(1, 4).join(' ');
  97. const centerMatch = str.match(centerRegex);
  98. const centerCoords = centerMatch? centerMatch[1].split(' ').map(x => x.trim()) : null;
  99. ui.stypee.value = typeInfo;
  100. ui.sxe.value = centerCoords[0];
  101. ui.sye.value = centerCoords[1];
  102. ui.sze.value = centerCoords[2];
  103. }
  104. function OnSPointAddStart(){
  105. const str = unit.form.mainfrm.OnGetName();
  106. // 匹配center坐标对应内容的正则表达式
  107. const centerRegex = /center:([\d. ]+)/;
  108. const typeInfo = str.split(' ').slice(1, 4).join(' ');
  109. const centerMatch = str.match(centerRegex);
  110. const centerCoords = centerMatch? centerMatch[1].split(' ').map(x => x.trim()) : null;
  111. ui.stypes.value = typeInfo;
  112. ui.sxs.value = centerCoords[0];
  113. ui.sys.value = centerCoords[1];
  114. ui.szs.value = centerCoords[2];
  115. }
  116. function OnGetName(){
  117. const str = unit.form.mainfrm.OnGetName();
  118. console.log(str);
  119. // 匹配center坐标对应内容的正则表达式
  120. const centerRegex = /center:([\d. ]+)/;
  121. const typeInfo = str.split(' ').slice(1, 4).join(' ');
  122. const centerMatch = str.match(centerRegex);
  123. const centerCoords = centerMatch? centerMatch[1].split(' ').map(x => x.trim()) : null;
  124. ui.type.value = typeInfo;
  125. ui.xc.value = centerCoords[0];
  126. ui.yc.value = centerCoords[1];
  127. ui.zc.value = centerCoords[2];
  128. }
  129. //修改约束
  130. function OnModify(){
  131. if(ui.limit_constraint.index === 0 && ui.constraint_type.index === 0) {
  132. let name = model.acax_app.model.constrain.Get(model.acax_app.model.constrain.Current()).unique;
  133. unit.form.mainfrm.OnModifyConstrains(ui.xc.value, ui.yc.value, ui.zc.value, name);
  134. let color = model.acax_app.model.constrain.Get(model.acax_app.model.constrain.Current()).color;
  135. let Load = {
  136. "constraint":"固定支撑",
  137. "约束类型":ui.constraint_type.value,
  138. "type":ui.type.value,
  139. "xc":ui.xc.value,
  140. "yc":ui.yc.value,
  141. "zc":ui.zc.value,
  142. "固定支撑属性xd":ui.con_xn.value,
  143. "固定支撑属性xr":ui.con_xr.value,
  144. "固定支撑属性yd":ui.con_yn.value,
  145. "固定支撑属性yr":ui.con_yr.value,
  146. "固定支撑属性zd":ui.con_zn.value,
  147. "固定支撑属性zr":ui.con_zr.value,
  148. "cons_type":"constraints",
  149. "color":color,
  150. "unique":name
  151. };
  152. unit.form.tree.ModifyConstraint(Load);
  153. unit.form.mainfrm.OnCueline('修改成功', 'green');
  154. }
  155. if(ui.limit_constraint.index ===1 && ui.misConstraints.index === 0 ) {
  156. let name = model.acax_app.model.constrain.Get(model.acax_app.model.constrain.Current()).unique;
  157. unit.form.mainfrm.OnModifyBeams(ui.pb_size.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, ui.R.value, ui.G.value, ui.B.value, ui.pb_node_size.value, name);
  158. let color = model.acax_app.model.constrain.Get(model.acax_app.model.constrain.Current()).color;
  159. let Load = {
  160. "constraint":"梁",
  161. "非约束类型":ui.misConstraints.value,
  162. "梁约束位置xDirection":ui.pb_xDiration.value,
  163. "梁约束位置yDirection":ui.pb_yDiration.value,
  164. "梁约束位置zDirection":ui.pb_zDiration.value,
  165. "梁约束位置xCoord":ui.pb_xCoord.value,
  166. "梁约束位置yCoord":ui.pb_yCoord.value,
  167. "梁约束位置zCoord":ui.pb_zCoord.value,
  168. "梁约束参数半径":ui.rad.value,
  169. "梁约束参数长度":ui.pb_length.value,
  170. "梁约束参数个数":ui.pb_size.value,
  171. "弹性模量":ui.m.value,
  172. "泊松比":ui.poi.value,
  173. "梁节点大小半径":ui.pb_node_size.value,
  174. "R":ui.R.value,
  175. "G":ui.G.value,
  176. "B":ui.B.value,
  177. "cons_type":"beams",
  178. "color":color,
  179. "unique":name
  180. };
  181. unit.form.tree.ModifyConstraint(Load);
  182. unit.form.mainfrm.OnCueline('修改成功', 'green');
  183. }
  184. if(ui.limit_constraint.index ===1 && ui.misConstraints.index === 1 ) {
  185. let name = model.acax_app.model.constrain.Get(model.acax_app.model.constrain.Current()).unique;
  186. unit.form.mainfrm.OnModifySpring(ui.sxs.value, ui.sys.value, ui.szs.value, ui.sxe.value, ui.sye.value, ui.sze.value, ui.sr.value, ui.sg.value, ui.sb.value, name);
  187. let color = model.acax_app.model.constrain.Get(model.acax_app.model.constrain.Current()).color;
  188. let Load = {
  189. "constraint":"弹簧",
  190. "非约束类型":ui.misConstraints.value,
  191. "弹簧坐标x":ui.sxs.value,
  192. "弹簧坐标y":ui.sys.value,
  193. "弹簧坐标z":ui.szs.value,
  194. "stypes":ui.stypes.value,
  195. "弹簧终点x":ui.sxe.value,
  196. "弹簧终点y":ui.sye.value,
  197. "弹簧终点z":ui.sze.value,
  198. "stypee":ui.stypee.value,
  199. "stiffness_x":ui.sstifx.value,
  200. "stiffness_y":ui.sstify.value,
  201. "stiffness_z":ui.sstifz.value,
  202. "R":ui.sr.value,
  203. "G":ui.sg.value,
  204. "B":ui.sb.value,
  205. "cons_type":"spring",
  206. "color":color,
  207. "unique":name
  208. };
  209. unit.form.tree.ModifyConstraint(Load);
  210. unit.form.mainfrm.OnCueline('修改成功', 'green');
  211. }
  212. if(ui.limit_constraint.index ===1 && ui.misConstraints.index === 2 ) {
  213. let name = model.acax_app.model.constrain.Get(model.acax_app.model.constrain.Current()).unique;
  214. unit.form.mainfrm.OnModifyConnects(ui.cxs.value, ui.cys.value, ui.czs.value, ui.cxe.value, ui.cye.value, ui.cze.value, ui.cr.value, ui.cg.value, ui.cb.value, name);
  215. let color = model.acax_app.model.constrain.Get(model.acax_app.model.constrain.Current()).color;
  216. let Load = {
  217. "constraint":"连接",
  218. "非约束类型":ui.misConstraints.value,
  219. "弹簧坐标x":ui.cxs.value,
  220. "弹簧坐标y":ui.cys.value,
  221. "弹簧坐标z":ui.czs.value,
  222. "ctypes":ui.ctypes.value,
  223. "弹簧终点x":ui.cxe.value,
  224. "弹簧终点y":ui.cye.value,
  225. "弹簧终点z":ui.cze.value,
  226. "ctpyee":ui.ctpyee.value,
  227. "弹簧材料xn":ui.cxn.value,
  228. "弹簧材料yn":ui.cyn.value,
  229. "弹簧材料zn":ui.czn.value,
  230. "弹簧材料xr":ui.cxr.value,
  231. "弹簧材料yr":ui.cyr.value,
  232. "弹簧材料zr":ui.czr.value,
  233. "R":ui.cr.value,
  234. "G":ui.cg.value,
  235. "B":ui.cb.value,
  236. "cons_type":"connect",
  237. "color":color,
  238. "unique":name
  239. };
  240. unit.form.tree.ModifyConstraint(Load);
  241. unit.form.mainfrm.OnCueline('修改成功', 'green');
  242. }
  243. }
  244. function OnChangeBeam(){
  245. if(parseFloat(ui.pb_length.value) <= 0 || parseFloat(ui.rad.value) <= 0 || parseFloat(ui.m.value) <= 0 || parseFloat(ui.poi.value) <= 0 || parseFloat(ui.rad.value) <= 0){
  246. unit.form.mainfrm.OnChangePicture(3, 3);
  247. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: red;font-size:20px;">非常抱歉,您输入的数据不在参数范围内!</h4>');
  248. unit.form.mainfrm.OnCueline('您输入的数据不在参数范围内!', 'red');
  249. }else{
  250. unit.form.mainfrm.OnChangePicture(3, 2);
  251. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: Blue;font-size:20px;">恭喜您,您输入了正确的数据!</h4>');
  252. unit.form.mainfrm.OnCueline('您输入了正确的数据!', 'blue');
  253. }
  254. }
  255. function OnFix(){
  256. let temp = unit.form.tree.GetCurUniqueName();
  257. let name = temp;
  258. let constrain_data = model.acax_app.model.constrain.Database();
  259. //console.log(workcondition_data);
  260. let i = 0;
  261. let j = 0;
  262. let constrain_arr = Object.keys(constrain_data.db);
  263. //console.log(constrain_data.db);
  264. name = name + "fix0";
  265. while(1){
  266. for( i = 0;i < constrain_arr.length;++i) {
  267. if(constrain_data.db[constrain_arr[i]].unique === name) {
  268. ++j;
  269. name = temp + "fix" + j;
  270. break;
  271. }
  272. }
  273. if(i === constrain_arr.length) {
  274. break;
  275. }
  276. }
  277. let name1 = unit.form.mainfrm.OnConstrains(ui.xc.value, ui.yc.value, ui.zc.value, name);
  278. name1 = name1.replace(temp, "");
  279. unit.form.mainfrm.OnChangePicture(3, 2);
  280. let color = unit.form.tree.getRandomHexColor();
  281. let Load = {
  282. "constraint":"固定支撑",
  283. "约束类型":ui.constraint_type.value,
  284. "type":ui.type.value,
  285. "xc":ui.xc.value,
  286. "yc":ui.yc.value,
  287. "zc":ui.zc.value,
  288. "固定支撑属性xd":ui.con_xn.value,
  289. "固定支撑属性xr":ui.con_xr.value,
  290. "固定支撑属性yd":ui.con_yn.value,
  291. "固定支撑属性yr":ui.con_yr.value,
  292. "固定支撑属性zd":ui.con_zn.value,
  293. "固定支撑属性zr":ui.con_zr.value,
  294. "cons_type":"constraints",
  295. "color":color,
  296. "unique":name
  297. };
  298. // console.log(name1);
  299. if(ui.type.value === '--') {
  300. unit.form.mainfrm.OnCueline('未添加中心坐标', 'green');
  301. }else{
  302. unit.form.tree.CreateBoundary(Load, name1);
  303. unit.form.mainfrm.OnCueline('您完成了固定支撑属性的添加,请用鼠标右键选中需要施加约束的物体并按快捷键T或者t进行添加!', 'green');
  304. }
  305. }
  306. function OnBeam2(){
  307. unit.form.mainfrm.OnSend('beamHightLight2 ' + ui.m_seg.value + ' ' + ui.m_len.value + ' ' + ui.m_radius.value + ' ' + ui.m_mat.value + ' ' + ui.m_poi.value + ' ' + ui.m_R.value + ' '+ ui.m_G.value + ' ' + ui.m_B.value + ' ' + ui.m_ras.value);
  308. model.clearStr();
  309. unit.form.mainfrm.OnChangePicture(3, 2);
  310. unit.form.mainfrm.OnCueline('您成功做好了不均匀梁的添加!', 'green');
  311. }
  312. function OnConnect(){
  313. let temp = unit.form.tree.GetCurUniqueName();
  314. let name = temp;
  315. let constrain_data = model.acax_app.model.constrain.Database();
  316. let i = 0;
  317. let j = 0;
  318. let constrain_arr = Object.keys(constrain_data.db);
  319. name = name + "con0";
  320. while(1){
  321. for( i = 0;i < constrain_arr.length;++i) {
  322. if(constrain_data.db[constrain_arr[i]].unique === name) {
  323. ++j;
  324. name = temp + "con" + j;
  325. break;
  326. }
  327. }
  328. if(i === constrain_arr.length) {
  329. break;
  330. }
  331. }
  332. let name1 = unit.form.mainfrm.OnConnects(ui.cxs.value, ui.cys.value, ui.czs.value, ui.cxe.value, ui.cye.value, ui.cze.value, ui.cr.value, ui.cg.value, ui.cb.value, name);
  333. name1 = name1.replace(temp, "");
  334. //console.log(name1);
  335. unit.form.mainfrm.OnChangePicture(3, 2);
  336. let color = unit.form.tree.getRandomHexColor();
  337. let Load = {
  338. "constraint":"连接",
  339. "非约束类型":ui.misConstraints.value,
  340. "弹簧坐标x":ui.cxs.value,
  341. "弹簧坐标y":ui.cys.value,
  342. "弹簧坐标z":ui.czs.value,
  343. "ctypes":ui.ctypes.value,
  344. "弹簧终点x":ui.cxe.value,
  345. "弹簧终点y":ui.cye.value,
  346. "弹簧终点z":ui.cze.value,
  347. "ctpyee":ui.ctpyee.value,
  348. "弹簧材料xn":ui.cxn.value,
  349. "弹簧材料yn":ui.cyn.value,
  350. "弹簧材料zn":ui.czn.value,
  351. "弹簧材料xr":ui.cxr.value,
  352. "弹簧材料yr":ui.cyr.value,
  353. "弹簧材料zr":ui.czr.value,
  354. "R":ui.cr.value,
  355. "G":ui.cg.value,
  356. "B":ui.cb.value,
  357. "cons_type":"connect",
  358. "color":color,
  359. "unique":name
  360. };
  361. //console.log(name1);
  362. if(ui.ctypes.value === '--' || ui.ctpyee.value === '--') {
  363. unit.form.mainfrm.OnCueline('未添加弹簧坐标', 'red');
  364. }else{
  365. unit.form.tree.CreateBoundary(Load, name1);
  366. unit.form.mainfrm.OnCueline('您成功地做好了连接!', 'green');
  367. }
  368. }
  369. function onEndMessage(){
  370. controls(false);
  371. }
  372. function onStartMessage(){
  373. controls(true);
  374. }
  375. function controls(idx){
  376. ui.pb_start_message.enable = !idx;
  377. ui.pb_start_mes.enable = !idx;
  378. ui.pb_start_x.enable = idx;
  379. ui.pb_start_y.enable = idx;
  380. ui.pb_start_z.enable = idx;
  381. ui.pb_end_message.enable = idx;
  382. ui.pb_end_mes.enable = idx;
  383. ui.pb_end_x.enable = !idx;
  384. ui.pb_end_y.enable = !idx;
  385. ui.pb_end_z.enable = !idx;
  386. if(idx === true){
  387. model.setStartEnd(0);
  388. }
  389. if(idx === false){
  390. model.setStartEnd(1);
  391. }
  392. }
  393. function OnChangeValue(){
  394. ui.pb_pass.enable = false;
  395. }
  396. function OnReturn(){
  397. unit.form.mainfrm.menu(4);
  398. }
  399. function OnFile(){
  400. ui.pb_pass.enable = true;
  401. model.setCon(1);
  402. if(ui.stack_menu.index === 0){
  403. let id = parent.setTimeout(() => {
  404. unit.form.mainfrm.OnSend('0');
  405. }, 100);
  406. unit.form.mainfrm.OnSend('beamSave ' + model.getCurrentDirectory());
  407. }
  408. if(ui.stack_menu.index === 1){
  409. let id = parent.setTimeout(() => {
  410. unit.form.mainfrm.OnSend('0');
  411. }, 100);
  412. unit.form.mainfrm.OnSend('springSave ' + model.getCurrentDirectory());
  413. }
  414. }
  415. function OnSpring(){
  416. let temp = unit.form.tree.GetCurUniqueName();
  417. let name = temp;
  418. let constrain_data = model.acax_app.model.constrain.Database();
  419. //console.log(workcondition_data);
  420. let i = 0;
  421. let j = 0;
  422. let constrain_arr = Object.keys(constrain_data.db);
  423. //console.log(constrain_data.db);
  424. name = name + "spring0";
  425. while(1){
  426. for( i = 0;i < constrain_arr.length;++i) {
  427. if(constrain_data.db[constrain_arr[i]].unique === name) {
  428. ++j;
  429. name = temp + "spring" + j;
  430. break;
  431. }
  432. }
  433. if(i === constrain_arr.length) {
  434. break;
  435. }
  436. }
  437. let name1 = unit.form.mainfrm.OnSpring(ui.sxs.value, ui.sys.value, ui.szs.value, ui.sxe.value, ui.sye.value, ui.sze.value, ui.sr.value, ui.sg.value, ui.sb.value, name);
  438. name1 = name1.replace(temp, "");
  439. unit.form.mainfrm.OnChangePicture(3, 2);
  440. let color = unit.form.tree.getRandomHexColor();
  441. let Load = {
  442. "constraint":"弹簧",
  443. "非约束类型":ui.misConstraints.value,
  444. "弹簧坐标x":ui.sxs.value,
  445. "弹簧坐标y":ui.sys.value,
  446. "弹簧坐标z":ui.szs.value,
  447. "stypes":ui.stypes.value,
  448. "弹簧终点x":ui.sxe.value,
  449. "弹簧终点y":ui.sye.value,
  450. "弹簧终点z":ui.sze.value,
  451. "stypee":ui.stypee.value,
  452. "stiffness_x":ui.sstifx.value,
  453. "stiffness_y":ui.sstify.value,
  454. "stiffness_z":ui.sstifz.value,
  455. "R":ui.sr.value,
  456. "G":ui.sg.value,
  457. "B":ui.sb.value,
  458. "cons_type":"spring",
  459. "color":color,
  460. "unique":name
  461. };
  462. //console.log(name1);
  463. if(ui.stypes.value === '--' || ui.stypee.value === '--') {
  464. unit.form.mainfrm.OnCueline('未添加弹簧坐标', 'green');
  465. }else{
  466. unit.form.tree.CreateBoundary(Load, name1);
  467. unit.form.mainfrm.OnCueline('您完成了弹簧约束的添加!', 'green');
  468. }
  469. }
  470. function OnBeam(){
  471. let temp = unit.form.tree.GetCurUniqueName();
  472. let name = temp;
  473. let constrain_data = model.acax_app.model.constrain.Database();
  474. //console.log(workcondition_data);
  475. let i = 0;
  476. let j = 0;
  477. let constrain_arr = Object.keys(constrain_data.db);
  478. //console.log(constrain_data.db);
  479. name = name + "beam0";
  480. while(1){
  481. for( i = 0;i < constrain_arr.length;++i) {
  482. if(constrain_data.db[constrain_arr[i]].unique.split(" ")[0] === name) {
  483. ++j;
  484. name = temp + "beam" + j;
  485. break;
  486. }
  487. }
  488. if(i === constrain_arr.length) {
  489. break;
  490. }
  491. }
  492. name = name + " B 0";
  493. const str =unit.form.mainfrm.OnBeams(ui.pb_size.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, ui.R.value, ui.G.value, ui.B.value, ui.pb_node_size.value, name);
  494. let name1 = str.split(' ')[0].split(':')[1];
  495. name1 = name1.replace(temp, "");
  496. const centerRegex = /centers:([\d. ]+)/;
  497. const centerMatch = str.match(centerRegex);
  498. const centerCoords = centerMatch? centerMatch[1].split(' ').map(x => x.trim()) : null;
  499. let color = unit.form.tree.getRandomHexColor();
  500. unit.form.mainfrm.OnChangePicture(3, 2);
  501. let Load = {
  502. "constraint":"梁",
  503. "非约束类型":ui.misConstraints.value,
  504. "梁约束位置xDirection":ui.pb_xDiration.value,
  505. "梁约束位置yDirection":ui.pb_yDiration.value,
  506. "梁约束位置zDirection":ui.pb_zDiration.value,
  507. "梁约束位置xCoord":ui.pb_xCoord.value,
  508. "梁约束位置yCoord":ui.pb_yCoord.value,
  509. "梁约束位置zCoord":ui.pb_zCoord.value,
  510. "梁约束参数半径":ui.rad.value,
  511. "梁约束参数长度":ui.pb_length.value,
  512. "梁约束参数个数":ui.pb_size.value,
  513. "弹性模量":ui.m.value,
  514. "泊松比":ui.poi.value,
  515. "梁节点大小半径":ui.pb_node_size.value,
  516. "R":ui.R.value,
  517. "G":ui.G.value,
  518. "B":ui.B.value,
  519. "point":centerCoords,
  520. "cons_type":"beams",
  521. "color":color,
  522. "unique":name
  523. };
  524. //console.log(name1);
  525. unit.form.tree.CreateBoundary(Load, name1);
  526. unit.form.mainfrm.OnCueline('您完成了梁约束的添加!', 'green');
  527. }
  528. function control(idx){
  529. ui.pb_start.enable = !idx;
  530. ui.pb_x.enable = idx;
  531. ui.pb_y.enable = idx;
  532. ui.pb_z.enable = idx;
  533. ui.pb_end.enable = idx;
  534. ui.pb_X.enable = !idx;
  535. ui.pb_Y.enable = !idx;
  536. ui.pb_Z.enable = !idx;
  537. if(idx === true){
  538. model.setStartEnd(0);
  539. }
  540. if(idx === false){
  541. model.setStartEnd(1);
  542. }
  543. }
  544. function OnEed(){
  545. control(false);
  546. }
  547. function OnStart(){
  548. control(true);
  549. }
  550. function OnChangeMenu(){
  551. ui.stack_menu.index = parseFloat(ui.misConstraints.index);
  552. // console.log(ui.no_limit_constraint.index === 1);
  553. //console.log(ui.limit_constraint.index);
  554. if(ui.stack_menu.index === 3){
  555. model.setBeam(true);
  556. }else{
  557. model.setBeam(false);
  558. }
  559. }
  560. function OnChangeConstraint(){
  561. ui.stack_constraint.index = ui.limit_constraint.index;
  562. if(parseFloat(idx) === 1){
  563. unit.form.mainfrm.OnChangePicture(3, 1);
  564. unit.form.mainfrm.OnCueline('注意事项:弹簧单元的起点和终点需要自动添加,鼠标右键选中起始/终止点,点击按钮(在窗口左侧倒数第3个按钮)添加即可将坐标导入!', 'blue');
  565. }else if(parseFloat(idx) === 2){
  566. unit.form.mainfrm.OnChangePicture(3, 1);
  567. unit.form.mainfrm.OnCueline('注意事项:连接单元的起点和终点需要自动添加,鼠标右键选中起始/终止点,点击按钮(在窗口左侧倒数第3个按钮)添加即可将坐标导入!', 'blue');
  568. }else if(parseFloat(idx) === 3){
  569. unit.form.mainfrm.OnChangePicture(3, 1);
  570. unit.form.mainfrm.OnCueline('注意事项:非均匀梁的各个节点需要用鼠标右键拾取后点击H或h进行保存,梁上的各个点需要在一条直线上!', 'blue');
  571. }
  572. }
  573. function ChangeRadiobutton(idx) {
  574. ui.limit_constraint.index = parseInt(idx);
  575. }
  576. //The message corresponding callback executed by the docker pane.
  577. // when calling [side_pane].fireEvent(type,para) in the main form.
  578. function OnParentDockerMessage(type, para) {
  579. }
  580. //////////////////////////////////////////////////////////////////////////
  581. // Utils Functions.
  582. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  583. CW_DeclareVariable("idx",
  584. val => {
  585. ui.limit_constraint.index = val;
  586. }, () => {});
  587. CW_DeclareVariable("pb_x",
  588. val => {
  589. ui.pb_x.value = val;
  590. ui.pb_start_x.value = val;
  591. }, () => {});
  592. CW_DeclareVariable("pb_y",
  593. val => {
  594. ui.pb_y.value = val;
  595. ui.pb_start_y.value = val;
  596. }, () => {});
  597. CW_DeclareVariable("pb_z",
  598. val => {
  599. ui.pb_z.value = val;
  600. ui.pb_start_z.value = val;
  601. }, () => {});
  602. CW_DeclareVariable("pb_X",
  603. val => {
  604. ui.pb_X.value = val;
  605. ui.pb_end_x.value = val;
  606. }, () => {});
  607. CW_DeclareVariable("pb_Y",
  608. val => {
  609. ui.pb_Y.value = val;
  610. ui.pb_end_y.value = val;
  611. }, () => {});
  612. CW_DeclareVariable("pb_Z",
  613. val => {
  614. ui.pb_Z.value = val;
  615. ui.pb_end_z.value = val;
  616. }, () => {});
  617. CW_DeclareVariable("listbox",
  618. val => {
  619. ui.listbox.list = [
  620. val
  621. ];
  622. }, () => {});
  623. CW_DeclareVariable("start_mes",
  624. val => {
  625. ui.pb_type1.value = val;
  626. ui.pb_start_mes.value = val;
  627. }, () => {});
  628. CW_DeclareVariable("end_mes",
  629. val => {
  630. ui.pb_type2.value = val;
  631. ui.pb_end_mes.value = val;
  632. }, () => {});
  633. CW_DeclareVariable("change1",
  634. val => {
  635. ui.stack_constraint.index = val;
  636. }, () => {});
  637. CW_DeclareVariable("change2",
  638. val => {
  639. ui.stack_menu.index = val;
  640. ui.misConstraints.index = val;
  641. }, () => {});
  642. //固定支撑
  643. CW_DeclareVariable("setConstraint0",
  644. val => {
  645. ui.type.value = val.type;
  646. ui.xc.value=val.xc;
  647. ui.yc.value=val.yc;
  648. ui.zc.value=val.zc;
  649. ui.con_xn.value = val["固定支撑属性xd"];
  650. ui.con_xr.value = val["固定支撑属性xr"];
  651. ui.con_yn.value = val["固定支撑属性yd"];
  652. ui.con_yr.value = val["固定支撑属性yr"];
  653. ui.con_zn.value = val["固定支撑属性zd"];
  654. ui.con_zr.value = val["固定支撑属性zr"];
  655. }, () => {});
  656. //梁
  657. CW_DeclareVariable("setConstraint1",
  658. val => {
  659. ui.pb_xDiration.value = val["梁约束位置xDirection"];
  660. ui.pb_yDiration.value = val["梁约束位置yDirection"];
  661. ui.pb_zDiration.value = val["梁约束位置zDirection"];
  662. ui.pb_xCoord.value = val["梁约束位置xCoord"];
  663. ui.pb_yCoord.value = val["梁约束位置yCoord"];
  664. ui.pb_zCoord.value = val["梁约束位置zCoord"];
  665. ui.rad.value = val["梁约束参数半径"];
  666. ui.pb_length.value = val["梁约束参数长度"];
  667. ui.pb_size.value = val["梁约束参数个数"];
  668. ui.m.value = val["弹性模量"];
  669. ui.poi.value = val["泊松比"];
  670. ui.pb_node_size.value = val["梁节点大小半径"];
  671. ui.R.value = val.R;
  672. ui.G.value = val.G;
  673. ui.B.value = val.B;
  674. }, () => {});
  675. //弹簧
  676. CW_DeclareVariable("setConstraint2",
  677. val => {
  678. ui.sxs.value = val["弹簧坐标x"];
  679. ui.sys.value = val["弹簧坐标y"];
  680. ui.szs.value = val["弹簧坐标z"];
  681. ui.stypes.value = val.stypes;
  682. ui.sxe.value = val["弹簧终点x"];
  683. ui.sye.value = val["弹簧终点y"];
  684. ui.sze.value = val["弹簧终点z"];
  685. ui.stypee.value = val.stypee;
  686. ui.sstifx.value = val.stiffness_x;
  687. ui.sstify.value = val.stiffness_y;
  688. ui.sstifz.value = val.stiffness_z;
  689. ui.sr.value = val.R;
  690. ui.sg.value = val.G;
  691. ui.sb.value = val.B;
  692. }, () => {});
  693. //连接
  694. CW_DeclareVariable("setConstraint3",
  695. val => {
  696. ui.cxs.value = val["弹簧坐标x"];
  697. ui.cys.value= val["弹簧坐标y"];
  698. ui.czs.value= val["弹簧坐标z"];
  699. ui.ctypes.value= val.ctypes;
  700. ui.cxe.value= val["弹簧终点x"];
  701. ui.cye.value= val["弹簧终点y"];
  702. ui.cze.value= val["弹簧终点z"];
  703. ui.ctpyee.value= val.ctpyee;
  704. ui.cxn.value = val["弹簧材料xn"];
  705. ui.cyn.value= val["弹簧材料yn"];
  706. ui.czn.value= val["弹簧材料zn"];
  707. ui.cxr.value= val["弹簧材料xr"];
  708. ui.cyr.value= val["弹簧材料yr"];
  709. ui.czr.value= val["弹簧材料zr"];
  710. ui.cr.value = val.R;
  711. ui.cg.value = val.G;
  712. ui.cb.value = val.B;
  713. }, () => {});
  714. function onDragFile(filepath) {
  715. }
  716. function PUI(cb) {
  717. if(pui){cb();}
  718. }
  719. /*Usage of BLOCK_EVENT
  720. BLOCK_EVENT(()=>{
  721. ui.[name].[var] = ...;
  722. });
  723. */
  724. function BLOCK_EVENT(cb) {
  725. ui.block_event = true;
  726. cb();
  727. ui.block_event = false;
  728. }
  729. //////////////////////////////////////////////////////////////////////////
  730. // template codes for cw callback js.
  731. function CW_DeclareVariable(name, setter, getter) {
  732. if(typeof(__DeclareVariable) === 'function') {
  733. __DeclareVariable(name, setter, getter);
  734. }
  735. }
  736. function CW_DeclareOuterVariable(name) {
  737. if(typeof(__DeclareOuterVariable) === 'function') {
  738. __DeclareOuterVariable(name);
  739. }
  740. }