Browse Source

地图创建区域需要与绘画组件融合

master
DIAMOND 1 year ago
parent
commit
7cfc07c70e
  1. 14
      src/components/earthMap/Toolbar.vue
  2. 174
      src/components/earthMap/toolbar/AddModelWin.vue
  3. 32
      src/components/earthMap/toolbar/DrawShape.vue
  4. 11
      src/components/earthMap/toolbar/DrawShapeMilitary.vue

14
src/components/earthMap/Toolbar.vue

@ -95,7 +95,7 @@
<KeyControlAreaList v-if="keyControlAreaListShow"></KeyControlAreaList> <KeyControlAreaList v-if="keyControlAreaListShow"></KeyControlAreaList>
<NotificationModel v-if="notificationModelShow"></NotificationModel> <NotificationModel v-if="notificationModelShow"></NotificationModel>
<WarnList v-if="WarnListShow"></WarnList> <WarnList v-if="WarnListShow"></WarnList>
<DrawShape v-if="drawShapeShow"></DrawShape> <DrawShape v-if="drawShapeShow" :drawShapePackage="drawShapePackage"></DrawShape>
<DrawShapeMilitary v-if="drawShapeMilitaryShow"></DrawShapeMilitary> <DrawShapeMilitary v-if="drawShapeMilitaryShow"></DrawShapeMilitary>
</div> </div>
</template> </template>
@ -131,6 +131,7 @@
import { defHttp } from '/@/utils/http/axios'; import { defHttp } from '/@/utils/http/axios';
import $ from 'jquery'; import $ from 'jquery';
import { useUserStore } from '/@/store/modules/user'; import { useUserStore } from '/@/store/modules/user';
import { useMessage } from '/@/hooks/web/useMessage';
import TestCom from './TestCom.vue'; import TestCom from './TestCom.vue';
@ -154,6 +155,7 @@
const { proxy }: any = getCurrentInstance(); const { proxy }: any = getCurrentInstance();
// const { userInfo } = useUserStore(); // const { userInfo } = useUserStore();
const userStore = useUserStore(); const userStore = useUserStore();
const { createMessage } = useMessage();
let _viewer = ref(); let _viewer = ref();
let show = ref(true); let show = ref(true);
let modalVisible = ref(false); let modalVisible = ref(false);
@ -179,6 +181,7 @@
const notificationModelShow = ref(false); const notificationModelShow = ref(false);
const WarnListShow = ref(false); const WarnListShow = ref(false);
const drawShapeShow = ref(false); const drawShapeShow = ref(false);
const drawShapePackage = ref(null);
const drawShapeMilitaryShow = ref(false); const drawShapeMilitaryShow = ref(false);
// //
@ -235,6 +238,11 @@
$mitt.on('warnInfoMan', function () { $mitt.on('warnInfoMan', function () {
warnInfoMan(); warnInfoMan();
}); });
//res.show,res
$mitt.on('drawShapeShow', function (res:any) {
drawShapeShow.value = res.show;
drawShapePackage.value = res
});
} }
// //
//disposers //disposers
@ -946,6 +954,8 @@
// //
function drawShape() { function drawShape() {
//
drawShapePackage.value = null
drawShapeShow.value = !drawShapeShow.value; drawShapeShow.value = !drawShapeShow.value;
} }
//- //-
@ -1019,7 +1029,6 @@
// $mitt.emit('windowCancel') // $mitt.emit('windowCancel')
// com = addModelWin // com = addModelWin
// console.log("proxy"); // console.log("proxy");
addModelWinShow.value = true; addModelWinShow.value = true;
break; break;
case 'roamPathList': case 'roamPathList':
@ -1138,6 +1147,7 @@
notificationModelShow, notificationModelShow,
WarnListShow, WarnListShow,
drawShapeShow, drawShapeShow,
drawShapePackage,
drawShapeMilitaryShow, drawShapeMilitaryShow,
drawShapeMilitaryIMG, drawShapeMilitaryIMG,
test, test,

174
src/components/earthMap/toolbar/AddModelWin.vue

