mainfrm_pane.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. ////////////////////////////////////////////////////////////////////////////
  2. // System Pre-define Functions
  3. // 95099372-ef3e-11ea-9c81-bf848405c62e
  4. var dock_widget = false;
  5. var dock_widget1 = false;
  6. var dock_widget2 = false;
  7. var dock_widget3 = false;
  8. var g_preview = false;
  9. var g_io = false;
  10. var g_wid = false;
  11. let myArray = [];
  12. var res = [];
  13. var judge = 0;
  14. var startEnd = 0;
  15. var vtkContext = null;
  16. var workData = null;
  17. function OnDockerChange(){
  18. updateDockerButtonStatus();
  19. }
  20. function OnResize() {
  21. if (dock_widget && !ui.docker.isVisible(dock_widget)) {
  22. showLeftDocker(true);
  23. }
  24. }
  25. function OnInitDocker() {
  26. dock_widget1 = appendDockPane(unit.form.toolbar, "", 4, 1|2|4);
  27. dock_widget2 = appendDockPane(unit.form.tree, "模型树", 1, 1|2);
  28. //dock_widget1 = appendDockPane(unit.form.toolAF_bar, "", 4, 1|2|4);
  29. //dock_widget3 = appendDockPane(unit.form.toolAF, "", 4, 1|2|4);
  30. //dock_widget1 = appendDockPane(unit.form.toolAF_bar, "", 4, 1|2|4);
  31. //dock_widget1 = appendDockPane(unit.form.message, "消息反馈区", 8, 8|2);
  32. }
  33. function updateDockerButtonStatus() {
  34. if (!dock_widget) {
  35. return;
  36. }
  37. //unit.form.cw_topmenu.onUpdateBtn(!ui.docker.isFloat(dock_widget), !ui.docker.isVisible(dock_widget));
  38. }
  39. function appendDockPane(sub_form, title, init_pos, allow_pos, features) {
  40. /*
  41. sub_form.Show();
  42. dock_widget = ui.docker.wrapWindow(sub_form.getWindowID(), "参数面板");
  43. */
  44. let dw = sub_form.CreateDock(title);
  45. if (features) {
  46. ui.docker.setFeatures(features);
  47. }
  48. ui.docker.setAllowAreas(dw, allow_pos);
  49. ui.docker.dock(dw, init_pos);
  50. return dw;
  51. }
  52. function showLeftDocker(flag) {
  53. ui.docker.show(dock_widget, flag);
  54. updateDockerButtonStatus();
  55. }
  56. function InitCanvasIOEngine() {
  57. ui.canvas.adaptor('nastran', function(fname_nas) {
  58. //console.log(fname_nas);
  59. console.time('Nastran Import');
  60. model.cueline('解析并加载Nastran文件 ...');
  61. model.updateGeometry(ui.geometry);
  62. ui.canvas.db = null;
  63. parent.mesh.shell.ClearCache();
  64. parent.mesh.shell.LoadNastranToCache(fname_nas);
  65. console.timeEnd('Nastran Import');
  66. model.cueline('创建图形缓冲区 ...');
  67. console.time('Nastran Buffer');
  68. var buf = parent.mesh.shell.RenderToGLCache();
  69. console.timeEnd('Nastran Buffer');
  70. model.cueline('生成图形数据库并渲染 ...');
  71. return buf;
  72. });
  73. /*
  74. ui.canvas.adaptor('step', function(fname_step) {
  75. console.time('Step Import'1
  76. model.cueline('解析并加载STEP文件 ...');
  77. model.updateGeometry(ui.geometry);
  78. ui.canvas.db = null;
  79. //comx.occore.Clear();
  80. comx.occio.ImportStep(comx.occore.GetEntry(), fname_step);
  81. console.timeEnd('Step Import');
  82. model.cueline('创建图形缓冲区 ...');
  83. console.time('Step Buffer');
  84. var gl_buf = comx.occrender.RenderToBuffer(comx.occore.GetEntry());
  85. console.timeEnd('Step Buffer');
  86. model.cueline('生成图形数据库并渲染 ...');
  87. return gl_buf;
  88. });*/
  89. ui.canvas.adaptor('step', function(fname_step) {
  90. console.log('Step');
  91. console.time('Step Import');
  92. model.cueline('解析并加载STEP文件 ...');
  93. model.updateGeometry(ui.geometry);
  94. ui.canvas.db = null;
  95. comx.occore.Clear();
  96. comx.occio.ImportStepEx(comx.occore.GetEntryEx(), fname_step);
  97. var modelTree = comx.occio.ImportStepEx(comx.occore.GetEntryEx(), fname_step);
  98. //ui.tree.tree = JSON.parse(modelTree);
  99. unit.form.tree.OnTree(JSON.parse(modelTree));
  100. var hashCodes = comx.occio.GetFaceHashCodes(comx.occore.GetEntryEx());
  101. console.log(JSON.parse(hashCodes));
  102. model.setHash(JSON.parse(hashCodes));
  103. console.timeEnd('Step Import');
  104. model.cueline('创建图形缓冲区 ...');
  105. console.time('Step Buffer');
  106. var gl_buf = comx.occrender.RenderToBufferEx(comx.occore.GetEntryEx());
  107. console.timeEnd('Step Buffer');
  108. model.cueline('生成图形数据库并渲染 ...');
  109. return gl_buf;
  110. });
  111. ui.canvas.adaptor('iges', function(fname_step) {
  112. console.time('Iges Import');
  113. model.cueline('解析并加载IGES文件 ...');
  114. model.updateGeometry(ui.geometry);
  115. ui.canvas.db = null;
  116. comx.occore.Clear();
  117. comx.occio.ImportIges(comx.occore.GetEntry(), fname_step);
  118. console.timeEnd('Iges Import');
  119. model.cueline('创建图形缓冲区 ...');
  120. console.time('Iges Buffer');
  121. var gl_buf = comx.occrender.RenderToBuffer(comx.occore.GetEntry());
  122. console.timeEnd('Iges Buffer');
  123. model.cueline('生成图形数据库并渲染 ...');
  124. return gl_buf;
  125. });
  126. }
  127. function SetCanvasProp() {
  128. ui.canvas.filter = [2025]; //面
  129. if (ui.canvas.view()) {
  130. //ui.canvas.view().setColor(0.75, 0.75, 0.75, 0.5);
  131. ui.canvas.view().setColor(1.0, 1.0, 0, 1.0);
  132. ui.canvas.view().setVisible(true);
  133. ui.canvas.view().setBlend(false);
  134. }
  135. ui.canvas.lamp = true;
  136. }
  137. //Callback of data preparation stage before UI is fully loaded.
  138. //显示3D模型
  139. function OnloadModel(path) {
  140. ui.canvas.step = path;
  141. }
  142. //清除canvas
  143. function ClearCanvas() {
  144. ui.canvas.db = null;
  145. }
  146. //设置材料参数界面
  147. function setMaterial(material) {
  148. ui.physics_mastk.setmaterial = material;
  149. }
  150. //设置约束
  151. function setConstraint(prop) {
  152. let constraint = {
  153. "固定支撑":function(){
  154. ui.cw_boundary_constraint_25.setConstraint0 = prop;
  155. },
  156. "梁":function(){
  157. ui.cw_boundary_constraint_25.setConstraint1 = prop;
  158. },
  159. "弹簧":function(){
  160. ui.cw_boundary_constraint_25.setConstraint2 = prop;
  161. },
  162. "连接":function(){
  163. ui.cw_boundary_constraint_25.setConstraint3 = prop;
  164. },
  165. "梁(非均匀)":function(){
  166. },
  167. "集中载荷压力":function(){
  168. ui.cw_boundary_force_24.setConstraint0 = prop;
  169. },
  170. "分布载荷压力":function(){
  171. ui.cw_boundary_force_24.setConstraint1 = prop;
  172. }
  173. };
  174. constraint[prop.constraint]();
  175. }
  176. //显示重命名界面
  177. function RenameTreeNode(Idx) {
  178. if(Idx === 2) {
  179. unit.form.Rename.Show();
  180. }else if(Idx === 5){
  181. unit.form.RenameMaterial.Show();
  182. }
  183. }
  184. function OnInitializeData(reload, preview) {
  185. //model.ide_info(model.uuid().length);
  186. vtkContext = comx.vtk.CreateContext();
  187. ui.canvas.vtkContextInterface = vtkContext.Interface();
  188. workData = comx.ply.InitWorkArea();
  189. ui.pc_geo.value = model.getPicturePath('蓝灰色.png');
  190. OnCueline('白色->未使用,蓝灰色->正在处理,绿色->未通过,蓝色->通过', 'blue');
  191. InitCanvasIOEngine();
  192. if (g_io) {
  193. ui.cons.appendWindowByID(g_wid);
  194. ui.Activate();
  195. return;
  196. }
  197. g_io = model.startSubProcess(pid => {
  198. g_wid = ui.GetWinID(pid);
  199. ui.cons.appendWindowByID(g_wid);
  200. ui.Activate();
  201. //ui.SetFocus(ui.pmsg.handle);
  202. },
  203. msg => {
  204. //console.log(msg);
  205. unit.form.tree.OnMessage(msg);
  206. //console.log(msg);
  207. if(msg === 'step_file_loaded_flag') {
  208. ui.cueline.value = '';
  209. unit.form.result_attribute.OnReset();
  210. }
  211. //ui.cw_boundary_stress_more_Peidian.message = msg;
  212. ui.cw_result_Play_collision.frame = msg;
  213. /*
  214. if(msg === "*0"){
  215. OnSetProp(0);
  216. }else if(msg === "*10"){
  217. OnSetProp(10);
  218. }else if(msg === "*50"){
  219. OnSetProp(50);
  220. }else if(msg === "*80"){
  221. OnSetProp(80);
  222. }else if(msg === "*100"){
  223. OnSetProp(100);
  224. //model.stop();
  225. }*/
  226. //ui.cw_boundary_beam.message = msg;
  227. },
  228. attribute => {
  229. //console.log(msg);
  230. //myArray.push(attribute);
  231. ui.cw_result_Play_collision.Array = attribute;
  232. },
  233. ids => {
  234. //ui.cw_boundary_beam.ID = ids;
  235. //ui.cw_boundary_spring.ID = ids;
  236. console.log('ll' + ids);
  237. ui.physics_mastk.pb_ID =ids;
  238. },
  239. spring => {
  240. //ui.cw_boundary_spring.message = spring;
  241. const str = spring.split(' ');
  242. if(model.getStartEnd() === 0){
  243. ui.cw_boundary_constraint_25.pb_x = str[0];
  244. ui.cw_boundary_constraint_25.pb_y = str[1];
  245. ui.cw_boundary_constraint_25.pb_z = str[2];
  246. var strs = "";
  247. for(var i = 3; i < str.length; i++){
  248. strs += str[i] + ' ';
  249. }
  250. ui.cw_boundary_constraint_25.start_mes = strs;
  251. ui.cw_geometry_mark_22.pb_x = str[0];
  252. ui.cw_geometry_mark_22.pb_y = str[1];
  253. ui.cw_geometry_mark_22.pb_z = str[2];
  254. }
  255. if(model.getStartEnd() === 1){
  256. ui.cw_boundary_constraint_25.pb_X = str[0];
  257. ui.cw_boundary_constraint_25.pb_Y = str[1];
  258. ui.cw_boundary_constraint_25.pb_Z = str[2];
  259. ui.cw_boundary_constraint_25.end_mes = str[3];
  260. var strs = "";
  261. for(var i = 3; i < str.length; i++){
  262. strs += str[i] + ' ';
  263. }
  264. ui.cw_boundary_constraint_25.end_mes = strs;
  265. ui.cw_geometry_mark_22.pb_x = str[0];
  266. ui.cw_geometry_mark_22.pb_y = str[1];
  267. ui.cw_geometry_mark_22.pb_z = str[2];
  268. }
  269. if(model.getBeam()){
  270. var mes = '(' + str[0] + ',' + str[1] + ',' + str[2] + ')';
  271. model.setStr(mes);
  272. ui.cw_boundary_constraint_25.listbox = model.getStr();
  273. }
  274. /*
  275. if(model.getJudge() === 0) {
  276. //var str = val.split(' ');
  277. if(model.getStartEnd() === 0){
  278. ui.cw_boundary_spring.pb_x = str[0];
  279. ui.cw_boundary_spring.pb_y = str[1];
  280. ui.cw_boundary_spring.pb_z = str[2];
  281. console.log(str[0] + 's ' + str[1] + 's ' + str[2]);
  282. }
  283. if(model.getStartEnd() === 1){
  284. ui.cw_boundary_spring.pb_X = str[0];
  285. ui.cw_boundary_spring.pb_Y = str[1];
  286. ui.cw_boundary_spring.pb_Z = str[2];
  287. console.log(str[0] + 'd ' + str[1] + 'd ' + str[2]);
  288. }
  289. }
  290. if(model.getJudge() === 1) {
  291. //var str = val.split(' ');
  292. if(model.getStartEnd() === 0){
  293. ui.cw_boundary_spring.pb_x = str[0];
  294. ui.cw_boundary_spring.pb_y = str[1];
  295. ui.cw_boundary_spring.pb_z = str[2];
  296. ui.cw_boundary_spring.pb_startID = str[3];
  297. console.log(str[0] + 'a ' + str[1] + ' a' + str[2]);
  298. }
  299. if(model.getStartEnd() === 1){
  300. ui.cw_boundary_spring.pb_X = str[0];
  301. ui.cw_boundary_spring.pb_Y = str[1];
  302. ui.cw_boundary_spring.pb_Z = str[2];
  303. ui.cw_boundary_spring.pb_endID = str[3];
  304. console.log(str[0] + ' s' + str[1] + ' s' + str[2]);
  305. }
  306. }*/
  307. },
  308. selectFace => {
  309. const str = selectFace.split(' ');
  310. ui.cw_boundary_brep_23.list = str;
  311. },
  312. Eigenvalue =>{
  313. res.push(Eigenvalue);
  314. ui.cw_result_ModelAnsys_24.list = res;
  315. }, model.getCurrentDirectory() + "src_post/QFrameSelect.exe", model.getCurrentDirectory() + "src_post", 3000);
  316. parent.setTimeout(() => {
  317. OnInitDocker();
  318. }, 0);
  319. }
  320. //Callback after UI is fully loaded and displayed.
  321. function OnAnalysisShow(){
  322. //unit.form.form.Show();
  323. }
  324. function OnSolveShow(){
  325. }
  326. function OnReady(reload, preview) {
  327. }
  328. function OnCloseForm() {
  329. //console.log(11);
  330. //model.deleteFile(model.getCurrentDirectory() + 'data/faceID');
  331. //model.deleteFile(model.getCurrentDirectory() + 'data/face');
  332. //model.deleteFile(model.getCurrentDirectory() + 'data/peidian');
  333. //model.deleteFile(model.getCurrentDirectory() + 'data/restraint');
  334. //model.deleteFile(model.getCurrentDirectory() + 'data/force');
  335. //model.deleteFile(model.getCurrentDirectory() + 'data/beam');
  336. }
  337. function OnException(err) {
  338. //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
  339. }
  340. //////////////////////////////////////////////////////////////////////////
  341. // Callback Functions.
  342. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  343. function OnPickup(){
  344. }
  345. function OnMat(){
  346. OnSend('MatIds');
  347. }
  348. function setExecs(index){
  349. ui.cw_solve_setup.exec = index;
  350. }
  351. function OnWindowVisible(idx){
  352. ui.stack_menu.visible = idx;
  353. ui.stack_switch.visible = idx;
  354. }
  355. function OnChangePicture(id, value){
  356. if(id === 1){
  357. if(value === 1){
  358. ui.pc_geo.value = model.getPicturePath('蓝灰色.png');
  359. }else if(value === 2){
  360. ui.pc_geo.value = model.getPicturePath('绿色.png');
  361. }else if(value === 3){
  362. ui.pc_geo.value = model.getPicturePath('红色.png');
  363. }
  364. }else if(id === 2){
  365. if(value === 1){
  366. ui.pc_mat.value = model.getPicturePath('蓝灰色.png');
  367. }else if(value === 2){
  368. ui.pc_mat.value = model.getPicturePath('绿色.png');
  369. }else if(value === 3){
  370. ui.pc_mat.value = model.getPicturePath('红色.png');
  371. }
  372. }else if(id === 3){
  373. if(value === 1){
  374. ui.pc_bou.value = model.getPicturePath('蓝灰色.png');
  375. }else if(value === 2){
  376. ui.pc_bou.value = model.getPicturePath('绿色.png');
  377. }else if(value === 3){
  378. ui.pc_bou.value = model.getPicturePath('红色.png');
  379. }
  380. }else if(id === 4){
  381. if(value === 1){
  382. ui.pc_sol.value = model.getPicturePath('蓝灰色.png');
  383. }else if(value === 2){
  384. ui.pc_sol.value = model.getPicturePath('绿色.png');
  385. }else if(value === 3){
  386. ui.pc_sol.value = model.getPicturePath('红色.png');
  387. }
  388. }else if(id === 5){
  389. if(value === 1){
  390. ui.pc_res.value = model.getPicturePath('蓝灰色.png');
  391. }else if(value === 2){
  392. ui.pc_res.value = model.getPicturePath('绿色.png');
  393. }else if(value === 3){
  394. ui.pc_res.value = model.getPicturePath('红色.png');
  395. }
  396. }
  397. }
  398. function OnCueline(msg, color){
  399. let real_color = 'black';
  400. if(color){real_color = color;}
  401. if(!msg) {
  402. ui.cueline.value = "";
  403. return;
  404. }
  405. ui.cueline.value = `<span style=\"color:black\"><u><b>提示信息</b></u>:</span><span style="color:${real_color}">${msg}</span>`;// + msg;
  406. }
  407. function OnPoints(){
  408. OnSend('pointsCoord');
  409. }
  410. function OnMaterial(){
  411. ui.stack_menu.index = 19;
  412. console.log(22);
  413. }
  414. function OnFalseOpacity(){
  415. var id = parent.setTimeout(() => {
  416. OnSend('0');
  417. }, 100);
  418. OnSend('Opacity 0');
  419. }
  420. function OnOpacity(){
  421. var id = parent.setTimeout(() => {
  422. OnSend('0');
  423. }, 100);
  424. OnSend('Opacity 1');
  425. }
  426. function OnFaceCanvas(){
  427. ui.canvas.filter = [2025]; //面
  428. if (ui.canvas.view()) {
  429. ui.canvas.view().setColor(0.5, 0.5, 0.5, 0.2);
  430. ui.canvas.view().setVisible(true);
  431. ui.canvas.view().setBlend(false);
  432. }
  433. }
  434. function OnLineCanvas(){
  435. ui.canvas.filter = [2025]; //面
  436. if (ui.canvas.view()) {
  437. //ui.canvas.view().setColor(1.0, 1.0, 0.0, 0.0);
  438. ui.canvas.view().setVisible(true);
  439. ui.canvas.view().setBlend(true);
  440. }
  441. }
  442. function OnHightFace(idx){
  443. ui.canvas.view([ui.canvas.generateKey(2025, parseInt(idx))]).setColor(1.0, 0.0, 0.0);
  444. }
  445. function OnSetProp(index){
  446. ui.prop.visible = true;
  447. ui.prop.value = parseFloat(index);
  448. if(parseFloat(index) === 100){
  449. ui.prop.visible = false;
  450. }
  451. }
  452. function OnGetBeam(idx){
  453. myArray.push(idx);
  454. ui.cw_boundary_spring.beam = myArray;
  455. }
  456. function OnDeleteBeam(idx){
  457. myArray.splice(idx, 1);
  458. ui.cw_boundary_spring.beam = myArray;
  459. }
  460. function OnModuleChange(idx){
  461. ui.stack_switch.index = parseInt(idx);
  462. }
  463. function OnTransform(idx) {
  464. //ui.pb_pan.valid = ui.pb_rotate.valid = ui.pb_zoom.valid = ui.pb_zoom_window.valid = false;
  465. if (idx === 1) {
  466. //ui.pb_pan.valid = true;
  467. ui.canvas.sensor = GL.Sensor.Pan;
  468. }
  469. if (idx === 2) {
  470. //ui.canvas.sensor = GL.Sensor.Rotate;
  471. ui.pb_rotate.valid = true;
  472. }
  473. if (idx === 3) {
  474. //ui.canvas.sensor = GL.Sensor.Scale;
  475. ui.pb_zoom.valid = true;
  476. }
  477. if (idx === 4) {
  478. //ui.canvas.sensor = GL.Sensor.RectScale;
  479. ui.pb_zoom_window.valid = true;
  480. }
  481. }
  482. function On3DPosition(idx) {
  483. //ui.pb_yox.valid = ui.pb_xoy.valid = ui.pb_zoy.valid = ui.pb_yoz.valid = ui.pb_zox.valid = ui.pb_xoz.valid = false;
  484. if (idx === 1) {
  485. //ui.pb_yox.valid = true;
  486. ui.canvas.sensor = GL.Sensor.YOX;
  487. }
  488. if (idx === 2) {
  489. //ui.pb_xoy.valid = true;
  490. ui.canvas.sensor = GL.Sensor.XOY;
  491. }
  492. if (idx === 3) {
  493. //ui.pb_zoy.valid = true;
  494. ui.canvas.sensor = GL.Sensor.ZOY;
  495. }
  496. if (idx === 4) {
  497. //ui.pb_yoz.valid = true;
  498. ui.canvas.sensor = GL.Sensor.YOZ;
  499. }
  500. if (idx === 5) {
  501. //ui.pb_xoz.valid = true;
  502. ui.canvas.sensor = GL.Sensor.XOZ;
  503. }
  504. if (idx === 6) {
  505. //ui.pb_zox.valid = true;
  506. ui.canvas.sensor = GL.Sensor.ZOX;
  507. }
  508. }
  509. function OnPickUp() {
  510. if (!ui.canvas.hits) {
  511. return;
  512. }
  513. var rec = ui.canvas.hits[0];
  514. //console.log(ui.canvas.hits[0]);
  515. var key = rec.keyRecord;
  516. var keyObj = ui.canvas.parseKey(key);
  517. console.log(keyObj.sid);
  518. //ui.cw_boundary_face.ID = keyObj.sid;
  519. //ui.cw_boundary_fix.ID = keyObj.sid;
  520. var hashCodes = comx.occio.GetFaceHashCodes(comx.occore.GetEntryEx());
  521. console.log(hashCodes);
  522. //ui.cw_boundary_load.ID = JSON.parse(hashCodes)[parseInt(keyObj.sid)];
  523. ui.cw_boundary_load.ID = keyObj.sid;
  524. if(model.getCon() === 0){
  525. ui.canvas.view().setColor(0.0, 0.0, 1.0, 0.8);
  526. }else if(model.getCon() === 1){
  527. ui.canvas.view().setColor(1.0, 0.0, 0.0, 0.8);
  528. }
  529. //ui.cw_geometry_nurbs.sci = comx.occore.GetBrepInfo(keyObj.sid);
  530. //ui.cw_geometry_nurbs.self = FilterNurbsInfo();
  531. }
  532. function pick(idx) {
  533. console.log(idx);
  534. if (idx === 1) {
  535. ui.canvas.picker = {
  536. mode: GL.Picker.Mode.Single,
  537. autoHighlight: true,
  538. behavior: GL.Picker.Behavior.Point
  539. };
  540. }
  541. if (idx === 2) {
  542. ui.canvas.picker = {
  543. mode: GL.Picker.Mode.Multi,
  544. autoHighlight: true,
  545. behavior: GL.Picker.Behavior.None
  546. };
  547. }
  548. }
  549. function OnChangeWindows(Idx){
  550. if(Idx === 1){
  551. ui.pb_window.index = 0;
  552. }
  553. if(Idx === 2){
  554. ui.pb_window.index = 1;
  555. }
  556. }
  557. function OnOpenSTL(){
  558. var fname = ui.OpenFileDialog("Import File", unit.dir + 'data/', "Stl Files(*.stl *.STL)");
  559. ui.cw_boundary_STL.path = fname;
  560. }
  561. function OnSend(Idx) {
  562. //console.log(33);
  563. if (g_io) {
  564. g_io.send(Idx);
  565. }
  566. }
  567. function OnOpenFile(fname) {
  568. if (fname) {
  569. var is_step = (fname.indexOf('.STEP') !== -1) ||
  570. (fname.indexOf('.step') !== -1) ||
  571. (fname.indexOf('.STP') !== -1) ||
  572. (fname.indexOf('.stp') !== -1);
  573. var is_nas = (fname.indexOf('.nas') !== -1) || (fname.indexOf('.NAS') !== -1);
  574. model.wait();
  575. ui.canvas.db = null;
  576. parent.setTimeout(() => {
  577. if (is_step) {
  578. console.time('Global Step Load');
  579. ui.canvas.step = fname;
  580. console.timeEnd('Global Step Load');
  581. } else if (is_nas) {
  582. console.time('Global Nastran Load');
  583. ui.canvas.nastran = fname;
  584. console.timeEnd('Global Nastran Load');
  585. SetCanvasProp();
  586. } else {
  587. console.time('Global Iges Load');
  588. ui.canvas.iges = fname;
  589. console.timeEnd('Global Iges Load');
  590. }
  591. SetCanvasProp();
  592. ui.canvas.lamp = true;
  593. model.stop();
  594. }, 100);
  595. }
  596. ui.cw_geometry_check.path = fname;
  597. }
  598. function OnChangeValue(idx){
  599. /*console.log(ui.geometry.index);
  600. if(ui.geo.index === 0){
  601. menu(0);
  602. }
  603. if(ui.geo.index === 1){
  604. menu(2);
  605. }
  606. if(ui.geo.index === 2){
  607. menu(5);
  608. }
  609. if(ui.geo.index === 3){
  610. menu(10);
  611. }
  612. if(ui.geo.index === 4){
  613. menu(12);
  614. } */
  615. menu(idx);
  616. }
  617. function menu(Idx) {
  618. ui.stack_menu.index = parseInt(Idx);
  619. }
  620. function changeConstrain(index1, index2){
  621. if(index1 === 1){
  622. ui.cw_boundary_constraint_25.change1 = index2;
  623. }
  624. if(index1 === 2){
  625. ui.cw_boundary_constraint_25.change2 = index2;
  626. }
  627. if(index1 === 3){
  628. ui.cw_boundary_force_24.index = index2;
  629. }
  630. }
  631. //The message corresponding callback executed by the main form
  632. // when calling pui.fireEvent(type,para) in the Docker subform.
  633. function OnChildDockerMessage(type, para){
  634. }
  635. //////////////////////////////////////////////////////////////////////////
  636. // Utils Functions.
  637. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  638. function onDragFile(filepath) {
  639. }
  640. /*Usage of BLOCK_EVENT
  641. BLOCK_EVENT(()=>{
  642. ui.[name].[var] = ...;
  643. });
  644. */
  645. function BLOCK_EVENT(cb) {
  646. ui.block_event = true;
  647. cb();
  648. ui.block_event = false;
  649. }