From 6ebbdec4142078fb5a3efbaff81120025bb8806a Mon Sep 17 00:00:00 2001 From: ival <160568032@qq.com> Date: Thu, 1 Apr 2021 22:11:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=87=BD=E6=95=B0=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/iscs_new/factory/compose.js | 6 +++--- src/iscs_new/factory/index.js | 22 +++++++++++----------- src/iscs_new/factory/tipsHandle.js | 4 ++-- src/iscs_new/painter.js | 30 +++++++++++++++--------------- src/iscs_new/selectingHandle.js | 8 ++++---- src/iscs_new/transformHandle.js | 4 ++-- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/iscs_new/factory/compose.js b/src/iscs_new/factory/compose.js index 76609dcee..e042f40c9 100644 --- a/src/iscs_new/factory/compose.js +++ b/src/iscs_new/factory/compose.js @@ -24,7 +24,7 @@ class Compose extends AbstractShape { this.model.elementCodes.forEach(code => { const el = this.shapeFactory.getShapeByCode(code); if (el.instance) { - this.shapeFactory.removeFromLevel(el.model.type, el.instance); + this.shapeFactory.removeFromLayer(el.model.type, el.instance); this.instance.add(el.instance); } }) @@ -70,7 +70,7 @@ class Compose extends AbstractShape { if (el && el.model) { el.model.composeCode = this.model.code; - this.shapeFactory.removeFromLevel(el.model.type, el.instance); + this.shapeFactory.removeFromLayer(el.model.type, el.instance); this.instance.add(el.instance); el.attr(el.model); } @@ -88,7 +88,7 @@ class Compose extends AbstractShape { el.model.composeCode) { el.model.composeCode = ''; this.remove(el.instance); - this.shapeFactory.addToLevel(el.model.type, el.instance); + this.shapeFactory.addToLayer(el.model.type, el.instance); el.attr(el.model); } }) diff --git a/src/iscs_new/factory/index.js b/src/iscs_new/factory/index.js index 7ff2ecd0b..6226f6eab 100644 --- a/src/iscs_new/factory/index.js +++ b/src/iscs_new/factory/index.js @@ -104,15 +104,15 @@ class ShapeFactory extends Eventful { }) } - parse(source={}, walk=None) { + parse(source={}, take=None) { try { this.source = source; zrUtil.each(source.elementList ||[], model => { - walk(this.storageShape(this.createShape(model, {shapeType: shapeType.Element}))); + take(this.storageShape(this.createShape(model, {shapeType: shapeType.Element}))); }, this); zrUtil.each(source.composeList ||[], model => { - walk(this.storageShape(this.createShape(model, {shapeType: shapeType.Compose}))); + take(this.storageShape(this.createShape(model, {shapeType: shapeType.Compose}))); }, this); } catch (error) { console.error('[ERROR] ', error); @@ -157,7 +157,7 @@ class ShapeFactory extends Eventful { const target = this.$controller.getTarget(); if (shape.hightLightInstance) { shape.hightLightInstance.setShape(shape.getBoundingRect()); - this.$painter.addToLevel(shapeLayer.HightLight)(shape.hightLightInstance); + this.$painter.addToLayer(shapeLayer.HightLight)(shape.hightLightInstance); } if (target == shape) { @@ -172,7 +172,7 @@ class ShapeFactory extends Eventful { hideHightLight(shape) { const target = this.$controller.getTarget(); if (shape.hightLightInstance) { - this.$painter.removeFromLevel(shapeLayer.HightLight)(shape.hightLightInstance); + this.$painter.removeFromLayer(shapeLayer.HightLight)(shape.hightLightInstance); } if (target != shape) { @@ -186,19 +186,19 @@ class ShapeFactory extends Eventful { showBorder(shape) { this.border.setShape(shape.getBoundingRect()); - this.$painter.addToLevel(shapeLayer.HightLight)(this.border); + this.$painter.addToLayer(shapeLayer.HightLight)(this.border); } hideBorder(shape) { - this.$painter.removeFromLevel(shapeLayer.HightLight)(this.border); + this.$painter.removeFromLayer(shapeLayer.HightLight)(this.border); } - addToLevel(level, view) { - return this.$painter.addToLevel(level)(view); + addToLayer(level, view) { + return this.$painter.addToLayer(level)(view); } - removeFromLevel(level, view) { - return this.$painter.removeFromLevel(level)(view); + removeFromLayer(level, view) { + return this.$painter.removeFromLayer(level)(view); } isDrawing() { diff --git a/src/iscs_new/factory/tipsHandle.js b/src/iscs_new/factory/tipsHandle.js index 98ae28998..4bd826c28 100644 --- a/src/iscs_new/factory/tipsHandle.js +++ b/src/iscs_new/factory/tipsHandle.js @@ -41,13 +41,13 @@ export default class TipsHandle { const painter = this.$map.getPainter(); this.message.setStyle({ x, y, text }); - painter.addToLevel(shapeLayer.Tips)(this.message); + painter.addToLayer(shapeLayer.Tips)(this.message); } onHide(e) { const painter = this.$map.getPainter(); - painter.removeFromLevel(shapeLayer.Tips)(this.message); + painter.removeFromLayer(shapeLayer.Tips)(this.message); this.message.setStyle('text', ''); } } diff --git a/src/iscs_new/painter.js b/src/iscs_new/painter.js index 8de2b8a58..c6d7e71f0 100644 --- a/src/iscs_new/painter.js +++ b/src/iscs_new/painter.js @@ -16,7 +16,7 @@ class Painter extends Group { initLevels(map) { // 初始化图层对象 - this.mapShapeLevel = {}; + this.mapShapeLayer = {}; // 获取顶层图层 this.$zr = map.getZr(); @@ -25,34 +25,34 @@ class Painter extends Group { this.$zr.add(this); // 创建select图层 - this.mapShapeLevel[shapeLayer.SelectIng] = new Group({ name: shapeLayer.SelectIng }); + this.mapShapeLayer[shapeLayer.SelectIng] = new Group({ name: shapeLayer.SelectIng }); // 创建hover图层 - this.mapShapeLevel[shapeLayer.HightLight] = new Group({ name: shapeLayer.HightLight }); + this.mapShapeLayer[shapeLayer.HightLight] = new Group({ name: shapeLayer.HightLight }); // 创建tips图层 - this.mapShapeLevel[shapeLayer.Tips] = new Group({name: shapeLayer.Tips }); + this.mapShapeLayer[shapeLayer.Tips] = new Group({name: shapeLayer.Tips }); // 创建元素图层 Object.keys(graphic).forEach(key => { - this.mapShapeLevel[key] = new Group({name: `__${key}__`}); + this.mapShapeLayer[key] = new Group({name: `__${key}__`}); }) // 添加图层 - Object.values(this.mapShapeLevel).forEach(el => { + Object.values(this.mapShapeLayer).forEach(el => { super.add(el); }) } add(shape) { if (shape && shape.instance) { - this.addToLevel(shape.model.type)(shape.instance); + this.addToLayer(shape.model.type)(shape.instance); } } remove(shape) { if (shape && shape.instance) { - this.removeFromLevel(shape.model.type)(shape.instance); + this.removeFromLayer(shape.model.type)(shape.instance); } } @@ -70,35 +70,35 @@ class Painter extends Group { this.$transformHandle.updateZrSize(opt); } - addToLevel(name) { + addToLayer(name) { name = Object.keys(graphic).includes(name)? name: `Group`; return (view) => { - this.mapShapeLevel[name].add(view); + this.mapShapeLayer[name].add(view); this.$transformHandle.transformView(view); this.dirty(); } } - removeFromLevel(name) { + removeFromLayer(name) { name = Object.keys(graphic).includes(name)? name: `Group`; return (view) => { - this.mapShapeLevel[name].remove(view); + this.mapShapeLayer[name].remove(view); } } getLevelByName(name) { - return this.mapShapeLevel[name]; + return this.mapShapeLayer[name]; } clear() { - Object.values(this.mapShapeLevel).forEach(el => { + Object.values(this.mapShapeLayer).forEach(el => { el.removeAll(); }) } destroy() { this.clear(); - this.mapShapeLevel = {}; + this.mapShapeLayer = {}; } } diff --git a/src/iscs_new/selectingHandle.js b/src/iscs_new/selectingHandle.js index 40ff3dcec..60a94a22e 100644 --- a/src/iscs_new/selectingHandle.js +++ b/src/iscs_new/selectingHandle.js @@ -39,7 +39,7 @@ export default class SelectingHandle { onSelectStart(e) { this.selecting.setShape({ x: e.x, y: e.y, width: 0, height: 0 }); - this.$painter.addToLevel(shapeLayer.SelectIng)(this.selecting); + this.$painter.addToLayer(shapeLayer.SelectIng)(this.selecting); this.begPoint = { x: e.x, y: e.y }; this.endPoint = null; } @@ -47,13 +47,13 @@ export default class SelectingHandle { onSelecting(e) { this.endPoint = { x: e.x, y: e.y }; this.selecting.setShape(this.normalizedArea(this.begPoint, this.endPoint)); - this.$painter.addToLevel(shapeLayer.SelectIng)(this.selecting); + this.$painter.addToLayer(shapeLayer.SelectIng)(this.selecting); } onSelectEnd(e) { this.endPoint = { x: e.x, y: e.y }; this.selecting.setShape(this.normalizedArea(this.begPoint, this.endPoint)); - this.$painter.addToLevel(shapeLayer.SelectIng)(this.selecting); + this.$painter.addToLayer(shapeLayer.SelectIng)(this.selecting); const selectingRect = this.selecting.getBoundingRect(); Object.values(this.$map.getMapShape()).forEach(el => { @@ -72,7 +72,7 @@ export default class SelectingHandle { } clear() { - this.$painter.removeFromLevel(shapeLayer.SelectIng)(this.selecting); + this.$painter.removeFromLayer(shapeLayer.SelectIng)(this.selecting); } checkSelectingRectContainShape(rect, shape) { diff --git a/src/iscs_new/transformHandle.js b/src/iscs_new/transformHandle.js index 62611b070..c180d0618 100644 --- a/src/iscs_new/transformHandle.js +++ b/src/iscs_new/transformHandle.js @@ -63,8 +63,8 @@ export default class TransformHandle { // 遍历group执行回调 traverse(cb, context) { - this.$painter.eachChild(level => { - level.eachChild((view) => { + this.$painter.eachChild(layer => { + layer.eachChild((view) => { cb.call(context, view); }, context); }, context);