riku
2025-02-24 0b700614e2f3e41df4655ba5469217e009c246ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<template>
  <BaseCard size="middle-s" direction="up">
    <template #content>
      <el-row align="middle" style="gap: 6px">
        <el-form-item label="遥测动画" v-loading="loading">
          <div class="map-btn-group">
            <font-awesome-icon
              :icon="btnStop.icon"
              :class="'btn-search m-r-2 ' + btnStop.clz"
              @click="handleStop"
            />
            <font-awesome-icon
              :icon="btnPlay.icon"
              class="btn-search"
              @click="handlePlayOrPause"
            />
          </div>
        </el-form-item>
        <el-form-item label="倍速">
          <el-select v-model="speed" size="small" class="w-60">
            <el-option label="1.0X" :value="1" />
            <el-option label="4.0X" :value="4" />
            <el-option label="8.0X" :value="8" />
            <el-option label="16X" :value="16" />
          </el-select>
        </el-form-item>
      </el-row>
    </template>
  </BaseCard>
</template>
<script>
import { unref } from 'vue';
import { GridAnimation } from '@/utils/map/grid-animation';
import SatelliteProxy from '@/views/satellitetelemetry/SatelliteProxy';
 
const gridAnimation = new GridAnimation();
 
export default {
  props: {
    gridData: Array,
    loading: Boolean,
    mapViews: Object
  },
  emits: ['change', 'stop'],
  data() {
    return {
      speed: 1,
      // 动画状态,0:停止;1:播放;2:暂停
      status: 0
    };
  },
  watch: {
    speed(nV, oV) {
      if (nV != oV) {
        this.changeSpeed(nV);
      }
    }
  },
  computed: {
    btnStop() {
      return {
        icon: 'fa fa-stop',
        clz: this.status == 0 ? 'btn-disable' : 'btn-able'
      };
    },
    btnPlay() {
      return {
        icon: this.status == 1 ? 'fa fa-pause' : 'fa fa-play'
      };
    }
  },
  methods: {
    handleStop() {
      if (this.status != 0) {
        this.status = 0;
        this.stopAnimation();
        this.handleChange();
      }
    },
    handlePlayOrPause() {
      if (this.status == 1) {
        this.status = 2;
        this.pauseAnimation();
      } else {
        this.status = 1;
        this.startAnimation();
      }
      this.handleChange();
    },
    handleChange() {
      this.$emit('change', this.status);
    },
 
    newTimeTask() {
      const that = this;
      gridAnimation.setDynamicSpeed(false); //关闭动态绘制速度调整
      gridAnimation.startAnimation(
        this.gridData,
        function (data, index, count) {
          const d = data[index];
          // SatelliteProxy.clearText(mapViews);
          // eslint-disable-next-line vue/no-mutating-props
          const { textViews, labelsLayer } = SatelliteProxy.drawDataText(
            that.mapViews.points,
            d,
            that.mapViews.textViews
          );
          // eslint-disable-next-line vue/no-mutating-props
          that.mapViews.textViews = textViews;
          // eslint-disable-next-line vue/no-mutating-props
          that.mapViews.labelsLayer = labelsLayer;
          SatelliteProxy.drawColor({
            gridViews: that.mapViews.gridViews,
            gridDataDetail: d
          });
        }
      );
    },
    startAnimation() {
      this.changeSpeed(this.speed);
      if (!gridAnimation.runStatus()) {
        this.newTimeTask();
      } else {
        gridAnimation.start();
      }
      // this.start();
    },
    changeSpeed(speed) {
      gridAnimation.changeSpeed(speed);
    },
    pauseAnimation() {
      gridAnimation.pause();
      // this.pause();
    },
    stopAnimation() {
      gridAnimation.stop();
      // this.stop();
    }
  },
  mounted() {
    gridAnimation.setOnStopCallback(() => {
      this.$emit('stop');
    });
  },
  unmounted() {
    gridAnimation.stop();
  }
};
</script>