toolbar_pane.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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. var isLisght = true;
  30. function OnLight(){
  31. isLisght = !isLisght;
  32. ui.light.valid = isLisght;
  33. unit.form.mainfrm.OnLight(isLisght);
  34. }
  35. function OnCanvasContentMenu(){
  36. if(ui.view.content_menu === 1){
  37. OnTransform(1);
  38. }
  39. if(ui.view.content_menu === 2){
  40. OnTransform(2);
  41. }
  42. if(ui.view.content_menu === 3){
  43. OnPosition(1);
  44. }
  45. if(ui.view.content_menu === 4){
  46. OnPosition(2);
  47. }
  48. if(ui.view.content_menu === 5){
  49. OnPosition(6);
  50. }
  51. if(ui.view.content_menu === 6){
  52. OnPosition(5);
  53. }
  54. if(ui.view.content_menu === 7){
  55. OnPosition(3);
  56. }
  57. if(ui.view.content_menu === 8){
  58. OnPosition(4);
  59. }
  60. }
  61. function OnCanvasRightClick(){
  62. ui.view.content_menu = [
  63. {
  64. name: '旋转',
  65. icon: 'bar10',
  66. id: 1
  67. },
  68. {
  69. name: '平移',
  70. icon: 'bar11',
  71. id: 2
  72. },
  73. {
  74. name: '-'
  75. },
  76. {
  77. name: 'YOX',
  78. icon: 'bar19',
  79. id: 3
  80. },
  81. {
  82. name: 'XOY',
  83. icon: 'bar20',
  84. id: 4
  85. },
  86. {
  87. name: 'ZOX',
  88. icon: 'bar21',
  89. id: 5
  90. },
  91. {
  92. name: 'XOZ',
  93. icon: 'bar22',
  94. id: 6
  95. },
  96. {
  97. name: 'ZOY',
  98. icon: 'bar23',
  99. id: 7
  100. },
  101. {
  102. name: 'YOZ',
  103. icon: 'bar24',
  104. id: 8
  105. }
  106. ];
  107. }
  108. function OnBrep(){
  109. unit.form.mainfrm.OnSend('generateBreps');
  110. }
  111. function OnFixed(){
  112. unit.form.mainfrm.OnSend('constrainAdd');
  113. }
  114. function OnArrow(){
  115. unit.form.mainfrm.OnSend('arrowAdd');
  116. }
  117. function OnFacePick(){
  118. unit.form.mainfrm.OnSend('facePickup');
  119. }
  120. function OnPick(){
  121. unit.form.mainfrm.OnSend('solidPickup');
  122. }
  123. function OnPostContentMenu(){
  124. switch (ui.pb_post.content_menu) {
  125. case 1:
  126. unit.form.colorMap.Show();
  127. break;
  128. }
  129. }
  130. function OnPost(){
  131. ui.pb_post.content_menu = [{
  132. name: "颜色映射表",
  133. icon: "图标",
  134. id: 1
  135. }];
  136. }
  137. var isShow = true;
  138. function OnShow(){
  139. isShow = !isShow;
  140. unit.form.mainfrm.OnWindowVisible(isShow);
  141. }
  142. function OnImport(){
  143. unit.form.tree.OnChangeMenu(1);
  144. }
  145. function OnFileContentMenu() {
  146. //打开文件
  147. switch (ui.pb_file.content_menu) {
  148. case 11:
  149. unit.form.workArea.Show();
  150. break;
  151. case 12:
  152. unit.form.Project.Show();
  153. break;
  154. case 13:
  155. unit.form.WorkCondition.Show();
  156. break;
  157. case 2:
  158. var fname = ui.OpenFolderDialog("Open WorkArea", unit.dir);
  159. unit.form.tree.OpenWorkArea(fname);
  160. break;
  161. case 3:
  162. unit.form.tree.SaveWorkArea();
  163. break;
  164. case 61:
  165. unit.form.tree.OnChangeMenu(1);
  166. unit.form.tree.OnTopMenu(1);
  167. break;
  168. case 62:
  169. unit.form.tree.OnChangeMenu(1);
  170. unit.form.tree.OnTopMenu(2);
  171. break;
  172. case 63:
  173. unit.form.tree.OnChangeMenu(1);
  174. unit.form.tree.OnTopMenu(3);
  175. break;
  176. case 64:
  177. unit.form.tree.OnChangeMenu(1);
  178. unit.form.tree.OnTopMenu(4);
  179. break;
  180. case 65:
  181. unit.form.tree.OnChangeMenu(1);
  182. unit.form.tree.OnTopMenu(5);
  183. break;
  184. }
  185. }
  186. function OnFile() {
  187. ui.pb_file.content_menu = [{
  188. name: "新建",
  189. icon: "bar01",
  190. id: 1,
  191. children: [{
  192. name: "工作区",
  193. icon: "import01",
  194. id: 11
  195. }, {
  196. name: "工程",
  197. icon: "import02",
  198. id: 12
  199. }, {
  200. name: "工况",
  201. icon: "import02",
  202. id: 13
  203. }]
  204. }, {
  205. name: "打开",
  206. icon: "bar02",
  207. id: 2
  208. }, {
  209. name: "导入",
  210. icon: "bar04",
  211. id: 6,
  212. children: [{
  213. name: "几何文件",
  214. icon: "import03",
  215. id: 63
  216. }]
  217. }];
  218. }
  219. function OnTransform(idx){
  220. unit.form.mainfrm.OnTransform(idx);
  221. }
  222. function OnPosition(index){
  223. unit.form.mainfrm.On3DPosition(index);
  224. }
  225. function OnUser(){
  226. unit.form.user.Show();
  227. }
  228. //The message corresponding callback executed by the docker pane.
  229. // when calling [side_pane].fireEvent(type,para) in the main form.
  230. function OnParentDockerMessage(type, para) {
  231. }
  232. //////////////////////////////////////////////////////////////////////////
  233. // Utils Functions.
  234. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  235. function onDragFile(filepath) {
  236. }
  237. function PUI(cb) {
  238. if(pui){cb();}
  239. }
  240. /*Usage of BLOCK_EVENT
  241. BLOCK_EVENT(()=>{
  242. ui.[name].[var] = ...;
  243. });
  244. */
  245. function BLOCK_EVENT(cb) {
  246. ui.block_event = true;
  247. cb();
  248. ui.block_event = false;
  249. }
  250. //////////////////////////////////////////////////////////////////////////
  251. // template codes for cw callback js.
  252. function CW_DeclareVariable(name, setter, getter) {
  253. if(typeof(__DeclareVariable) === 'function') {
  254. __DeclareVariable(name, setter, getter);
  255. }
  256. }
  257. function CW_DeclareOuterVariable(name) {
  258. if(typeof(__DeclareOuterVariable) === 'function') {
  259. __DeclareOuterVariable(name);
  260. }
  261. }