From b2482467febc309787464cb7c3551e9aa97ae9b6 Mon Sep 17 00:00:00 2001 From: zyy <1787816799@qq.com> Date: Tue, 23 Jul 2019 13:40:55 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/config/defaultSkin.js | 11 + src/jmap/shape/Section/EAxle.js | 8 +- src/jmap/shape/Section/ELimitLines.js | 20 +- src/jmap/shape/Section/ELines.js | 8 +- src/jmap/shape/Section/ESeparator.js | 28 +-- src/jmap/shape/Section/index.js | 152 ++++++------- src/jmap/shape/Signal/index.js | 4 +- src/jmap/shape/StationStand/EDetain.js | 6 +- src/jmap/shape/StationStand/EJump.js | 4 +- src/jmap/shape/StationStand/ELevel.js | 4 +- src/jmap/shape/StationStand/ESafeDoor.js | 12 +- src/jmap/shape/StationStand/ESafeEmergent.js | 4 +- src/jmap/shape/StationStand/ESafeStand.js | 2 +- src/jmap/shape/StationStand/ETime.js | 4 +- src/jmap/shape/StationStand/index.js | 76 +++---- src/jmap/shape/Switch/ESwLnversion.js | 2 +- src/jmap/shape/Switch/index copy.js | 34 +-- src/jmap/shape/Switch/index.js | 32 +-- src/jmap/theme/bejing.js | 10 +- src/jmap/theme/fuzhou.js | 222 ++++++++----------- 20 files changed, 313 insertions(+), 330 deletions(-) diff --git a/src/jmap/config/defaultSkin.js b/src/jmap/config/defaultSkin.js index 7446b9e98..68d59730a 100644 --- a/src/jmap/config/defaultSkin.js +++ b/src/jmap/config/defaultSkin.js @@ -39,6 +39,17 @@ export default class DefaultSkin { /** 目的码字体颜色*/ this.destinationTextFontColor = 'yellow'; + /** 计数器字体颜色*/ + this.stationCounterTextColor = '#FFFFFF'; + /** 计数器边框颜色*/ + this.stationCounterBorderColor = '#E4EF50'; + /** 延迟解锁倒计时和设备文字之间的距离*/ + this.stationDelayUnlockDistance = 3; + /** 延时解锁字体颜色*/ + this.stationDelayUnlockTextColor = '#FFFFFF'; + /** 延迟解锁边框颜色*/ + this.stationDelayUnlockBorderColor = '#FFFFFF'; + /** 列车长度*/ this.trainWidth = 40; diff --git a/src/jmap/shape/Section/EAxle.js b/src/jmap/shape/Section/EAxle.js index 894f09003..4023cad6b 100644 --- a/src/jmap/shape/Section/EAxle.js +++ b/src/jmap/shape/Section/EAxle.js @@ -14,7 +14,7 @@ export default class EAxle extends Group { _create(model) { if (model && model.style && model.traingle) { - const axleLength = 2 * model.style.Section.sectionAxleR; + const axleLength = 2 * model.style.Section.axle.radius; const positionx = model.point.x + model.drictx * (model.traingle.getCos(axleLength)); const positiony = model.point.y + model.dricty * (model.traingle.getCos(axleLength)); @@ -30,7 +30,7 @@ export default class EAxle extends Group { }, style: { GBaseLineWidth: 1, - stroke: model.style.Section.sectionAxleColor + stroke: model.style.Section.axle.color } }); this.axle = new Circle({ @@ -40,11 +40,11 @@ export default class EAxle extends Group { shape: { cx: positionx - model.dricty * model.traingle.getSin(axleLength), cy: positiony + model.drictx * model.traingle.getSin(axleLength), - r: model.style.Section.sectionAxleR + r: model.style.Section.axle.radius }, style: { GBaseLineWidth: 1, - stroke: model.style.Section.sectionAxleColor, + stroke: model.style.Section.axle.color, fill: model.style.transparentColor } }); diff --git a/src/jmap/shape/Section/ELimitLines.js b/src/jmap/shape/Section/ELimitLines.js index 4d2ce9252..1c5b14eae 100644 --- a/src/jmap/shape/Section/ELimitLines.js +++ b/src/jmap/shape/Section/ELimitLines.js @@ -36,8 +36,8 @@ export default class ELimitLines extends Group { shape: shape, position: model.position, style: { - lineWidth: model.style.Section.sectionSpeedLimitLinewidth, - stroke: model.style.Section.sectionSpeedLimitColor, + lineWidth: model.style.Section.speedLimit.width, + stroke: model.style.Section.speedLimit.lineColor, fillOpacity: 0 } })); @@ -59,8 +59,8 @@ export default class ELimitLines extends Group { y2: end.y }, style: { - lineWidth: model.style.Section.sectionSpeedLimitLinewidth, - stroke: model.style.Section.sectionSpeedLimitColor + lineWidth: model.style.Section.speedLimit.width, + stroke: model.style.Section.speedLimit.lineColor } })); } else { @@ -77,8 +77,8 @@ export default class ELimitLines extends Group { y2: model.points[1].y }, style: { - lineWidth: model.style.Section.sectionSpeedLimitLinewidth, - stroke: model.style.Section.sectionSpeedLimitColor + lineWidth: model.style.Section.speedLimit.width, + stroke: model.style.Section.speedLimit.lineColor } })); @@ -96,8 +96,8 @@ export default class ELimitLines extends Group { y2: model.points[i + 1].y }, style: { - lineWidth: model.style.Section.sectionSpeedLimitLinewidth, - stroke: model.style.Section.sectionSpeedLimitColor + lineWidth: model.style.Section.speedLimit.width, + stroke: model.style.Section.speedLimit.lineColor } })); } @@ -115,8 +115,8 @@ export default class ELimitLines extends Group { y2: end.y }, style: { - lineWidth: model.style.Section.sectionSpeedLimitLinewidth, - stroke: model.style.Section.sectionSpeedLimitColor + lineWidth: model.style.Section.speedLimit.width, + stroke: model.style.Section.speedLimit.lineColor } })); } diff --git a/src/jmap/shape/Section/ELines.js b/src/jmap/shape/Section/ELines.js index fecaf5182..89adbcbce 100644 --- a/src/jmap/shape/Section/ELines.js +++ b/src/jmap/shape/Section/ELines.js @@ -35,8 +35,8 @@ export default class ELines extends Group { culling: true, shape: shape, style: { - lineWidth: model.style.Section.sectionWidth, - stroke: model.style.Section.sectionSpareColor, + lineWidth: model.style.Section.line.width, + stroke: model.style.Section.line.spareColor, fillOpacity: 0 } })); @@ -54,8 +54,8 @@ export default class ELines extends Group { y2: model.points[i + 1].y }, style: { - lineWidth: model.style.Section.sectionWidth, - stroke: model.style.Section.sectionSpareColor + lineWidth: model.style.Section.line.width, + stroke: model.style.Section.line.spareColor } })); } diff --git a/src/jmap/shape/Section/ESeparator.js b/src/jmap/shape/Section/ESeparator.js index 30a757ffb..1ed793423 100644 --- a/src/jmap/shape/Section/ESeparator.js +++ b/src/jmap/shape/Section/ESeparator.js @@ -22,8 +22,8 @@ export default class ESeparator extends Group { points: [] }, style: { - lineWidth: this.style.Section.sectionSeparatorWidth, - stroke: this.style.Section.sectionSeparatorColor + lineWidth: this.style.Section.separator.width, + stroke: this.style.Section.separator.color } }); @@ -34,10 +34,10 @@ export default class ESeparator extends Group { shape: { cx: model.point.x, cy: model.point.y, - r: this.style.Section.sectionWidth + r: this.style.Section.line.width }, style: { - stroke: this.style.Section.sectionInvadeColor, + stroke: this.style.Section.line.invadeColor, GBaseLineWidth: 0.5, fill: this.style.transparentColor } @@ -59,26 +59,26 @@ export default class ESeparator extends Group { ]); } else if (type === '01') { this.partition.setShape('points', [ - [model.point.x, model.point.y - (this.style.Section.sectionWidth)], - [model.point.x, model.point.y + (this.style.Section.sectionWidth)] + [model.point.x, model.point.y - (this.style.Section.line.width)], + [model.point.x, model.point.y + (this.style.Section.line.width)] ]); this.add(this.partition); } else if (type === '02') { this.partition.setShape('points', [ - [model.point.x + model.drict * (this.style.Section.sectionWidth), model.point.y - (this.style.Section.sectionWidth * 1.5)], - [model.point.x, model.point.y - (this.style.Section.sectionWidth * 1.5)], - [model.point.x, model.point.y + (this.style.Section.sectionWidth * 1.5)] + [model.point.x + model.drict * (this.style.Section.line.width), model.point.y - (this.style.Section.line.width * 1.5)], + [model.point.x, model.point.y - (this.style.Section.line.width * 1.5)], + [model.point.x, model.point.y + (this.style.Section.line.width * 1.5)] ]); this.add(this.partition); } else if (type === '03') { this.partition.setShape('points', [ - [model.point.x + model.drict * (this.style.Section.sectionWidth) * 1.2, model.point.y - (this.style.Section.sectionWidth * 1.2)], - [model.point.x, model.point.y - (this.style.Section.sectionWidth * 1.2)], - [model.point.x, model.point.y + (this.style.Section.sectionWidth * 1.2)], - [model.point.x + model.drict * (this.style.Section.sectionWidth) * 1.2, model.point.y + (this.style.Section.sectionWidth * 1.2)] + [model.point.x + model.drict * (this.style.Section.line.width) * 1.2, model.point.y - (this.style.Section.line.width * 1.2)], + [model.point.x, model.point.y - (this.style.Section.line.width * 1.2)], + [model.point.x, model.point.y + (this.style.Section.line.width * 1.2)], + [model.point.x + model.drict * (this.style.Section.line.width) * 1.2, model.point.y + (this.style.Section.line.width * 1.2)] ]); this.add(this.partition); - this.partition.setStyle({'lineWidth': this.style.Section.sectionEndSeparatorWidth, 'stroke': this.style.Section.sectionEndSeparatorStroke }); + this.partition.setStyle({'lineWidth': this.style.Section.separator.endWidth, 'stroke': this.style.Section.separator.endColor }); } else if (type === '04') { this.add(this.circle); } diff --git a/src/jmap/shape/Section/index.js b/src/jmap/shape/Section/index.js index da445c345..0096dcf85 100644 --- a/src/jmap/shape/Section/index.js +++ b/src/jmap/shape/Section/index.js @@ -69,12 +69,12 @@ export default class Section extends Group { x2: model.points[0].x + traingle.getCos(traingle.absz / 3 * 2), y2: model.points[0].y + traingle.getSin(traingle.absz / 3 * 2) }, - lineWidth: style.Section.sectionWidth, - stroke: style.Section.sectionSpareColor + lineWidth: style.Section.line.width, + stroke: style.Section.line.spareColor }); - let x = traingle.drictx * (style.Section.sectionSpeedLimitDistance) * traingle.getSinRate(); - let y = traingle.dricty * (style.Section.sectionSpeedLimitDistance) * traingle.getCosRate(); + let x = traingle.drictx * (style.Section.speedLimit.Distance) * traingle.getSinRate(); + let y = traingle.dricty * (style.Section.speedLimit.Distance) * traingle.getCosRate(); if (x == Infinity) { x = 0; } if (y == Infinity) { y = 0; } @@ -123,22 +123,22 @@ export default class Section extends Group { let tempx = x; let tempy = y; - if (style.Section.sectionTextPosition == 1) { - tempy = tempy - style.textFontSize; - } else if (style.Section.sectionTextPosition == -1) { - tempy = tempy + style.textFontSize; - } else if (style.Section.sectionTextPosition == 0) { + if (style.Section.text.position == 1) { + tempy = tempy - style.Section.text.fontSize; + } else if (style.Section.text.position == -1) { + tempy = tempy + style.Section.text.fontSize; + } else if (style.Section.text.position == 0) { // 根据列车上下行进行坐标偏移 const traingle = new JTriangle(model.points[0], model.points[model.points.length - 1]); if (model.trainPosType === '01') { - tempy -= (style.Section.sectionWidth * 1.5); + tempy -= (style.Section.line.width * 1.5); if (model.type === '01') { - tempy += traingle.getCos(style.textFontSize * 0.8 + style.nameDistance) - style.textFontSize * 2; + tempy += traingle.getCos(style.Section.text.fontSize * 0.8 + style.nameDistance) - style.Section.text.fontSize * 2; } } else { - tempy += (style.Section.sectionWidth * 1.5); + tempy += (style.Section.line.width * 1.5); if (model.type === '01') { - tempy -= traingle.getCos(style.textFontSize * 0.8 + style.nameDistance) - style.textFontSize * 2; + tempy -= traingle.getCos(style.Section.text.fontSize * 0.8 + style.nameDistance) - style.Section.text.fontSize * 2; } } } @@ -148,12 +148,12 @@ export default class Section extends Group { // 如果不是逻辑区段,让名称和区段保持点距离 const traingle = new JTriangle(model.points[0], model.points[model.points.length - 1]); if (model.type === '01') { - tempx += traingle.getSin(style.textFontSize * 0.8 + style.nameDistance); + tempx += traingle.getSin(style.Section.text.fontSize * 0.8 + style.nameDistance); } } // 创建区段名称 - const fontSize = style.type == '02' ? style.textFontSize + 2 : style.textFontSize; + const fontSize = style.type == '02' ? style.Section.text.fontSize + 2 : style.Section.text.fontSize; this.sectionText = new ETextName({ _subType: 'Text', zlevel: this.zlevel, @@ -161,11 +161,11 @@ export default class Section extends Group { x: tempx, y: tempy, text: model.name, - textFont: fontSize + 'px ' + style.textFontFormat, - textFill: style.textFontColor, - textAlign: 'center', - textPosition: 'inside', - textVerticalAlign: 'middle', + textFont: fontSize + 'px ' + style.Section.text.fontFormat, + textFill: style.Section.text.fontColor, + textAlign: style.Section.text.textAlign, + textPosition: style.Section.text.textPosition, + textVerticalAlign: style.Section.text.textVerticalAlign, style: this.style }); this.add(this.sectionText); @@ -188,10 +188,10 @@ export default class Section extends Group { x: tempx + model.standTrackNamePosition.x, y: tempy + model.standTrackNamePosition.y, text: model.standTrackName, - textFont: style.textFontSize + 'px ' + style.textFontFormat, - textFill: style.textFontColor, - textAlign: 'center', - textPosition: 'inside', + textFont: style.Section.text.fontSize + 'px ' + style.Section.text.fontFormat, + textFill: style.Section.text.fontColor, + textAlign: style.Section.text.textAlign, + textPosition: style.Section.text.textPosition, style: this.style }); // 添加视图 @@ -205,12 +205,12 @@ export default class Section extends Group { zlevel: this.zlevel, z: 6, x: x + model.reentryTrackNamePosition.x, - y: y + model.reentryTrackNamePosition.y + style.nameDistance + style.textFontSize, + y: y + model.reentryTrackNamePosition.y + style.nameDistance + style.Section.text.fontSize, text: model.reentryTrackName, - textFont: style.textFontSize + 'px ' + style.textFontFormat, - textFill: style.textFontColor, - textAlign: 'center', - textPosition: 'inside', + textFont: style.Section.text.fontSize + 'px ' + style.Section.text.fontFormat, + textFill: style.Section.text.fontColor, + textAlign: style.Section.text.textAlign, + textPosition: style.Section.text.textPosition, style: this.style }); // 添加视图 @@ -224,12 +224,12 @@ export default class Section extends Group { zlevel: this.zlevel, z: 6, x: x + model.transferTrackNamePosition.x, - y: y + model.transferTrackNamePosition.y + style.nameDistance + style.textFontSize * 2, + y: y + model.transferTrackNamePosition.y + style.nameDistance + style.Section.text.fontSize * 2, text: model.transferTrackName, - textFont: style.textFontSize + 'px ' + style.textFontFormat, - textFill: style.textFontColor, - textAlign: 'center', - textPosition: 'inside', + textFont: style.Section.text.fontSize + 'px ' + style.Section.text.fontFormat, + textFill: style.Section.text.fontColor, + textAlign: style.Section.text.textAlign, + textPosition: style.Section.text.textPosition, style: this.style }); // 添加视图 @@ -245,10 +245,10 @@ export default class Section extends Group { x: x + model.destinationCodePoint.x, y: y + model.destinationCodePoint.y, text: model.destinationCode, - textFont: style.textFontSize + 'px ' + style.textFontFormat, + textFont: style.Section.text.fontSize + 'px ' + style.Section.text.fontFormat, textFill: style.destinationTextFontColor, - textAlign: 'center', - textPosition: 'inside', + textAlign: style.Section.text.textAlign, + textPosition: style.Section.text.textPosition, style: this.style }); // 添加视图 @@ -381,8 +381,8 @@ export default class Section extends Group { this.section.stopAnimation(true); this.section.setStyle({ fill: this.style.backgroundColor, - stroke: this.style.Section.sectionSpareColor, - lineWidth: this.style.Section.sectionWidth + stroke: this.style.Section.line.spareColor, + lineWidth: this.style.Section.line.width }); this.release.hide(); @@ -395,8 +395,8 @@ export default class Section extends Group { undefine() { if (this.section) { this.section.setStyle({ - stroke: this.style.Section.sectionUndefinedColor, - lineWidth: this.style.Section.sectionWidth + stroke: this.style.Section.line.undefinedColor, + lineWidth: this.style.Section.line.width }); } } @@ -405,8 +405,8 @@ export default class Section extends Group { spare() { if (this.section) { this.section.setStyle({ - stroke: this.style.Section.sectionSpareColor, - lineWidth: this.style.Section.sectionWidth + stroke: this.style.Section.line.spareColor, + lineWidth: this.style.Section.line.width }); } } @@ -415,8 +415,8 @@ export default class Section extends Group { communicationOccupied() { if (this.section) { this.section.setStyle({ - stroke: this.style.Section.sectionCommunicationOccupiedColor, - lineWidth: this.style.Section.sectionWidth + this.style.Section.sectionBeyondWidth + stroke: this.style.Section.line.communicationOccupiedColor, + lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth }); } } @@ -425,8 +425,8 @@ export default class Section extends Group { unCommunicationOccupied() { if (this.section) { this.section.setStyle({ - stroke: this.style.Section.sectionUnCommunicationOccupiedColor, - lineWidth: this.style.Section.sectionWidth + this.style.Section.sectionBeyondWidth + stroke: this.style.Section.line.unCommunicationOccupiedColor, + lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth }); } } @@ -435,8 +435,8 @@ export default class Section extends Group { routeLock() { if (this.section) { this.section.setStyle({ - stroke: this.style.Section.sectionRouteLockColor, - lineWidth: this.style.Section.sectionWidth + this.style.Section.sectionBeyondWidth + stroke: this.style.Section.line.routeLockColor, + lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth }); } } @@ -445,8 +445,8 @@ export default class Section extends Group { block() { if (this.section) { this.section.setStyle({ - stroke: this.style.Section.sectionBlockColor, - lineWidth: this.style.Section.sectionWidth + this.style.Section.sectionBeyondWidth + stroke: this.style.Section.line.blockColor, + lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth }); } } @@ -455,8 +455,8 @@ export default class Section extends Group { faultLock() { if (this.section) { this.section.setStyle({ - stroke: this.style.Section.sectionFaultLockColor, - lineWidth: this.style.Section.sectionWidth + this.style.Section.sectionBeyondWidth + stroke: this.style.Section.line.faultLockColor, + lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth }); } } @@ -465,8 +465,8 @@ export default class Section extends Group { atcExcision() { if (this.section) { this.section.setStyle({ - stroke: this.style.Section.sectionAtcExcisionColor, - lineWidth: this.style.Section.sectionWidth + this.style.Section.sectionBeyondWidth + stroke: this.style.Section.line.atcExcisionColor, + lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth }); } } @@ -477,7 +477,7 @@ export default class Section extends Group { this.atcExcision(); this.section.animateStyle(true, [ { time: 1000, styles: { stroke: this.style.backgroundColor } }, - { time: 2000, styles: { stroke: this.style.Section.sectionAtsExcisionColor, lineWidth: this.style.Section.sectionWidth + this.style.Section.sectionBeyondWidth } } + { time: 2000, styles: { stroke: this.style.Section.line.atsExcisionColor, lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth } } ]); } } @@ -486,8 +486,8 @@ export default class Section extends Group { protectiveLock() { if (this.section) { this.section.setStyle({ - stroke: this.style.Section.sectionProtectiveLockColor, - lineWidth: this.style.Section.sectionWidth + this.style.Section.sectionBeyondWidth + stroke: this.style.Section.line.protectiveLockColor, + lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth }); } } @@ -496,15 +496,15 @@ export default class Section extends Group { timeRelease() { if (this.release) { this.section.setStyle({ - stroke: this.style.Section.sectionRouteLockColor, - lineWidth: this.style.Section.sectionWidth + this.style.Section.sectionBeyondWidth + stroke: this.style.Section.line.routeLockColor, + lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth }); this.release.show(); - this.release.setStyle('lineWidth', this.style.Section.sectionWidth + this.style.Section.sectionBeyondWidth); - this.release.setStyle('stroke', this.style.Section.sectionRouteLockColor); + this.release.setStyle('lineWidth', this.style.Section.line.width + this.style.Section.line.beyondWidth); + this.release.setStyle('stroke', this.style.Section.line.routeLockColor); this.release.animateStyle(true) - .when(1000, { stroke: this.style.Section.sectionRouteLockColor }) - .when(2000, { stroke: this.style.Section.sectionTimeReleaseColor }) + .when(1000, { stroke: this.style.Section.line.routeLockColor }) + .when(2000, { stroke: this.style.Section.line.timeReleaseColor }) .start(); } } @@ -513,15 +513,15 @@ export default class Section extends Group { protectiveTimeRelease() { if (this.release) { this.section.setStyle({ - stroke: this.style.Section.sectionProtectiveLockColor, - lineWidth: this.style.Section.sectionWidth + this.style.Section.sectionBeyondWidth + stroke: this.style.Section.line.protectiveLockColor, + lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth }); this.release.show(); - this.release.setStyle('lineWidth', this.style.Section.sectionWidth + this.style.Section.sectionBeyondWidth); - this.release.setStyle('stroke', this.style.Section.sectionProtectiveLockColor); + this.release.setStyle('lineWidth', this.style.Section.line.width + this.style.Section.line.beyondWidth); + this.release.setStyle('stroke', this.style.Section.line.protectiveLockColor); this.release.animateStyle(true) - .when(1000, { stroke: this.style.Section.sectionProtectiveLockColor }) - .when(2000, { stroke: this.style.Section.sectionProtectiveTimeReleaseColor }) + .when(1000, { stroke: this.style.Section.line.protectiveLockColor }) + .when(2000, { stroke: this.style.Section.line.protectiveTimeReleaseColor }) .start(); } } @@ -529,7 +529,7 @@ export default class Section extends Group { /** 区段切除*/ sectionCutOff() { if (this.release) { - const lineWidth = this.style.Section.sectionWidth + (this.model.status != '01' ? this.style.Section.sectionBeyondWidth : 0); + const lineWidth = this.style.Section.line.width + (this.model.status != '01' ? this.style.Section.line.beyondWidth : 0); this.section.animateStyle(true, [ { time: 0, styles: { lineWidth: lineWidth } }, { time: 1000, styles: { stroke: this.style.backgroundColor } }, @@ -551,7 +551,7 @@ export default class Section extends Group { if (this.release) { this.release.show(); this.release.setStyle({ - stroke: this.style.Section.sectionAxleResetColor + stroke: this.style.Section.axle.resetColor }); } } @@ -560,8 +560,8 @@ export default class Section extends Group { alxeFailure() { if (this.section) { this.section.setStyle({ - stroke: this.style.Section.sectionAxleFailure, - lineWidth: this.style.Section.sectionWidth + this.style.Section.sectionBeyondWidth + stroke: this.style.Section.axle.Failure, + lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth }); } } @@ -631,12 +631,12 @@ export default class Section extends Group { /** 计算提示位置*/ getShapeTipPoint() { let rect = this.getBoundingRect(); - let distance = this.style.Section.sectionWidth / 2; + let distance = this.style.Section.line.width / 2; if (this.section) { rect = this.section.getBoundingRect(); if (this.model.type !== '02' && this.model.nameShow) { if (this.model.trainPosType == '01') { - distance = distance + this.style.nameDistance + this.style.textFontSize; + distance = distance + this.style.nameDistance + this.style.Section.text.fontSize; } } } diff --git a/src/jmap/shape/Signal/index.js b/src/jmap/shape/Signal/index.js index 20596c112..59634ff0f 100644 --- a/src/jmap/shape/Signal/index.js +++ b/src/jmap/shape/Signal/index.js @@ -42,7 +42,7 @@ class Signal extends Group { drict: drict, type: model.lampPostType, x: model.position.x, - y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.signalR) + y: model.position.y + posit * (style.Signal.signalDistance + style.Section.line.width + style.Signal.signalR) }); // 信号灯 @@ -66,7 +66,7 @@ class Signal extends Group { // 信号机名称 const sigNameX = model.position.x + model.namePosition.x; - const sigNameY = model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.signalR * 2 + model.namePosition.y); + const sigNameY = model.position.y + posit * (style.Signal.signalDistance + style.Section.line.width + style.Signal.signalR * 2 + model.namePosition.y); this.sigName = new ESigName({ zlevel: this.zlevel, z: this.z, diff --git a/src/jmap/shape/StationStand/EDetain.js b/src/jmap/shape/StationStand/EDetain.js index 9072e80f6..6f5151221 100644 --- a/src/jmap/shape/StationStand/EDetain.js +++ b/src/jmap/shape/StationStand/EDetain.js @@ -18,11 +18,11 @@ class EDetain extends Group { style: { x: model.x, y: model.y, - text: style.StationStand.standDetainText, + text: style.StationStand.detainCar.text, textAlign: model.textAlign, textVerticalAlign: model.textVerticalAlign, - fontSize: `${style.StationStand.standHeadFontSize} px ${style.textFontFormat}`, - textFill: style.StationStand.standCenterDetainTrainColor, + fontSize: `${style.StationStand.stand.headFontSize} px ${style.textFontFormat}`, + textFill: style.StationStand.detainCar.centerTrainColor, textStroke: style.backgroundColor } }); diff --git a/src/jmap/shape/StationStand/EJump.js b/src/jmap/shape/StationStand/EJump.js index fa3d09178..3794a2da7 100644 --- a/src/jmap/shape/StationStand/EJump.js +++ b/src/jmap/shape/StationStand/EJump.js @@ -19,9 +19,9 @@ class EJump extends Group { x: model.x, y: model.y, text: model.name, - textFill: style.StationStand.standLevelTextColor, + textFill: style.StationStand.level.textColor, textAlign: 'middle', - textFont: `${style.StationStand.standTextFontSize} px ${style.textFontFormat}` + textFont: `${style.StationStand.common.textFontSize} px ${style.textFontFormat}` } }); diff --git a/src/jmap/shape/StationStand/ELevel.js b/src/jmap/shape/StationStand/ELevel.js index b530633d1..851d83359 100644 --- a/src/jmap/shape/StationStand/ELevel.js +++ b/src/jmap/shape/StationStand/ELevel.js @@ -19,9 +19,9 @@ class ELevel extends Group { x: model.x, y: model.y, text: model.name, - textFill: style.StationStand.standLevelTextColor, + textFill: style.StationStand.level.textColor, textAlign: 'middle', - textFont: `${style.StationStand.standTextFontSize} px ${style.textFontFormat}` + textFont: `${style.StationStand.common.textFontSize} px ${style.textFontFormat}` } }); diff --git a/src/jmap/shape/StationStand/ESafeDoor.js b/src/jmap/shape/StationStand/ESafeDoor.js index ea187baa8..473139594 100644 --- a/src/jmap/shape/StationStand/ESafeDoor.js +++ b/src/jmap/shape/StationStand/ESafeDoor.js @@ -24,8 +24,8 @@ class ESafeDoor extends Group { }, style: { lineWidth: 0, - stroke: style.StationStand.standDoorDefaultColor, - fill: style.StationStand.standDoorDefaultColor + stroke: style.StationStand.safetyDoor.defaultColor, + fill: style.StationStand.safetyDoor.defaultColor } }); @@ -40,8 +40,8 @@ class ESafeDoor extends Group { }, style: { lineWidth: 0, - stroke: style.StationStand.standDoorDefaultColor, - fill: style.StationStand.standDoorDefaultColor + stroke: style.StationStand.safetyDoor.defaultColor, + fill: style.StationStand.safetyDoor.defaultColor } }); @@ -56,8 +56,8 @@ class ESafeDoor extends Group { }, style: { lineWidth: 0, - stroke: style.StationStand.standDoorDefaultColor, - fill: style.StationStand.standDoorDefaultColor + stroke: style.StationStand.safetyDoor.defaultColor, + fill: style.StationStand.safetyDoor.defaultColor } }); diff --git a/src/jmap/shape/StationStand/ESafeEmergent.js b/src/jmap/shape/StationStand/ESafeEmergent.js index cc2734de0..da2905c21 100644 --- a/src/jmap/shape/StationStand/ESafeEmergent.js +++ b/src/jmap/shape/StationStand/ESafeEmergent.js @@ -23,8 +23,8 @@ class ESafeEmergent extends Group { }, style: { lineWidth: 0, - stroke: style.StationStand.standEmergentCloseColor, - fill: style.StationStand.standEmergentCloseColor + stroke: style.StationStand.standEmergent.closeColor, + fill: style.StationStand.standEmergent.closeColor } }); diff --git a/src/jmap/shape/StationStand/ESafeStand.js b/src/jmap/shape/StationStand/ESafeStand.js index 74f4ebfbf..57834a850 100644 --- a/src/jmap/shape/StationStand/ESafeStand.js +++ b/src/jmap/shape/StationStand/ESafeStand.js @@ -24,7 +24,7 @@ class ESafeStand extends Group { style: { lineWidth: 0, stroke: style.sidelineColor, - fill: style.StationStand.standSpareColor + fill: style.StationStand.stand.spareColor } }); diff --git a/src/jmap/shape/StationStand/ETime.js b/src/jmap/shape/StationStand/ETime.js index bfe80cf0f..cb2bef7f4 100644 --- a/src/jmap/shape/StationStand/ETime.js +++ b/src/jmap/shape/StationStand/ETime.js @@ -19,9 +19,9 @@ class ETime extends Group { x: model.x, y: model.y, text: model.name, - textFill: style.StationStand.standTimeTextColor, + textFill: style.StationStand.stopTime.textColor, textAlign: 'middle', - textFont: `${style.StationStand.standTextFontSize} px ${style.textFontFormat}` + textFont: `${style.StationStand.common.textFontSize} px ${style.textFontFormat}` } }); diff --git a/src/jmap/shape/StationStand/index.js b/src/jmap/shape/StationStand/index.js index fd5e3333e..2a19c6b3b 100644 --- a/src/jmap/shape/StationStand/index.js +++ b/src/jmap/shape/StationStand/index.js @@ -36,14 +36,14 @@ class StationStand extends Group { x: model.position.x, y: model.position.y, width: model.width, - height: style.StationStand.standSafeHeight, + height: style.StationStand.safetyDoor.height, show: model.hasDoor }); /** 列车站台*/ - const standH = drict > 0 ? style.StationStand.standSafeHeight : model.height; + const standH = drict > 0 ? style.StationStand.safetyDoor.height : model.height; const standX = model.position.x - model.width / 2; - const standY = model.position.y + drict * (style.StationStand.standDistance + standH); + const standY = model.position.y + drict * (style.StationStand.safetyDoor.distance + standH); this.safeStand = new ESafeStand({ zlevel: this.zlevel, z: this.z, @@ -55,24 +55,24 @@ class StationStand extends Group { }); /** 站台紧急关闭*/ - const emergentH = drict > 0 ? style.StationStand.standEmergentR + style.StationStand.standSafeHeight: style.StationStand.standEmergentR; - const emergentX = model.position.x + drict * (style.StationStand.standEmergentOffset.x); - const emergentY = model.position.y + drict * (style.StationStand.standEmergentOffset.y + emergentH); + const emergentH = drict > 0 ? style.StationStand.standEmergent.mergentR + style.StationStand.safetyDoor.height: style.StationStand.standEmergent.mergentR; + const emergentX = model.position.x + drict * (style.StationStand.standEmergent.offset.x); + const emergentY = model.position.y + drict * (style.StationStand.standEmergent.offset.y + emergentH); this.emergent = new ESafeEmergent({ zlevel: this.zlevel, z: this.z + 1, style: style, x: emergentX, y: emergentY, - r: style.StationStand.standEmergentR, + r: style.StationStand.standEmergent.mergentR, n: 4 }); /** 站台折返策略*/ - const reentryD = style.StationStand.standReentryDirection ? model.height + 6: -style.StationStand.standDistance - style.StationStand.standSafeHeight; - const reentryH = drict > 0 ? style.StationStand.standEmergentR : style.StationStand.standEmergentR + style.StationStand.standDistance + reentryD; - const reentryX = model.position.x - (style.StationStand.standReentryDirection || drict) * (style.StationStand.standReentryOffset.x - model.width / 2); - const reentryY = model.position.y + (style.StationStand.standReentryDirection || drict) * (style.StationStand.standReentryOffset.y) + drict * reentryH; + const reentryD = style.StationStand.reentry.direction ? model.height + 6: -style.StationStand.safetyDoor.distance - style.StationStand.safetyDoor.height; + const reentryH = drict > 0 ? style.StationStand.standEmergent.mergentR : style.StationStand.standEmergent.mergentR + style.StationStand.safetyDoor.distance + reentryD; + const reentryX = model.position.x - (style.StationStand.reentry.direction || drict) * (style.StationStand.reentry.offset.x - model.width / 2); + const reentryY = model.position.y + (style.StationStand.reentry.direction || drict) * (style.StationStand.reentry.offset.y) + drict * reentryH; this.reentry = new EReentry({ zlevel: this.zlevel, z: this.z + 1, @@ -81,16 +81,16 @@ class StationStand extends Group { x: reentryX, y: reentryY, lineWidth: 0, - fill: style.StationStand.standNoHumanReentryColor + fill: style.StationStand.reentry.noHumanColor }); - const distance = style.StationStand.standSafeHeight*2 - style.StationStand.standHeadFontSize/2 - 2; + const distance = style.StationStand.safetyDoor.height*2 - style.StationStand.stand.headFontSize/2 - 2; /** 站台扣车*/ - const detainD = style.StationStand.standDetainDirection ? model.height - distance: -style.StationStand.standSafeHeight; - const detainH = drict > 0 ? style.StationStand.standEmergentR : style.StationStand.standEmergentR + style.StationStand.standDistance + detainD; - const detainX = model.position.x - (style.StationStand.standDetainDirection || drict) * (style.StationStand.standDetainOffset.x - model.width / 2); - const detainY = model.position.y + (style.StationStand.standDetainDirection || drict) * (style.StationStand.standDetainOffset.y) + drict * detainH; + const detainD = style.StationStand.detainCar.direction ? model.height - distance: -style.StationStand.safetyDoor.height; + const detainH = drict > 0 ? style.StationStand.standEmergent.mergentR : style.StationStand.standEmergent.mergentR + style.StationStand.safetyDoor.distance + detainD; + const detainX = model.position.x - (style.StationStand.detainCar.direction || drict) * (style.StationStand.detainCar.offset.x - model.width / 2); + const detainY = model.position.y + (style.StationStand.detainCar.direction || drict) * (style.StationStand.detainCar.offset.y) + drict * detainH; this.detain = new EDetain({ zlevel: this.zlevel, z: this.z, @@ -102,10 +102,10 @@ class StationStand extends Group { }); /** 停站时间*/ - const timeD = style.StationStand.standTimeDirection ? model.height - distance: -style.StationStand.standSafeHeight; - const timeH = drict > 0 ? style.StationStand.standEmergentR : style.StationStand.standEmergentR + style.StationStand.standDistance + timeD; - const timeX = model.position.x - (style.StationStand.standTimeDirection || drict) * (style.StationStand.standTimeOffset.x - model.width / 2); - const timeY = model.position.y + (style.StationStand.standTimeDirection || drict) * (style.StationStand.standTimeOffset.y) + drict * timeH; + const timeD = style.StationStand.stopTime.direction ? model.height - distance: -style.StationStand.safetyDoor.height; + const timeH = drict > 0 ? style.StationStand.standEmergent.mergentR : style.StationStand.standEmergent.mergentR + style.StationStand.safetyDoor.distance + timeD; + const timeX = model.position.x - (style.StationStand.stopTime.direction || drict) * (style.StationStand.stopTime.offset.x - model.width / 2); + const timeY = model.position.y + (style.StationStand.stopTime.direction || drict) * (style.StationStand.stopTime.offset.y) + drict * timeH; this.time = new ETime({ zlevel: this.zlevel, z: this.z + 1, @@ -116,10 +116,10 @@ class StationStand extends Group { }); /** 运行等级*/ - const levelD = style.StationStand.standLevelDirection ? model.height - distance: -style.StationStand.standSafeHeight; - const levelH = drict > 0 ? style.StationStand.standEmergentR : style.StationStand.standEmergentR + style.StationStand.standDistance + levelD; - const levelX = model.position.x - (style.StationStand.standLevelDirection || drict) * (style.StationStand.standLevelOffset.x - model.width / 2); - const levelY = model.position.y + (style.StationStand.standLevelDirection || drict) * (style.StationStand.standLevelOffset.y) + drict * levelH; + const levelD = style.StationStand.level.direction ? model.height - distance: -style.StationStand.safetyDoor.height; + const levelH = drict > 0 ? style.StationStand.standEmergent.mergentR : style.StationStand.standEmergent.mergentR + style.StationStand.safetyDoor.distance + levelD; + const levelX = model.position.x - (style.StationStand.level.direction || drict) * (style.StationStand.level.offset.x - model.width / 2); + const levelY = model.position.y + (style.StationStand.level.direction || drict) * (style.StationStand.level.offset.y) + drict * levelH; this.level = new ELevel({ zlevel: this.zlevel, z: this.z + 1, @@ -154,27 +154,27 @@ class StationStand extends Group { this.reentry.hide(); this.emergent.hide(); if (this.model.visible) { this.safeDoor.hasDoor(true); } - this.safeDoor.setColor(this.style.StationStand.standDoorDefaultColor); + this.safeDoor.setColor(this.style.StationStand.safetyDoor.defaultColor); } /** 空闲*/ spare() { - this.safeStand.setColor(this.style.StationStand.standSpareColor); + this.safeStand.setColor(this.style.StationStand.stand.spareColor); } /** 列车停站*/ stop() { - this.safeStand.setColor(this.style.StationStand.standStopColor); + this.safeStand.setColor(this.style.StationStand.stand.stopColor); } /** 指定列车跳站*/ designatedJumpStop() { - this.safeStand.setColor(this.style.StationStand.standDesignatedJumpStopColor); + this.safeStand.setColor(this.style.StationStand.stand.designatedJumpStopColor); } /** 站台紧急关闭*/ emergentClose() { - this.safeStand.setColor(this.style.StationStand.standSpareColor); + this.safeStand.setColor(this.style.StationStand.stand.spareColor); this.emergent.show(); } @@ -184,7 +184,7 @@ class StationStand extends Group { /** 站台跳停*/ jumpStop() { - this.safeStand.setColor(this.style.StationStand.standJumpStopColor); + this.safeStand.setColor(this.style.StationStand.stand.jumpStopColor); } /** 未设置扣车*/ @@ -195,13 +195,13 @@ class StationStand extends Group { /** 车站扣车*/ standDetainTrain() { this.detain.show(); - this.detain.setColor(this.style.StationStand.standDetainTrainTextColor); + this.detain.setColor(this.style.StationStand.detainCar.detainTrainTextColor); } /** 中心扣车*/ centerDetainTrain() { this.detain.show(); - this.detain.setColor(this.style.StationStand.standCenterDetainTrainColor); + this.detain.setColor(this.style.StationStand.detainCar.centerTrainColor); } /** 中心+车站扣车*/ @@ -233,17 +233,17 @@ class StationStand extends Group { /** 屏蔽门正常*/ doorNormal() { - this.safeDoor.setColor(this.style.StationStand.standDoorDefaultColor); + this.safeDoor.setColor(this.style.StationStand.safetyDoor.defaultColor); } /** 屏蔽门故障*/ doorFault() { - this.safeDoor.setColor(this.style.StationStand.standSplitDoorColor); + this.safeDoor.setColor(this.style.StationStand.safetyDoor.splitDoorColor); } /** 屏蔽门切除*/ doorSplit() { - this.safeDoor.setColor(this.style.StationStand.standSplitDoorColor); + this.safeDoor.setColor(this.style.StationStand.safetyDoor.splitDoorColor); } /** 无折返(默认)*/ @@ -254,12 +254,12 @@ class StationStand extends Group { /** 无人折返*/ noHumanReentry() { this.reentry.show(); - this.reentry.setColor(this.style.StationStand.standNoHumanReentryColor); + this.reentry.setColor(this.style.StationStand.reentry.noHumanColor); } /** 自动换端*/ autoChangeEnds() { this.reentry.show(); - this.reentry.setColor(this.style.StationStand.standAutoChangeEndsColor); + this.reentry.setColor(this.style.StationStand.reentry.AutoChangeEndsColor); } setState(state) { diff --git a/src/jmap/shape/Switch/ESwLnversion.js b/src/jmap/shape/Switch/ESwLnversion.js index 5863a776c..2534fd762 100644 --- a/src/jmap/shape/Switch/ESwLnversion.js +++ b/src/jmap/shape/Switch/ESwLnversion.js @@ -34,7 +34,7 @@ class ESwLnversion extends Group { points: model.sectionPoints }, style: { - fill: style.Section.sectionSpareColor + fill: style.Section.line.spareColor }, cursor: model.cursor, onmouseover: model.onmouseover, diff --git a/src/jmap/shape/Switch/index copy.js b/src/jmap/shape/Switch/index copy.js index ac8b2af31..139cd6b6e 100644 --- a/src/jmap/shape/Switch/index copy.js +++ b/src/jmap/shape/Switch/index copy.js @@ -31,8 +31,8 @@ export default class Switch extends Group { this.triangle = new JTriangle(model.intersection, model.skew); - let halfWidth = style.Section.sectionWidth / 2; - const switchWidth = style.Section.sectionWidth + style.Section.sectionBeyondWidth*2 + 0.8; + let halfWidth = style.Section.line.width / 2; + const switchWidth = style.Section.line.width + style.Section.line.beyondWidth*2 + 0.8; const swPadding = style.Switch.switchLen; const directx = this.triangle.drictx; const directy = this.triangle.dricty; @@ -98,8 +98,8 @@ export default class Switch extends Group { this.relocShelter.position = [-directx * rpx, -directy * 0.2]; this.relocShelter.hide(); - const sinX = style.Section.sectionWidth / this.triangle.getSinRate(); - const switchWidth1 = style.Section.sectionWidth / 2; + const sinX = style.Section.line.width / this.triangle.getSinRate(); + const switchWidth1 = style.Section.line.width / 2; const width1 = switchWidth1 * this.triangle.getSinRate(); const height1 = switchWidth1 * this.triangle.getCosRate(); const width2 = (height1 + switchWidth1) / this.triangle.getTanRate(); @@ -116,7 +116,7 @@ export default class Switch extends Group { ] }, style: { - fill: style.Section.sectionSpareColor + fill: style.Section.line.spareColor }, cursor: 'pointer', onmouseover: () => { this.name.getArrowText().show(); }, @@ -134,14 +134,14 @@ export default class Switch extends Group { y2: model.intersection.y }, style: { - lineWidth: style.Section.sectionWidth + style.Section.sectionBeyondWidth + 1, + lineWidth: style.Section.line.width + style.Section.line.beyondWidth + 1, stroke: style.backgroundColor } }); const arrowTextX = model.intersection.x + 10; const arrowTextY = model.intersection.y + 15; - const nameTextX = model.namePosition.x + model.intersection.x + this.triangle.drictx * (style.Section.sectionWidth * 3 + style.Switch.switchNameDistance) * this.triangle.getCotRate(); + const nameTextX = model.namePosition.x + model.intersection.x + this.triangle.drictx * (style.Section.line.width * 3 + style.Switch.switchNameDistance) * this.triangle.getCotRate(); const nameTextY = model.namePosition.y + model.intersection.y + this.triangle.dricty * (style.Switch.switchNameDistance); this.name = new ESwName({ zlevel: this.zlevel, @@ -309,35 +309,35 @@ export default class Switch extends Group { switch (state) { case '00': break; case '01': /** 空闲*/ - section.setStyle(style, this.style.Section.sectionSpareColor); + section.setStyle(style, this.style.Section.line.spareColor); break; case '02': /** 通信车占用*/ - section.setStyle(style, this.style.Section.sectionCommunicationOccupiedColor); + section.setStyle(style, this.style.Section.line.communicationOccupiedColor); break; case '03': /** 非通信车占用*/ - section.setStyle(style, this.style.Section.sectionUnCommunicationOccupiedColor); + section.setStyle(style, this.style.Section.line.unCommunicationOccupiedColor); break; case '04': /** 进路锁闭*/ - section.setStyle(style, this.style.Section.sectionRouteLockColor); + section.setStyle(style, this.style.Section.line.routeLockColor); break; case '05': /** 故障锁闭*/ - section.setStyle(style, this.style.Section.sectionFaultLockColor); + section.setStyle(style, this.style.Section.line.faultLockColor); break; case '06': /** 封锁*/ - section.setStyle(style, this.style.Section.sectionBlockColor); + section.setStyle(style, this.style.Section.line.blockColor); break; case '07': /** ATC切除*/ - section.setStyle(style, this.style.Section.sectionAtcExcisionColor); + section.setStyle(style, this.style.Section.line.atcExcisionColor); break; case '08': /** ATS切除*/ - section.setStyle(style, this.style.Section.sectionAtsExcisionColor); + section.setStyle(style, this.style.Section.line.atsExcisionColor); section.animateStyle(true) .when(1000, { fill: this.style.backgroundColor }) - .when(2000, { fill: this.style.Section.sectionAtsExcisionColor }) + .when(2000, { fill: this.style.Section.line.atsExcisionColor }) .start(); break; case '09': /** 进路延续保护 */ - section.setStyle(style, this.style.Section.sectionProtectiveLockColor); + section.setStyle(style, this.style.Section.line.protectiveLockColor); break; } } diff --git a/src/jmap/shape/Switch/index.js b/src/jmap/shape/Switch/index.js index 7cd9bc12f..33c983948 100644 --- a/src/jmap/shape/Switch/index.js +++ b/src/jmap/shape/Switch/index.js @@ -32,8 +32,8 @@ export default class Switch extends Group { this.triangle = new JTriangle(model.intersection, model.skew); - let halfWidth = style.Section.sectionWidth / 2; - const switchWidth = style.Section.sectionWidth + style.Section.sectionBeyondWidth*2 + 0.8; + let halfWidth = style.Section.line.width / 2; + const switchWidth = style.Section.line.width + style.Section.line.beyondWidth*2 + 0.8; const swPadding = style.Switch.switchLen; const directx = this.triangle.drictx; const directy = this.triangle.dricty; @@ -73,11 +73,11 @@ export default class Switch extends Group { const rpoint3 = [rpoint2[0], rpoint2[1] + directy * switchWidth]; const rpoint4 = [rpoint1[0] + this.triangle.getCos(slen), rpoint1[1] + this.triangle.getSin(slen)]; - const switchWidth1 = style.Section.sectionWidth / 2; + const switchWidth1 = style.Section.line.width / 2; const width1 = switchWidth1 * this.triangle.getSinRate(); const height1 = switchWidth1 * this.triangle.getCosRate(); const width2 = (height1 + switchWidth1) / this.triangle.getTanRate(); - const width3 = (style.Section.sectionWidth / this.triangle.getSinRate()) - width2 - width1; + const width3 = (style.Section.line.width / this.triangle.getSinRate()) - width2 - width1; const spoint1 = [model.intersection.x + directx * width3, model.intersection.y - directy * switchWidth1]; const spoint2 = [spoint1[0] - directx * (width2 + width1) - directx * width3, spoint1[1]]; const spoint3 = [model.intersection.x - directx * width3, model.intersection.y + directy * switchWidth1]; @@ -106,14 +106,14 @@ export default class Switch extends Group { y2: model.intersection.y }, style: { - lineWidth: style.Section.sectionWidth + style.Section.sectionBeyondWidth + 1, + lineWidth: style.Section.line.width + style.Section.line.beyondWidth + 1, stroke: style.backgroundColor } }); const arrowTextX = model.intersection.x + 10; const arrowTextY = model.intersection.y + 15; - const nameTextX = model.namePosition.x + model.intersection.x + this.triangle.drictx * (style.Section.sectionWidth * 3 + style.Switch.switchNameDistance) * this.triangle.getCotRate(); + const nameTextX = model.namePosition.x + model.intersection.x + this.triangle.drictx * (style.Section.line.width * 3 + style.Switch.switchNameDistance) * this.triangle.getCotRate(); const nameTextY = model.namePosition.y + model.intersection.y + this.triangle.dricty * (style.Switch.switchNameDistance); this.name = new ESwName({ zlevel: this.zlevel, @@ -276,35 +276,35 @@ export default class Switch extends Group { switch (state) { case '00': break; case '01': /** 空闲*/ - section.setStyle(style, this.style.Section.sectionSpareColor); + section.setStyle(style, this.style.Section.line.spareColor); break; case '02': /** 通信车占用*/ - section.setStyle(style, this.style.Section.sectionCommunicationOccupiedColor); + section.setStyle(style, this.style.Section.line.communicationOccupiedColor); break; case '03': /** 非通信车占用*/ - section.setStyle(style, this.style.Section.sectionUnCommunicationOccupiedColor); + section.setStyle(style, this.style.Section.line.unCommunicationOccupiedColor); break; case '04': /** 进路锁闭*/ - section.setStyle(style, this.style.Section.sectionRouteLockColor); + section.setStyle(style, this.style.Section.line.routeLockColor); break; case '05': /** 故障锁闭*/ - section.setStyle(style, this.style.Section.sectionFaultLockColor); + section.setStyle(style, this.style.Section.line.faultLockColor); break; case '06': /** 封锁*/ - section.setStyle(style, this.style.Section.sectionBlockColor); + section.setStyle(style, this.style.Section.line.blockColor); break; case '07': /** ATC切除*/ - section.setStyle(style, this.style.Section.sectionAtcExcisionColor); + section.setStyle(style, this.style.Section.line.atcExcisionColor); break; case '08': /** ATS切除*/ - section.setStyle(style, this.style.Section.sectionAtsExcisionColor); + section.setStyle(style, this.style.Section.line.atsExcisionColor); section.animateStyle(true) .when(1000, { fill: this.style.backgroundColor }) - .when(2000, { fill: this.style.Section.sectionAtsExcisionColor }) + .when(2000, { fill: this.style.Section.line.atsExcisionColor }) .start(); break; case '09': /** 进路延续保护 */ - section.setStyle(style, this.style.Section.sectionProtectiveLockColor); + section.setStyle(style, this.style.Section.line.protectiveLockColor); break; } } diff --git a/src/jmap/theme/bejing.js b/src/jmap/theme/bejing.js index e4af39b45..7a9081b33 100644 --- a/src/jmap/theme/bejing.js +++ b/src/jmap/theme/bejing.js @@ -18,7 +18,15 @@ class Beijing extends defaultSkin { linkTextColor: '#FFFFFF' }; this[deviceType.Section] = { - sectionTextPosition: 1, // 区段名称位置 1 上行 -1 下面 0 默认 + text: { // 区段文字属性 + fontSize: 10, // 字体大小 + fontFormat: 'consolas', // 字体族类 + fontColor: '#C0C0C0', // 字体颜色 + textAlign: 'center', // 水平对齐方式 + textPosition: 'inside', // 文字位置 + textVerticalAlign: 'middle', // 文字垂直对齐方式 + position: 1 // 区段名称位置 1 上行 -1 下面 0 默认 + }, /** 区段 宽度*/ sectionWidth: 5, /** 区段宽超出宽度*/ diff --git a/src/jmap/theme/fuzhou.js b/src/jmap/theme/fuzhou.js index acca5e351..c9c6e31f5 100644 --- a/src/jmap/theme/fuzhou.js +++ b/src/jmap/theme/fuzhou.js @@ -7,73 +7,61 @@ class Fuzhou extends defaultSkin { this[deviceType.Link] = { /** line 颜色*/ lineWidthColor: '#FFFFFF', - /** link 宽度*/ linkWidth: 4.4, - /** link 线条颜色*/ linkColor: '#3F3F3F', - /** link 字体颜色*/ linkTextColor: '#FFFFFF' }; this[deviceType.Section] = { - sectionTextPosition: 0, // 区段名称位置 1 上行 -1 下面 0 默认 - /** 区段 宽度*/ - sectionWidth: 5, - /** 区段宽超出宽度*/ - sectionBeyondWidth: 1, - /** 计轴 半径*/ - sectionAxleR: 3, - /** 计轴和区段之间的距离*/ /** 需要添加*/ - sectionAxleDistance: 5, - /** 限速线的宽短*/ - sectionSpeedLimitLinewidth: 1, - /** 限速线距离区段距离*/ - sectionSpeedLimitDistance: 5, - sectionSeparatorWidth: 1.2, // 分隔符宽度 - sectionEndSeparatorWidth: 3.5, // 尽头分隔符宽度 - sectionEndSeparatorStroke: '#3F3F3F', // 尽头分隔符颜色 - /** 区段侵入颜色*/ - sectionInvadeColor: '#EF0C08', - /** 限速线颜色*/ - sectionSpeedLimitColor: '#FFFF00', - sectionLogicalBackgroundColor: '#FFFF00', // 逻辑区段颜色 - /** 区段计轴颜色*/ - sectionAxleColor: '#FFFFFF', - /** 区段边界符颜色*/ - sectionSeparatorColor: '#3149C3', - /** 区段空闲颜色*/ - sectionSpareColor: '#3F3F3F', - /** 逻辑区段名称颜色*/ - sectionLogicalTextColor: '#FFFFFF', - /** 区段通信车占用颜色**/ - sectionCommunicationOccupiedColor: '#FF329A', - /** 区段非通讯车占用颜色*/ - sectionUnCommunicationOccupiedColor: '#FE0000', - /** 区段路由锁定颜色*/ - sectionRouteLockColor: '#FFFFFF', - /** 区段故障锁定颜色*/ - sectionFaultLockColor: '#9B4A0A', - /** 区段未定义颜色*/ - sectionUndefinedColor: '#0071C1', - /** 保护区段锁闭*/ - sectionProtectionSectionLockedColor: '#FEFF00', - /** 区段计轴预复位*/ - sectionAxleResetColor: '#00FFFF', - /** 区段封锁颜色*/ - sectionBlockColor: '#800080', - /** 区段atc切除颜色*/ - sectionAtcExcisionColor: '#A0522D', - /** 区段ats切除颜色*/ - sectionAtsExcisionColor: '#A0522D', - /** 区段延时释放颜色*/ - sectionTimeReleaseColor: '#3F3F3F', - /** 区段保护锁闭*/ - sectionProtectiveLockColor: '#FFFF00', - /** 区段保护延时解锁*/ - sectionProtectiveTimeReleaseColor: '#0071C1', - sectionAxleFailure: '#E6A23C' // #FFFF00 计轴失效 + text: { // 区段文字属性 + fontSize: 10, // 字体大小 + fontFormat: 'consolas', // 字体族类 + fontColor: '#C0C0C0', // 字体颜色 + textAlign: 'center', // 水平对齐方式 + textPosition: 'inside', // 文字位置 + textVerticalAlign: 'middle', // 文字垂直对齐方式 + position: 0 // 区段名称位置 1 上行 -1 下面 0 默认 + }, + line: { + width: 5, // 区段宽度 + beyondWidth: 1, // 区段宽超出宽度 + invadeColor: '#EF0C08', // 区段侵入颜色 + spareColor: '#3F3F3F', // 区段空闲颜色 + communicationOccupiedColor: '#FF329A', // 区段通信车占用颜色 + unCommunicationOccupiedColor: '#FE0000', // 区段非通讯车占用颜色 + routeLockColor: '#FFFFFF', // 区段路由锁定颜色 + faultLockColor: '#9B4A0A', // 区段故障锁定颜色 + undefinedColor: '#0071C1', // 区段未定义颜色 + protectionLockedColor: '#FEFF00', // 保护区段锁闭(未用) + blockColor: '#800080', // 区段封锁颜色 + atcExcisionColor: '#A0522D', // 区段atc切除颜色 + atsExcisionColor: '#A0522D', // 区段ats切除颜色 + timeReleaseColor: '#3F3F3F', // 区段延时释放颜色 + protectiveLockColor: '#FFFF00', // 区段保护锁闭 + protectiveTimeReleaseColor: '#0071C1', // 区段保护延时解锁 + logicalColor: '#FFFF00', // 逻辑区段颜色 (未用) + logicalTextColor: '#FFFFFF' // 逻辑区段名称颜色 (未用) + }, + axle: { + radius: 3, // 计轴 半径 + distance: 5, // 计轴和区段之间的距离 (未用) + color: '#FFFFFF', // 区段计轴颜色 + resetColor: '#00FFFF', // 区段计轴预复位颜色 + Failure: '#E6A23C' // #FFFF00 计轴失效 + }, + speedLimit: { // 限速元素 + width: 1, // 限速线的宽短 + Distance: 5, // 限速线距离区段距离 + lineColor: '#FFFF00' // 限速线颜色 + }, + separator: { + width: 1.2, // 分隔符宽度 + endWidth: 3.5, // 尽头分隔符宽度 + endColor: '#3F3F3F', // 尽头分隔符颜色 + color: '#3149C3' // 区段边界符颜色 + } }; this[deviceType.Signal] = { /** 信号机宽度 */ @@ -130,76 +118,52 @@ class Fuzhou extends defaultSkin { signalLampBlueColor: '#0070C0' }; this[deviceType.StationStand] = { - /** 站台和屏蔽门之间的距离*/ - standDistance: 8, - /** 站台屏蔽门高度*/ - standSafeHeight: 3, - /** 站台首端字体大小*/ - standHeadFontSize: 10, - /** 站台默认字体大小*/ - standTextFontSize: 10, - /** 站台紧急关闭半径*/ - standEmergentR: 4, - /** 站台紧急关闭偏移量*/ - standEmergentOffset: {x: 0, y: 40}, - /** 扣车方向*/ - standDetainDirection: -1, - /** 扣车偏移量*/ - standDetainOffset: {x: -8, y: -6}, - /** 运行时间方向*/ - standTimeDirection: 1, - /** 运行时间偏移量*/ - standTimeOffset: {x: -8, y: 26}, - /** 运行等级方向*/ - standLevelDirection: 1, - /** 运行等级偏移量*/ - standLevelOffset: {x: -8, y: 6}, - /** 折返方向*/ - standReentryDirection: 0, - /** 折返偏移量*/ - standReentryOffset: {x: -16, y: 20}, - /** 扣车显示内容*/ - standDetainText: 'H', - /** 站台无人折返*/ - standNoHumanReentryColor: '#0F16DA', - /** 站台自动换端*/ - standAutoChangeEndsColor: '#0BF400', - /** 站台空闲颜色*/ - standSpareColor: '#606060', - /** 站台列车停站颜色*/ - standStopColor: '#FEFE00', - /** 站台跳停颜色*/ - standJumpStopColor: '#9A99FF', - /** 站台指定列车跳停颜色*/ - standDesignatedJumpStopColor: 'lightSkyBlue', - /** 站台紧急关闭颜色*/ - standEmergentCloseColor: '#F61107', - /** 停站时间字体颜色*/ - standTimeTextColor: '#FFFFFF', - /** 停站等级字体颜色*/ - standLevelTextColor: '#FFFFFF', - /** 车站扣车颜色*/ - standDetainTrainColor: '#E4EF50', - /** 中心扣车颜色*/ - standCenterDetainTrainColor: '#FFFFFF', - /** 车站+中心扣车颜色*/ - standAndCenterDetainTrainColor: '#F61107', - /** 屏蔽门默认颜色*/ - standDoorDefaultColor: '#00FF00', - /** 屏蔽门切除颜色*/ - standSplitDoorColor: '#F61107', - /** 车站扣除文字颜色*/ - standDetainTrainTextColor: '#E4EF50', - /** 计数器字体颜色*/ - stationCounterTextColor: '#FFFFFF', - /** 计数器边框颜色*/ - stationCounterBorderColor: '#E4EF50', - /** 延迟解锁倒计时和设备文字之间的距离*/ - stationDelayUnlockDistance: 3, - /** 延时解锁字体颜色*/ - stationDelayUnlockTextColor: '#FFFFFF', - /** 延迟解锁边框颜色*/ - stationDelayUnlockBorderColor: '#FFFFFF' + common: { // 通用属性 + textFontSize: 10 // 站台默认字体大小 + }, + safetyDoor: { // 屏蔽门 + height: 3, // 站台屏蔽门高度 + distance: 8, // 站台和屏蔽门之间的距离 + defaultColor: '#00FF00', // 屏蔽门默认颜色 + splitDoorColor: '#F61107' // 屏蔽门切除颜色 + }, + stand: { // 站台 + headFontSize: 10, // 站台首端字体大小 + spareColor: '#606060', // 站台空闲颜色 + stopColor: '#FEFE00', // 站台列车停站颜色 + jumpStopColor: '#9A99FF', // 站台跳停颜色 + designatedJumpStopColor: 'lightSkyBlue' // 站台指定列车跳停颜色 + }, + standEmergent: { // 紧急关闭 + mergentR: 4, // 站台紧急关闭半径 + offset: {x: 0, y: 40}, // 站台紧急关闭偏移量 + closeColor: '#F61107' // 站台紧急关闭颜色 + }, + reentry: { // 站台折返策略 + direction: 0, // 折返方向 + offset: {x: -16, y: 20}, // 折返偏移量 + noHumanColor: '#0F16DA', // 站台无人折返 + AutoChangeEndsColor: '#0BF400' // 站台自动换端 + }, + detainCar: { // 扣车 + text: 'H', // 扣车显示内容 + direction: -1, // 扣车方向 + offset: {x: -8, y: -6}, // 扣车偏移量 + trainColor: '#E4EF50', // 车站扣车颜色 + centerTrainColor: '#FFFFFF', // 中心扣车颜色 + andCenterTrainColor: '#F61107', // 车站+中心扣车颜色 + detainTrainTextColor: '#E4EF50' // 车站扣除文字颜色 + }, + stopTime: { // 停站时间 + direction: 1, // 运行时间方向 + offset: {x: -8, y: 26}, // 运行时间偏移量 + textColor: '#FFFFFF' // 停站时间字体颜色 + }, + level: { // 运行等级 + direction: 1, // 运行等级方向 + offset: {x: -8, y: 6}, // 运行等级偏移量 + textColor: '#FFFFFF' // 停站等级字体颜色 + } }; this[deviceType.StationControl] = { singleControlNum: 2, From ffe150a3516660356dc8643b32c72c726ed75ba6 Mon Sep 17 00:00:00 2001 From: zyy <1787816799@qq.com> Date: Tue, 23 Jul 2019 18:05:26 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/shape/ImageControl/index.js | 3 +- src/jmap/shape/Section/EAxle.js | 125 +++++++----- src/jmap/shape/Section/ELimitLines.js | 270 ++++++++++++++++---------- src/jmap/shape/Section/index.js | 142 +++++++++----- src/jmap/shape/Switch/index.js | 2 +- src/jmap/theme/bejing.js | 214 ++++++++------------ src/jmap/utils/parser.js | 6 +- src/views/jmap/index.vue | 2 +- 8 files changed, 434 insertions(+), 330 deletions(-) diff --git a/src/jmap/shape/ImageControl/index.js b/src/jmap/shape/ImageControl/index.js index a13d6c94b..5e8e2fe71 100644 --- a/src/jmap/shape/ImageControl/index.js +++ b/src/jmap/shape/ImageControl/index.js @@ -7,13 +7,14 @@ import Image from 'zrender/src/graphic/Image'; export default class ImageControl extends Group { constructor({ _code, _type, zlevel, model, state }, style) { super(); + console.log(model); this._code = _code; this._type = _type; this.zlevel = zlevel; this.model = model; this.state = state; this.style = style; - this.z = model.zIndex || 1; + this.z = model.zIndex || 1; // 默认5 this._create(); } diff --git a/src/jmap/shape/Section/EAxle.js b/src/jmap/shape/Section/EAxle.js index 4023cad6b..99527d79a 100644 --- a/src/jmap/shape/Section/EAxle.js +++ b/src/jmap/shape/Section/EAxle.js @@ -1,56 +1,85 @@ -import Group from 'zrender/src/container/Group'; -import Line from 'zrender/src/graphic/shape/Line'; -import Circle from 'zrender/src/graphic/shape/Circle'; +// import Group from 'zrender/src/container/Group'; +// import Line from 'zrender/src/graphic/shape/Line'; +// import Circle from 'zrender/src/graphic/shape/Circle'; +import Path from 'zrender/src/graphic/Path'; -/** 计轴*/ -export default class EAxle extends Group { - constructor(model) { - super(); - this.model = model; - this.zlevel = model.zlevel; - this.z = 5; - this._create(model); - } - - _create(model) { +// 计轴 +export const EAxle = Path.extend({ + type: 'EAxle', + shape: { + point: null + }, + buildPath: function (ctx, model) { if (model && model.style && model.traingle) { const axleLength = 2 * model.style.Section.axle.radius; const positionx = model.point.x + model.drictx * (model.traingle.getCos(axleLength)); const positiony = model.point.y + model.dricty * (model.traingle.getCos(axleLength)); + // 圆弧 + const arcX = positionx - model.dricty * model.traingle.getSin(axleLength); + const arcY = positiony + model.drictx * model.traingle.getSin(axleLength); + const arcR = model.style.Section.axle.radius; + ctx.arc(arcX, arcY, arcR, 0, 2 * Math.PI, false); + ctx.closePath(); - this.line = new Line({ - zlevel: this.zlevel, - z: this.z, - progressive: model.progressive, - shape: { - x1: positionx - model.traingle.getCos(axleLength) - model.dricty * model.traingle.getSin(axleLength), - y1: positiony + model.drictx * model.traingle.getSin(axleLength) - model.traingle.getSin(axleLength), - x2: positionx + model.traingle.getCos(axleLength) - model.dricty * model.traingle.getSin(axleLength), - y2: positiony + model.drictx * model.traingle.getSin(axleLength) + model.traingle.getSin(axleLength) - }, - style: { - GBaseLineWidth: 1, - stroke: model.style.Section.axle.color - } - }); - this.axle = new Circle({ - zlevel: this.zlevel, - z: this.z, - progressive: model.progressive, - shape: { - cx: positionx - model.dricty * model.traingle.getSin(axleLength), - cy: positiony + model.drictx * model.traingle.getSin(axleLength), - r: model.style.Section.axle.radius - }, - style: { - GBaseLineWidth: 1, - stroke: model.style.Section.axle.color, - fill: model.style.transparentColor - } - }); - - this.add(this.line); - this.add(this.axle); + const x1 = positionx - model.traingle.getCos(axleLength) - model.dricty * model.traingle.getSin(axleLength); + const y1 = positiony + model.drictx * model.traingle.getSin(axleLength) - model.traingle.getSin(axleLength); + const x2 = positionx + model.traingle.getCos(axleLength) - model.dricty * model.traingle.getSin(axleLength); + const y2 = positiony + model.drictx * model.traingle.getSin(axleLength) + model.traingle.getSin(axleLength); + ctx.moveTo(x1, y1); + ctx.lineTo(x2, y2); + ctx.closePath(); } } -} +}); + +// export default class EAxle extends Group { +// constructor(model) { +// super(); +// this.model = model; +// this.zlevel = model.zlevel; +// this.z = 5; +// this._create(model); +// } + +// _create(model) { +// if (model && model.style && model.traingle) { +// const axleLength = 2 * model.style.Section.axle.radius; +// const positionx = model.point.x + model.drictx * (model.traingle.getCos(axleLength)); +// const positiony = model.point.y + model.dricty * (model.traingle.getCos(axleLength)); + +// this.line = new Line({ +// zlevel: this.zlevel, +// z: this.z, +// progressive: model.progressive, +// shape: { +// x1: positionx - model.traingle.getCos(axleLength) - model.dricty * model.traingle.getSin(axleLength), +// y1: positiony + model.drictx * model.traingle.getSin(axleLength) - model.traingle.getSin(axleLength), +// x2: positionx + model.traingle.getCos(axleLength) - model.dricty * model.traingle.getSin(axleLength), +// y2: positiony + model.drictx * model.traingle.getSin(axleLength) + model.traingle.getSin(axleLength) +// }, +// style: { +// GBaseLineWidth: 1, +// stroke: model.style.Section.axle.color +// } +// }); +// this.axle = new Circle({ +// zlevel: this.zlevel, +// z: this.z, +// progressive: model.progressive, +// shape: { +// cx: positionx - model.dricty * model.traingle.getSin(axleLength), +// cy: positiony + model.drictx * model.traingle.getSin(axleLength), +// r: model.style.Section.axle.radius +// }, +// style: { +// GBaseLineWidth: 1, +// stroke: model.style.Section.axle.color, +// fill: model.style.transparentColor +// } +// }); + +// this.add(this.line); +// this.add(this.axle); +// } +// } +// } diff --git a/src/jmap/shape/Section/ELimitLines.js b/src/jmap/shape/Section/ELimitLines.js index 1c5b14eae..1379456c1 100644 --- a/src/jmap/shape/Section/ELimitLines.js +++ b/src/jmap/shape/Section/ELimitLines.js @@ -1,126 +1,198 @@ -import Group from 'zrender/src/container/Group'; -import BezierCurve from 'zrender/src/graphic/shape/BezierCurve'; -import Line from 'zrender/src/graphic/shape/Line'; +// import Group from 'zrender/src/container/Group'; +// import BezierCurve from 'zrender/src/graphic/shape/BezierCurve'; +// import Line from 'zrender/src/graphic/shape/Line'; +import JTriangle from '../../utils/JTriangle'; +import Path from 'zrender/src/graphic/Path'; -/** 创建区段限速限集合*/ -export default class ELimitLines extends Group { - constructor(model) { - super(); - this.model = model; - this.zlevel = model.zlevel; - this.z = model.z; - this._create(model); - } - - _create(model) { +// 创建区段限速限集合 +export const ELimitLines = Path.extend({ + type: 'ELimitLines', + shape: { + points: null + }, + buildPath: function (ctx, model) { /** 创建区段*/ if (model && model.points.length > 1) { if (model.isCurve) { + ctx.beginPath(); const shape = {}; for (let i = 1; i < (model.points.length - 1); i++) { shape[`cpx${i}`] = model.points[i].x; shape[`cpy${i}`] = model.points[i].y; } - shape[`x1`] = model.points[0].x; shape[`y1`] = model.points[0].y; shape[`x2`] = model.points[model.points.length - 1].x; shape[`y2`] = model.points[model.points.length - 1].y; - this.add(new BezierCurve({ - isLine: true, - zlevel: this.zlevel, - progressive: model.progressive, - z: this.z, - culling: true, - shape: shape, - position: model.position, - style: { - lineWidth: model.style.Section.speedLimit.width, - stroke: model.style.Section.speedLimit.lineColor, - fillOpacity: 0 - } - })); + ctx.moveTo(shape[`x1`], shape[`y1`]); + if (model.points.length <= 3) { + ctx.quadraticCurveTo(shape[`cpx1`], shape[`cpy1`], shape[`x2`], shape[`y2`]); + } else { + ctx.bezierCurveTo(shape[`cpx1`], shape[`cpy1`], shape[`cpx2`], shape[`cpy2`], shape[`x2`], shape[`y2`]); + } } else { + const swPadding = model.style.Switch.switchLen; // 定位和反位时区段距离岔芯的距离 + var switchWidth = model.style.Section.line.width + model.style.Section.line.beyondWidth; // 道岔宽度 const beg = Object.assign({}, model.points[0]); const end = Object.assign({}, model.points[model.points.length - 1]); + if (model.isSwitchSection && beg.y !== end.y) { + const swch = model.switch; + if (swch) { + const traingle = new JTriangle(swch.intersection, swch.skew); + if ((swch.intersection.x === beg.x) && (swch.intersection.y === beg.y)) { + beg.x = beg.x + traingle.drictx * (swPadding + switchWidth) * traingle.getCotRate(); + beg.y = beg.y + traingle.dricty * (swPadding + switchWidth); + } + + if ((swch.intersection.x === end.x) && (swch.intersection.y === end.y)) { + end.x = end.x + traingle.drictx * (swPadding + switchWidth) * traingle.getCotRate(); + end.y = end.y + traingle.dricty * (swPadding + switchWidth); + } + } + } if (model.points.length == 2) { - this.add(new Line({ - isLine: true, - zlevel: this.zlevel, - progressive: model.progressive, - z: this.z, - position: model.position, - shape: { - x1: beg.x, - y1: beg.y, - x2: end.x, - y2: end.y - }, - style: { - lineWidth: model.style.Section.speedLimit.width, - stroke: model.style.Section.speedLimit.lineColor - } - })); + ctx.moveTo(beg.x, beg.y); + ctx.lineTo(end.x, end.y); + ctx.closePath(); } else { - this.add(new Line({ - isLine: true, - zlevel: this.zlevel, - progressive: model.progressive, - z: this.z, - position: model.position, - shape: { - x1: beg.x, - y1: beg.y, - x2: model.points[1].x, - y2: model.points[1].y - }, - style: { - lineWidth: model.style.Section.speedLimit.width, - stroke: model.style.Section.speedLimit.lineColor - } - })); + ctx.moveTo(beg.x, beg.y); + ctx.lineTo(model.points[1].x, model.points[1].y); + ctx.closePath(); for (let i = 1; i < (model.points.length - 2); i++) { - this.add(new Line({ - isLine: true, - zlevel: this.zlevel, - z: this.z, - progressive: model.progressive, - position: model.position, - shape: { - x1: model.points[i].x, - y1: model.points[i].y, - x2: model.points[i + 1].x, - y2: model.points[i + 1].y - }, - style: { - lineWidth: model.style.Section.speedLimit.width, - stroke: model.style.Section.speedLimit.lineColor - } - })); + ctx.moveTo(model.points[i].x, model.points[i].y); + ctx.lineTo(model.points[i + 1].x, model.points[i + 1].y); + ctx.closePath(); } - - this.add(new Line({ - isLine: true, - zlevel: this.zlevel, - z: this.z, - position: model.position, - progressive: model.progressive, - shape: { - x1: model.points[model.points.length - 2].x, - y1: model.points[model.points.length - 2].y, - x2: end.x, - y2: end.y - }, - style: { - lineWidth: model.style.Section.speedLimit.width, - stroke: model.style.Section.speedLimit.lineColor - } - })); + ctx.moveTo(model.points[model.points.length - 2].x, model.points[model.points.length - 2].y); + ctx.lineTo(end.x, end.y); + ctx.closePath(); } } } } -} +}); + +// export default class ELimitLines extends Group { +// constructor(model) { +// super(); +// this.model = model; +// this.zlevel = model.zlevel; +// this.z = model.z; +// this._create(model); +// } + +// _create(model) { +// /** 创建区段*/ +// if (model && model.points.length > 1) { +// if (model.isCurve) { +// const shape = {}; +// for (let i = 1; i < (model.points.length - 1); i++) { +// shape[`cpx${i}`] = model.points[i].x; +// shape[`cpy${i}`] = model.points[i].y; +// } + +// shape[`x1`] = model.points[0].x; +// shape[`y1`] = model.points[0].y; +// shape[`x2`] = model.points[model.points.length - 1].x; +// shape[`y2`] = model.points[model.points.length - 1].y; + +// this.add(new BezierCurve({ +// isLine: true, +// zlevel: this.zlevel, +// progressive: model.progressive, +// z: this.z, +// culling: true, +// shape: shape, +// position: model.position, +// style: { +// lineWidth: model.style.Section.speedLimit.width, +// stroke: model.style.Section.speedLimit.lineColor, +// fillOpacity: 0 +// } +// })); +// } else { +// const beg = Object.assign({}, model.points[0]); +// const end = Object.assign({}, model.points[model.points.length - 1]); + +// if (model.points.length == 2) { +// this.add(new Line({ +// isLine: true, +// zlevel: this.zlevel, +// progressive: model.progressive, +// z: this.z, +// position: model.position, +// shape: { +// x1: beg.x, +// y1: beg.y, +// x2: end.x, +// y2: end.y +// }, +// style: { +// lineWidth: model.style.Section.speedLimit.width, +// stroke: model.style.Section.speedLimit.lineColor +// } +// })); +// } else { +// this.add(new Line({ +// isLine: true, +// zlevel: this.zlevel, +// progressive: model.progressive, +// z: this.z, +// position: model.position, +// shape: { +// x1: beg.x, +// y1: beg.y, +// x2: model.points[1].x, +// y2: model.points[1].y +// }, +// style: { +// lineWidth: model.style.Section.speedLimit.width, +// stroke: model.style.Section.speedLimit.lineColor +// } +// })); + +// for (let i = 1; i < (model.points.length - 2); i++) { +// this.add(new Line({ +// isLine: true, +// zlevel: this.zlevel, +// z: this.z, +// progressive: model.progressive, +// position: model.position, +// shape: { +// x1: model.points[i].x, +// y1: model.points[i].y, +// x2: model.points[i + 1].x, +// y2: model.points[i + 1].y +// }, +// style: { +// lineWidth: model.style.Section.speedLimit.width, +// stroke: model.style.Section.speedLimit.lineColor +// } +// })); +// } + +// this.add(new Line({ +// isLine: true, +// zlevel: this.zlevel, +// z: this.z, +// position: model.position, +// progressive: model.progressive, +// shape: { +// x1: model.points[model.points.length - 2].x, +// y1: model.points[model.points.length - 2].y, +// x2: end.x, +// y2: end.y +// }, +// style: { +// lineWidth: model.style.Section.speedLimit.width, +// stroke: model.style.Section.speedLimit.lineColor +// } +// })); +// } +// } +// } +// } +// } diff --git a/src/jmap/shape/Section/index.js b/src/jmap/shape/Section/index.js index 0096dcf85..8ed6ce38a 100644 --- a/src/jmap/shape/Section/index.js +++ b/src/jmap/shape/Section/index.js @@ -1,10 +1,10 @@ import Group from 'zrender/src/container/Group'; import ETextName from '../element/ETextName'; // 名称文字 (共有) import ERelease from './ERelease'; // 线段 (共有) -import ELimitLines from './ELimitLines'; // 区段限速 (私有) +import { ELimitLines } from './ELimitLines'; // 区段限速 (私有) import ELines from './ELines'; // 创建多线条 曲线 (私有) import ESeparator from './ESeparator'; // 分隔符 (私有) -import EAxle from './EAxle'; // 创建计轴 (私有) +import { EAxle } from './EAxle'; // 创建计轴 (私有) import JTriangle from '../../utils/JTriangle'; /** 区段*/ @@ -14,7 +14,7 @@ export default class Section extends Group { this._code = _code; this._type = _type; this.zlevel = zlevel; - this.z = model.layer || 5; + this.z = 5; this.model = model; this.state = state; this.style = style; @@ -81,26 +81,44 @@ export default class Section extends Group { // 创建限速线 this.speedLimitLeft = new ELimitLines({ zlevel: this.zlevel, - z: this.z, + z: model.isCurve ? this.z - 1 : this.z, progressive: 5, position: [x, -y], - isCurve: model.isCurve, - points: model.points, - isSwitchSection: model.isSwitchSection, - relSwitchCode: model.relSwitchCode, - style: style + isLine: true, + culling: model.isCurve, // 是否裁剪 + shape: { + points: model.points, + isCurve: model.isCurve, // 是否曲线 + isSwitchSection: model.isSwitchSection, + relSwitchCode: model.relSwitchCode, + switch: model.switch, + style: style + }, + style: { + lineWidth: style.Section.speedLimit.width, + stroke: style.Section.speedLimit.lineColor + } }); this.speedLimitRight = new ELimitLines({ zlevel: this.zlevel, - z: this.z, + z: model.isCurve ? this.z - 1 : this.z, progressive: 5, - position: [-x, y], - isCurve: model.isCurve, - points: model.points, - isSwitchSection: model.isSwitchSection, - relSwitchCode: model.relSwitchCode, - style: style + position: [x, -y], + isLine: true, + culling: model.isCurve, // 是否裁剪 + shape: { + points: model.points, + isCurve: model.isCurve, // 是否曲线 + isSwitchSection: model.isSwitchSection, + relSwitchCode: model.relSwitchCodes, + switch: model.switch, + style: style + }, + style: { + lineWidth: style.Section.speedLimit.width, + stroke: style.Section.speedLimit.lineColor + } }); this.add(this.section); @@ -267,54 +285,78 @@ export default class Section extends Group { if (model && style && model.axleShow && model.points && model.points.length > 1) { traingle = new JTriangle(model.points[0], model.points[1]); this.lUpAxle = new EAxle({ - style: style, - progressive: 4, zlevel: this.zlevel, - point: { - x: model.points[0].x, - y: model.points[0].y + z: this.z + 5, // 层级大于道岔z 否则会压住显示完整 + shape: { + point: { + x: model.points[0].x, + y: model.points[0].y + }, + drictx: 1, + dricty: -1, + traingle: traingle, + style: style }, - drictx: 1, - dricty: -1, - traingle: traingle + style: { + GBaseLineWidth: 1, + stroke: style.Section.axle.color + } }); this.lBottomAxle = new EAxle({ - style: style, - progressive: 4, zlevel: this.zlevel, - point: { - x: model.points[0].x, - y: model.points[0].y + z: this.z + 5, // 层级大于道岔z 否则会压住显示完整 + shape: { + point: { + x: model.points[0].x, + y: model.points[0].y + }, + drictx: 1, + dricty: 1, + traingle: traingle, + style: style }, - drictx: 1, - dricty: 1, - traingle: traingle + style: { + GBaseLineWidth: 1, + stroke: style.Section.axle.color + } }); traingle = new JTriangle(model.points[model.points.length - 2], model.points[model.points.length - 1]); this.rUpAxle = new EAxle({ - style: style, - progressive: 4, zlevel: this.zlevel, - point: { - x: model.points[model.points.length - 1].x, - y: model.points[model.points.length - 1].y + z: this.z + 5, // 层级大于道岔z 否则会压住显示完整 + shape: { + point: { + x: model.points[model.points.length - 1].x, + y: model.points[model.points.length - 1].y + }, + drictx: -1, + dricty: -1, + traingle: traingle, + style: style }, - drictx: -1, - dricty: -1, - traingle: traingle + style: { + GBaseLineWidth: 1, + stroke: style.Section.axle.color + } }); this.rBottomAxle = new EAxle({ - style: style, - progressive: 4, zlevel: this.zlevel, - point: { - x: model.points[model.points.length - 1].x, - y: model.points[model.points.length - 1].y + z: this.z + 5, // 层级大于道岔z 否则会压住显示完整 + shape: { + point: { + x: model.points[model.points.length - 1].x, + y: model.points[model.points.length - 1].y + }, + drictx: -1, + dricty: 1, + traingle: traingle, + style: style }, - drictx: -1, - dricty: 1, - traingle: traingle + style: { + GBaseLineWidth: 1, + stroke: style.Section.axle.color + } }); this.add(this.lUpAxle); @@ -386,8 +428,8 @@ export default class Section extends Group { }); this.release.hide(); - this.speedLimitLeft.hide(); - this.speedLimitRight.hide(); + // this.speedLimitLeft.hide(); + // this.speedLimitRight.hide(); } } diff --git a/src/jmap/shape/Switch/index.js b/src/jmap/shape/Switch/index.js index 33c983948..472d39360 100644 --- a/src/jmap/shape/Switch/index.js +++ b/src/jmap/shape/Switch/index.js @@ -20,7 +20,7 @@ export default class Switch extends Group { this.jmap = jmap; this.selected = false; this.zlevel = zlevel; - this.z = 8; + this.z = 6; this._create(); this.setState(state); diff --git a/src/jmap/theme/bejing.js b/src/jmap/theme/bejing.js index 7a9081b33..239f8d580 100644 --- a/src/jmap/theme/bejing.js +++ b/src/jmap/theme/bejing.js @@ -25,66 +25,46 @@ class Beijing extends defaultSkin { textAlign: 'center', // 水平对齐方式 textPosition: 'inside', // 文字位置 textVerticalAlign: 'middle', // 文字垂直对齐方式 - position: 1 // 区段名称位置 1 上行 -1 下面 0 默认 + position: 0 // 区段名称位置 1 上行 -1 下面 0 默认 }, - /** 区段 宽度*/ - sectionWidth: 5, - /** 区段宽超出宽度*/ - sectionBeyondWidth: 0, - /** 计轴 半径*/ - sectionAxleR: 3, - /** 计轴和区段之间的距离*/ - sectionAxleDistance: 5, - /** 限速线的宽度*/ - sectionSpeedLimitLinewidth: 1, - /** 限速线距离区段距离*/ - sectionSpeedLimitDistance: 5, - /** 分隔符宽度*/ - sectionSeparatorWidth: 1.2, - sectionEndSeparatorWidth: 1.2, // 尽头分隔符宽度 - sectionEndSeparatorStroke: '#7F7F7F', // 尽头分隔符颜色 - /** 区段侵入颜色*/ - sectionInvadeColor: '#EF0C08', - /** 限速线颜色*/ - sectionSpeedLimitColor: '#FFFF00', - /** 逻辑区段颜色*/ - sectionLogicalBackgroundColor: '#FFFF00', - /** 区段计轴颜色*/ - sectionAxleColor: '#C0C0C0', - /** 区段边界符颜色*/ - sectionSeparatorColor: '#7F7F7F', - /** 区段空闲颜色*/ - sectionSpareColor: '#606060', - /** 逻辑区段名称颜色*/ - sectionLogicalTextColor: '#C0C0C0', - /** 区段通信车占用颜色**/ - sectionCommunicationOccupiedColor: '#FF0000', - /** 区段非通讯车占用颜色*/ - sectionUnCommunicationOccupiedColor: '#800080', - /** 区段路由锁定颜色*/ - sectionRouteLockColor: '#FFFFFF', - /** 区段故障锁定颜色*/ - sectionFaultLockColor: '#006400', - /** 区段未定义颜色*/ - sectionUndefinedColor: '#0071C1', - /** 保护区段锁闭*/ - sectionProtectionSectionLockedColor: '#FEFF00', - /** 区段计轴预复位*/ - sectionAxleResetColor: '#00FFFF', - /** 区段封锁颜色*/ - sectionBlockColor: '#800080', - /** 区段atc切除颜色*/ - sectionAtcExcisionColor: '#A0522D', - /** 区段ats切除颜色*/ - sectionAtsExcisionColor: '#A0522D', - /** 区段延时释放颜色*/ - sectionTimeReleaseColor: '#3F3F3F', - /** 区段保护锁闭*/ - sectionProtectiveLockColor: '#FFFF00', - /** 区段保护延时解锁*/ - sectionProtectiveTimeReleaseColor: '#0071C1', - /** 计轴失效*/ - sectionAxleFailure: '#E6A23C' // #FFFF00 + line: { + width: 5, // 区段宽度 + beyondWidth: 0, // 区段宽超出宽度 + invadeColor: '#EF0C08', // 区段侵入颜色 + spareColor: '#606060', // 区段空闲颜色 + communicationOccupiedColor: '#FF0000', // 区段通信车占用颜色 + unCommunicationOccupiedColor: '#800080', // 区段非通讯车占用颜色 + routeLockColor: '#FFFFFF', // 区段路由锁定颜色 + faultLockColor: '#006400', // 区段故障锁定颜色 + undefinedColor: '#0071C1', // 区段未定义颜色 + protectionLockedColor: '#FEFF00', // 保护区段锁闭(未用) + blockColor: '#800080', // 区段封锁颜色 + atcExcisionColor: '#A0522D', // 区段atc切除颜色 + atsExcisionColor: '#A0522D', // 区段ats切除颜色 + timeReleaseColor: '#3F3F3F', // 区段延时释放颜色 + protectiveLockColor: '#FFFF00', // 区段保护锁闭 + protectiveTimeReleaseColor: '#0071C1', // 区段保护延时解锁 + logicalColor: '#FFFF00', // 逻辑区段颜色 (未用) + logicalTextColor: '#C0C0C0' // 逻辑区段名称颜色 (未用) + }, + axle: { + radius: 3, // 计轴 半径 + distance: 5, // 计轴和区段之间的距离 (未用) + color: '#C0C0C0', // 区段计轴颜色 + resetColor: '#00FFFF', // 区段计轴预复位颜色 + Failure: '#E6A23C' // #FFFF00 计轴失效 + }, + speedLimit: { // 限速元素 + width: 1, // 限速线的宽度 + Distance: 5, // 限速线距离区段距离 + lineColor: '#FFFF00' // 限速线颜色 + }, + separator: { + width: 1.2, // 分隔符宽度 + endWidth: 1.2, // 尽头分隔符宽度 + endColor: '#7F7F7F', // 尽头分隔符颜色 + color: '#7F7F7F' // 区段边界符颜色 + } }; this[deviceType.Signal] = { /** 信号机宽度 */ @@ -141,76 +121,52 @@ class Beijing extends defaultSkin { signalLampBlueColor: '#0070C0' }; this[deviceType.StationStand] = { - /** 站台和屏蔽门之间的距离*/ - standDistance: 9, - /** 站台屏蔽门高度*/ - standSafeHeight: 1.6, - /** 站台首端字体大小*/ - standHeadFontSize: 8, - /** 站台默认字体大小*/ - standTextFontSize: 8, - /** 站台紧急关闭半径*/ - standEmergentR: 4, - /** 站台紧急关闭偏移量*/ - standEmergentOffset: {x: 0, y: 0}, - /** 扣车方向*/ - standDetainDirection: 1, - /** 扣车偏移量*/ - standDetainOffset: {x: -8, y: 13}, - /** 运行时间方向*/ - standTimeDirection: 1, - /** 运行时间偏移量*/ - standTimeOffset: {x: -8, y: 3}, - /** 运行等级方向*/ - standLevelDirection: 1, - /** 运行等级偏移量*/ - standLevelOffset: {x: -8, y: 22}, - /** 折返方向*/ - standReentryDirection: 0, - /** 折返偏移量*/ - standReentryOffset: {x: -16, y: 18}, - /** 扣车显示内容*/ - standDetainText: 'H', - /** 站台无人折返*/ - standNoHumanReentryColor: '#0F16DA', - /** 站台自动换端*/ - standAutoChangeEndsColor: '#0BF400', - /** 站台空闲颜色*/ - standSpareColor: '#606060', - /** 站台列车停站颜色*/ - standStopColor: '#FEFE00', - /** 站台跳停颜色*/ - standJumpStopColor: '#9A99FF', - /** 站台指定列车跳停颜色*/ - standDesignatedJumpStopColor: 'lightSkyBlue', - /** 站台紧急关闭颜色*/ - standEmergentCloseColor: '#F61107', - /** 停站时间字体颜色*/ - standTimeTextColor: '#FFFFFF', - /** 停站等级字体颜色*/ - standLevelTextColor: '#FFFFFF', - /** 车站扣车颜色*/ - standDetainTrainColor: '#E4EF50', - /** 中心扣车颜色*/ - standCenterDetainTrainColor: '#FFFFFF', - /** 车站+中心扣车颜色*/ - standAndCenterDetainTrainColor: '#F61107', - /** 屏蔽门默认颜色*/ - standDoorDefaultColor: '#00FF00', - /** 屏蔽门切除颜色*/ - standSplitDoorColor: '#F61107', - /** 车站扣除文字颜色*/ - standDetainTrainTextColor: '#E4EF50', - /** 计数器字体颜色*/ - stationCounterTextColor: '#FFFFFF', - /** 计数器边框颜色*/ - stationCounterBorderColor: '#E4EF50', - /** 延迟解锁倒计时和设备文字之间的距离*/ - stationDelayUnlockDistance: 3, - /** 延时解锁字体颜色*/ - stationDelayUnlockTextColor: '#FFFFFF', - /** 延迟解锁边框颜色*/ - stationDelayUnlockBorderColor: '#FFFFFF' + common: { // 通用属性 + textFontSize: 8 // 站台默认字体大小 + }, + safetyDoor: { // 屏蔽门 + height: 1.6, // 站台屏蔽门高度 + distance: 9, // 站台和屏蔽门之间的距离 + defaultColor: '#00FF00', // 屏蔽门默认颜色 + splitDoorColor: '#F61107' // 屏蔽门切除颜色 + }, + stand: { // 站台 + headFontSize: 8, // 站台首端字体大小 + spareColor: '#606060', // 站台空闲颜色 + stopColor: '#FEFE00', // 站台列车停站颜色 + jumpStopColor: '#9A99FF', // 站台跳停颜色 + designatedJumpStopColor: 'lightSkyBlue' // 站台指定列车跳停颜色 + }, + standEmergent: { // 紧急关闭 + mergentR: 4, // 站台紧急关闭半径 + offset: {x: 0, y: 0}, // 站台紧急关闭偏移量 + closeColor: '#F61107' // 站台紧急关闭颜色 + }, + reentry: { // 站台折返策略 + direction: 0, // 折返方向 + offset: {x: -16, y: 18}, // 折返偏移量 + noHumanColor: '#0F16DA', // 站台无人折返 + AutoChangeEndsColor: '#0BF400' // 站台自动换端 + }, + detainCar: { // 扣车 + text: 'H', // 扣车显示内容 + direction: 1, // 扣车方向 + offset: {x: -8, y: 13}, // 扣车偏移量 + trainColor: '#E4EF50', // 车站扣车颜色 + centerTrainColor: '#FFFFFF', // 中心扣车颜色 + andCenterTrainColor: '#F61107', // 车站+中心扣车颜色 + detainTrainTextColor: '#E4EF50' // 车站扣除文字颜色 + }, + stopTime: { // 停站时间 + direction: 1, // 运行时间方向 + offset: {x: -8, y: 3}, // 运行时间偏移量 + textColor: '#FFFFFF' // 停站时间字体颜色 + }, + level: { // 运行等级 + direction: 1, // 运行等级方向 + offset: {x: -8, y: 22}, // 运行等级偏移量 + textColor: '#FFFFFF' // 停站等级字体颜色 + } }; this[deviceType.StationControl] = { singleControlNum: 3, diff --git a/src/jmap/utils/parser.js b/src/jmap/utils/parser.js index 613f10dbf..0cd850676 100644 --- a/src/jmap/utils/parser.js +++ b/src/jmap/utils/parser.js @@ -21,6 +21,7 @@ export function parser(data, jmap) { zrUtil.each(data.sectionList || [], elem => { mapDevice[elem.code] = deviceFactory(deviceType.Section, defaultStateDict, elem); + }, this); zrUtil.each(data.signalList || [], elem => { @@ -82,7 +83,10 @@ export function parser(data, jmap) { zrUtil.each(data.switchList || [], elem => { const cnodeSection = elem['sectionA'] = mapDevice[elem.sectionACode]; const lnodeSection = elem['sectionB'] = mapDevice[elem.sectionBCode]; - const rnodeSection = elem['sectionC'] =mapDevice[elem.sectionCCode]; + const rnodeSection = elem['sectionC'] = mapDevice[elem.sectionCCode]; + + cnodeSection.model['switch'] = lnodeSection.model['switch'] = rnodeSection.model['switch'] = elem; + if (cnodeSection && lnodeSection && rnodeSection) { const cnode = mapDevice[cnodeSection.model.linkCode]; if (cnode && cnode.model.leftFdCode === lnodeSection.model.linkCode && cnode.model.leftSdCode === rnodeSection.model.linkCode) { diff --git a/src/views/jmap/index.vue b/src/views/jmap/index.vue index 388b424df..3619c1577 100644 --- a/src/views/jmap/index.vue +++ b/src/views/jmap/index.vue @@ -58,7 +58,7 @@ export default { // this.jmap.load({ skinVO: { code: '02' }, linkList: list }); - getPublishMapDetail('02').then(resp => { + getPublishMapDetail('03').then(resp => { this.jmap.setLevelVisible([deviceType.Link], false); this.jmap.load(resp.data); // this.jmap.setDefaultState(); From 39af264196ce3744cc4ec64f2a8beca421ca3e67 Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Tue, 23 Jul 2019 18:06:13 +0800 Subject: [PATCH 03/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README-zh.md | 95 +------------ README.md | 85 +---------- src/jmap/shape/Signal/ESigButton.js | 18 +-- src/jmap/shape/Signal/ESigDelay.js | 49 ------- src/jmap/shape/Signal/ESigLmap.js | 89 ------------ src/jmap/shape/Signal/ESigName.js | 51 ------- src/jmap/shape/Signal/ESigPass.js | 66 --------- src/jmap/shape/Signal/ESigPost.js | 68 --------- src/jmap/shape/Signal/ESigRoute.js | 41 ------ src/jmap/shape/Signal/SigAuto.js | 27 ++++ src/jmap/shape/Signal/index.js | 210 ++++++++++++++++------------ src/jmap/theme/fuzhou.js | 126 ++++++++++------- 12 files changed, 233 insertions(+), 692 deletions(-) delete mode 100644 src/jmap/shape/Signal/ESigDelay.js delete mode 100644 src/jmap/shape/Signal/ESigLmap.js delete mode 100644 src/jmap/shape/Signal/ESigName.js delete mode 100644 src/jmap/shape/Signal/ESigPass.js delete mode 100644 src/jmap/shape/Signal/ESigPost.js delete mode 100644 src/jmap/shape/Signal/ESigRoute.js create mode 100644 src/jmap/shape/Signal/SigAuto.js diff --git a/README-zh.md b/README-zh.md index 32243a46d..543b3fa20 100644 --- a/README-zh.md +++ b/README-zh.md @@ -1,96 +1,3 @@ -# vue-admin-template - -> 这是一个极简的 vue admin 管理后台。它只包含了 Element UI & axios & iconfont & permission control & lint,这些搭建后台必要的东西。 - -[线上地址](http://panjiachen.github.io/vue-admin-template) - -[国内访问](https://panjiachen.gitee.io/vue-admin-template) - -目前版本为 `v4.0+` 基于 `vue-cli` 进行构建,若你想使用旧版本,可以切换分支到[tag/3.11.0](https://github.com/PanJiaChen/vue-admin-template/tree/tag/3.11.0),它不依赖 `vue-cli`。 - -## Extra - -如果你想要根据用户角色来动态生成侧边栏和 router,你可以使用该分支[permission-control](https://github.com/PanJiaChen/vue-admin-template/tree/permission-control) - -## 相关项目 - -[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin) - -[electron-vue-admin](https://github.com/PanJiaChen/electron-vue-admin) - -[vue-typescript-admin-template](https://github.com/Armour/vue-typescript-admin-template) - -写了一个系列的教程配套文章,如何从零构建后一个完整的后台项目: - -- [手摸手,带你用 vue 撸后台 系列一(基础篇)](https://juejin.im/post/59097cd7a22b9d0065fb61d2) -- [手摸手,带你用 vue 撸后台 系列二(登录权限篇)](https://juejin.im/post/591aa14f570c35006961acac) -- [手摸手,带你用 vue 撸后台 系列三 (实战篇)](https://juejin.im/post/593121aa0ce4630057f70d35) -- [手摸手,带你用 vue 撸后台 系列四(vueAdmin 一个极简的后台基础模板,专门针对本项目的文章,算作是一篇文档)](https://juejin.im/post/595b4d776fb9a06bbe7dba56) -- [手摸手,带你封装一个 vue component](https://segmentfault.com/a/1190000009090836) - -## Build Setup - -```bash -# 克隆项目 -git clone https://github.com/PanJiaChen/vue-admin-template.git - -# 进入项目目录 -cd vue-admin-template - -# 安装依赖 -npm install - -# 建议不要直接使用 cnpm 安装以来,会有各种诡异的 bug。可以通过如下操作解决 npm 下载速度慢的问题 -npm install --registry=https://registry.npm.taobao.org - -# 启动服务 -npm run dev -``` - -浏览器访问 [http://localhost:9528](http://localhost:9528) - -## 发布 - -```bash -# 构建测试环境 -npm run build:stage - -# 构建生产环境 -npm run build:prod -``` - -## 其它 - -```bash -# 预览发布环境效果 -npm run preview - -# 预览发布环境效果 + 静态资源分析 -npm run preview -- --report - -# 代码格式检查 -npm run lint - -# 代码格式检查并自动修复 -npm run lint -- --fix -``` - -更多信息请参考 [使用文档](https://panjiachen.github.io/vue-element-admin-site/zh/) - -## Demo - -![demo](https://github.com/PanJiaChen/PanJiaChen.github.io/blob/master/images/demo.gif) - -## Browsers support - -Modern browsers and Internet Explorer 10+. - -| [IE / Edge](http://godban.github.io/browsers-support-badges/)
IE / Edge | [Firefox](http://godban.github.io/browsers-support-badges/)
Firefox | [Chrome](http://godban.github.io/browsers-support-badges/)
Chrome | [Safari](http://godban.github.io/browsers-support-badges/)
Safari | -| --------- | --------- | --------- | --------- | -| IE10, IE11, Edge| last 2 versions| last 2 versions| last 2 versions - -## License - -[MIT](https://github.com/PanJiaChen/vue-admin-template/blob/master/LICENSE) license. +# jl-nclient Copyright (c) 2017-present PanJiaChen diff --git a/README.md b/README.md index bd3dbc87e..b0f0459af 100644 --- a/README.md +++ b/README.md @@ -1,89 +1,6 @@ -# vue-admin-template +# jl-nclient English | [简体中文](./README-zh.md) -> A minimal vue admin template with Element UI & axios & iconfont & permission control & lint - -**Live demo:** http://panjiachen.github.io/vue-admin-template - - -**The current version is `v4.0+` build on `vue-cli`. If you want to use the old version , you can switch branch to [tag/3.11.0](https://github.com/PanJiaChen/vue-admin-template/tree/tag/3.11.0), it does not rely on `vue-cli`** - -## Build Setup - - -```bash -# clone the project -git clone https://github.com/PanJiaChen/vue-element-admin.git - -# enter the project directory -cd vue-element-admin - -# install dependency -npm install - -# develop -npm run dev -``` - -This will automatically open http://localhost:9527 - -## Build - -```bash -# build for test environment -npm run build:stage - -# build for production environment -npm run build:prod -``` - -## Advanced - -```bash -# preview the release environment effect -npm run preview - -# preview the release environment effect + static resource analysis -npm run preview -- --report - -# code format check -npm run lint - -# code format check and auto fix -npm run lint -- --fix -``` - -Refer to [Documentation](https://panjiachen.github.io/vue-element-admin-site/guide/essentials/deploy.html) for more information - -## Demo - -![demo](https://github.com/PanJiaChen/PanJiaChen.github.io/blob/master/images/demo.gif) - -## Extra - -If you want router permission && generate menu by user roles , you can use this branch [permission-control](https://github.com/PanJiaChen/vue-admin-template/tree/permission-control) - -For `typescript` version, you can use [vue-typescript-admin-template](https://github.com/Armour/vue-typescript-admin-template) (Credits: [@Armour](https://github.com/Armour)) - -## Related Project - -[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin) - -[electron-vue-admin](https://github.com/PanJiaChen/electron-vue-admin) - -[vue-typescript-admin-template](https://github.com/Armour/vue-typescript-admin-template) - -## Browsers support - -Modern browsers and Internet Explorer 10+. - -| [IE / Edge](http://godban.github.io/browsers-support-badges/)
IE / Edge | [Firefox](http://godban.github.io/browsers-support-badges/)
Firefox | [Chrome](http://godban.github.io/browsers-support-badges/)
Chrome | [Safari](http://godban.github.io/browsers-support-badges/)
Safari | -| --------- | --------- | --------- | --------- | -| IE10, IE11, Edge| last 2 versions| last 2 versions| last 2 versions - -## License - -[MIT](https://github.com/PanJiaChen/vue-admin-template/blob/master/LICENSE) license. Copyright (c) 2017-present PanJiaChen diff --git a/src/jmap/shape/Signal/ESigButton.js b/src/jmap/shape/Signal/ESigButton.js index 10a172d6a..a80393e84 100644 --- a/src/jmap/shape/Signal/ESigButton.js +++ b/src/jmap/shape/Signal/ESigButton.js @@ -15,7 +15,7 @@ class ESigButton extends Group { const model = this.model; const style = this.model.style; const padding = 1; - const r = style.Signal.signalR * 0.8; + const r = style.Signal.Lamp.signalR * 0.8; this.style = style; this._subType = 'SignalButton'; @@ -26,15 +26,15 @@ class ESigButton extends Group { _subType: this._subType, _val: '1', shape: { - x: model.x - style.Signal.signalR, + x: model.x - style.Signal.Lamp.signalR, y: model.y - r + r * model.posit, - width: style.Signal.signalR * 2, - height: style.Signal.signalR * 2 + width: style.Signal.Lamp.signalR * 2, + height: style.Signal.Lamp.signalR * 2 }, style: { lineWidth: 0.2, - stroke: style.Signal.signalButtonDashColor, - fill: style.Signal.signalButtonColor + stroke: style.Signal.Button.signalButtonDashColor, + fill: style.Signal.Button.signalButtonColor } }); @@ -46,12 +46,12 @@ class ESigButton extends Group { shape: { cx: model.x, cy: model.y - 5 / 2 * r * model.posit, - r: style.Signal.signalR + r: style.Signal.Lamp.signalR }, style: { lineWidth: 0.2, - stroke: style.Signal.signalButtonDashColor, - fill: style.Signal.signalButtonColor + stroke: style.Signal.Button.signalButtonDashColor, + fill: style.Signal.Button.signalButtonColor } }); diff --git a/src/jmap/shape/Signal/ESigDelay.js b/src/jmap/shape/Signal/ESigDelay.js deleted file mode 100644 index 776603d0c..000000000 --- a/src/jmap/shape/Signal/ESigDelay.js +++ /dev/null @@ -1,49 +0,0 @@ -import Group from 'zrender/src/container/Group'; -import Text from 'zrender/src/graphic/Text'; - -class ESigDelay extends Group { - constructor(model) { - super(); - this.model = model; - this._create(); - } - - _create() { - const model = this.model; - this.name = new Text({ - _subType: model._subType, - zlevel: model.zlevel, - z: model.z, - silent: model.silent || false, - style: { - x: model.x, - y: model.y, - text: model.text, - textFont: model.textFont, - textFill: model.textFill, - textAlign: model.textAlign, - textPosition: model.textPosition || 'inside', - textVerticalAlign: model.textVerticalAlign || null - } - }); - this.add(this.name); - } - - setStyle(model) { - this.name.setStyle(model); - } - - setColor(color) { - this.name.setStyle('textFill', color); - } - - hide() { - this.name.hide(); - } - - show() { - this.name.show(); - } -} - -export default ESigDelay; diff --git a/src/jmap/shape/Signal/ESigLmap.js b/src/jmap/shape/Signal/ESigLmap.js deleted file mode 100644 index ac1f2dcab..000000000 --- a/src/jmap/shape/Signal/ESigLmap.js +++ /dev/null @@ -1,89 +0,0 @@ -import Line from 'zrender/src/graphic/shape/Line'; -import Arc from 'zrender/src/graphic/shape/Arc'; -import Group from 'zrender/src/container/Group'; - -class ESigLmap extends Group { - constructor(model) { - super(); - this.model = model; - this._create(); - } - - _create() { - const model = this.model; - const style = this.model.style; - - this.lamp = new Arc({ - name: model.index, - zlevel: model.zlevel, - z: model.z, - shape: { - cx: model.x, - cy: model.y, - r: style.Signal.signalR - }, - style: { - lineWidth: 0.4, - fill: style.backgroundColor, - stroke: style.Signal.signalLampStandardColor - } - }); - - this.lstop = new Line({ - zlevel: model.zlevel, - z: model.z, - origin: { - x: model.originX, - y: model.originY - }, - shape: { - x1: model.x + (style.Signal.signalR + 1) * Math.cos(Math.PI / 4), - y1: model.y + (style.Signal.signalR + 1) * Math.sin(Math.PI / 4), - x2: model.x - (style.Signal.signalR + 1) * Math.cos(Math.PI / 4), - y2: model.y - (style.Signal.signalR + 1) * Math.sin(Math.PI / 4) - }, - style: { - lineWidth: 1.5, - stroke: style.backgroundColor - } - }); - - this.rstop = new Line({ - zlevel: model.zlevel, - z: model.z, - origin: { - x: model.originX, - y: model.originY - }, - shape: { - x1: model.x + (style.Signal.signalR + 1) * Math.cos(Math.PI / 4), - y1: model.y + (style.Signal.signalR + 1) * (Math.sin(Math.PI / 4) - Math.sqrt(2)), - x2: model.x - (style.Signal.signalR + 1) * Math.cos(Math.PI / 4), - y2: model.y - (style.Signal.signalR + 1) * (Math.sin(Math.PI / 4) - Math.sqrt(2)) - }, - style: { - lineWidth: 1.5, - stroke: style.backgroundColor - } - }); - this.add(this.lamp); - this.add(this.lstop); - this.add(this.rstop); - } - - setColor(color) { - this.lamp.setStyle('fill', color); - } - - setStop(has) { - if (has) { - this.lstop.show(); - this.rstop.show(); - } else { - this.lstop.hide(); - this.rstop.hide(); - } - } -} - -export default ESigLmap; diff --git a/src/jmap/shape/Signal/ESigName.js b/src/jmap/shape/Signal/ESigName.js deleted file mode 100644 index 785cf1aac..000000000 --- a/src/jmap/shape/Signal/ESigName.js +++ /dev/null @@ -1,51 +0,0 @@ -import Group from 'zrender/src/container/Group'; -import Text from 'zrender/src/graphic/Text'; - -class ESigName extends Group { - constructor(model) { - super(); - this.model = model; - this._create(); - } - - _create() { - const model = this.model; - this.name = new Text({ - _subType: model._subType, - zlevel: model.zlevel, - z: model.z, - silent: model.silent, - style: { - x: model.x, - y: model.y, - text: model.text, - textFont: model.textFont, - textFill: model.textFill, - textAlign: model.textAlign, - textPosition: model.textPosition || 'inside', - textVerticalAlign: model.textVerticalAlign || null - } - }); - this.add(this.name); - } - - setStyle(model) { - this.name.setStyle(model); - } - - setColor(color) { - this.name.setStyle('textFill', color); - } - - // 隐藏 - hide() { - this.name.hide(); - } - - // 显示 - show() { - this.name.show(); - } -} - -export default ESigName; diff --git a/src/jmap/shape/Signal/ESigPass.js b/src/jmap/shape/Signal/ESigPass.js deleted file mode 100644 index ca1f0eeeb..000000000 --- a/src/jmap/shape/Signal/ESigPass.js +++ /dev/null @@ -1,66 +0,0 @@ -import Polygon from 'zrender/src/graphic/shape/Polygon'; -import Group from 'zrender/src/container/Group'; -import { arrows } from '../utils/ShapePoints'; - -class ESigPass extends Group { - constructor(model) { - super(); - this.model = model; - this._create(); - } - - _create() { - const model = this.model; - const style = this.model.style; - const rotation = model.drict != 1? 0 : Math.PI; - const point = arrows(model.x, model.y, style.Signal.signalSigPassWidth, style.Signal.signalR * 0.8); - this.arrows = new Polygon({ - zlevel: model.zlevel, - z: model.z, - rotation: rotation, - shape: { - points: point - }, - style: { - stroke: model.stroke, - lineWidth: model.lineWidth, - fill: model.fill - } - }); - this.add(this.arrows); - } - - // 停止动画 - animationRecover() { - this.arrows.stopAnimation(false); - } - - // 箭头颜色 - setColor(color) { - this.arrows.setStyle('fill', color); - } - - // 箭头闪烁 - arrowsAnimation() { - const style = this.model.style; - const fill = this.arrows.style.Signal.fill; - this.arrows.animate(true) - .when(1000, { fill: style.backgroundColor, stroke: style.style.backgroundColor }) - .when(2000, { fill: fill, stroke: style.style.Signal.sidelineColor }) - .when(3000, { fill: style.style.backgroundColor, stroke: style.style.backgroundColor }) - .when(4000, { fill: fill, stroke: style.style.Signal.sidelineColor }) - .start(); - } - - // 隐藏 - hide() { - this.arrows.hide(); - } - - // 显示 - show() { - this.arrows.show(); - } -} - -export default ESigPass; diff --git a/src/jmap/shape/Signal/ESigPost.js b/src/jmap/shape/Signal/ESigPost.js deleted file mode 100644 index 59eced36a..000000000 --- a/src/jmap/shape/Signal/ESigPost.js +++ /dev/null @@ -1,68 +0,0 @@ -import Polyline from 'zrender/src/graphic/shape/Polyline'; -import Group from 'zrender/src/container/Group'; - -class ESigPost extends Group { - constructor(model) { - super(); - this.model = model; - this._create(); - } - - _create() { - const model = this.model; - const style = this.model.style; - - this.ver = new Polyline({ - zlevel: model.zlevel, - z: model.z, - shape: { - points: [ - [model.x, model.y + style.Signal.signalR * 1.2], - [model.x, model.y - style.Signal.signalR * 1.2] - ] - }, - style: { - lineWidth: style.Signal.signalLampStandardWidth, - stroke: style.Signal.signalLampStandardColor - } - }); - - this.hor = new Polyline({ - zlevel: model.zlevel, - z: model.z, - shape: { - points: [ - [model.x, model.y], - [model.x + model.drict * style.Signal.signalR * 1.2, model.y] - ] - }, - style: { - lineWidth: style.Signal.signalLampStandardWidth, - stroke: style.Signal.signalLampStandardColor - } - }); - - this.add(this.ver); - this.add(this.hor); - - model.type === '01' ? this.hor.hide() : this.hor.show(); - } - - getLampPosition(type) { - const model = this.model; - const style = this.model.style; - if (type === '01') { - return { - x: model.x + model.drict * style.Signal.signalR * 3 / 2, - y: model.y - }; - } else { - return { - x: this.hor.shape.points[1][0] + model.drict * style.Signal.signalR, - y: this.hor.shape.points[1][1] - }; - } - } -} - -export default ESigPost; diff --git a/src/jmap/shape/Signal/ESigRoute.js b/src/jmap/shape/Signal/ESigRoute.js deleted file mode 100644 index 2321d6638..000000000 --- a/src/jmap/shape/Signal/ESigRoute.js +++ /dev/null @@ -1,41 +0,0 @@ -import Polygon from 'zrender/src/graphic/shape/Polygon'; -import Group from 'zrender/src/container/Group'; -import { triangular } from '../utils/ShapePoints'; - -class ESigDrict extends Group { - constructor(model) { - super(); - this.model = model; - this._create(); - } - - _create() { - const model = this.model; - const style = this.model.style; - this.sigDrict = new Polygon({ - zlevel: model.zlevel, - z: model.z, - shape: { - points: triangular(model.x, model.y, model.drict, style.Signal.signalR) - }, - style: { - stroke: style.backgroundColor, - lineWidth: 0.5, - fill: style.Signal.signalLampYellowColor - } - }); - this.add(this.sigDrict); - } - - // 隐藏 - hide() { - this.sigDrict.hide(); - } - - // 显示 - show() { - this.sigDrict.show(); - } -} - -export default ESigDrict; diff --git a/src/jmap/shape/Signal/SigAuto.js b/src/jmap/shape/Signal/SigAuto.js new file mode 100644 index 000000000..7b523eedb --- /dev/null +++ b/src/jmap/shape/Signal/SigAuto.js @@ -0,0 +1,27 @@ +import Path from 'zrender/src/graphic/Path'; + +export default Path.extend({ + type: 'SigAuto', + + shape: { + x: 0, // 三角中心x + y: 0, // 三角中心y + r: 0, // 三角形半径 + forward: false // 三角箭头朝向: 左/右 + }, + + style: { + stroke: '#c0c0c0', + lineWidth: 0.5, + fill: null + }, + + buildPath: function (ctx, shape) { + const r = shape.forward ? shape.r : -shape.r; + ctx.moveTo(shape.x, shape.y); + ctx.lineTo(shape.x + r, shape.y - shape.r); + ctx.lineTo(shape.x + r, shape.y + shape.r); + ctx.closePath(); + ctx.fill(); + } +}); diff --git a/src/jmap/shape/Signal/index.js b/src/jmap/shape/Signal/index.js index 20596c112..9ad620c34 100644 --- a/src/jmap/shape/Signal/index.js +++ b/src/jmap/shape/Signal/index.js @@ -2,13 +2,12 @@ * 信号机 */ -import ESigPost from './ESigPost'; -import ESigLmap from './ESigLmap'; -import ESigPass from './ESigPass'; -import ESigRoute from './ESigRoute'; +import SigPost from './SigPost'; +import SigLamp from './SigLamp'; +import SigAuto from './SigAuto'; +import SigRoute from './SigRoute'; import ESigButton from './ESigButton'; -import ESigDelay from './ESigDelay'; -import ESigName from './ESigName'; +import Text from 'zrender/src/graphic/Text'; import Group from 'zrender/src/container/Group'; class Signal extends Group { @@ -35,30 +34,46 @@ class Signal extends Group { const posit = this.model.positionType == '01' ? -1 : 1; // 位置 上:下 // 信号机高柱矮柱 - this.sigPost = new ESigPost({ + this.sigPost = new SigPost({ zlevel: this.zlevel, - z: this.z, - style: style, - drict: drict, - type: model.lampPostType, - x: model.position.x, - y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.signalR) + z: this.z + 1, + shape: { + x: model.position.x, + y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.Lamp.signalR), + h: style.Signal.Lamp.signalR * 2, + w: style.Signal.Lamp.signalR, + isDwarf: model.lampPositionType == '02', + forward: model.directionType == '01' + }, + style: { + stroke: style.Signal.Post.signalLampStandardColor, + lineWidth: style.Signal.Post.signalLampStandardWidth + } }); + const endPoint = { + x: model.position.x + drict * (style.Signal.Lamp.signalR * 2), + y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.Lamp.signalR) + }; + // 信号灯 - const endPoint = this.sigPost.getLampPosition(model.lampPostType); this.lamps = []; for (let i = 0; i < this.count; i++) { - const lamp = new ESigLmap({ + const lamp = new SigLamp({ zlevel: this.zlevel, z: this.z, - style: style, - index: i + 1, - drict: drict, - x: endPoint.x + i * drict * style.Signal.signalR * 2, - y: endPoint.y, - originX: model.position.x, - originY: model.position.y + shape: { + x: endPoint.x + i * drict * (style.Signal.Lamp.signalR * 2 + style.Signal.Lamp.signalBorderWidth), + y: endPoint.y, + r: style.Signal.Lamp.signalR, + signalStopWidth: style.Signal.Lamp.signalStopWidth, + isStop: false + }, + style: { + stroke: style.Signal.Lamp.signalBorderColor, + lineWidth: style.Signal.Lamp.signalBorderWidth, + fill: style.Signal.Lamp.signalLampGrayColor + } }); this.lamps.push(lamp); @@ -66,67 +81,76 @@ class Signal extends Group { // 信号机名称 const sigNameX = model.position.x + model.namePosition.x; - const sigNameY = model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.signalR * 2 + model.namePosition.y); - this.sigName = new ESigName({ + const sigNameY = model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.Lamp.signalR * 2 + model.namePosition.y); + this.sigName = new Text({ zlevel: this.zlevel, z: this.z, silent: false, - style: style, - x: sigNameX, - y: sigNameY, - text: model.name, - textFont: `bold ${style.Signal.signalTextFontSize} px ${style.textFontFormat}`, - textFill: style.Signal.signalTextGreen, - textAlign: 'middle', - textVerticalAlign: posit == 1 ? 'top' : 'bottom' + style: { + x: sigNameX, + y: sigNameY, + text: model.name, + textFont: `bold ${style.Signal.Text.signalTextFontSize} px ${style.textFontFormat}`, + textFill: style.Signal.Text.signalTextGreen, + textAlign: 'middle', + textPosition: model.textPosition || 'inside', + textVerticalAlign: posit == 1 ? 'top' : 'bottom' + } }); // 自动进路 - const sigRouteH = style.Signal.signalSigRouteDirection ? this.count * style.Signal.signalR * 2 : -style.Signal.signalR * 2; - const sigRouteX = endPoint.x + (style.Signal.signalSigRouteOffset.x + sigRouteH) * drict; - const sigRouteY = endPoint.y + (style.Signal.signalSigRouteOffset.y); - this.sigRoute = new ESigRoute({ + const sigRouteH = style.Signal.Route.signalRouteDirection ? this.count * style.Signal.Lamp.signalR * 2 : -style.Signal.Lamp.signalR * 2; + const sigRouteX = endPoint.x + (style.Signal.Route.signalRouteOffset.x + sigRouteH) * drict; + const sigRouteY = endPoint.y + (style.Signal.Route.signalRouteOffset.y); + this.sigRoute = new SigRoute({ zlevel: this.zlevel, z: this.z, - style: style, - x: sigRouteX, - y: sigRouteY, - drict: drict + shape: { + x: sigRouteX, + y: sigRouteY, + forward: model.directionType == '01' + }, + style: { + fill: style.Signal.Route.signalRouteColor + } }); // 自动通过 - const sigPassH = style.Signal.signalSigPassDirection ? this.count * style.Signal.signalR * 2 : -style.Signal.signalR * 2; - const sigPassX = endPoint.x + (style.Signal.signalSigPassOffset.x + sigPassH) * drict; - const sigPassY = endPoint.y + (style.Signal.signalSigPassOffset.y); - this.sigPass = new ESigPass({ + const sigAutoH = style.Signal.Auto.signalAutoDirection ? this.count * style.Signal.Lamp.signalR * 2 : -style.Signal.Lamp.signalR * 2; + const sigAutoX = endPoint.x + (style.Signal.Auto.signalAutoOffset.x + sigAutoH) * drict; + const sigAutoY = endPoint.y + (style.Signal.Auto.signalAutoOffset.y); + this.sigAuto = new SigAuto({ zlevel: this.zlevel, z: this.z, - style: style, - count: this.count, - drict: drict, - x: sigPassX, - y: sigPassY, - width: style.Signal.signalSigPassWidth, - fill: style.Signal.signalLampGreenColor, - lineWidth: 0.6, - stroke: style.sidelineColor + shape: { + x: sigAutoX, + y: sigAutoY, + r: style.Signal.Lamp.signalR, + forward: model.directionType == '01' + }, + style: { + fill: style.Signal.Auto.signalAutoColor + } }); // 延迟解锁 - const sigDelayH = style.Signal.signalSigDelayDirection ? this.count * style.Signal.signalR * 2 : -style.Signal.signalR * 2; - const sigDelayX = endPoint.x + (style.Signal.signalSigDelayOffset.x + sigDelayH) * drict; - const sigDelayY = endPoint.y - (style.Signal.signalSigDelayOffset.y) * posit; - this.sigDelay = new ESigDelay({ + const sigDelayH = style.Signal.Delay.signalDelayDirection ? this.count * style.Signal.Lamp.signalR * 2 : -style.Signal.Lamp.signalR * 2; + const sigDelayX = endPoint.x + (style.Signal.Delay.signalDelayOffset.x + sigDelayH) * drict; + const sigDelayY = endPoint.y - (style.Signal.Delay.signalDelayOffset.y) * posit; + this.sigDelay = new Text({ zlevel: this.zlevel, z: this.z, - style: style, - x: sigDelayX, - y: sigDelayY, - text: this.state.delayCount || '0', - textFont: `bold ${style.Signal.signalDelayTextFontSize} px ${style.textFontFormat}`, - textFill: style.Signal.signalTextRed, - textAlign: drict > 0 ? 'right' : 'left', - textVerticalAlign: 'middle' + silent: false, + style: { + x: sigDelayX, + y: sigDelayY, + text: this.state.delayCount || '0', + textFont: `bold ${style.Signal.Delay.signalDelayTextFontSize} px ${style.textFontFormat}`, + textFill: style.Signal.Delay.signalDelayTextColor, + textAlign: drict > 0 ? 'right' : 'left', + textPosition: model.textPosition || 'inside', + textVerticalAlign: 'middle' + } }); // 信号灯按钮 @@ -137,16 +161,16 @@ class Signal extends Group { posit: posit, show: model.buttonShow, x: model.buttonPosition.x, - y: model.buttonPosition.y - posit * (style.Signal.signalButtonDistance + style.Signal.signalR * 2) + y: model.buttonPosition.y - posit * (style.Signal.Button.signalButtonDistance + style.Signal.Lamp.signalR * 2) }); this.add(this.sigPost); this.lamps.forEach(lamp => { this.add(lamp); }); this.add(this.sigName); - this.add(this.sigPass); this.add(this.sigRoute); + this.add(this.sigAuto); this.add(this.sigDelay); - // this.add(this.sigButton); + this.add(this.sigButton); } // 整体旋转信号灯 @@ -169,13 +193,13 @@ class Signal extends Group { if (this.count === 1) { if (this.model.useType === '05') { /** 单灯 调车信号机*/ - this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampBlueColor); + this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampBlueColor); } else { /** 单灯 出站信号机 */ /** 单灯 阻挡信号机*/ /** 单灯 阻挡兼调车信号 */ /** 单灯 列兼调信号机 */ - this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampRedColor); + this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampRedColor); } } } @@ -185,7 +209,7 @@ class Signal extends Group { if (this.count === 1) { /** 单灯 出站信号机*/ /** 单灯 阻隔信号机*/ - this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampGreenColor); + this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampGreenColor); } } @@ -193,7 +217,7 @@ class Signal extends Group { trainRoute() { if (this.count === 1) { /** 单灯 列兼调信号*/ - this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampYellowColor); + this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampYellowColor); } } @@ -202,7 +226,7 @@ class Signal extends Group { if (this.count === 1) { /** 单灯 列兼调信号*/ /** 单灯 阻挡兼调车信号*/ - this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampWhiteColor); + this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampWhiteColor); } } @@ -213,8 +237,8 @@ class Signal extends Group { // 封锁 block() { - this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampRedColor); - this.sigName.setColor(this.style.Signal.sectionBlockTextColor); + this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampRedColor); + this.sigName.setStyle('textFill', this.style.Signal.Text.signalTextRed); } // 功能封锁 @@ -232,53 +256,59 @@ class Signal extends Group { // 物理点灯 logicalLight() { - this.lamps.forEach(lamp => { lamp.setStop(false); }); + this.lamps.forEach(lamp => { lamp.setShape('isStop', false); }); } // 逻辑点灯 physicsLight() { - this.lamps.forEach(lamp => { lamp.setStop(true); }); + this.lamps.forEach(lamp => { lamp.setShape('isStop', true); }); } // 设置自动进路模式状态类型 setAutoRouteOpen() { if (this.model.linkageAutoRouteShow) { - this.sigPass.show(); + this.sigAuto.show(); } else { - this.sigPass.hide(); + this.sigAuto.hide(); } this.recover(); - this.sigPass.setColor(this.style.Signal.signalLampGreenColor); + this.sigAuto.setStyle('fill', this.style.Signal.signalAutoRoute); } // 信号机进路自动触发模式状态类型 setAutoAccessOpen() { if (this.model.atsAutoTriggerShow) { - this.sigPass.show(); + this.sigAuto.show(); } else { - this.sigPass.hide(); + this.sigAuto.hide(); } this.recover(); - this.sigPass.setColor(this.style.Signal.signalLampYellowColor); + this.sigAuto.setStyle('fill', this.style.Signal.signalAutoTrigger); } // 设置自动信号模式状态类型 - setAutoSignalOpen() { + setAutonalOpen() { this.sigRoute.show(); } // 隐藏自动信号和自动进路 setAutoClose() { - this.sigPass.hide(); - this.sigPass.setColor(this.style.backgroundColor); this.sigRoute.hide(); + this.sigAuto.hide(); } // 自动信号和自动进路开始动画 setAutoFlicker() { - this.sigPass.arrowsAnimation(); + const style = this.model.style; + const fill = this.sigAuto.style.Signal.fill; + this.sigAuto.animate(true) + .when(1000, { fill: style.backgroundColor, stroke: style.style.backgroundColor }) + .when(2000, { fill: fill, stroke: style.style.Signal.sidelineColor }) + .when(3000, { fill: style.style.backgroundColor, stroke: style.style.backgroundColor }) + .when(4000, { fill: fill, stroke: style.style.Signal.sidelineColor }) + .start(); } // 设置延时解锁 @@ -289,8 +319,8 @@ class Signal extends Group { // 恢复状态 recover() { this.sigDelay.hide(); - this.sigPass.animationRecover(); - this.sigName.setColor(this.style.Signal.signalTextGreen); + this.sigAuto.stopAnimation(false); + this.sigName.setStyle('textFill', this.style.Signal.Text.signalTextGreen); } setState(state) { @@ -321,7 +351,7 @@ class Signal extends Group { /** 设置自动类型*/ switch (state.autoType) { case '01': this.setAutoClose(); break; // 隐藏 隐藏自动信号和自动进路 - case '02': this.setAutoSignalOpen(); break; // 显示 设置自动信号模式状态类型 + case '02': this.setAutonalOpen(); break; // 显示 设置自动信号模式状态类型 case '03': this.setAutoRouteOpen(); break; // 显示 设置自动进路模式状态类型 case '04': this.setAutoAccessOpen(); break; // 显示 信号机进路自动触发模式状态类型 } diff --git a/src/jmap/theme/fuzhou.js b/src/jmap/theme/fuzhou.js index acca5e351..f9a5d7405 100644 --- a/src/jmap/theme/fuzhou.js +++ b/src/jmap/theme/fuzhou.js @@ -76,58 +76,82 @@ class Fuzhou extends defaultSkin { sectionAxleFailure: '#E6A23C' // #FFFF00 计轴失效 }; this[deviceType.Signal] = { - /** 信号机宽度 */ - signalR: 5, - /** 自动信号宽度*/ - signalSigPassWidth: 6, - /** 延迟解锁字体大小*/ - signalDelayTextFontSize: 9, - /** 信号机名称字体大小*/ - signalTextFontSize: 12, - /** 灯柱宽度*/ - signalLampStandardWidth: 1.2, /** 设备距离区段的距离*/ - signalDistance: 3, - /** 信号灯按钮距离区段的距离*/ - signalButtonDistance: 5, - /** 自动进路方向*/ - signalSigRouteDirection: false, - /** 自动进路偏移量*/ - signalSigRouteOffset: { x: -4, y: -2 }, - /** 自动通过方向*/ - signalSigPassDirection: false, - /** 自动通过偏移量*/ - signalSigPassOffset: { x: -12, y: 0}, - /** 延时解锁方向*/ - signalSigDelayDirection: true, - /** 延时解锁偏移量*/ - signalSigDelayOffset: { x: 15, y: -10}, - /** 信号灯按钮边线*/ - signalButtonDashColor: '#FFFFFF', - /** 信号灯按钮颜色*/ - signalButtonColor: 'darkgreen', - /** 信号灯按钮闪烁颜色*/ - signalButtonLightenColor: '#E4EF50', - /** 信号灯字体颜色*/ - signalTextRed: '#EF0C08', - /** 信号机字体绿色*/ - signalTextGreen: '#4DD43F', - /** 信号灯灯柱颜色*/ - signalLampStandardColor: '#3149C3', - /** 信号灯锁闭*/ - signalBlockColor: '#EF0C08', - /** 信号灯灰色*/ - signalLampGrayColor: '#7F7F7F', - /** 信号灯红色*/ - signalLampRedColor: '#FF0000', - /** 信号灯绿色*/ - signalLampGreenColor: '#00FF00', - /** 信号灯黄色*/ - signalLampYellowColor: '#FFFF00', - /** 信号灯白色*/ - signalLampWhiteColor: '#FFFFFF', - /** 信号灯蓝色*/ - signalLampBlueColor: '#0070C0' + signalDistance: 10, + Post: { + signalLampStandardColor: '#3149C3', + signalLampStandardWidth: 2 + }, + Text: { + /** 信号机名称字体大小*/ + signalTextFontSize: 8, + /** 信号灯字体颜色*/ + signalTextRed: '#EF0C08', + /** 信号机字体绿色*/ + signalTextGreen: '#4DD43F' + }, + Lamp: { + /** 禁止线宽度*/ + signalStopWidth: 2, + /** 信号灯边框线宽度*/ + signalBorderWidth: 0.5, + /** 信号灯边框线颜色*/ + signalBorderColor: '#3149C3', + /** 信号灯半径*/ + signalR: 6, + /** 信号灯锁闭*/ + signalBlockColor: '#EF0C08', + /** 信号灯灰色*/ + signalLampGrayColor: '#7F7F7F', + /** 信号灯红色*/ + signalLampRedColor: '#FF0000', + /** 信号灯绿色*/ + signalLampGreenColor: '#00FF00', + /** 信号灯黄色*/ + signalLampYellowColor: '#FFFF00', + /** 信号灯白色*/ + signalLampWhiteColor: '#FFFFFF', + /** 信号灯蓝色*/ + signalLampBlueColor: '#0070C0' + }, + Route: { + /** 自动进路方向*/ + signalRouteDirection: false, + /** 自动进路偏移量*/ + signalRouteOffset: { x: -4, y: 0 }, + /** 自动进路*/ + signalRouteColor: '#00FF00' + }, + Auto: { + /** 自动通过方向*/ + signalAutoDirection: false, + /** 自动通过偏移量*/ + signalAutoOffset: { x: -4, y: 0}, + /** 自动进路*/ + signalAutoRoute: '#00FF00', + /** 自动触发*/ + signalAutoTrigger: '#FFFF00' + }, + Delay: { + /** 延迟解锁字体大小*/ + signalDelayTextFontSize: 9, + /** 延时解锁方向*/ + signalDelayDirection: true, + /** 延时解锁偏移量*/ + signalDelayOffset: { x: 15, y: -10}, + /** 延迟解锁颜色*/ + signalDelayTextColor: '#FF0000' + }, + Button: { + /** 信号灯按钮距离区段的距离*/ + signalButtonDistance: 5, + /** 信号灯按钮边线*/ + signalButtonDashColor: '#FFFFFF', + /** 信号灯按钮颜色*/ + signalButtonColor: 'darkgreen', + /** 信号灯按钮闪烁颜色*/ + signalButtonLightenColor: '#E4EF50' + } }; this[deviceType.StationStand] = { /** 站台和屏蔽门之间的距离*/ From 9115574bc09b6101f080673960ac685851a22a7a Mon Sep 17 00:00:00 2001 From: zyy <1787816799@qq.com> Date: Tue, 23 Jul 2019 18:10:42 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/config/defaultSkin.js | 11 ++ src/jmap/theme/bejing.js | 222 ++++++++++++++------------------- 2 files changed, 104 insertions(+), 129 deletions(-) diff --git a/src/jmap/config/defaultSkin.js b/src/jmap/config/defaultSkin.js index 7446b9e98..f13503649 100644 --- a/src/jmap/config/defaultSkin.js +++ b/src/jmap/config/defaultSkin.js @@ -36,6 +36,17 @@ export default class DefaultSkin { /** 默认名称和设备的距离*/ this.nameDistance = 2; + /** 计数器字体颜色*/ + this.stationCounterTextColor = '#FFFFFF'; + /** 计数器边框颜色*/ + this.stationCounterBorderColor = '#E4EF50'; + /** 延迟解锁倒计时和设备文字之间的距离*/ + this.stationDelayUnlockDistance = 3; + /** 延时解锁字体颜色*/ + this.stationDelayUnlockTextColor = '#FFFFFF'; + /** 延迟解锁边框颜色*/ + this.stationDelayUnlockBorderColor = '#FFFFFF'; + /** 目的码字体颜色*/ this.destinationTextFontColor = 'yellow'; diff --git a/src/jmap/theme/bejing.js b/src/jmap/theme/bejing.js index e4af39b45..239f8d580 100644 --- a/src/jmap/theme/bejing.js +++ b/src/jmap/theme/bejing.js @@ -18,65 +18,53 @@ class Beijing extends defaultSkin { linkTextColor: '#FFFFFF' }; this[deviceType.Section] = { - sectionTextPosition: 1, // 区段名称位置 1 上行 -1 下面 0 默认 - /** 区段 宽度*/ - sectionWidth: 5, - /** 区段宽超出宽度*/ - sectionBeyondWidth: 0, - /** 计轴 半径*/ - sectionAxleR: 3, - /** 计轴和区段之间的距离*/ - sectionAxleDistance: 5, - /** 限速线的宽度*/ - sectionSpeedLimitLinewidth: 1, - /** 限速线距离区段距离*/ - sectionSpeedLimitDistance: 5, - /** 分隔符宽度*/ - sectionSeparatorWidth: 1.2, - sectionEndSeparatorWidth: 1.2, // 尽头分隔符宽度 - sectionEndSeparatorStroke: '#7F7F7F', // 尽头分隔符颜色 - /** 区段侵入颜色*/ - sectionInvadeColor: '#EF0C08', - /** 限速线颜色*/ - sectionSpeedLimitColor: '#FFFF00', - /** 逻辑区段颜色*/ - sectionLogicalBackgroundColor: '#FFFF00', - /** 区段计轴颜色*/ - sectionAxleColor: '#C0C0C0', - /** 区段边界符颜色*/ - sectionSeparatorColor: '#7F7F7F', - /** 区段空闲颜色*/ - sectionSpareColor: '#606060', - /** 逻辑区段名称颜色*/ - sectionLogicalTextColor: '#C0C0C0', - /** 区段通信车占用颜色**/ - sectionCommunicationOccupiedColor: '#FF0000', - /** 区段非通讯车占用颜色*/ - sectionUnCommunicationOccupiedColor: '#800080', - /** 区段路由锁定颜色*/ - sectionRouteLockColor: '#FFFFFF', - /** 区段故障锁定颜色*/ - sectionFaultLockColor: '#006400', - /** 区段未定义颜色*/ - sectionUndefinedColor: '#0071C1', - /** 保护区段锁闭*/ - sectionProtectionSectionLockedColor: '#FEFF00', - /** 区段计轴预复位*/ - sectionAxleResetColor: '#00FFFF', - /** 区段封锁颜色*/ - sectionBlockColor: '#800080', - /** 区段atc切除颜色*/ - sectionAtcExcisionColor: '#A0522D', - /** 区段ats切除颜色*/ - sectionAtsExcisionColor: '#A0522D', - /** 区段延时释放颜色*/ - sectionTimeReleaseColor: '#3F3F3F', - /** 区段保护锁闭*/ - sectionProtectiveLockColor: '#FFFF00', - /** 区段保护延时解锁*/ - sectionProtectiveTimeReleaseColor: '#0071C1', - /** 计轴失效*/ - sectionAxleFailure: '#E6A23C' // #FFFF00 + text: { // 区段文字属性 + fontSize: 10, // 字体大小 + fontFormat: 'consolas', // 字体族类 + fontColor: '#C0C0C0', // 字体颜色 + textAlign: 'center', // 水平对齐方式 + textPosition: 'inside', // 文字位置 + textVerticalAlign: 'middle', // 文字垂直对齐方式 + position: 0 // 区段名称位置 1 上行 -1 下面 0 默认 + }, + line: { + width: 5, // 区段宽度 + beyondWidth: 0, // 区段宽超出宽度 + invadeColor: '#EF0C08', // 区段侵入颜色 + spareColor: '#606060', // 区段空闲颜色 + communicationOccupiedColor: '#FF0000', // 区段通信车占用颜色 + unCommunicationOccupiedColor: '#800080', // 区段非通讯车占用颜色 + routeLockColor: '#FFFFFF', // 区段路由锁定颜色 + faultLockColor: '#006400', // 区段故障锁定颜色 + undefinedColor: '#0071C1', // 区段未定义颜色 + protectionLockedColor: '#FEFF00', // 保护区段锁闭(未用) + blockColor: '#800080', // 区段封锁颜色 + atcExcisionColor: '#A0522D', // 区段atc切除颜色 + atsExcisionColor: '#A0522D', // 区段ats切除颜色 + timeReleaseColor: '#3F3F3F', // 区段延时释放颜色 + protectiveLockColor: '#FFFF00', // 区段保护锁闭 + protectiveTimeReleaseColor: '#0071C1', // 区段保护延时解锁 + logicalColor: '#FFFF00', // 逻辑区段颜色 (未用) + logicalTextColor: '#C0C0C0' // 逻辑区段名称颜色 (未用) + }, + axle: { + radius: 3, // 计轴 半径 + distance: 5, // 计轴和区段之间的距离 (未用) + color: '#C0C0C0', // 区段计轴颜色 + resetColor: '#00FFFF', // 区段计轴预复位颜色 + Failure: '#E6A23C' // #FFFF00 计轴失效 + }, + speedLimit: { // 限速元素 + width: 1, // 限速线的宽度 + Distance: 5, // 限速线距离区段距离 + lineColor: '#FFFF00' // 限速线颜色 + }, + separator: { + width: 1.2, // 分隔符宽度 + endWidth: 1.2, // 尽头分隔符宽度 + endColor: '#7F7F7F', // 尽头分隔符颜色 + color: '#7F7F7F' // 区段边界符颜色 + } }; this[deviceType.Signal] = { /** 信号机宽度 */ @@ -133,76 +121,52 @@ class Beijing extends defaultSkin { signalLampBlueColor: '#0070C0' }; this[deviceType.StationStand] = { - /** 站台和屏蔽门之间的距离*/ - standDistance: 9, - /** 站台屏蔽门高度*/ - standSafeHeight: 1.6, - /** 站台首端字体大小*/ - standHeadFontSize: 8, - /** 站台默认字体大小*/ - standTextFontSize: 8, - /** 站台紧急关闭半径*/ - standEmergentR: 4, - /** 站台紧急关闭偏移量*/ - standEmergentOffset: {x: 0, y: 0}, - /** 扣车方向*/ - standDetainDirection: 1, - /** 扣车偏移量*/ - standDetainOffset: {x: -8, y: 13}, - /** 运行时间方向*/ - standTimeDirection: 1, - /** 运行时间偏移量*/ - standTimeOffset: {x: -8, y: 3}, - /** 运行等级方向*/ - standLevelDirection: 1, - /** 运行等级偏移量*/ - standLevelOffset: {x: -8, y: 22}, - /** 折返方向*/ - standReentryDirection: 0, - /** 折返偏移量*/ - standReentryOffset: {x: -16, y: 18}, - /** 扣车显示内容*/ - standDetainText: 'H', - /** 站台无人折返*/ - standNoHumanReentryColor: '#0F16DA', - /** 站台自动换端*/ - standAutoChangeEndsColor: '#0BF400', - /** 站台空闲颜色*/ - standSpareColor: '#606060', - /** 站台列车停站颜色*/ - standStopColor: '#FEFE00', - /** 站台跳停颜色*/ - standJumpStopColor: '#9A99FF', - /** 站台指定列车跳停颜色*/ - standDesignatedJumpStopColor: 'lightSkyBlue', - /** 站台紧急关闭颜色*/ - standEmergentCloseColor: '#F61107', - /** 停站时间字体颜色*/ - standTimeTextColor: '#FFFFFF', - /** 停站等级字体颜色*/ - standLevelTextColor: '#FFFFFF', - /** 车站扣车颜色*/ - standDetainTrainColor: '#E4EF50', - /** 中心扣车颜色*/ - standCenterDetainTrainColor: '#FFFFFF', - /** 车站+中心扣车颜色*/ - standAndCenterDetainTrainColor: '#F61107', - /** 屏蔽门默认颜色*/ - standDoorDefaultColor: '#00FF00', - /** 屏蔽门切除颜色*/ - standSplitDoorColor: '#F61107', - /** 车站扣除文字颜色*/ - standDetainTrainTextColor: '#E4EF50', - /** 计数器字体颜色*/ - stationCounterTextColor: '#FFFFFF', - /** 计数器边框颜色*/ - stationCounterBorderColor: '#E4EF50', - /** 延迟解锁倒计时和设备文字之间的距离*/ - stationDelayUnlockDistance: 3, - /** 延时解锁字体颜色*/ - stationDelayUnlockTextColor: '#FFFFFF', - /** 延迟解锁边框颜色*/ - stationDelayUnlockBorderColor: '#FFFFFF' + common: { // 通用属性 + textFontSize: 8 // 站台默认字体大小 + }, + safetyDoor: { // 屏蔽门 + height: 1.6, // 站台屏蔽门高度 + distance: 9, // 站台和屏蔽门之间的距离 + defaultColor: '#00FF00', // 屏蔽门默认颜色 + splitDoorColor: '#F61107' // 屏蔽门切除颜色 + }, + stand: { // 站台 + headFontSize: 8, // 站台首端字体大小 + spareColor: '#606060', // 站台空闲颜色 + stopColor: '#FEFE00', // 站台列车停站颜色 + jumpStopColor: '#9A99FF', // 站台跳停颜色 + designatedJumpStopColor: 'lightSkyBlue' // 站台指定列车跳停颜色 + }, + standEmergent: { // 紧急关闭 + mergentR: 4, // 站台紧急关闭半径 + offset: {x: 0, y: 0}, // 站台紧急关闭偏移量 + closeColor: '#F61107' // 站台紧急关闭颜色 + }, + reentry: { // 站台折返策略 + direction: 0, // 折返方向 + offset: {x: -16, y: 18}, // 折返偏移量 + noHumanColor: '#0F16DA', // 站台无人折返 + AutoChangeEndsColor: '#0BF400' // 站台自动换端 + }, + detainCar: { // 扣车 + text: 'H', // 扣车显示内容 + direction: 1, // 扣车方向 + offset: {x: -8, y: 13}, // 扣车偏移量 + trainColor: '#E4EF50', // 车站扣车颜色 + centerTrainColor: '#FFFFFF', // 中心扣车颜色 + andCenterTrainColor: '#F61107', // 车站+中心扣车颜色 + detainTrainTextColor: '#E4EF50' // 车站扣除文字颜色 + }, + stopTime: { // 停站时间 + direction: 1, // 运行时间方向 + offset: {x: -8, y: 3}, // 运行时间偏移量 + textColor: '#FFFFFF' // 停站时间字体颜色 + }, + level: { // 运行等级 + direction: 1, // 运行等级方向 + offset: {x: -8, y: 22}, // 运行等级偏移量 + textColor: '#FFFFFF' // 停站等级字体颜色 + } }; this[deviceType.StationControl] = { singleControlNum: 3, From 2604b121203ed4c18466efb69f24b9e2e0714ef7 Mon Sep 17 00:00:00 2001 From: zyy <1787816799@qq.com> Date: Tue, 23 Jul 2019 18:13:50 +0800 Subject: [PATCH 05/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/theme/fuzhou.js | 222 ++++++++++++++++----------------------- 1 file changed, 93 insertions(+), 129 deletions(-) diff --git a/src/jmap/theme/fuzhou.js b/src/jmap/theme/fuzhou.js index acca5e351..c9c6e31f5 100644 --- a/src/jmap/theme/fuzhou.js +++ b/src/jmap/theme/fuzhou.js @@ -7,73 +7,61 @@ class Fuzhou extends defaultSkin { this[deviceType.Link] = { /** line 颜色*/ lineWidthColor: '#FFFFFF', - /** link 宽度*/ linkWidth: 4.4, - /** link 线条颜色*/ linkColor: '#3F3F3F', - /** link 字体颜色*/ linkTextColor: '#FFFFFF' }; this[deviceType.Section] = { - sectionTextPosition: 0, // 区段名称位置 1 上行 -1 下面 0 默认 - /** 区段 宽度*/ - sectionWidth: 5, - /** 区段宽超出宽度*/ - sectionBeyondWidth: 1, - /** 计轴 半径*/ - sectionAxleR: 3, - /** 计轴和区段之间的距离*/ /** 需要添加*/ - sectionAxleDistance: 5, - /** 限速线的宽短*/ - sectionSpeedLimitLinewidth: 1, - /** 限速线距离区段距离*/ - sectionSpeedLimitDistance: 5, - sectionSeparatorWidth: 1.2, // 分隔符宽度 - sectionEndSeparatorWidth: 3.5, // 尽头分隔符宽度 - sectionEndSeparatorStroke: '#3F3F3F', // 尽头分隔符颜色 - /** 区段侵入颜色*/ - sectionInvadeColor: '#EF0C08', - /** 限速线颜色*/ - sectionSpeedLimitColor: '#FFFF00', - sectionLogicalBackgroundColor: '#FFFF00', // 逻辑区段颜色 - /** 区段计轴颜色*/ - sectionAxleColor: '#FFFFFF', - /** 区段边界符颜色*/ - sectionSeparatorColor: '#3149C3', - /** 区段空闲颜色*/ - sectionSpareColor: '#3F3F3F', - /** 逻辑区段名称颜色*/ - sectionLogicalTextColor: '#FFFFFF', - /** 区段通信车占用颜色**/ - sectionCommunicationOccupiedColor: '#FF329A', - /** 区段非通讯车占用颜色*/ - sectionUnCommunicationOccupiedColor: '#FE0000', - /** 区段路由锁定颜色*/ - sectionRouteLockColor: '#FFFFFF', - /** 区段故障锁定颜色*/ - sectionFaultLockColor: '#9B4A0A', - /** 区段未定义颜色*/ - sectionUndefinedColor: '#0071C1', - /** 保护区段锁闭*/ - sectionProtectionSectionLockedColor: '#FEFF00', - /** 区段计轴预复位*/ - sectionAxleResetColor: '#00FFFF', - /** 区段封锁颜色*/ - sectionBlockColor: '#800080', - /** 区段atc切除颜色*/ - sectionAtcExcisionColor: '#A0522D', - /** 区段ats切除颜色*/ - sectionAtsExcisionColor: '#A0522D', - /** 区段延时释放颜色*/ - sectionTimeReleaseColor: '#3F3F3F', - /** 区段保护锁闭*/ - sectionProtectiveLockColor: '#FFFF00', - /** 区段保护延时解锁*/ - sectionProtectiveTimeReleaseColor: '#0071C1', - sectionAxleFailure: '#E6A23C' // #FFFF00 计轴失效 + text: { // 区段文字属性 + fontSize: 10, // 字体大小 + fontFormat: 'consolas', // 字体族类 + fontColor: '#C0C0C0', // 字体颜色 + textAlign: 'center', // 水平对齐方式 + textPosition: 'inside', // 文字位置 + textVerticalAlign: 'middle', // 文字垂直对齐方式 + position: 0 // 区段名称位置 1 上行 -1 下面 0 默认 + }, + line: { + width: 5, // 区段宽度 + beyondWidth: 1, // 区段宽超出宽度 + invadeColor: '#EF0C08', // 区段侵入颜色 + spareColor: '#3F3F3F', // 区段空闲颜色 + communicationOccupiedColor: '#FF329A', // 区段通信车占用颜色 + unCommunicationOccupiedColor: '#FE0000', // 区段非通讯车占用颜色 + routeLockColor: '#FFFFFF', // 区段路由锁定颜色 + faultLockColor: '#9B4A0A', // 区段故障锁定颜色 + undefinedColor: '#0071C1', // 区段未定义颜色 + protectionLockedColor: '#FEFF00', // 保护区段锁闭(未用) + blockColor: '#800080', // 区段封锁颜色 + atcExcisionColor: '#A0522D', // 区段atc切除颜色 + atsExcisionColor: '#A0522D', // 区段ats切除颜色 + timeReleaseColor: '#3F3F3F', // 区段延时释放颜色 + protectiveLockColor: '#FFFF00', // 区段保护锁闭 + protectiveTimeReleaseColor: '#0071C1', // 区段保护延时解锁 + logicalColor: '#FFFF00', // 逻辑区段颜色 (未用) + logicalTextColor: '#FFFFFF' // 逻辑区段名称颜色 (未用) + }, + axle: { + radius: 3, // 计轴 半径 + distance: 5, // 计轴和区段之间的距离 (未用) + color: '#FFFFFF', // 区段计轴颜色 + resetColor: '#00FFFF', // 区段计轴预复位颜色 + Failure: '#E6A23C' // #FFFF00 计轴失效 + }, + speedLimit: { // 限速元素 + width: 1, // 限速线的宽短 + Distance: 5, // 限速线距离区段距离 + lineColor: '#FFFF00' // 限速线颜色 + }, + separator: { + width: 1.2, // 分隔符宽度 + endWidth: 3.5, // 尽头分隔符宽度 + endColor: '#3F3F3F', // 尽头分隔符颜色 + color: '#3149C3' // 区段边界符颜色 + } }; this[deviceType.Signal] = { /** 信号机宽度 */ @@ -130,76 +118,52 @@ class Fuzhou extends defaultSkin { signalLampBlueColor: '#0070C0' }; this[deviceType.StationStand] = { - /** 站台和屏蔽门之间的距离*/ - standDistance: 8, - /** 站台屏蔽门高度*/ - standSafeHeight: 3, - /** 站台首端字体大小*/ - standHeadFontSize: 10, - /** 站台默认字体大小*/ - standTextFontSize: 10, - /** 站台紧急关闭半径*/ - standEmergentR: 4, - /** 站台紧急关闭偏移量*/ - standEmergentOffset: {x: 0, y: 40}, - /** 扣车方向*/ - standDetainDirection: -1, - /** 扣车偏移量*/ - standDetainOffset: {x: -8, y: -6}, - /** 运行时间方向*/ - standTimeDirection: 1, - /** 运行时间偏移量*/ - standTimeOffset: {x: -8, y: 26}, - /** 运行等级方向*/ - standLevelDirection: 1, - /** 运行等级偏移量*/ - standLevelOffset: {x: -8, y: 6}, - /** 折返方向*/ - standReentryDirection: 0, - /** 折返偏移量*/ - standReentryOffset: {x: -16, y: 20}, - /** 扣车显示内容*/ - standDetainText: 'H', - /** 站台无人折返*/ - standNoHumanReentryColor: '#0F16DA', - /** 站台自动换端*/ - standAutoChangeEndsColor: '#0BF400', - /** 站台空闲颜色*/ - standSpareColor: '#606060', - /** 站台列车停站颜色*/ - standStopColor: '#FEFE00', - /** 站台跳停颜色*/ - standJumpStopColor: '#9A99FF', - /** 站台指定列车跳停颜色*/ - standDesignatedJumpStopColor: 'lightSkyBlue', - /** 站台紧急关闭颜色*/ - standEmergentCloseColor: '#F61107', - /** 停站时间字体颜色*/ - standTimeTextColor: '#FFFFFF', - /** 停站等级字体颜色*/ - standLevelTextColor: '#FFFFFF', - /** 车站扣车颜色*/ - standDetainTrainColor: '#E4EF50', - /** 中心扣车颜色*/ - standCenterDetainTrainColor: '#FFFFFF', - /** 车站+中心扣车颜色*/ - standAndCenterDetainTrainColor: '#F61107', - /** 屏蔽门默认颜色*/ - standDoorDefaultColor: '#00FF00', - /** 屏蔽门切除颜色*/ - standSplitDoorColor: '#F61107', - /** 车站扣除文字颜色*/ - standDetainTrainTextColor: '#E4EF50', - /** 计数器字体颜色*/ - stationCounterTextColor: '#FFFFFF', - /** 计数器边框颜色*/ - stationCounterBorderColor: '#E4EF50', - /** 延迟解锁倒计时和设备文字之间的距离*/ - stationDelayUnlockDistance: 3, - /** 延时解锁字体颜色*/ - stationDelayUnlockTextColor: '#FFFFFF', - /** 延迟解锁边框颜色*/ - stationDelayUnlockBorderColor: '#FFFFFF' + common: { // 通用属性 + textFontSize: 10 // 站台默认字体大小 + }, + safetyDoor: { // 屏蔽门 + height: 3, // 站台屏蔽门高度 + distance: 8, // 站台和屏蔽门之间的距离 + defaultColor: '#00FF00', // 屏蔽门默认颜色 + splitDoorColor: '#F61107' // 屏蔽门切除颜色 + }, + stand: { // 站台 + headFontSize: 10, // 站台首端字体大小 + spareColor: '#606060', // 站台空闲颜色 + stopColor: '#FEFE00', // 站台列车停站颜色 + jumpStopColor: '#9A99FF', // 站台跳停颜色 + designatedJumpStopColor: 'lightSkyBlue' // 站台指定列车跳停颜色 + }, + standEmergent: { // 紧急关闭 + mergentR: 4, // 站台紧急关闭半径 + offset: {x: 0, y: 40}, // 站台紧急关闭偏移量 + closeColor: '#F61107' // 站台紧急关闭颜色 + }, + reentry: { // 站台折返策略 + direction: 0, // 折返方向 + offset: {x: -16, y: 20}, // 折返偏移量 + noHumanColor: '#0F16DA', // 站台无人折返 + AutoChangeEndsColor: '#0BF400' // 站台自动换端 + }, + detainCar: { // 扣车 + text: 'H', // 扣车显示内容 + direction: -1, // 扣车方向 + offset: {x: -8, y: -6}, // 扣车偏移量 + trainColor: '#E4EF50', // 车站扣车颜色 + centerTrainColor: '#FFFFFF', // 中心扣车颜色 + andCenterTrainColor: '#F61107', // 车站+中心扣车颜色 + detainTrainTextColor: '#E4EF50' // 车站扣除文字颜色 + }, + stopTime: { // 停站时间 + direction: 1, // 运行时间方向 + offset: {x: -8, y: 26}, // 运行时间偏移量 + textColor: '#FFFFFF' // 停站时间字体颜色 + }, + level: { // 运行等级 + direction: 1, // 运行等级方向 + offset: {x: -8, y: 6}, // 运行等级偏移量 + textColor: '#FFFFFF' // 停站等级字体颜色 + } }; this[deviceType.StationControl] = { singleControlNum: 2, From 1bab212c0537164fd4ad3f7a3ad7cbd5cbc09ff1 Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Tue, 23 Jul 2019 18:21:49 +0800 Subject: [PATCH 06/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/shape/Signal/ESigButton.js | 18 ++-- src/jmap/shape/Signal/ESigLmap.js | 26 ++--- src/jmap/shape/Signal/ESigPass.js | 66 ------------- src/jmap/shape/Signal/ESigPost.js | 18 ++-- src/jmap/shape/Signal/ESigRoute.js | 4 +- src/jmap/shape/Signal/index.js | 80 +++++++-------- src/jmap/shape/StationControl/EArrow.js | 4 +- src/jmap/theme/fuzhou.js | 126 ++++++++++++++---------- 8 files changed, 150 insertions(+), 192 deletions(-) delete mode 100644 src/jmap/shape/Signal/ESigPass.js diff --git a/src/jmap/shape/Signal/ESigButton.js b/src/jmap/shape/Signal/ESigButton.js index 10a172d6a..19341cdc9 100644 --- a/src/jmap/shape/Signal/ESigButton.js +++ b/src/jmap/shape/Signal/ESigButton.js @@ -15,7 +15,7 @@ class ESigButton extends Group { const model = this.model; const style = this.model.style; const padding = 1; - const r = style.Signal.signalR * 0.8; + const r = style.Signal.lamp.signalR * 0.8; this.style = style; this._subType = 'SignalButton'; @@ -26,15 +26,15 @@ class ESigButton extends Group { _subType: this._subType, _val: '1', shape: { - x: model.x - style.Signal.signalR, + x: model.x - style.Signal.lamp.signalR, y: model.y - r + r * model.posit, - width: style.Signal.signalR * 2, - height: style.Signal.signalR * 2 + width: style.Signal.lamp.signalR * 2, + height: style.Signal.lamp.signalR * 2 }, style: { lineWidth: 0.2, - stroke: style.Signal.signalButtonDashColor, - fill: style.Signal.signalButtonColor + stroke: style.Signal.button.signalButtonDashColor, + fill: style.Signal.button.signalButtonColor } }); @@ -46,12 +46,12 @@ class ESigButton extends Group { shape: { cx: model.x, cy: model.y - 5 / 2 * r * model.posit, - r: style.Signal.signalR + r: style.Signal.lamp.signalR }, style: { lineWidth: 0.2, - stroke: style.Signal.signalButtonDashColor, - fill: style.Signal.signalButtonColor + stroke: style.Signal.button.signalButtonDashColor, + fill: style.Signal.button.signalButtonColor } }); diff --git a/src/jmap/shape/Signal/ESigLmap.js b/src/jmap/shape/Signal/ESigLmap.js index ac1f2dcab..90d3c8ed0 100644 --- a/src/jmap/shape/Signal/ESigLmap.js +++ b/src/jmap/shape/Signal/ESigLmap.js @@ -20,12 +20,12 @@ class ESigLmap extends Group { shape: { cx: model.x, cy: model.y, - r: style.Signal.signalR + r: style.Signal.lamp.signalR }, style: { - lineWidth: 0.4, + lineWidth: style.Signal.lamp.signalBorderWidth, fill: style.backgroundColor, - stroke: style.Signal.signalLampStandardColor + stroke: style.Signal.post.signalLampStandardColor } }); @@ -37,13 +37,13 @@ class ESigLmap extends Group { y: model.originY }, shape: { - x1: model.x + (style.Signal.signalR + 1) * Math.cos(Math.PI / 4), - y1: model.y + (style.Signal.signalR + 1) * Math.sin(Math.PI / 4), - x2: model.x - (style.Signal.signalR + 1) * Math.cos(Math.PI / 4), - y2: model.y - (style.Signal.signalR + 1) * Math.sin(Math.PI / 4) + x1: model.x + (style.Signal.lamp.signalR + 1) * Math.cos(Math.PI / 4), + y1: model.y + (style.Signal.lamp.signalR + 1) * Math.sin(Math.PI / 4), + x2: model.x - (style.Signal.lamp.signalR + 1) * Math.cos(Math.PI / 4), + y2: model.y - (style.Signal.lamp.signalR + 1) * Math.sin(Math.PI / 4) }, style: { - lineWidth: 1.5, + lineWidth: style.Signal.lamp.signalStopWidth, stroke: style.backgroundColor } }); @@ -56,13 +56,13 @@ class ESigLmap extends Group { y: model.originY }, shape: { - x1: model.x + (style.Signal.signalR + 1) * Math.cos(Math.PI / 4), - y1: model.y + (style.Signal.signalR + 1) * (Math.sin(Math.PI / 4) - Math.sqrt(2)), - x2: model.x - (style.Signal.signalR + 1) * Math.cos(Math.PI / 4), - y2: model.y - (style.Signal.signalR + 1) * (Math.sin(Math.PI / 4) - Math.sqrt(2)) + x1: model.x + (style.Signal.lamp.signalR + 1) * Math.cos(Math.PI / 4), + y1: model.y + (style.Signal.lamp.signalR + 1) * (Math.sin(Math.PI / 4) - Math.sqrt(2)), + x2: model.x - (style.Signal.lamp.signalR + 1) * Math.cos(Math.PI / 4), + y2: model.y - (style.Signal.lamp.signalR + 1) * (Math.sin(Math.PI / 4) - Math.sqrt(2)) }, style: { - lineWidth: 1.5, + lineWidth: style.Signal.lamp.signalStopWidth, stroke: style.backgroundColor } }); diff --git a/src/jmap/shape/Signal/ESigPass.js b/src/jmap/shape/Signal/ESigPass.js deleted file mode 100644 index ca1f0eeeb..000000000 --- a/src/jmap/shape/Signal/ESigPass.js +++ /dev/null @@ -1,66 +0,0 @@ -import Polygon from 'zrender/src/graphic/shape/Polygon'; -import Group from 'zrender/src/container/Group'; -import { arrows } from '../utils/ShapePoints'; - -class ESigPass extends Group { - constructor(model) { - super(); - this.model = model; - this._create(); - } - - _create() { - const model = this.model; - const style = this.model.style; - const rotation = model.drict != 1? 0 : Math.PI; - const point = arrows(model.x, model.y, style.Signal.signalSigPassWidth, style.Signal.signalR * 0.8); - this.arrows = new Polygon({ - zlevel: model.zlevel, - z: model.z, - rotation: rotation, - shape: { - points: point - }, - style: { - stroke: model.stroke, - lineWidth: model.lineWidth, - fill: model.fill - } - }); - this.add(this.arrows); - } - - // 停止动画 - animationRecover() { - this.arrows.stopAnimation(false); - } - - // 箭头颜色 - setColor(color) { - this.arrows.setStyle('fill', color); - } - - // 箭头闪烁 - arrowsAnimation() { - const style = this.model.style; - const fill = this.arrows.style.Signal.fill; - this.arrows.animate(true) - .when(1000, { fill: style.backgroundColor, stroke: style.style.backgroundColor }) - .when(2000, { fill: fill, stroke: style.style.Signal.sidelineColor }) - .when(3000, { fill: style.style.backgroundColor, stroke: style.style.backgroundColor }) - .when(4000, { fill: fill, stroke: style.style.Signal.sidelineColor }) - .start(); - } - - // 隐藏 - hide() { - this.arrows.hide(); - } - - // 显示 - show() { - this.arrows.show(); - } -} - -export default ESigPass; diff --git a/src/jmap/shape/Signal/ESigPost.js b/src/jmap/shape/Signal/ESigPost.js index 59eced36a..d844546b0 100644 --- a/src/jmap/shape/Signal/ESigPost.js +++ b/src/jmap/shape/Signal/ESigPost.js @@ -17,13 +17,13 @@ class ESigPost extends Group { z: model.z, shape: { points: [ - [model.x, model.y + style.Signal.signalR * 1.2], - [model.x, model.y - style.Signal.signalR * 1.2] + [model.x, model.y + style.Signal.lamp.signalR * 1.2], + [model.x, model.y - style.Signal.lamp.signalR * 1.2] ] }, style: { - lineWidth: style.Signal.signalLampStandardWidth, - stroke: style.Signal.signalLampStandardColor + lineWidth: style.Signal.post.signalLampStandardWidth, + stroke: style.Signal.post.signalLampStandardColor } }); @@ -33,12 +33,12 @@ class ESigPost extends Group { shape: { points: [ [model.x, model.y], - [model.x + model.drict * style.Signal.signalR * 1.2, model.y] + [model.x + model.drict * style.Signal.lamp.signalR * 1.2, model.y] ] }, style: { - lineWidth: style.Signal.signalLampStandardWidth, - stroke: style.Signal.signalLampStandardColor + lineWidth: style.Signal.post.signalLampStandardWidth, + stroke: style.Signal.post.signalLampStandardColor } }); @@ -53,12 +53,12 @@ class ESigPost extends Group { const style = this.model.style; if (type === '01') { return { - x: model.x + model.drict * style.Signal.signalR * 3 / 2, + x: model.x + model.drict * style.Signal.lamp.signalR * 3 / 2, y: model.y }; } else { return { - x: this.hor.shape.points[1][0] + model.drict * style.Signal.signalR, + x: this.hor.shape.points[1][0] + model.drict * style.Signal.lamp.signalR, y: this.hor.shape.points[1][1] }; } diff --git a/src/jmap/shape/Signal/ESigRoute.js b/src/jmap/shape/Signal/ESigRoute.js index 2321d6638..398fe29b5 100644 --- a/src/jmap/shape/Signal/ESigRoute.js +++ b/src/jmap/shape/Signal/ESigRoute.js @@ -16,12 +16,12 @@ class ESigDrict extends Group { zlevel: model.zlevel, z: model.z, shape: { - points: triangular(model.x, model.y, model.drict, style.Signal.signalR) + points: triangular(model.x, model.y, model.drict, style.Signal.lamp.signalR) }, style: { stroke: style.backgroundColor, lineWidth: 0.5, - fill: style.Signal.signalLampYellowColor + fill: style.Signal.route.signalRouteColor } }); this.add(this.sigDrict); diff --git a/src/jmap/shape/Signal/index.js b/src/jmap/shape/Signal/index.js index 20596c112..7f3c459c6 100644 --- a/src/jmap/shape/Signal/index.js +++ b/src/jmap/shape/Signal/index.js @@ -4,7 +4,7 @@ import ESigPost from './ESigPost'; import ESigLmap from './ESigLmap'; -import ESigPass from './ESigPass'; +import ESigAuto from './ESigAuto'; import ESigRoute from './ESigRoute'; import ESigButton from './ESigButton'; import ESigDelay from './ESigDelay'; @@ -42,7 +42,7 @@ class Signal extends Group { drict: drict, type: model.lampPostType, x: model.position.x, - y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.signalR) + y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.lamp.signalR) }); // 信号灯 @@ -55,7 +55,7 @@ class Signal extends Group { style: style, index: i + 1, drict: drict, - x: endPoint.x + i * drict * style.Signal.signalR * 2, + x: endPoint.x + i * drict * style.Signal.lamp.signalR * 2, y: endPoint.y, originX: model.position.x, originY: model.position.y @@ -66,7 +66,7 @@ class Signal extends Group { // 信号机名称 const sigNameX = model.position.x + model.namePosition.x; - const sigNameY = model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.signalR * 2 + model.namePosition.y); + const sigNameY = model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.lamp.signalR * 2 + model.namePosition.y); this.sigName = new ESigName({ zlevel: this.zlevel, z: this.z, @@ -75,16 +75,16 @@ class Signal extends Group { x: sigNameX, y: sigNameY, text: model.name, - textFont: `bold ${style.Signal.signalTextFontSize} px ${style.textFontFormat}`, - textFill: style.Signal.signalTextGreen, + textFont: `bold ${style.Signal.text.signalTextFontSize} px ${style.textFontFormat}`, + textFill: style.Signal.text.signalTextGreen, textAlign: 'middle', textVerticalAlign: posit == 1 ? 'top' : 'bottom' }); // 自动进路 - const sigRouteH = style.Signal.signalSigRouteDirection ? this.count * style.Signal.signalR * 2 : -style.Signal.signalR * 2; - const sigRouteX = endPoint.x + (style.Signal.signalSigRouteOffset.x + sigRouteH) * drict; - const sigRouteY = endPoint.y + (style.Signal.signalSigRouteOffset.y); + const sigRouteH = style.Signal.route.signalRouteDirection ? this.count * style.Signal.lamp.signalR * 2 : -style.Signal.lamp.signalR * 2; + const sigRouteX = endPoint.x + (style.Signal.route.signalRouteOffset.x + sigRouteH) * drict; + const sigRouteY = endPoint.y + (style.Signal.route.signalRouteOffset.y); this.sigRoute = new ESigRoute({ zlevel: this.zlevel, z: this.z, @@ -95,27 +95,27 @@ class Signal extends Group { }); // 自动通过 - const sigPassH = style.Signal.signalSigPassDirection ? this.count * style.Signal.signalR * 2 : -style.Signal.signalR * 2; - const sigPassX = endPoint.x + (style.Signal.signalSigPassOffset.x + sigPassH) * drict; - const sigPassY = endPoint.y + (style.Signal.signalSigPassOffset.y); - this.sigPass = new ESigPass({ + const sigAutoH = style.Signal.auto.signalAutoDirection ? this.count * style.Signal.lamp.signalR * 2 : -style.Signal.lamp.signalR * 2; + const sigAutoX = endPoint.x + (style.Signal.auto.signalAutoOffset.x + sigAutoH) * drict; + const sigAutoY = endPoint.y + (style.Signal.auto.signalAutoOffset.y); + this.sigAuto = new ESigAuto({ zlevel: this.zlevel, z: this.z, style: style, count: this.count, drict: drict, - x: sigPassX, - y: sigPassY, + x: sigAutoX, + y: sigAutoY, width: style.Signal.signalSigPassWidth, - fill: style.Signal.signalLampGreenColor, + fill: style.Signal.lamp.signalLampGreenColor, lineWidth: 0.6, stroke: style.sidelineColor }); // 延迟解锁 - const sigDelayH = style.Signal.signalSigDelayDirection ? this.count * style.Signal.signalR * 2 : -style.Signal.signalR * 2; - const sigDelayX = endPoint.x + (style.Signal.signalSigDelayOffset.x + sigDelayH) * drict; - const sigDelayY = endPoint.y - (style.Signal.signalSigDelayOffset.y) * posit; + const sigDelayH = style.Signal.delay.signalDelayDirection ? this.count * style.Signal.lamp.signalR * 2 : -style.Signal.lamp.signalR * 2; + const sigDelayX = endPoint.x + (style.Signal.delay.signalDelayOffset.x + sigDelayH) * drict; + const sigDelayY = endPoint.y - (style.Signal.delay.signalDelayOffset.y) * posit; this.sigDelay = new ESigDelay({ zlevel: this.zlevel, z: this.z, @@ -123,8 +123,8 @@ class Signal extends Group { x: sigDelayX, y: sigDelayY, text: this.state.delayCount || '0', - textFont: `bold ${style.Signal.signalDelayTextFontSize} px ${style.textFontFormat}`, - textFill: style.Signal.signalTextRed, + textFont: `bold ${style.Signal.delay.signalDelayTextFontSize} px ${style.textFontFormat}`, + textFill: style.Signal.delay.signalDelayTextColor, textAlign: drict > 0 ? 'right' : 'left', textVerticalAlign: 'middle' }); @@ -137,13 +137,13 @@ class Signal extends Group { posit: posit, show: model.buttonShow, x: model.buttonPosition.x, - y: model.buttonPosition.y - posit * (style.Signal.signalButtonDistance + style.Signal.signalR * 2) + y: model.buttonPosition.y - posit * (style.Signal.button.signalButtonDistance + style.Signal.lamp.signalR * 2) }); this.add(this.sigPost); this.lamps.forEach(lamp => { this.add(lamp); }); this.add(this.sigName); - this.add(this.sigPass); + this.add(this.sigAuto); this.add(this.sigRoute); this.add(this.sigDelay); // this.add(this.sigButton); @@ -169,13 +169,13 @@ class Signal extends Group { if (this.count === 1) { if (this.model.useType === '05') { /** 单灯 调车信号机*/ - this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampBlueColor); + this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampBlueColor); } else { /** 单灯 出站信号机 */ /** 单灯 阻挡信号机*/ /** 单灯 阻挡兼调车信号 */ /** 单灯 列兼调信号机 */ - this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampRedColor); + this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampRedColor); } } } @@ -185,7 +185,7 @@ class Signal extends Group { if (this.count === 1) { /** 单灯 出站信号机*/ /** 单灯 阻隔信号机*/ - this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampGreenColor); + this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampGreenColor); } } @@ -193,7 +193,7 @@ class Signal extends Group { trainRoute() { if (this.count === 1) { /** 单灯 列兼调信号*/ - this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampYellowColor); + this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampYellowColor); } } @@ -202,7 +202,7 @@ class Signal extends Group { if (this.count === 1) { /** 单灯 列兼调信号*/ /** 单灯 阻挡兼调车信号*/ - this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampWhiteColor); + this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampWhiteColor); } } @@ -213,7 +213,7 @@ class Signal extends Group { // 封锁 block() { - this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampRedColor); + this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampRedColor); this.sigName.setColor(this.style.Signal.sectionBlockTextColor); } @@ -243,25 +243,25 @@ class Signal extends Group { // 设置自动进路模式状态类型 setAutoRouteOpen() { if (this.model.linkageAutoRouteShow) { - this.sigPass.show(); + this.sigAuto.show(); } else { - this.sigPass.hide(); + this.sigAuto.hide(); } this.recover(); - this.sigPass.setColor(this.style.Signal.signalLampGreenColor); + this.sigAuto.setColor(this.style.Signal.auto.signalAutoRoute); } // 信号机进路自动触发模式状态类型 setAutoAccessOpen() { if (this.model.atsAutoTriggerShow) { - this.sigPass.show(); + this.sigAuto.show(); } else { - this.sigPass.hide(); + this.sigAuto.hide(); } this.recover(); - this.sigPass.setColor(this.style.Signal.signalLampYellowColor); + this.sigAuto.setColor(this.style.Signal.auto.signalAutoTrigger); } // 设置自动信号模式状态类型 @@ -271,14 +271,14 @@ class Signal extends Group { // 隐藏自动信号和自动进路 setAutoClose() { - this.sigPass.hide(); - this.sigPass.setColor(this.style.backgroundColor); + this.sigAuto.hide(); + this.sigAuto.setColor(this.style.backgroundColor); this.sigRoute.hide(); } // 自动信号和自动进路开始动画 setAutoFlicker() { - this.sigPass.arrowsAnimation(); + this.sigAuto.arrowsAnimation(); } // 设置延时解锁 @@ -289,8 +289,8 @@ class Signal extends Group { // 恢复状态 recover() { this.sigDelay.hide(); - this.sigPass.animationRecover(); - this.sigName.setColor(this.style.Signal.signalTextGreen); + this.sigAuto.animationRecover(); + this.sigName.setColor(this.style.Signal.text.signalTextGreen); } setState(state) { diff --git a/src/jmap/shape/StationControl/EArrow.js b/src/jmap/shape/StationControl/EArrow.js index edd1828d4..72e675607 100644 --- a/src/jmap/shape/StationControl/EArrow.js +++ b/src/jmap/shape/StationControl/EArrow.js @@ -13,8 +13,8 @@ class ESigAuto extends Group { const model = this.model; const style = this.model.style; const rotation = model.drict != 1? 0 : Math.PI; - const x = model.x + model.drict * (model.count * style.Signal.signalR + style.Signal.signalLampStandardWidth) * 2; - const y = model.y - style.Signal.signalLampStandardWidth; + const x = model.x + model.drict * (model.count * style.Signal.lamp.signalR + style.Signal.post.signalLampStandardWidth) * 2; + const y = model.y - style.Signal.post.signalLampStandardWidth; this.arrows = new Polygon({ zlevel: model.zlevel, diff --git a/src/jmap/theme/fuzhou.js b/src/jmap/theme/fuzhou.js index acca5e351..81f44a016 100644 --- a/src/jmap/theme/fuzhou.js +++ b/src/jmap/theme/fuzhou.js @@ -76,58 +76,82 @@ class Fuzhou extends defaultSkin { sectionAxleFailure: '#E6A23C' // #FFFF00 计轴失效 }; this[deviceType.Signal] = { - /** 信号机宽度 */ - signalR: 5, - /** 自动信号宽度*/ - signalSigPassWidth: 6, - /** 延迟解锁字体大小*/ - signalDelayTextFontSize: 9, - /** 信号机名称字体大小*/ - signalTextFontSize: 12, - /** 灯柱宽度*/ - signalLampStandardWidth: 1.2, /** 设备距离区段的距离*/ - signalDistance: 3, - /** 信号灯按钮距离区段的距离*/ - signalButtonDistance: 5, - /** 自动进路方向*/ - signalSigRouteDirection: false, - /** 自动进路偏移量*/ - signalSigRouteOffset: { x: -4, y: -2 }, - /** 自动通过方向*/ - signalSigPassDirection: false, - /** 自动通过偏移量*/ - signalSigPassOffset: { x: -12, y: 0}, - /** 延时解锁方向*/ - signalSigDelayDirection: true, - /** 延时解锁偏移量*/ - signalSigDelayOffset: { x: 15, y: -10}, - /** 信号灯按钮边线*/ - signalButtonDashColor: '#FFFFFF', - /** 信号灯按钮颜色*/ - signalButtonColor: 'darkgreen', - /** 信号灯按钮闪烁颜色*/ - signalButtonLightenColor: '#E4EF50', - /** 信号灯字体颜色*/ - signalTextRed: '#EF0C08', - /** 信号机字体绿色*/ - signalTextGreen: '#4DD43F', - /** 信号灯灯柱颜色*/ - signalLampStandardColor: '#3149C3', - /** 信号灯锁闭*/ - signalBlockColor: '#EF0C08', - /** 信号灯灰色*/ - signalLampGrayColor: '#7F7F7F', - /** 信号灯红色*/ - signalLampRedColor: '#FF0000', - /** 信号灯绿色*/ - signalLampGreenColor: '#00FF00', - /** 信号灯黄色*/ - signalLampYellowColor: '#FFFF00', - /** 信号灯白色*/ - signalLampWhiteColor: '#FFFFFF', - /** 信号灯蓝色*/ - signalLampBlueColor: '#0070C0' + signalDistance: 10, + post: { + signalLampStandardColor: '#3149C3', + signalLampStandardWidth: 2 + }, + text: { + /** 信号机名称字体大小*/ + signalTextFontSize: 8, + /** 信号灯字体颜色*/ + signalTextRed: '#EF0C08', + /** 信号机字体绿色*/ + signalTextGreen: '#4DD43F' + }, + lamp: { + /** 禁止线宽度*/ + signalStopWidth: 2, + /** 信号灯边框线宽度*/ + signalBorderWidth: 0.5, + /** 信号灯边框线颜色*/ + signalBorderColor: '#3149C3', + /** 信号灯半径*/ + signalR: 6, + /** 信号灯锁闭*/ + signalBlockColor: '#EF0C08', + /** 信号灯灰色*/ + signalLampGrayColor: '#7F7F7F', + /** 信号灯红色*/ + signalLampRedColor: '#FF0000', + /** 信号灯绿色*/ + signalLampGreenColor: '#00FF00', + /** 信号灯黄色*/ + signalLampYellowColor: '#FFFF00', + /** 信号灯白色*/ + signalLampWhiteColor: '#FFFFFF', + /** 信号灯蓝色*/ + signalLampBlueColor: '#0070C0' + }, + route: { + /** 自动进路方向*/ + signalRouteDirection: false, + /** 自动进路偏移量*/ + signalRouteOffset: { x: -4, y: 0 }, + /** 自动进路*/ + signalRouteColor: '#00FF00' + }, + auto: { + /** 自动通过方向*/ + signalAutoDirection: false, + /** 自动通过偏移量*/ + signalAutoOffset: { x: -4, y: 0}, + /** 自动进路*/ + signalAutoRoute: '#00FF00', + /** 自动触发*/ + signalAutoTrigger: '#FFFF00' + }, + delay: { + /** 延迟解锁字体大小*/ + signalDelayTextFontSize: 9, + /** 延时解锁方向*/ + signalDelayDirection: true, + /** 延时解锁偏移量*/ + signalDelayOffset: { x: 15, y: -10}, + /** 延迟解锁颜色*/ + signalDelayTextColor: '#FF0000' + }, + button: { + /** 信号灯按钮距离区段的距离*/ + signalButtonDistance: 5, + /** 信号灯按钮边线*/ + signalButtonDashColor: '#FFFFFF', + /** 信号灯按钮颜色*/ + signalButtonColor: 'darkgreen', + /** 信号灯按钮闪烁颜色*/ + signalButtonLightenColor: '#E4EF50' + } }; this[deviceType.StationStand] = { /** 站台和屏蔽门之间的距离*/ From b9132cb29f989ed446ab280219f019db1abbba14 Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Tue, 23 Jul 2019 18:22:05 +0800 Subject: [PATCH 07/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/shape/Signal/ESigAuto.js | 66 +++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/jmap/shape/Signal/ESigAuto.js diff --git a/src/jmap/shape/Signal/ESigAuto.js b/src/jmap/shape/Signal/ESigAuto.js new file mode 100644 index 000000000..d1bfd916c --- /dev/null +++ b/src/jmap/shape/Signal/ESigAuto.js @@ -0,0 +1,66 @@ +import Polygon from 'zrender/src/graphic/shape/Polygon'; +import Group from 'zrender/src/container/Group'; +import { arrows } from '../utils/ShapePoints'; + +class ESigPass extends Group { + constructor(model) { + super(); + this.model = model; + this._create(); + } + + _create() { + const model = this.model; + const style = this.model.style; + const rotation = model.drict != 1? 0 : Math.PI; + const point = arrows(model.x, model.y, style.Signal.signalSigPassWidth, style.Signal.lamp.signalR * 0.8); + this.arrows = new Polygon({ + zlevel: model.zlevel, + z: model.z, + rotation: rotation, + shape: { + points: point + }, + style: { + stroke: model.stroke, + lineWidth: model.lineWidth, + fill: model.fill + } + }); + this.add(this.arrows); + } + + // 停止动画 + animationRecover() { + this.arrows.stopAnimation(false); + } + + // 箭头颜色 + setColor(color) { + this.arrows.setStyle('fill', color); + } + + // 箭头闪烁 + arrowsAnimation() { + const style = this.model.style; + const fill = this.arrows.style.Signal.fill; + this.arrows.animate(true) + .when(1000, { fill: style.backgroundColor, stroke: style.style.backgroundColor }) + .when(2000, { fill: fill, stroke: style.style.Signal.sidelineColor }) + .when(3000, { fill: style.style.backgroundColor, stroke: style.style.backgroundColor }) + .when(4000, { fill: fill, stroke: style.style.Signal.sidelineColor }) + .start(); + } + + // 隐藏 + hide() { + this.arrows.hide(); + } + + // 显示 + show() { + this.arrows.show(); + } +} + +export default ESigPass; From a5528542cc8811d51abeb37b0ac555d2ab13eea2 Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Tue, 23 Jul 2019 18:30:08 +0800 Subject: [PATCH 08/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/shape/Signal/ESigButton.js | 25 ----- src/jmap/shape/Signal/SigAuto.js | 27 ----- src/jmap/shape/Signal/SigLamp.js | 36 ------ src/jmap/shape/Signal/SigPost.js | 30 ----- src/jmap/shape/Signal/SigRoute.js | 37 ------ src/jmap/shape/Signal/index.js | 168 +--------------------------- src/jmap/theme/fuzhou.js | 28 ----- 7 files changed, 4 insertions(+), 347 deletions(-) delete mode 100644 src/jmap/shape/Signal/SigAuto.js delete mode 100644 src/jmap/shape/Signal/SigLamp.js delete mode 100644 src/jmap/shape/Signal/SigPost.js delete mode 100644 src/jmap/shape/Signal/SigRoute.js diff --git a/src/jmap/shape/Signal/ESigButton.js b/src/jmap/shape/Signal/ESigButton.js index 2de81627c..a80393e84 100644 --- a/src/jmap/shape/Signal/ESigButton.js +++ b/src/jmap/shape/Signal/ESigButton.js @@ -15,11 +15,7 @@ class ESigButton extends Group { const model = this.model; const style = this.model.style; const padding = 1; -<<<<<<< HEAD - const r = style.Signal.lamp.signalR * 0.8; -======= const r = style.Signal.Lamp.signalR * 0.8; ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 this.style = style; this._subType = 'SignalButton'; @@ -30,17 +26,6 @@ class ESigButton extends Group { _subType: this._subType, _val: '1', shape: { -<<<<<<< HEAD - x: model.x - style.Signal.lamp.signalR, - y: model.y - r + r * model.posit, - width: style.Signal.lamp.signalR * 2, - height: style.Signal.lamp.signalR * 2 - }, - style: { - lineWidth: 0.2, - stroke: style.Signal.button.signalButtonDashColor, - fill: style.Signal.button.signalButtonColor -======= x: model.x - style.Signal.Lamp.signalR, y: model.y - r + r * model.posit, width: style.Signal.Lamp.signalR * 2, @@ -50,7 +35,6 @@ class ESigButton extends Group { lineWidth: 0.2, stroke: style.Signal.Button.signalButtonDashColor, fill: style.Signal.Button.signalButtonColor ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 } }); @@ -62,21 +46,12 @@ class ESigButton extends Group { shape: { cx: model.x, cy: model.y - 5 / 2 * r * model.posit, -<<<<<<< HEAD - r: style.Signal.lamp.signalR - }, - style: { - lineWidth: 0.2, - stroke: style.Signal.button.signalButtonDashColor, - fill: style.Signal.button.signalButtonColor -======= r: style.Signal.Lamp.signalR }, style: { lineWidth: 0.2, stroke: style.Signal.Button.signalButtonDashColor, fill: style.Signal.Button.signalButtonColor ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 } }); diff --git a/src/jmap/shape/Signal/SigAuto.js b/src/jmap/shape/Signal/SigAuto.js deleted file mode 100644 index 7b523eedb..000000000 --- a/src/jmap/shape/Signal/SigAuto.js +++ /dev/null @@ -1,27 +0,0 @@ -import Path from 'zrender/src/graphic/Path'; - -export default Path.extend({ - type: 'SigAuto', - - shape: { - x: 0, // 三角中心x - y: 0, // 三角中心y - r: 0, // 三角形半径 - forward: false // 三角箭头朝向: 左/右 - }, - - style: { - stroke: '#c0c0c0', - lineWidth: 0.5, - fill: null - }, - - buildPath: function (ctx, shape) { - const r = shape.forward ? shape.r : -shape.r; - ctx.moveTo(shape.x, shape.y); - ctx.lineTo(shape.x + r, shape.y - shape.r); - ctx.lineTo(shape.x + r, shape.y + shape.r); - ctx.closePath(); - ctx.fill(); - } -}); diff --git a/src/jmap/shape/Signal/SigLamp.js b/src/jmap/shape/Signal/SigLamp.js deleted file mode 100644 index 7955bebd4..000000000 --- a/src/jmap/shape/Signal/SigLamp.js +++ /dev/null @@ -1,36 +0,0 @@ -import Path from 'zrender/src/graphic/Path'; - -export default Path.extend({ - type: 'SigLmap', - - shape: { - x: 0, // 圆心x - y: 0, // 圆心y - r: 5, // 圆半径 - signalStopWidth: 2, // 圆心禁止线宽度 - isStop: true // 圆心叉是否存在 - }, - - style: { - stroke: '#c0c0c0', - lineWidth: 0.5, - fill: null - }, - - buildPath: function (ctx, shape) { - // ctx.strokeStyle = this.style.stroke; - // ctx.lineWidth = this.style.lineWidth; - // ctx.fillStyle = this.style.fill; - ctx.arc(shape.x, shape.y, shape.r, 0, Math.PI * 2, true); - - if (!shape.isStop) { - // ctx.beginPath(); - // ctx.strokeStyle = '#000'; - // ctx.lineWidth = shape.signalStopWidth; - ctx.moveTo(shape.x - shape.r * Math.cos(Math.PI / 4), shape.y - shape.r * Math.sin(Math.PI / 4)); - ctx.lineTo(shape.x + shape.r * Math.cos(Math.PI / 4), shape.y + shape.r * Math.sin(Math.PI / 4)); - ctx.moveTo(shape.x + shape.r * Math.cos(Math.PI / 4), shape.y - shape.r * Math.sin(Math.PI / 4)); - ctx.lineTo(shape.x - shape.r * Math.cos(Math.PI / 4), shape.y + shape.r * Math.sin(Math.PI / 4)); - } - } -}); diff --git a/src/jmap/shape/Signal/SigPost.js b/src/jmap/shape/Signal/SigPost.js deleted file mode 100644 index 5b4847084..000000000 --- a/src/jmap/shape/Signal/SigPost.js +++ /dev/null @@ -1,30 +0,0 @@ -import Path from 'zrender/src/graphic/Path'; - -export default Path.extend({ - type: 'SigPost', - - shape: { - x: 0, // 灯柱高柱中心x - y: 0, // 灯柱高柱中心y - h: 10, // 灯柱高柱长度 - w: 5, // 灯珠矮柱宽度 - isDwarf: false, // 是否是矮柱 - forward: true // 灯柱朝向 - }, - - style: { - stroke: '#000', - lineWidth: 1 - }, - - buildPath: function (ctx, shape) { - const w = shape.forward ? -shape.w : shape.w; - const r = shape.h / 2; - ctx.moveTo(shape.x, shape.y - r); - ctx.lineTo(shape.x, shape.y + r); - if (shape.isDwarf) { - ctx.moveTo(shape.x, shape.y); - ctx.lineTo(shape.x + w, shape.y); - } - } -}); diff --git a/src/jmap/shape/Signal/SigRoute.js b/src/jmap/shape/Signal/SigRoute.js deleted file mode 100644 index 8c39a9c28..000000000 --- a/src/jmap/shape/Signal/SigRoute.js +++ /dev/null @@ -1,37 +0,0 @@ -import Path from 'zrender/src/graphic/Path'; - -export default Path.extend({ - type: 'SigRoute', - - shape: { - x: 0, - y: 0, - h: 4, - w: 4, - l: 10, - d: 2, - forward: false - }, - - style: { - stroke: '#c0c0c0', - lineWidth: 0.5, - fill: null - }, - - buildPath: function (ctx, shape) { - const l = shape.forward ? shape.l : -shape.l; - const w = shape.forward ? shape.w : -shape.w; - - ctx.moveTo(shape.x, shape.y); - ctx.lineTo(shape.x + w, shape.y - shape.h); - ctx.lineTo(shape.x + w, shape.y - shape.h + shape.d); - ctx.lineTo(shape.x + w + l, shape.y - shape.h + shape.d); - ctx.lineTo(shape.x + w + l, shape.y + shape.h - shape.d); - ctx.lineTo(shape.x + w, shape.y + shape.h - shape.d); - ctx.lineTo(shape.x + w, shape.y + shape.h); - - ctx.closePath(); - ctx.fill(); - } -}); diff --git a/src/jmap/shape/Signal/index.js b/src/jmap/shape/Signal/index.js index 8cfcb7d5b..164b2d5f9 100644 --- a/src/jmap/shape/Signal/index.js +++ b/src/jmap/shape/Signal/index.js @@ -2,19 +2,12 @@ * 信号机 */ -<<<<<<< HEAD import ESigPost from './ESigPost'; -import ESigLmap from './ESigLmap'; +import ESigLamp from './ESigLamp'; import ESigAuto from './ESigAuto'; import ESigRoute from './ESigRoute'; -======= -import SigPost from './SigPost'; -import SigLamp from './SigLamp'; -import SigAuto from './SigAuto'; -import SigRoute from './SigRoute'; ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 import ESigButton from './ESigButton'; -import Text from 'zrender/src/graphic/Text'; +import ESigName from './ESigName'; import Group from 'zrender/src/container/Group'; class Signal extends Group { @@ -41,30 +34,14 @@ class Signal extends Group { const posit = this.model.positionType == '01' ? -1 : 1; // 位置 上:下 // 信号机高柱矮柱 - this.sigPost = new SigPost({ + this.sigPost = new ESigPost({ zlevel: this.zlevel, -<<<<<<< HEAD z: this.z, style: style, drict: drict, type: model.lampPostType, x: model.position.x, y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.lamp.signalR) -======= - z: this.z + 1, - shape: { - x: model.position.x, - y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.Lamp.signalR), - h: style.Signal.Lamp.signalR * 2, - w: style.Signal.Lamp.signalR, - isDwarf: model.lampPositionType == '02', - forward: model.directionType == '01' - }, - style: { - stroke: style.Signal.Post.signalLampStandardColor, - lineWidth: style.Signal.Post.signalLampStandardWidth - } ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 }); const endPoint = { @@ -75,10 +52,9 @@ class Signal extends Group { // 信号灯 this.lamps = []; for (let i = 0; i < this.count; i++) { - const lamp = new SigLamp({ + const lamp = new ESigLamp({ zlevel: this.zlevel, z: this.z, -<<<<<<< HEAD style: style, index: i + 1, drict: drict, @@ -86,20 +62,6 @@ class Signal extends Group { y: endPoint.y, originX: model.position.x, originY: model.position.y -======= - shape: { - x: endPoint.x + i * drict * (style.Signal.Lamp.signalR * 2 + style.Signal.Lamp.signalBorderWidth), - y: endPoint.y, - r: style.Signal.Lamp.signalR, - signalStopWidth: style.Signal.Lamp.signalStopWidth, - isStop: false - }, - style: { - stroke: style.Signal.Lamp.signalBorderColor, - lineWidth: style.Signal.Lamp.signalBorderWidth, - fill: style.Signal.Lamp.signalLampGrayColor - } ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 }); this.lamps.push(lamp); @@ -107,7 +69,6 @@ class Signal extends Group { // 信号机名称 const sigNameX = model.position.x + model.namePosition.x; -<<<<<<< HEAD const sigNameY = model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.lamp.signalR * 2 + model.namePosition.y); this.sigName = new ESigName({ zlevel: this.zlevel, @@ -128,30 +89,6 @@ class Signal extends Group { const sigRouteX = endPoint.x + (style.Signal.route.signalRouteOffset.x + sigRouteH) * drict; const sigRouteY = endPoint.y + (style.Signal.route.signalRouteOffset.y); this.sigRoute = new ESigRoute({ -======= - const sigNameY = model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.Lamp.signalR * 2 + model.namePosition.y); - this.sigName = new Text({ - zlevel: this.zlevel, - z: this.z, - silent: false, - style: { - x: sigNameX, - y: sigNameY, - text: model.name, - textFont: `bold ${style.Signal.Text.signalTextFontSize} px ${style.textFontFormat}`, - textFill: style.Signal.Text.signalTextGreen, - textAlign: 'middle', - textPosition: model.textPosition || 'inside', - textVerticalAlign: posit == 1 ? 'top' : 'bottom' - } - }); - - // 自动进路 - const sigRouteH = style.Signal.Route.signalRouteDirection ? this.count * style.Signal.Lamp.signalR * 2 : -style.Signal.Lamp.signalR * 2; - const sigRouteX = endPoint.x + (style.Signal.Route.signalRouteOffset.x + sigRouteH) * drict; - const sigRouteY = endPoint.y + (style.Signal.Route.signalRouteOffset.y); - this.sigRoute = new SigRoute({ ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 zlevel: this.zlevel, z: this.z, shape: { @@ -165,7 +102,6 @@ class Signal extends Group { }); // 自动通过 -<<<<<<< HEAD const sigAutoH = style.Signal.auto.signalAutoDirection ? this.count * style.Signal.lamp.signalR * 2 : -style.Signal.lamp.signalR * 2; const sigAutoX = endPoint.x + (style.Signal.auto.signalAutoOffset.x + sigAutoH) * drict; const sigAutoY = endPoint.y + (style.Signal.auto.signalAutoOffset.y); @@ -198,43 +134,6 @@ class Signal extends Group { textFill: style.Signal.delay.signalDelayTextColor, textAlign: drict > 0 ? 'right' : 'left', textVerticalAlign: 'middle' -======= - const sigAutoH = style.Signal.Auto.signalAutoDirection ? this.count * style.Signal.Lamp.signalR * 2 : -style.Signal.Lamp.signalR * 2; - const sigAutoX = endPoint.x + (style.Signal.Auto.signalAutoOffset.x + sigAutoH) * drict; - const sigAutoY = endPoint.y + (style.Signal.Auto.signalAutoOffset.y); - this.sigAuto = new SigAuto({ - zlevel: this.zlevel, - z: this.z, - shape: { - x: sigAutoX, - y: sigAutoY, - r: style.Signal.Lamp.signalR, - forward: model.directionType == '01' - }, - style: { - fill: style.Signal.Auto.signalAutoColor - } - }); - - // 延迟解锁 - const sigDelayH = style.Signal.Delay.signalDelayDirection ? this.count * style.Signal.Lamp.signalR * 2 : -style.Signal.Lamp.signalR * 2; - const sigDelayX = endPoint.x + (style.Signal.Delay.signalDelayOffset.x + sigDelayH) * drict; - const sigDelayY = endPoint.y - (style.Signal.Delay.signalDelayOffset.y) * posit; - this.sigDelay = new Text({ - zlevel: this.zlevel, - z: this.z, - silent: false, - style: { - x: sigDelayX, - y: sigDelayY, - text: this.state.delayCount || '0', - textFont: `bold ${style.Signal.Delay.signalDelayTextFontSize} px ${style.textFontFormat}`, - textFill: style.Signal.Delay.signalDelayTextColor, - textAlign: drict > 0 ? 'right' : 'left', - textPosition: model.textPosition || 'inside', - textVerticalAlign: 'middle' - } ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 }); // 信号灯按钮 @@ -245,20 +144,13 @@ class Signal extends Group { posit: posit, show: model.buttonShow, x: model.buttonPosition.x, -<<<<<<< HEAD y: model.buttonPosition.y - posit * (style.Signal.button.signalButtonDistance + style.Signal.lamp.signalR * 2) -======= - y: model.buttonPosition.y - posit * (style.Signal.Button.signalButtonDistance + style.Signal.Lamp.signalR * 2) ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 }); this.add(this.sigPost); this.lamps.forEach(lamp => { this.add(lamp); }); this.add(this.sigName); -<<<<<<< HEAD this.add(this.sigAuto); -======= ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 this.add(this.sigRoute); this.add(this.sigAuto); this.add(this.sigDelay); @@ -285,21 +177,13 @@ class Signal extends Group { if (this.count === 1) { if (this.model.useType === '05') { /** 单灯 调车信号机*/ -<<<<<<< HEAD this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampBlueColor); -======= - this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampBlueColor); ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 } else { /** 单灯 出站信号机 */ /** 单灯 阻挡信号机*/ /** 单灯 阻挡兼调车信号 */ /** 单灯 列兼调信号机 */ -<<<<<<< HEAD this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampRedColor); -======= - this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampRedColor); ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 } } } @@ -309,11 +193,7 @@ class Signal extends Group { if (this.count === 1) { /** 单灯 出站信号机*/ /** 单灯 阻隔信号机*/ -<<<<<<< HEAD this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampGreenColor); -======= - this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampGreenColor); ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 } } @@ -321,11 +201,7 @@ class Signal extends Group { trainRoute() { if (this.count === 1) { /** 单灯 列兼调信号*/ -<<<<<<< HEAD this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampYellowColor); -======= - this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampYellowColor); ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 } } @@ -334,11 +210,7 @@ class Signal extends Group { if (this.count === 1) { /** 单灯 列兼调信号*/ /** 单灯 阻挡兼调车信号*/ -<<<<<<< HEAD this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampWhiteColor); -======= - this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampWhiteColor); ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 } } @@ -349,13 +221,8 @@ class Signal extends Group { // 封锁 block() { -<<<<<<< HEAD this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampRedColor); this.sigName.setColor(this.style.Signal.sectionBlockTextColor); -======= - this.lamps[0] && this.lamps[0].setStyle('fill', this.style.Signal.Lamp.signalLampRedColor); - this.sigName.setStyle('textFill', this.style.Signal.Text.signalTextRed); ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 } // 功能封锁 @@ -390,11 +257,7 @@ class Signal extends Group { } this.recover(); -<<<<<<< HEAD this.sigAuto.setColor(this.style.Signal.auto.signalAutoRoute); -======= - this.sigAuto.setStyle('fill', this.style.Signal.signalAutoRoute); ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 } // 信号机进路自动触发模式状态类型 @@ -406,11 +269,7 @@ class Signal extends Group { } this.recover(); -<<<<<<< HEAD this.sigAuto.setColor(this.style.Signal.auto.signalAutoTrigger); -======= - this.sigAuto.setStyle('fill', this.style.Signal.signalAutoTrigger); ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 } // 设置自动信号模式状态类型 @@ -420,29 +279,15 @@ class Signal extends Group { // 隐藏自动信号和自动进路 setAutoClose() { -<<<<<<< HEAD this.sigAuto.hide(); this.sigAuto.setColor(this.style.backgroundColor); -======= ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 this.sigRoute.hide(); this.sigAuto.hide(); } // 自动信号和自动进路开始动画 setAutoFlicker() { -<<<<<<< HEAD this.sigAuto.arrowsAnimation(); -======= - const style = this.model.style; - const fill = this.sigAuto.style.Signal.fill; - this.sigAuto.animate(true) - .when(1000, { fill: style.backgroundColor, stroke: style.style.backgroundColor }) - .when(2000, { fill: fill, stroke: style.style.Signal.sidelineColor }) - .when(3000, { fill: style.style.backgroundColor, stroke: style.style.backgroundColor }) - .when(4000, { fill: fill, stroke: style.style.Signal.sidelineColor }) - .start(); ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 } // 设置延时解锁 @@ -453,13 +298,8 @@ class Signal extends Group { // 恢复状态 recover() { this.sigDelay.hide(); -<<<<<<< HEAD this.sigAuto.animationRecover(); this.sigName.setColor(this.style.Signal.text.signalTextGreen); -======= - this.sigAuto.stopAnimation(false); - this.sigName.setStyle('textFill', this.style.Signal.Text.signalTextGreen); ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 } setState(state) { diff --git a/src/jmap/theme/fuzhou.js b/src/jmap/theme/fuzhou.js index 759717eb9..e1e7e36ee 100644 --- a/src/jmap/theme/fuzhou.js +++ b/src/jmap/theme/fuzhou.js @@ -66,19 +66,11 @@ class Fuzhou extends defaultSkin { this[deviceType.Signal] = { /** 设备距离区段的距离*/ signalDistance: 10, -<<<<<<< HEAD - post: { - signalLampStandardColor: '#3149C3', - signalLampStandardWidth: 2 - }, - text: { -======= Post: { signalLampStandardColor: '#3149C3', signalLampStandardWidth: 2 }, Text: { ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 /** 信号机名称字体大小*/ signalTextFontSize: 8, /** 信号灯字体颜色*/ @@ -86,11 +78,7 @@ class Fuzhou extends defaultSkin { /** 信号机字体绿色*/ signalTextGreen: '#4DD43F' }, -<<<<<<< HEAD - lamp: { -======= Lamp: { ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 /** 禁止线宽度*/ signalStopWidth: 2, /** 信号灯边框线宽度*/ @@ -114,11 +102,7 @@ class Fuzhou extends defaultSkin { /** 信号灯蓝色*/ signalLampBlueColor: '#0070C0' }, -<<<<<<< HEAD route: { -======= - Route: { ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 /** 自动进路方向*/ signalRouteDirection: false, /** 自动进路偏移量*/ @@ -126,11 +110,7 @@ class Fuzhou extends defaultSkin { /** 自动进路*/ signalRouteColor: '#00FF00' }, -<<<<<<< HEAD auto: { -======= - Auto: { ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 /** 自动通过方向*/ signalAutoDirection: false, /** 自动通过偏移量*/ @@ -140,11 +120,7 @@ class Fuzhou extends defaultSkin { /** 自动触发*/ signalAutoTrigger: '#FFFF00' }, -<<<<<<< HEAD delay: { -======= - Delay: { ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 /** 延迟解锁字体大小*/ signalDelayTextFontSize: 9, /** 延时解锁方向*/ @@ -154,11 +130,7 @@ class Fuzhou extends defaultSkin { /** 延迟解锁颜色*/ signalDelayTextColor: '#FF0000' }, -<<<<<<< HEAD button: { -======= - Button: { ->>>>>>> b938022cbffc1b6cf6ee66a34bfe23ec12025e77 /** 信号灯按钮距离区段的距离*/ signalButtonDistance: 5, /** 信号灯按钮边线*/ From d26085b8a5a946d84d901140cb2eeb01e16f5047 Mon Sep 17 00:00:00 2001 From: zyy <1787816799@qq.com> Date: Tue, 23 Jul 2019 18:33:30 +0800 Subject: [PATCH 09/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/shape/Section/ELimitLines.js | 321 ++++++++++++++------------ src/jmap/shape/Section/index.js | 78 ++++--- src/jmap/shape/Signal/index.js | 6 +- 3 files changed, 217 insertions(+), 188 deletions(-) diff --git a/src/jmap/shape/Section/ELimitLines.js b/src/jmap/shape/Section/ELimitLines.js index 1379456c1..d46dc9839 100644 --- a/src/jmap/shape/Section/ELimitLines.js +++ b/src/jmap/shape/Section/ELimitLines.js @@ -1,36 +1,118 @@ -// import Group from 'zrender/src/container/Group'; -// import BezierCurve from 'zrender/src/graphic/shape/BezierCurve'; -// import Line from 'zrender/src/graphic/shape/Line'; +import Group from 'zrender/src/container/Group'; +import BezierCurve from 'zrender/src/graphic/shape/BezierCurve'; +import Line from 'zrender/src/graphic/shape/Line'; import JTriangle from '../../utils/JTriangle'; -import Path from 'zrender/src/graphic/Path'; +// import Path from 'zrender/src/graphic/Path'; // 创建区段限速限集合 -export const ELimitLines = Path.extend({ - type: 'ELimitLines', - shape: { - points: null - }, - buildPath: function (ctx, model) { +// export const ELimitLines = Path.extend({ +// type: 'ELimitLines', +// shape: { +// points: null +// }, +// buildPath: function (ctx, model) { +// /** 创建区段*/ +// if (model && model.points.length > 1) { +// if (model.isCurve) { +// ctx.beginPath(); +// const shape = {}; +// for (let i = 1; i < (model.points.length - 1); i++) { +// shape[`cpx${i}`] = model.points[i].x; +// shape[`cpy${i}`] = model.points[i].y; +// } +// shape[`x1`] = model.points[0].x; +// shape[`y1`] = model.points[0].y; +// shape[`x2`] = model.points[model.points.length - 1].x; +// shape[`y2`] = model.points[model.points.length - 1].y; + +// ctx.moveTo(shape[`x1`], shape[`y1`]); +// if (model.points.length <= 3) { +// ctx.quadraticCurveTo(shape[`cpx1`], shape[`cpy1`], shape[`x2`], shape[`y2`]); +// } else { +// ctx.bezierCurveTo(shape[`cpx1`], shape[`cpy1`], shape[`cpx2`], shape[`cpy2`], shape[`x2`], shape[`y2`]); +// } +// } else { +// const swPadding = model.style.Switch.switchLen; // 定位和反位时区段距离岔芯的距离 +// var switchWidth = model.style.Section.line.width + model.style.Section.line.beyondWidth; // 道岔宽度 +// const beg = Object.assign({}, model.points[0]); +// const end = Object.assign({}, model.points[model.points.length - 1]); +// if (model.isSwitchSection && beg.y !== end.y) { +// const swch = model.switch; +// if (swch) { +// const traingle = new JTriangle(swch.intersection, swch.skew); +// if ((swch.intersection.x === beg.x) && (swch.intersection.y === beg.y)) { +// beg.x = beg.x + traingle.drictx * (swPadding + switchWidth) * traingle.getCotRate(); +// beg.y = beg.y + traingle.dricty * (swPadding + switchWidth); +// } + +// if ((swch.intersection.x === end.x) && (swch.intersection.y === end.y)) { +// end.x = end.x + traingle.drictx * (swPadding + switchWidth) * traingle.getCotRate(); +// end.y = end.y + traingle.dricty * (swPadding + switchWidth); +// } +// } +// } + +// if (model.points.length == 2) { +// ctx.moveTo(beg.x, beg.y); +// ctx.lineTo(end.x, end.y); +// ctx.closePath(); +// } else { +// ctx.moveTo(beg.x, beg.y); +// ctx.lineTo(model.points[1].x, model.points[1].y); +// ctx.closePath(); + +// for (let i = 1; i < (model.points.length - 2); i++) { +// ctx.moveTo(model.points[i].x, model.points[i].y); +// ctx.lineTo(model.points[i + 1].x, model.points[i + 1].y); +// ctx.closePath(); +// } +// ctx.moveTo(model.points[model.points.length - 2].x, model.points[model.points.length - 2].y); +// ctx.lineTo(end.x, end.y); +// ctx.closePath(); +// } +// } +// } +// } +// }); + +export default class ELimitLines extends Group { + constructor(model) { + super(); + this.model = model; + this.zlevel = model.zlevel; + this.z = model.z; + this._create(model); + } + + _create(model) { /** 创建区段*/ if (model && model.points.length > 1) { if (model.isCurve) { - ctx.beginPath(); const shape = {}; for (let i = 1; i < (model.points.length - 1); i++) { shape[`cpx${i}`] = model.points[i].x; shape[`cpy${i}`] = model.points[i].y; } + shape[`x1`] = model.points[0].x; shape[`y1`] = model.points[0].y; shape[`x2`] = model.points[model.points.length - 1].x; shape[`y2`] = model.points[model.points.length - 1].y; - ctx.moveTo(shape[`x1`], shape[`y1`]); - if (model.points.length <= 3) { - ctx.quadraticCurveTo(shape[`cpx1`], shape[`cpy1`], shape[`x2`], shape[`y2`]); - } else { - ctx.bezierCurveTo(shape[`cpx1`], shape[`cpy1`], shape[`cpx2`], shape[`cpy2`], shape[`x2`], shape[`y2`]); - } + this.add(new BezierCurve({ + isLine: true, + zlevel: this.zlevel, + progressive: model.progressive, + z: this.z, + culling: true, + shape: shape, + position: model.position, + style: { + lineWidth: model.style.Section.speedLimit.width, + stroke: model.style.Section.speedLimit.lineColor, + fillOpacity: 0 + } + })); } else { const swPadding = model.style.Switch.switchLen; // 定位和反位时区段距离岔芯的距离 var switchWidth = model.style.Section.line.width + model.style.Section.line.beyondWidth; // 道岔宽度 @@ -53,146 +135,81 @@ export const ELimitLines = Path.extend({ } if (model.points.length == 2) { - ctx.moveTo(beg.x, beg.y); - ctx.lineTo(end.x, end.y); - ctx.closePath(); + this.add(new Line({ + isLine: true, + zlevel: this.zlevel, + progressive: model.progressive, + z: this.z, + position: model.position, + shape: { + x1: beg.x, + y1: beg.y, + x2: end.x, + y2: end.y + }, + style: { + lineWidth: model.style.Section.speedLimit.width, + stroke: model.style.Section.speedLimit.lineColor + } + })); } else { - ctx.moveTo(beg.x, beg.y); - ctx.lineTo(model.points[1].x, model.points[1].y); - ctx.closePath(); + this.add(new Line({ + isLine: true, + zlevel: this.zlevel, + progressive: model.progressive, + z: this.z, + position: model.position, + shape: { + x1: beg.x, + y1: beg.y, + x2: model.points[1].x, + y2: model.points[1].y + }, + style: { + lineWidth: model.style.Section.speedLimit.width, + stroke: model.style.Section.speedLimit.lineColor + } + })); for (let i = 1; i < (model.points.length - 2); i++) { - ctx.moveTo(model.points[i].x, model.points[i].y); - ctx.lineTo(model.points[i + 1].x, model.points[i + 1].y); - ctx.closePath(); + this.add(new Line({ + isLine: true, + zlevel: this.zlevel, + z: this.z, + progressive: model.progressive, + position: model.position, + shape: { + x1: model.points[i].x, + y1: model.points[i].y, + x2: model.points[i + 1].x, + y2: model.points[i + 1].y + }, + style: { + lineWidth: model.style.Section.speedLimit.width, + stroke: model.style.Section.speedLimit.lineColor + } + })); } - ctx.moveTo(model.points[model.points.length - 2].x, model.points[model.points.length - 2].y); - ctx.lineTo(end.x, end.y); - ctx.closePath(); + + this.add(new Line({ + isLine: true, + zlevel: this.zlevel, + z: this.z, + position: model.position, + progressive: model.progressive, + shape: { + x1: model.points[model.points.length - 2].x, + y1: model.points[model.points.length - 2].y, + x2: end.x, + y2: end.y + }, + style: { + lineWidth: model.style.Section.speedLimit.width, + stroke: model.style.Section.speedLimit.lineColor + } + })); } } } } -}); - -// export default class ELimitLines extends Group { -// constructor(model) { -// super(); -// this.model = model; -// this.zlevel = model.zlevel; -// this.z = model.z; -// this._create(model); -// } - -// _create(model) { -// /** 创建区段*/ -// if (model && model.points.length > 1) { -// if (model.isCurve) { -// const shape = {}; -// for (let i = 1; i < (model.points.length - 1); i++) { -// shape[`cpx${i}`] = model.points[i].x; -// shape[`cpy${i}`] = model.points[i].y; -// } - -// shape[`x1`] = model.points[0].x; -// shape[`y1`] = model.points[0].y; -// shape[`x2`] = model.points[model.points.length - 1].x; -// shape[`y2`] = model.points[model.points.length - 1].y; - -// this.add(new BezierCurve({ -// isLine: true, -// zlevel: this.zlevel, -// progressive: model.progressive, -// z: this.z, -// culling: true, -// shape: shape, -// position: model.position, -// style: { -// lineWidth: model.style.Section.speedLimit.width, -// stroke: model.style.Section.speedLimit.lineColor, -// fillOpacity: 0 -// } -// })); -// } else { -// const beg = Object.assign({}, model.points[0]); -// const end = Object.assign({}, model.points[model.points.length - 1]); - -// if (model.points.length == 2) { -// this.add(new Line({ -// isLine: true, -// zlevel: this.zlevel, -// progressive: model.progressive, -// z: this.z, -// position: model.position, -// shape: { -// x1: beg.x, -// y1: beg.y, -// x2: end.x, -// y2: end.y -// }, -// style: { -// lineWidth: model.style.Section.speedLimit.width, -// stroke: model.style.Section.speedLimit.lineColor -// } -// })); -// } else { -// this.add(new Line({ -// isLine: true, -// zlevel: this.zlevel, -// progressive: model.progressive, -// z: this.z, -// position: model.position, -// shape: { -// x1: beg.x, -// y1: beg.y, -// x2: model.points[1].x, -// y2: model.points[1].y -// }, -// style: { -// lineWidth: model.style.Section.speedLimit.width, -// stroke: model.style.Section.speedLimit.lineColor -// } -// })); - -// for (let i = 1; i < (model.points.length - 2); i++) { -// this.add(new Line({ -// isLine: true, -// zlevel: this.zlevel, -// z: this.z, -// progressive: model.progressive, -// position: model.position, -// shape: { -// x1: model.points[i].x, -// y1: model.points[i].y, -// x2: model.points[i + 1].x, -// y2: model.points[i + 1].y -// }, -// style: { -// lineWidth: model.style.Section.speedLimit.width, -// stroke: model.style.Section.speedLimit.lineColor -// } -// })); -// } - -// this.add(new Line({ -// isLine: true, -// zlevel: this.zlevel, -// z: this.z, -// position: model.position, -// progressive: model.progressive, -// shape: { -// x1: model.points[model.points.length - 2].x, -// y1: model.points[model.points.length - 2].y, -// x2: end.x, -// y2: end.y -// }, -// style: { -// lineWidth: model.style.Section.speedLimit.width, -// stroke: model.style.Section.speedLimit.lineColor -// } -// })); -// } -// } -// } -// } -// } +} diff --git a/src/jmap/shape/Section/index.js b/src/jmap/shape/Section/index.js index 8ed6ce38a..53337c884 100644 --- a/src/jmap/shape/Section/index.js +++ b/src/jmap/shape/Section/index.js @@ -1,7 +1,7 @@ import Group from 'zrender/src/container/Group'; import ETextName from '../element/ETextName'; // 名称文字 (共有) import ERelease from './ERelease'; // 线段 (共有) -import { ELimitLines } from './ELimitLines'; // 区段限速 (私有) +import ELimitLines from './ELimitLines'; // 区段限速 (私有) import ELines from './ELines'; // 创建多线条 曲线 (私有) import ESeparator from './ESeparator'; // 分隔符 (私有) import { EAxle } from './EAxle'; // 创建计轴 (私有) @@ -81,44 +81,56 @@ export default class Section extends Group { // 创建限速线 this.speedLimitLeft = new ELimitLines({ zlevel: this.zlevel, - z: model.isCurve ? this.z - 1 : this.z, + z: this.z, progressive: 5, position: [x, -y], - isLine: true, - culling: model.isCurve, // 是否裁剪 - shape: { - points: model.points, - isCurve: model.isCurve, // 是否曲线 - isSwitchSection: model.isSwitchSection, - relSwitchCode: model.relSwitchCode, - switch: model.switch, - style: style - }, - style: { - lineWidth: style.Section.speedLimit.width, - stroke: style.Section.speedLimit.lineColor - } + style: style, + points: model.points, + isCurve: model.isCurve, // 是否曲线 + isSwitchSection: model.isSwitchSection, + relSwitchCode: model.relSwitchCodes, + switch: model.switch + // isLine: true, + // culling: model.isCurve, // 是否裁剪 + // shape: { + // points: model.points, + // isCurve: model.isCurve, // 是否曲线 + // isSwitchSection: model.isSwitchSection, + // relSwitchCode: model.relSwitchCode, + // switch: model.switch, + // style: style + // }, + // style: { + // lineWidth: style.Section.speedLimit.width, + // stroke: style.Section.speedLimit.lineColor + // } }); this.speedLimitRight = new ELimitLines({ + style: style, zlevel: this.zlevel, - z: model.isCurve ? this.z - 1 : this.z, + z: this.z, progressive: 5, position: [x, -y], - isLine: true, - culling: model.isCurve, // 是否裁剪 - shape: { - points: model.points, - isCurve: model.isCurve, // 是否曲线 - isSwitchSection: model.isSwitchSection, - relSwitchCode: model.relSwitchCodes, - switch: model.switch, - style: style - }, - style: { - lineWidth: style.Section.speedLimit.width, - stroke: style.Section.speedLimit.lineColor - } + points: model.points, + isCurve: model.isCurve, // 是否曲线 + isSwitchSection: model.isSwitchSection, + relSwitchCode: model.relSwitchCodes, + switch: model.switch + // isLine: true, + // culling: model.isCurve, // 是否裁剪 + // shape: { + // points: model.points, + // isCurve: model.isCurve, // 是否曲线 + // isSwitchSection: model.isSwitchSection, + // relSwitchCode: model.relSwitchCodes, + // switch: model.switch, + // style: style + // }, + // style: { + // lineWidth: style.Section.speedLimit.width, + // stroke: style.Section.speedLimit.lineColor + // } }); this.add(this.section); @@ -428,8 +440,8 @@ export default class Section extends Group { }); this.release.hide(); - // this.speedLimitLeft.hide(); - // this.speedLimitRight.hide(); + this.speedLimitLeft.hide(); + this.speedLimitRight.hide(); } } diff --git a/src/jmap/shape/Signal/index.js b/src/jmap/shape/Signal/index.js index 9ad620c34..ee920febf 100644 --- a/src/jmap/shape/Signal/index.js +++ b/src/jmap/shape/Signal/index.js @@ -39,7 +39,7 @@ class Signal extends Group { z: this.z + 1, shape: { x: model.position.x, - y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.Lamp.signalR), + y: model.position.y + posit * (style.Signal.signalDistance + style.Section.line.width + style.Signal.Lamp.signalR), h: style.Signal.Lamp.signalR * 2, w: style.Signal.Lamp.signalR, isDwarf: model.lampPositionType == '02', @@ -53,7 +53,7 @@ class Signal extends Group { const endPoint = { x: model.position.x + drict * (style.Signal.Lamp.signalR * 2), - y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.Lamp.signalR) + y: model.position.y + posit * (style.Signal.signalDistance + style.Section.line.width + style.Signal.Lamp.signalR) }; // 信号灯 @@ -81,7 +81,7 @@ class Signal extends Group { // 信号机名称 const sigNameX = model.position.x + model.namePosition.x; - const sigNameY = model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.Lamp.signalR * 2 + model.namePosition.y); + const sigNameY = model.position.y + posit * (style.Signal.signalDistance + style.Section.line.width + style.Signal.Lamp.signalR * 2 + model.namePosition.y); this.sigName = new Text({ zlevel: this.zlevel, z: this.z, From 68d83c2a880fd317d15d4d897b8c1d0b40069f36 Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Tue, 23 Jul 2019 18:49:54 +0800 Subject: [PATCH 10/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/shape/Signal/ESigButton.js | 18 +++---- src/jmap/shape/Signal/ESigDelay.js | 49 ++++++++++++++++++ .../shape/Signal/{ESigLmap.js => ESigLamp.js} | 4 +- src/jmap/shape/Signal/ESigName.js | 51 +++++++++++++++++++ src/jmap/shape/Signal/index.js | 31 ++++------- 5 files changed, 122 insertions(+), 31 deletions(-) create mode 100644 src/jmap/shape/Signal/ESigDelay.js rename src/jmap/shape/Signal/{ESigLmap.js => ESigLamp.js} (97%) create mode 100644 src/jmap/shape/Signal/ESigName.js diff --git a/src/jmap/shape/Signal/ESigButton.js b/src/jmap/shape/Signal/ESigButton.js index a80393e84..19341cdc9 100644 --- a/src/jmap/shape/Signal/ESigButton.js +++ b/src/jmap/shape/Signal/ESigButton.js @@ -15,7 +15,7 @@ class ESigButton extends Group { const model = this.model; const style = this.model.style; const padding = 1; - const r = style.Signal.Lamp.signalR * 0.8; + const r = style.Signal.lamp.signalR * 0.8; this.style = style; this._subType = 'SignalButton'; @@ -26,15 +26,15 @@ class ESigButton extends Group { _subType: this._subType, _val: '1', shape: { - x: model.x - style.Signal.Lamp.signalR, + x: model.x - style.Signal.lamp.signalR, y: model.y - r + r * model.posit, - width: style.Signal.Lamp.signalR * 2, - height: style.Signal.Lamp.signalR * 2 + width: style.Signal.lamp.signalR * 2, + height: style.Signal.lamp.signalR * 2 }, style: { lineWidth: 0.2, - stroke: style.Signal.Button.signalButtonDashColor, - fill: style.Signal.Button.signalButtonColor + stroke: style.Signal.button.signalButtonDashColor, + fill: style.Signal.button.signalButtonColor } }); @@ -46,12 +46,12 @@ class ESigButton extends Group { shape: { cx: model.x, cy: model.y - 5 / 2 * r * model.posit, - r: style.Signal.Lamp.signalR + r: style.Signal.lamp.signalR }, style: { lineWidth: 0.2, - stroke: style.Signal.Button.signalButtonDashColor, - fill: style.Signal.Button.signalButtonColor + stroke: style.Signal.button.signalButtonDashColor, + fill: style.Signal.button.signalButtonColor } }); diff --git a/src/jmap/shape/Signal/ESigDelay.js b/src/jmap/shape/Signal/ESigDelay.js new file mode 100644 index 000000000..776603d0c --- /dev/null +++ b/src/jmap/shape/Signal/ESigDelay.js @@ -0,0 +1,49 @@ +import Group from 'zrender/src/container/Group'; +import Text from 'zrender/src/graphic/Text'; + +class ESigDelay extends Group { + constructor(model) { + super(); + this.model = model; + this._create(); + } + + _create() { + const model = this.model; + this.name = new Text({ + _subType: model._subType, + zlevel: model.zlevel, + z: model.z, + silent: model.silent || false, + style: { + x: model.x, + y: model.y, + text: model.text, + textFont: model.textFont, + textFill: model.textFill, + textAlign: model.textAlign, + textPosition: model.textPosition || 'inside', + textVerticalAlign: model.textVerticalAlign || null + } + }); + this.add(this.name); + } + + setStyle(model) { + this.name.setStyle(model); + } + + setColor(color) { + this.name.setStyle('textFill', color); + } + + hide() { + this.name.hide(); + } + + show() { + this.name.show(); + } +} + +export default ESigDelay; diff --git a/src/jmap/shape/Signal/ESigLmap.js b/src/jmap/shape/Signal/ESigLamp.js similarity index 97% rename from src/jmap/shape/Signal/ESigLmap.js rename to src/jmap/shape/Signal/ESigLamp.js index 90d3c8ed0..0153055b4 100644 --- a/src/jmap/shape/Signal/ESigLmap.js +++ b/src/jmap/shape/Signal/ESigLamp.js @@ -2,7 +2,7 @@ import Line from 'zrender/src/graphic/shape/Line'; import Arc from 'zrender/src/graphic/shape/Arc'; import Group from 'zrender/src/container/Group'; -class ESigLmap extends Group { +class ESigLamp extends Group { constructor(model) { super(); this.model = model; @@ -86,4 +86,4 @@ class ESigLmap extends Group { } } -export default ESigLmap; +export default ESigLamp; diff --git a/src/jmap/shape/Signal/ESigName.js b/src/jmap/shape/Signal/ESigName.js new file mode 100644 index 000000000..785cf1aac --- /dev/null +++ b/src/jmap/shape/Signal/ESigName.js @@ -0,0 +1,51 @@ +import Group from 'zrender/src/container/Group'; +import Text from 'zrender/src/graphic/Text'; + +class ESigName extends Group { + constructor(model) { + super(); + this.model = model; + this._create(); + } + + _create() { + const model = this.model; + this.name = new Text({ + _subType: model._subType, + zlevel: model.zlevel, + z: model.z, + silent: model.silent, + style: { + x: model.x, + y: model.y, + text: model.text, + textFont: model.textFont, + textFill: model.textFill, + textAlign: model.textAlign, + textPosition: model.textPosition || 'inside', + textVerticalAlign: model.textVerticalAlign || null + } + }); + this.add(this.name); + } + + setStyle(model) { + this.name.setStyle(model); + } + + setColor(color) { + this.name.setStyle('textFill', color); + } + + // 隐藏 + hide() { + this.name.hide(); + } + + // 显示 + show() { + this.name.show(); + } +} + +export default ESigName; diff --git a/src/jmap/shape/Signal/index.js b/src/jmap/shape/Signal/index.js index 164b2d5f9..f2a4300b2 100644 --- a/src/jmap/shape/Signal/index.js +++ b/src/jmap/shape/Signal/index.js @@ -7,6 +7,7 @@ import ESigLamp from './ESigLamp'; import ESigAuto from './ESigAuto'; import ESigRoute from './ESigRoute'; import ESigButton from './ESigButton'; +import ESigDelay from './ESigDelay'; import ESigName from './ESigName'; import Group from 'zrender/src/container/Group'; @@ -44,12 +45,8 @@ class Signal extends Group { y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.lamp.signalR) }); - const endPoint = { - x: model.position.x + drict * (style.Signal.Lamp.signalR * 2), - y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.Lamp.signalR) - }; - // 信号灯 + const endPoint = this.sigPost.getLampPosition(model.lampPostType); this.lamps = []; for (let i = 0; i < this.count; i++) { const lamp = new ESigLamp({ @@ -91,14 +88,10 @@ class Signal extends Group { this.sigRoute = new ESigRoute({ zlevel: this.zlevel, z: this.z, - shape: { - x: sigRouteX, - y: sigRouteY, - forward: model.directionType == '01' - }, - style: { - fill: style.Signal.Route.signalRouteColor - } + style: style, + x: sigRouteX, + y: sigRouteY, + drict: drict }); // 自动通过 @@ -152,9 +145,8 @@ class Signal extends Group { this.add(this.sigName); this.add(this.sigAuto); this.add(this.sigRoute); - this.add(this.sigAuto); this.add(this.sigDelay); - this.add(this.sigButton); + // this.add(this.sigButton); } // 整体旋转信号灯 @@ -240,12 +232,12 @@ class Signal extends Group { // 物理点灯 logicalLight() { - this.lamps.forEach(lamp => { lamp.setShape('isStop', false); }); + this.lamps.forEach(lamp => { lamp.setStop(false); }); } // 逻辑点灯 physicsLight() { - this.lamps.forEach(lamp => { lamp.setShape('isStop', true); }); + this.lamps.forEach(lamp => { lamp.setStop(true); }); } // 设置自动进路模式状态类型 @@ -273,7 +265,7 @@ class Signal extends Group { } // 设置自动信号模式状态类型 - setAutonalOpen() { + setAutoSignalOpen() { this.sigRoute.show(); } @@ -282,7 +274,6 @@ class Signal extends Group { this.sigAuto.hide(); this.sigAuto.setColor(this.style.backgroundColor); this.sigRoute.hide(); - this.sigAuto.hide(); } // 自动信号和自动进路开始动画 @@ -330,7 +321,7 @@ class Signal extends Group { /** 设置自动类型*/ switch (state.autoType) { case '01': this.setAutoClose(); break; // 隐藏 隐藏自动信号和自动进路 - case '02': this.setAutonalOpen(); break; // 显示 设置自动信号模式状态类型 + case '02': this.setAutoSignalOpen(); break; // 显示 设置自动信号模式状态类型 case '03': this.setAutoRouteOpen(); break; // 显示 设置自动进路模式状态类型 case '04': this.setAutoAccessOpen(); break; // 显示 信号机进路自动触发模式状态类型 } From 627a7d86c897e45d835424254b407da2410c277e Mon Sep 17 00:00:00 2001 From: zyy <1787816799@qq.com> Date: Wed, 24 Jul 2019 09:21:10 +0800 Subject: [PATCH 11/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/shape/Section/ELimitLines.js | 324 ++++++++++++++------------ src/jmap/shape/Section/index.js | 74 +++--- 2 files changed, 215 insertions(+), 183 deletions(-) diff --git a/src/jmap/shape/Section/ELimitLines.js b/src/jmap/shape/Section/ELimitLines.js index 1379456c1..9693183d8 100644 --- a/src/jmap/shape/Section/ELimitLines.js +++ b/src/jmap/shape/Section/ELimitLines.js @@ -1,37 +1,122 @@ -// import Group from 'zrender/src/container/Group'; -// import BezierCurve from 'zrender/src/graphic/shape/BezierCurve'; -// import Line from 'zrender/src/graphic/shape/Line'; +import Group from 'zrender/src/container/Group'; +import BezierCurve from 'zrender/src/graphic/shape/BezierCurve'; +import Line from 'zrender/src/graphic/shape/Line'; import JTriangle from '../../utils/JTriangle'; -import Path from 'zrender/src/graphic/Path'; +// import Path from 'zrender/src/graphic/Path'; // 创建区段限速限集合 -export const ELimitLines = Path.extend({ - type: 'ELimitLines', - shape: { - points: null - }, - buildPath: function (ctx, model) { +// export const ELimitLines = Path.extend({ +// type: 'ELimitLines', +// shape: { +// points: null +// }, +// buildPath: function (ctx, model) { +// /** 创建区段*/ +// if (model && model.points.length > 1) { +// if (model.isCurve) { +// ctx.beginPath(); +// const shape = {}; +// for (let i = 1; i < (model.points.length - 1); i++) { +// shape[`cpx${i}`] = model.points[i].x; +// shape[`cpy${i}`] = model.points[i].y; +// } +// shape[`x1`] = model.points[0].x; +// shape[`y1`] = model.points[0].y; +// shape[`x2`] = model.points[model.points.length - 1].x; +// shape[`y2`] = model.points[model.points.length - 1].y; + +// ctx.moveTo(shape[`x1`], shape[`y1`]); +// if (model.points.length <= 3) { +// ctx.quadraticCurveTo(shape[`cpx1`], shape[`cpy1`], shape[`x2`], shape[`y2`]); +// } else { +// ctx.bezierCurveTo(shape[`cpx1`], shape[`cpy1`], shape[`cpx2`], shape[`cpy2`], shape[`x2`], shape[`y2`]); +// } +// } else { +// const swPadding = model.style.Switch.switchLen; // 定位和反位时区段距离岔芯的距离 +// var switchWidth = model.style.Section.line.width + model.style.Section.line.beyondWidth; // 道岔宽度 +// const beg = Object.assign({}, model.points[0]); +// const end = Object.assign({}, model.points[model.points.length - 1]); +// if (model.isSwitchSection && beg.y !== end.y) { +// const swch = model.switch; +// if (swch) { +// const traingle = new JTriangle(swch.intersection, swch.skew); +// if ((swch.intersection.x === beg.x) && (swch.intersection.y === beg.y)) { +// beg.x = beg.x + traingle.drictx * (swPadding + switchWidth) * traingle.getCotRate(); +// beg.y = beg.y + traingle.dricty * (swPadding + switchWidth); +// } + +// if ((swch.intersection.x === end.x) && (swch.intersection.y === end.y)) { +// end.x = end.x + traingle.drictx * (swPadding + switchWidth) * traingle.getCotRate(); +// end.y = end.y + traingle.dricty * (swPadding + switchWidth); +// } +// } +// } + +// if (model.points.length == 2) { +// ctx.moveTo(beg.x, beg.y); +// ctx.lineTo(end.x, end.y); +// ctx.closePath(); +// } else { +// ctx.moveTo(beg.x, beg.y); +// ctx.lineTo(model.points[1].x, model.points[1].y); +// ctx.closePath(); + +// for (let i = 1; i < (model.points.length - 2); i++) { +// ctx.moveTo(model.points[i].x, model.points[i].y); +// ctx.lineTo(model.points[i + 1].x, model.points[i + 1].y); +// ctx.closePath(); +// } +// ctx.moveTo(model.points[model.points.length - 2].x, model.points[model.points.length - 2].y); +// ctx.lineTo(end.x, end.y); +// ctx.closePath(); +// } +// } +// } +// } +// }); + +export default class ELimitLines extends Group { + constructor(model) { + super(); + this.model = model; + this.zlevel = model.zlevel; + this.z = model.z; + this._create(model); + } + + _create(model) { /** 创建区段*/ if (model && model.points.length > 1) { if (model.isCurve) { - ctx.beginPath(); const shape = {}; for (let i = 1; i < (model.points.length - 1); i++) { shape[`cpx${i}`] = model.points[i].x; shape[`cpy${i}`] = model.points[i].y; } + shape[`x1`] = model.points[0].x; shape[`y1`] = model.points[0].y; shape[`x2`] = model.points[model.points.length - 1].x; shape[`y2`] = model.points[model.points.length - 1].y; - ctx.moveTo(shape[`x1`], shape[`y1`]); - if (model.points.length <= 3) { - ctx.quadraticCurveTo(shape[`cpx1`], shape[`cpy1`], shape[`x2`], shape[`y2`]); - } else { - ctx.bezierCurveTo(shape[`cpx1`], shape[`cpy1`], shape[`cpx2`], shape[`cpy2`], shape[`x2`], shape[`y2`]); - } + this.add(new BezierCurve({ + isLine: true, + zlevel: this.zlevel, + progressive: model.progressive, + z: this.z, + culling: true, + shape: shape, + position: model.position, + style: { + lineWidth: model.style.Section.speedLimit.width, + stroke: model.style.Section.speedLimit.lineColor, + fillOpacity: 0 + } + })); } else { + // const beg = Object.assign({}, model.points[0]); + // const end = Object.assign({}, model.points[model.points.length - 1]); + const swPadding = model.style.Switch.switchLen; // 定位和反位时区段距离岔芯的距离 var switchWidth = model.style.Section.line.width + model.style.Section.line.beyondWidth; // 道岔宽度 const beg = Object.assign({}, model.points[0]); @@ -53,146 +138,81 @@ export const ELimitLines = Path.extend({ } if (model.points.length == 2) { - ctx.moveTo(beg.x, beg.y); - ctx.lineTo(end.x, end.y); - ctx.closePath(); + this.add(new Line({ + isLine: true, + zlevel: this.zlevel, + progressive: model.progressive, + z: this.z, + position: model.position, + shape: { + x1: beg.x, + y1: beg.y, + x2: end.x, + y2: end.y + }, + style: { + lineWidth: model.style.Section.speedLimit.width, + stroke: model.style.Section.speedLimit.lineColor + } + })); } else { - ctx.moveTo(beg.x, beg.y); - ctx.lineTo(model.points[1].x, model.points[1].y); - ctx.closePath(); + this.add(new Line({ + isLine: true, + zlevel: this.zlevel, + progressive: model.progressive, + z: this.z, + position: model.position, + shape: { + x1: beg.x, + y1: beg.y, + x2: model.points[1].x, + y2: model.points[1].y + }, + style: { + lineWidth: model.style.Section.speedLimit.width, + stroke: model.style.Section.speedLimit.lineColor + } + })); for (let i = 1; i < (model.points.length - 2); i++) { - ctx.moveTo(model.points[i].x, model.points[i].y); - ctx.lineTo(model.points[i + 1].x, model.points[i + 1].y); - ctx.closePath(); + this.add(new Line({ + isLine: true, + zlevel: this.zlevel, + z: this.z, + progressive: model.progressive, + position: model.position, + shape: { + x1: model.points[i].x, + y1: model.points[i].y, + x2: model.points[i + 1].x, + y2: model.points[i + 1].y + }, + style: { + lineWidth: model.style.Section.speedLimit.width, + stroke: model.style.Section.speedLimit.lineColor + } + })); } - ctx.moveTo(model.points[model.points.length - 2].x, model.points[model.points.length - 2].y); - ctx.lineTo(end.x, end.y); - ctx.closePath(); + + this.add(new Line({ + isLine: true, + zlevel: this.zlevel, + z: this.z, + position: model.position, + progressive: model.progressive, + shape: { + x1: model.points[model.points.length - 2].x, + y1: model.points[model.points.length - 2].y, + x2: end.x, + y2: end.y + }, + style: { + lineWidth: model.style.Section.speedLimit.width, + stroke: model.style.Section.speedLimit.lineColor + } + })); } } } } -}); - -// export default class ELimitLines extends Group { -// constructor(model) { -// super(); -// this.model = model; -// this.zlevel = model.zlevel; -// this.z = model.z; -// this._create(model); -// } - -// _create(model) { -// /** 创建区段*/ -// if (model && model.points.length > 1) { -// if (model.isCurve) { -// const shape = {}; -// for (let i = 1; i < (model.points.length - 1); i++) { -// shape[`cpx${i}`] = model.points[i].x; -// shape[`cpy${i}`] = model.points[i].y; -// } - -// shape[`x1`] = model.points[0].x; -// shape[`y1`] = model.points[0].y; -// shape[`x2`] = model.points[model.points.length - 1].x; -// shape[`y2`] = model.points[model.points.length - 1].y; - -// this.add(new BezierCurve({ -// isLine: true, -// zlevel: this.zlevel, -// progressive: model.progressive, -// z: this.z, -// culling: true, -// shape: shape, -// position: model.position, -// style: { -// lineWidth: model.style.Section.speedLimit.width, -// stroke: model.style.Section.speedLimit.lineColor, -// fillOpacity: 0 -// } -// })); -// } else { -// const beg = Object.assign({}, model.points[0]); -// const end = Object.assign({}, model.points[model.points.length - 1]); - -// if (model.points.length == 2) { -// this.add(new Line({ -// isLine: true, -// zlevel: this.zlevel, -// progressive: model.progressive, -// z: this.z, -// position: model.position, -// shape: { -// x1: beg.x, -// y1: beg.y, -// x2: end.x, -// y2: end.y -// }, -// style: { -// lineWidth: model.style.Section.speedLimit.width, -// stroke: model.style.Section.speedLimit.lineColor -// } -// })); -// } else { -// this.add(new Line({ -// isLine: true, -// zlevel: this.zlevel, -// progressive: model.progressive, -// z: this.z, -// position: model.position, -// shape: { -// x1: beg.x, -// y1: beg.y, -// x2: model.points[1].x, -// y2: model.points[1].y -// }, -// style: { -// lineWidth: model.style.Section.speedLimit.width, -// stroke: model.style.Section.speedLimit.lineColor -// } -// })); - -// for (let i = 1; i < (model.points.length - 2); i++) { -// this.add(new Line({ -// isLine: true, -// zlevel: this.zlevel, -// z: this.z, -// progressive: model.progressive, -// position: model.position, -// shape: { -// x1: model.points[i].x, -// y1: model.points[i].y, -// x2: model.points[i + 1].x, -// y2: model.points[i + 1].y -// }, -// style: { -// lineWidth: model.style.Section.speedLimit.width, -// stroke: model.style.Section.speedLimit.lineColor -// } -// })); -// } - -// this.add(new Line({ -// isLine: true, -// zlevel: this.zlevel, -// z: this.z, -// position: model.position, -// progressive: model.progressive, -// shape: { -// x1: model.points[model.points.length - 2].x, -// y1: model.points[model.points.length - 2].y, -// x2: end.x, -// y2: end.y -// }, -// style: { -// lineWidth: model.style.Section.speedLimit.width, -// stroke: model.style.Section.speedLimit.lineColor -// } -// })); -// } -// } -// } -// } -// } +} diff --git a/src/jmap/shape/Section/index.js b/src/jmap/shape/Section/index.js index 8ed6ce38a..13e79a268 100644 --- a/src/jmap/shape/Section/index.js +++ b/src/jmap/shape/Section/index.js @@ -1,7 +1,7 @@ import Group from 'zrender/src/container/Group'; import ETextName from '../element/ETextName'; // 名称文字 (共有) import ERelease from './ERelease'; // 线段 (共有) -import { ELimitLines } from './ELimitLines'; // 区段限速 (私有) +import ELimitLines from './ELimitLines'; // 区段限速 (私有) import ELines from './ELines'; // 创建多线条 曲线 (私有) import ESeparator from './ESeparator'; // 分隔符 (私有) import { EAxle } from './EAxle'; // 创建计轴 (私有) @@ -81,44 +81,56 @@ export default class Section extends Group { // 创建限速线 this.speedLimitLeft = new ELimitLines({ zlevel: this.zlevel, - z: model.isCurve ? this.z - 1 : this.z, + z: this.z, progressive: 5, position: [x, -y], - isLine: true, - culling: model.isCurve, // 是否裁剪 - shape: { - points: model.points, - isCurve: model.isCurve, // 是否曲线 - isSwitchSection: model.isSwitchSection, - relSwitchCode: model.relSwitchCode, - switch: model.switch, - style: style - }, - style: { - lineWidth: style.Section.speedLimit.width, - stroke: style.Section.speedLimit.lineColor - } + style: style, + switch: model.switch, + isSwitchSection: model.isSwitchSection, + relSwitchCode: model.relSwitchCode, + isCurve: model.isCurve, // 是否曲线 + points: model.points + // isLine: true, + // culling: model.isCurve, // 是否裁剪 + // shape: { + // points: model.points, + // isCurve: model.isCurve, // 是否曲线 + // isSwitchSection: model.isSwitchSection, + // relSwitchCode: model.relSwitchCode, + // switch: model.switch, + // style: style + // }, + // style: { + // lineWidth: style.Section.speedLimit.width, + // stroke: style.Section.speedLimit.lineColor + // } }); this.speedLimitRight = new ELimitLines({ zlevel: this.zlevel, - z: model.isCurve ? this.z - 1 : this.z, + z: this.z, progressive: 5, position: [x, -y], - isLine: true, - culling: model.isCurve, // 是否裁剪 - shape: { - points: model.points, - isCurve: model.isCurve, // 是否曲线 - isSwitchSection: model.isSwitchSection, - relSwitchCode: model.relSwitchCodes, - switch: model.switch, - style: style - }, - style: { - lineWidth: style.Section.speedLimit.width, - stroke: style.Section.speedLimit.lineColor - } + style: style, + switch: model.switch, + isSwitchSection: model.isSwitchSection, + relSwitchCode: model.relSwitchCode, + isCurve: model.isCurve, // 是否曲线 + points: model.points + // isLine: true, + // culling: model.isCurve, // 是否裁剪 + // shape: { + // points: model.points, + // isCurve: model.isCurve, // 是否曲线 + // isSwitchSection: model.isSwitchSection, + // relSwitchCode: model.relSwitchCodes, + // switch: model.switch, + // style: style + // }, + // style: { + // lineWidth: style.Section.speedLimit.width, + // stroke: style.Section.speedLimit.lineColor + // } }); this.add(this.section); From 540dc4e34656ba647a23a421d5ba219f2cc4755a Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Wed, 24 Jul 2019 09:23:08 +0800 Subject: [PATCH 12/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/shape/Signal/ESigAuto.js | 46 +++++---- src/jmap/shape/Signal/ESigButton.js | 152 ++++++++++++++-------------- src/jmap/shape/Signal/ESigDelay.js | 45 ++++---- src/jmap/shape/Signal/ESigRoute.js | 38 ++++--- 4 files changed, 152 insertions(+), 129 deletions(-) diff --git a/src/jmap/shape/Signal/ESigAuto.js b/src/jmap/shape/Signal/ESigAuto.js index 099f9a091..c8877fde5 100644 --- a/src/jmap/shape/Signal/ESigAuto.js +++ b/src/jmap/shape/Signal/ESigAuto.js @@ -6,42 +6,48 @@ class ESigPass extends Group { constructor(model) { super(); this.model = model; - this._create(); + this.isNew = false; } _create() { - const model = this.model; - const style = this.model.style; - const rotation = model.drict != 1? 0 : Math.PI; - const point = arrows(model.x, model.y, style.Signal.signalAutoWidth, style.Signal.lamp.signalR * 0.8); - this.arrows = new Polygon({ - zlevel: model.zlevel, - z: model.z, - rotation: rotation, - shape: { - points: point - }, - style: { - stroke: model.stroke, - lineWidth: model.lineWidth, - fill: model.fill - } - }); - this.add(this.arrows); + if (!this.isNew) { + const model = this.model; + const style = this.model.style; + const rotation = model.drict != 1? 0 : Math.PI; + const point = arrows(model.x, model.y, style.Signal.signalAutoWidth, style.Signal.lamp.signalR * 0.8); + this.arrows = new Polygon({ + zlevel: model.zlevel, + z: model.z, + rotation: rotation, + shape: { + points: point + }, + style: { + stroke: model.stroke, + lineWidth: model.lineWidth, + fill: model.fill + } + }); + this.add(this.arrows); + this.isNew = true; + } } // 停止动画 animationRecover() { + this._create(); this.arrows.stopAnimation(false); } // 箭头颜色 setColor(color) { + this._create(); this.arrows.setStyle('fill', color); } // 箭头闪烁 arrowsAnimation() { + this._create(); const style = this.model.style; const fill = this.arrows.style.Signal.fill; this.arrows.animate(true) @@ -54,11 +60,13 @@ class ESigPass extends Group { // 隐藏 hide() { + this._create(); this.arrows.hide(); } // 显示 show() { + this._create(); this.arrows.show(); } } diff --git a/src/jmap/shape/Signal/ESigButton.js b/src/jmap/shape/Signal/ESigButton.js index 19341cdc9..c7bcf3651 100644 --- a/src/jmap/shape/Signal/ESigButton.js +++ b/src/jmap/shape/Signal/ESigButton.js @@ -8,97 +8,99 @@ class ESigButton extends Group { constructor(model) { super(); this.model = model; - this._create(); + this.isNew = false; } _create() { - const model = this.model; - const style = this.model.style; - const padding = 1; - const r = style.Signal.lamp.signalR * 0.8; + if (!this.isNew) { + const model = this.model; + const style = this.model.style; + const padding = 1; + const r = style.Signal.lamp.signalR * 0.8; - this.style = style; - this._subType = 'SignalButton'; + this.sigNormalButtom = new Rect({ + zlevel: model.zlevel, + z: model.z, + _subType: 'SignalButton', + _val: '1', + shape: { + x: model.x - style.Signal.lamp.signalR, + y: model.y - r + r * model.posit, + width: style.Signal.lamp.signalR * 2, + height: style.Signal.lamp.signalR * 2 + }, + style: { + lineWidth: 0.2, + stroke: style.Signal.button.signalButtonDashColor, + fill: style.Signal.button.signalButtonColor + } + }); - this.sigNormalButtom = new Rect({ - zlevel: model.zlevel, - z: model.z, - _subType: this._subType, - _val: '1', - shape: { - x: model.x - style.Signal.lamp.signalR, - y: model.y - r + r * model.posit, - width: style.Signal.lamp.signalR * 2, - height: style.Signal.lamp.signalR * 2 - }, - style: { - lineWidth: 0.2, - stroke: style.Signal.button.signalButtonDashColor, - fill: style.Signal.button.signalButtonColor - } - }); + this.sigReentryButton = new Circle({ + zlevel: model.zlevel, + z: model.z, + _subType: 'SignalButton', + _val: '2', // 折返按钮 + shape: { + cx: model.x, + cy: model.y - 5 / 2 * r * model.posit, + r: style.Signal.lamp.signalR + }, + style: { + lineWidth: 0.2, + stroke: style.Signal.button.signalButtonDashColor, + fill: style.Signal.button.signalButtonColor + } + }); - this.sigReentryButton = new Circle({ - zlevel: model.zlevel, - z: model.z, - _subType: this._subType, - _val: '2', // 折返按钮 - shape: { - cx: model.x, - cy: model.y - 5 / 2 * r * model.posit, - r: style.Signal.lamp.signalR - }, - style: { - lineWidth: 0.2, - stroke: style.Signal.button.signalButtonDashColor, - fill: style.Signal.button.signalButtonColor - } - }); + this.sigNormalButtomDown = new Polyline({ + zlevel: model.zlevel, + z: model.z, + silent: true, + shape: { points: [ + [model.x - padding + r, this.sigNormalButtom.shape.y + padding], + [model.x + padding - r, this.sigNormalButtom.shape.y + padding], + [model.x + padding - r, this.sigNormalButtom.shape.y + padding * 2 + r] + ] }, + style: { + lineWidth: 0.8, + stroke: style.backgroundColor + } + }); - this.sigNormalButtomDown = new Polyline({ - zlevel: model.zlevel, - z: model.z, - silent: true, - shape: { points: [ - [model.x - padding + r, this.sigNormalButtom.shape.y + padding], - [model.x + padding - r, this.sigNormalButtom.shape.y + padding], - [model.x + padding - r, this.sigNormalButtom.shape.y + padding * 2 + r] - ] }, - style: { - lineWidth: 0.8, - stroke: style.backgroundColor - } - }); + this.sigReentryButtonDown = new Arc({ + zlevel: model.zlevel, + z: model.z, + silent: true, + shape: { + cx: this.sigReentryButton.shape.cx, + cy: this.sigReentryButton.shape.cy, + r: this.sigReentryButton.shape.r - padding, + startAngle: Math.PI * 8 / 5, + endAngle: Math.PI * 4 / 5, + clockwise: false + }, + style: { + lineWidth: 0.8, + stroke: style.backgroundColor + } + }); - this.sigReentryButtonDown = new Arc({ - zlevel: model.zlevel, - z: model.z, - silent: true, - shape: { - cx: this.sigReentryButton.shape.cx, - cy: this.sigReentryButton.shape.cy, - r: this.sigReentryButton.shape.r - padding, - startAngle: Math.PI * 8 / 5, - endAngle: Math.PI * 4 / 5, - clockwise: false - }, - style: { - lineWidth: 0.8, - stroke: style.backgroundColor - } - }); - - this.add(this.sigNormalButtom); - this.add(this.sigReentryButton); - this.hide(); + this.add(this.sigNormalButtom); + this.add(this.sigReentryButton); + this.hide(); + this.isNew = true; + } } hide() { + this._create(); this.sigNormalButtom.hide(); this.sigReentryButton.hide(); } show() { + this._create(); this.sigNormalButtom.show(); this.sigReentryButton.show(); } diff --git a/src/jmap/shape/Signal/ESigDelay.js b/src/jmap/shape/Signal/ESigDelay.js index 776603d0c..d9ced14da 100644 --- a/src/jmap/shape/Signal/ESigDelay.js +++ b/src/jmap/shape/Signal/ESigDelay.js @@ -5,43 +5,50 @@ class ESigDelay extends Group { constructor(model) { super(); this.model = model; - this._create(); + this.isNew = false; } _create() { - const model = this.model; - this.name = new Text({ - _subType: model._subType, - zlevel: model.zlevel, - z: model.z, - silent: model.silent || false, - style: { - x: model.x, - y: model.y, - text: model.text, - textFont: model.textFont, - textFill: model.textFill, - textAlign: model.textAlign, - textPosition: model.textPosition || 'inside', - textVerticalAlign: model.textVerticalAlign || null - } - }); - this.add(this.name); + if (!this.isNew) { + const model = this.model; + this.name = new Text({ + _subType: model._subType, + zlevel: model.zlevel, + z: model.z, + silent: model.silent || false, + style: { + x: model.x, + y: model.y, + text: model.text, + textFont: model.textFont, + textFill: model.textFill, + textAlign: model.textAlign, + textPosition: model.textPosition || 'inside', + textVerticalAlign: model.textVerticalAlign || null + } + }); + this.add(this.name); + this.isNew = true; + } } setStyle(model) { + this._create(); this.name.setStyle(model); } setColor(color) { + this._create(); this.name.setStyle('textFill', color); } hide() { + this._create(); this.name.hide(); } show() { + this._create(); this.name.show(); } } diff --git a/src/jmap/shape/Signal/ESigRoute.js b/src/jmap/shape/Signal/ESigRoute.js index 398fe29b5..eb09d95bd 100644 --- a/src/jmap/shape/Signal/ESigRoute.js +++ b/src/jmap/shape/Signal/ESigRoute.js @@ -6,34 +6,40 @@ class ESigDrict extends Group { constructor(model) { super(); this.model = model; - this._create(); + this.isNew = false; } _create() { - const model = this.model; - const style = this.model.style; - this.sigDrict = new Polygon({ - zlevel: model.zlevel, - z: model.z, - shape: { - points: triangular(model.x, model.y, model.drict, style.Signal.lamp.signalR) - }, - style: { - stroke: style.backgroundColor, - lineWidth: 0.5, - fill: style.Signal.route.signalRouteColor - } - }); - this.add(this.sigDrict); + if (!this.isNew) { + const model = this.model; + const style = this.model.style; + this.sigDrict = new Polygon({ + zlevel: model.zlevel, + z: model.z, + shape: { + points: triangular(model.x, model.y, model.drict, style.Signal.lamp.signalR) + }, + style: { + stroke: style.backgroundColor, + lineWidth: 0.5, + fill: style.Signal.route.signalRouteColor + } + }); + + this.add(this.sigDrict); + this.isNew = true; + } } // 隐藏 hide() { + this._create(); this.sigDrict.hide(); } // 显示 show() { + this._create(); this.sigDrict.show(); } } From 7609233eb5e27bab7d256bc382f028da99580501 Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Wed, 24 Jul 2019 10:02:07 +0800 Subject: [PATCH 13/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/shape/Section/ELimitLines.js | 4 +- src/jmap/shape/Signal/index.js | 6 +- src/jmap/shape/Switch/ESwName.js | 4 +- src/jmap/shape/Switch/index copy.js | 398 -------------------------- src/jmap/shape/Switch/index.js | 16 +- src/jmap/theme/batong.js | 2 +- src/jmap/theme/bejing.js | 163 ++++++----- src/jmap/theme/chengdu.js | 2 +- src/jmap/theme/fuzhou.js | 40 +-- src/views/jmap/index.vue | 2 +- 10 files changed, 139 insertions(+), 498 deletions(-) delete mode 100644 src/jmap/shape/Switch/index copy.js diff --git a/src/jmap/shape/Section/ELimitLines.js b/src/jmap/shape/Section/ELimitLines.js index 9693183d8..b7c78b52e 100644 --- a/src/jmap/shape/Section/ELimitLines.js +++ b/src/jmap/shape/Section/ELimitLines.js @@ -32,7 +32,7 @@ import JTriangle from '../../utils/JTriangle'; // ctx.bezierCurveTo(shape[`cpx1`], shape[`cpy1`], shape[`cpx2`], shape[`cpy2`], shape[`x2`], shape[`y2`]); // } // } else { -// const swPadding = model.style.Switch.switchLen; // 定位和反位时区段距离岔芯的距离 +// const swPadding = model.style.Switch.core.switchLen; // 定位和反位时区段距离岔芯的距离 // var switchWidth = model.style.Section.line.width + model.style.Section.line.beyondWidth; // 道岔宽度 // const beg = Object.assign({}, model.points[0]); // const end = Object.assign({}, model.points[model.points.length - 1]); @@ -117,7 +117,7 @@ export default class ELimitLines extends Group { // const beg = Object.assign({}, model.points[0]); // const end = Object.assign({}, model.points[model.points.length - 1]); - const swPadding = model.style.Switch.switchLen; // 定位和反位时区段距离岔芯的距离 + const swPadding = model.style.Switch.core.switchLen; // 定位和反位时区段距离岔芯的距离 var switchWidth = model.style.Section.line.width + model.style.Section.line.beyondWidth; // 道岔宽度 const beg = Object.assign({}, model.points[0]); const end = Object.assign({}, model.points[model.points.length - 1]); diff --git a/src/jmap/shape/Signal/index.js b/src/jmap/shape/Signal/index.js index b3212c576..7a1afeac4 100644 --- a/src/jmap/shape/Signal/index.js +++ b/src/jmap/shape/Signal/index.js @@ -76,7 +76,7 @@ class Signal extends Group { y: sigNameY, text: model.name, textFont: `bold ${style.Signal.text.signalTextFontSize} px ${style.textFontFormat}`, - textFill: style.Signal.text.signalTextGreen, + textFill: style.Signal.text.signalDefaultTextColor, textAlign: 'middle', textVerticalAlign: posit == 1 ? 'top' : 'bottom' }); @@ -214,7 +214,7 @@ class Signal extends Group { // 封锁 block() { this.lamps[0] && this.lamps[0].setColor(this.style.Signal.lamp.signalLampRedColor); - this.sigName.setColor(this.style.Signal.sectionBlockTextColor); + this.sigName.setColor(this.style.Signal.signalTextBlockColor); } // 功能封锁 @@ -290,7 +290,7 @@ class Signal extends Group { recover() { this.sigDelay.hide(); this.sigAuto.animationRecover(); - this.sigName.setColor(this.style.Signal.text.signalTextGreen); + this.sigName.setColor(this.style.Signal.text.signalDefaultTextColor); } setState(state) { diff --git a/src/jmap/shape/Switch/ESwName.js b/src/jmap/shape/Switch/ESwName.js index 66f37cf61..c6fa4c741 100644 --- a/src/jmap/shape/Switch/ESwName.js +++ b/src/jmap/shape/Switch/ESwName.js @@ -23,7 +23,7 @@ class ESwName extends Group { textAlign: model.triangle.drictx === 1 ? 'left' : 'right', textVerticalAlign: model.triangle.dricty === 1 ? 'top' : 'bottom', textFont: style.textFontSize + 'px ' + style.textFontFormat, - textFill: style.Switch.switchTextLossColor + textFill: style.Switch.text.switchTextLossColor } }); @@ -47,7 +47,7 @@ class ESwName extends Group { style: { lineWidth: 0, lineDash: [3, 3], - stroke: style.Switch.switchTextBorderColor, + stroke: style.Switch.text.switchTextBorderColor, fill: style.transparentColor } }); diff --git a/src/jmap/shape/Switch/index copy.js b/src/jmap/shape/Switch/index copy.js deleted file mode 100644 index 139cd6b6e..000000000 --- a/src/jmap/shape/Switch/index copy.js +++ /dev/null @@ -1,398 +0,0 @@ -/* -* 道岔 -*/ -import Line from 'zrender/src/graphic/shape/Line'; -import Group from 'zrender/src/container/Group'; -import Polygon from 'zrender/src/graphic/shape/Polygon'; -import JTriangle from '../../utils/JTriangle'; -import ESwName from './ESwName.js'; -import ESwCore from './ESwCore.js'; - -export default class Switch extends Group { - constructor({ _code, _type, zlevel, model, state }, style, jmap) { - super(); - this._code = _code; - this._type = _type; - this.model = model; - this.state = state; - this.style = style; - this.jmap = jmap; - this.selected = false; - this.zlevel = zlevel; - this.z = 8; - - this._create(); - this.setState(state); - } - - _create() { - const model = this.model; - const style = this.style; - - this.triangle = new JTriangle(model.intersection, model.skew); - - let halfWidth = style.Section.line.width / 2; - const switchWidth = style.Section.line.width + style.Section.line.beyondWidth*2 + 0.8; - const swPadding = style.Switch.switchLen; - const directx = this.triangle.drictx; - const directy = this.triangle.dricty; - const direct = -this.triangle.drictx * this.triangle.dricty; - const coverLength = switchWidth * 1.5; - - this.swCore = new ESwCore({ - zlevel: this.zlevel, - z: this.z, - style: style, - intersectionX: model.intersection.x, - intersectionY: model.intersection.y, - coverLength: coverLength, - lineWidth: switchWidth, - triangle: this.triangle - }); - - halfWidth += 0.3; - const point1 = [model.intersection.x - directx * halfWidth, model.intersection.y + directy * halfWidth]; - const point2 = [point1[0] + directx * switchWidth / this.triangle.getSinRate(), point1[1]]; - const point3 = [point2[0] + directx * this.triangle.getCotRate() * swPadding, point2[1] + directy * swPadding]; - const point4 = [point3[0] + direct * this.triangle.getSin(switchWidth), point3[1] - direct * this.triangle.getCos(switchWidth)]; - this.locShelter = new Polygon({ - zlevel: this.zlevel, - z: this.z, - shape: { - points: [ - point1, point2, point3, point4 - ] - }, - style: { - fill: style.backgroundColor - }, - cursor: 'pointer', - onmouseover: () => { this.name.getArrowText().show(); }, - onmouseout: () => { this.name.getArrowText().hide(); } - }); - const lpx = Math.abs(this.triangle.getCos(1)); - this.locShelter.position = [directx * lpx, -directy * 0.2]; - this.locShelter.show(); - - const slen = switchWidth / this.triangle.getSinRate(); - const rpoint1 = [model.intersection.x + directx * halfWidth, model.intersection.y - directy * halfWidth]; - const rpoint2 = [rpoint1[0] + directx * (swPadding + switchWidth * this.triangle.getCotRate()), rpoint1[1]]; - const rpoint3 = [rpoint2[0], rpoint2[1] + directy * switchWidth]; - const rpoint4 = [rpoint1[0] + this.triangle.getCos(slen), rpoint1[1] + this.triangle.getSin(slen)]; - this.relocShelter = new Polygon({ - zlevel: this.zlevel, - z: this.z, - shape: { - points: [ - rpoint1, rpoint2, rpoint3, rpoint4 - ] - }, - style: { - fill: style.backgroundColor - }, - cursor: 'pointer', - onmouseover: () => { this.name.getArrowText().show(); }, - onmouseout: () => { this.name.getArrowText().hide(); } - }); - const rpx = Math.abs(this.triangle.getCos(halfWidth)) + 0.2; - this.relocShelter.position = [-directx * rpx, -directy * 0.2]; - this.relocShelter.hide(); - - const sinX = style.Section.line.width / this.triangle.getSinRate(); - const switchWidth1 = style.Section.line.width / 2; - const width1 = switchWidth1 * this.triangle.getSinRate(); - const height1 = switchWidth1 * this.triangle.getCosRate(); - const width2 = (height1 + switchWidth1) / this.triangle.getTanRate(); - const width3 = sinX - width2 - width1; - const switchPoint1 = [model.intersection.x + directx * width3, model.intersection.y - directy * switchWidth1]; - const switchPoint2 = [switchPoint1[0] - directx * (width2 + width1) - directx * width3, switchPoint1[1]]; - const switchPoint3 = [model.intersection.x - directx * width3, model.intersection.y + directy * switchWidth1]; - const switchPoint4 = [switchPoint1[0] + directx * (width2 + width1) - directx * width3, switchPoint3[1]]; - this.reserveSection = new Polygon({ - zlevel: this.zlevel, - shape: { - points: [ - switchPoint1, switchPoint2, switchPoint3, switchPoint4 - ] - }, - style: { - fill: style.Section.line.spareColor - }, - cursor: 'pointer', - onmouseover: () => { this.name.getArrowText().show(); }, - onmouseout: () => { this.name.getArrowText().hide(); } - }); - this.reserveSection.hide(); - - this.releaseBackground = new Line({ - zlevel: this.zlevel, - z: this.z, - shape: { - x1: model.intersection.x - (coverLength * this.triangle.getCotRate()), - y1: model.intersection.y, - x2: model.intersection.x + (coverLength * this.triangle.getCotRate()), - y2: model.intersection.y - }, - style: { - lineWidth: style.Section.line.width + style.Section.line.beyondWidth + 1, - stroke: style.backgroundColor - } - }); - - const arrowTextX = model.intersection.x + 10; - const arrowTextY = model.intersection.y + 15; - const nameTextX = model.namePosition.x + model.intersection.x + this.triangle.drictx * (style.Section.line.width * 3 + style.Switch.switchNameDistance) * this.triangle.getCotRate(); - const nameTextY = model.namePosition.y + model.intersection.y + this.triangle.dricty * (style.Switch.switchNameDistance); - this.name = new ESwName({ - zlevel: this.zlevel, - z: this.z, - style: style, - arrowTextX: arrowTextX, - arrowTextY: arrowTextY, - nameTextX: nameTextX, - nameTextY: nameTextY, - sectionName: model.sectionName, - name: model.name, - nameShow: model.nameShow, - triangle: this.triangle - }); - - this.add(this.swCore); - this.add(this.locShelter); - this.add(this.relocShelter); - this.add(this.reserveSection); - this.add(this.releaseBackground); - this.add(this.name); - } - - /** 名称动画*/ - nameTextAnimation() { - this.name.getNameText().animateStyle(true) - .when(0, { textFill: this.style.backgroundColor }) - .when(1000, { textFill: this.style.Switch.switchTextLossColor }) - .when(2000, { textFill: this.style.backgroundColor }) - .start(); - - this.name.getTextRect().animateStyle(true) - .when(0, { textFill: this.style.backgroundColor }) - .when(1000, { textFill: this.style.Switch.switchTextBorderColor }) - .when(2000, { textFill: this.style.backgroundColor }) - .start(); - } - - /** 设置岔芯是否隐藏*/ - setSwitchCoreInvisible(invisible) { - if (invisible) { - this.swCore.hide(); - } else { - this.swCore.show(); - } - } - - /** 设置岔芯颜色*/ - setSwitchCoreColor(color) { - this.swCore.setColor(color); - } - - /** 设置道岔文字颜色*/ - setTextColor(color) { - this.name.getNameText().setStyle('textFill', color); - } - - /** 设置道岔文字边框颜色 */ - setHasTextBorder(width) { - this.name.getTextRect().setStyle('lineWidth', width); - } - - /** 恢复状态*/ - recover() { - this.setSwitchCoreColor(this.style.backgroundColor); - this.name.getNameText().stopAnimation(false); - this.reserveSection.stopAnimation(false); - this.swCore.stopAnimation(false); - - this.relocShelter.hide(); - this.releaseBackground.hide(); - - this.setHasTextBorder(0); - switch (this.state.locateType) { - case '01': - this.setTextColor(this.style.Switch.switchLocateTextColor); - break; - case '02': - this.setTextColor(this.style.Switch.switchInversionColor); - break; - default: - this.setTextColor(this.style.Switch.switchTextLossColor); - break; - } - } - - /** 定位*/ - setLocationAction() { - this.recover(); - this.setSwitchCoreInvisible(true); - this.locShelter.show(); - this.relocShelter.hide(); - this.reserveSection.hide(); - } - - /** 反位*/ - setInversionAction() { - this.recover(); - this.setSwitchCoreInvisible(true); - this.locShelter.hide(); - this.relocShelter.show(); - this.reserveSection.show(); - } - - /** 失去*/ - setLossAction(nameFlicker) { - this.recover(); - this.locShelter.hide(); - this.relocShelter.hide(); - this.reserveSection.hide(); - this.setSwitchCoreInvisible(false); - nameFlicker && this.nameTextAnimation(); - } - - /** 挤叉*/ - setForkAction() { - this.setLossAction(true); - this.swCore.animateStyle(item => { - item.animateStyle(true) - .when(0, { stroke: this.style.backgroundColor }) - .when(1000, { stroke: 'red' }) - .when(2000, { stroke: this.style.backgroundColor }) - .start(); - }); - } - - /** 空闲*/ - spare() { - } - - /** 单锁*/ - setMonolock() { - this.setTextColor(this.style.Switch.switchMonolockColor); - } - - /** 封锁 */ - block() { - this.setHasTextBorder(1); - } - - /** 延时释放*/ - timeRelease() { - this.setSwitchCoreInvisible(true); - this.releaseBackground.show(); - } - - /** 设置道岔切除*/ - setSwitchCutOff() { - this.setSwitchCoreInvisible(true); - switch (this.model.locateType) { - case '01': - this.releaseBackground.hide(); - this.setSectionState(this.release, 'stroke', this.model.sectionAstatus); - break; - case '02': - this.reserveSection.animateStyle(true) - .when(1000, { fill: this.style.backgroundColor }) - .start(); - break; - } - } - - setSectionState(section, style, state) { - if (section) { - switch (state) { - case '00': break; - case '01': /** 空闲*/ - section.setStyle(style, this.style.Section.line.spareColor); - break; - case '02': /** 通信车占用*/ - section.setStyle(style, this.style.Section.line.communicationOccupiedColor); - break; - case '03': /** 非通信车占用*/ - section.setStyle(style, this.style.Section.line.unCommunicationOccupiedColor); - break; - case '04': /** 进路锁闭*/ - section.setStyle(style, this.style.Section.line.routeLockColor); - break; - case '05': /** 故障锁闭*/ - section.setStyle(style, this.style.Section.line.faultLockColor); - break; - case '06': /** 封锁*/ - section.setStyle(style, this.style.Section.line.blockColor); - break; - case '07': /** ATC切除*/ - section.setStyle(style, this.style.Section.line.atcExcisionColor); - break; - case '08': /** ATS切除*/ - section.setStyle(style, this.style.Section.line.atsExcisionColor); - section.animateStyle(true) - .when(1000, { fill: this.style.backgroundColor }) - .when(2000, { fill: this.style.Section.line.atsExcisionColor }) - .start(); - break; - case '09': /** 进路延续保护 */ - section.setStyle(style, this.style.Section.line.protectiveLockColor); - break; - } - } - } - - setLocateType(state) { - this.setSectionState(this.reserveSection, 'fill', this.model.sectionCstatus); - switch (state.locateType) { - case '01': - this.setLocationAction(); /** 定位*/ - break; - case '02': - this.setInversionAction(); /** 反位*/ - break; - case '03': - this.setLossAction(true); /** 失去*/ - break; - case '04': - this.setForkAction(); /** 挤岔*/ - break; - } - } - - setState(state) { - this.setLocateType(state); - switch (state.status) { - case '01': - this.spare(); /** 空闲*/ - break; - case '10': - this.setMonolock(); /** 单锁*/ - break; - case '13': - this.timeRelease(); /** 延时释放*/ - break; - case '14': - this.block(); /** 封锁*/ - break; - } - - /** 区段切除*/ - if (state.cutOff) { - this.setSwitchCutOff(); - } - } - - getShapeTipPoint() { - let rect = null; - rect = this.name.getNameText().getBoundingRect(); - if (rect) { - return { - x: rect.x + rect.width / 2, - y: rect.y - }; - } - return null; - } -} diff --git a/src/jmap/shape/Switch/index.js b/src/jmap/shape/Switch/index.js index 472d39360..354d0730c 100644 --- a/src/jmap/shape/Switch/index.js +++ b/src/jmap/shape/Switch/index.js @@ -34,7 +34,7 @@ export default class Switch extends Group { let halfWidth = style.Section.line.width / 2; const switchWidth = style.Section.line.width + style.Section.line.beyondWidth*2 + 0.8; - const swPadding = style.Switch.switchLen; + const swPadding = style.Switch.core.switchLen; const directx = this.triangle.drictx; const directy = this.triangle.dricty; const direct = -this.triangle.drictx * this.triangle.dricty; @@ -113,8 +113,8 @@ export default class Switch extends Group { const arrowTextX = model.intersection.x + 10; const arrowTextY = model.intersection.y + 15; - const nameTextX = model.namePosition.x + model.intersection.x + this.triangle.drictx * (style.Section.line.width * 3 + style.Switch.switchNameDistance) * this.triangle.getCotRate(); - const nameTextY = model.namePosition.y + model.intersection.y + this.triangle.dricty * (style.Switch.switchNameDistance); + const nameTextX = model.namePosition.x + model.intersection.x + this.triangle.drictx * (style.Section.line.width * 3 + style.Switch.text.switchNameDistance) * this.triangle.getCotRate(); + const nameTextY = model.namePosition.y + model.intersection.y + this.triangle.dricty * (style.Switch.text.switchNameDistance); this.name = new ESwName({ zlevel: this.zlevel, z: this.z, @@ -140,13 +140,13 @@ export default class Switch extends Group { nameTextAnimation() { this.name.getNameText().animateStyle(true) .when(0, { textFill: this.style.backgroundColor }) - .when(1000, { textFill: this.style.Switch.switchTextLossColor }) + .when(1000, { textFill: this.style.Switch.text.switchTextLossColor }) .when(2000, { textFill: this.style.backgroundColor }) .start(); this.name.getTextRect().animateStyle(true) .when(0, { textFill: this.style.backgroundColor }) - .when(1000, { textFill: this.style.Switch.switchTextBorderColor }) + .when(1000, { textFill: this.style.Switch.text.switchTextBorderColor }) .when(2000, { textFill: this.style.backgroundColor }) .start(); } @@ -187,13 +187,13 @@ export default class Switch extends Group { this.setHasTextBorder(0); switch (this.state.locateType) { case '01': - this.setTextColor(this.style.Switch.switchLocateTextColor); + this.setTextColor(this.style.Switch.text.switchTextLocateColor); break; case '02': - this.setTextColor(this.style.Switch.switchInversionColor); + this.setTextColor(this.style.Switch.text.switchTextInversionColor); break; default: - this.setTextColor(this.style.Switch.switchTextLossColor); + this.setTextColor(this.style.Switch.text.switchTextLossColor); break; } } diff --git a/src/jmap/theme/batong.js b/src/jmap/theme/batong.js index 4960e0eb6..ec661bd56 100644 --- a/src/jmap/theme/batong.js +++ b/src/jmap/theme/batong.js @@ -235,7 +235,7 @@ class Batong extends defaultSkin { /** 道岔失去颜色*/ switchTextLossColor: '#FFFFFF', /** 道岔定位颜色*/ - switchLocateTextColor: '#00FF00', + switchTextLocateColor: '#00FF00', /** 道岔反位颜色*/ switchInversionColor: '#9C9D09', /** 道岔单锁颜色*/ diff --git a/src/jmap/theme/bejing.js b/src/jmap/theme/bejing.js index c1232ed7d..b698535bd 100644 --- a/src/jmap/theme/bejing.js +++ b/src/jmap/theme/bejing.js @@ -17,6 +17,7 @@ class Beijing extends defaultSkin { /** link 字体颜色*/ linkTextColor: '#FFFFFF' }; + this[deviceType.Section] = { text: { // 区段文字属性 fontSize: 10, // 字体大小 @@ -66,60 +67,87 @@ class Beijing extends defaultSkin { color: '#7F7F7F' // 区段边界符颜色 } }; + this[deviceType.Signal] = { - /** 信号机宽度 */ - signalR: 7, - /** 自动信号宽度*/ - signalAutoWidth: 5, - /** 延迟解锁字体大小*/ - signalDelayTextFontSize: 10, - /** 信号机名称字体大小*/ - signalTextFontSize: 12, - /** 灯柱宽度*/ - signalLampStandardWidth: 1.2, /** 设备距离区段的距离*/ signalDistance: 0, - /** 信号灯按钮距离区段的距离*/ - signalButtonDistance: 5, - /** 自动进路方向*/ - signalSigRouteDirection: false, - /** 自动进路偏移量*/ - signalSigRouteOffset: { x: 4, y: -2 }, - /** 自动通过方向*/ - signalSigPassDirection: true, - /** 自动通过偏移量*/ - signalSigPassOffset: { x: 4, y: 0}, - /** 延时解锁方向*/ - signalSigDelayDirection: false, - /** 延时解锁偏移量*/ - signalSigDelayOffset: { x: 0, y: -5}, - /** 信号灯按钮边线*/ - signalButtonDashColor: '#FFFFFF', - /** 信号灯按钮颜色*/ - signalButtonColor: 'darkgreen', - /** 信号灯按钮闪烁颜色*/ - signalButtonLightenColor: '#E4EF50', - /** 信号灯字体颜色*/ - signalTextRed: '#EF0C08', - /** 信号机字体绿色*/ - signalTextGreen: '#4DD43F', - /** 信号灯灯柱颜色*/ - signalLampStandardColor: '#5578B6', - /** 信号灯锁闭*/ - signalBlockColor: '#EF0C08', - /** 信号灯灰色*/ - signalLampGrayColor: '#7F7F7F', - /** 信号灯红色*/ - signalLampRedColor: '#FF0000', - /** 信号灯绿色*/ - signalLampGreenColor: '#00FF00', - /** 信号灯黄色*/ - signalLampYellowColor: '#FFFF00', - /** 信号灯白色*/ - signalLampWhiteColor: '#FFFFFF', - /** 信号灯蓝色*/ - signalLampBlueColor: '#0070C0' + post: { + /** 信号灯灯柱颜色*/ + signalLampStandardColor: '#5578B6', + signalLampStandardWidth: 1.5 + }, + text: { + /** 信号机名称字体大小*/ + signalTextFontSize: 12, + /** 信号灯字体默认色*/ + signalDefaultTextColor: '#C0C0C0', + /** 信号灯字体锁定颜色*/ + signalTextBlockColor: '#EF0C08' + }, + lamp: { + /** 禁止线宽度*/ + signalStopWidth: 2, + /** 信号灯边框线宽度*/ + signalBorderWidth: 0.5, + /** 信号灯边框线颜色*/ + signalBorderColor: '#3149C3', + /** 信号机宽度 */ + signalR: 7, + /** 信号灯锁闭*/ + signalBlockColor: '#EF0C08', + /** 信号灯灰色*/ + signalLampGrayColor: '#7F7F7F', + /** 信号灯红色*/ + signalLampRedColor: '#FF0000', + /** 信号灯绿色*/ + signalLampGreenColor: '#00FF00', + /** 信号灯黄色*/ + signalLampYellowColor: '#FFFF00', + /** 信号灯白色*/ + signalLampWhiteColor: '#FFFFFF', + /** 信号灯蓝色*/ + signalLampBlueColor: '#0070C0' + }, + route: { + /** 自动进路方向*/ + signalRouteDirection: false, + /** 自动进路偏移量*/ + signalRouteOffset: { x: 4, y: -2 }, + /** 自动进路*/ + signalRouteColor: '#00FF00' + }, + auto: { + /** 自动通过方向*/ + signalAutoDirection: true, + /** 自动通过偏移量*/ + signalAutoOffset: { x: 4, y: 0}, + /** 自动进路*/ + signalAutoRoute: '#00FF00', + /** 自动触发*/ + signalAutoTrigger: '#FFFF00' + }, + delay: { + /** 延迟解锁字体大小*/ + signalDelayTextFontSize: 9, + /** 延时解锁方向*/ + signalDelayDirection: false, + /** 延时解锁偏移量*/ + signalDelayOffset: { x: 0, y: -5}, + /** 延迟解锁颜色*/ + signalDelayTextColor: '#FF0000' + }, + button: { + /** 信号灯按钮距离区段的距离*/ + signalButtonDistance: 5, + /** 信号灯按钮边线*/ + signalButtonDashColor: '#FFFFFF', + /** 信号灯按钮颜色*/ + signalButtonColor: 'darkgreen', + /** 信号灯按钮闪烁颜色*/ + signalButtonLightenColor: '#E4EF50' + } }; + this[deviceType.StationStand] = { common: { // 通用属性 textFontSize: 8 // 站台默认字体大小 @@ -168,6 +196,7 @@ class Beijing extends defaultSkin { textColor: '#FFFFFF' // 停站等级字体颜色 } }; + this[deviceType.StationControl] = { singleControlNum: 3, stationOffset: {x: 20, y: 0}, @@ -187,24 +216,30 @@ class Beijing extends defaultSkin { /** 控制模式黄色*/ stationControlYellowColor: '#FFFF00' }; + this[deviceType.Station] = { kilometerPosition: 'down' // 公里标位置 }; + this[deviceType.Switch] = { - /** 道岔单边长度 */ - switchLen: 6, - /** 道岔名称与区段距离*/ - switchNameDistance: 2, - /** 道岔边框颜色*/ - switchTextBorderColor: '#FE0000', - /** 道岔失去颜色*/ - switchTextLossColor: '#FFFFFF', - /** 道岔定位颜色*/ - switchLocateTextColor: '#00FF00', - /** 道岔反位颜色*/ - switchInversionColor: '#9C9D09', - /** 道岔单锁颜色*/ - switchMonolockColor: '#870E10' + text: { + /** 道岔名称与区段距离*/ + switchNameDistance: 2, + /** 道岔边框颜色*/ + switchTextBorderColor: '#FE0000', + /** 道岔失去颜色*/ + switchTextLossColor: '#FFFFFF', + /** 道岔定位颜色*/ + switchTextLocateColor: '#00FF00', + /** 道岔反位颜色*/ + switchInversionColor: '#9C9D09', + /** 道岔单锁颜色*/ + switchMonolockColor: '#870E10' + }, + core: { + /** 道岔单边长度 */ + switchLen: 6 + } }; } } diff --git a/src/jmap/theme/chengdu.js b/src/jmap/theme/chengdu.js index c26a82b13..36166f9f5 100644 --- a/src/jmap/theme/chengdu.js +++ b/src/jmap/theme/chengdu.js @@ -238,7 +238,7 @@ class Beijing extends defaultSkin { /** 道岔失去颜色*/ switchTextLossColor: '#C00808', /** 道岔定位颜色*/ - switchLocateTextColor: '#08C008', + switchTextLocateColor: '#08C008', /** 道岔反位颜色*/ switchInversionColor: '#C0C000', /** 道岔单锁颜色*/ diff --git a/src/jmap/theme/fuzhou.js b/src/jmap/theme/fuzhou.js index 7d1e0c80f..fc6fcc8df 100644 --- a/src/jmap/theme/fuzhou.js +++ b/src/jmap/theme/fuzhou.js @@ -73,10 +73,10 @@ class Fuzhou extends defaultSkin { text: { /** 信号机名称字体大小*/ signalTextFontSize: 8, - /** 信号灯字体颜色*/ - signalTextRed: '#EF0C08', - /** 信号机字体绿色*/ - signalTextGreen: '#4DD43F' + /** 信号灯字体默认色*/ + signalDefaultTextColor: '#FFFFFF', + /** 信号灯字体锁定颜色*/ + signalTextBlockColor: '#EF0C08' }, lamp: { /** 禁止线宽度*/ @@ -212,20 +212,24 @@ class Fuzhou extends defaultSkin { kilometerPosition: 'up' }; this[deviceType.Switch] = { - /** 道岔单边长度 */ - switchLen: 6, - /** 道岔名称与区段距离*/ - switchNameDistance: 2, - /** 道岔边框颜色*/ - switchTextBorderColor: '#FE0000', - /** 道岔失去颜色*/ - switchTextLossColor: '#FFFFFF', - /** 道岔定位颜色*/ - switchLocateTextColor: '#00FF00', - /** 道岔反位颜色*/ - switchInversionColor: '#9C9D09', - /** 道岔单锁颜色*/ - switchMonolockColor: '#870E10' + text: { + /** 道岔名称与区段距离*/ + switchNameDistance: 2, + /** 道岔边框颜色*/ + switchTextBorderColor: '#FE0000', + /** 道岔失去颜色*/ + switchTextLossColor: '#FFFFFF', + /** 道岔定位颜色*/ + switchTextLocateColor: '#00FF00', + /** 道岔反位颜色*/ + switchInversionColor: '#9C9D09', + /** 道岔单锁颜色*/ + switchMonolockColor: '#870E10' + }, + core: { + /** 道岔单边长度 */ + switchLen: 6 + } }; } } diff --git a/src/views/jmap/index.vue b/src/views/jmap/index.vue index 388b424df..3619c1577 100644 --- a/src/views/jmap/index.vue +++ b/src/views/jmap/index.vue @@ -58,7 +58,7 @@ export default { // this.jmap.load({ skinVO: { code: '02' }, linkList: list }); - getPublishMapDetail('02').then(resp => { + getPublishMapDetail('03').then(resp => { this.jmap.setLevelVisible([deviceType.Link], false); this.jmap.load(resp.data); // this.jmap.setDefaultState(); From 8a4239a865773860f18d473db1694d8c6e2e65c7 Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Wed, 24 Jul 2019 10:13:01 +0800 Subject: [PATCH 14/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/shape/Signal/ESigAuto.js | 5 ++- src/jmap/shape/Signal/ESigButton.js | 2 +- src/jmap/shape/Signal/ESigDelay.js | 3 +- src/jmap/shape/Signal/ESigRoute.js | 3 +- src/jmap/shape/StationStand/EDetain.js | 45 +++++++++++--------- src/jmap/shape/StationStand/EJump.js | 45 +++++++++++--------- src/jmap/shape/StationStand/ELevel.js | 45 +++++++++++--------- src/jmap/shape/StationStand/EReentry.js | 34 +++++++++------ src/jmap/shape/StationStand/ESafeEmergent.js | 43 ++++++++++--------- src/jmap/shape/StationStand/ETime.js | 45 +++++++++++--------- 10 files changed, 151 insertions(+), 119 deletions(-) diff --git a/src/jmap/shape/Signal/ESigAuto.js b/src/jmap/shape/Signal/ESigAuto.js index c8877fde5..ffb55db8a 100644 --- a/src/jmap/shape/Signal/ESigAuto.js +++ b/src/jmap/shape/Signal/ESigAuto.js @@ -15,6 +15,8 @@ class ESigPass extends Group { const style = this.model.style; const rotation = model.drict != 1? 0 : Math.PI; const point = arrows(model.x, model.y, style.Signal.signalAutoWidth, style.Signal.lamp.signalR * 0.8); + + this.isNew = true; this.arrows = new Polygon({ zlevel: model.zlevel, z: model.z, @@ -29,7 +31,6 @@ class ESigPass extends Group { } }); this.add(this.arrows); - this.isNew = true; } } @@ -48,8 +49,10 @@ class ESigPass extends Group { // 箭头闪烁 arrowsAnimation() { this._create(); + const style = this.model.style; const fill = this.arrows.style.Signal.fill; + this.arrows.animate(true) .when(1000, { fill: style.backgroundColor, stroke: style.style.backgroundColor }) .when(2000, { fill: fill, stroke: style.style.Signal.sidelineColor }) diff --git a/src/jmap/shape/Signal/ESigButton.js b/src/jmap/shape/Signal/ESigButton.js index c7bcf3651..edf334cca 100644 --- a/src/jmap/shape/Signal/ESigButton.js +++ b/src/jmap/shape/Signal/ESigButton.js @@ -18,6 +18,7 @@ class ESigButton extends Group { const padding = 1; const r = style.Signal.lamp.signalR * 0.8; + this.isNew = true; this.sigNormalButtom = new Rect({ zlevel: model.zlevel, z: model.z, @@ -89,7 +90,6 @@ class ESigButton extends Group { this.add(this.sigNormalButtom); this.add(this.sigReentryButton); this.hide(); - this.isNew = true; } } diff --git a/src/jmap/shape/Signal/ESigDelay.js b/src/jmap/shape/Signal/ESigDelay.js index d9ced14da..5a19b00a6 100644 --- a/src/jmap/shape/Signal/ESigDelay.js +++ b/src/jmap/shape/Signal/ESigDelay.js @@ -11,6 +11,8 @@ class ESigDelay extends Group { _create() { if (!this.isNew) { const model = this.model; + + this.isNew = true; this.name = new Text({ _subType: model._subType, zlevel: model.zlevel, @@ -28,7 +30,6 @@ class ESigDelay extends Group { } }); this.add(this.name); - this.isNew = true; } } diff --git a/src/jmap/shape/Signal/ESigRoute.js b/src/jmap/shape/Signal/ESigRoute.js index eb09d95bd..797e8ee9a 100644 --- a/src/jmap/shape/Signal/ESigRoute.js +++ b/src/jmap/shape/Signal/ESigRoute.js @@ -13,6 +13,8 @@ class ESigDrict extends Group { if (!this.isNew) { const model = this.model; const style = this.model.style; + + this.isNew = true; this.sigDrict = new Polygon({ zlevel: model.zlevel, z: model.z, @@ -27,7 +29,6 @@ class ESigDrict extends Group { }); this.add(this.sigDrict); - this.isNew = true; } } diff --git a/src/jmap/shape/StationStand/EDetain.js b/src/jmap/shape/StationStand/EDetain.js index 6f5151221..629286219 100644 --- a/src/jmap/shape/StationStand/EDetain.js +++ b/src/jmap/shape/StationStand/EDetain.js @@ -5,40 +5,47 @@ class EDetain extends Group { constructor(model) { super(); this.model = model; - this._create(); + this.isNew = false; } _create() { - const model = this.model; - const style = this.model.style; - this.detain = new Text({ - zlevel: model.zlevel, - z: model.z, - position: [0, 0], - style: { - x: model.x, - y: model.y, - text: style.StationStand.detainCar.text, - textAlign: model.textAlign, - textVerticalAlign: model.textVerticalAlign, - fontSize: `${style.StationStand.stand.headFontSize} px ${style.textFontFormat}`, - textFill: style.StationStand.detainCar.centerTrainColor, - textStroke: style.backgroundColor - } - }); + if (!this.isNew) { + const model = this.model; + const style = this.model.style; - this.add(this.detain); + this.isNew = true; + this.detain = new Text({ + zlevel: model.zlevel, + z: model.z, + position: [0, 0], + style: { + x: model.x, + y: model.y, + text: style.StationStand.detainCar.text, + textAlign: model.textAlign, + textVerticalAlign: model.textVerticalAlign, + fontSize: `${style.StationStand.stand.headFontSize} px ${style.textFontFormat}`, + textFill: style.StationStand.detainCar.centerTrainColor, + textStroke: style.backgroundColor + } + }); + + this.add(this.detain); + } } setColor(color) { + this._create(); this.detain.setStyle('textFill', color); } hide() { + this._create(); this.detain.hide(); } show() { + this._create(); this.detain.show(); } } diff --git a/src/jmap/shape/StationStand/EJump.js b/src/jmap/shape/StationStand/EJump.js index 3794a2da7..95a7de585 100644 --- a/src/jmap/shape/StationStand/EJump.js +++ b/src/jmap/shape/StationStand/EJump.js @@ -5,46 +5,49 @@ class EJump extends Group { constructor(model) { super(); this.model = model; - this._create(); + this.isNew = false; } _create() { - const model = this.model; - const style = this.model.style; + if (!this.isNew) { + const model = this.model; + const style = this.model.style; - this.jump = new Text({ - zlevel: model.zlevel, - z: model.z, - style: { - x: model.x, - y: model.y, - text: model.name, - textFill: style.StationStand.level.textColor, - textAlign: 'middle', - textFont: `${style.StationStand.common.textFontSize} px ${style.textFontFormat}` - } - }); + this.isNew = true; + this.jump = new Text({ + zlevel: model.zlevel, + z: model.z, + style: { + x: model.x, + y: model.y, + text: model.name, + textFill: style.StationStand.level.textColor, + textAlign: 'middle', + textFont: `${style.StationStand.common.textFontSize} px ${style.textFontFormat}` + } + }); - this.add(this.jump); + this.add(this.jump); + } } setName(val) { - this.jump.attr({ - style: { - text: val - } - }); + this._create(); + this.jump.setStyle('text', val); } setColor(color) { + this._create(); this.jump.setStyle('textFill', color); } hide() { + this._create(); this.jump.hide(); } show() { + this._create(); this.jump.show(); } } diff --git a/src/jmap/shape/StationStand/ELevel.js b/src/jmap/shape/StationStand/ELevel.js index 851d83359..e932ebff8 100644 --- a/src/jmap/shape/StationStand/ELevel.js +++ b/src/jmap/shape/StationStand/ELevel.js @@ -5,46 +5,49 @@ class ELevel extends Group { constructor(model) { super(); this.model = model; - this._create(); + this.isNew = false; } _create() { - const model = this.model; - const style = this.model.style; + if (!this.isNew) { + const model = this.model; + const style = this.model.style; - this.level = new Text({ - zlevel: model.zlevel, - z: model.z, - style: { - x: model.x, - y: model.y, - text: model.name, - textFill: style.StationStand.level.textColor, - textAlign: 'middle', - textFont: `${style.StationStand.common.textFontSize} px ${style.textFontFormat}` - } - }); + this.isNew = true; + this.level = new Text({ + zlevel: model.zlevel, + z: model.z, + style: { + x: model.x, + y: model.y, + text: model.name, + textFill: style.StationStand.level.textColor, + textAlign: 'middle', + textFont: `${style.StationStand.common.textFontSize} px ${style.textFontFormat}` + } + }); - this.add(this.level); + this.add(this.level); + } } setName(val) { - this.level.attr({ - style: { - text: val - } - }); + this._create(); + this.level.setStyle('text', val); } setColor(color) { + this._create(); this.level.setStyle('textFill', color); } hide() { + this._create(); this.level.hide(); } show() { + this._create(); this.level.show(); } } diff --git a/src/jmap/shape/StationStand/EReentry.js b/src/jmap/shape/StationStand/EReentry.js index 5c4007fe4..c66534306 100644 --- a/src/jmap/shape/StationStand/EReentry.js +++ b/src/jmap/shape/StationStand/EReentry.js @@ -6,36 +6,42 @@ class EReentry extends Group { constructor(model) { super(); this.model = model; - this._create(); + this.isNew = false; } _create() { - const model = this.model; + if (!this.isNew) { + const model = this.model; - this.reentry = new Polygon({ - zlevel: model.zlevel, - z: model.z, - shape: { - points: flashlight(model.x, model.y, model.drict, 10, 5, 0, 0, 4) - }, - style: { - lineWidth: model.lineWidth, - fill: model.fill - } - }); + this.isNew = true; + this.reentry = new Polygon({ + zlevel: model.zlevel, + z: model.z, + shape: { + points: flashlight(model.x, model.y, model.drict, 10, 5, 0, 0, 4) + }, + style: { + lineWidth: model.lineWidth, + fill: model.fill + } + }); - this.add(this.reentry); + this.add(this.reentry); + } } setColor(color) { + this._create(); this.reentry.setStyle('textFill', color); } hide() { + this._create(); this.reentry.hide(); } show() { + this._create(); this.reentry.show(); } } diff --git a/src/jmap/shape/StationStand/ESafeEmergent.js b/src/jmap/shape/StationStand/ESafeEmergent.js index da2905c21..f6a829c4f 100644 --- a/src/jmap/shape/StationStand/ESafeEmergent.js +++ b/src/jmap/shape/StationStand/ESafeEmergent.js @@ -5,37 +5,42 @@ class ESafeEmergent extends Group { constructor(model) { super(); this.model = model; - this._create(); + this.isNew = false; } _create() { - const model = this.model; - const style = this.model.style; + if (!this.isNew) { + const model = this.model; + const style = this.model.style; - this.emergent = new Isogon({ - zlevel: model.zlevel, - z: model.z, - shape: { - x: model.x, - y: model.y, - r: model.r, - n: model.n - }, - style: { - lineWidth: 0, - stroke: style.StationStand.standEmergent.closeColor, - fill: style.StationStand.standEmergent.closeColor - } - }); + this.isNew = true; + this.emergent = new Isogon({ + zlevel: model.zlevel, + z: model.z, + shape: { + x: model.x, + y: model.y, + r: model.r, + n: model.n + }, + style: { + lineWidth: 0, + stroke: style.StationStand.standEmergent.closeColor, + fill: style.StationStand.standEmergent.closeColor + } + }); - this.add(this.emergent); + this.add(this.emergent); + } } hide() { + this._create(); this.emergent.hide(); } show() { + this._create(); this.emergent.show(); } } diff --git a/src/jmap/shape/StationStand/ETime.js b/src/jmap/shape/StationStand/ETime.js index cb2bef7f4..a9bb580f8 100644 --- a/src/jmap/shape/StationStand/ETime.js +++ b/src/jmap/shape/StationStand/ETime.js @@ -5,46 +5,49 @@ class ETime extends Group { constructor(model) { super(); this.model = model; - this._create(); + this.isNew = false; } _create() { - const model = this.model; - const style = this.model.style; + if (!this.isNew) { + const model = this.model; + const style = this.model.style; - this.time = new Text({ - zlevel: model.zlevel, - z: model.z, - style: { - x: model.x, - y: model.y, - text: model.name, - textFill: style.StationStand.stopTime.textColor, - textAlign: 'middle', - textFont: `${style.StationStand.common.textFontSize} px ${style.textFontFormat}` - } - }); + this.isNew = true; + this.time = new Text({ + zlevel: model.zlevel, + z: model.z, + style: { + x: model.x, + y: model.y, + text: model.name, + textFill: style.StationStand.stopTime.textColor, + textAlign: 'middle', + textFont: `${style.StationStand.common.textFontSize} px ${style.textFontFormat}` + } + }); - this.add(this.time); + this.add(this.time); + } } setName(val) { - this.time.attr({ - style: { - text: val - } - }); + this._create(); + this.time.setStyle('text', val); } setColor(color) { + this._create(); this.time.setStyle('textFill', color); } hide() { + this._create(); this.time.hide(); } show() { + this._create(); this.time.show(); } } From e06411df1c96c00379092523d95ed328dd88d0ae Mon Sep 17 00:00:00 2001 From: zyy <1787816799@qq.com> Date: Wed, 24 Jul 2019 11:12:15 +0800 Subject: [PATCH 15/19] =?UTF-8?q?desc:=20=E4=BF=AE=E6=94=B9section?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/shape/Section/ESeparator.js | 57 ++++++----- src/jmap/shape/Section/index.js | 140 +++++++++++---------------- 2 files changed, 86 insertions(+), 111 deletions(-) diff --git a/src/jmap/shape/Section/ESeparator.js b/src/jmap/shape/Section/ESeparator.js index 1ed793423..d2538fe68 100644 --- a/src/jmap/shape/Section/ESeparator.js +++ b/src/jmap/shape/Section/ESeparator.js @@ -10,23 +10,29 @@ export default class ESeparator extends Group { this.zlevel = model.zlevel; this.style = model.style; this.z = 6; - this._create(model); + this.setType(); } - _create(model) { + createModel(points, lineWidth = null, stroke = null) { + const model = this.model; this.partition = new Polyline({ zlevel: this.zlevel, progressive: model.progressive, z: this.z, shape: { - points: [] + points: points }, style: { - lineWidth: this.style.Section.separator.width, - stroke: this.style.Section.separator.color + lineWidth: lineWidth || this.style.Section.separator.width, + stroke: stroke || this.style.Section.separator.color } }); + this.add(this.partition); + } + // 创建 侵限分隔符 + createCircle() { + const model = this.model; this.circle = new Circle({ zlevel: this.zlevel, z: this.z, @@ -42,45 +48,38 @@ export default class ESeparator extends Group { fill: this.style.transparentColor } }); - - this.add(this.partition); - this.setType(); + this.add(this.circle); } setType() { const type = this.model.sepType; const model = this.model; if (model && this.style && model.traingle) { - this.remove(this.circle); - if (type === '00') { - this.partition.setShape('points', [ - [model.point.x, model.point.y], - [model.point.x, model.point.y] - ]); - } else if (type === '01') { - this.partition.setShape('points', [ + if (type === '01') { // 普通分割 + const points = [ [model.point.x, model.point.y - (this.style.Section.line.width)], [model.point.x, model.point.y + (this.style.Section.line.width)] - ]); - this.add(this.partition); - } else if (type === '02') { - this.partition.setShape('points', [ + ]; + this.createModel(points); + } else if (type === '02') { // 单侧分割符 + const points = [ [model.point.x + model.drict * (this.style.Section.line.width), model.point.y - (this.style.Section.line.width * 1.5)], [model.point.x, model.point.y - (this.style.Section.line.width * 1.5)], [model.point.x, model.point.y + (this.style.Section.line.width * 1.5)] - ]); - this.add(this.partition); - } else if (type === '03') { - this.partition.setShape('points', [ + ]; + this.createModel(points); + } else if (type === '03') { // 尽头分隔符 + const points = [ [model.point.x + model.drict * (this.style.Section.line.width) * 1.2, model.point.y - (this.style.Section.line.width * 1.2)], [model.point.x, model.point.y - (this.style.Section.line.width * 1.2)], [model.point.x, model.point.y + (this.style.Section.line.width * 1.2)], [model.point.x + model.drict * (this.style.Section.line.width) * 1.2, model.point.y + (this.style.Section.line.width * 1.2)] - ]); - this.add(this.partition); - this.partition.setStyle({'lineWidth': this.style.Section.separator.endWidth, 'stroke': this.style.Section.separator.endColor }); - } else if (type === '04') { - this.add(this.circle); + ]; + const lineWidth = this.style.Section.separator.endWidth; + const stroke = this.style.Section.separator.endColor; + this.createModel(points, lineWidth, stroke); + } else if (type === '04') { // 侵限分隔符 + this.createCircle(); } } diff --git a/src/jmap/shape/Section/index.js b/src/jmap/shape/Section/index.js index 13e79a268..37656405e 100644 --- a/src/jmap/shape/Section/index.js +++ b/src/jmap/shape/Section/index.js @@ -56,7 +56,13 @@ export default class Section extends Group { style: style }); - // 创建延时释放 + this.add(this.section); + } + + // 创建延时释放 (需要在创建) + creatRelease(stroke, lineWidth) { + const model = this.model; + const style = this.style; const traingle = new JTriangle(model.points[0], model.points[model.points.length - 1]); this.release = new ERelease({ @@ -69,16 +75,23 @@ export default class Section extends Group { x2: model.points[0].x + traingle.getCos(traingle.absz / 3 * 2), y2: model.points[0].y + traingle.getSin(traingle.absz / 3 * 2) }, - lineWidth: style.Section.line.width, - stroke: style.Section.line.spareColor + lineWidth: lineWidth || style.Section.line.width, + stroke: stroke || style.Section.line.spareColor }); + this.add(this.release); + } + + // 创建限速线 (需要在创建) + creatSpeedLimit() { + const model = this.model; + const style = this.style; + const traingle = new JTriangle(model.points[0], model.points[model.points.length - 1]); let x = traingle.drictx * (style.Section.speedLimit.Distance) * traingle.getSinRate(); let y = traingle.dricty * (style.Section.speedLimit.Distance) * traingle.getCosRate(); if (x == Infinity) { x = 0; } if (y == Infinity) { y = 0; } - // 创建限速线 this.speedLimitLeft = new ELimitLines({ zlevel: this.zlevel, z: this.z, @@ -90,20 +103,6 @@ export default class Section extends Group { relSwitchCode: model.relSwitchCode, isCurve: model.isCurve, // 是否曲线 points: model.points - // isLine: true, - // culling: model.isCurve, // 是否裁剪 - // shape: { - // points: model.points, - // isCurve: model.isCurve, // 是否曲线 - // isSwitchSection: model.isSwitchSection, - // relSwitchCode: model.relSwitchCode, - // switch: model.switch, - // style: style - // }, - // style: { - // lineWidth: style.Section.speedLimit.width, - // stroke: style.Section.speedLimit.lineColor - // } }); this.speedLimitRight = new ELimitLines({ @@ -117,29 +116,13 @@ export default class Section extends Group { relSwitchCode: model.relSwitchCode, isCurve: model.isCurve, // 是否曲线 points: model.points - // isLine: true, - // culling: model.isCurve, // 是否裁剪 - // shape: { - // points: model.points, - // isCurve: model.isCurve, // 是否曲线 - // isSwitchSection: model.isSwitchSection, - // relSwitchCode: model.relSwitchCodes, - // switch: model.switch, - // style: style - // }, - // style: { - // lineWidth: style.Section.speedLimit.width, - // stroke: style.Section.speedLimit.lineColor - // } }); - this.add(this.section); - this.add(this.release); this.add(this.speedLimitLeft); this.add(this.speedLimitRight); } - /** 创建区段名称*/ + // 创建区段名称 createSectionText() { const model = this.model; const style = this.style; @@ -287,7 +270,7 @@ export default class Section extends Group { } } - /** 创建计轴*/ + // 创建计轴 (需要在创建) createAxles() { const model = this.model; const style = this.style; @@ -378,7 +361,7 @@ export default class Section extends Group { } } - /** 创建分隔符*/ + // 创建分隔符 (内层需要在创建) createSeparator() { const model = this.model; const style = this.style; @@ -439,9 +422,13 @@ export default class Section extends Group { lineWidth: this.style.Section.line.width }); - this.release.hide(); - // this.speedLimitLeft.hide(); - // this.speedLimitRight.hide(); + if (this.release) { + this.remove(this.release); + } + if (this.speedLimitLeft && this.speedLimitRight) { + this.remove(this.speedLimitLeft); + this.remove(this.speedLimitRight); + } } } @@ -548,66 +535,55 @@ export default class Section extends Group { /** 延时释放 10*/ timeRelease() { - if (this.release) { - this.section.setStyle({ - stroke: this.style.Section.line.routeLockColor, - lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth - }); - this.release.show(); - this.release.setStyle('lineWidth', this.style.Section.line.width + this.style.Section.line.beyondWidth); - this.release.setStyle('stroke', this.style.Section.line.routeLockColor); - this.release.animateStyle(true) - .when(1000, { stroke: this.style.Section.line.routeLockColor }) - .when(2000, { stroke: this.style.Section.line.timeReleaseColor }) - .start(); - } + const lineWidth = this.style.Section.line.width + this.style.Section.line.beyondWidth; + const stroke = this.style.Section.line.routeLockColor; + this.creatRelease(stroke, lineWidth); + this.section.setStyle({ + stroke: this.style.Section.line.routeLockColor, + lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth + }); + this.release.animateStyle(true) + .when(1000, { stroke: this.style.Section.line.routeLockColor }) + .when(2000, { stroke: this.style.Section.line.timeReleaseColor }) + .start(); } /** 保护区段延时解锁 11*/ protectiveTimeRelease() { - if (this.release) { - this.section.setStyle({ - stroke: this.style.Section.line.protectiveLockColor, - lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth - }); - this.release.show(); - this.release.setStyle('lineWidth', this.style.Section.line.width + this.style.Section.line.beyondWidth); - this.release.setStyle('stroke', this.style.Section.line.protectiveLockColor); - this.release.animateStyle(true) - .when(1000, { stroke: this.style.Section.line.protectiveLockColor }) - .when(2000, { stroke: this.style.Section.line.protectiveTimeReleaseColor }) - .start(); - } + const lineWidth = this.style.Section.line.width + this.style.Section.line.beyondWidth; + const stroke = this.style.Section.line.protectiveLockColor; + this.creatRelease(stroke, lineWidth); + this.section.setStyle({ + stroke: this.style.Section.line.protectiveLockColor, + lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth + }); + this.release.animateStyle(true) + .when(1000, { stroke: this.style.Section.line.protectiveLockColor }) + .when(2000, { stroke: this.style.Section.line.protectiveTimeReleaseColor }) + .start(); } /** 区段切除*/ sectionCutOff() { - if (this.release) { - const lineWidth = this.style.Section.line.width + (this.model.status != '01' ? this.style.Section.line.beyondWidth : 0); - this.section.animateStyle(true, [ - { time: 0, styles: { lineWidth: lineWidth } }, - { time: 1000, styles: { stroke: this.style.backgroundColor } }, - { time: 2000, styles: { lineWidth: lineWidth } } - ]); - } + const lineWidth = this.style.Section.line.width + (this.model.status != '01' ? this.style.Section.line.beyondWidth : 0); + this.section.animateStyle(true, [ + { time: 0, styles: { lineWidth: lineWidth } }, + { time: 1000, styles: { stroke: this.style.backgroundColor } }, + { time: 2000, styles: { lineWidth: lineWidth } } + ]); } /** 设置限速*/ setSpeedUpperLimit() { if (this.section) { - this.speedLimitLeft.show(); - this.speedLimitRight.show(); + this.creatSpeedLimit(); } } /** 计轴预复位 12*/ axleReset() { - if (this.release) { - this.release.show(); - this.release.setStyle({ - stroke: this.style.Section.axle.resetColor - }); - } + const stroke = this.style.Section.axle.resetColor; + this.creatRelease(stroke, null); } /** 计轴失效 13*/ From e8dad49c5fb9255e19c078a596dd0f2ff6de5c8b Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Wed, 24 Jul 2019 11:24:13 +0800 Subject: [PATCH 16/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/shape/Section/index.js | 28 +++++++++++++++++++--------- src/jmap/shape/Signal/ESigName.js | 5 +++-- src/jmap/shape/Signal/index.js | 4 +++- src/jmap/shape/Station/index.js | 8 ++++++-- src/jmap/shape/element/ETextName.js | 5 +++-- src/jmap/theme/bejing.js | 8 ++++---- src/jmap/theme/fuzhou.js | 5 ++--- src/views/jmap/index.vue | 2 +- 8 files changed, 41 insertions(+), 24 deletions(-) diff --git a/src/jmap/shape/Section/index.js b/src/jmap/shape/Section/index.js index 13e79a268..13276bf3c 100644 --- a/src/jmap/shape/Section/index.js +++ b/src/jmap/shape/Section/index.js @@ -183,20 +183,22 @@ export default class Section extends Group { } // 创建区段名称 - const fontSize = style.type == '02' ? style.Section.text.fontSize + 2 : style.Section.text.fontSize; + const fontSize = model.type == '02' ? style.Section.text.fontSize + 2: style.Section.text.fontSize; this.sectionText = new ETextName({ - _subType: 'Text', zlevel: this.zlevel, z: this.z + 6, + style: this.style, + silent: false, x: tempx, y: tempy, + fontWeight: 'bold', + fontSize: fontSize, + fontFamily: style.textFontFormat, text: model.name, - textFont: fontSize + 'px ' + style.Section.text.fontFormat, textFill: style.Section.text.fontColor, textAlign: style.Section.text.textAlign, textPosition: style.Section.text.textPosition, - textVerticalAlign: style.Section.text.textVerticalAlign, - style: this.style + textVerticalAlign: style.Section.text.textVerticalAlign }); this.add(this.sectionText); } @@ -217,8 +219,10 @@ export default class Section extends Group { z: 6, x: tempx + model.standTrackNamePosition.x, y: tempy + model.standTrackNamePosition.y, + fontWeight: 'bold', + fontSize: style.Section.text.fontSize, + fontFamily: style.textFontFormat, text: model.standTrackName, - textFont: style.Section.text.fontSize + 'px ' + style.Section.text.fontFormat, textFill: style.Section.text.fontColor, textAlign: style.Section.text.textAlign, textPosition: style.Section.text.textPosition, @@ -236,8 +240,10 @@ export default class Section extends Group { z: 6, x: x + model.reentryTrackNamePosition.x, y: y + model.reentryTrackNamePosition.y + style.nameDistance + style.Section.text.fontSize, + fontWeight: 'bold', + fontSize: style.Section.text.fontSize, + fontFamily: style.textFontFormat, text: model.reentryTrackName, - textFont: style.Section.text.fontSize + 'px ' + style.Section.text.fontFormat, textFill: style.Section.text.fontColor, textAlign: style.Section.text.textAlign, textPosition: style.Section.text.textPosition, @@ -255,8 +261,10 @@ export default class Section extends Group { z: 6, x: x + model.transferTrackNamePosition.x, y: y + model.transferTrackNamePosition.y + style.nameDistance + style.Section.text.fontSize * 2, + fontWeight: 'bold', + fontSize: style.Section.text.fontSize, + fontFamily: style.textFontFormat, text: model.transferTrackName, - textFont: style.Section.text.fontSize + 'px ' + style.Section.text.fontFormat, textFill: style.Section.text.fontColor, textAlign: style.Section.text.textAlign, textPosition: style.Section.text.textPosition, @@ -274,8 +282,10 @@ export default class Section extends Group { z: 6, x: x + model.destinationCodePoint.x, y: y + model.destinationCodePoint.y, + fontWeight: 'bold', + fontSize: style.Section.text.fontSize, + fontFamily: style.textFontFormat, text: model.destinationCode, - textFont: style.Section.text.fontSize + 'px ' + style.Section.text.fontFormat, textFill: style.destinationTextFontColor, textAlign: style.Section.text.textAlign, textPosition: style.Section.text.textPosition, diff --git a/src/jmap/shape/Signal/ESigName.js b/src/jmap/shape/Signal/ESigName.js index 785cf1aac..0466a0d4b 100644 --- a/src/jmap/shape/Signal/ESigName.js +++ b/src/jmap/shape/Signal/ESigName.js @@ -11,15 +11,16 @@ class ESigName extends Group { _create() { const model = this.model; this.name = new Text({ - _subType: model._subType, zlevel: model.zlevel, z: model.z, silent: model.silent, style: { x: model.x, y: model.y, + fontWeight: model.fontWeight, + fontSize: model.fontSize, + fontFamily: model.fontFamily, text: model.text, - textFont: model.textFont, textFill: model.textFill, textAlign: model.textAlign, textPosition: model.textPosition || 'inside', diff --git a/src/jmap/shape/Signal/index.js b/src/jmap/shape/Signal/index.js index 7a1afeac4..97f06cae3 100644 --- a/src/jmap/shape/Signal/index.js +++ b/src/jmap/shape/Signal/index.js @@ -75,7 +75,9 @@ class Signal extends Group { x: sigNameX, y: sigNameY, text: model.name, - textFont: `bold ${style.Signal.text.signalTextFontSize} px ${style.textFontFormat}`, + fontWeight: 'bold', + fontSize: style.Signal.text.signalTextFontSize, + fontFamily: style.textFontFormat, textFill: style.Signal.text.signalDefaultTextColor, textAlign: 'middle', textVerticalAlign: posit == 1 ? 'top' : 'bottom' diff --git a/src/jmap/shape/Station/index.js b/src/jmap/shape/Station/index.js index 1b1b3deda..f6d88f7de 100644 --- a/src/jmap/shape/Station/index.js +++ b/src/jmap/shape/Station/index.js @@ -29,10 +29,12 @@ export default class Station extends Group { position: [0, 0], x: model.position.x, y: model.position.y, + fontWeight: 'bold', + fontSize: model.nameFont || 18, + fontFamily: style.textFontFormat, text: model.name, textAlign: 'middle', textVerticalAlign: 'top', - textFont: model.nameFont || '18px ' + style.textFontFormat, textFill: model.nameFontColor }); let direction = 1; @@ -45,10 +47,12 @@ export default class Station extends Group { position: [0, 0], x: model.position.x, y: model.position.y + ((parseInt(model.nameFont) + 2) * direction), + fontWeight: 'bold', + fontSize: model.kmPostFont || 18, + fontFamily: style.textFontFormat, text: model.kmPost, textAlign: 'middle', textVerticalAlign: 'top', - textFont: model.kmPostFont || '18px ' + style.textFontFormat, textFill: model.kmPostFontColor }); diff --git a/src/jmap/shape/element/ETextName.js b/src/jmap/shape/element/ETextName.js index 6e229f491..8ac278413 100644 --- a/src/jmap/shape/element/ETextName.js +++ b/src/jmap/shape/element/ETextName.js @@ -4,15 +4,16 @@ import Text from 'zrender/src/graphic/Text'; /** 名称元素*/ export default function ETextName(model) { const TextName = new Text({ - _subType: model._subType, zlevel: model.zlevel, z: model.z, silent: model.silent || false, style: { x: model.x, y: model.y, + fontWeight: model.fontWeight, + fontSize: model.fontSize, + fontFamily: model.fontFamily, text: model.text, - textFont: model.textFont, textFill: model.textFill, textAlign: model.textAlign, textPosition: model.textPosition || 'inside', diff --git a/src/jmap/theme/bejing.js b/src/jmap/theme/bejing.js index b698535bd..ff8e68b14 100644 --- a/src/jmap/theme/bejing.js +++ b/src/jmap/theme/bejing.js @@ -61,8 +61,8 @@ class Beijing extends defaultSkin { lineColor: '#FFFF00' // 限速线颜色 }, separator: { - width: 1.2, // 分隔符宽度 - endWidth: 1.2, // 尽头分隔符宽度 + width: 1.5, // 分隔符宽度 + endWidth: 1.5, // 尽头分隔符宽度 endColor: '#7F7F7F', // 尽头分隔符颜色 color: '#7F7F7F' // 区段边界符颜色 } @@ -78,7 +78,7 @@ class Beijing extends defaultSkin { }, text: { /** 信号机名称字体大小*/ - signalTextFontSize: 12, + signalTextFontSize: 10, /** 信号灯字体默认色*/ signalDefaultTextColor: '#C0C0C0', /** 信号灯字体锁定颜色*/ @@ -92,7 +92,7 @@ class Beijing extends defaultSkin { /** 信号灯边框线颜色*/ signalBorderColor: '#3149C3', /** 信号机宽度 */ - signalR: 7, + signalR: 6, /** 信号灯锁闭*/ signalBlockColor: '#EF0C08', /** 信号灯灰色*/ diff --git a/src/jmap/theme/fuzhou.js b/src/jmap/theme/fuzhou.js index fc6fcc8df..51b279f65 100644 --- a/src/jmap/theme/fuzhou.js +++ b/src/jmap/theme/fuzhou.js @@ -17,8 +17,7 @@ class Fuzhou extends defaultSkin { this[deviceType.Section] = { text: { // 区段文字属性 fontSize: 10, // 字体大小 - fontFormat: 'consolas', // 字体族类 - fontColor: '#C0C0C0', // 字体颜色 + fontColor: '#FFFFFF', // 字体颜色 textAlign: 'center', // 水平对齐方式 textPosition: 'inside', // 文字位置 textVerticalAlign: 'middle', // 文字垂直对齐方式 @@ -72,7 +71,7 @@ class Fuzhou extends defaultSkin { }, text: { /** 信号机名称字体大小*/ - signalTextFontSize: 8, + signalTextFontSize: 10, /** 信号灯字体默认色*/ signalDefaultTextColor: '#FFFFFF', /** 信号灯字体锁定颜色*/ diff --git a/src/views/jmap/index.vue b/src/views/jmap/index.vue index 3619c1577..388b424df 100644 --- a/src/views/jmap/index.vue +++ b/src/views/jmap/index.vue @@ -58,7 +58,7 @@ export default { // this.jmap.load({ skinVO: { code: '02' }, linkList: list }); - getPublishMapDetail('03').then(resp => { + getPublishMapDetail('02').then(resp => { this.jmap.setLevelVisible([deviceType.Link], false); this.jmap.load(resp.data); // this.jmap.setDefaultState(); From 2b8afd0010f86168a95fdc418fb81ce6ad5fe26a Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Wed, 24 Jul 2019 13:02:19 +0800 Subject: [PATCH 17/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/jmap/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/jmap/index.vue b/src/views/jmap/index.vue index 388b424df..3619c1577 100644 --- a/src/views/jmap/index.vue +++ b/src/views/jmap/index.vue @@ -58,7 +58,7 @@ export default { // this.jmap.load({ skinVO: { code: '02' }, linkList: list }); - getPublishMapDetail('02').then(resp => { + getPublishMapDetail('03').then(resp => { this.jmap.setLevelVisible([deviceType.Link], false); this.jmap.load(resp.data); // this.jmap.setDefaultState(); From dfd337e93f13569f30563388d647d02d130e4068 Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Wed, 24 Jul 2019 13:50:37 +0800 Subject: [PATCH 18/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=97=E4=BD=93?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/shape/ImageControl/index.js | 1 - src/jmap/shape/LcControl/index.js | 6 ++++-- src/jmap/shape/LimitControl/index.js | 6 ++++-- src/jmap/shape/Signal/ESigDelay.js | 4 +++- src/jmap/shape/Signal/index.js | 7 +++++-- src/jmap/shape/StationControl/ESingleControl.js | 4 +++- src/jmap/shape/StationCounter/index.js | 12 ++++++++---- src/jmap/shape/StationDelayUnlock/index.js | 8 ++++++-- src/jmap/shape/StationStand/EJump.js | 6 ++++-- src/jmap/shape/StationStand/ELevel.js | 6 ++++-- src/jmap/shape/StationStand/ETime.js | 6 ++++-- src/jmap/shape/Switch/ESwName.js | 8 ++++++-- src/jmap/shape/Train/index.js | 14 +++++++------- src/jmap/shape/ZcControl/index.js | 6 ++++-- src/jmap/shape/element/EControl.js | 6 ++++-- src/jmap/theme/bejing.js | 8 +++++--- src/jmap/theme/fuzhou.js | 2 ++ 17 files changed, 73 insertions(+), 37 deletions(-) diff --git a/src/jmap/shape/ImageControl/index.js b/src/jmap/shape/ImageControl/index.js index 5e8e2fe71..b8dcca88a 100644 --- a/src/jmap/shape/ImageControl/index.js +++ b/src/jmap/shape/ImageControl/index.js @@ -7,7 +7,6 @@ import Image from 'zrender/src/graphic/Image'; export default class ImageControl extends Group { constructor({ _code, _type, zlevel, model, state }, style) { super(); - console.log(model); this._code = _code; this._type = _type; this.zlevel = zlevel; diff --git a/src/jmap/shape/LcControl/index.js b/src/jmap/shape/LcControl/index.js index dee4483dc..c19f4dec7 100644 --- a/src/jmap/shape/LcControl/index.js +++ b/src/jmap/shape/LcControl/index.js @@ -36,11 +36,13 @@ export default class LcControl extends Group { position: [0, 0], x: model.position.x, y: model.position.y + this.style.zcControlmodeR + this.style.nameDistance, + fontWeight: 'normal', + fontSize: this.style.stationControlTextSize, + fontFamily: this.style.textFontFormat, text: model.name, textFill: '#fff', textAlign: 'middle', - textVerticalAlign: 'top', - textFont: this.style.stationControlTextSize + 'px ' + this.style.textFontFormat + textVerticalAlign: 'top' }, style: this.style }); diff --git a/src/jmap/shape/LimitControl/index.js b/src/jmap/shape/LimitControl/index.js index 911270fba..226dac902 100644 --- a/src/jmap/shape/LimitControl/index.js +++ b/src/jmap/shape/LimitControl/index.js @@ -35,11 +35,13 @@ export default class LimitControl extends Group { position: [0, 0], x: model.position.x, y: model.position.y + this.style.zcControlmodeR + this.style.nameDistance, + fontWeight: 'normal', + fontSize: this.style.stationControlTextSize, + fontFamily: this.style.textFontFormat, text: model.name, textFill: '#fff', textAlign: 'middle', - textVerticalAlign: 'top', - textFont: this.style.stationControlTextSize + 'px ' + this.style.textFontFormat + textVerticalAlign: 'top' }, style: this.style }); diff --git a/src/jmap/shape/Signal/ESigDelay.js b/src/jmap/shape/Signal/ESigDelay.js index 5a19b00a6..133b3702d 100644 --- a/src/jmap/shape/Signal/ESigDelay.js +++ b/src/jmap/shape/Signal/ESigDelay.js @@ -21,8 +21,10 @@ class ESigDelay extends Group { style: { x: model.x, y: model.y, + fontWeight: model.fontWeight, + fontSize: model.fontSize, + fontFamily: model.fontFamily, text: model.text, - textFont: model.textFont, textFill: model.textFill, textAlign: model.textAlign, textPosition: model.textPosition || 'inside', diff --git a/src/jmap/shape/Signal/index.js b/src/jmap/shape/Signal/index.js index 97f06cae3..21633b993 100644 --- a/src/jmap/shape/Signal/index.js +++ b/src/jmap/shape/Signal/index.js @@ -71,6 +71,7 @@ class Signal extends Group { zlevel: this.zlevel, z: this.z, silent: false, + isNoRotation: style.Signal.text.isNoRotation, style: style, x: sigNameX, y: sigNameY, @@ -124,8 +125,10 @@ class Signal extends Group { style: style, x: sigDelayX, y: sigDelayY, + fontWeight: 'bold', + fontSize: style.Signal.delay.signalDelayTextFontSize, + fontFamily: style.textFontFormat, text: this.state.delayCount || '0', - textFont: `bold ${style.Signal.delay.signalDelayTextFontSize} px ${style.textFontFormat}`, textFill: style.Signal.delay.signalDelayTextColor, textAlign: drict > 0 ? 'right' : 'left', textVerticalAlign: 'middle' @@ -157,7 +160,7 @@ class Signal extends Group { device.eachChild(item => { if (item instanceof Group) { this.transformRotation(item); - } else { + } else if (item && item.model && item.model.isNoRotation) { item.origin = [this.model.position.x, this.model.position.y]; item.rotation = -Math.PI / 180 * Number(this.model.rotate); item.dirty(); diff --git a/src/jmap/shape/StationControl/ESingleControl.js b/src/jmap/shape/StationControl/ESingleControl.js index 781511ef3..3c8f78cc1 100644 --- a/src/jmap/shape/StationControl/ESingleControl.js +++ b/src/jmap/shape/StationControl/ESingleControl.js @@ -48,9 +48,11 @@ export default class ESingleControl extends Group { style: { x: model.point.x, y: model.point.y + model.style.StationControl.stationControlmodeR + model.style.nameDistance, + fontWeight: 'normal', + fontSize: model.style.textFontSize, + fontFamily: model.style.textFontFormat, text: model.context, textFill: model.style.textFontColor, - textFont: model.style.textFontSize + 'px ' + model.style.textFontFormat, textAlign: 'middle', textVerticalAlign: 'top' } diff --git a/src/jmap/shape/StationCounter/index.js b/src/jmap/shape/StationCounter/index.js index 65c3cba98..61998e00a 100644 --- a/src/jmap/shape/StationCounter/index.js +++ b/src/jmap/shape/StationCounter/index.js @@ -29,11 +29,13 @@ export default class StationCounter extends Group { style: { x: model.position.x, y: model.position.y, + fontWeight: 'normal', + fontSize: style.textFontSize, + fontFamily: style.textFontFormat, text: model.val, textFill: style.stationCounterTextColor, textAlign: 'middle', - textStrokeWidth: 1, - textFont: style.textFontSize + 'px ' + style.textFontFormat + textStrokeWidth: 1 } }); @@ -64,12 +66,14 @@ export default class StationCounter extends Group { style: { x: model.position.x, y: model.position.y + this.rect.width + this.vPadding + style.textFontSize + style.nameDistance, + fontWeight: 'bold', + fontSize: style.textFontSize, + fontFamily: style.textFontFormat, text: model.name, textFill: style.stationCounterTextColor, textAlign: 'middle', textVerticalAlign: 'top', - textStrokeWidth: 1, - textFont: style.textFontSize + 'px ' + style.textFontFormat + textStrokeWidth: 1 } }); this.add(this.counterName); diff --git a/src/jmap/shape/StationDelayUnlock/index.js b/src/jmap/shape/StationDelayUnlock/index.js index f5e14ad1f..96ff6169f 100644 --- a/src/jmap/shape/StationDelayUnlock/index.js +++ b/src/jmap/shape/StationDelayUnlock/index.js @@ -29,10 +29,12 @@ export default class StationDelayUnlock extends Group { style: { x: model.position.x, y: model.position.y, + fontWeight: 'normal', + fontSize: model.textFont, + fontFamily: style.textFontFormat, text: model.deviceName + ' ', textFill: style.stationDelayUnlockTextColor, textStrokeWidth: 1, - textFont: model.textFont + 'px ' + style.textFontFormat, textAlign: 'left' } }); @@ -45,10 +47,12 @@ export default class StationDelayUnlock extends Group { style: { x: model.position.x, y: model.position.y + fontSize + style.stationDelayUnlockDistance, + fontWeight: 'normal', + fontSize: model.textFont, + fontFamily: style.textFontFormat, text: model.remainTime || '', textFill: style.stationDelayUnlockTextColor, textStrokeWidth: 1, - textFont: model.textFont + 'px ' + style.textFontFormat, textAlign: 'left' } }); diff --git a/src/jmap/shape/StationStand/EJump.js b/src/jmap/shape/StationStand/EJump.js index 95a7de585..ef1f97cde 100644 --- a/src/jmap/shape/StationStand/EJump.js +++ b/src/jmap/shape/StationStand/EJump.js @@ -20,10 +20,12 @@ class EJump extends Group { style: { x: model.x, y: model.y, + fontWeight: 'normal', + fontSize: style.StationStand.common.textFontSize, + fontFamily: style.textFontFormat, text: model.name, textFill: style.StationStand.level.textColor, - textAlign: 'middle', - textFont: `${style.StationStand.common.textFontSize} px ${style.textFontFormat}` + textAlign: 'middle' } }); diff --git a/src/jmap/shape/StationStand/ELevel.js b/src/jmap/shape/StationStand/ELevel.js index e932ebff8..e346f4093 100644 --- a/src/jmap/shape/StationStand/ELevel.js +++ b/src/jmap/shape/StationStand/ELevel.js @@ -20,10 +20,12 @@ class ELevel extends Group { style: { x: model.x, y: model.y, + fontWeight: 'normal', + fontSize: style.StationStand.common.textFontSize, + fontFamily: style.textFontFormat, text: model.name, textFill: style.StationStand.level.textColor, - textAlign: 'middle', - textFont: `${style.StationStand.common.textFontSize} px ${style.textFontFormat}` + textAlign: 'middle' } }); diff --git a/src/jmap/shape/StationStand/ETime.js b/src/jmap/shape/StationStand/ETime.js index a9bb580f8..c7127a029 100644 --- a/src/jmap/shape/StationStand/ETime.js +++ b/src/jmap/shape/StationStand/ETime.js @@ -20,10 +20,12 @@ class ETime extends Group { style: { x: model.x, y: model.y, + fontWeight: 'normal', + fontSize: style.StationStand.common.textFontSize, + fontFamily: style.textFontFormat, text: model.name, textFill: style.StationStand.stopTime.textColor, - textAlign: 'middle', - textFont: `${style.StationStand.common.textFontSize} px ${style.textFontFormat}` + textAlign: 'middle' } }); diff --git a/src/jmap/shape/Switch/ESwName.js b/src/jmap/shape/Switch/ESwName.js index c6fa4c741..2cea8f83f 100644 --- a/src/jmap/shape/Switch/ESwName.js +++ b/src/jmap/shape/Switch/ESwName.js @@ -19,10 +19,12 @@ class ESwName extends Group { style: { x: model.nameTextX, y: model.nameTextY, + fontWeight: 'normal', + fontSize: style.textFontSize, + fontFamily: style.textFontFormat, text: model.name, textAlign: model.triangle.drictx === 1 ? 'left' : 'right', textVerticalAlign: model.triangle.dricty === 1 ? 'top' : 'bottom', - textFont: style.textFontSize + 'px ' + style.textFontFormat, textFill: style.Switch.text.switchTextLossColor } }); @@ -58,10 +60,12 @@ class ESwName extends Group { style: { x: model.arrowTextX, y: model.arrowTextY, + fontWeight: 'normal', + fontSize: 10, + fontFamily: style.textFontFormat, text: `道岔区段名称: ${model.sectionName}`, textFill: '#000', textAlign: 'letf', - textFont: 10 + 'px consolas', textPadding: 3, textBackgroundColor: style.tipBackgroundColor } diff --git a/src/jmap/shape/Train/index.js b/src/jmap/shape/Train/index.js index d6208bc7c..d86e815bc 100644 --- a/src/jmap/shape/Train/index.js +++ b/src/jmap/shape/Train/index.js @@ -35,10 +35,10 @@ class TrainBody extends Group { style: { x: model.point.x + 50, y: model.point.y + 25, + font: 10 + 'px consolas', text: `列车类型: 计划车\n表\0\0\0\0号: ${model.serviceNumber}\n车\0次\0号: ${model.tripNumber}\n目的地号: ${model.targetCode ? model.targetCode : ''}\n车\0组\0号: ${model.groupNumber}\n早\0晚\0点: ${destinationText}\n运行方向: ${model.directionType == '02' ? '上行' : '下行'}\n乘务组号: \n起点站名: \n终点站名: \n占用轨道: ${model.sectionModel ? model.sectionModel.trackName : ''}\n所在车站: \n车地通信: 正常\n运行等级: 4\n扣车状态: ${model.runControlStatus == '01' ? '正常' : model.runControlStatus == '03' ? '跳停' : '扣车'}\n停稳状态: ${model.runStatus == '02' ? '未停稳' : '停稳'}\n阻塞状态: 无\n列车速度: ${model.speed || 0} km/h\n列车移动授权距离: ${model.maLen || 0} m`, textFill: '#000', textAlign: 'letf', - textFont: 10 + 'px consolas', textPadding: 3, textBackgroundColor: style.tipBackgroundColor } @@ -72,9 +72,9 @@ class TrainBody extends Group { style: { x: parseInt(beginX + margin * 0), y: parseInt(beginY), + font: TextFontHSDA, text: 'H', textFill: style.trainYellowColor, - textFont: TextFontHSDA, textAlign: 'middle', textVerticalAlign: 'top' } @@ -86,9 +86,9 @@ class TrainBody extends Group { style: { x: parseInt(beginX + margin * 1), y: parseInt(beginY), + font: TextFontHSDA, text: 'S', textFill: style.trainBlueColor, - textFont: TextFontHSDA, textAlign: 'middle', textVerticalAlign: 'top' } @@ -100,9 +100,9 @@ class TrainBody extends Group { style: { x: parseInt(beginX + margin * 2), y: parseInt(beginY), + font: TextFontHSDA, text: 'D', textFill: style.trainGreenColor, - textFont: TextFontHSDA, textAlign: 'middle', textVerticalAlign: 'top' } @@ -114,9 +114,9 @@ class TrainBody extends Group { style: { x: parseInt(beginX + margin * 3), y: parseInt(beginY), + font: TextFontHSDA, text: 'A', textFill: style.trainRedColor, - textFont: TextFontHSDA, textAlign: 'middle', textVerticalAlign: 'top' } @@ -135,9 +135,9 @@ class TrainBody extends Group { style: { x: parseInt(model.point.x + lrPadding), y: parseInt(model.point.y + upPadding), + font: textFont, text: serviceNumber.substring(serviceNumber.length - 2), textFill: style.trainBrownColor, - textFont: textFont, textAlign: 'left', textVerticalAlign: 'top' } @@ -149,9 +149,9 @@ class TrainBody extends Group { style: { x: parseInt(model.point.x + style.trainWidth - lrPadding), y: parseInt(model.point.y + upPadding), + font: textFont, text: tripNumber.substring(tripNumber.length - 3), textFill: style.trainYellowColor, - textFont: textFont, textAlign: 'right', textVerticalAlign: 'top' } diff --git a/src/jmap/shape/ZcControl/index.js b/src/jmap/shape/ZcControl/index.js index b18b4b2c3..1f3f337a4 100644 --- a/src/jmap/shape/ZcControl/index.js +++ b/src/jmap/shape/ZcControl/index.js @@ -34,11 +34,13 @@ export default class ZcControl extends Group { position: [0, 0], x: model.position.x, y: model.position.y + this.style.zcControlmodeR + this.style.nameDistance, + fontWeight: 'normal', + fontSize: this.style.stationControlTextSize, + fontFamily: this.style.textFontFormat, text: model.name, textFill: '#fff', textAlign: 'middle', - textVerticalAlign: 'top', - textFont: this.style.stationControlTextSize + 'px ' + this.style.textFontFormat + textVerticalAlign: 'top' }, style: this.style }); diff --git a/src/jmap/shape/element/EControl.js b/src/jmap/shape/element/EControl.js index 26634885b..337f3d944 100644 --- a/src/jmap/shape/element/EControl.js +++ b/src/jmap/shape/element/EControl.js @@ -35,11 +35,13 @@ export default class EControl extends Group { style: { x: this.textStyle.x, y: this.textStyle.y, + fontWeight: this.textStyle.fontWeight, + fontSize: this.textStyle.fontSize, + fontFamily: this.textStyle.fontFamily, text: this.textStyle.text, textFill: this.textStyle.textFill, textAlign: this.textStyle.textAlign, - textVerticalAlign: this.textStyle.textVerticalAlign, - textFont: this.textStyle.textFont + textVerticalAlign: this.textStyle.textVerticalAlign } }); diff --git a/src/jmap/theme/bejing.js b/src/jmap/theme/bejing.js index ff8e68b14..7468aed4e 100644 --- a/src/jmap/theme/bejing.js +++ b/src/jmap/theme/bejing.js @@ -26,7 +26,7 @@ class Beijing extends defaultSkin { textAlign: 'center', // 水平对齐方式 textPosition: 'inside', // 文字位置 textVerticalAlign: 'middle', // 文字垂直对齐方式 - position: 0 // 区段名称位置 1 上行 -1 下面 0 默认 + position: 1 // 区段名称位置 1 上面 -1 下面 0 默认 }, line: { width: 5, // 区段宽度 @@ -77,6 +77,8 @@ class Beijing extends defaultSkin { signalLampStandardWidth: 1.5 }, text: { + /** 是否禁止旋转*/ + isNoRotation: true, /** 信号机名称字体大小*/ signalTextFontSize: 10, /** 信号灯字体默认色*/ @@ -199,12 +201,12 @@ class Beijing extends defaultSkin { this[deviceType.StationControl] = { singleControlNum: 3, - stationOffset: {x: 20, y: 0}, + stationOffset: { x: 20, y: 0 }, arrowsShow: false, // 控制模式箭头显隐 /** 控制模式字体大小*/ stationControlTextSize: 10, /** 控制模式灯的半径 */ - stationControlmodeR: 4, + stationControlmodeR: 6, /** 控制模式之间灯之间的距离*/ stationControlDistance: 36, /** 控制模式灰色*/ diff --git a/src/jmap/theme/fuzhou.js b/src/jmap/theme/fuzhou.js index 51b279f65..c663a922d 100644 --- a/src/jmap/theme/fuzhou.js +++ b/src/jmap/theme/fuzhou.js @@ -70,6 +70,8 @@ class Fuzhou extends defaultSkin { signalLampStandardWidth: 2 }, text: { + /** 是否禁止旋转*/ + isNoRotation: true, /** 信号机名称字体大小*/ signalTextFontSize: 10, /** 信号灯字体默认色*/ From 59933cf4b96f7d79171b827d8e84775c30ac80ad Mon Sep 17 00:00:00 2001 From: zyy <1787816799@qq.com> Date: Wed, 24 Jul 2019 14:33:50 +0800 Subject: [PATCH 19/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/shape/ImageControl/index.js | 1 - src/jmap/shape/Section/ERelease.js | 48 ++++++----- src/jmap/shape/Section/index.js | 115 ++++++++++++++------------- src/jmap/theme/bejing.js | 5 -- 4 files changed, 87 insertions(+), 82 deletions(-) diff --git a/src/jmap/shape/ImageControl/index.js b/src/jmap/shape/ImageControl/index.js index 5e8e2fe71..b8dcca88a 100644 --- a/src/jmap/shape/ImageControl/index.js +++ b/src/jmap/shape/ImageControl/index.js @@ -7,7 +7,6 @@ import Image from 'zrender/src/graphic/Image'; export default class ImageControl extends Group { constructor({ _code, _type, zlevel, model, state }, style) { super(); - console.log(model); this._code = _code; this._type = _type; this.zlevel = zlevel; diff --git a/src/jmap/shape/Section/ERelease.js b/src/jmap/shape/Section/ERelease.js index fcefc7a65..efda4b174 100644 --- a/src/jmap/shape/Section/ERelease.js +++ b/src/jmap/shape/Section/ERelease.js @@ -6,43 +6,50 @@ export default class ERelease extends Group { constructor(model) { super(); this.model = model; - this.zlevel = model.zlevel; - this.z = model.z; - this._create(); + this.isNew = false; + } _create() { - const model = this.model; - this.Lines = new Line({ - zlevel: model.zlevel, - z: this.z, - shape: model.shape, - progressive: model.progressive, - style: { - lineWidth: model.lineWidth, - stroke: model.stroke - } - }); - this.add(this.Lines); + if (!this.isNew) { + const model = this.model; + + this.isNew = true; + this.lines = new Line({ + zlevel: model.zlevel, + z: model.z, + shape: model.shape, + progressive: model.progressive, + style: { + lineWidth: model.lineWidth, + stroke: model.stroke + } + }); + this.add(this.lines); + } } setStyle(model) { - this.Lines.setStyle(model); + this._create(); + this.lines.setStyle(model); } hide() { - this.Lines.hide(); + this._create(); + this.lines.hide(); } show() { - this.Lines.show(); + this._create(); + this.lines.show(); } // 开始动画 animateStyle(loop, animates) { + this._create(); if (animates && animates.length) { this.eachChild((child) => { - if (child.animateStyle && child.isLine) { + if (child.animateStyle) { let an = child.animateStyle(loop); animates.forEach(elem => { an = an.when(elem.time, elem.styles); @@ -55,8 +62,9 @@ export default class ERelease extends Group { // 结束动画 stopAnimation(flag) { + this._create(); this.eachChild((child) => { - if (child.stopAnimation && child.isLine) { + if (child.stopAnimation) { child.stopAnimation(flag); } }); diff --git a/src/jmap/shape/Section/index.js b/src/jmap/shape/Section/index.js index 37656405e..a6a74a82f 100644 --- a/src/jmap/shape/Section/index.js +++ b/src/jmap/shape/Section/index.js @@ -32,6 +32,7 @@ export default class Section extends Group { model.logicSectionNum.length == 1 && model.logicSectionNum[0] == 0) || model.type === '02') { this.createSection(); // 创建区段 + this.creatRelease(); // 创建延时释放 this.createSeparator(); // 创建分隔符 if (model.type === '01') { this.createAxles(); // 创建计轴 @@ -49,7 +50,6 @@ export default class Section extends Group { this.section = new ELines({ zlevel: this.zlevel, z: this.z, - progressive: 1, isSwitchSection: model.isSwitchSection, isCurve: model.isCurve, points: model.points, @@ -60,14 +60,12 @@ export default class Section extends Group { } // 创建延时释放 (需要在创建) - creatRelease(stroke, lineWidth) { + creatRelease() { const model = this.model; const style = this.style; const traingle = new JTriangle(model.points[0], model.points[model.points.length - 1]); - this.release = new ERelease({ - zlevel: model.zlevel, - progressive: 6, + zlevel: this.zlevel, z: this.z, shape: { x1: model.points[0].x + traingle.getCos(traingle.absz / 3), @@ -75,8 +73,8 @@ export default class Section extends Group { x2: model.points[0].x + traingle.getCos(traingle.absz / 3 * 2), y2: model.points[0].y + traingle.getSin(traingle.absz / 3 * 2) }, - lineWidth: lineWidth || style.Section.line.width, - stroke: stroke || style.Section.line.spareColor + lineWidth: style.Section.line.width, + stroke: style.Section.line.spareColor }); this.add(this.release); @@ -91,33 +89,30 @@ export default class Section extends Group { let y = traingle.dricty * (style.Section.speedLimit.Distance) * traingle.getCosRate(); if (x == Infinity) { x = 0; } if (y == Infinity) { y = 0; } - - this.speedLimitLeft = new ELimitLines({ - zlevel: this.zlevel, - z: this.z, - progressive: 5, - position: [x, -y], - style: style, - switch: model.switch, - isSwitchSection: model.isSwitchSection, - relSwitchCode: model.relSwitchCode, - isCurve: model.isCurve, // 是否曲线 - points: model.points - }); - - this.speedLimitRight = new ELimitLines({ - zlevel: this.zlevel, - z: this.z, - progressive: 5, - position: [x, -y], - style: style, - switch: model.switch, - isSwitchSection: model.isSwitchSection, - relSwitchCode: model.relSwitchCode, - isCurve: model.isCurve, // 是否曲线 - points: model.points - }); - + if (!this.speedLimitLeft && !this.speedLimitRight) { + this.speedLimitLeft = new ELimitLines({ + zlevel: this.zlevel, + z: this.z, + position: [x, -y], + style: style, + switch: model.switch, + isSwitchSection: model.isSwitchSection, + relSwitchCode: model.relSwitchCode, + isCurve: model.isCurve, // 是否曲线 + points: model.points + }); + this.speedLimitRight = new ELimitLines({ + zlevel: this.zlevel, + z: this.z, + position: [-x, y], + style: style, + switch: model.switch, + isSwitchSection: model.isSwitchSection, + relSwitchCode: model.relSwitchCode, + isCurve: model.isCurve, // 是否曲线 + points: model.points + }); + } this.add(this.speedLimitLeft); this.add(this.speedLimitRight); } @@ -372,7 +367,6 @@ export default class Section extends Group { traingle = new JTriangle(model.points[0], model.points[1]); this.lPartition = new ESeparator({ style: style, - progressive: 2, zlevel: this.zlevel, traingle: traingle, point: { @@ -387,7 +381,6 @@ export default class Section extends Group { traingle = new JTriangle(model.points[model.points.length - 2], model.points[model.points.length - 1]); this.rPartition = new ESeparator({ style: style, - progressive: 2, zlevel: this.zlevel, traingle: traingle, point: { @@ -423,7 +416,7 @@ export default class Section extends Group { }); if (this.release) { - this.remove(this.release); + this.release.hide(); } if (this.speedLimitLeft && this.speedLimitRight) { this.remove(this.speedLimitLeft); @@ -534,33 +527,40 @@ export default class Section extends Group { } /** 延时释放 10*/ - timeRelease() { - const lineWidth = this.style.Section.line.width + this.style.Section.line.beyondWidth; - const stroke = this.style.Section.line.routeLockColor; - this.creatRelease(stroke, lineWidth); + async timeRelease() { this.section.setStyle({ stroke: this.style.Section.line.routeLockColor, lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth }); - this.release.animateStyle(true) - .when(1000, { stroke: this.style.Section.line.routeLockColor }) - .when(2000, { stroke: this.style.Section.line.timeReleaseColor }) - .start(); + + if (this.release) { + this.release.show(); + this.release.setStyle({ + stroke: this.style.Section.line.routeLockColor, + lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth + }); + this.release.animateStyle(true, [ + { time: 1000, styles: { stroke: this.style.Section.line.routeLockColor } }, + { time: 2000, styles: { stroke: this.style.Section.line.timeReleaseColor } } + ]); + } } /** 保护区段延时解锁 11*/ protectiveTimeRelease() { - const lineWidth = this.style.Section.line.width + this.style.Section.line.beyondWidth; - const stroke = this.style.Section.line.protectiveLockColor; - this.creatRelease(stroke, lineWidth); this.section.setStyle({ stroke: this.style.Section.line.protectiveLockColor, lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth }); - this.release.animateStyle(true) - .when(1000, { stroke: this.style.Section.line.protectiveLockColor }) - .when(2000, { stroke: this.style.Section.line.protectiveTimeReleaseColor }) - .start(); + this.release && this.release.show(); + this.release && this.release.setStyle({ + stroke: this.style.Section.line.protectiveLockColor, + lineWidth: this.style.Section.line.width + this.style.Section.line.beyondWidth + }); + this.release && this.release.animateStyle(true, [ + { time: 1000, styles: { stroke: this.style.Section.line.protectiveLockColor } }, + { time: 2000, styles: { stroke: this.style.Section.line.protectiveTimeReleaseColor } } + ]); } /** 区段切除*/ @@ -582,8 +582,13 @@ export default class Section extends Group { /** 计轴预复位 12*/ axleReset() { - const stroke = this.style.Section.axle.resetColor; - this.creatRelease(stroke, null); + if (this.release) { + this.release.show(); + this.release && this.release.setStyle({ + stroke: this.style.Section.axle.resetColor, + fill: 'green' + }); + } } /** 计轴失效 13*/ @@ -599,7 +604,6 @@ export default class Section extends Group { /** 设置状态*/ setState(state) { this.recover(); - // state.status = '02'; switch (state.status) { case '00': /** 未定义*/ this.undefine(); @@ -651,7 +655,6 @@ export default class Section extends Group { if (state.cutOff) { this.sectionCutOff(); } - /** 是否限速*/ if (state.speedUpperLimit >= 0) { this.setSpeedUpperLimit(); diff --git a/src/jmap/theme/bejing.js b/src/jmap/theme/bejing.js index b698535bd..00c4428d1 100644 --- a/src/jmap/theme/bejing.js +++ b/src/jmap/theme/bejing.js @@ -7,17 +7,13 @@ class Beijing extends defaultSkin { this[deviceType.Link] = { /** line 颜色*/ lineWidthColor: '#FFFFFF', - /** link 宽度*/ linkWidth: 4.4, - /** link 线条颜色*/ linkColor: '#3F3F3F', - /** link 字体颜色*/ linkTextColor: '#FFFFFF' }; - this[deviceType.Section] = { text: { // 区段文字属性 fontSize: 10, // 字体大小 @@ -67,7 +63,6 @@ class Beijing extends defaultSkin { color: '#7F7F7F' // 区段边界符颜色 } }; - this[deviceType.Signal] = { /** 设备距离区段的距离*/ signalDistance: 0,