From a0dcff598ba567a895f9f1752c15d22061a65430 Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Sun, 7 Jul 2019 22:56:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=90=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/jmap/transformController.js | 46 ++++++++++++--------------------- src/views/jmap/index.vue | 14 +++++----- 3 files changed, 25 insertions(+), 36 deletions(-) diff --git a/package.json b/package.json index 213427812..e772c36fb 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "nprogress": "0.2.0", "path-to-regexp": "2.4.0", "qrcode.vue": "^1.6.2", + "sessionstorage": "^0.1.0", "stompjs": "^2.3.3", "storejs": "^1.0.25", "vue": "2.6.10", diff --git a/src/jmap/transformController.js b/src/jmap/transformController.js index 2fb9a4a29..0846024eb 100644 --- a/src/jmap/transformController.js +++ b/src/jmap/transformController.js @@ -1,27 +1,36 @@ import * as matrix from 'zrender/src/core/matrix'; -function getTransform(zoom) { +function createTransform(zoom) { let transform = matrix.create(); transform = matrix.scale(matrix.create(), transform, [zoom.scale, zoom.scale]); transform = matrix.translate(matrix.create(), transform, [zoom.offsetX, zoom.offsetY]); return transform; } +function createBoundingRect(view) { + let rect = view.getBoundingRect(); + let scale = view.scale[0]; + let offsetX = view.position[0]; + let offsetY = view.position[1]; + rect.width = rect.width * scale; + rect.height = rect.height * scale; + rect.x = rect.x * scale + offsetX; + rect.y = rect.y * scale + offsetY; + return rect; +} + class transformController { constructor(painter) { this.$painter = painter; this.$zr = painter.$zr; this.parentLevel = painter.parentLevel; - this.zoom = {scale: 1, offsetX: 0, offsetY: 0}; this.rect = {x:0, y:0, width: this.$zr.getWidth(), height: this.$zr.getHeight()}; - this.transform = getTransform(this.zoom); + this.transform = createTransform({scale: 1, offsetX: 0, offsetY: 0}); } checkVisible(view) { - let rect = this.getBoundingRect(); - let viewRect = this.getViewBoundingRect(view); - return viewRect.intersect(rect); + return createBoundingRect(view).intersect(this.rect); } revisibleView(view) { @@ -36,7 +45,7 @@ class transformController { transformView(view) { if (view) { - view.transform = this.getTransform(); + view.transform = this.transform; view.decomposeTransform(); this.revisibleView(view); } @@ -61,29 +70,8 @@ class transformController { } updateTransform(zoom) { - this.transform = getTransform(zoom); + this.transform = createTransform(zoom); this.transformAll(); - } - - getTransform() { - return this.transform; - } - - getBoundingRect() { - return this.rect; - } - - getViewBoundingRect(view) { - let rect = view.getBoundingRect(); - let scale = view.scale[0]; - let offsetX = view.position[0]; - let offsetY = view.position[1]; - - rect.width = rect.width * scale; - rect.height = rect.height * scale; - rect.x = rect.x * scale + offsetX; - rect.y = rect.y * scale + offsetY; - return rect; } } diff --git a/src/views/jmap/index.vue b/src/views/jmap/index.vue index c802ec2e7..d644d86ab 100644 --- a/src/views/jmap/index.vue +++ b/src/views/jmap/index.vue @@ -29,8 +29,8 @@ { code: '1', beg: { x: 20 , y: 50}, end: { x: 120, y: 50 } } ]; - for (var i = 1; i < 10; i++) { - for (var j = 1; j < 6000; j++) { + for (var i = 1; i < 2; i++) { + for (var j = 1; j < 70000; j++) { list.push({ code: `${i}${j}`, beg: { x: i * 120 + 50, y: j * 20 + 50}, end: { x: i * 120 + 150, y: j * 20 + 50 } }); } } @@ -42,15 +42,15 @@ ); // this.jmap.render([ - // {code: '2', type: 'Link', beg: { x: 20 , y: 100}, end: { x: 120, y: 100 }} + // {code: '11', type: 'Link', beg: { x: 20 , y: 100}, end: { x: 120, y: 100 }} // ]); - // this.jmap.update([ - // {code: '2', type: 'Link', status: '02'} - // ]); + this.jmap.update([ + {code: '11', type: 'Link', status: '02'} + ]); // this.jmap.render([ - // {code: '2', type: 'Link', beg: { x: 0 , y: 0}, end: { x: 200, y: 200 }} + // {code: '11', type: 'Link', beg: { x: 0 , y: 0}, end: { x: 200, y: 200 }} // ]); console.log(this.jmap.mapDevice, this.jmap.proxyData, this.jmap.data);