diff --git a/ruoyi-ui/src/views/cesiumMap/DrawingToolbar.vue b/ruoyi-ui/src/views/cesiumMap/DrawingToolbar.vue index dcced8d..58d3b46 100644 --- a/ruoyi-ui/src/views/cesiumMap/DrawingToolbar.vue +++ b/ruoyi-ui/src/views/cesiumMap/DrawingToolbar.vue @@ -45,9 +45,6 @@ export default { { id: 'polygon', name: '面', icon: 'el-icon-house' }, { id: 'rectangle', name: '矩形', icon: 'jx' }, { id: 'circle', name: '圆形', icon: 'circle' }, - { id: 'ellipse', name: '椭圆', icon: 'el-icon-oval' }, - { id: 'hold_circle', name: '圆形盘旋', icon: 'circle' }, - { id: 'hold_ellipse', name: '椭圆盘旋', icon: 'el-icon-oval' }, { id: 'sector', name: '扇形', icon: 'sx' }, { id: 'arrow', name: '箭头', icon: 'el-icon-right' }, { id: 'text', name: '文本', icon: 'el-icon-document' }, diff --git a/ruoyi-ui/src/views/cesiumMap/index.vue b/ruoyi-ui/src/views/cesiumMap/index.vue index 20b8e6c..552d41d 100644 --- a/ruoyi-ui/src/views/cesiumMap/index.vue +++ b/ruoyi-ui/src/views/cesiumMap/index.vue @@ -132,7 +132,6 @@ export default { isDrawing: false, missionHoldParamsByIndex: {}, missionPendingHold: null, - missionInitialHoldParams: null, tempHoldEntity: null, activeCursorPosition: null, // 实时鼠标位置 // 实体管理 @@ -160,9 +159,6 @@ export default { polygon: { color: '#0000FF', opacity: 0.5, width: 2 }, rectangle: { color: '#FFA500', opacity: 0.3, width: 2 }, circle: { color: '#800080', opacity: 0.4, width: 2 }, - ellipse: { color: '#008080', opacity: 0.4, width: 2 }, - hold_circle: { color: '#00BFFF', width: 2 }, - hold_ellipse: { color: '#00BFFF', width: 2 }, sector: { color: '#FF6347', opacity: 0.5, width: 2 }, arrow: { color: '#FF0000', width: 6 }, text: { color: '#000000', font: '48px Microsoft YaHei, PingFang SC, sans-serif', backgroundColor: 'rgba(255, 255, 255, 0.8)' }, @@ -384,7 +380,6 @@ export default { this.drawingPoints = []; this.missionHoldParamsByIndex = {}; this.missionPendingHold = null; - this.missionInitialHoldParams = null; let activeCursorPosition = null; this.isDrawing = true; this.viewer.canvas.style.cursor = 'crosshair'; @@ -402,22 +397,6 @@ export default { const position = this.getClickPosition(click.position); if (!position) return; this.drawingPoints.push(position); - if (this.missionInitialHoldParams && this.drawingPoints.length === 2) { - this.missionPendingHold = { - beforeIndex: 1, - center: Cesium.Cartesian3.clone(this.drawingPoints[0]), - params: this.missionInitialHoldParams - }; - this.missionInitialHoldParams = null; - if (this.tempHoldEntity) { try { this.viewer.entities.remove(this.tempHoldEntity); } catch (e) {} this.tempHoldEntity = null; } - this.tempHoldEntity = this.viewer.entities.add({ - id: 'temp_hold_preview', - name: 'HOLD', - position: this.missionPendingHold.center, - point: { pixelSize: 10, color: Cesium.Color.ORANGE, outlineColor: Cesium.Color.WHITE, outlineWidth: 2, disableDepthTestDistance: Number.POSITIVE_INFINITY }, - label: { text: 'HOLD', font: '12px MicroSoft YaHei', fillColor: Cesium.Color.ORANGE, outlineColor: Cesium.Color.BLACK, outlineWidth: 2 } - }); - } const wpIndex = this.drawingPoints.length; this.$emit('drawing-points-update', this.drawingPoints.length); // 绘制业务航点 @@ -552,11 +531,6 @@ export default { return (this.drawingPoints && this.drawingPoints.length) || 0; }, - /** 方式一:先画盘旋再画航线。在开始航线绘制后、用户点击第一个点作为盘旋中心,第二个点后自动插入该盘旋 */ - setInitialHoldParams(holdParams) { - this.missionInitialHoldParams = holdParams; - }, - // 格式化平台图标 URL(与 RouteEditDialog / RightPanel 一致) formatPlatformIconUrl(url) { if (!url) return ''; @@ -1569,15 +1543,6 @@ export default { case 'circle': this.startCircleDrawing() break - case 'ellipse': - this.startEllipseDrawing() - break - case 'hold_circle': - this.startHoldCircleDrawing() - break - case 'hold_ellipse': - this.startHoldEllipseDrawing() - break case 'sector': this.startSectorDrawing() break @@ -1619,7 +1584,6 @@ export default { this.tempHoldEntity = null; } this.missionPendingHold = null; - this.missionInitialHoldParams = null; this.missionHoldParamsByIndex = {}; //清理已知的预览实体 if (this.tempEntity) { @@ -2226,89 +2190,6 @@ export default { this.drawingPoints = []; this.activeCursorPosition = null; }, - // 绘制椭圆:三点(圆心、长轴端点、短轴端点) - startEllipseDrawing() { - this.drawingPoints = []; - this.activeCursorPosition = null; - if (this.tempEntity) { this.viewer.entities.remove(this.tempEntity); this.tempEntity = null; } - if (this.tempPreviewEntity) { this.viewer.entities.remove(this.tempPreviewEntity); this.tempPreviewEntity = null; } - this.drawingHandler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE); - this.drawingHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); - this.drawingHandler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK); - this.drawingHandler.setInputAction((movement) => { - const newPosition = this.getClickPosition(movement.endPosition); - if (newPosition) this.activeCursorPosition = newPosition; - }, Cesium.ScreenSpaceEventType.MOUSE_MOVE); - this.drawingHandler.setInputAction((click) => { - const position = this.getClickPosition(click.position); - if (!position) return; - this.drawingPoints.push(position); - if (this.drawingPoints.length === 1) { - this.activeCursorPosition = position; - this.tempEntity = this.viewer.entities.add({ - position: position, - ellipse: { - semiMajorAxis: new Cesium.CallbackProperty(() => { - let a = 100; - let b = 50; - if (this.drawingPoints.length >= 2 && this.drawingPoints[0] && this.drawingPoints[1]) { - a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.drawingPoints[1]), 50); - } else if (this.activeCursorPosition && this.drawingPoints.length === 1) { - a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.activeCursorPosition), 50); - } - if (this.drawingPoints.length >= 3 && this.drawingPoints[0] && this.drawingPoints[1] && this.drawingPoints[2]) { - b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.drawingPoints[2]), 20); - } else if (this.drawingPoints.length >= 2 && this.activeCursorPosition) { - b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.activeCursorPosition), 20); - } - return Math.max(a, b); - }, false), - semiMinorAxis: new Cesium.CallbackProperty(() => { - let a = 100; - let b = 50; - if (this.drawingPoints.length >= 2 && this.drawingPoints[0] && this.drawingPoints[1]) { - a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.drawingPoints[1]), 50); - } else if (this.activeCursorPosition && this.drawingPoints.length === 1) { - a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.activeCursorPosition), 50); - } - if (this.drawingPoints.length >= 3 && this.drawingPoints[0] && this.drawingPoints[1] && this.drawingPoints[2]) { - b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.drawingPoints[2]), 20); - } else if (this.drawingPoints.length >= 2 && this.activeCursorPosition) { - b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.activeCursorPosition), 20); - } - return Math.min(a, b); - }, false), - rotation: new Cesium.CallbackProperty(() => { - if (this.drawingPoints.length >= 2 && this.drawingPoints[0] && this.drawingPoints[1]) { - let heading = this.ellipseHeadingFromCenterAndMajor(this.drawingPoints[0], this.drawingPoints[1]); - let a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.drawingPoints[1]), 50); - let b = 50; - if (this.drawingPoints.length >= 3 && this.drawingPoints[2]) { - b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.drawingPoints[2]), 20); - } else if (this.activeCursorPosition) { - b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.activeCursorPosition), 20); - } - if (b > a) heading += Math.PI / 2; - return heading; - } - return 0; - }, false), - material: Cesium.Color.fromCssColorString(this.defaultStyles.ellipse.color).withAlpha(0.5), - outline: true, - outlineColor: Cesium.Color.fromCssColorString(this.defaultStyles.ellipse.color), - outlineWidth: 2 - } - }); - } else if (this.drawingPoints.length === 2) { - this.activeCursorPosition = this.drawingPoints[1]; - } else if (this.drawingPoints.length === 3) { - this.activeCursorPosition = null; - if (this.tempEntity) { this.viewer.entities.remove(this.tempEntity); this.tempEntity = null; } - this.finishEllipseDrawing(); - } - }, Cesium.ScreenSpaceEventType.LEFT_CLICK); - this.drawingHandler.setInputAction(() => this.cancelDrawing(), Cesium.ScreenSpaceEventType.RIGHT_CLICK); - }, ellipseHeadingFromCenterAndMajor(center, majorEnd) { const ellipsoid = this.viewer.scene.globe.ellipsoid; const enu = Cesium.Transforms.eastNorthUpToFixedFrame(center); @@ -2330,261 +2211,6 @@ export default { const minorComponent = -e3 * Math.sin(heading) + n3 * Math.cos(heading); return Math.abs(minorComponent); }, - finishEllipseDrawing() { - const center = this.drawingPoints[0]; - const majorEnd = this.drawingPoints[1]; - const third = this.drawingPoints[2]; - let a = Math.max(Cesium.Cartesian3.distance(center, majorEnd), 50); - let b = Math.max(this.ellipseSemiMinorFromThreePoints(center, majorEnd, third), 20); - let heading = this.ellipseHeadingFromCenterAndMajor(center, majorEnd); - if (b > a) { - [a, b] = [b, a]; - heading += Math.PI / 2; - } - const semiMajor = a; - const semiMinor = b; - this.entityCounter++; - const id = `ellipse_${this.entityCounter}`; - const entity = this.viewer.entities.add({ - id, - name: `椭圆 ${this.entityCounter}`, - position: center, - ellipse: { - semiMajorAxis: semiMajor, - semiMinorAxis: semiMinor, - rotation: heading, - material: Cesium.Color.fromCssColorString(this.defaultStyles.ellipse.color).withAlpha(this.defaultStyles.ellipse.opacity), - outline: true, - outlineColor: Cesium.Color.fromCssColorString(this.defaultStyles.ellipse.color), - outlineWidth: this.defaultStyles.ellipse.width - } - }); - const entityData = { - id, - type: 'ellipse', - points: this.drawingPoints.map(p => this.cartesianToLatLng(p)), - positions: [...this.drawingPoints], - entity, - semiMajorAxis: semiMajor, - semiMinorAxis: semiMinor, - headingDeg: (heading * 180 / Math.PI), - color: this.defaultStyles.ellipse.color, - opacity: this.defaultStyles.ellipse.opacity, - width: this.defaultStyles.ellipse.width, - label: `椭圆 ${this.entityCounter}` - }; - this.allEntities.push(entityData); - this.measurementResult = { type: 'ellipse', semiMajorAxis: semiMajor, semiMinorAxis: semiMinor, area: Math.PI * semiMajor * semiMinor }; - this.drawingPoints = []; - this.activeCursorPosition = null; - }, - // 圆形盘旋:仅边框、不填充,交互与圆一致(圆心 + 边缘点) - startHoldCircleDrawing() { - this.drawingPoints = []; - this.activeCursorPosition = null; - if (this.tempEntity) { this.viewer.entities.remove(this.tempEntity); this.tempEntity = null; } - if (this.tempPreviewEntity) { this.viewer.entities.remove(this.tempPreviewEntity); this.tempPreviewEntity = null; } - const initialRadius = 100; - this.drawingHandler.setInputAction((movement) => { - const newPosition = this.getClickPosition(movement.endPosition); - if (newPosition) this.activeCursorPosition = newPosition; - }, Cesium.ScreenSpaceEventType.MOUSE_MOVE); - this.drawingHandler.setInputAction((click) => { - const position = this.getClickPosition(click.position); - if (!position) return; - if (this.drawingPoints.length === 0) { - this.drawingPoints.push(position); - this.activeCursorPosition = position; - this.tempEntity = this.viewer.entities.add({ - position: position, - ellipse: { - semiMajorAxis: new Cesium.CallbackProperty(() => { - if (this.activeCursorPosition && this.drawingPoints[0]) { - const d = Cesium.Cartesian3.distance(this.drawingPoints[0], this.activeCursorPosition); - return isFinite(d) && d > 0 ? d : initialRadius; - } - return initialRadius; - }, false), - semiMinorAxis: new Cesium.CallbackProperty(() => { - if (this.activeCursorPosition && this.drawingPoints[0]) { - const d = Cesium.Cartesian3.distance(this.drawingPoints[0], this.activeCursorPosition); - return isFinite(d) && d > 0 ? d : initialRadius; - } - return initialRadius; - }, false), - material: Cesium.Color.TRANSPARENT, - outline: true, - outlineColor: Cesium.Color.fromCssColorString(this.defaultStyles.hold_circle.color), - outlineWidth: this.defaultStyles.hold_circle.width || 2 - } - }); - } else if (this.drawingPoints.length === 1) { - this.drawingPoints.push(position); - this.activeCursorPosition = null; - this.finishHoldCircleDrawing(position); - } - }, Cesium.ScreenSpaceEventType.LEFT_CLICK); - this.drawingHandler.setInputAction(() => this.cancelDrawing(), Cesium.ScreenSpaceEventType.RIGHT_CLICK); - }, - finishHoldCircleDrawing(edgePosition) { - const centerPoint = this.drawingPoints[0]; - const radius = Cesium.Cartesian3.distance(centerPoint, edgePosition); - if (this.tempEntity) { this.viewer.entities.remove(this.tempEntity); this.tempEntity = null; } - this.entityCounter++; - const id = `hold_circle_${this.entityCounter}`; - const finalEntity = this.viewer.entities.add({ - id, - position: centerPoint, - ellipse: { - semiMajorAxis: radius, - semiMinorAxis: radius, - material: Cesium.Color.TRANSPARENT, - outline: true, - outlineColor: Cesium.Color.fromCssColorString(this.defaultStyles.hold_circle.color), - outlineWidth: this.defaultStyles.hold_circle.width || 2 - } - }); - const entityData = { - id, - type: 'hold_circle', - points: [centerPoint, edgePosition].map(p => this.cartesianToLatLng(p)), - positions: [centerPoint, edgePosition], - entity: finalEntity, - color: this.defaultStyles.hold_circle.color, - width: this.defaultStyles.hold_circle.width || 2, - radius, - label: `圆形盘旋 ${this.entityCounter}` - }; - this.allEntities.push(entityData); - this.measurementResult = { type: 'hold_circle', radius, area: Math.PI * radius * radius }; - this.drawingPoints = []; - this.activeCursorPosition = null; - }, - // 椭圆盘旋:仅边框、不填充,交互与椭圆一致(圆心、长轴端点、短轴端点) - startHoldEllipseDrawing() { - this.drawingPoints = []; - this.activeCursorPosition = null; - if (this.tempEntity) { this.viewer.entities.remove(this.tempEntity); this.tempEntity = null; } - if (this.tempPreviewEntity) { this.viewer.entities.remove(this.tempPreviewEntity); this.tempPreviewEntity = null; } - this.drawingHandler.setInputAction((movement) => { - const newPosition = this.getClickPosition(movement.endPosition); - if (newPosition) this.activeCursorPosition = newPosition; - }, Cesium.ScreenSpaceEventType.MOUSE_MOVE); - this.drawingHandler.setInputAction((click) => { - const position = this.getClickPosition(click.position); - if (!position) return; - this.drawingPoints.push(position); - if (this.drawingPoints.length === 1) { - this.activeCursorPosition = position; - this.tempEntity = this.viewer.entities.add({ - position: position, - ellipse: { - semiMajorAxis: new Cesium.CallbackProperty(() => { - let a = 100, b = 50; - if (this.drawingPoints.length >= 2 && this.drawingPoints[0] && this.drawingPoints[1]) { - a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.drawingPoints[1]), 50); - } else if (this.activeCursorPosition && this.drawingPoints.length === 1) { - a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.activeCursorPosition), 50); - } - if (this.drawingPoints.length >= 3 && this.drawingPoints[0] && this.drawingPoints[1] && this.drawingPoints[2]) { - b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.drawingPoints[2]), 20); - } else if (this.drawingPoints.length >= 2 && this.activeCursorPosition) { - b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.activeCursorPosition), 20); - } - return Math.max(a, b); - }, false), - semiMinorAxis: new Cesium.CallbackProperty(() => { - let a = 100, b = 50; - if (this.drawingPoints.length >= 2 && this.drawingPoints[0] && this.drawingPoints[1]) { - a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.drawingPoints[1]), 50); - } else if (this.activeCursorPosition && this.drawingPoints.length === 1) { - a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.activeCursorPosition), 50); - } - if (this.drawingPoints.length >= 3 && this.drawingPoints[0] && this.drawingPoints[1] && this.drawingPoints[2]) { - b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.drawingPoints[2]), 20); - } else if (this.drawingPoints.length >= 2 && this.activeCursorPosition) { - b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.activeCursorPosition), 20); - } - return Math.min(a, b); - }, false), - rotation: new Cesium.CallbackProperty(() => { - if (this.drawingPoints.length >= 2 && this.drawingPoints[0] && this.drawingPoints[1]) { - let heading = this.ellipseHeadingFromCenterAndMajor(this.drawingPoints[0], this.drawingPoints[1]); - let a = Math.max(Cesium.Cartesian3.distance(this.drawingPoints[0], this.drawingPoints[1]), 50); - let b = 50; - if (this.drawingPoints.length >= 3 && this.drawingPoints[2]) { - b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.drawingPoints[2]), 20); - } else if (this.activeCursorPosition) { - b = Math.max(this.ellipseSemiMinorFromThreePoints(this.drawingPoints[0], this.drawingPoints[1], this.activeCursorPosition), 20); - } - if (b > a) heading += Math.PI / 2; - return heading; - } - return 0; - }, false), - material: Cesium.Color.TRANSPARENT, - outline: true, - outlineColor: Cesium.Color.fromCssColorString(this.defaultStyles.hold_ellipse.color), - outlineWidth: this.defaultStyles.hold_ellipse.width || 2 - } - }); - } else if (this.drawingPoints.length === 2) { - this.activeCursorPosition = this.drawingPoints[1]; - } else if (this.drawingPoints.length === 3) { - this.activeCursorPosition = null; - if (this.tempEntity) { this.viewer.entities.remove(this.tempEntity); this.tempEntity = null; } - this.finishHoldEllipseDrawing(); - } - }, Cesium.ScreenSpaceEventType.LEFT_CLICK); - this.drawingHandler.setInputAction(() => this.cancelDrawing(), Cesium.ScreenSpaceEventType.RIGHT_CLICK); - }, - finishHoldEllipseDrawing() { - const center = this.drawingPoints[0]; - const majorEnd = this.drawingPoints[1]; - const third = this.drawingPoints[2]; - let a = Math.max(Cesium.Cartesian3.distance(center, majorEnd), 50); - let b = Math.max(this.ellipseSemiMinorFromThreePoints(center, majorEnd, third), 20); - let heading = this.ellipseHeadingFromCenterAndMajor(center, majorEnd); - if (b > a) { - [a, b] = [b, a]; - heading += Math.PI / 2; - } - const semiMajor = a; - const semiMinor = b; - this.entityCounter++; - const id = `hold_ellipse_${this.entityCounter}`; - const entity = this.viewer.entities.add({ - id, - name: `椭圆盘旋 ${this.entityCounter}`, - position: center, - ellipse: { - semiMajorAxis: semiMajor, - semiMinorAxis: semiMinor, - rotation: heading, - material: Cesium.Color.TRANSPARENT, - outline: true, - outlineColor: Cesium.Color.fromCssColorString(this.defaultStyles.hold_ellipse.color), - outlineWidth: this.defaultStyles.hold_ellipse.width || 2 - } - }); - const entityData = { - id, - type: 'hold_ellipse', - points: this.drawingPoints.map(p => this.cartesianToLatLng(p)), - positions: [...this.drawingPoints], - entity, - semiMajorAxis: semiMajor, - semiMinorAxis: semiMinor, - headingDeg: (heading * 180 / Math.PI), - color: this.defaultStyles.hold_ellipse.color, - width: this.defaultStyles.hold_ellipse.width || 2, - label: `椭圆盘旋 ${this.entityCounter}` - }; - this.allEntities.push(entityData); - this.measurementResult = { type: 'hold_ellipse', semiMajorAxis: semiMajor, semiMinorAxis: semiMinor, area: Math.PI * semiMajor * semiMinor }; - this.drawingPoints = []; - this.activeCursorPosition = null; - }, // 绘制扇形 startSectorDrawing() { // 重置绘制状态 diff --git a/ruoyi-ui/src/views/childRoom/RightPanel.vue b/ruoyi-ui/src/views/childRoom/RightPanel.vue index 1f3a46b..3187dc1 100644 --- a/ruoyi-ui/src/views/childRoom/RightPanel.vue +++ b/ruoyi-ui/src/views/childRoom/RightPanel.vue @@ -42,7 +42,6 @@