@@ -341,6 +341,9 @@ export default {
updateEditSelectAsset(selsetAsset,selectData){
console.log(selectData);
if(this.nowSelect != null){
+ if(selsetAsset == "clear"){
+
+ }
if(selectData.fileType == "model"){
if(selsetAsset == "sceneEdit"){
this.sceneAssetList[this.nowSelect].id = selectData.id;
diff --git a/src/views/jlmap3d/edit/component/assets.vue b/src/views/jlmap3d/edit/component/assets.vue
index f5d7f2383..4bb3fac9e 100644
--- a/src/views/jlmap3d/edit/component/assets.vue
+++ b/src/views/jlmap3d/edit/component/assets.vue
@@ -20,7 +20,7 @@
-
+
@@ -175,6 +175,9 @@ export default {
// this.$emit('smodel',this.modelList[index]);
updateEditSelectAsset(this.nowAssetName,this.nowAssetList[index]);
},
+ clearModel(){
+ updateEditSelectAsset("clear");
+ },
//刷新资源库显示
updateAssetList(newdata,newtype){
console.log(newdata);
From 901fa60bc42916d23d9f3f9e68eb00c6b31261fe Mon Sep 17 00:00:00 2001
From: zyy <1787816799@qq.com>
Date: Fri, 18 Dec 2020 15:37:35 +0800
Subject: [PATCH 5/5] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=81=93=E5=B2=94?=
=?UTF-8?q?=E7=94=9F=E6=88=90=E6=B5=81=E7=A8=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/jmapNew/shape/Section/index.js | 4 +-
.../newMapdraft/mapoperate/section/index.vue | 5 +-
.../newMapdraft/mapoperate/switch/create.vue | 287 +++++++++++++++---
3 files changed, 256 insertions(+), 40 deletions(-)
diff --git a/src/jmapNew/shape/Section/index.js b/src/jmapNew/shape/Section/index.js
index c90bf65ba..09daa9ba4 100644
--- a/src/jmapNew/shape/Section/index.js
+++ b/src/jmapNew/shape/Section/index.js
@@ -246,12 +246,12 @@ export default class Section extends Group {
// 哈尔滨线路 道岔相关区段设置 默认颜色
if (this.style.Switch.sectionAction.flag && model.relSwitchCode && !flag) {
const switchModel = Vue.prototype.$jlmap.mapDevice[model.relSwitchCode];
- if (switchModel.normalPosition != 0) { // 定位情况
+ if (switchModel && switchModel.normalPosition != 0) { // 定位情况
const sectionC = Vue.prototype.$jlmap.mapDevice[switchModel.sectionCCode];
sectionC && sectionC.instance && sectionC.instance.line.setStyle({ stroke: this.style.Switch.sectionAction.spareColor });
const sectionB = Vue.prototype.$jlmap.mapDevice[switchModel.sectionBCode];
sectionB && sectionB.instance && sectionB.instance.setState(sectionB, true);
- } else if (switchModel.normalPosition == 0) { // 反位情况
+ } else if (switchModel && switchModel.normalPosition == 0) { // 反位情况
const sectionB = Vue.prototype.$jlmap.mapDevice[switchModel.sectionBCode];
sectionB && sectionB.instance && sectionB.instance.line.setStyle({ stroke: this.style.Switch.sectionAction.spareColor });
const sectionC = Vue.prototype.$jlmap.mapDevice[switchModel.sectionCCode];
diff --git a/src/views/newMap/newMapdraft/mapoperate/section/index.vue b/src/views/newMap/newMapdraft/mapoperate/section/index.vue
index 3cc9ff847..744d487e9 100644
--- a/src/views/newMap/newMapdraft/mapoperate/section/index.vue
+++ b/src/views/newMap/newMapdraft/mapoperate/section/index.vue
@@ -501,10 +501,7 @@ export default {
model.rightStopPointOffset = model.rightStopPointOffset || model.lengthFact - 5;
}
const changeSectionList = this.handleOtherSectionChange(model);
- // let changeStandList = [];
- // if (this.editModel.stationCode != this.selected.stationCode) { // 优化
const changeStandList = this.handleRelevanceStand(model);
- // }
models = [...changeSectionList, ...changeStandList];
this.$emit('updateMapModel', models);
@@ -512,8 +509,10 @@ export default {
this.oldLeftSectionCode = model.leftSectionCode;
this.oldRightSectionCode = model.rightSectionCode;
this.field = '';
+ this.$emit('deviceSelect', ''); // 清空属性
} else {
this.$message('还有属性未填写,修改未生效!');
+ this.$emit('deviceSelect', '');
}
});
},
diff --git a/src/views/newMap/newMapdraft/mapoperate/switch/create.vue b/src/views/newMap/newMapdraft/mapoperate/switch/create.vue
index 832eb1a4b..99abca947 100644
--- a/src/views/newMap/newMapdraft/mapoperate/switch/create.vue
+++ b/src/views/newMap/newMapdraft/mapoperate/switch/create.vue
@@ -23,6 +23,8 @@ export default {
methods:{
create() { // 一键生成道岔
const createArr = []; // 创建model列表
+ // const changeSectionLists = [];
+ // const changeSectionList = this.changeSectionsAttr(); // 找道岔中心点
const changeSectionList = this.changeSectionAttr(); // 找道岔中心点
changeSectionList.forEach(section => {
if (section['typeModel'] && section['typeModel'] == 'start') { // 右侧关联关系为空 且 道岔区段
@@ -35,7 +37,7 @@ export default {
if (this.handleResetPoint(item.points)) {
sectionEnd = item.points[item.points.length - 1];
} else {
- sectionEnd = item.points[0];
+ sectionEnd = item.points.length == 2 ? item.points[0] : item.points[item.points.length - 2];
}
if ((sectionEnd.y == section.points[section.points.length - 1].y) || (sectionEnd.x == section.points[section.points.length - 1].x)) { // 是否水平拿第二个点判断
sectionB = item;
@@ -50,13 +52,13 @@ export default {
if (this.handleResetPoint(section.points)) {
intersection = section.points[section.points.length - 1];
} else {
- intersection = section.points[0];
+ intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 2];
}
let skew;
if (this.handleResetPoint(sectionC.points)) {
skew = sectionC.points[sectionC.points.length - 1];
} else {
- skew = sectionC.points[0];
+ skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2];
}
const data = {
code: getUID('W', [...this.switchList, ...createArr]),
@@ -91,7 +93,7 @@ export default {
list.forEach(item => {
let sectionStart;
if (this.handleResetPoint(item.points)) {
- sectionStart = item.points[0];
+ sectionStart = item.points.length == 2 ? item.points[0] : item.points[item.points.length - 2];
} else {
sectionStart = item.points[item.points.length - 1];
}
@@ -106,13 +108,13 @@ export default {
const switchModel = getModel('Switch');
let intersection;
if (this.handleResetPoint(section.points)) {
- intersection = section.points[0];
+ intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 2];
} else {
intersection = section.points[section.points.length - 1];
}
let skew;
if (this.handleResetPoint(sectionC.points)) {
- skew = sectionC.points[0];
+ skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2];
} else {
skew = sectionC.points[sectionC.points.length - 1];
}
@@ -140,6 +142,92 @@ export default {
!swch && createArr.push(model); // 已有的道岔不在创建
}
}
+ // if (item['typeModel'] == 'start') { // 右侧关联关系为空 且 道岔区段
+ // const section = item.A;
+ // const sectionB = item.B;
+ // const sectionC = item.C;
+ // if (section.code && sectionB.code && sectionC.code) {
+ // const uname = 'W' + section.name.replace('T', '');
+ // const switchModel = getModel('Switch');
+ // let intersection;
+ // if (this.handleResetPoint(section.points)) {
+ // intersection = section.points[section.points.length - 1];
+ // } else {
+ // intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 2];
+ // }
+ // let skew;
+ // if (this.handleResetPoint(sectionC.points)) {
+ // skew = sectionC.points[sectionC.points.length - 1];
+ // } else {
+ // skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2];
+ // }
+ // const data = {
+ // code: getUID('W', [...this.switchList, ...createArr]),
+ // name: uname,
+ // nameShow: true,
+ // timeoutShow: true,
+ // sectionACode: section.code,
+ // sectionBCode: sectionB.code,
+ // sectionCCode: sectionC.code,
+ // turnTime: 3,
+ // intersection: {
+ // x: intersection.x,
+ // y: intersection.y
+ // },
+ // skew: {
+ // x: skew.x,
+ // y: skew.y
+ // },
+ // normalPosition: 1 // 默认状态定位
+ // };
+ // const model = Object.assign(switchModel, data);
+ // const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
+ // !swch && createArr.push(model); // 已有的道岔不在创建
+ // }
+ // }
+ // if (item['typeModel'] == 'end') { // 左侧关联关系为空 且 道岔区段
+ // const section = item.A;
+ // const sectionB = item.B;
+ // const sectionC = item.C;
+ // if (section.code && sectionB.code && sectionC.code) {
+ // const uname = 'W' + section.name.replace('T', '');
+ // const switchModel = getModel('Switch');
+ // let intersection;
+ // if (this.handleResetPoint(section.points)) {
+ // intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 2];
+ // } else {
+ // intersection = section.points[section.points.length - 1];
+ // }
+ // let skew;
+ // if (this.handleResetPoint(sectionC.points)) {
+ // skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2];
+ // } else {
+ // skew = sectionC.points[sectionC.points.length - 1];
+ // }
+ // const data = {
+ // code: getUID('W', [...this.switchList, ...createArr]),
+ // name: uname,
+ // nameShow: true,
+ // timeoutShow: true,
+ // sectionACode: section.code,
+ // sectionBCode: sectionB.code,
+ // sectionCCode: sectionC.code,
+ // turnTime: 3,
+ // intersection: {
+ // x: intersection.x,
+ // y: intersection.y
+ // },
+ // skew: {
+ // x: skew.x,
+ // y: skew.y
+ // },
+ // normalPosition: 1 // 默认状态定位
+ // };
+ // const model = Object.assign(switchModel, data);
+ // const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
+ // !swch && createArr.push(model); // 已有的道岔不在创建
+ // }
+ // }
}
});
this.$confirm(this.$t('tip.confirmBatchGeneration'), this.$t('tip.hint'), {
@@ -147,6 +235,8 @@ export default {
cancelButtonText: this.$t('tip.cancel'),
type: 'warning'
}).then((res) => {
+ // console.log(createArr, changeSectionLists);
+ // debugger;
const modelsList = this.createSwitchSection(createArr, changeSectionList);
modelsList.forEach(item => {
createArr.push(item);
@@ -157,6 +247,133 @@ export default {
this.$message( this.$t('tip.cancelGeneration'));
});
},
+ findArr(arr) {
+ if (arr[0].slope !== arr[1].slope && arr[0].slope !== arr[2].slope) {
+ return arr[0];
+ }
+ for (var i = 0, len = arr.length; i < len; i++) {
+ if (arr[i].slope !== arr[0].slope) {
+ return arr[i];
+ }
+ }
+ },
+ // 修改区段属性
+ // changeSectionsAttr() {
+ // const pointMap = {};
+ // const ponitMapNew = {};
+ // this.sectionList.forEach(item=> {
+ // if (item.type == '01' || item.type == '03') {
+ // const ponits = item.points;
+ // const startKey = ponits[0].x + '-' + ponits[0].y;
+ // const endKey = ponits[ponits.length - 1].x + '-' + ponits[ponits.length - 1].y;
+ // if (pointMap[startKey]) {
+ // pointMap[startKey].count++;
+ // pointMap[startKey].lists.push(item);
+ // if (pointMap[startKey].count >= 2) { ponitMapNew[startKey] = pointMap[startKey]; }
+ // } else {
+ // pointMap[startKey] = {count: 0, lists: [item]};
+ // }
+ // if (pointMap[endKey]) {
+ // pointMap[endKey].count++;
+ // pointMap[endKey].lists.push(item);
+ // if (pointMap[endKey].count >= 2) { ponitMapNew[endKey] = pointMap[endKey]; }
+ // } else {
+ // pointMap[endKey] = {count: 0, lists: [item]};
+ // }
+ // }
+ // });
+ // const keys = Object.keys(ponitMapNew);
+ // const switchSections = [];
+ // keys.forEach(key => {
+ // if (ponitMapNew[key].count == 2) {
+ // const slopeList = [];
+ // ponitMapNew[key].lists.forEach(sectionModel => {
+ // let slope = '';
+ // const points = sectionModel.points;
+ // const startKey = points[0].x + '-' + points[0].y;
+ // const endKey = points[points.length - 1].x + '-' + points[points.length - 1].y;
+ // if (key == startKey) {
+ // slope = ( points[1].y - points[0].y ) / ( points[1].x - points[0].x );
+ // }
+ // if (key == endKey) {
+ // slope = ( points[points.length - 1].y - points[points.length - 2].y ) / ( points[points.length - 1].x - points[points.length - 2].x );
+ // }
+ // slopeList.push({slope: slope, code: sectionModel.code, model: sectionModel});
+ // });
+ // const arr = [];
+ // let A, B;
+ // const sectionModelC = this.findArr(slopeList);
+ // slopeList.forEach(ele => {
+ // if (ele.slope != sectionModelC.slope) {
+ // arr.push(ele);
+ // }
+ // });
+ // const C = sectionModelC.model;
+ // const pointsC = C.points;
+ // arr.forEach(item => {
+ // const sectionModel = item.model;
+ // const points = sectionModel.points;
+ // const startKey = points[0].x + '-' + points[0].y;
+ // const endKey = points[points.length - 1].x + '-' + points[points.length - 1].y;
+ // const startKeyC = pointsC[0].x + '-' + pointsC[0].y;
+ // const endKeyC = pointsC[pointsC.length - 1].x + '-' + pointsC[pointsC.length - 1].y;
+ // let pointC = null;
+ // if (key == startKeyC) {
+ // pointC = JSON.parse(JSON.stringify(pointsC[1]));
+ // }
+ // if (key == endKeyC) {
+ // pointC = JSON.parse(JSON.stringify(pointsC[pointsC.length - 2]));
+ // }
+ // let acuteAngle;
+ // if (key == startKey) {
+ // acuteAngle = this.handleAngle([points[1], points[0], pointC]);
+ // }
+ // if (key == endKey) {
+ // acuteAngle = this.handleAngle([points[points.length - 2], points[points.length - 1], pointC]);
+ // }
+ // if (acuteAngle) {
+ // B = item.model;
+ // } else {
+ // A = item.model;
+ // }
+ // });
+ // let typeModel;
+ // if (key == A.points[A.points.length - 1].x + '-' + A.points[A.points.length - 1].y) {
+ // A.rightSectionCode = '';
+ // A.sepTypeRight = '00'; // 分隔符
+ // B.leftSectionCode = '';
+ // B.sepTypeLeft = '00';
+ // C.leftSectionCode = '';
+ // C.sepTypeLeft = '00';
+ // typeModel = 'start';
+ // }
+ // if (key == A.points[0].x + '-' + A.points[0].y) {
+ // A.leftSectionCode = '';
+ // A.sepTypeLeft = '00'; // 分隔符
+ // B.rightSectionCode = '';
+ // B.sepTypeRight = '00';
+ // C.rightSectionCode = '';
+ // C.sepTypeRight = '00';
+ // typeModel = 'end';
+ // }
+ // A.type = '03';
+ // B.type = '03';
+ // C.type = '03';
+ // switchSections.push({A: A, B: B, C: C, typeModel: typeModel });
+ // }
+ // });
+ // console.log(switchSections);
+ // return switchSections;
+ // },
+ // handleAngle(points) {
+ // const A = points[0];
+ // const B = points[1];
+ // const C = points[2];
+ // var AB = Math.sqrt(Math.pow(A.x - B.x, 2) + Math.pow(A.y - B.y, 2));
+ // var AC = Math.sqrt(Math.pow(A.x - C.x, 2) + Math.pow(A.y - C.y, 2));
+ // var BC = Math.sqrt(Math.pow(B.x - C.x, 2) + Math.pow(B.y - C.y, 2));
+ // return Math.pow(AB, 2) + Math.pow(BC, 2) > Math.pow(AC, 2);
+ // },
findSectionA(pointX, pointY, lists, code) {
const list = [];
lists.forEach(item => {
@@ -208,19 +425,19 @@ export default {
},
// 重置坐标点
handleResetPoint(points) {
- return (points[points.length - 1].x >= points[0].x) && (points[points.length - 1].y >= points[0].y);
+ return points[points.length - 1].x >= points[points.length - 2].x;
},
// 修改区段属性
changeSectionAttr() {
const changeSectionList = []; // 改变的区段列表
this.sectionList.forEach(section => {
- if (section.type == '01') {
+ if (section.type == '01' || section.type == '03') {
const oneSection = section.points[section.points.length - 1];
const oneSectionStar = section.points[0];
let countA = 0;
let countB = 0;
this.sectionList.forEach(elem => {
- if (elem.type == '01' && section.code != elem.code) {
+ if ((elem.type == '01' || section.type == '03') && section.code != elem.code) {
let twoSection, twoSectionEnd;
if (this.handleResetPoint(elem.points)) {
twoSection = elem.points[0];
@@ -276,34 +493,34 @@ export default {
});
return changeSectionList;
},
- checkAddListA(points, code) { // 判断是否添加list (暂时不用)
- let flag = false;
- this.sectionList.forEach(section => {
- section.points.forEach((point, index) => {
- if (index > 0 && section.code != code) {
- if (point.x == points.x && point.y == points.y) {
- flag = true;
- }
- }
- });
+ // checkAddListA(points, code) { // 判断是否添加list (暂时不用)
+ // let flag = false;
+ // this.sectionList.forEach(section => {
+ // section.points.forEach((point, index) => {
+ // if (index > 0 && section.code != code) {
+ // if (point.x == points.x && point.y == points.y) {
+ // flag = true;
+ // }
+ // }
+ // });
- });
- return flag;
- },
- checkAddListB(points, code) { // 判断是否添加list (暂时不用)
- let flag = false;
- this.sectionList.forEach(section => {
- section.points.forEach((point, index) => {
- if (index == 0 && section.code != code) {
- if (point.x == points.x && point.y == points.y) {
- flag = true;
- }
- }
- });
+ // });
+ // return flag;
+ // },
+ // checkAddListB(points, code) { // 判断是否添加list (暂时不用)
+ // let flag = false;
+ // this.sectionList.forEach(section => {
+ // section.points.forEach((point, index) => {
+ // if (index == 0 && section.code != code) {
+ // if (point.x == points.x && point.y == points.y) {
+ // flag = true;
+ // }
+ // }
+ // });
- });
- return flag;
- },
+ // });
+ // return flag;
+ // },
// 一键生成道岔计轴区段
createSwitchSection(list, sectionLists) {
const models = [];