/* * 信号机 */ import ESigPost from './element/ESigPost'; import ESigLmap from './element/ESigLmap'; import ESigButton from './element/ESigButton'; import Group from 'zrender/src/container/Group'; class Signal extends Group { constructor({ _code, _type, zlevel, model, state }, style) { super(); this._code = _code; this._type = _type; this.zlevel = zlevel; this.model = model; this.state = state; this.style = style; this.count = parseInt(model.lampPositionType); this.lamps = new Array(this.count); this.create(); this.setState(state); } create() { const drict = this.model.directionType == '01' ? -1 : 1; // 朝向 左:右 const posit = this.model.positionType == '01' ? -1 : 1; // 位置 上:下 // 信号机高柱矮柱 this.siglpost = new ESigPost({ zlevel: this.zlevel, z: 1, style: this.style, drict: drict, type: this.model.lampPostType, position: { x: this.model.position.x, y: this.model.position.y + posit * (this.style.Signal.signalDistance + this.style.Section.sectionWidth) } }); // 信号灯 const nextPosition = this.siglpost.getLampPosition(this.model.highType); this.lamps = []; for (let i = 0; i < this.count; i++) { const lamp = new ESigLmap({ zlevel: this.zlevel, z: 1, style: this.style, index: i + 1, drict: drict, position: { x: nextPosition.x + i * drict * this.style.Signal.signalR * 2, y: nextPosition.y }, origin: { x: this.model.position.x, y: this.model.position.y } }); this.lamps.push(lamp); } // 信号灯按钮 this.sigButton = new ESigButton({ zlevel: this.zlevel, z: 1, style: this.style, posit: posit, show: this.model.buttonShow, position: { x: this.model.buttonPosition.x, y: this.model.buttonPosition.y } }); this.add(this.siglpost); this.lamps.forEach(lamp => { this.add(lamp); }); // this.add(this.sigButton); } setState(state) { } } export default Signal;