| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- ////////////////////////////////////////////////////////////////////////////
- // System Pre-define Functions
- // 95099372-ef3e-11ea-9c81-bf848405c62e
- //Callback of data preparation stage before UI is fully loaded.
- function OnInitializeData(reload, preview) {
-
- PUI(()=>{
- //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
- //The 'pui' variable is valid in all functions of this document.
- //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
-
- });
- ui.main_tip_stk.index = 1;
- OnTipBtnChange('point');
- OnOpenCenterOfDie();
- OnShowCurTip();
- model.startLocalhost(()=>{
- ui.webview.value = "http://localhost:4000";
- parent.setTimeout(()=>{
- model.updateLineChart(getChart());
-
- }, 100);
- });
-
- }
- function upda() {
- model.updateLineChart(getChart());
- }
- //Callback after UI is fully loaded and displayed.
- function OnReady(reload, preview) {
-
- PUI(()=>{
- //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
- //The 'pui' variable is valid in all functions of this document.
- //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
-
- });
- }
- function OnCloseForm() {
- model.closeLocalhost();
- }
- function OnException(err) {
- //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
- }
- //////////////////////////////////////////////////////////////////////////
- // Callback Functions.
- // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
- function getChart() {
- const data = [];
- for (let i = 0; i <= 360; i++) {
- let t = (i / 180) * Math.PI;
- let r = Math.sin(2 * t) * Math.cos(2 * t);
- data.push([r, i]);
- }
- option = {
- legend: {
- data: ['line']
- },
- polar: {
- center: ['50%', '54%'],
- radius:'60%'
- },
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'cross'
- }, padding: [5, 10], // 减小内边距,缩小提示框
- textStyle: {
- fontSize: 10 // 减小字体大小
- }
- },
- angleAxis: {
- type: 'value',
- startAngle: 0
- },
- radiusAxis: {
- min: 0
- },
- series: [
- {
- coordinateSystem: 'polar',
- name: 'line',
- type: 'line',
- showSymbol: false,
- data: data
- }
- ],
- animationDuration: 2000,
- width:'80',
- height:'80'
- };
- return option;
- }
- function OnResize(){
- }
- function OnHideCurTip(){
- ui.cur_tip_stk.visible = false;
- ui.tip_right.visible = true;
- ui.tip_down.visible = false;
- }
- function OnShowCurTip(){
- ui.cur_tip_stk.visible = true;
- ui.tip_right.visible = false;
- ui.tip_down.visible = true;
- }
- function OnTipBtnChange(Idx){
- const difTipMOdel = {
- 'point':() => {
- ui.Automatic_tip_stk.index = 0;
- ui.T_point.valid = true;
- ui.T_angel.valid = false;
- ui.C_die.valid = false;
- ui.cur_tip_model_stk.visible = true;
- },
- 'angle':() => {
- ui.Automatic_tip_stk.index = 1;
- ui.T_point.valid = false;
- ui.T_angel.valid = true;
- ui.C_die.valid = false;
- ui.cur_tip_model_stk.visible = true;
- },
- 'die':() => {
- ui.Automatic_tip_stk.index = 2;
- ui.T_point.valid = false;
- ui.T_angel.valid = false;
- ui.C_die.valid = true;
- ui.cur_tip_model_stk.visible = false;
- }
- };
- return difTipMOdel[Idx]();
- }
- function OnOpenCenterOfDie(){
- ui.center_of_die_stk.index = 1;
- }
- function OnCloseCenterOfDie(){
- ui.center_of_die_stk.index = 0;
- }
- //The message corresponding callback executed by the docker pane.
- // when calling [side_pane].fireEvent(type,para) in the main form.
- function OnParentDockerMessage(type, para) {
- }
- //////////////////////////////////////////////////////////////////////////
- // Utils Functions.
- // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
- function onDragFile(filepath) {
- }
- function PUI(cb) {
- if(pui){cb();}
- }
- /*Usage of BLOCK_EVENT
- BLOCK_EVENT(()=>{
- ui.[name].[var] = ...;
- });
- */
- function BLOCK_EVENT(cb) {
- ui.block_event = true;
-
- cb();
-
- ui.block_event = false;
- }
- //////////////////////////////////////////////////////////////////////////
- // template codes for cw callback js.
- function CW_DeclareVariable(name, setter, getter) {
- if(typeof(__DeclareVariable) === 'function') {
- __DeclareVariable(name, setter, getter);
- }
- }
- function CW_DeclareOuterVariable(name) {
- if(typeof(__DeclareOuterVariable) === 'function') {
- __DeclareOuterVariable(name);
- }
- }
|