toolbar_pane.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. }
  12. //Callback after UI is fully loaded and displayed.
  13. function OnReady(reload, preview) {
  14. PUI(()=>{
  15. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  16. //The 'pui' variable is valid in all functions of this document.
  17. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  18. });
  19. }
  20. function OnCloseForm() {
  21. }
  22. function OnException(err) {
  23. //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
  24. }
  25. //////////////////////////////////////////////////////////////////////////
  26. // Callback Functions.
  27. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  28. function OnBrep(){
  29. unit.form.mainfrm.OnSend('generateBreps');
  30. }
  31. function OnFixed(){
  32. unit.form.mainfrm.OnSend('constrainAdd');
  33. }
  34. function OnArrow(){
  35. unit.form.mainfrm.OnSend('arrowAdd');
  36. }
  37. function OnFacePick(){
  38. unit.form.mainfrm.OnSend('facePickup');
  39. }
  40. function OnPick(){
  41. unit.form.mainfrm.OnSend('solidPickup');
  42. }
  43. function OnPostContentMenu(){
  44. switch (ui.pb_post.content_menu) {
  45. case 1:
  46. unit.form.colorMap.Show();
  47. break;
  48. }
  49. }
  50. function OnPost(){
  51. ui.pb_post.content_menu = [{
  52. name: "颜色映射表",
  53. icon: "图标",
  54. id: 1
  55. }];
  56. }
  57. var isShow = true;
  58. function OnShow(){
  59. isShow = !isShow;
  60. unit.form.mainfrm.OnWindowVisible(isShow);
  61. }
  62. function OnImport(){
  63. unit.form.tree.OnChangeMenu(4);
  64. }
  65. function OnFileContentMenu() {
  66. //打开文件
  67. switch (ui.pb_file.content_menu) {
  68. case 11:
  69. unit.form.workArea.Show();
  70. break;
  71. case 12:
  72. unit.form.Project.Show();
  73. break;
  74. case 13:
  75. unit.form.WorkCondition.Show();
  76. break;
  77. case 2:
  78. var fname = ui.OpenFolderDialog("Open WorkArea", unit.dir);
  79. unit.form.tree.OpenWorkArea(fname);
  80. break;
  81. case 3:
  82. unit.form.tree.SaveWorkArea();
  83. break;
  84. case 61:
  85. unit.form.tree.OnChangeMenu(4);
  86. unit.form.tree.OnTopMenu(1);
  87. break;
  88. case 62:
  89. unit.form.tree.OnChangeMenu(4);
  90. unit.form.tree.OnTopMenu(2);
  91. break;
  92. case 63:
  93. unit.form.tree.OnChangeMenu(4);
  94. unit.form.tree.OnTopMenu(3);
  95. break;
  96. case 64:
  97. unit.form.tree.OnChangeMenu(4);
  98. unit.form.tree.OnTopMenu(4);
  99. break;
  100. case 65:
  101. unit.form.tree.OnChangeMenu(4);
  102. unit.form.tree.OnTopMenu(5);
  103. break;
  104. }
  105. }
  106. function OnFile() {
  107. ui.pb_file.content_menu = [{
  108. name: "New",
  109. icon: "bar01",
  110. id: 1,
  111. children: [{
  112. name: "WorkArea",
  113. icon: "import01",
  114. id: 11
  115. }, {
  116. name: "Project",
  117. icon: "import02",
  118. id: 12
  119. }, {
  120. name: "WorkCondition",
  121. icon: "import02",
  122. id: 13
  123. }]
  124. }, {
  125. name: "Open",
  126. icon: "bar02",
  127. id: 2
  128. }, {
  129. name: "Save",
  130. icon: "bar03",
  131. id: 3
  132. }, {
  133. name: "Save As",
  134. icon: "bar03",
  135. id: 4
  136. }, {
  137. name: "-"
  138. }, {
  139. name: "Subscribe",
  140. id: 5
  141. }, {
  142. name: "-"
  143. }, {
  144. name: "Import",
  145. icon: "bar04",
  146. id: 6,
  147. children: [{
  148. name: "Model",
  149. icon: "import01",
  150. id: 61
  151. }, {
  152. name: "Solver Deck",
  153. icon: "import02",
  154. id: 62
  155. }, {
  156. name: "Geometry",
  157. icon: "import03",
  158. id: 63
  159. }, {
  160. name: "BOM",
  161. icon: "import04",
  162. id: 64
  163. }, {
  164. name: "Connectors",
  165. icon: "import05",
  166. id: 65
  167. }]
  168. }, {
  169. name: "Load",
  170. icon: "bar07",
  171. id: 7,
  172. children:[{
  173. name: "Results",
  174. icon: "bar07",
  175. id: 71
  176. }, {
  177. name: "User Profile",
  178. icon: "bar06",
  179. id: 72
  180. }, {
  181. name: "Solver Template",
  182. id: 73
  183. }]
  184. }, {
  185. name: "Run",
  186. icon: "Formability1",
  187. id: 8,
  188. children: [{
  189. name: "Tcl/Tk Script",
  190. id: 81
  191. }, {
  192. name: "Command File",
  193. id: 82
  194. }]
  195. }, {
  196. name: "-"
  197. }, {
  198. name: "Export",
  199. icon: "bar05",
  200. id: 9,
  201. children: [{
  202. name: "Model",
  203. id: 91
  204. }, {
  205. name: "Solver Deck",
  206. id: 92
  207. }, {
  208. name: "Geometry",
  209. id: 93
  210. }, {
  211. name: "BOM",
  212. id: 94
  213. }, {
  214. name: "Connectors",
  215. id: 95
  216. }]
  217. }, {
  218. name: "Recent Files",
  219. id: 10
  220. }, {
  221. name: "Recent Import",
  222. id: 11
  223. }, {
  224. name:"-"
  225. }, {
  226. name: "Exit",
  227. id: 12
  228. }];
  229. }
  230. function OnTransform(idx){
  231. unit.form.mainfrm.OnTransform(idx);
  232. }
  233. function OnPosition(index){
  234. var id = parent.setTimeout(() => {
  235. unit.form.mainfrm.OnSend('0');
  236. }, 100);
  237. unit.form.mainfrm.OnSend('reset');
  238. unit.form.mainfrm.On3DPosition(index);
  239. }
  240. function OnUser(){
  241. unit.form.user.Show();
  242. }
  243. //The message corresponding callback executed by the docker pane.
  244. // when calling [side_pane].fireEvent(type,para) in the main form.
  245. function OnParentDockerMessage(type, para) {
  246. }
  247. //////////////////////////////////////////////////////////////////////////
  248. // Utils Functions.
  249. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  250. function onDragFile(filepath) {
  251. }
  252. function PUI(cb) {
  253. if(pui){cb();}
  254. }
  255. /*Usage of BLOCK_EVENT
  256. BLOCK_EVENT(()=>{
  257. ui.[name].[var] = ...;
  258. });
  259. */
  260. function BLOCK_EVENT(cb) {
  261. ui.block_event = true;
  262. cb();
  263. ui.block_event = false;
  264. }
  265. //////////////////////////////////////////////////////////////////////////
  266. // template codes for cw callback js.
  267. function CW_DeclareVariable(name, setter, getter) {
  268. if(typeof(__DeclareVariable) === 'function') {
  269. __DeclareVariable(name, setter, getter);
  270. }
  271. }
  272. function CW_DeclareOuterVariable(name) {
  273. if(typeof(__DeclareOuterVariable) === 'function') {
  274. __DeclareOuterVariable(name);
  275. }
  276. }