part_tip_pane.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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.main_tip_stk.index = 1;
  12. OnTipBtnChange('point');
  13. OnOpenCenterOfDie();
  14. OnShowCurTip();
  15. model.startLocalhost(()=>{
  16. ui.webview.value = "http://localhost:4000";
  17. parent.setTimeout(()=>{
  18. model.updateLineChart(getChart());
  19. }, 100);
  20. });
  21. }
  22. function upda() {
  23. model.updateLineChart(getChart());
  24. }
  25. //Callback after UI is fully loaded and displayed.
  26. function OnReady(reload, preview) {
  27. PUI(()=>{
  28. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  29. //The 'pui' variable is valid in all functions of this document.
  30. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  31. });
  32. }
  33. function OnCloseForm() {
  34. model.closeLocalhost();
  35. }
  36. function OnException(err) {
  37. //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
  38. }
  39. //////////////////////////////////////////////////////////////////////////
  40. // Callback Functions.
  41. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  42. function getChart() {
  43. const data = [];
  44. for (let i = 0; i <= 360; i++) {
  45. let t = (i / 180) * Math.PI;
  46. let r = Math.sin(2 * t) * Math.cos(2 * t);
  47. data.push([r, i]);
  48. }
  49. option = {
  50. legend: {
  51. data: ['line']
  52. },
  53. polar: {
  54. center: ['50%', '54%'],
  55. radius:'60%'
  56. },
  57. tooltip: {
  58. trigger: 'axis',
  59. axisPointer: {
  60. type: 'cross'
  61. }, padding: [5, 10], // 减小内边距,缩小提示框
  62. textStyle: {
  63. fontSize: 10 // 减小字体大小
  64. }
  65. },
  66. angleAxis: {
  67. type: 'value',
  68. startAngle: 0
  69. },
  70. radiusAxis: {
  71. min: 0
  72. },
  73. series: [
  74. {
  75. coordinateSystem: 'polar',
  76. name: 'line',
  77. type: 'line',
  78. showSymbol: false,
  79. data: data
  80. }
  81. ],
  82. animationDuration: 2000,
  83. width:'80',
  84. height:'80'
  85. };
  86. return option;
  87. }
  88. function OnResize(){
  89. }
  90. function OnHideCurTip(){
  91. ui.cur_tip_stk.visible = false;
  92. ui.tip_right.visible = true;
  93. ui.tip_down.visible = false;
  94. }
  95. function OnShowCurTip(){
  96. ui.cur_tip_stk.visible = true;
  97. ui.tip_right.visible = false;
  98. ui.tip_down.visible = true;
  99. }
  100. function OnTipBtnChange(Idx){
  101. const difTipMOdel = {
  102. 'point':() => {
  103. ui.Automatic_tip_stk.index = 0;
  104. ui.T_point.valid = true;
  105. ui.T_angel.valid = false;
  106. ui.C_die.valid = false;
  107. ui.cur_tip_model_stk.visible = true;
  108. },
  109. 'angle':() => {
  110. ui.Automatic_tip_stk.index = 1;
  111. ui.T_point.valid = false;
  112. ui.T_angel.valid = true;
  113. ui.C_die.valid = false;
  114. ui.cur_tip_model_stk.visible = true;
  115. },
  116. 'die':() => {
  117. ui.Automatic_tip_stk.index = 2;
  118. ui.T_point.valid = false;
  119. ui.T_angel.valid = false;
  120. ui.C_die.valid = true;
  121. ui.cur_tip_model_stk.visible = false;
  122. }
  123. };
  124. return difTipMOdel[Idx]();
  125. }
  126. function OnOpenCenterOfDie(){
  127. ui.center_of_die_stk.index = 1;
  128. }
  129. function OnCloseCenterOfDie(){
  130. ui.center_of_die_stk.index = 0;
  131. }
  132. //The message corresponding callback executed by the docker pane.
  133. // when calling [side_pane].fireEvent(type,para) in the main form.
  134. function OnParentDockerMessage(type, para) {
  135. }
  136. //////////////////////////////////////////////////////////////////////////
  137. // Utils Functions.
  138. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  139. function onDragFile(filepath) {
  140. }
  141. function PUI(cb) {
  142. if(pui){cb();}
  143. }
  144. /*Usage of BLOCK_EVENT
  145. BLOCK_EVENT(()=>{
  146. ui.[name].[var] = ...;
  147. });
  148. */
  149. function BLOCK_EVENT(cb) {
  150. ui.block_event = true;
  151. cb();
  152. ui.block_event = false;
  153. }
  154. //////////////////////////////////////////////////////////////////////////
  155. // template codes for cw callback js.
  156. function CW_DeclareVariable(name, setter, getter) {
  157. if(typeof(__DeclareVariable) === 'function') {
  158. __DeclareVariable(name, setter, getter);
  159. }
  160. }
  161. function CW_DeclareOuterVariable(name) {
  162. if(typeof(__DeclareOuterVariable) === 'function') {
  163. __DeclareOuterVariable(name);
  164. }
  165. }