dcim-topology2d 1.1.6 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/activity-diagram/src/final/final.d.ts +1 -1
- package/activity-diagram/src/final/final.rect.d.ts +1 -1
- package/activity-diagram/src/final/final.rect.js +1 -1
- package/activity-diagram/src/fork/fork.anchor.d.ts +1 -1
- package/activity-diagram/src/fork/fork.anchor.js +1 -1
- package/activity-diagram/src/fork/fork.d.ts +1 -1
- package/activity-diagram/src/fork/fork.rect.d.ts +1 -1
- package/activity-diagram/src/fork/fork.rect.js +1 -1
- package/activity-diagram/src/register.js +1 -1
- package/activity-diagram/src/swimlaneH/swimlaneH.d.ts +1 -1
- package/activity-diagram/src/swimlaneH/swimlaneH.rect.d.ts +1 -1
- package/activity-diagram/src/swimlaneH/swimlaneH.rect.js +1 -1
- package/activity-diagram/src/swimlaneV/swimlaneV.d.ts +1 -1
- package/activity-diagram/src/swimlaneV/swimlaneV.rect.d.ts +1 -1
- package/activity-diagram/src/swimlaneV/swimlaneV.rect.js +1 -1
- package/chart-diagram/index.d.ts +0 -2
- package/chart-diagram/index.js +0 -1
- package/chart-diagram/src/echarts/index.d.ts +2 -1
- package/chart-diagram/src/echarts/index.js +104 -106
- package/chart-diagram/src/register.js +8 -9
- package/class-diagram/src/class/class.d.ts +1 -1
- package/class-diagram/src/class/class.rect.d.ts +1 -1
- package/class-diagram/src/class/class.rect.js +1 -1
- package/class-diagram/src/register.js +1 -1
- package/core/index.d.ts +0 -1
- package/core/index.js +0 -1
- package/core/src/activeLayer.d.ts +10 -2
- package/core/src/activeLayer.js +41 -42
- package/core/src/animateLayer.d.ts +7 -3
- package/core/src/animateLayer.js +12 -10
- package/core/src/calling.d.ts +4 -1
- package/core/src/calling.js +41 -43
- package/core/src/canvas.d.ts +6 -1
- package/core/src/canvas.js +18 -17
- package/core/src/common.d.ts +5 -5
- package/core/src/common.js +202 -172
- package/core/src/core.d.ts +4 -3
- package/core/src/core.js +321 -339
- package/core/src/divLayer.d.ts +33 -2
- package/core/src/divLayer.js +292 -41
- package/core/src/healps/changeData.d.ts +1 -1
- package/core/src/healps/changeData.js +44 -102
- package/core/src/hoverLayer.d.ts +9 -2
- package/core/src/hoverLayer.js +34 -31
- package/core/src/middles/default.d.ts +3 -1
- package/core/src/middles/default.js +51 -51
- package/core/src/middles/index.js +2 -3
- package/core/src/middles/nodes/pentagon.rect.js +1 -1
- package/core/src/middles/nodes/rectangle.rect.js +1 -1
- package/core/src/models/data.d.ts +26 -0
- package/core/src/models/data.js +77 -0
- package/core/src/models/data.js.map +1 -0
- package/core/src/models/index.d.ts +1 -0
- package/core/src/models/index.js +1 -0
- package/core/src/models/node.d.ts +0 -6
- package/core/src/models/node.js +16 -29
- package/core/src/models/pen.js +7 -16
- package/core/src/mqtt.d.ts +14 -0
- package/core/src/mqtt.js +82 -0
- package/core/src/mqtt.js.map +1 -0
- package/core/src/offscreen.d.ts +4 -1
- package/core/src/offscreen.js +8 -10
- package/core/src/options.js +0 -1
- package/core/src/poll.js +2 -0
- package/core/src/preview.d.ts +13 -1
- package/core/src/preview.js +34 -56
- package/core/src/renderLayer.d.ts +3 -1
- package/core/src/renderLayer.js +31 -26
- package/core/src/socket.d.ts +10 -0
- package/core/src/socket.js +51 -0
- package/core/src/socket.js.map +1 -0
- package/core/src/utils/canvas.js +1 -1
- package/core/src/utils/conversion.d.ts +0 -7
- package/core/src/utils/conversion.js +0 -54
- package/core/src/utils/dom.d.ts +5 -6
- package/core/src/utils/dom.js +46 -82
- package/core/src/utils/index.d.ts +0 -1
- package/core/src/utils/index.js +0 -1
- package/core/src/utils/onmousevent.js +3 -12
- package/flow-diagram/src/comment/comment.anchor.d.ts +1 -1
- package/flow-diagram/src/comment/comment.anchor.js +1 -1
- package/flow-diagram/src/comment/comment.d.ts +1 -1
- package/flow-diagram/src/data/data.anchor.d.ts +1 -1
- package/flow-diagram/src/data/data.anchor.js +1 -1
- package/flow-diagram/src/data/data.d.ts +1 -1
- package/flow-diagram/src/data/data.rect.d.ts +1 -1
- package/flow-diagram/src/data/data.rect.js +1 -1
- package/flow-diagram/src/db/db.d.ts +1 -1
- package/flow-diagram/src/db/db.rect.d.ts +1 -1
- package/flow-diagram/src/db/db.rect.js +1 -1
- package/flow-diagram/src/display/display.anchor.d.ts +1 -1
- package/flow-diagram/src/display/display.anchor.js +1 -1
- package/flow-diagram/src/display/display.d.ts +1 -1
- package/flow-diagram/src/display/display.rect.d.ts +1 -1
- package/flow-diagram/src/display/display.rect.js +1 -1
- package/flow-diagram/src/document/document.anchor.d.ts +1 -1
- package/flow-diagram/src/document/document.anchor.js +1 -1
- package/flow-diagram/src/document/document.d.ts +1 -1
- package/flow-diagram/src/document/document.rect.d.ts +1 -1
- package/flow-diagram/src/document/document.rect.js +1 -1
- package/flow-diagram/src/externStorage/externStorage.anchor.d.ts +1 -1
- package/flow-diagram/src/externStorage/externStorage.anchor.js +1 -1
- package/flow-diagram/src/externStorage/externStorage.d.ts +1 -1
- package/flow-diagram/src/externStorage/externStorage.rect.d.ts +1 -1
- package/flow-diagram/src/externStorage/externStorage.rect.js +1 -1
- package/flow-diagram/src/internalStorage/internalStorage.d.ts +1 -1
- package/flow-diagram/src/internalStorage/internalStorage.rect.d.ts +1 -1
- package/flow-diagram/src/internalStorage/internalStorage.rect.js +1 -1
- package/flow-diagram/src/manually/manually.anchor.d.ts +1 -1
- package/flow-diagram/src/manually/manually.anchor.js +1 -1
- package/flow-diagram/src/manually/manually.d.ts +1 -1
- package/flow-diagram/src/manually/manually.rect.d.ts +1 -1
- package/flow-diagram/src/manually/manually.rect.js +1 -1
- package/flow-diagram/src/parallel/parallel.anchor.d.ts +1 -1
- package/flow-diagram/src/parallel/parallel.anchor.js +1 -1
- package/flow-diagram/src/parallel/parallel.d.ts +1 -1
- package/flow-diagram/src/queue/queue.d.ts +1 -1
- package/flow-diagram/src/queue/queue.rect.d.ts +1 -1
- package/flow-diagram/src/queue/queue.rect.js +1 -1
- package/flow-diagram/src/register.js +1 -1
- package/flow-diagram/src/subprocess/subprocess.d.ts +1 -1
- package/flow-diagram/src/subprocess/subprocess.rect.d.ts +1 -1
- package/flow-diagram/src/subprocess/subprocess.rect.js +1 -1
- package/layout/src/align.d.ts +1 -1
- package/layout/src/align.js +1 -1
- package/layout/src/layout.d.ts +1 -1
- package/layout/src/layout.js +1 -1
- package/myShape-diagram/myShape.js +1 -1
- package/package.json +1 -1
- package/sequence-diagram/src/focus/focus.anchor.d.ts +1 -1
- package/sequence-diagram/src/focus/focus.anchor.js +1 -1
- package/sequence-diagram/src/focus/focus.d.ts +1 -1
- package/sequence-diagram/src/focus/focus.rect.d.ts +1 -1
- package/sequence-diagram/src/focus/focus.rect.js +1 -1
- package/sequence-diagram/src/lifeline/lifeline.anchor.d.ts +1 -1
- package/sequence-diagram/src/lifeline/lifeline.anchor.js +1 -1
- package/sequence-diagram/src/lifeline/lifeline.d.ts +1 -1
- package/sequence-diagram/src/lifeline/lifeline.rect.d.ts +1 -1
- package/sequence-diagram/src/lifeline/lifeline.rect.js +1 -1
- package/sequence-diagram/src/register.js +1 -1
- package/chart-diagram/src/utils/changeOptions.d.ts +0 -4
- package/chart-diagram/src/utils/changeOptions.js +0 -163
- package/chart-diagram/src/utils/conversion.d.ts +0 -17
- package/chart-diagram/src/utils/conversion.js +0 -179
- package/chart-diagram/src/utils/drawGraphic.d.ts +0 -3
- package/chart-diagram/src/utils/drawGraphic.js +0 -97
- package/chart-diagram/src/utils/index.d.ts +0 -3
- package/chart-diagram/src/utils/index.js +0 -3
- package/core/src/middles/arrows/index.d.ts +0 -4
- package/core/src/middles/arrows/index.js +0 -5
- package/core/src/middles/lines/index.d.ts +0 -4
- package/core/src/middles/lines/index.js +0 -5
- package/core/src/middles/nodes/iframe.d.ts +0 -2
- package/core/src/middles/nodes/iframe.js +0 -12
- package/core/src/middles/nodes/index.d.ts +0 -46
- package/core/src/middles/nodes/index.js +0 -47
- package/core/src/store/common.d.ts +0 -9
- package/core/src/store/common.js +0 -5
- package/core/src/store/data.d.ts +0 -129
- package/core/src/store/data.js +0 -86
- package/core/src/store/index.d.ts +0 -2
- package/core/src/store/index.js +0 -2
- package/core/src/utils/assignment.d.ts +0 -3
- package/core/src/utils/assignment.js +0 -69
- package/static/echartsDefaultData.js +0 -239
- package/static/echartsStore.js +0 -14
- package/static/index.js +0 -2
- package/style/index.css +0 -13
package/core/src/core.js
CHANGED
@@ -16,9 +16,9 @@ import { Common } from './common'
|
|
16
16
|
import {HoverLayer} from './hoverLayer';
|
17
17
|
import {ActiveLayer} from './activeLayer';
|
18
18
|
import {KeyType, KeydownType} from './options';
|
19
|
-
import {PenType, Node, Point, Line, Lock, AnchorMode, Rect} from './models';
|
19
|
+
import {PenType, Node, Point, Line, TopologyData, Lock, AnchorMode, Rect} from './models';
|
20
20
|
import {drawNodeFns, drawLineFns} from './middles/index';
|
21
|
-
import { s8, pointInRect, formatPadding,
|
21
|
+
import { s8, pointInRect, formatPadding, previewType} from './utils';
|
22
22
|
import axios from 'axios'
|
23
23
|
|
24
24
|
var resizeCursors = ['nw-resize', 'ne-resize', 'se-resize', 'sw-resize'];
|
@@ -27,8 +27,8 @@ var Topology = (function (_super) {
|
|
27
27
|
__extends(Topology, _super);
|
28
28
|
function Topology(parent, options) {
|
29
29
|
var _this = _super.call(this, parent, options) || this;
|
30
|
-
_this.hoverLayer = new HoverLayer(_this.id);
|
31
|
-
_this.activeLayer = new ActiveLayer(_this.id);
|
30
|
+
_this.hoverLayer = new HoverLayer(this.options, _this.id);
|
31
|
+
_this.activeLayer = new ActiveLayer(this.options, _this.id);
|
32
32
|
_this.offscreen.getRoutineLayer();
|
33
33
|
_this.activeLayer.topology = this;
|
34
34
|
_this.gridElem = document.createElement('div');
|
@@ -50,7 +50,7 @@ var Topology = (function (_super) {
|
|
50
50
|
if (Store.get('addingArbitraryGraph')) {
|
51
51
|
return
|
52
52
|
}
|
53
|
-
if (_this.scheduledAnimationFrame || _this.
|
53
|
+
if (_this.scheduledAnimationFrame || _this.data.locked === Lock.NoEvent) {
|
54
54
|
return;
|
55
55
|
}
|
56
56
|
// https://caniuse.com/#feat=mdn-api_mouseevent_buttons
|
@@ -61,7 +61,7 @@ var Topology = (function (_super) {
|
|
61
61
|
}
|
62
62
|
if (_this.mouseDown) {
|
63
63
|
var b = false;
|
64
|
-
switch (_this.
|
64
|
+
switch (_this.options.translateKey) {
|
65
65
|
case KeyType.None:
|
66
66
|
b = true;
|
67
67
|
break;
|
@@ -96,7 +96,7 @@ var Topology = (function (_super) {
|
|
96
96
|
return false;
|
97
97
|
}
|
98
98
|
}
|
99
|
-
if (_this.
|
99
|
+
if (_this.data.locked && _this.mouseDown) {
|
100
100
|
return;
|
101
101
|
}
|
102
102
|
_this.scheduledAnimationFrame = true;
|
@@ -150,18 +150,18 @@ var Topology = (function (_super) {
|
|
150
150
|
return;
|
151
151
|
}
|
152
152
|
// Move out parent element.
|
153
|
-
var moveOutX = pos.x + 50 > _this.
|
154
|
-
var moveOutY = pos.y + 50 > _this.
|
155
|
-
if (!_this.
|
153
|
+
var moveOutX = pos.x + 50 > _this.parentElem.clientWidth + _this.parentElem.scrollLeft;
|
154
|
+
var moveOutY = pos.y + 50 > _this.parentElem.clientHeight + _this.parentElem.scrollTop;
|
155
|
+
if (!_this.options.disableMoveOutParent && (moveOutX || moveOutY)) {
|
156
156
|
_this.dispatch('moveOutParent', pos);
|
157
|
-
if (_this.
|
157
|
+
if (_this.options.autoExpandDistance > 0) {
|
158
158
|
var resize = false;
|
159
159
|
if (pos.x + 50 > _this.divLayer.canvas.clientWidth) {
|
160
|
-
_this.canvas.width += _this.
|
160
|
+
_this.canvas.width += _this.options.autoExpandDistance;
|
161
161
|
resize = true;
|
162
162
|
}
|
163
163
|
if (pos.y + 50 > _this.divLayer.canvas.clientHeight) {
|
164
|
-
_this.canvas.height += _this.
|
164
|
+
_this.canvas.height += _this.options.autoExpandDistance;
|
165
165
|
resize = true;
|
166
166
|
}
|
167
167
|
if (resize) {
|
@@ -170,21 +170,20 @@ var Topology = (function (_super) {
|
|
170
170
|
height: _this.canvas.height,
|
171
171
|
});
|
172
172
|
}
|
173
|
-
_this.scroll(moveOutX ? _this.
|
173
|
+
_this.scroll(moveOutX ? _this.options.autoExpandDistance / 2 : 0, moveOutY ? _this.options.autoExpandDistance / 2 : 0);
|
174
174
|
}
|
175
175
|
}
|
176
|
-
var moveLeft = pos.x - 100 < _this.
|
177
|
-
var moveTop = pos.y - 100 < _this.
|
176
|
+
var moveLeft = pos.x - 100 < _this.parentElem.scrollLeft;
|
177
|
+
var moveTop = pos.y - 100 < _this.parentElem.scrollTop;
|
178
178
|
if ((moveLeft || moveTop)) {
|
179
179
|
_this.scroll(moveLeft ? -100 : 0, moveTop ? -100 : 0);
|
180
180
|
}
|
181
|
-
//console.log('_this.moveIn.type----', _this.moveIn.type)
|
181
|
+
// console.log('_this.moveIn.type----', _this.moveIn.type)
|
182
182
|
switch (_this.moveIn.type) {
|
183
183
|
case _this.moveInType.None:
|
184
184
|
_this.hoverLayer.dragRect = new Rect(_this.mouseDown.x, _this.mouseDown.y, pos.x - _this.mouseDown.x, pos.y - _this.mouseDown.y);
|
185
185
|
break;
|
186
186
|
case _this.moveInType.Nodes:
|
187
|
-
_this.store.data.dataResize = 0;
|
188
187
|
if (_this.activeLayer.locked()) {
|
189
188
|
break;
|
190
189
|
}
|
@@ -197,7 +196,6 @@ var Topology = (function (_super) {
|
|
197
196
|
}
|
198
197
|
break;
|
199
198
|
case _this.moveInType.ResizeCP:
|
200
|
-
_this.store.data.dataResize = 1;
|
201
199
|
var p1 = new Point(_this.mouseDown.x, _this.mouseDown.y);
|
202
200
|
var p2 = new Point(pos.x, pos.y);
|
203
201
|
var offsetX = p2.x - p1.x;
|
@@ -287,7 +285,7 @@ var Topology = (function (_super) {
|
|
287
285
|
|
288
286
|
} else {
|
289
287
|
|
290
|
-
var arrow = _this.
|
288
|
+
var arrow = _this.data.toArrowType;
|
291
289
|
if (_this.moveIn.hoverLine) {
|
292
290
|
arrow = _this.moveIn.hoverLine.toArrow;
|
293
291
|
}
|
@@ -341,7 +339,6 @@ var Topology = (function (_super) {
|
|
341
339
|
});
|
342
340
|
};
|
343
341
|
_this.onmousedown = function (e) {
|
344
|
-
_this.store.data.dataResize = 0;
|
345
342
|
if (e.button !== 0)
|
346
343
|
return;
|
347
344
|
var canvasPos = _this.divLayer.canvas.getBoundingClientRect();
|
@@ -378,7 +375,7 @@ var Topology = (function (_super) {
|
|
378
375
|
break;
|
379
376
|
case _this.moveInType.LineMove:
|
380
377
|
_this.hoverLayer.initLine = new Line(_this.moveIn.hoverLine);
|
381
|
-
if (_this.
|
378
|
+
if (_this.data.locked || _this.moveIn.hoverLine.locked) {
|
382
379
|
_this.moveIn.hoverLine.click();
|
383
380
|
}
|
384
381
|
// tslint:disable-next-line:no-switch-case-fall-through
|
@@ -396,12 +393,12 @@ var Topology = (function (_super) {
|
|
396
393
|
|
397
394
|
} else {
|
398
395
|
_this.hoverLayer.line = _this.addLine({
|
399
|
-
name: _this.
|
396
|
+
name: _this.data.lineName,
|
400
397
|
from: new Point(_this.moveIn.hoverNode.rotatedAnchors[_this.moveIn.hoverAnchorIndex].x, _this.moveIn.hoverNode.rotatedAnchors[_this.moveIn.hoverAnchorIndex].y, _this.moveIn.hoverNode.rotatedAnchors[_this.moveIn.hoverAnchorIndex].direction, _this.moveIn.hoverAnchorIndex, _this.moveIn.hoverNode.id),
|
401
|
-
fromArrow: _this.
|
398
|
+
fromArrow: _this.data.fromArrowType,
|
402
399
|
to: new Point(_this.moveIn.hoverNode.rotatedAnchors[_this.moveIn.hoverAnchorIndex].x, _this.moveIn.hoverNode.rotatedAnchors[_this.moveIn.hoverAnchorIndex].y),
|
403
|
-
toArrow: _this.
|
404
|
-
strokeStyle: _this.
|
400
|
+
toArrow: _this.data.toArrowType,
|
401
|
+
strokeStyle: _this.options.color,
|
405
402
|
});
|
406
403
|
_this.dispatch('anchor', {
|
407
404
|
anchor: _this.moveIn.hoverNode.rotatedAnchors[_this.moveIn.hoverAnchorIndex],
|
@@ -447,7 +444,7 @@ var Topology = (function (_super) {
|
|
447
444
|
if (activeNode && activeNode.name == 'arbitraryGraph') {
|
448
445
|
_this.dispatch('node', activeNode);
|
449
446
|
} else if (activeNode && activeNode.name == 'tablePagination') {
|
450
|
-
if (_this.
|
447
|
+
if (_this.options.type === 'topology') return _this.dispatch('node', activeNode);
|
451
448
|
const pnlKeys = Object.keys(activeNode.paginationData.pageNumberLocals);
|
452
449
|
const pageNumArea = pnlKeys.find((pna) => {
|
453
450
|
return e.offsetX - 32 < pna && e.offsetX - parseInt(pna) > 0
|
@@ -473,7 +470,7 @@ var Topology = (function (_super) {
|
|
473
470
|
}
|
474
471
|
}
|
475
472
|
}
|
476
|
-
if (_this.
|
473
|
+
if (_this.data.locked || _this.moveIn.activeNode.locked) {
|
477
474
|
_this.moveIn.activeNode.click();
|
478
475
|
}
|
479
476
|
break;
|
@@ -514,10 +511,10 @@ var Topology = (function (_super) {
|
|
514
511
|
if (_this.hoverLayer.line) {
|
515
512
|
var willAddLine = void 0;
|
516
513
|
if (_this.hoverLayer.line.to.id) {
|
517
|
-
if (!_this.
|
514
|
+
if (!_this.options.disableRepeatLine) {
|
518
515
|
willAddLine = true;
|
519
516
|
} else {
|
520
|
-
var lines = _this.
|
517
|
+
var lines = _this.data.pens.filter(function (pen) {
|
521
518
|
return pen.type === PenType.Line &&
|
522
519
|
pen.from.isSameAs(_this.hoverLayer.line.from) &&
|
523
520
|
pen.to.isSameAs(_this.hoverLayer.line.to);
|
@@ -525,13 +522,13 @@ var Topology = (function (_super) {
|
|
525
522
|
willAddLine = lines.length <= 1;
|
526
523
|
}
|
527
524
|
} else {
|
528
|
-
willAddLine = !_this.
|
525
|
+
willAddLine = !_this.options.disableEmptyLine;
|
529
526
|
}
|
530
527
|
if (willAddLine) {
|
531
528
|
_this.activeLayer.pens = [_this.hoverLayer.line];
|
532
529
|
_this.dispatch('addLine', _this.hoverLayer.line);
|
533
530
|
} else {
|
534
|
-
_this.
|
531
|
+
_this.data.pens.pop();
|
535
532
|
_this.activeLayer.clear();
|
536
533
|
}
|
537
534
|
}
|
@@ -550,7 +547,7 @@ var Topology = (function (_super) {
|
|
550
547
|
(!_this.hoverLayer.line.from.id || !_this.hoverLayer.line.to.id)) {
|
551
548
|
_this.needCache = true;
|
552
549
|
_this.activeLayer.clear();
|
553
|
-
_this.
|
550
|
+
_this.data.pens.splice(_this.findIndex(_this.hoverLayer.line), 1);
|
554
551
|
}
|
555
552
|
break;
|
556
553
|
}
|
@@ -563,7 +560,7 @@ var Topology = (function (_super) {
|
|
563
560
|
_this.needCache = false;
|
564
561
|
};
|
565
562
|
_this.onkeydown = function (key) {
|
566
|
-
if (_this.
|
563
|
+
if (_this.data.locked ||
|
567
564
|
key.target.tagName === 'INPUT' ||
|
568
565
|
key.target.tagName === 'TEXTAREA') {
|
569
566
|
return;
|
@@ -574,7 +571,7 @@ var Topology = (function (_super) {
|
|
574
571
|
switch (key.key) {
|
575
572
|
case 'a':
|
576
573
|
case 'A':
|
577
|
-
_this.activeLayer.setPens(_this.
|
574
|
+
_this.activeLayer.setPens(_this.data.pens);
|
578
575
|
_this.dispatch('multi', _this.activeLayer.pens);
|
579
576
|
done = true;
|
580
577
|
break;
|
@@ -678,45 +675,41 @@ var Topology = (function (_super) {
|
|
678
675
|
return;
|
679
676
|
var obj = JSON.parse(json);
|
680
677
|
event.preventDefault();
|
681
|
-
if(obj.
|
682
|
-
|
683
|
-
|
684
|
-
_this.
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
}
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
_this.
|
704
|
-
|
705
|
-
_this.
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
oZindex: -1, //是否达到起点
|
710
|
-
isDragging: false, //是否在抓取
|
711
|
-
close: false, //闭合
|
712
|
-
};
|
678
|
+
if (obj.name && obj.name == 'arbitraryGraph') {
|
679
|
+
Store.set('addingArbitraryGraph', true);
|
680
|
+
_this.addingArbitraryGraph = true;
|
681
|
+
_this.dispatch('addingArbitraryGraph', true);
|
682
|
+
return
|
683
|
+
}
|
684
|
+
_this.addingArbitraryGraph = false;
|
685
|
+
Store.set('addingArbitraryGraph', false);
|
686
|
+
_this.arbitrarygGraphData = {
|
687
|
+
points: [],
|
688
|
+
circles: [],
|
689
|
+
indexCircle: 0, //当前点击的圆圈
|
690
|
+
oZindex: -1, //是否达到起点
|
691
|
+
isDragging: false, //是否在抓取
|
692
|
+
close: false, //闭合
|
693
|
+
};
|
694
|
+
if (obj.name == 'temp') {
|
695
|
+
// 温湿度元件
|
696
|
+
let activeTempNodes = []
|
697
|
+
_this.dropNodes([obj.children[0]], event.offsetX - 23.5, event.offsetY)
|
698
|
+
activeTempNodes.push(_this.activeLayer.pens[0])
|
699
|
+
_this.dropNodes([obj.children[1]], event.offsetX + 11.5, event.offsetY - 8.5)
|
700
|
+
activeTempNodes.push(_this.activeLayer.pens[0])
|
701
|
+
_this.dropNodes([obj.children[2]], event.offsetX + 11.5, event.offsetY + 8.5)
|
702
|
+
activeTempNodes.push(_this.activeLayer.pens[0])
|
703
|
+
_this.activeLayer.pens = activeTempNodes
|
704
|
+
_this.combine(activeTempNodes, null, 'temp');
|
705
|
+
} else {
|
713
706
|
_this.dropNodes(Array.isArray(obj) ? obj : [obj], event.offsetX, event.offsetY);
|
714
707
|
}
|
715
708
|
} catch (_a) {
|
716
709
|
}
|
717
710
|
};
|
718
711
|
_this.subcribeAnimateMoved = Store.subscribe(this.generateStoreKey('LT:rectChanged'), function (e) {
|
719
|
-
_this.activeLayer.updateLines(_this.
|
712
|
+
_this.activeLayer.updateLines(_this.data.pens);
|
720
713
|
});
|
721
714
|
_this.subcribeMediaEnd = Store.subscribe(this.generateStoreKey('mediaEnd'), function (node) {
|
722
715
|
if (node.nextPlay) {
|
@@ -729,7 +722,7 @@ var Topology = (function (_super) {
|
|
729
722
|
if (window.location.pathname.includes('workspace')) {
|
730
723
|
return
|
731
724
|
}
|
732
|
-
_this.hidePenByTag(_this.
|
725
|
+
_this.hidePenByTag(_this.data.pens, e);
|
733
726
|
const obj = e ? JSON.parse(e) : {}
|
734
727
|
const visibleRange = obj.visibleRange
|
735
728
|
if (visibleRange == '1') {
|
@@ -740,10 +733,10 @@ var Topology = (function (_super) {
|
|
740
733
|
_this.divLayer.canvas.onmousedown = this.onmousedown;
|
741
734
|
_this.divLayer.canvas.onmouseup = this.onmouseup;
|
742
735
|
_this.divLayer.canvas.onwheel = function (event) {
|
743
|
-
if (_this.
|
736
|
+
if (_this.options.disableScale) {
|
744
737
|
return;
|
745
738
|
}
|
746
|
-
switch (_this.
|
739
|
+
switch (_this.options.scaleKey) {
|
747
740
|
case KeyType.None:
|
748
741
|
break;
|
749
742
|
case KeyType.Ctrl:
|
@@ -778,17 +771,17 @@ var Topology = (function (_super) {
|
|
778
771
|
} else {
|
779
772
|
if (event.layerX && event.layerY) {
|
780
773
|
_this.scale(0.9, {x: event.layerX, y: event.layerY});
|
781
|
-
|
774
|
+
_this.canvas.scale(0.9, {x: event.layerX, y: event.layerY});
|
782
775
|
} else {
|
783
776
|
_this.scale(0.9);
|
784
|
-
|
777
|
+
_this.canvas.scale(0.9);
|
785
778
|
}
|
786
779
|
}
|
787
780
|
_this.divLayer.canvas.focus();
|
788
781
|
return false;
|
789
782
|
};
|
790
783
|
_this.cache();
|
791
|
-
switch (_this.
|
784
|
+
switch (_this.options.keydown) {
|
792
785
|
case KeydownType.Document:
|
793
786
|
document.onkeydown = _this.onkeydown;
|
794
787
|
break;
|
@@ -802,7 +795,6 @@ var Topology = (function (_super) {
|
|
802
795
|
clearTimeout(timer);
|
803
796
|
}
|
804
797
|
timer = setTimeout(function () {
|
805
|
-
_this.resize();
|
806
798
|
_this.overflow();
|
807
799
|
_this.render();
|
808
800
|
}, 100);
|
@@ -811,26 +803,26 @@ var Topology = (function (_super) {
|
|
811
803
|
return _this;
|
812
804
|
}
|
813
805
|
// Render or redraw
|
814
|
-
Topology.prototype.render = function (noFocus) {
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
806
|
+
Topology.prototype.render = function (noFocus, type) {
|
807
|
+
try{
|
808
|
+
if (noFocus === void 0) {
|
809
|
+
noFocus = false;
|
810
|
+
}
|
811
|
+
if (noFocus) {
|
812
|
+
this.activeLayer.pens = [];
|
813
|
+
this.hoverLayer.node = null;
|
814
|
+
this.hoverLayer.line = null;
|
815
|
+
}
|
816
|
+
if (this.rendering) {
|
817
|
+
return this;
|
818
|
+
}
|
819
|
+
this.rendering = true;
|
820
|
+
this.offscreen.render();
|
821
|
+
this.canvas.render();
|
822
|
+
this.rendering = false;
|
823
|
+
}catch (e){
|
824
|
+
console.log('render-error-------------')
|
825
|
+
}
|
834
826
|
};
|
835
827
|
Topology.prototype.resize = function (size) {
|
836
828
|
this.canvasResize(size);
|
@@ -860,26 +852,58 @@ var Topology = (function (_super) {
|
|
860
852
|
}
|
861
853
|
if (json.name === 'lineAlone') {
|
862
854
|
_this.addLine({
|
863
|
-
name: _this.
|
855
|
+
name: _this.data.lineName,
|
864
856
|
from: new Point(json.rect.x, json.rect.y),
|
865
|
-
fromArrow: _this.
|
857
|
+
fromArrow: _this.data.fromArrowType,
|
866
858
|
to: new Point(json.rect.x + json.rect.width, json.rect.y + json.rect.height),
|
867
|
-
toArrow: _this.
|
868
|
-
strokeStyle: _this.
|
859
|
+
toArrow: _this.data.toArrowType,
|
860
|
+
strokeStyle: _this.options.color,
|
869
861
|
}, true);
|
870
862
|
}
|
871
863
|
|
872
864
|
if (json.name == 'define') {
|
865
|
+
|
873
866
|
// console.log('创建自定义组件 ', json);
|
867
|
+
|
874
868
|
console.log('store 中的 自定义 ', Store.get('defineNode'));
|
875
|
-
_this.
|
876
|
-
|
877
|
-
//
|
878
|
-
|
879
|
-
|
869
|
+
if (_this.data.locked) return
|
870
|
+
// let defineNode = Store.get('defineNode');
|
871
|
+
// let nodesList = Store.get('defineNode').pens;
|
872
|
+
let defineNode = JSON.parse(localStorage.getItem("defineNode_"))
|
873
|
+
let nodesList = defineNode.pens;
|
874
|
+
|
875
|
+
let renderNodesList = [];
|
876
|
+
|
877
|
+
for (let i = 0, len = nodesList.length; i < len; i++) {
|
878
|
+
|
879
|
+
nodesList[i].rect.x = offsetX - nodesList[i].rect.width / 2;
|
880
|
+
|
881
|
+
nodesList[i].rect.y = offsetY - nodesList[i].rect.height / 2;
|
882
|
+
|
883
|
+
let node = new Node(nodesList[i]);
|
884
|
+
|
885
|
+
node.setTID(s8());
|
886
|
+
node.id = s8();
|
887
|
+
node.fileId = defineNode.fileId;
|
888
|
+
|
889
|
+
// console.log('push之前的node', node);
|
890
|
+
|
891
|
+
_this.data.pens.push(node);
|
892
|
+
|
893
|
+
renderNodesList.push(node);
|
894
|
+
}
|
895
|
+
_this.activeLayer.setPens([renderNodesList[0]]);
|
896
|
+
|
897
|
+
_this.render(false);
|
898
|
+
|
899
|
+
_this.animate(true);
|
900
|
+
|
901
|
+
_this.cache();
|
902
|
+
|
903
|
+
_this.dispatch('addNode', renderNodesList[0]);
|
904
|
+
|
905
|
+
} else {
|
880
906
|
var node = new Node(json);
|
881
|
-
if(node.name === 'echarts') node.dash = 4;
|
882
|
-
if(node.name === 'iframe') node.iframe = 'http://www.yingzeshiji.com.cn/'; // 默认展示盈泽世纪官网
|
883
907
|
node.setTID(_this.id);
|
884
908
|
node.clearChildrenIds();
|
885
909
|
_this.addNode(node, true);
|
@@ -887,7 +911,7 @@ var Topology = (function (_super) {
|
|
887
911
|
_this.dispatch('LT:addDiv', node);
|
888
912
|
}
|
889
913
|
if (node.name === 'formTable') {
|
890
|
-
_this.
|
914
|
+
_this.data.dataConstruct[node.id] = {
|
891
915
|
id: node.id,
|
892
916
|
name: 'table'
|
893
917
|
}
|
@@ -896,107 +920,36 @@ var Topology = (function (_super) {
|
|
896
920
|
});
|
897
921
|
this.divLayer.canvas.focus();
|
898
922
|
};
|
899
|
-
Topology.prototype.
|
900
|
-
const item = new Node(node);
|
901
|
-
item.setTID(this.id);
|
902
|
-
item.clearChildrenIds();
|
903
|
-
return item;
|
904
|
-
};
|
905
|
-
// 添加温湿度元件
|
906
|
-
Topology.prototype.dropTempNode = function(json) {
|
907
|
-
const nodeChildren = json.children;
|
908
|
-
delete json['children'];
|
909
|
-
const node = this.setNodeData(json);
|
910
|
-
const combinTempData = [];
|
911
|
-
let nodeX = node.rect.x;
|
912
|
-
let nodeY = node.rect.y;
|
913
|
-
for (let i = 0; i < nodeChildren.length; i++) {
|
914
|
-
const childNode = this.setNodeData(nodeChildren[i]);
|
915
|
-
childNode.rect.x = i === 0 ? nodeX : nodeX + childNode.rect.width / 2;
|
916
|
-
childNode.rect.y = i === 2 ? nodeY + childNode.rect.height + 1 : nodeY;
|
917
|
-
childNode.rect.center = {
|
918
|
-
x: childNode.rect.x + childNode.rect.width / 2,
|
919
|
-
y: childNode.rect.y + childNode.rect.height / 2
|
920
|
-
}
|
921
|
-
childNode.rect.ex = childNode.rect.x + childNode.rect.width;
|
922
|
-
childNode.rect.ey = childNode.rect.y + childNode.rect.height;
|
923
|
-
combinTempData.push(childNode);
|
924
|
-
}
|
925
|
-
this.combine(combinTempData, null, 'temp');
|
926
|
-
this.render();
|
927
|
-
this.cache();
|
928
|
-
};
|
929
|
-
// 添加自定义元件
|
930
|
-
Topology.prototype.dropDefineNode = function(josn, offsetX, offsetY) {
|
931
|
-
var _this = this;
|
932
|
-
if (_this.store.data.locked) return
|
933
|
-
// let defineNode = Store.get('defineNode');
|
934
|
-
// let nodesList = Store.get('defineNode').pens;
|
935
|
-
let defineNode = JSON.parse(localStorage.getItem("defineNode_"))
|
936
|
-
let nodesList = defineNode.pens;
|
937
|
-
|
938
|
-
let renderNodesList = [];
|
939
|
-
|
940
|
-
for (let i = 0, len = nodesList.length; i < len; i++) {
|
941
|
-
|
942
|
-
nodesList[i].rect.x = offsetX - nodesList[i].rect.width / 2;
|
943
|
-
|
944
|
-
nodesList[i].rect.y = offsetY - nodesList[i].rect.height / 2;
|
945
|
-
|
946
|
-
let node = new Node(nodesList[i]);
|
947
|
-
|
948
|
-
node.setTID(s8());
|
949
|
-
node.id = s8();
|
950
|
-
node.fileId = defineNode.fileId;
|
951
|
-
|
952
|
-
// console.log('push之前的node', node);
|
953
|
-
|
954
|
-
_this.store.data.pens.push(node);
|
955
|
-
|
956
|
-
renderNodesList.push(node);
|
957
|
-
}
|
958
|
-
_this.activeLayer.setPens([renderNodesList[0]]);
|
959
|
-
|
960
|
-
_this.render(false);
|
961
|
-
|
962
|
-
_this.animate(true);
|
963
|
-
|
964
|
-
_this.cache();
|
965
|
-
|
966
|
-
_this.dispatch('addNode', renderNodesList[0]);
|
967
|
-
};
|
968
|
-
Topology.prototype.addNode = function (node, focus, visit) {
|
923
|
+
Topology.prototype.addNode = function (node, focus) {
|
969
924
|
if (focus === void 0) {
|
970
925
|
focus = false;
|
971
926
|
}
|
972
|
-
if (this.
|
927
|
+
if (this.data.locked || !drawNodeFns[node.name]) {
|
973
928
|
return null;
|
974
929
|
}
|
975
930
|
// if it's not a Node
|
976
931
|
if (!node.init) {
|
977
932
|
node = new Node(node);
|
978
933
|
}
|
979
|
-
if (!node.strokeStyle && this.
|
980
|
-
node.strokeStyle = this.
|
934
|
+
if (!node.strokeStyle && this.options.color) {
|
935
|
+
node.strokeStyle = this.options.color;
|
981
936
|
}
|
982
937
|
for (var key in node.font) {
|
983
938
|
if (!node.font[key]) {
|
984
|
-
node.font[key] = this.
|
939
|
+
node.font[key] = this.options.font[key];
|
985
940
|
}
|
986
941
|
}
|
987
|
-
if (this.
|
988
|
-
node.scale(this.
|
942
|
+
if (this.data.scale !== 1) {
|
943
|
+
node.scale(this.data.scale);
|
989
944
|
}
|
990
|
-
this.
|
991
|
-
this.setSwitchTabData(node, this.
|
945
|
+
this.data.pens.push(node);
|
946
|
+
this.setSwitchTabData(node, this.data.pens.length-1);
|
992
947
|
if (focus) {
|
948
|
+
this.activeLayer.setPens([node]);
|
993
949
|
this.render();
|
994
950
|
this.animate(true);
|
995
951
|
this.cache();
|
996
|
-
|
997
|
-
this.activeLayer.setPens([node]);
|
998
|
-
this.dispatch('addNode', node);
|
999
|
-
}
|
952
|
+
this.dispatch('addNode', node);
|
1000
953
|
}
|
1001
954
|
return node;
|
1002
955
|
};
|
@@ -1004,14 +957,14 @@ var Topology = (function (_super) {
|
|
1004
957
|
if (focus === void 0) {
|
1005
958
|
focus = false;
|
1006
959
|
}
|
1007
|
-
if (this.
|
960
|
+
if (this.data.locked) {
|
1008
961
|
return null;
|
1009
962
|
}
|
1010
963
|
if (!line.clone) {
|
1011
964
|
line = new Line(line);
|
1012
965
|
line.calcControlPoints(true);
|
1013
966
|
}
|
1014
|
-
this.
|
967
|
+
this.data.pens.push(line);
|
1015
968
|
if (focus) {
|
1016
969
|
this.activeLayer.setPens([line]);
|
1017
970
|
this.render();
|
@@ -1024,10 +977,10 @@ var Topology = (function (_super) {
|
|
1024
977
|
// open - redraw by the data
|
1025
978
|
Topology.prototype.open = function (topoJSon) {
|
1026
979
|
this.conversionData(topoJSon);
|
1027
|
-
Store.set(this.generateStoreKey('LT:scale'), this.
|
1028
|
-
this.dispatch('scale', this.
|
1029
|
-
this.
|
1030
|
-
this.
|
980
|
+
Store.set(this.generateStoreKey('LT:scale'), this.data.scale);
|
981
|
+
this.dispatch('scale', this.data.scale);
|
982
|
+
this.parentElem.scrollLeft = 0;
|
983
|
+
this.parentElem.scrollTop = 0;
|
1031
984
|
this.caches.list = [];
|
1032
985
|
this.divLayer.clear();
|
1033
986
|
this.cache();
|
@@ -1037,22 +990,22 @@ var Topology = (function (_super) {
|
|
1037
990
|
this.showGrid();
|
1038
991
|
};
|
1039
992
|
Topology.prototype.overflow = function () {
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
993
|
+
try {
|
994
|
+
var rect = this.getRect();
|
995
|
+
let _a = this.canvas;
|
996
|
+
if(!_a.width) return;
|
997
|
+
let width = _a.width, height = _a.height;
|
998
|
+
if (width < rect.width) {
|
999
|
+
width = rect.width;
|
1000
|
+
}
|
1001
|
+
if (height < rect.height) {
|
1002
|
+
height = rect.height;
|
1003
|
+
}
|
1004
|
+
this.resize({width: width, height: height});
|
1005
|
+
return rect;
|
1006
|
+
}catch (e){
|
1007
|
+
console.log('init-error-----------')
|
1008
|
+
}
|
1056
1009
|
};
|
1057
1010
|
Topology.prototype.getMoveIn = function (pt) {
|
1058
1011
|
this.lastHoverNode = this.moveIn.hoverNode;
|
@@ -1062,13 +1015,13 @@ var Topology = (function (_super) {
|
|
1062
1015
|
this.moveIn.lineControlPoint = null;
|
1063
1016
|
this.moveIn.hoverLine = null;
|
1064
1017
|
this.hoverLayer.hoverAnchorIndex = -1;
|
1065
|
-
if (!this.
|
1018
|
+
if (!this.data.locked &&
|
1066
1019
|
!(this.activeLayer.pens.length === 1 && this.activeLayer.pens[0].type) &&
|
1067
1020
|
!this.activeLayer.locked() &&
|
1068
1021
|
this.activeLayer.rotateCPs[0] &&
|
1069
1022
|
this.activeLayer.rotateCPs[0].hit(pt, 15)) {
|
1070
1023
|
this.moveIn.type = this.moveInType.Rotate;
|
1071
|
-
var cursor = this.
|
1024
|
+
var cursor = this.options.rotateCursor;
|
1072
1025
|
this.divLayer.canvas.style.cursor = cursor.includes('/')
|
1073
1026
|
? "url(\"" + cursor + "\"), auto"
|
1074
1027
|
: cursor;
|
@@ -1078,9 +1031,9 @@ var Topology = (function (_super) {
|
|
1078
1031
|
pointInRect(pt, this.activeLayer.sizeCPs)) {
|
1079
1032
|
this.moveIn.type = this.moveInType.Nodes;
|
1080
1033
|
}
|
1081
|
-
if (!this.
|
1034
|
+
if (!this.data.locked &&
|
1082
1035
|
!this.activeLayer.locked() &&
|
1083
|
-
!this.
|
1036
|
+
!this.options.hideSizeCP) {
|
1084
1037
|
if (this.activeLayer.pens.length > 1 ||
|
1085
1038
|
(!this.activeLayer.pens[0].type && !this.activeLayer.pens[0].hideSizeCP)) {
|
1086
1039
|
for (var i = 0; i < this.activeLayer.sizeCPs.length; ++i) {
|
@@ -1094,7 +1047,7 @@ var Topology = (function (_super) {
|
|
1094
1047
|
}
|
1095
1048
|
}
|
1096
1049
|
// In active pen.
|
1097
|
-
if (!this.
|
1050
|
+
if (!this.data.locked) {
|
1098
1051
|
for (var _i = 0, _a = this.activeLayer.pens; _i < _a.length; _i++) {
|
1099
1052
|
var item = _a[_i];
|
1100
1053
|
if (item instanceof Line && !item.locked) {
|
@@ -1114,15 +1067,14 @@ var Topology = (function (_super) {
|
|
1114
1067
|
}
|
1115
1068
|
}
|
1116
1069
|
}
|
1117
|
-
this.store.data.dataResize = 1;
|
1118
1070
|
this.divLayer.canvas.style.cursor = 'default';
|
1119
|
-
var len = this.
|
1071
|
+
var len = this.data.pens.length;
|
1120
1072
|
for (var i = len - 1; i > -1; --i) {
|
1121
|
-
if (this.
|
1122
|
-
this.inNode(pt, this.
|
1073
|
+
if (this.data.pens[i].type === PenType.Node &&
|
1074
|
+
this.inNode(pt, this.data.pens[i])) {
|
1123
1075
|
return;
|
1124
|
-
} else if (this.
|
1125
|
-
this.inLine(pt, this.
|
1076
|
+
} else if (this.data.pens[i].type === PenType.Line &&
|
1077
|
+
this.inLine(pt, this.data.pens[i])) {
|
1126
1078
|
// 需要优先判断十分在节点锚点上
|
1127
1079
|
// return;
|
1128
1080
|
}
|
@@ -1155,7 +1107,7 @@ var Topology = (function (_super) {
|
|
1155
1107
|
if (inChild === void 0) {
|
1156
1108
|
inChild = false;
|
1157
1109
|
}
|
1158
|
-
if (this.
|
1110
|
+
if (this.data.locked === Lock.NoEvent ||
|
1159
1111
|
(!node.visible && !window.location.pathname.includes('workspace')) ||
|
1160
1112
|
node.locked === Lock.NoEvent) {
|
1161
1113
|
return null;
|
@@ -1176,22 +1128,21 @@ var Topology = (function (_super) {
|
|
1176
1128
|
}
|
1177
1129
|
return child;
|
1178
1130
|
}
|
1179
|
-
if(!(node instanceof Node)) node = new Node(node);
|
1180
1131
|
if (node.hit(pt)) {
|
1181
1132
|
this.moveIn.hoverNode = node;
|
1182
1133
|
this.moveIn.type = this.moveInType.Nodes;
|
1183
1134
|
// 非绘画页面下禁止不包含点击、双击事件的节点选中鼠标样式
|
1184
1135
|
if (!this.checkNodeOfClickType(node)) {
|
1185
|
-
if (!this.
|
1136
|
+
if (!this.data.locked && !node.locked) {
|
1186
1137
|
this.divLayer.canvas.style.cursor = 'move';
|
1187
1138
|
} else {
|
1188
|
-
this.divLayer.canvas.style.cursor = this.
|
1139
|
+
this.divLayer.canvas.style.cursor = this.options.hoverCursor;
|
1189
1140
|
}
|
1190
1141
|
}
|
1191
1142
|
// Too small
|
1192
|
-
if (!this.
|
1143
|
+
if (!this.data.locked &&
|
1193
1144
|
!node.locked &&
|
1194
|
-
!(this.
|
1145
|
+
!(this.options.hideAnchor ||
|
1195
1146
|
node.hideAnchor ||
|
1196
1147
|
node.rect.width < 20 ||
|
1197
1148
|
node.rect.height < 20)) {
|
@@ -1214,9 +1165,9 @@ var Topology = (function (_super) {
|
|
1214
1165
|
}
|
1215
1166
|
return node;
|
1216
1167
|
}
|
1217
|
-
if (this.
|
1168
|
+
if (this.options.hideAnchor ||
|
1218
1169
|
node.hideAnchor ||
|
1219
|
-
this.
|
1170
|
+
this.data.locked ||
|
1220
1171
|
node.locked) {
|
1221
1172
|
return null;
|
1222
1173
|
}
|
@@ -1248,8 +1199,8 @@ var Topology = (function (_super) {
|
|
1248
1199
|
if (line.from.hit(point, 5)) {
|
1249
1200
|
this.moveIn.type = this.moveInType.LineFrom;
|
1250
1201
|
this.moveIn.hoverLine = line;
|
1251
|
-
if (this.
|
1252
|
-
this.divLayer.canvas.style.cursor = this.
|
1202
|
+
if (this.data.locked || line.locked) {
|
1203
|
+
this.divLayer.canvas.style.cursor = this.options.hoverCursor;
|
1253
1204
|
} else {
|
1254
1205
|
this.divLayer.canvas.style.cursor = 'move';
|
1255
1206
|
}
|
@@ -1258,8 +1209,8 @@ var Topology = (function (_super) {
|
|
1258
1209
|
if (line.to.hit(point, 5)) {
|
1259
1210
|
this.moveIn.type = this.moveInType.LineTo;
|
1260
1211
|
this.moveIn.hoverLine = line;
|
1261
|
-
if (this.
|
1262
|
-
this.divLayer.canvas.style.cursor = this.
|
1212
|
+
if (this.data.locked || line.locked) {
|
1213
|
+
this.divLayer.canvas.style.cursor = this.options.hoverCursor;
|
1263
1214
|
} else {
|
1264
1215
|
this.divLayer.canvas.style.cursor = 'move';
|
1265
1216
|
}
|
@@ -1268,7 +1219,7 @@ var Topology = (function (_super) {
|
|
1268
1219
|
if (line.pointIn(point)) {
|
1269
1220
|
this.moveIn.type = this.moveInType.LineMove;
|
1270
1221
|
this.moveIn.hoverLine = line;
|
1271
|
-
this.divLayer.canvas.style.cursor = this.
|
1222
|
+
this.divLayer.canvas.style.cursor = this.options.hoverCursor;
|
1272
1223
|
if (line.from.id || line.to.id) {
|
1273
1224
|
this.moveIn.type = this.moveInType.Line;
|
1274
1225
|
}
|
@@ -1278,7 +1229,7 @@ var Topology = (function (_super) {
|
|
1278
1229
|
};
|
1279
1230
|
Topology.prototype.getLineDock = function (point) {
|
1280
1231
|
this.hoverLayer.dockAnchor = null;
|
1281
|
-
for (var _i = 0, _a = this.
|
1232
|
+
for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
|
1282
1233
|
var item = _a[_i];
|
1283
1234
|
if (item instanceof Node) {
|
1284
1235
|
if (item.rect.hit(point, 10)) {
|
@@ -1345,7 +1296,7 @@ var Topology = (function (_super) {
|
|
1345
1296
|
rect.ey = rect.y + rect.height;
|
1346
1297
|
}
|
1347
1298
|
this.activeLayer.pens = [];
|
1348
|
-
for (var _i = 0, _a = this.
|
1299
|
+
for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
|
1349
1300
|
var item = _a[_i];
|
1350
1301
|
if (item.locked === Lock.NoEvent) {
|
1351
1302
|
continue;
|
@@ -1392,7 +1343,7 @@ var Topology = (function (_super) {
|
|
1392
1343
|
x: 0,
|
1393
1344
|
y: 0,
|
1394
1345
|
};
|
1395
|
-
if (noDock || this.
|
1346
|
+
if (noDock || this.options.disableDockLine) {
|
1396
1347
|
return offset;
|
1397
1348
|
}
|
1398
1349
|
var x = 0;
|
@@ -1401,7 +1352,7 @@ var Topology = (function (_super) {
|
|
1401
1352
|
var disY = dockOffset;
|
1402
1353
|
for (var _i = 0, _a = this.activeLayer.dockWatchers; _i < _a.length; _i++) {
|
1403
1354
|
var activePt = _a[_i];
|
1404
|
-
for (var _b = 0, _c = this.
|
1355
|
+
for (var _b = 0, _c = this.data.pens; _b < _c.length; _b++) {
|
1405
1356
|
var item = _c[_b];
|
1406
1357
|
if (!(item instanceof Node) ||
|
1407
1358
|
this.activeLayer.has(item) ||
|
@@ -1434,9 +1385,9 @@ var Topology = (function (_super) {
|
|
1434
1385
|
if (this.caches.index < this.caches.list.length - 1) {
|
1435
1386
|
this.caches.list.splice(this.caches.index + 1, this.caches.list.length - this.caches.index - 1);
|
1436
1387
|
}
|
1437
|
-
var data =
|
1388
|
+
var data = new TopologyData(this.data);
|
1438
1389
|
this.caches.list.push(data);
|
1439
|
-
if (this.caches.list.length > this.
|
1390
|
+
if (this.caches.list.length > this.options.cacheLen) {
|
1440
1391
|
this.caches.list.shift();
|
1441
1392
|
}
|
1442
1393
|
this.caches.index = this.caches.list.length - 1;
|
@@ -1469,31 +1420,31 @@ var Topology = (function (_super) {
|
|
1469
1420
|
if (noRedo === void 0) {
|
1470
1421
|
noRedo = false;
|
1471
1422
|
}
|
1472
|
-
if (this.
|
1423
|
+
if (this.data.locked || this.caches.index < 1) {
|
1473
1424
|
return;
|
1474
1425
|
}
|
1475
1426
|
this.divLayer.clear();
|
1476
|
-
var data =
|
1477
|
-
this.
|
1478
|
-
this.
|
1427
|
+
var data = new TopologyData(this.caches.list[--this.caches.index]);
|
1428
|
+
this.data.pens.splice(0, this.data.pens.length);
|
1429
|
+
this.data.pens.push.apply(this.data.pens, data.pens);
|
1479
1430
|
this.render(true);
|
1480
1431
|
this.divLayer.render();
|
1481
1432
|
if (noRedo) {
|
1482
1433
|
this.caches.list.splice(this.caches.index + 1, this.caches.list.length - this.caches.index - 1);
|
1483
1434
|
}
|
1484
|
-
this.dispatch('undo', this.
|
1435
|
+
this.dispatch('undo', this.data);
|
1485
1436
|
};
|
1486
1437
|
Topology.prototype.redo = function () {
|
1487
|
-
if (this.
|
1438
|
+
if (this.data.locked || this.caches.index > this.caches.list.length - 2) {
|
1488
1439
|
return;
|
1489
1440
|
}
|
1490
1441
|
this.divLayer.clear();
|
1491
|
-
var data =
|
1492
|
-
this.
|
1493
|
-
this.
|
1442
|
+
var data = new TopologyData(this.caches.list[++this.caches.index]);
|
1443
|
+
this.data.pens.splice(0, this.data.pens.length);
|
1444
|
+
this.data.pens.push.apply(this.data.pens, data.pens);
|
1494
1445
|
this.render(true);
|
1495
1446
|
this.divLayer.render();
|
1496
|
-
this.dispatch('redo', this.
|
1447
|
+
this.dispatch('redo', this.data);
|
1497
1448
|
};
|
1498
1449
|
Topology.prototype.toImage = function (type, quality, callback, padding, thumbnail) {
|
1499
1450
|
if (thumbnail === void 0) {
|
@@ -1557,13 +1508,13 @@ var Topology = (function (_super) {
|
|
1557
1508
|
}
|
1558
1509
|
var found = this.findIndex(pen);
|
1559
1510
|
if (found > -1) {
|
1560
|
-
if (this.
|
1561
|
-
this.divLayer.removeDiv(this.
|
1511
|
+
if (this.data.pens[found].type === PenType.Node) {
|
1512
|
+
this.divLayer.removeDiv(this.data.pens[found]);
|
1562
1513
|
}
|
1563
|
-
if (this.
|
1514
|
+
if (this.options.disableEmptyLine) {
|
1564
1515
|
this.delEmptyLines(pen.id);
|
1565
1516
|
}
|
1566
|
-
pens.push.apply(pens, this.
|
1517
|
+
pens.push.apply(pens, this.data.pens.splice(found, 1));
|
1567
1518
|
this.setSwitchTabData(pen, found, 'delete');
|
1568
1519
|
--i;
|
1569
1520
|
}
|
@@ -1577,16 +1528,16 @@ var Topology = (function (_super) {
|
|
1577
1528
|
this.dispatch('delete', pens);
|
1578
1529
|
};
|
1579
1530
|
Topology.prototype.delEmptyLines = function (deleteedId) {
|
1580
|
-
for (var i = 0; i < this.
|
1581
|
-
if (this.
|
1531
|
+
for (var i = 0; i < this.data.pens.length; i++) {
|
1532
|
+
if (this.data.pens[i].type !== PenType.Line) {
|
1582
1533
|
continue;
|
1583
1534
|
}
|
1584
|
-
var line = this.
|
1535
|
+
var line = this.data.pens[i];
|
1585
1536
|
if (!line.from.id ||
|
1586
1537
|
!line.to.id ||
|
1587
1538
|
line.from.id === deleteedId ||
|
1588
1539
|
line.to.id === deleteedId) {
|
1589
|
-
this.
|
1540
|
+
this.data.pens.splice(i, 1);
|
1590
1541
|
this.animateLayer.pens.delete(line.id);
|
1591
1542
|
--i;
|
1592
1543
|
}
|
@@ -1595,8 +1546,8 @@ var Topology = (function (_super) {
|
|
1595
1546
|
Topology.prototype.removeNode = function (node) {
|
1596
1547
|
var i = this.findIndex(node);
|
1597
1548
|
if (i > -1) {
|
1598
|
-
this.divLayer.removeDiv(this.
|
1599
|
-
var nodes = this.
|
1549
|
+
this.divLayer.removeDiv(this.data.pens[i]);
|
1550
|
+
var nodes = this.data.pens.splice(i, 1);
|
1600
1551
|
this.dispatch('delete', nodes);
|
1601
1552
|
}
|
1602
1553
|
this.render(true);
|
@@ -1605,28 +1556,28 @@ var Topology = (function (_super) {
|
|
1605
1556
|
Topology.prototype.removeLine = function (line) {
|
1606
1557
|
var i = this.findIndex(line);
|
1607
1558
|
if (i > -1) {
|
1608
|
-
var lines = this.
|
1559
|
+
var lines = this.data.pens.splice(i, 1);
|
1609
1560
|
this.dispatch('delete', lines);
|
1610
1561
|
}
|
1611
1562
|
this.render(true);
|
1612
1563
|
this.cache();
|
1613
1564
|
};
|
1614
1565
|
Topology.prototype.cut = function () {
|
1615
|
-
if (this.
|
1566
|
+
if (this.data.locked) {
|
1616
1567
|
return;
|
1617
1568
|
}
|
1618
|
-
this.clipboard = {
|
1569
|
+
this.clipboard = new TopologyData({
|
1619
1570
|
pens: [],
|
1620
|
-
};
|
1571
|
+
});
|
1621
1572
|
for (var i = 0; i < this.activeLayer.pens.length; i++) {
|
1622
1573
|
var pen = this.activeLayer.pens[i];
|
1623
1574
|
this.clipboard.pens.push(pen.clone());
|
1624
1575
|
var found = this.findIndex(pen);
|
1625
1576
|
if (found > -1) {
|
1626
1577
|
if (pen.type === PenType.Node) {
|
1627
|
-
this.divLayer.removeDiv(this.
|
1578
|
+
this.divLayer.removeDiv(this.data.pens[found]);
|
1628
1579
|
}
|
1629
|
-
this.
|
1580
|
+
this.data.pens.splice(found, 1);
|
1630
1581
|
--i;
|
1631
1582
|
}
|
1632
1583
|
}
|
@@ -1643,9 +1594,9 @@ var Topology = (function (_super) {
|
|
1643
1594
|
return item.animatePlay;
|
1644
1595
|
});
|
1645
1596
|
if(isAnimate) return false;
|
1646
|
-
this.clipboard = {
|
1597
|
+
this.clipboard = new TopologyData({
|
1647
1598
|
pens: [],
|
1648
|
-
};
|
1599
|
+
});
|
1649
1600
|
for (var _i = 0, _a = this.activeLayer.pens; _i < _a.length; _i++) {
|
1650
1601
|
var pen = _a[_i];
|
1651
1602
|
this.clipboard.pens.push(pen.clone());
|
@@ -1653,7 +1604,7 @@ var Topology = (function (_super) {
|
|
1653
1604
|
return true;
|
1654
1605
|
};
|
1655
1606
|
Topology.prototype.paste = function () {
|
1656
|
-
if (!this.clipboard || this.
|
1607
|
+
if (!this.clipboard || this.data.locked) {
|
1657
1608
|
return;
|
1658
1609
|
}
|
1659
1610
|
this.hoverLayer.node = null;
|
@@ -1694,9 +1645,9 @@ var Topology = (function (_super) {
|
|
1694
1645
|
}
|
1695
1646
|
pen.controlPoints = controlPoints;
|
1696
1647
|
}
|
1697
|
-
this.
|
1648
|
+
this.data.pens.push(pen);
|
1698
1649
|
this.activeLayer.add(pen);
|
1699
|
-
this.setSwitchTabData(pen, this.
|
1650
|
+
this.setSwitchTabData(pen, this.data.pens.length-1);
|
1700
1651
|
}
|
1701
1652
|
this.render();
|
1702
1653
|
this.animate(true);
|
@@ -1715,9 +1666,9 @@ var Topology = (function (_super) {
|
|
1715
1666
|
}
|
1716
1667
|
};
|
1717
1668
|
Topology.prototype.bind = function (item, exite, dataType, index) {
|
1718
|
-
this.clipboard = {
|
1669
|
+
this.clipboard = new TopologyData({
|
1719
1670
|
pens: [],
|
1720
|
-
};
|
1671
|
+
});
|
1721
1672
|
for (var _i = 0, _a = this.activeLayer.pens; _i < _a.length; _i++) {
|
1722
1673
|
var pen = _a[_i];
|
1723
1674
|
pen.data = []
|
@@ -1729,20 +1680,46 @@ var Topology = (function (_super) {
|
|
1729
1680
|
}
|
1730
1681
|
};
|
1731
1682
|
Topology.prototype.bindInfo = async function (item, pen, type, index) {
|
1732
|
-
if (
|
1733
|
-
|
1734
|
-
|
1683
|
+
if (type == 0) {
|
1684
|
+
pen.data.push({
|
1685
|
+
"key": "tagId",
|
1686
|
+
"value": item.tagId,
|
1687
|
+
"isControlDis": item.isControlDis,
|
1688
|
+
"type": item.tagType,
|
1689
|
+
"tagVal": item.value,
|
1690
|
+
"valExplain": item.valExplain,
|
1691
|
+
"tagId": item.tagId
|
1692
|
+
}, {
|
1693
|
+
"key": "测点名称",
|
1694
|
+
"value": item.tagName
|
1695
|
+
})
|
1696
|
+
let obj = {
|
1697
|
+
"key": "threeCategoryId",
|
1698
|
+
"value": item.threeCategoryId
|
1699
|
+
}
|
1735
1700
|
// 绑定悬浮文字
|
1736
1701
|
pen.title = item.touchpname
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
} else if (
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1702
|
+
if (!JSON.stringify(pen.data).includes(JSON.stringify(obj))) {
|
1703
|
+
pen.data.push(obj)
|
1704
|
+
}
|
1705
|
+
} else if (type == 1) {
|
1706
|
+
pen.data.push({
|
1707
|
+
"key": "kpiAddr",
|
1708
|
+
"value": item.kpiId + '_' + item.kpiAddr,
|
1709
|
+
"isControlDis": item.isControlDis,
|
1710
|
+
"type": item.tagType
|
1711
|
+
}, {
|
1712
|
+
"key": "指标名称",
|
1713
|
+
"value": item.kpiName
|
1714
|
+
})
|
1715
|
+
} else if (type == 2) {
|
1716
|
+
pen.data.push({
|
1717
|
+
"key": "assetId",
|
1718
|
+
"value": item.id
|
1719
|
+
}, {
|
1720
|
+
"key": "资产名称",
|
1721
|
+
"value": item.name
|
1722
|
+
})
|
1746
1723
|
// 绑定悬浮文字
|
1747
1724
|
pen.title = item.bak
|
1748
1725
|
if (pen.subName && pen.subName == 'temp') {
|
@@ -1776,16 +1753,22 @@ var Topology = (function (_super) {
|
|
1776
1753
|
}]
|
1777
1754
|
})
|
1778
1755
|
}
|
1779
|
-
} else if (
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
//
|
1756
|
+
} else if (type == 3) {
|
1757
|
+
pen.data.push({
|
1758
|
+
"key": "areaId",
|
1759
|
+
"value": item.id
|
1760
|
+
}, {
|
1761
|
+
"key": "区域名称",
|
1762
|
+
"value": item.name
|
1763
|
+
})
|
1764
|
+
}
|
1765
|
+
// let str = JSON.stringify(pen.events)
|
1766
|
+
// pen.events.forEach((_item) => {
|
1767
|
+
// if(_item.action==0 && _item.dcimDetailPage && _item.dcimDetailPage != '' && item.devId){
|
1768
|
+
// str = str.replace(new RegExp(_item.dcimAssetValue,'g'), item.devId)
|
1769
|
+
// }
|
1770
|
+
// });
|
1771
|
+
// pen.events = JSON.parse(str)
|
1789
1772
|
return pen
|
1790
1773
|
};
|
1791
1774
|
Topology.prototype.newId = function (node, idMaps) {
|
@@ -1832,15 +1815,15 @@ var Topology = (function (_super) {
|
|
1832
1815
|
cache && this.cache();
|
1833
1816
|
};
|
1834
1817
|
Topology.prototype.lock = function (lock) {
|
1835
|
-
this.
|
1836
|
-
for (var _i = 0, _a = this.
|
1818
|
+
this.data.locked = lock;
|
1819
|
+
for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
|
1837
1820
|
var item = _a[_i];
|
1838
1821
|
item.addToDiv && item.addToDiv();
|
1839
1822
|
}
|
1840
|
-
this.dispatch('locked', this.
|
1823
|
+
this.dispatch('locked', this.data.locked);
|
1841
1824
|
};
|
1842
1825
|
Topology.prototype.lockPens = function (pens, lock) {
|
1843
|
-
for (var _i = 0, _a = this.
|
1826
|
+
for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
|
1844
1827
|
var item = _a[_i];
|
1845
1828
|
for (var _b = 0, pens_2 = pens; _b < pens_2.length; _b++) {
|
1846
1829
|
var pen = pens_2[_b];
|
@@ -1858,33 +1841,33 @@ var Topology = (function (_super) {
|
|
1858
1841
|
};
|
1859
1842
|
Topology.prototype.up = function (pen) {
|
1860
1843
|
var i = this.findIndex(pen);
|
1861
|
-
if (i > -1 && i !== this.
|
1862
|
-
this.
|
1863
|
-
this.
|
1844
|
+
if (i > -1 && i !== this.data.pens.length - 1) {
|
1845
|
+
this.data.pens.splice(i + 2, 0, this.data.pens[i]);
|
1846
|
+
this.data.pens.splice(i, 1);
|
1864
1847
|
}
|
1865
1848
|
};
|
1866
1849
|
Topology.prototype.top = function (pen) {
|
1867
1850
|
var i = this.findIndex(pen);
|
1868
1851
|
if (i > -1) {
|
1869
|
-
this.
|
1870
|
-
this.
|
1852
|
+
this.data.pens.push(this.data.pens[i]);
|
1853
|
+
this.data.pens.splice(i, 1);
|
1871
1854
|
}
|
1872
1855
|
};
|
1873
1856
|
Topology.prototype.down = function (pen) {
|
1874
1857
|
var i = this.findIndex(pen);
|
1875
1858
|
if (i > -1 && i !== 0) {
|
1876
|
-
this.
|
1877
|
-
this.
|
1859
|
+
this.data.pens.splice(i - 1, 0, this.data.pens[i]);
|
1860
|
+
this.data.pens.splice(i + 1, 1);
|
1878
1861
|
}
|
1879
1862
|
};
|
1880
1863
|
Topology.prototype.bottom = function (pen) {
|
1881
1864
|
var i = this.findIndex(pen);
|
1882
1865
|
if (i > -1) {
|
1883
|
-
this.
|
1884
|
-
this.
|
1866
|
+
this.data.pens.unshift(this.data.pens[i]);
|
1867
|
+
this.data.pens.splice(i + 1, 1);
|
1885
1868
|
}
|
1886
1869
|
};
|
1887
|
-
Topology.prototype.combine = function (pens, stand, temp
|
1870
|
+
Topology.prototype.combine = function (pens, stand, temp) {
|
1888
1871
|
if (stand === void 0) {
|
1889
1872
|
stand = false;
|
1890
1873
|
}
|
@@ -1897,7 +1880,7 @@ var Topology = (function (_super) {
|
|
1897
1880
|
var item = pens_3[_i];
|
1898
1881
|
var i = this.findIndex(item);
|
1899
1882
|
if (i > -1) {
|
1900
|
-
this.
|
1883
|
+
this.data.pens.splice(i, 1);
|
1901
1884
|
}
|
1902
1885
|
}
|
1903
1886
|
var node = new Node({
|
@@ -1922,7 +1905,7 @@ var Topology = (function (_super) {
|
|
1922
1905
|
item.calcRectInParent(node);
|
1923
1906
|
node.children.push(item);
|
1924
1907
|
}
|
1925
|
-
this.
|
1908
|
+
this.data.pens.push(node);
|
1926
1909
|
this.activeLayer.setPens([node]);
|
1927
1910
|
this.dispatch('node', node);
|
1928
1911
|
this.cache();
|
@@ -1940,11 +1923,11 @@ var Topology = (function (_super) {
|
|
1940
1923
|
item.parentId = undefined;
|
1941
1924
|
item.rectInParent = undefined;
|
1942
1925
|
item.locked = Lock.None;
|
1943
|
-
this.
|
1926
|
+
this.data.pens.push(item);
|
1944
1927
|
}
|
1945
1928
|
var i = this.findIndex(nodeChildren);
|
1946
1929
|
if (i > -1 && nodeChildren.name === 'combine') {
|
1947
|
-
this.
|
1930
|
+
this.data.pens.splice(i, 1);
|
1948
1931
|
} else {
|
1949
1932
|
nodeChildren.children = null;
|
1950
1933
|
}
|
@@ -1955,7 +1938,7 @@ var Topology = (function (_super) {
|
|
1955
1938
|
Topology.prototype.find = function (idOrTag, pens) {
|
1956
1939
|
var _this = this;
|
1957
1940
|
if (!pens) {
|
1958
|
-
pens = this.
|
1941
|
+
pens = this.data.pens;
|
1959
1942
|
}
|
1960
1943
|
var result = [];
|
1961
1944
|
pens.forEach(function (item) {
|
@@ -1972,28 +1955,28 @@ var Topology = (function (_super) {
|
|
1972
1955
|
return result;
|
1973
1956
|
};
|
1974
1957
|
Topology.prototype.findIndex = function (pen) {
|
1975
|
-
for (var i = 0; i < this.
|
1976
|
-
if (pen.id === this.
|
1958
|
+
for (var i = 0; i < this.data.pens.length; ++i) {
|
1959
|
+
if (pen.id === this.data.pens[i].id) {
|
1977
1960
|
return i;
|
1978
1961
|
}
|
1979
1962
|
}
|
1980
1963
|
return -1;
|
1981
1964
|
};
|
1982
1965
|
Topology.prototype.anchor = function (anchor) {
|
1983
|
-
this.
|
1966
|
+
this.options.hideAnchor = anchor
|
1984
1967
|
this.dispatch('hideAnchor', anchor);
|
1985
1968
|
};
|
1986
1969
|
// scale for scaled canvas:
|
1987
1970
|
// > 1, expand
|
1988
1971
|
// < 1, reduce
|
1989
1972
|
Topology.prototype.scale = function (scale, center, w, h) {
|
1990
|
-
if (this.
|
1991
|
-
this.
|
1973
|
+
if (this.data.scale * scale < this.options.minScale ||
|
1974
|
+
this.data.scale * scale > this.options.maxScale) {
|
1992
1975
|
return;
|
1993
1976
|
}
|
1994
|
-
this.
|
1977
|
+
this.data.scale *= scale;
|
1995
1978
|
!center && (center = this.getRect().center);
|
1996
|
-
for (var _i = 0, _a = this.
|
1979
|
+
for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
|
1997
1980
|
var item = _a[_i];
|
1998
1981
|
item.scale(scale, center, w, h);
|
1999
1982
|
}
|
@@ -2002,18 +1985,18 @@ var Topology = (function (_super) {
|
|
2002
1985
|
pen.scale(scale, center);
|
2003
1986
|
}
|
2004
1987
|
});
|
2005
|
-
Store.set(this.generateStoreKey('LT:scale'), this.
|
1988
|
+
Store.set(this.generateStoreKey('LT:scale'), this.data.scale);
|
2006
1989
|
this.render();
|
2007
1990
|
this.cache();
|
2008
|
-
this.dispatch('scale', this.
|
1991
|
+
this.dispatch('scale', this.data.scale);
|
2009
1992
|
};
|
2010
1993
|
// scale for origin canvas:
|
2011
1994
|
Topology.prototype.scaleTo = function (scale) {
|
2012
|
-
this.scale(scale / this.
|
2013
|
-
this.
|
1995
|
+
this.scale(scale / this.data.scale);
|
1996
|
+
this.data.scale = scale;
|
2014
1997
|
};
|
2015
1998
|
Topology.prototype.round = function () {
|
2016
|
-
for (var _i = 0, _a = this.
|
1999
|
+
for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
|
2017
2000
|
var item = _a[_i];
|
2018
2001
|
if (item instanceof Node) {
|
2019
2002
|
item.round();
|
@@ -2024,7 +2007,7 @@ var Topology = (function (_super) {
|
|
2024
2007
|
if (!this.hasView())
|
2025
2008
|
return;
|
2026
2009
|
// 1. 重置画布尺寸为容器尺寸
|
2027
|
-
var parentElem = this.
|
2010
|
+
var parentElem = this.canvas.parentElem;
|
2028
2011
|
var width = parentElem.offsetWidth, height = parentElem.offsetHeight;
|
2029
2012
|
this.resize({
|
2030
2013
|
width: width,
|
@@ -2033,7 +2016,7 @@ var Topology = (function (_super) {
|
|
2033
2016
|
// 2. 图形居中
|
2034
2017
|
this.centerView(viewPadding);
|
2035
2018
|
// 3. 获取设置的留白值
|
2036
|
-
var padding = formatPadding(viewPadding || this.
|
2019
|
+
var padding = formatPadding(viewPadding || this.options.viewPadding);
|
2037
2020
|
// 4. 获取图形尺寸
|
2038
2021
|
var rect = this.getRect();
|
2039
2022
|
// 6. 计算缩放比
|
@@ -2046,7 +2029,7 @@ var Topology = (function (_super) {
|
|
2046
2029
|
this.scale(ratio);
|
2047
2030
|
};
|
2048
2031
|
Topology.prototype.showTipText = function (data, pos) {
|
2049
|
-
if (this.
|
2032
|
+
if (this.data.locked && data.title) {
|
2050
2033
|
this.divLayer.canvas.title = data.title;
|
2051
2034
|
this.tip = data.id;
|
2052
2035
|
}
|
@@ -2057,15 +2040,15 @@ var Topology = (function (_super) {
|
|
2057
2040
|
return;
|
2058
2041
|
}
|
2059
2042
|
this.scrolling = true;
|
2060
|
-
this.
|
2061
|
-
this.
|
2043
|
+
this.parentElem.scrollLeft += x;
|
2044
|
+
this.parentElem.scrollTop += y;
|
2062
2045
|
setTimeout(function () {
|
2063
2046
|
_this.scrolling = false;
|
2064
2047
|
}, 700);
|
2065
2048
|
};
|
2066
2049
|
Topology.prototype.toComponent = function (pens) {
|
2067
2050
|
if (!pens) {
|
2068
|
-
pens = this.
|
2051
|
+
pens = this.data.pens;
|
2069
2052
|
}
|
2070
2053
|
var rect = this.getRect(pens);
|
2071
2054
|
var node = new Node({
|
@@ -2106,7 +2089,7 @@ var Topology = (function (_super) {
|
|
2106
2089
|
attr = 'text';
|
2107
2090
|
}
|
2108
2091
|
var pen;
|
2109
|
-
this.
|
2092
|
+
this.data.pens.forEach(function (item) {
|
2110
2093
|
if (item.id === idOrTag || item.tags.indexOf(idOrTag) > -1) {
|
2111
2094
|
pen = item;
|
2112
2095
|
}
|
@@ -2118,7 +2101,7 @@ var Topology = (function (_super) {
|
|
2118
2101
|
attr = 'text';
|
2119
2102
|
}
|
2120
2103
|
var pen;
|
2121
|
-
this.
|
2104
|
+
this.data.pens.forEach(function (item) {
|
2122
2105
|
if (item.id === idOrTag || item.tags.indexOf(idOrTag) > -1) {
|
2123
2106
|
pen = item;
|
2124
2107
|
}
|
@@ -2131,12 +2114,11 @@ var Topology = (function (_super) {
|
|
2131
2114
|
this.gridElem.style.left = '0';
|
2132
2115
|
this.gridElem.style.top = '0';
|
2133
2116
|
this.gridElem.innerHTML = "<svg class=\"svg-grid\" width=\"100%\" height=\"100%\" style=\"position:absolute;left:0;right:0;top:0;bottom:0\"\n xmlns=\"http://www.w3.org/2000/svg\">\n <defs>\n <pattern id=\"grid\" width=\"10\" height=\"10\" patternUnits=\"userSpaceOnUse\">\n <path d=\"M 10 0 L 0 0 0 10\" fill=\"none\" stroke=\"#f3f3f3\" stroke-width=\"1\" />\n </pattern>\n </defs>\n <rect width=\"100%\" height=\"100%\" fill=\"url(#grid)\" />\n </svg>";
|
2134
|
-
this.
|
2117
|
+
this.parentElem.appendChild(this.gridElem);
|
2135
2118
|
};
|
2136
2119
|
Topology.prototype.showGrid = function (show) {
|
2137
|
-
if(!this.store || !this.store.data) return;
|
2138
2120
|
if (show === undefined) {
|
2139
|
-
show = this.
|
2121
|
+
show = this.data.grid;
|
2140
2122
|
}
|
2141
2123
|
this.gridElem.style.width = this.canvas.width + 'px';
|
2142
2124
|
this.gridElem.style.height = this.canvas.height + 'px';
|
@@ -2227,7 +2209,7 @@ var Topology = (function (_super) {
|
|
2227
2209
|
canvas.style.height = 500 + 'px';
|
2228
2210
|
canvas.style.zIndex = 1;
|
2229
2211
|
canvas.setAttribute('id', 'arbitraryCanvas');
|
2230
|
-
this.
|
2212
|
+
this.parentElem.appendChild(canvas)
|
2231
2213
|
};
|
2232
2214
|
Topology.prototype.createArbitraryGraph = function () {
|
2233
2215
|
|