From 7fd73dbf377dab395e628903342c4e677e274ad3 Mon Sep 17 00:00:00 2001 From: fan <18706759286@163.com> Date: Mon, 26 Aug 2019 11:15:40 +0800 Subject: [PATCH] =?UTF-8?q?ibp=E7=9B=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ibp/constant/deviceRender.js | 10 +++++----- src/ibp/constant/deviceType.js | 4 ++-- src/ibp/constant/ibpData.js | 12 ++++++++++++ src/ibp/ibpPan.js | 2 -- src/ibp/mouseController.js | 18 +++++++++--------- src/ibp/shape/arrow.js | 1 - src/ibp/shape/circularLamp.js | 21 ++++++++++++++++++--- src/ibp/shape/factory.js | 3 ++- src/ibp/utils/parser.js | 7 ++----- 9 files changed, 50 insertions(+), 28 deletions(-) diff --git a/src/ibp/constant/deviceRender.js b/src/ibp/constant/deviceRender.js index 7d0082b50..f304fe19c 100644 --- a/src/ibp/constant/deviceRender.js +++ b/src/ibp/constant/deviceRender.js @@ -12,11 +12,6 @@ deviceRender[deviceType.SquareButton] = { zlevel: 1 }; -/** LampControl渲染配置*/ -deviceRender[deviceType.LampControl] = { - zlevel: 1 -}; - /** WarnButton渲染配置*/ deviceRender[deviceType.WarnButton] = { zlevel: 1 @@ -41,4 +36,9 @@ deviceRender[deviceType.Tip] = { deviceRender[deviceType.Background] = { zlevel: 0 }; + +/** CircularLamp渲染配置 */ +deviceRender[deviceType.CircularLamp] = { + zlevel: 1 +}; export default deviceRender; diff --git a/src/ibp/constant/deviceType.js b/src/ibp/constant/deviceType.js index 33e7a0f64..18fb9e2be 100644 --- a/src/ibp/constant/deviceType.js +++ b/src/ibp/constant/deviceType.js @@ -1,12 +1,12 @@ const deviceType = { Text: 'Text', SquareButton: 'SquareButton', - LampControl: 'LampControl', WarnButton: 'WarnButton', Arrow: 'Arrow', RotatingButton: 'RotatingButton', Tip: 'Tip', - Background: 'Background' + Background: 'Background', + CircularLamp: 'CircularLamp' }; export default deviceType; diff --git a/src/ibp/constant/ibpData.js b/src/ibp/constant/ibpData.js index 1f83b5fe9..656fc75cc 100644 --- a/src/ibp/constant/ibpData.js +++ b/src/ibp/constant/ibpData.js @@ -33,6 +33,18 @@ const ibpData = { direction: '下行', stationstandDirection: '车辆段方向' } + ], + circularLampList: [ + { + type: 'CircularLamp', + code: '1333_lamp', + point: { + x: 600, + y: 600 + }, + r: 40, + fillColor: '#332C22' + } ] }; diff --git a/src/ibp/ibpPan.js b/src/ibp/ibpPan.js index 444f2a0ea..a09561fee 100644 --- a/src/ibp/ibpPan.js +++ b/src/ibp/ibpPan.js @@ -152,7 +152,6 @@ class IbpPan { localStore(code, val); } - for (var prop in elem) { if (elem[prop] != oDevice[prop]) { Object.assign(oDevice, elem); @@ -166,7 +165,6 @@ class IbpPan { update(list) { (list || []).forEach(elem => { const code = elem.code; - const type = elem._type; const oDevice = this.ibpDevice[code]; if (elem.dispose) { this.$painter.delete(oDevice); diff --git a/src/ibp/mouseController.js b/src/ibp/mouseController.js index e6e07b95d..f061602c2 100644 --- a/src/ibp/mouseController.js +++ b/src/ibp/mouseController.js @@ -29,11 +29,11 @@ class EventModel { } class MouseController extends Eventful { - constructor(jmap) { + constructor(ibp) { super(); - this.$jmap = jmap; - this.$zr = jmap.getZr(); - this.events = jmap.getEvents(); + this.$ibp = ibp; + this.$zr = ibp.getZr(); + this.events = ibp.getEvents(); this.initHandler(this.$zr); } @@ -154,7 +154,7 @@ class MouseController extends Eventful { const trainDetails = store.state.map.trainDetails; if (trainDetails) { if (newEm.deviceType != deviceType.Train || trainDetails.code != newEm.deviceCode) { - var instance = (this.$jmap.getDeviceByCode(trainDetails.code) || {} ).instance; + var instance = (this.$ibp.getDeviceByCode(trainDetails.code) || {} ).instance; instance && instance.removeTrainDetail && instance.removeTrainDetail(); } } @@ -165,10 +165,10 @@ class MouseController extends Eventful { var newEm = new EventModel(e); if ([1, 3].includes(e.which)) { // 查找之前和当前鼠标选中的实例 - var oldDevice = this.$jmap.getDeviceByCode(oldEm.deviceCode) || {}; - var newDevice = this.$jmap.getDeviceByCode(newEm.deviceCode) || {}; - var oldInstance = (this.$jmap.getDeviceByCode(oldEm.deviceCode) || {}).instance || {}; - var newInstance = (this.$jmap.getDeviceByCode(newEm.deviceCode) || {}).instance || {}; + var oldDevice = this.$ibp.getDeviceByCode(oldEm.deviceCode) || {}; + var newDevice = this.$ibp.getDeviceByCode(newEm.deviceCode) || {}; + var oldInstance = (this.$ibp.getDeviceByCode(oldEm.deviceCode) || {}).instance || {}; + var newInstance = (this.$ibp.getDeviceByCode(newEm.deviceCode) || {}).instance || {}; // 如果之前和当前选中的实例不一致 if (oldInstance != newInstance) { diff --git a/src/ibp/shape/arrow.js b/src/ibp/shape/arrow.js index 42f9eadbd..00d133fba 100644 --- a/src/ibp/shape/arrow.js +++ b/src/ibp/shape/arrow.js @@ -6,7 +6,6 @@ class Arrow extends Group { constructor(model) { super(); this.model = model; - console.log('----------', model); this.create(); } diff --git a/src/ibp/shape/circularLamp.js b/src/ibp/shape/circularLamp.js index ac85f8ae5..38f6bc778 100644 --- a/src/ibp/shape/circularLamp.js +++ b/src/ibp/shape/circularLamp.js @@ -1,7 +1,6 @@ import Group from 'zrender/src/container/Group'; -import Arc from 'zrender/src/graphic/shape/Arc'; -import Text from 'zrender/src/graphic/Text'; -import Rect from 'zrender/src/graphic/shape/Rect'; +import Circle from 'zrender/src/graphic/shape/Circle'; +import MouseController from '../mouseController'; export default class CircularLamp extends Group { constructor(model) { @@ -13,6 +12,22 @@ export default class CircularLamp extends Group { } create() { + this.lamp = new Circle({ + zlevel: this.zlevel, + z: this.z, + shape: { + cx: this.model.point.x, + cy: this.model.point.y, + r: this.model.r + }, + style: { + fill: this.model.fillColor + } + }); + this.add(this.lamp); + } + setCircularLampColor(color) { + this.lamp.setStyle('fill', color); } } diff --git a/src/ibp/shape/factory.js b/src/ibp/shape/factory.js index 7bd2dca6d..3c9a1732a 100644 --- a/src/ibp/shape/factory.js +++ b/src/ibp/shape/factory.js @@ -1,13 +1,14 @@ import Arrow from './arrow'; import deviceType from '../constant/deviceType'; import Background from './background'; +import CircularLamp from './circularLamp' const ibpShape = {}; ibpShape[deviceType.Arrow] = Arrow; ibpShape[deviceType.Background] = Background; +ibpShape[deviceType.CircularLamp] = CircularLamp; function shapefactory(device, ibp) { - console.log('device',device) const type = device._type; const shape = ibpShape[type]; if (shape instanceof Function) { diff --git a/src/ibp/utils/parser.js b/src/ibp/utils/parser.js index 6e82eff4b..049c8b137 100644 --- a/src/ibp/utils/parser.js +++ b/src/ibp/utils/parser.js @@ -2,8 +2,6 @@ import * as zrUtil from 'zrender/src/core/util'; import * as matrix from 'zrender/src/core/matrix'; import deviceType from '../constant/deviceType'; import deviceRender from '../constant/deviceRender'; -import Vue from 'vue'; -import background from '../shape/background'; export function createTransform(opts) { let transform = matrix.create(); @@ -47,7 +45,6 @@ export function parser(data, config) { Object.assign(data.background, config); ibpDevice[data.background.code] = createDevice(deviceType.Background, data.background, propConvert); - console.log(data, '000',ibpDevice); zrUtil.each(data.textList || [], elem => { ibpDevice[elem.code] = createDevice(deviceType.Text, elem, propConvert); }, this); @@ -56,8 +53,8 @@ export function parser(data, config) { ibpDevice[elem.code] = createDevice(deviceType.SquareButton, elem, propConvert); }, this); - zrUtil.each(data.lampControlList || [], elem => { - ibpDevice[elem.code] = createDevice(deviceType.LampControl, elem, propConvert); + zrUtil.each(data.circularLampList || [], elem => { + ibpDevice[elem.code] = createDevice(deviceType.CircularLamp, elem, propConvert); }, this); zrUtil.each(data.warnButtonList || [], elem => {