拖拽panel,
This commit is contained in:
parent
d20d91b0fc
commit
212d128c59
@ -1,5 +1,6 @@
|
|||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
|
import { drag } from '@/utils/directive'
|
||||||
|
|
||||||
// import * as Cesium from 'cesium'
|
// import * as Cesium from 'cesium'
|
||||||
// window.Cesium = Cesium
|
// window.Cesium = Cesium
|
||||||
@ -26,4 +27,6 @@ app.use(createPinia())
|
|||||||
app.use(router)
|
app.use(router)
|
||||||
app.use(Loading)
|
app.use(Loading)
|
||||||
|
|
||||||
|
app.directive('drag', drag)
|
||||||
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
76
src/utils/directive.js
Normal file
76
src/utils/directive.js
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
export const drag = {
|
||||||
|
mounted(el, binding, vnode, prevVnode) {
|
||||||
|
// let oDiv = el // 获取当前元素
|
||||||
|
// oDiv.onmousedown = e => {
|
||||||
|
// // 算出鼠标相对元素的位置
|
||||||
|
// let disX = e.clientX - oDiv.offsetLeft
|
||||||
|
// let disY = e.clientY - oDiv.offsetTop
|
||||||
|
// document.onmousemove = e => {
|
||||||
|
// // 用鼠标的位置减去鼠标相对元素的位置,得到元素的位置
|
||||||
|
// let left = e.clientX - disX
|
||||||
|
// let top = e.clientY - disY
|
||||||
|
// oDiv.style.left = left + 'px'
|
||||||
|
// oDiv.style.top = top + 'px'
|
||||||
|
// }
|
||||||
|
|
||||||
|
// document.onmouseup = e => {
|
||||||
|
// document.onmousemove = null
|
||||||
|
// document.onmouseup = null
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
el.style.cursor = 'move'
|
||||||
|
el.style.position = 'absolute'
|
||||||
|
el.onmousedown = function (e) {
|
||||||
|
let disX = e.pageX - el.offsetLeft
|
||||||
|
let disY = e.pageY - el.offsetTop
|
||||||
|
|
||||||
|
if (binding.value === 'father') {
|
||||||
|
disX = e.pageX - el.parentNode.offsetLeft
|
||||||
|
disY = e.pageY - el.parentNode.offsetTop
|
||||||
|
} else {
|
||||||
|
disX = e.pageX - el.offsetLeft
|
||||||
|
disY = e.pageY - el.offsetTop
|
||||||
|
}
|
||||||
|
|
||||||
|
document.onmousemove = function (e) {
|
||||||
|
let x = e.pageX - disX
|
||||||
|
let y = e.pageY - disY
|
||||||
|
let maxX
|
||||||
|
let maxY
|
||||||
|
|
||||||
|
if (binding.value === 'father') {
|
||||||
|
maxX =
|
||||||
|
el.parentNode.parentNode.offsetWidth - el.parentNode.offsetWidth
|
||||||
|
maxY =
|
||||||
|
el.parentNode.parentNode.offsetHeight - el.parentNode.offsetHeight
|
||||||
|
} else {
|
||||||
|
maxX = el.parentNode.offsetWidth - el.offsetWidth
|
||||||
|
maxY = el.parentNode.offsetHeight - el.offsetHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x < 0) {
|
||||||
|
x = 0
|
||||||
|
} else if (x > maxX) {
|
||||||
|
x = maxX
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y < 0) {
|
||||||
|
y = 0
|
||||||
|
} else if (y > maxY) {
|
||||||
|
y = maxY
|
||||||
|
}
|
||||||
|
|
||||||
|
if (binding.value === 'father') {
|
||||||
|
el.parentNode.style.left = x + 'px'
|
||||||
|
el.parentNode.style.top = y + 'px'
|
||||||
|
} else {
|
||||||
|
el.style.left = x + 'px'
|
||||||
|
el.style.top = y + 'px'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.onmouseup = function () {
|
||||||
|
document.onmousemove = document.onmouseup = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
@ -267,7 +267,7 @@ const showOrHideTextReport = () => {
|
|||||||
></mubiao-his-trajectory>
|
></mubiao-his-trajectory>
|
||||||
<multi-his-trajectory
|
<multi-his-trajectory
|
||||||
v-if="showMultiHisTrajCom"
|
v-if="showMultiHisTrajCom"
|
||||||
class="z-30 h-[260px] w-full"
|
class="absolute z-30 h-[260px] w-[80%]"
|
||||||
></multi-his-trajectory>
|
></multi-his-trajectory>
|
||||||
<his-images
|
<his-images
|
||||||
v-if="showHisImageCom"
|
v-if="showHisImageCom"
|
||||||
|
@ -78,6 +78,7 @@ const speedOptions = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
watch(times, timeArray => {
|
watch(times, timeArray => {
|
||||||
|
|
||||||
const segments = divideTimeRangeIntoParts(
|
const segments = divideTimeRangeIntoParts(
|
||||||
timeArray[0],
|
timeArray[0],
|
||||||
timeArray[timeArray.length - 1],
|
timeArray[timeArray.length - 1],
|
||||||
@ -114,7 +115,7 @@ function divideTimeRangeIntoParts(
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div v-drag>
|
||||||
<panel
|
<panel
|
||||||
title="多目标轨迹回放"
|
title="多目标轨迹回放"
|
||||||
showClose
|
showClose
|
||||||
@ -123,8 +124,9 @@ function divideTimeRangeIntoParts(
|
|||||||
<div class="flex h-full flex-col justify-center">
|
<div class="flex h-full flex-col justify-center">
|
||||||
<div>
|
<div>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
|
<!-- v-model:formatted-value="timeRange" -->
|
||||||
<n-date-picker
|
<n-date-picker
|
||||||
v-model:formatted-value="timeRange"
|
v-model:value="timeRange"
|
||||||
clearable
|
clearable
|
||||||
type="datetimerange"
|
type="datetimerange"
|
||||||
:shortcuts="rangeShortcuts"
|
:shortcuts="rangeShortcuts"
|
||||||
|
4
src/views/MultiTrajPlayback/hooks/useMultiDDTraj.js
Normal file
4
src/views/MultiTrajPlayback/hooks/useMultiDDTraj.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import { ref } from 'vue'
|
||||||
|
export default function useMultiDDTraj() {}
|
||||||
|
|
||||||
|
const multiDDTrajMap = new Map()
|
4
src/views/MultiTrajPlayback/hooks/useMultiHJTraj.js
Normal file
4
src/views/MultiTrajPlayback/hooks/useMultiHJTraj.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import { ref } from 'vue'
|
||||||
|
export default function useMultiHJTraj() {}
|
||||||
|
|
||||||
|
const multiHJTrajMap = new Map()
|
20
src/views/MultiTrajPlayback/hooks/useMultiSatTraj.js
Normal file
20
src/views/MultiTrajPlayback/hooks/useMultiSatTraj.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { ref } from 'vue'
|
||||||
|
import { useSatellite } from '../../Satellite/hooks/satellite'
|
||||||
|
export function useMultiSatTraj() {
|
||||||
|
return { addSatelliteTraj }
|
||||||
|
}
|
||||||
|
|
||||||
|
const multiSatTrajMap = new Map()
|
||||||
|
|
||||||
|
const { addSatellite } = useSatellite()
|
||||||
|
|
||||||
|
function addSatelliteTraj(satelliteList = []) {
|
||||||
|
console.log(satelliteList)
|
||||||
|
satelliteList.forEach(({ id, tle }) => {
|
||||||
|
if (!multiSatTrajMap.has(id)) {
|
||||||
|
const satellite = addSatellite({ id, tle })
|
||||||
|
console.log(satellite, 'satellite')
|
||||||
|
multiSatTrajMap.set(id, satellite)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
@ -1,16 +1,16 @@
|
|||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { useMultiTrajReq } from './useMultiTrajReq'
|
import { useMultiTrajReq } from './useMultiTrajReq'
|
||||||
|
import { useMultiSatTraj } from './useMultiSatTraj'
|
||||||
|
|
||||||
|
const timesMap = ref(new Map())
|
||||||
|
const times = ref([])
|
||||||
|
|
||||||
|
const customElapsedTime = ref(0)
|
||||||
|
const animationSpeed = ref(1)
|
||||||
|
// const lastFrameTime = ref<number>(performance.now())
|
||||||
|
const isAnimationRunning = ref(false)
|
||||||
|
const isPaused = ref(false)
|
||||||
export function useMultiTraj() {
|
export function useMultiTraj() {
|
||||||
const timesMap = ref(new Map())
|
|
||||||
const times = ref([])
|
|
||||||
|
|
||||||
const customElapsedTime = ref(0)
|
|
||||||
const animationSpeed = ref(1)
|
|
||||||
// const lastFrameTime = ref<number>(performance.now())
|
|
||||||
const isAnimationRunning = ref(false)
|
|
||||||
const isPaused = ref(false)
|
|
||||||
|
|
||||||
function play() {
|
function play() {
|
||||||
isAnimationRunning.value = true
|
isAnimationRunning.value = true
|
||||||
isPaused.value = false
|
isPaused.value = false
|
||||||
@ -53,6 +53,7 @@ export function useMultiTraj() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 所有树勾选的ids
|
||||||
const checkedAllKeys = ref({
|
const checkedAllKeys = ref({
|
||||||
zb: [],
|
zb: [],
|
||||||
dd: [],
|
dd: [],
|
||||||
@ -60,32 +61,84 @@ const checkedAllKeys = ref({
|
|||||||
hj: [],
|
hj: [],
|
||||||
})
|
})
|
||||||
|
|
||||||
const showMultiHisTrajCom = ref(false)
|
|
||||||
|
|
||||||
const showMultiHisTrajDrawer = ref(false)
|
const showMultiHisTrajDrawer = ref(false)
|
||||||
|
// 显示或隐藏多目标历史轨迹抽屉
|
||||||
function showOrHideMultiHisTrajDrawer() {
|
function showOrHideMultiHisTrajDrawer() {
|
||||||
showMultiHisTrajDrawer.value = !showMultiHisTrajDrawer.value
|
showMultiHisTrajDrawer.value = !showMultiHisTrajDrawer.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const showMultiHisTrajCom = ref(false)
|
||||||
|
// 显示或隐藏多目标历史轨迹组件
|
||||||
function showOrHideMultiHisTraj() {
|
function showOrHideMultiHisTraj() {
|
||||||
showMultiHisTrajCom.value = !showMultiHisTrajCom.value
|
showMultiHisTrajCom.value = !showMultiHisTrajCom.value
|
||||||
|
resetTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
const { getZBHisTraj } = useMultiTrajReq()
|
const { getZBHisTraj, getSatelliteHisTraj } = useMultiTrajReq()
|
||||||
|
|
||||||
|
// 加载多目标历史轨迹
|
||||||
function loadMultiHisTraj(timeRange) {
|
function loadMultiHisTraj(timeRange) {
|
||||||
console.log(timeRange)
|
console.log(timeRange)
|
||||||
|
|
||||||
const dictFunc = {
|
const dictFunc = {
|
||||||
zb: getZBHisTraj,
|
zb: getZBHisTraj,
|
||||||
dd: null,
|
dd: null,
|
||||||
satellite: null,
|
satellite: getSatelliteHisTraj,
|
||||||
hj: null,
|
hj: null,
|
||||||
}
|
}
|
||||||
Object.keys(checkedAllKeys.value).forEach(key => {
|
const reqList = Object.keys(checkedAllKeys.value).filter(key => {
|
||||||
checkedAllKeys.value[key].forEach(item => {
|
if (
|
||||||
typeof dictFunc[key] === 'function' && dictFunc[key](item, timeRange)
|
typeof dictFunc[key] === 'function' &&
|
||||||
})
|
checkedAllKeys.value[key].length
|
||||||
|
) {
|
||||||
|
return dictFunc[key]
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Promise.all(
|
||||||
|
reqList.map(key => {
|
||||||
|
return dictFunc[key]({
|
||||||
|
timeRange,
|
||||||
|
ids: checkedAllKeys.value[key],
|
||||||
|
})
|
||||||
|
})
|
||||||
|
).then(res => {
|
||||||
|
const data = reqList.reduce((acc, key, index) => {
|
||||||
|
return Object.assign(acc, { [key]: res[index] })
|
||||||
|
}, {})
|
||||||
|
addAllEntity(data)
|
||||||
|
})
|
||||||
|
|
||||||
|
times.value = timeRange
|
||||||
|
// setTimeRange(timeRange)
|
||||||
|
}
|
||||||
|
|
||||||
|
const { addSatelliteTraj } = useMultiSatTraj()
|
||||||
|
// 添加轨迹实体
|
||||||
|
function addAllEntity(data) {
|
||||||
|
const { zb, satellite } = data
|
||||||
|
// zb && useMultiSatTraj(satellite)
|
||||||
|
// dd && useMultiSatTraj(dd)
|
||||||
|
// hj && useMultiSatTraj(hj)
|
||||||
|
satellite && addSatelliteTraj(satellite)
|
||||||
|
}
|
||||||
|
|
||||||
|
function setTimeRange(timeRange) {
|
||||||
|
const [start, stop] = timeRange
|
||||||
|
const startTime = Cesium.JulianDate.fromDate(new Date(start))
|
||||||
|
const stopTime = Cesium.JulianDate.fromDate(new Date(stop))
|
||||||
|
|
||||||
|
viewer.clock.startTime = startTime
|
||||||
|
viewer.clock.stopTime = stopTime
|
||||||
|
viewer.clock.currentTime = startTime
|
||||||
|
viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP
|
||||||
|
viewer.clock.multiplier = 1
|
||||||
|
viewer.clock.shouldAnimate = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetTime() {
|
||||||
|
const currentTime = Cesium.JulianDate.fromDate(new Date())
|
||||||
|
viewer.clock.currentTime = currentTime
|
||||||
|
viewer.clock.clockRange = Cesium.ClockRange.UNBOUNDED
|
||||||
|
viewer.clock.shouldAnimate = true
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import { getHangjing } from '../../../api/Hangjing'
|
|||||||
import { getDaodanTree } from '../../../api/Daodan'
|
import { getDaodanTree } from '../../../api/Daodan'
|
||||||
|
|
||||||
export function useMultiTrajReq() {
|
export function useMultiTrajReq() {
|
||||||
return { allTreeData, getAllTree, getZBHisTraj }
|
return { allTreeData, getAllTree, getZBHisTraj, getSatelliteHisTraj }
|
||||||
}
|
}
|
||||||
|
|
||||||
const allTreeData = ref([])
|
const allTreeData = ref([])
|
||||||
@ -61,10 +61,10 @@ async function getHJTree() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getZBHisTraj(id, params) {
|
async function getZBHisTraj({ ids, timeRange }) {
|
||||||
const [timeBegin, timeEnd] = params
|
const [timeBegin, timeEnd] = timeRange
|
||||||
const { code, data } = await getMubiaoHisTraj({
|
const { code, data } = await getMubiaoHisTraj({
|
||||||
target_id: id,
|
target_id: ids,
|
||||||
timeBegin,
|
timeBegin,
|
||||||
timeEnd,
|
timeEnd,
|
||||||
})
|
})
|
||||||
@ -74,7 +74,16 @@ async function getZBHisTraj(id, params) {
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getSatelliteHisTraj(id, params) {
|
async function getSatelliteHisTraj({ ids, timeRange }) {
|
||||||
|
return Promise.resolve([
|
||||||
|
{
|
||||||
|
id: 'CALSPHERE 1',
|
||||||
|
name: 'CALSPHERE 1',
|
||||||
|
tle: `CALSPHERE 1
|
||||||
|
1 00900U 64063C 25112.58517632 .00001163 00000+0 11864-2 0 9998
|
||||||
|
2 00900 90.2148 62.1269 0027145 120.7790 303.4225 13.75994622 13579`,
|
||||||
|
},
|
||||||
|
])
|
||||||
const { timeBegin, timeEnd } = params
|
const { timeBegin, timeEnd } = params
|
||||||
const { code, data } = await getSatellite()
|
const { code, data } = await getSatellite()
|
||||||
if (code === '200') {
|
if (code === '200') {
|
||||||
|
12
src/views/MultiTrajPlayback/hooks/useMultiZBTraj.js
Normal file
12
src/views/MultiTrajPlayback/hooks/useMultiZBTraj.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { ref } from 'vue'
|
||||||
|
export default function useMultiZBTraj() {
|
||||||
|
return {
|
||||||
|
multiZBTrajMap,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const multiZBTrajMap = new Map()
|
||||||
|
|
||||||
|
function addMultiZBTraj(id, traj) {
|
||||||
|
multiZBTrajMap.set(id, traj)
|
||||||
|
}
|
@ -25,7 +25,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
function renderSuffix({ option }) {
|
function renderSuffix({ option }) {
|
||||||
return option.data ? (
|
return option.data ? (
|
||||||
<div class="">
|
<div class="pr-2">
|
||||||
<NIcon
|
<NIcon
|
||||||
size={14}
|
size={14}
|
||||||
class="cursor-pointer text-gray-500 hover:text-blue-600"
|
class="cursor-pointer text-gray-500 hover:text-blue-600"
|
||||||
@ -51,21 +51,28 @@ export default defineComponent({
|
|||||||
name: dict[key],
|
name: dict[key],
|
||||||
value: key,
|
value: key,
|
||||||
component: () => (
|
component: () => (
|
||||||
<Tree
|
<div class="px-4 py-2 w-h-full">
|
||||||
data={allTreeData.value[key]}
|
<Tree
|
||||||
key-field={key === 'satellite' ? 'id' : 'dataId'}
|
data={allTreeData.value[key]}
|
||||||
label-field={key === 'satellite' ? 'name' : 'nodeName'}
|
key-field={key === 'satellite' ? 'id' : 'dataId'}
|
||||||
showSearch
|
label-field={key === 'satellite' ? 'name' : 'nodeName'}
|
||||||
renderSuffix={renderSuffix}
|
showSearch
|
||||||
v-model:checked={checkedAllKeys.value[key]}
|
renderSuffix={renderSuffix}
|
||||||
/>
|
v-model:checked={checkedAllKeys.value[key]}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const canPlay = computed(() => {
|
||||||
|
return Object.values(checkedAllKeys.value).flat().length > 0
|
||||||
|
})
|
||||||
|
|
||||||
function playMultiTraj() {
|
function playMultiTraj() {
|
||||||
// TODO: 轨迹回放
|
// TODO: 轨迹回放
|
||||||
|
|
||||||
showOrHideMultiHisTraj()
|
showOrHideMultiHisTraj()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +93,9 @@ export default defineComponent({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<NButton onClick={playMultiTraj}>轨迹回放</NButton>
|
<NButton disabled={!canPlay.value} onClick={playMultiTraj}>
|
||||||
|
轨迹回放
|
||||||
|
</NButton>
|
||||||
</div>
|
</div>
|
||||||
</Panel>
|
</Panel>
|
||||||
</div>
|
</div>
|
||||||
|
@ -111,6 +111,7 @@ export function useSatellite() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
satelliteList,
|
satelliteList,
|
||||||
|
addSatellite,
|
||||||
checkedKeys,
|
checkedKeys,
|
||||||
getSatelliteList,
|
getSatelliteList,
|
||||||
addSatellites,
|
addSatellites,
|
||||||
@ -136,13 +137,11 @@ function createSatelliteCommunicationPayload(satId: string) {
|
|||||||
?.communicationPayload?.target.forEach((mbId: string) => {
|
?.communicationPayload?.target.forEach((mbId: string) => {
|
||||||
console.log(mbId, 'mbId')
|
console.log(mbId, 'mbId')
|
||||||
if (mubiaoMap.has(mbId)) {
|
if (mubiaoMap.has(mbId)) {
|
||||||
const beam = new Beam({
|
const beam = createBeam({
|
||||||
topEntity: satelliteMap.get(satId).entity,
|
topEntity: satelliteMap.get(satId).entity,
|
||||||
bottomEntity: mubiaoMap.get(mbId),
|
bottomEntity: mubiaoMap.get(mbId),
|
||||||
})
|
})
|
||||||
|
|
||||||
beam.create()
|
|
||||||
|
|
||||||
if (!satelliteBeamMap.has(satId)) {
|
if (!satelliteBeamMap.has(satId)) {
|
||||||
satelliteBeamMap.set(satId, new Map())
|
satelliteBeamMap.set(satId, new Map())
|
||||||
}
|
}
|
||||||
@ -153,6 +152,15 @@ function createSatelliteCommunicationPayload(satId: string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createBeam({ topEntity, bottomEntity }) {
|
||||||
|
const beam = new Beam({
|
||||||
|
topEntity,
|
||||||
|
bottomEntity,
|
||||||
|
})
|
||||||
|
beam.create()
|
||||||
|
return beam
|
||||||
|
}
|
||||||
|
|
||||||
function removeSatelliteCommunicationPayload(satId: string) {
|
function removeSatelliteCommunicationPayload(satId: string) {
|
||||||
if (!satelliteBeamMap.has(satId)) {
|
if (!satelliteBeamMap.has(satId)) {
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user