This commit is contained in:
fan 2019-08-26 11:15:40 +08:00
parent bc9180d814
commit 7fd73dbf37
9 changed files with 50 additions and 28 deletions

View File

@ -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;

View File

@ -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;

View File

@ -33,6 +33,18 @@ const ibpData = {
direction: '下行',
stationstandDirection: '车辆段方向'
}
],
circularLampList: [
{
type: 'CircularLamp',
code: '1333_lamp',
point: {
x: 600,
y: 600
},
r: 40,
fillColor: '#332C22'
}
]
};

View File

@ -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);

View File

@ -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) {

View File

@ -6,7 +6,6 @@ class Arrow extends Group {
constructor(model) {
super();
this.model = model;
console.log('----------', model);
this.create();
}

View File

@ -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);
}
}

View File

@ -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) {

View File

@ -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 => {