boundary_STL_pane.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 OnAutoLoadSTL(){
  29. var id = parent.setTimeout(() => {
  30. unit.form.mainfrm.OnSend('readStl 0');
  31. }, 100);
  32. unit.form.mainfrm.OnSend('readStl 1 ' + model.getCurrentDirectory() + '/data/locomotive_bogieassembly_sldasm2.stl');
  33. }
  34. let myArray = [];
  35. //////////////////////////////////////////////////////////////////////////
  36. // Callback Functions.
  37. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  38. function OnReturnMenu(){
  39. unit.form.mainfrm.menu(5);
  40. }
  41. function OnMaterialFiles() {
  42. var id = parent.setTimeout(() => {
  43. unit.form.mainfrm.OnSend('readStl 0');
  44. }, 100);
  45. unit.form.mainfrm.OnSend('readStl 1');
  46. }
  47. function OnDeleteValue() {
  48. myArray.splice(parseFloat(ui.listBox.index), 1);
  49. console.log(ui.listBox.index);
  50. ui.listBox.list = [
  51. myArray
  52. ];
  53. }
  54. function OnAddValue() {
  55. //unit.form.mainfrm.OnOpenSTL();
  56. var id = parent.setTimeout(() => {
  57. myArray.push(ui.pb_value.value);
  58. ui.listbox.list = [
  59. myArray
  60. ];
  61. }, 100);
  62. }
  63. //The message corresponding callback executed by the docker pane.
  64. // when calling [side_pane].fireEvent(type,para) in the main form.
  65. function OnParentDockerMessage(type, para) {
  66. }
  67. //////////////////////////////////////////////////////////////////////////
  68. // Utils Functions.
  69. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  70. function onDragFile(filepath) {
  71. }
  72. function PUI(cb) {
  73. if(pui){cb();}
  74. }
  75. CW_DeclareVariable("path",
  76. val => {
  77. ui.pb_value.value = val;
  78. }, () => {});
  79. /*Usage of BLOCK_EVENT
  80. BLOCK_EVENT(()=>{
  81. ui.[name].[var] = ...;
  82. });
  83. */
  84. function BLOCK_EVENT(cb) {
  85. ui.block_event = true;
  86. cb();
  87. ui.block_event = false;
  88. }
  89. //////////////////////////////////////////////////////////////////////////
  90. // template codes for cw callback js.
  91. function CW_DeclareVariable(name, setter, getter) {
  92. if(typeof(__DeclareVariable) === 'function') {
  93. __DeclareVariable(name, setter, getter);
  94. }
  95. }
  96. function CW_DeclareOuterVariable(name) {
  97. if(typeof(__DeclareOuterVariable) === 'function') {
  98. __DeclareOuterVariable(name);
  99. }
  100. }