toolbar_pane.js 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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.light.valid = true;
  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 OnZhenDongMenu(){
  30. switch (ui.pb_zhendong.content_menu) {
  31. case 1:
  32. unit.form.mainfrm.OnChangeValue(6);
  33. unit.form.mainfrm.OnChangeIndex(3);
  34. break;
  35. case 2:
  36. unit.form.mainfrm.OnChangeValue(6);
  37. unit.form.mainfrm.OnChangeIndex(3);
  38. break;
  39. case 4:
  40. unit.form.result_ZhenDong.Show();
  41. break;
  42. case 5:
  43. unit.form.result_ZhenDongYueShu.Show();
  44. break;
  45. }
  46. }
  47. function OnZhenDong(){
  48. ui.pb_zhendong.content_menu = [{
  49. name: "自由振动",
  50. id: 1
  51. }, {
  52. name: "约束振动",
  53. id: 2
  54. }, {
  55. name: "任意激励",
  56. id: 3
  57. }];
  58. }
  59. function OnMoTaiMenu(){
  60. switch (ui.motai.content_menu) {
  61. case 1:
  62. unit.form.physicsCreate2.Show();
  63. break;
  64. case 2:
  65. unit.form.createAnsys.Show();
  66. break;
  67. case 3:
  68. unit.form.mainfrm.OnCueline("求解中...", "blue");
  69. parent.setTimeout(() => {
  70. unit.form.mainfrm.OnCueline("求解成功!", "green");
  71. }, 20000);
  72. break;
  73. case 4:
  74. unit.form.result_ModelAnsys.Show();
  75. break;
  76. }
  77. }
  78. function OnMoTai(){
  79. ui.motai.content_menu = [{
  80. name: "创建分析类型",
  81. id: 1
  82. }, {
  83. name: "创建分析步",
  84. id: 2
  85. }, {
  86. name: "求解",
  87. id: 3
  88. }, {
  89. name: "结果",
  90. id: 4
  91. }];
  92. }
  93. var isLisght = true;
  94. function OnLight(){
  95. isLisght = !isLisght;
  96. ui.light.valid = isLisght;
  97. unit.form.mainfrm.OnLight(isLisght);
  98. }
  99. function OnCanvasContentMenu(){
  100. if(ui.view.content_menu === 1){
  101. OnTransform(1);
  102. }
  103. if(ui.view.content_menu === 2){
  104. OnTransform(2);
  105. }
  106. if(ui.view.content_menu === 3){
  107. OnPosition(1);
  108. }
  109. if(ui.view.content_menu === 4){
  110. OnPosition(2);
  111. }
  112. if(ui.view.content_menu === 5){
  113. OnPosition(6);
  114. }
  115. if(ui.view.content_menu === 6){
  116. OnPosition(5);
  117. }
  118. if(ui.view.content_menu === 7){
  119. OnPosition(3);
  120. }
  121. if(ui.view.content_menu === 8){
  122. OnPosition(4);
  123. }
  124. }
  125. function OnCanvasRightClick(){
  126. ui.view.content_menu = [
  127. {
  128. name: '旋转',
  129. icon: 'bar10',
  130. id: 1
  131. },
  132. {
  133. name: '平移',
  134. icon: 'bar11',
  135. id: 2
  136. },
  137. {
  138. name: '-'
  139. },
  140. {
  141. name: 'YOX',
  142. icon: 'bar19',
  143. id: 3
  144. },
  145. {
  146. name: 'XOY',
  147. icon: 'bar20',
  148. id: 4
  149. },
  150. {
  151. name: 'ZOX',
  152. icon: 'bar21',
  153. id: 5
  154. },
  155. {
  156. name: 'XOZ',
  157. icon: 'bar22',
  158. id: 6
  159. },
  160. {
  161. name: 'ZOY',
  162. icon: 'bar23',
  163. id: 7
  164. },
  165. {
  166. name: 'YOZ',
  167. icon: 'bar24',
  168. id: 8
  169. }
  170. ];
  171. }
  172. function OnBrep(){
  173. unit.form.mainfrm.OnSend('generateBreps');
  174. }
  175. function OnFixed(){
  176. unit.form.mainfrm.OnSend('constrainAdd');
  177. }
  178. function OnArrow(){
  179. unit.form.mainfrm.OnSend('arrowAdd');
  180. }
  181. function OnFacePick(){
  182. unit.form.mainfrm.OnSend('facePickup');
  183. }
  184. function OnPick(){
  185. unit.form.mainfrm.OnSend('solidPickup');
  186. }
  187. function OnPostContentMenu(){
  188. switch (ui.pb_post.content_menu) {
  189. case 1:
  190. unit.form.colorMap.Show();
  191. break;
  192. }
  193. }
  194. function OnPost(){
  195. ui.pb_post.content_menu = [{
  196. name: "颜色映射表",
  197. icon: "图标",
  198. id: 1
  199. }];
  200. }
  201. var isShow = true;
  202. function OnShow(){
  203. isShow = !isShow;
  204. unit.form.mainfrm.OnWindowVisible(isShow);
  205. }
  206. function OnImport(){
  207. unit.form.tree.OnChangeMenu(1);
  208. }
  209. function OnFileContentMenu() {
  210. //打开文件
  211. switch (ui.pb_file.content_menu) {
  212. case 11:
  213. unit.form.workArea.Show();
  214. break;
  215. case 12:
  216. unit.form.Project.Show();
  217. break;
  218. case 13:
  219. unit.form.WorkCondition.Show();
  220. break;
  221. case 2:
  222. var fname = ui.OpenFolderDialog("Open WorkArea", unit.dir);
  223. unit.form.tree.OpenWorkArea(fname);
  224. break;
  225. case 3:
  226. unit.form.tree.SaveWorkArea();
  227. break;
  228. case 61:
  229. unit.form.tree.OnChangeMenu(1);
  230. unit.form.tree.OnTopMenu(1);
  231. break;
  232. case 62:
  233. unit.form.tree.OnChangeMenu(1);
  234. unit.form.tree.OnTopMenu(2);
  235. break;
  236. case 63:
  237. unit.form.tree.OnChangeMenu(1);
  238. unit.form.tree.OnTopMenu(3);
  239. break;
  240. case 64:
  241. unit.form.tree.OnChangeMenu(1);
  242. unit.form.tree.OnTopMenu(4);
  243. break;
  244. case 65:
  245. unit.form.tree.OnChangeMenu(1);
  246. unit.form.tree.OnTopMenu(5);
  247. break;
  248. }
  249. }
  250. function OnFile() {
  251. ui.pb_file.content_menu = [{
  252. name: "新建",
  253. icon: "bar01",
  254. id: 1,
  255. children: [{
  256. name: "工作区",
  257. icon: "import01",
  258. id: 11
  259. }, {
  260. name: "工程",
  261. icon: "import02",
  262. id: 12
  263. }, {
  264. name: "工况",
  265. icon: "import02",
  266. id: 13
  267. }]
  268. }, {
  269. name: "打开",
  270. icon: "bar02",
  271. id: 2
  272. }, {
  273. name: "导入",
  274. icon: "bar04",
  275. id: 6,
  276. children: [{
  277. name: "几何文件",
  278. icon: "import03",
  279. id: 63
  280. }]
  281. }];
  282. }
  283. function OnTransform(idx){
  284. unit.form.mainfrm.OnTransform(idx);
  285. }
  286. function OnPosition(index){
  287. unit.form.mainfrm.On3DPosition(index);
  288. }
  289. function OnUser(){
  290. unit.form.user.Show();
  291. }
  292. //The message corresponding callback executed by the docker pane.
  293. // when calling [side_pane].fireEvent(type,para) in the main form.
  294. function OnParentDockerMessage(type, para) {
  295. }
  296. //////////////////////////////////////////////////////////////////////////
  297. // Utils Functions.
  298. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  299. function onDragFile(filepath) {
  300. }
  301. function PUI(cb) {
  302. if(pui){cb();}
  303. }
  304. /*Usage of BLOCK_EVENT
  305. BLOCK_EVENT(()=>{
  306. ui.[name].[var] = ...;
  307. });
  308. */
  309. function BLOCK_EVENT(cb) {
  310. ui.block_event = true;
  311. cb();
  312. ui.block_event = false;
  313. }
  314. //////////////////////////////////////////////////////////////////////////
  315. // template codes for cw callback js.
  316. function CW_DeclareVariable(name, setter, getter) {
  317. if(typeof(__DeclareVariable) === 'function') {
  318. __DeclareVariable(name, setter, getter);
  319. }
  320. }
  321. function CW_DeclareOuterVariable(name) {
  322. if(typeof(__DeclareOuterVariable) === 'function') {
  323. __DeclareOuterVariable(name);
  324. }
  325. }