From 2cf73646a781121409ca0c0ecb579b403334f40e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E4=BA=89=E9=B8=A3?= Date: Wed, 19 Feb 2025 18:35:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8B=BE=E9=80=89=E5=8D=AB?= =?UTF-8?q?=E6=98=9F=E5=86=8D=E4=BF=AE=E6=94=B9=E8=BD=BD=E8=8D=B7=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E5=A4=9A=E4=BD=99=E8=BD=BD=E8=8D=B7=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=A4=9A=E7=9B=AE=E6=A0=87=E8=BD=A8=E8=BF=B9=E5=9B=9E?= =?UTF-8?q?=E6=94=BE=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9B=AE=E6=A0=87=EF=BC=88?= =?UTF-8?q?=E5=9B=A0=E4=B8=BA=E6=97=B6=E9=97=B4=E9=94=99=E4=BA=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/satelliteEntity.js | 5 ++-- .../Daodan/components/hooks/testHooks.jsx | 24 +++++++-------- src/views/Gantt/index.jsx | 12 ++++++-- .../MultiHisTrajectory/hooks/multiMbTraj.ts | 29 ++++++++++++------- src/views/Mubiao/hooks/mubiao.ts | 13 ++++----- src/views/Satellite/hooks/satellite.ts | 8 ++--- 6 files changed, 52 insertions(+), 39 deletions(-) diff --git a/src/js/satelliteEntity.js b/src/js/satelliteEntity.js index 8823938dd..03fd81b39 100644 --- a/src/js/satelliteEntity.js +++ b/src/js/satelliteEntity.js @@ -38,7 +38,7 @@ class SatelliteEntity { set sensor(showSensor) { // console.log(showSensor, 'showSensor') this._sensor = showSensor - if (showSensor) { + if (showSensor && !this.sensorEntity) { if (this._sensorType === 'conic') { this.createConicSensor(this.entity) } else if (this._sensorType === 'rectangle') { @@ -503,16 +503,17 @@ class SatelliteEntity { viewer.scene.primitives.remove(this.sensorEntity) } this.sensorEntity = null + viewer.scene.preRender.addEventListener(this._listener) this._listener = null } } destroy() { + this.removeSensor() viewer.entities.remove(this.entity) this.underPointEntity && viewer.entities.remove(this.underPointEntity) this.removeListener() - this.removeSensor() } removeListener() { diff --git a/src/views/Daodan/components/hooks/testHooks.jsx b/src/views/Daodan/components/hooks/testHooks.jsx index e3e7281c1..bdbf14e47 100644 --- a/src/views/Daodan/components/hooks/testHooks.jsx +++ b/src/views/Daodan/components/hooks/testHooks.jsx @@ -226,18 +226,18 @@ function addDaodan(trajData, type = 0) { let minTime = 0 function initDaodan() { saveDataToStore() - // minTime = getMinTime([ - // ...toRaw(trajData.value.data), - // ...toRaw(interceptData.value.map(item => toRaw(item.data))).flat(Infinity), - // ]) - // // console.log(minTime) - // addDaodan(trajData.value) - // aniIndexMap.set(trajData.value.id, 0) - // interceptData.value.forEach(item => { - // const { id, data } = item - // addDaodan(item, 1) - // aniIndexMap.set(id, 0) - // }) + minTime = getMinTime([ + ...toRaw(trajData.value.data), + ...toRaw(interceptData.value.map(item => toRaw(item.data))).flat(Infinity), + ]) + // console.log(minTime) + addDaodan(trajData.value) + aniIndexMap.set(trajData.value.id, 0) + interceptData.value.forEach(item => { + const { id, data } = item + addDaodan(item, 1) + aniIndexMap.set(id, 0) + }) } function getMinTime(data) { diff --git a/src/views/Gantt/index.jsx b/src/views/Gantt/index.jsx index 3f55138d6..dc92a7d3d 100644 --- a/src/views/Gantt/index.jsx +++ b/src/views/Gantt/index.jsx @@ -17,6 +17,7 @@ import EventList from './components/EventList' import NewTask from './components/TaskList/components/NewTask' import useTask from './components/TaskList/components/NewTask/hooks' +import { useEvent } from './components/EventList/hooks' export default defineComponent({ setup() { const show = ref(false) @@ -36,6 +37,13 @@ export default defineComponent({ const dd = ref(`DD-1`) const paneClass = `border-1 h-full border-l-0 border-[var(--n-tab-border-color)] !p-2` + + const { showMainEvent, mainEventData } = useEvent() + const addNewMainEvent = () => { + showMainEvent.value = true + mainEventData.value = {} + } + return () => (
@@ -114,9 +122,9 @@ export default defineComponent({ type="daterange" clearable /> - {/* + 添加事件 - */} +
diff --git a/src/views/Mubiao/components/MultiHisTrajectory/hooks/multiMbTraj.ts b/src/views/Mubiao/components/MultiHisTrajectory/hooks/multiMbTraj.ts index 0601af0f2..58ade1a4f 100644 --- a/src/views/Mubiao/components/MultiHisTrajectory/hooks/multiMbTraj.ts +++ b/src/views/Mubiao/components/MultiHisTrajectory/hooks/multiMbTraj.ts @@ -23,6 +23,8 @@ export const useMultiMBTrajectory = () => { const isPaused = ref(false) async function loadMultiHisTraj(timeRange: string[]) { + removeEntities() + const mbIds = [...mubiaoMap.keys()] showEntity(false) if (mbIds.length === 0) { @@ -33,13 +35,14 @@ export const useMultiMBTrajectory = () => { id: mbId, timeRange, }) + // console.log(points, posArray, timeArray) timesMap.value.set(mbId, timeArray) if (timeArray.length <= 1) { continue } const color = Cesium.Color.fromRandom({ alpha: 1 }) - createTarget(mbId, points, posArray as number[], color) + createTarget(mbId, points, posArray as number[], color, timeArray) } const allTime = [...timesMap.value.values()].flat() @@ -49,29 +52,33 @@ export const useMultiMBTrajectory = () => { } function showOrHideMultiHisTraj() { - if (showMultiHisTrajCom.value) { - reset() - } + // if (showMultiHisTrajCom.value) { + reset() + // } showMultiHisTrajCom.value = !showMultiHisTrajCom.value - removeEntities() + if (!showMultiHisTrajCom.value) { + removeEntities() + showEntity(true) + } } function createTarget( mbId: string, points: TPoints, posArray: number[], - color: Cesium.Color + color: Cesium.Color, + timeArray: number[] ) { // const totalAnimationTime = points[points.length - 1].time // console.log('totalAnimationTime', totalAnimationTime) const positionProperty = new Cesium.SampledPositionProperty() // const startTime = Cesium.JulianDate.now() // 添加路径点到位置属性 - points.forEach(point => { + points.forEach((point, index) => { const pointEntity = createPoint(point.position, color) pointsEntities.push(pointEntity) - const time = Cesium.JulianDate.fromDate(new Date(point.time)) - + const time = Cesium.JulianDate.fromDate(new Date(timeArray[index])) + // console.log(new Date(timeArray[index]).toLocaleString()) positionProperty.addSample(time, point.position) }) @@ -79,8 +86,10 @@ export const useMultiMBTrajectory = () => { id: mbId, targetType: '甲', }) + // console.log(mbEntityOpt) // 创建实体 const mbTarget = viewer.entities.add({ + show: true, position: positionProperty, // point: { pixelSize: 10, color: Cesium.Color.RED }, polyline: { @@ -95,7 +104,6 @@ export const useMultiMBTrajectory = () => { ...mbEntityOpt, orientation: new Cesium.VelocityOrientationProperty(positionProperty), }) - mbTargetMap.set(mbId, mbTarget) } function createPoint(position: Cesium.Cartesian3, color: Cesium.Color) { @@ -173,7 +181,6 @@ export const useMultiMBTrajectory = () => { viewer.entities.remove(mbTarget) }) mbTargetMap.clear() - showEntity(true) } return { customElapsedTime, diff --git a/src/views/Mubiao/hooks/mubiao.ts b/src/views/Mubiao/hooks/mubiao.ts index 6fbdd6206..66c05d15a 100644 --- a/src/views/Mubiao/hooks/mubiao.ts +++ b/src/views/Mubiao/hooks/mubiao.ts @@ -56,6 +56,12 @@ export const useMubiao = () => { const addIds = difference(ids, [...mubiaoMap.keys()]) const removeIds = difference([...mubiaoMap.keys()], ids) + // 删除 + if (removeIds.length > 0) { + removeIds.forEach(id => { + removeMubiao(id) + }) + } // 添加 if (addIds.length > 0) { const nodes = filterTreeNodeByField({ @@ -89,13 +95,6 @@ export const useMubiao = () => { mubiaoMap.set(id, mbEntity) }) } - - // 删除 - if (removeIds.length > 0) { - removeIds.forEach(id => { - removeMubiao(id) - }) - } } async function postCheckedIds(ids: Array) { diff --git a/src/views/Satellite/hooks/satellite.ts b/src/views/Satellite/hooks/satellite.ts index 975708619..d9f0e6dc4 100644 --- a/src/views/Satellite/hooks/satellite.ts +++ b/src/views/Satellite/hooks/satellite.ts @@ -37,7 +37,9 @@ export function useSatellite() { function addSatellites(ids: Array) { const addIds = difference(ids, [...satelliteMap.keys()]) const removeIds = difference([...satelliteMap.keys()], ids) - + removeIds.forEach(id => { + removeSatellite(id) + }) if (addIds.length > 0) { const nodes = filterTreeNodeByField({ treeData: satelliteList.value, @@ -53,10 +55,6 @@ export function useSatellite() { } }) } - - removeIds.forEach(id => { - removeSatellite(id) - }) } // 创建satellite entity 实例 function addSatellite({ id, tle }: ISatellite) {