Merge branch 'master' of https://git.qcloud.com/joylink/jl-nclient
# Conflicts: # src/jmap/map.js # src/jmap/shape/Signal/index.js # src/views/jmap/index.vue
This commit is contained in:
commit
c912074739
@ -42,14 +42,13 @@ class Jmap {
|
|||||||
const width = opts.dom.clientWidth;
|
const width = opts.dom.clientWidth;
|
||||||
const height = opts.dom.clientHeight;
|
const height = opts.dom.clientHeight;
|
||||||
|
|
||||||
this.optionsHandler = this.setOptions.bind(this);
|
|
||||||
|
|
||||||
this.$zr = zrender.init(opts.dom, Object.assign({ renderer, devicePixelRatio, width, height }, opts.config));
|
this.$zr = zrender.init(opts.dom, Object.assign({ renderer, devicePixelRatio, width, height }, opts.config));
|
||||||
|
|
||||||
this.$options = new Options(Object.assign({ scaleRate: 1, offsetX: 0, offsetY: 0 }, opts.options || {})); // 缩放
|
this.$options = new Options(Object.assign({ scaleRate: 1, offsetX: 0, offsetY: 0 }, opts.options || {})); // 缩放
|
||||||
|
this.$painter = new Painter(this);
|
||||||
|
this.$painter.updateTransform(this.$options);
|
||||||
|
|
||||||
this.$painter = new Painter(this); // 绘画层
|
this.optionsHandler = this.setOptions.bind(this);
|
||||||
this.$painter.updateZoomTransform(this.$options);
|
|
||||||
|
|
||||||
this.$mouseController = new MouseController(this);
|
this.$mouseController = new MouseController(this);
|
||||||
this.$mouseController.enable();
|
this.$mouseController.enable();
|
||||||
@ -116,8 +115,8 @@ class Jmap {
|
|||||||
if (payload.type === 'zoom') {
|
if (payload.type === 'zoom') {
|
||||||
const zrWidth = this.$zr.getWidth();
|
const zrWidth = this.$zr.getWidth();
|
||||||
const zrHeight = this.$zr.getHeight();
|
const zrHeight = this.$zr.getHeight();
|
||||||
const originX = this.$options.zoomOnMouseWheel ? payload.originX : zrWidth / 2;
|
const originX = payload.originX || zrWidth / 2;
|
||||||
const originY = this.$options.zoomOnMouseWheel ? payload.originY : zrHeight / 2;
|
const originY = payload.originY || zrHeight / 2;
|
||||||
const x = (this.$options.offsetX + originX) / this.$options.scaleRate;
|
const x = (this.$options.offsetX + originX) / this.$options.scaleRate;
|
||||||
const y = (this.$options.offsetY + originY) / this.$options.scaleRate;
|
const y = (this.$options.offsetY + originY) / this.$options.scaleRate;
|
||||||
const newScaleRate = this.$options.getScaleRate(payload.scale);
|
const newScaleRate = this.$options.getScaleRate(payload.scale);
|
||||||
@ -130,15 +129,19 @@ class Jmap {
|
|||||||
return payload || {};
|
return payload || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
setOptions(zoom) {
|
setOptions(opts) {
|
||||||
console.log(zoom, '1111');
|
this.$options.update(this.pullBack(opts));
|
||||||
this.$options.update(this.pullBack(zoom));
|
this.$painter.updateTransform(this.$options);
|
||||||
this.$painter.updateZoomTransform(this.$options);
|
|
||||||
if (this.methods.optionsUpdate instanceof Function) { this.methods.optionsUpdate(); }
|
if (this.methods.optionsUpdate instanceof Function) { this.methods.optionsUpdate(); }
|
||||||
|
if (this.$options.disabled == true) {
|
||||||
|
this.$mouseController.disable();
|
||||||
|
} else {
|
||||||
|
this.$mouseController.enable(opts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setLevelInvisible(list) {
|
setLevelVisible(list, show) {
|
||||||
this.$painter.setLevelInvisible(list);
|
this.$painter.setLevelVisible(list, show);
|
||||||
}
|
}
|
||||||
|
|
||||||
render(list) {
|
render(list) {
|
||||||
@ -247,6 +250,11 @@ class Jmap {
|
|||||||
return this.mapDevice[code];
|
return this.mapDevice[code];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resize(opt) {
|
||||||
|
this.$zr.resize(opt);
|
||||||
|
this.$painter.updateZrSize({width: this.$zr.getWidth(), height: this.$zr.getHeight()});
|
||||||
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
this.$painter.refresh();
|
this.$painter.refresh();
|
||||||
}
|
}
|
||||||
|
@ -32,10 +32,10 @@ class MouseController extends Eventful {
|
|||||||
super();
|
super();
|
||||||
this.events = jmap.getEvents();
|
this.events = jmap.getEvents();
|
||||||
this.$zr = jmap.getZr();
|
this.$zr = jmap.getZr();
|
||||||
this.initController(this.$zr);
|
this.initHandler(this.$zr);
|
||||||
}
|
}
|
||||||
|
|
||||||
initController(zr) {
|
initHandler(zr) {
|
||||||
if (zr) {
|
if (zr) {
|
||||||
const clickHandler = this.click.bind(this);
|
const clickHandler = this.click.bind(this);
|
||||||
const contextmenuHandler = this.contextmenu.bind(this);
|
const contextmenuHandler = this.contextmenu.bind(this);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
class Options {
|
class Options {
|
||||||
constructor(opts, zr) {
|
constructor(opts) {
|
||||||
this.$zr = zr;
|
|
||||||
this.scaleIndex = 0;
|
this.scaleIndex = 0;
|
||||||
this.scaleList = [
|
this.scaleList = [
|
||||||
0.5, 0.6, 0.7, 0.8, 0.9,
|
0.5, 0.6, 0.7, 0.8, 0.9,
|
||||||
@ -29,7 +28,7 @@ class Options {
|
|||||||
|
|
||||||
this.throttle = opts.throttle || 100; // 刷新频率
|
this.throttle = opts.throttle || 100; // 刷新频率
|
||||||
|
|
||||||
this.disabled = false; // 是否禁用
|
this.disabled = false;
|
||||||
|
|
||||||
this.moveOnMouseMove = true;
|
this.moveOnMouseMove = true;
|
||||||
|
|
||||||
@ -45,20 +44,23 @@ class Options {
|
|||||||
if (Number.isFinite(payload.dy)) {
|
if (Number.isFinite(payload.dy)) {
|
||||||
this.offsetY -= payload.dy;
|
this.offsetY -= payload.dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Number.isFinite(payload.offsetX)) {
|
if (Number.isFinite(payload.offsetX)) {
|
||||||
this.offsetX = payload.offsetX;
|
this.offsetX = payload.offsetX;
|
||||||
}
|
}
|
||||||
if (Number.isFinite(payload.offsetY)) {
|
if (Number.isFinite(payload.offsetY)) {
|
||||||
this.offsetY = payload.offsetY;
|
this.offsetY = payload.offsetY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Number.isFinite(payload.scale)) {
|
if (Number.isFinite(payload.scale)) {
|
||||||
if (Number.isFinite(payload.scale)) {
|
if (Number.isFinite(payload.scale)) {
|
||||||
if (this.scaleIndex + payload.scale >= 0 && this.scaleIndex + payload.scale < this.scaleList.length) {
|
if ((this.scaleIndex + payload.scale) >= 0 && (this.scaleIndex + payload.scale) < this.scaleList.length) {
|
||||||
this.scaleIndex = this.scaleIndex + payload.scale;
|
this.scaleIndex = this.scaleIndex + payload.scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.scaleRate = this.scaleList[this.scaleIndex];
|
this.scaleRate = this.scaleList[this.scaleIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Number.isFinite(payload.scaleRate)) {
|
if (Number.isFinite(payload.scaleRate)) {
|
||||||
const idx = this.scaleList.indexOf(payload.scaleRate);
|
const idx = this.scaleList.indexOf(payload.scaleRate);
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
@ -67,12 +69,15 @@ class Options {
|
|||||||
this.scaleIndex = idx;
|
this.scaleIndex = idx;
|
||||||
this.scaleRate = payload.scaleRate;
|
this.scaleRate = payload.scaleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payload.disabled === true || payload.disabled === false) {
|
if (payload.disabled === true || payload.disabled === false) {
|
||||||
this.disabled = payload.disabled;
|
this.disabled = payload.disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payload.moveOnMouseMove === true || payload.moveOnMouseMove === false) {
|
if (payload.moveOnMouseMove === true || payload.moveOnMouseMove === false) {
|
||||||
this.moveOnMouseMove = payload.moveOnMouseMove;
|
this.moveOnMouseMove = payload.moveOnMouseMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payload.zoomOnMouseWheel === true || payload.zoomOnMouseWheel === false) {
|
if (payload.zoomOnMouseWheel === true || payload.zoomOnMouseWheel === false) {
|
||||||
this.zoomOnMouseWheel = payload.zoomOnMouseWheel;
|
this.zoomOnMouseWheel = payload.zoomOnMouseWheel;
|
||||||
}
|
}
|
||||||
@ -80,7 +85,7 @@ class Options {
|
|||||||
|
|
||||||
getScaleRate(scale) {
|
getScaleRate(scale) {
|
||||||
if (Number.isFinite(scale)) {
|
if (Number.isFinite(scale)) {
|
||||||
if (this.scaleIndex + scale >= 0 && this.scaleIndex + scale < this.scaleList.length) {
|
if ((this.scaleIndex + scale) >= 0 && (this.scaleIndex + scale) < this.scaleList.length) {
|
||||||
return this.scaleList[this.scaleIndex + scale];
|
return this.scaleList[this.scaleIndex + scale];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import * as zrUtil from 'zrender/src/core/util';
|
|||||||
import Group from 'zrender/src/container/Group';
|
import Group from 'zrender/src/container/Group';
|
||||||
import deviceType from './constant/deviceType';
|
import deviceType from './constant/deviceType';
|
||||||
import shapefactory from './shape/factory';
|
import shapefactory from './shape/factory';
|
||||||
import Transform from './transform';
|
import TransformHandle from './transformHandle';
|
||||||
|
|
||||||
class Painter {
|
class Painter {
|
||||||
constructor(jmap) {
|
constructor(jmap) {
|
||||||
@ -11,16 +11,13 @@ class Painter {
|
|||||||
this.$zr = jmap.getZr();
|
this.$zr = jmap.getZr();
|
||||||
|
|
||||||
// 视图控制器
|
// 视图控制器
|
||||||
this.$transform = new Transform(this, this.$zr);
|
this.$transformHandle = new TransformHandle(this, this.$zr);
|
||||||
|
|
||||||
// 图层数据
|
// 图层数据
|
||||||
this.mapInstanceLevel = {};
|
this.mapInstanceLevel = {};
|
||||||
|
|
||||||
// 父级图层
|
// 初始图层
|
||||||
this.parentLevel = null;
|
this.initPainterLevels();
|
||||||
|
|
||||||
// 初始绘图实例
|
|
||||||
this.initPainterInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,7 +25,7 @@ class Painter {
|
|||||||
* @param {*} dom
|
* @param {*} dom
|
||||||
* @param {*} config
|
* @param {*} config
|
||||||
*/
|
*/
|
||||||
initPainterInstance() {
|
initPainterLevels() {
|
||||||
// 添加父级图层
|
// 添加父级图层
|
||||||
this.parentLevel = new Group({ name: '__parent__' });
|
this.parentLevel = new Group({ name: '__parent__' });
|
||||||
this.$zr.add(this.parentLevel);
|
this.$zr.add(this.parentLevel);
|
||||||
@ -63,7 +60,7 @@ class Painter {
|
|||||||
const type = device._type;
|
const type = device._type;
|
||||||
const instance = shapefactory(type, device, this.$jmap);
|
const instance = shapefactory(type, device, this.$jmap);
|
||||||
if (instance) {
|
if (instance) {
|
||||||
this.$transform.transformView(instance);
|
this.$transformHandle.transformView(instance);
|
||||||
device.instance = instance;
|
device.instance = instance;
|
||||||
this.mapInstanceLevel[type].add(instance);
|
this.mapInstanceLevel[type].add(instance);
|
||||||
}
|
}
|
||||||
@ -93,24 +90,32 @@ class Painter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新图层zoom
|
* 更新transform变化
|
||||||
* @param {*} zoom
|
* @param {*} opt
|
||||||
*/
|
*/
|
||||||
updateZoomTransform(zoom) {
|
updateTransform(opt) {
|
||||||
this.$transform.updateTransform(zoom);
|
this.$transformHandle.updateTransform(opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置图层显隐
|
* 更新zrender尺寸
|
||||||
|
* @param {*} opt
|
||||||
|
*/
|
||||||
|
updateZrSize(opt) {
|
||||||
|
this.$transformHandle.updateZrSize(opt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置图层可见
|
||||||
* @param {*} code
|
* @param {*} code
|
||||||
*/
|
*/
|
||||||
setLevelInvisible(list) {
|
setLevelVisible(list, show) {
|
||||||
zrUtil.each(Object.values(deviceType), type => {
|
zrUtil.each(Object.values(deviceType), type => {
|
||||||
const level = this.mapInstanceLevel[type];
|
const level = this.mapInstanceLevel[type];
|
||||||
if (list.includes(type)) {
|
if (list.includes(type)) {
|
||||||
level.hide();
|
show ? level.show() : level.hide();
|
||||||
} else {
|
} else {
|
||||||
level.show();
|
show ? level.hide() : level.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -134,8 +139,8 @@ class Painter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 销毁图层
|
* 销毁图层
|
||||||
*/
|
*/
|
||||||
dispose() {
|
dispose() {
|
||||||
this.mapInstanceLevel = {};
|
this.mapInstanceLevel = {};
|
||||||
this.parentLevel = null;
|
this.parentLevel = null;
|
||||||
|
@ -9,7 +9,7 @@ import JTriangle from '../../utils/JTriangle';
|
|||||||
|
|
||||||
/** 区段*/
|
/** 区段*/
|
||||||
export default class Section extends Group {
|
export default class Section extends Group {
|
||||||
constructor({ _code, _type, zlevel, model, state }, style, jmap) {
|
constructor({ _code, _type, zlevel, model, state }, style) {
|
||||||
super();
|
super();
|
||||||
this._code = _code;
|
this._code = _code;
|
||||||
this._type = _type;
|
this._type = _type;
|
||||||
@ -19,7 +19,6 @@ export default class Section extends Group {
|
|||||||
this.state = state;
|
this.state = state;
|
||||||
this.style = style;
|
this.style = style;
|
||||||
this.selected = false;
|
this.selected = false;
|
||||||
this.jmap = jmap;
|
|
||||||
this._create();
|
this._create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
50
src/jmap/shape/Signal/ESigDelay.js
Normal file
50
src/jmap/shape/Signal/ESigDelay.js
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
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.zlevel = model.zlevel;
|
||||||
|
this.z = model.z;
|
||||||
|
this._create();
|
||||||
|
}
|
||||||
|
|
||||||
|
_create() {
|
||||||
|
this.name = new Text({
|
||||||
|
_subType: this.model._subType,
|
||||||
|
zlevel: this.zlevel,
|
||||||
|
z: this.z,
|
||||||
|
silent: this.model.silent || false,
|
||||||
|
style: {
|
||||||
|
x: this.model.x,
|
||||||
|
y: this.model.y,
|
||||||
|
text: this.model.text,
|
||||||
|
textFont: this.model.textFont,
|
||||||
|
textFill: this.model.textFill,
|
||||||
|
textAlign: this.model.textAlign,
|
||||||
|
textPosition: this.model.textPosition || 'inside',
|
||||||
|
textVerticalAlign: this.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;
|
50
src/jmap/shape/Signal/ESigName.js
Normal file
50
src/jmap/shape/Signal/ESigName.js
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
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.zlevel = model.zlevel;
|
||||||
|
this.z = model.z;
|
||||||
|
this._create();
|
||||||
|
}
|
||||||
|
|
||||||
|
_create() {
|
||||||
|
this.name = new Text({
|
||||||
|
_subType: this.model._subType,
|
||||||
|
zlevel: this.zlevel,
|
||||||
|
z: this.z,
|
||||||
|
silent: this.model.silent || false,
|
||||||
|
style: {
|
||||||
|
x: this.model.x,
|
||||||
|
y: this.model.y,
|
||||||
|
text: this.model.text,
|
||||||
|
textFont: this.model.textFont,
|
||||||
|
textFill: this.model.textFill,
|
||||||
|
textAlign: this.model.textAlign,
|
||||||
|
textPosition: this.model.textPosition || 'inside',
|
||||||
|
textVerticalAlign: this.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;
|
@ -7,7 +7,9 @@ import ESigLmap from './ESigLmap';
|
|||||||
import ESigPass from './ESigPass';
|
import ESigPass from './ESigPass';
|
||||||
import ESigRoute from './ESigRoute';
|
import ESigRoute from './ESigRoute';
|
||||||
import ESigButton from './ESigButton';
|
import ESigButton from './ESigButton';
|
||||||
import ETextName from '../element/ETextName';
|
import ESigDelay from './ESigDelay';
|
||||||
|
import ESigName from './ESigName';
|
||||||
|
// import Text from 'zrender/src/graphic/Text';
|
||||||
import Group from 'zrender/src/container/Group';
|
import Group from 'zrender/src/container/Group';
|
||||||
|
|
||||||
class Signal extends Group {
|
class Signal extends Group {
|
||||||
@ -62,12 +64,30 @@ class Signal extends Group {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 信号机名称
|
// 信号机名称
|
||||||
this.sigName = new ETextName({
|
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 Text({
|
||||||
|
// zlevel: this.zlevel,
|
||||||
|
// z: 1,
|
||||||
|
// silent: model.silent || false,
|
||||||
|
// style: {
|
||||||
|
// x: sigNameX,
|
||||||
|
// y: sigNameY,
|
||||||
|
// text: model.name,
|
||||||
|
// textFont: `bold ${style.Signal.signalTextFontSize} px ${style.textFontFormat}`,
|
||||||
|
// textFill: style.Signal.sigTextGreen,
|
||||||
|
// textAlign: 'middle',
|
||||||
|
// textPosition: this.model.textPosition || 'inside',
|
||||||
|
// textVerticalAlign: posit == 1 ? 'top' : 'bottom'
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
this.sigName = new ESigName({
|
||||||
zlevel: this.zlevel,
|
zlevel: this.zlevel,
|
||||||
z: 1,
|
z: 1,
|
||||||
style: style,
|
style: style,
|
||||||
x: model.position.x + model.namePosition.x,
|
x: sigNameX,
|
||||||
y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.signalR * 2 + model.namePosition.y),
|
y: sigNameY,
|
||||||
text: model.name,
|
text: model.name,
|
||||||
textFont: `bold ${style.Signal.signalTextFontSize} px ${style.textFontFormat}`,
|
textFont: `bold ${style.Signal.signalTextFontSize} px ${style.textFontFormat}`,
|
||||||
textFill: style.Signal.sigTextGreen,
|
textFill: style.Signal.sigTextGreen,
|
||||||
@ -110,7 +130,7 @@ class Signal extends Group {
|
|||||||
const sigDelayH = style.Signal.signalSigDelayDirection ? this.count * style.Signal.signalR * 2 : -style.Signal.signalR * 2;
|
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 sigDelayX = endPoint.x + (style.Signal.signalSigDelayOffset.x + sigDelayH) * drict;
|
||||||
const sigDelayY = endPoint.y - (style.Signal.signalSigDelayOffset.y) * posit;
|
const sigDelayY = endPoint.y - (style.Signal.signalSigDelayOffset.y) * posit;
|
||||||
this.sigDelay = new ETextName({
|
this.sigDelay = new ESigDelay({
|
||||||
zlevel: this.zlevel,
|
zlevel: this.zlevel,
|
||||||
z: 1,
|
z: 1,
|
||||||
style: style,
|
style: style,
|
||||||
|
@ -38,7 +38,7 @@ function shapefactory(type, device, jmap) {
|
|||||||
const shape = mapShape[type];
|
const shape = mapShape[type];
|
||||||
if (shape instanceof Function) {
|
if (shape instanceof Function) {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
return new shape(device, style, jmap);
|
return new shape(device, style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import Group from 'zrender/src/container/Group';
|
||||||
import * as matrix from 'zrender/src/core/matrix';
|
import * as matrix from 'zrender/src/core/matrix';
|
||||||
|
|
||||||
function createTransform(zoom) {
|
function createTransform(zoom) {
|
||||||
@ -25,7 +26,7 @@ class TransformHandle {
|
|||||||
this.$zr = zr;
|
this.$zr = zr;
|
||||||
|
|
||||||
this.rect = { x: 0, y: 0, width: this.$zr.getWidth(), height: this.$zr.getHeight() };
|
this.rect = { x: 0, y: 0, width: this.$zr.getWidth(), height: this.$zr.getHeight() };
|
||||||
this.transform = createTransform({ scale: 1, offsetX: 0, offsetY: 0 });
|
this.transform = createTransform({ scaleRate: 1, offsetX: 0, offsetY: 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
checkVisible(view) {
|
checkVisible(view) {
|
||||||
@ -38,6 +39,7 @@ class TransformHandle {
|
|||||||
} else {
|
} else {
|
||||||
view.hide();
|
view.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
view.dirty();
|
view.dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +57,7 @@ class TransformHandle {
|
|||||||
// 处理所有视图缩放/平移
|
// 处理所有视图缩放/平移
|
||||||
transformAll() {
|
transformAll() {
|
||||||
const parentLevel = this.$painter.getParentLevel();
|
const parentLevel = this.$painter.getParentLevel();
|
||||||
if (parentLevel) {
|
if (parentLevel instanceof Group) {
|
||||||
parentLevel.eachChild((level) => {
|
parentLevel.eachChild((level) => {
|
||||||
level.eachChild((view) => {
|
level.eachChild((view) => {
|
||||||
this.transformView(view);
|
this.transformView(view);
|
||||||
@ -67,7 +69,7 @@ class TransformHandle {
|
|||||||
// 重新计算显示图形
|
// 重新计算显示图形
|
||||||
revisibleAll() {
|
revisibleAll() {
|
||||||
const parentLevel = this.$painter.getParentLevel();
|
const parentLevel = this.$painter.getParentLevel();
|
||||||
if (parentLevel) {
|
if (parentLevel instanceof Group) {
|
||||||
parentLevel.eachChild((level) => {
|
parentLevel.eachChild((level) => {
|
||||||
level.eachChild((view) => {
|
level.eachChild((view) => {
|
||||||
this.revisibleView(view);
|
this.revisibleView(view);
|
||||||
@ -77,10 +79,16 @@ class TransformHandle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 更新偏移量
|
// 更新偏移量
|
||||||
updateTransform(zoom) {
|
updateTransform(opts) {
|
||||||
this.transform = createTransform(zoom);
|
this.transform = createTransform(opts);
|
||||||
this.transformAll();
|
this.transformAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新画布尺寸
|
||||||
|
updateZrSize(opts) {
|
||||||
|
this.rect = { x: 0, y: 0, width: opts.width, height: opts.height };
|
||||||
|
this.revisibleAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default TransformHandle;
|
export default TransformHandle;
|
@ -6,9 +6,13 @@
|
|||||||
import Jmap from '@/jmap/map';
|
import Jmap from '@/jmap/map';
|
||||||
import deviceType from '@/jmap/constant/deviceType';
|
import deviceType from '@/jmap/constant/deviceType';
|
||||||
import { getPublishMapDetail } from '@/api/test.js';
|
import { getPublishMapDetail } from '@/api/test.js';
|
||||||
|
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Jmap',
|
name: 'Jmap',
|
||||||
|
mixins: [
|
||||||
|
WindowResizeHandler
|
||||||
|
],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
id: '__jmap__',
|
id: '__jmap__',
|
||||||
@ -56,8 +60,8 @@ export default {
|
|||||||
|
|
||||||
getPublishMapDetail('03').then(resp => {
|
getPublishMapDetail('03').then(resp => {
|
||||||
this.jmap.load(resp.data);
|
this.jmap.load(resp.data);
|
||||||
// this.jmap.setDefaultState();
|
this.jmap.setDefaultState();
|
||||||
this.jmap.setLevelInvisible([deviceType.Link]);
|
this.jmap.setLevelVisible([deviceType.Link], false);
|
||||||
});
|
});
|
||||||
|
|
||||||
// this.jmap.render([
|
// this.jmap.render([
|
||||||
@ -81,6 +85,9 @@ export default {
|
|||||||
this.jmap = null;
|
this.jmap = null;
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
resizeHandler() {
|
||||||
|
this.jmap.resize({width: this._clientWidth, height: this._clientHeight});
|
||||||
|
},
|
||||||
selected(e) {
|
selected(e) {
|
||||||
// console.log('selected', e, this.jmap);
|
// console.log('selected', e, this.jmap);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user