@ -1,18 +1,7 @@
<template> <template>
<div class="create-model-modal" v-if="winVisible"> <div class="create-model-modal" v-if="winVisible">
<Window <Window :title="title" @cancel="cancel" @ok="ok" :width="width" :minWidth="600" :height="height" :left="left"
:title="title" :top="top" :floatright="false" :footervisible="true" v-show="!creating">
@cancel="cancel"
@ok="ok"
:width="width"
:minWidth="600"
:height="height"
:left="left"
:top="top"
:floatright="false"
:footervisible="true"
v-show="!creating"
>
<div style="display: flex" class="custom-item" v-if="!isUpdateModel"> <div style="display: flex" class="custom-item" v-if="!isUpdateModel">
<label class="custom-label">模型类型:</label> <label class="custom-label">模型类型:</label>
<div class="custom-item-box"> <div class="custom-item-box">
@ -23,7 +12,8 @@
<div style="display: flex" class="custom-item"> <div style="display: flex" class="custom-item">
<label class="custom-label">名称:</label> <label class="custom-label">名称:</label>
<div class="custom-item-box"> <div class="custom-item-box">
<input v-model="name" class="name-input" style="height: 90%; width: 100%" @change="nameChange(currentModel)" /> <input v-model="name" class="name-input" style="height: 90%; width: 100%"
@change="nameChange(currentModel)" />
</div> </div>
</div> </div>
<div style="display: flex" class="custom-item"> <div style="display: flex" class="custom-item">
@ -38,14 +28,8 @@
<!-- <XbsjSlider style="margin-top: 16px" :min="0" :max="256" :step="1" showTip="always" <!-- <XbsjSlider style="margin-top: 16px" :min="0" :max="256" :step="1" showTip="always"
v-model="minimumPixelSize"> v-model="minimumPixelSize">
</XbsjSlider> --> </XbsjSlider> -->
<a-slider <a-slider v-model:value="minimumPixelSize" :min="0" :max="256" :step="1" :tooltipVisible="true"
v-model:value="minimumPixelSize" v-if="currentModel && currentModel.xbsjType == 'Model'" />
:min="0"
:max="256"
:step="1"
:tooltipVisible="true"
v-if="currentModel && currentModel.xbsjType == 'Model'"
/>
</div> </div>
</div> </div>
<div style="display: flex" class="custom-item"> <div style="display: flex" class="custom-item">
@ -71,28 +55,19 @@
</div> </div>
</div> </div>
<div style="display: flex; align-items: center; justify-content: center" class="custom-item"> <div style="display: flex; align-items: center; justify-content: center" class="custom-item">
<button <button @click="modelState('creating')"
@click="modelState('creating')" :class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" :disabled="creating"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" style="width: 20%">
:disabled="creating"
style="width: 20%"
>
拾取 拾取
</button> </button>
<button <button @click="currentModel.positionEditing = true"
@click="currentModel.positionEditing = true" :class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" :disabled="creating"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" style="width: 20%">
:disabled="creating"
style="width: 20%"
>
移动 移动
</button> </button>
<button <button @click="modelState('rotationEditing')"
@click="modelState('rotationEditing')"
:class="['xbsj-button', 'edit-model-btn', !currentModel || rotationEditing ? 'edit-model-btn-disable' : '']" :class="['xbsj-button', 'edit-model-btn', !currentModel || rotationEditing ? 'edit-model-btn-disable' : '']"
:disabled="rotationEditing" :disabled="rotationEditing" style="width: 20%">
style="width: 20%"
>
旋转 旋转
</button> </button>
</div> </div>
@ -101,7 +76,8 @@
<div style="display: flex" class="custom-item"> <div style="display: flex" class="custom-item">
<label class="custom-label">名称:</label> <label class="custom-label">名称:</label>
<div class="custom-item-box"> <div class="custom-item-box">
<input v-model="name" class="name-input" style="height: 90%; width: 100%" @change="nameChange(currentModel)" /> <input v-model="name" class="name-input" style="height: 90%; width: 100%"
@change="nameChange(currentModel)" />
</div> </div>
</div> </div>
<div style="display: flex" class="custom-item"> <div style="display: flex" class="custom-item">
@ -126,7 +102,8 @@
<label class="custom-label">上传图标:</label> <label class="custom-label">上传图标:</label>
<div class="custom-item-box"> <div class="custom-item-box">
<div class="upload-box"> <div class="upload-box">
<upload v-model:file="uploadFile" :pre-view-url="previewImgUrl" :isUpdateModel="isUpdateModel" ref="pinIconUpload" /> <upload v-model:file="uploadFile" :pre-view-url="previewImgUrl" :isUpdateModel="isUpdateModel"
ref="pinIconUpload" />
</div> </div>
</div> </div>
</div> </div>
@ -164,20 +141,14 @@
</div> </div>
</div> </div>
<div style="display: flex; justify-content: center" class="custom-item"> <div style="display: flex; justify-content: center" class="custom-item">
<button <button @click="modelState('creating')"
@click="modelState('creating')" :class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" :disabled="creating"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" style="width: 20%; display: flex; align-items: center; justify-content: center">
:disabled="creating"
style="width: 20%; display: flex; align-items: center; justify-content: center"
>
拾取 拾取
</button> </button>
<button <button @click="currentModel.editing = true"
@click="currentModel.editing = true" :class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" :disabled="creating"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" style="width: 20%; display: flex; align-items: center; justify-content: center">
:disabled="creating"
style="width: 20%; display: flex; align-items: center; justify-content: center"
>
移动 移动
</button> </button>
</div> </div>
@ -186,7 +157,8 @@
<div style="display: flex" class="custom-item"> <div style="display: flex" class="custom-item">
<label class="custom-label">名称:</label> <label class="custom-label">名称:</label>
<div class="custom-item-box"> <div class="custom-item-box">
<input v-model="name" class="name-input" style="height: 90%; width: 100%" @change="nameChange(currentModel)" /> <input v-model="name" class="name-input" style="height: 90%; width: 100%"
@change="nameChange(currentModel)" />
</div> </div>
</div> </div>
<div style="display: flex" class="custom-item"> <div style="display: flex" class="custom-item">
@ -211,7 +183,8 @@
<label class="custom-label">上传图标:</label> <label class="custom-label">上传图标:</label>
<div class="custom-item-box"> <div class="custom-item-box">
<div class="upload-box"> <div class="upload-box">
<upload v-model:file="uploadFile" :pre-view-url="previewImgUrl" :isUpdateModel="isUpdateModel" ref="pinIconUpload" /> <upload v-model:file="uploadFile" :pre-view-url="previewImgUrl" :isUpdateModel="isUpdateModel"
ref="pinIconUpload" />
</div> </div>
</div> </div>
</div> </div>
@ -225,20 +198,14 @@
</div> </div>
</div> </div>
<div style="display: flex; justify-content: center" class="custom-item"> <div style="display: flex; justify-content: center" class="custom-item">
<button <button @click="modelState('creating')"
@click="modelState('creating')" :class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" :disabled="creating"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" style="width: 20%; display: flex; align-items: center; justify-content: center">
:disabled="creating"
style="width: 20%; display: flex; align-items: center; justify-content: center"
>
拾取 拾取
</button> </button>
<button <button @click="currentModel.editing = true"
@click="currentModel.editing = true" :class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" :disabled="creating"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" style="width: 20%; display: flex; align-items: center; justify-content: center">
:disabled="creating"
style="width: 20%; display: flex; align-items: center; justify-content: center"
>
移动 移动
</button> </button>
</div> </div>
@ -259,6 +226,7 @@
import { defHttp } from '/@/utils/http/axios'; import { defHttp } from '/@/utils/http/axios';
// import mitt from '/@/utils/mitt'; // import mitt from '/@/utils/mitt';
import $mitt from '@/utils/earthMap/mitt'; import $mitt from '@/utils/earthMap/mitt';
import { useMessage } from '/@/hooks/web/useMessage';
import $ from 'jquery'; import $ from 'jquery';
import { addModel, addPin, addViewShed, addViewShedRadar } from '@/utils/earthMap/earthObj'; import { addModel, addPin, addViewShed, addViewShedRadar } from '@/utils/earthMap/earthObj';
export default defineComponent({ export default defineComponent({
@ -312,6 +280,7 @@
}, },
setup(props, ctx) { setup(props, ctx) {
const { proxy }: any = getCurrentInstance(); const { proxy }: any = getCurrentInstance();
const { createMessage } = useMessage();
// const $mitt = mitt(); // const $mitt = mitt();
const userStore = useUserStore(); const userStore = useUserStore();
@ -457,6 +426,10 @@
watch(selectModel, (newVal, oldVal) => { watch(selectModel, (newVal, oldVal) => {
// console.log("selectModel",newVal); // console.log("selectModel",newVal);
// debugger // debugger
/**
* 防止重复打开drawShape组件所以每次变更选项时都进行关闭操作
*/
$mitt.emit('drawShapeShow', { show: false })
// //
if (isUpdateModel.value) { if (isUpdateModel.value) {
return; return;
@ -491,7 +464,9 @@
currentModel.value = addModel(); currentModel.value = addModel();
// console.log(" currentModel.value", currentModel.value); // console.log(" currentModel.value", currentModel.value);
} else if (selectModel.value.value === 'qy') { } else if (selectModel.value.value === 'qy') {
currentModel.value = addPolyline();
currentModel.value = addArea();
// currentModel.value = addPolyline();
// console.log(" currentModel.value", currentModel.value); // console.log(" currentModel.value", currentModel.value);
} else { } else {
currentModel.value = addPin(); currentModel.value = addPin();
@ -550,7 +525,10 @@
onBeforeUnmount(() => { onBeforeUnmount(() => {
// mitt // mitt
$mitt.emit('drawShapeShow', { show: false })
$mitt.off('windowCancel'); $mitt.off('windowCancel');
$mitt.off('addAreaFinished');
}); });
// //
function cancel() { function cancel() {
@ -718,11 +696,67 @@
} }
// //
function addPolyline() { /**
* @abstract 需要调用 drawShape组件 进行绘图提取当中的坐标点position
* 处理完数据再使用 addPolyline方法 window.XE.Obj.Polyline 创建线段
*
* @abstract
* $mitt.emit('drawShapeShow') 打开drawShape组件显示
* @abstract
* $mitt.emit('addAreaFinished') 接受传回来的临时图形
*/
function addArea() {
$mitt.emit('drawShapeShow', { show: true, title: '创建区域工具', from: 'addArea' })
$mitt.on("addAreaFinished", (t: any) => {
console.log("addAreaFinished", t);
//t drawShape
t.creating = true;
// t
window.XE.MVVM.watch(t, 'creating', (n: any) => {
console.log("creating", n);
if (n == false) {
//
let positions: any = []
if (t._polygon) {
positions = t._polygon._polyline.positions
}
//线
else if (t._polyline) {
positions = t._polyline.positions
}
else {
positions = t.positions
// console.error("");
}
//
t.destroy()
/**
* 控制时序处理完数据再调用方法 addPolyline
* 否则会出现在数据滞后在图形创建时导致数据错误
*
*/
nextTick(() => { addPolyline(positions); })
}
})
})
}
/**
* @params 需要调用 addArea 方法进行绘图获取坐标点position
*/
function addPolyline(positions: any = null) {
// //
cancel(); cancel();
// //
const currentModel = new window.XE.Obj.Polyline(window.$earth); const currentModel = new window.XE.Obj.Polyline(window.$earth);
//
const objConfig = {
positions: positions,
}
//
currentModel.xbsjFromJSON(objConfig);
console.log("currentModel", currentModel);
// ui // ui
const earthUI = window.$uia; const earthUI = window.$uia;
// ui // ui
@ -1473,6 +1507,7 @@
bindPinProps, bindPinProps,
addPin, addPin,
addPolyline, addPolyline,
addArea,
modelState, modelState,
submitModel, submitModel,
nameChange, nameChange,
@ -1550,6 +1585,7 @@
.object-box { .object-box {
width: 100%; width: 100%;
height: 86%; height: 86%;
label { label {
color: #ffffff; color: #ffffff;
} }

32
src/components/earthMap/toolbar/DrawShape.vue

@ -15,6 +15,9 @@
</template> </template>
<a-collapse-panel key="1" header="线" :style="customStyle"> <a-collapse-panel key="1" header="线" :style="customStyle">
<div class="toolBoxImg"> <div class="toolBoxImg">
<p class="tb-img-p" title="实线" @click="draw('Polyline')">
<img :src="solidLine" alt="实线" />
</p>
<p class="tb-img-p" title="圆弧" @click="draw('GeoArc')"> <p class="tb-img-p" title="圆弧" @click="draw('GeoArc')">
<img :src="arc" alt="圆弧" /> <img :src="arc" alt="圆弧" />
</p> </p>
@ -30,9 +33,7 @@
<!-- <p class="tb-img-p" title="曲线箭头" @click="drawCurveArrow"> <!-- <p class="tb-img-p" title="曲线箭头" @click="drawCurveArrow">
<img :src="curveArrow" alt="曲线箭头" /> <img :src="curveArrow" alt="曲线箭头" />
</p> --> </p> -->
<p class="tb-img-p" title="实线" @click="draw('Polyline')">
<img :src="solidLine" alt="实线" />
</p>
</div> </div>
</a-collapse-panel> </a-collapse-panel>
<a-collapse-panel key="2" header="面" :style="customStyle"> <a-collapse-panel key="2" header="面" :style="customStyle">
@ -227,6 +228,10 @@ const props = defineProps({
type: Boolean, type: Boolean,
default: false, default: false,
}, },
drawShapePackage: {
type: Object,
default: null,
},
}); });
const { proxy }: any = getCurrentInstance(); const { proxy }: any = getCurrentInstance();
@ -237,6 +242,19 @@ const activeKey = ref(['1', '2']);
const customStyle = 'background: rgb(255 255 255 / 0%);border-radius: 4px;border: 0;overflow: hidden'; const customStyle = 'background: rgb(255 255 255 / 0%);border-radius: 4px;border: 0;overflow: hidden';
const earthUI = window.$uia // ui const earthUI = window.$uia // ui
let title = ref(props.title)
onMounted(() => {
//
if (props.drawShapePackage != null) {
console.log("绘画组件正在调用", props.drawShapePackage);
if (props.drawShapePackage.title != null)
//title
title.value = props.drawShapePackage.title
}
})
function draw(type: String = '') { function draw(type: String = '') {
let t = null let t = null
switch (type) { switch (type) {
@ -304,6 +322,14 @@ function draw(type: String = '') {
console.log("错误"); console.log("错误");
break; break;
} }
// t
if (props.drawShapePackage &&
props.drawShapePackage.from &&
props.drawShapePackage.from == 'addArea') {
$mitt.emit('addAreaFinished', t)
return
}
else
return editUI(t) return editUI(t)
} }

11
src/components/earthMap/toolbar/DrawShapeMilitary.vue

@ -40,9 +40,14 @@
<p class="tb-img-p" title="曲线箭头" @click="draw('GeoCurveArrow')"> <p class="tb-img-p" title="曲线箭头" @click="draw('GeoCurveArrow')">
<img :src="curveArrow" alt="曲线箭头" /> <img :src="curveArrow" alt="曲线箭头" />
</p> </p>
<p class="tb-img-p" title="单次箭头" @click="draw('GeoSimpleArrow')"> <!-- //
/**
* 报错Reaction doesn't converge to a stable state after 100 iterations.
* Probably there is a cycle in the reactive function: Reaction
/ -->
<!-- <p class="tb-img-p" title="单次箭头" @click="draw('GeoSimpleArrow')">
<img :src="simpleArrow" alt="单次箭头" /> <img :src="simpleArrow" alt="单次箭头" />
</p> </p> -->
<p class="tb-img-p" title="平尾箭头" @click="draw('GeoArrow')"> <p class="tb-img-p" title="平尾箭头" @click="draw('GeoArrow')">
<img :src="flatArrow" alt="平尾箭头" /> <img :src="flatArrow" alt="平尾箭头" />
</p> </p>
@ -394,8 +399,10 @@ function saveInStore(obj: any) {
function editUI(obj: any, objConfig: any = null) { function editUI(obj: any, objConfig: any = null) {
console.log("obj", obj); console.log("obj", obj);
obj.creating = true; obj.creating = true;
// if (obj.showType == "forkedTail") return
earthUI.showPropertyWindow(obj) earthUI.showPropertyWindow(obj)
nextTick(() => { nextTick(() => {
// ui // ui
const mainUI = earthUI._vm.$refs.mainUI const mainUI = earthUI._vm.$refs.mainUI
// uiRef // uiRef

Loading…
Cancel
Save