boundary_constraint_pane.js 31 KB

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