dcim-topology2d 1.1.3 → 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/src/echarts/index.d.ts +1 -1
- package/chart-diagram/src/echarts/index.js +7 -10
- package/chart-diagram/src/register.js +1 -1
- 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 -40
- 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 +115 -161
- package/core/src/core.d.ts +4 -3
- package/core/src/core.js +253 -228
- package/core/src/divLayer.d.ts +7 -2
- package/core/src/divLayer.js +25 -25
- package/core/src/healps/changeData.d.ts +1 -1
- package/core/src/healps/changeData.js +42 -77
- package/core/src/hoverLayer.d.ts +9 -2
- package/core/src/hoverLayer.js +34 -31
- 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.js +12 -14
- package/core/src/models/pen.js +1 -10
- 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 -42
- 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 -4
- package/core/src/utils/dom.js +1 -3
- 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/core/src/store/common.d.ts +0 -9
- package/core/src/store/common.js +0 -5
- package/core/src/store/data.d.ts +0 -126
- package/core/src/store/data.js +0 -80
- package/core/src/store/index.d.ts +0 -2
- package/core/src/store/index.js +0 -2
- package/static/echartsDefaultData.js +0 -95
- package/static/index.js +0 -1
- package/style/index.css +0 -10
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,11 +170,11 @@ 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
|
}
|
@@ -285,7 +285,7 @@ var Topology = (function (_super) {
|
|
285
285
|
|
286
286
|
} else {
|
287
287
|
|
288
|
-
var arrow = _this.
|
288
|
+
var arrow = _this.data.toArrowType;
|
289
289
|
if (_this.moveIn.hoverLine) {
|
290
290
|
arrow = _this.moveIn.hoverLine.toArrow;
|
291
291
|
}
|
@@ -375,7 +375,7 @@ var Topology = (function (_super) {
|
|
375
375
|
break;
|
376
376
|
case _this.moveInType.LineMove:
|
377
377
|
_this.hoverLayer.initLine = new Line(_this.moveIn.hoverLine);
|
378
|
-
if (_this.
|
378
|
+
if (_this.data.locked || _this.moveIn.hoverLine.locked) {
|
379
379
|
_this.moveIn.hoverLine.click();
|
380
380
|
}
|
381
381
|
// tslint:disable-next-line:no-switch-case-fall-through
|
@@ -393,12 +393,12 @@ var Topology = (function (_super) {
|
|
393
393
|
|
394
394
|
} else {
|
395
395
|
_this.hoverLayer.line = _this.addLine({
|
396
|
-
name: _this.
|
396
|
+
name: _this.data.lineName,
|
397
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),
|
398
|
-
fromArrow: _this.
|
398
|
+
fromArrow: _this.data.fromArrowType,
|
399
399
|
to: new Point(_this.moveIn.hoverNode.rotatedAnchors[_this.moveIn.hoverAnchorIndex].x, _this.moveIn.hoverNode.rotatedAnchors[_this.moveIn.hoverAnchorIndex].y),
|
400
|
-
toArrow: _this.
|
401
|
-
strokeStyle: _this.
|
400
|
+
toArrow: _this.data.toArrowType,
|
401
|
+
strokeStyle: _this.options.color,
|
402
402
|
});
|
403
403
|
_this.dispatch('anchor', {
|
404
404
|
anchor: _this.moveIn.hoverNode.rotatedAnchors[_this.moveIn.hoverAnchorIndex],
|
@@ -444,7 +444,7 @@ var Topology = (function (_super) {
|
|
444
444
|
if (activeNode && activeNode.name == 'arbitraryGraph') {
|
445
445
|
_this.dispatch('node', activeNode);
|
446
446
|
} else if (activeNode && activeNode.name == 'tablePagination') {
|
447
|
-
if (_this.
|
447
|
+
if (_this.options.type === 'topology') return _this.dispatch('node', activeNode);
|
448
448
|
const pnlKeys = Object.keys(activeNode.paginationData.pageNumberLocals);
|
449
449
|
const pageNumArea = pnlKeys.find((pna) => {
|
450
450
|
return e.offsetX - 32 < pna && e.offsetX - parseInt(pna) > 0
|
@@ -470,7 +470,7 @@ var Topology = (function (_super) {
|
|
470
470
|
}
|
471
471
|
}
|
472
472
|
}
|
473
|
-
if (_this.
|
473
|
+
if (_this.data.locked || _this.moveIn.activeNode.locked) {
|
474
474
|
_this.moveIn.activeNode.click();
|
475
475
|
}
|
476
476
|
break;
|
@@ -511,10 +511,10 @@ var Topology = (function (_super) {
|
|
511
511
|
if (_this.hoverLayer.line) {
|
512
512
|
var willAddLine = void 0;
|
513
513
|
if (_this.hoverLayer.line.to.id) {
|
514
|
-
if (!_this.
|
514
|
+
if (!_this.options.disableRepeatLine) {
|
515
515
|
willAddLine = true;
|
516
516
|
} else {
|
517
|
-
var lines = _this.
|
517
|
+
var lines = _this.data.pens.filter(function (pen) {
|
518
518
|
return pen.type === PenType.Line &&
|
519
519
|
pen.from.isSameAs(_this.hoverLayer.line.from) &&
|
520
520
|
pen.to.isSameAs(_this.hoverLayer.line.to);
|
@@ -522,13 +522,13 @@ var Topology = (function (_super) {
|
|
522
522
|
willAddLine = lines.length <= 1;
|
523
523
|
}
|
524
524
|
} else {
|
525
|
-
willAddLine = !_this.
|
525
|
+
willAddLine = !_this.options.disableEmptyLine;
|
526
526
|
}
|
527
527
|
if (willAddLine) {
|
528
528
|
_this.activeLayer.pens = [_this.hoverLayer.line];
|
529
529
|
_this.dispatch('addLine', _this.hoverLayer.line);
|
530
530
|
} else {
|
531
|
-
_this.
|
531
|
+
_this.data.pens.pop();
|
532
532
|
_this.activeLayer.clear();
|
533
533
|
}
|
534
534
|
}
|
@@ -547,7 +547,7 @@ var Topology = (function (_super) {
|
|
547
547
|
(!_this.hoverLayer.line.from.id || !_this.hoverLayer.line.to.id)) {
|
548
548
|
_this.needCache = true;
|
549
549
|
_this.activeLayer.clear();
|
550
|
-
_this.
|
550
|
+
_this.data.pens.splice(_this.findIndex(_this.hoverLayer.line), 1);
|
551
551
|
}
|
552
552
|
break;
|
553
553
|
}
|
@@ -560,7 +560,7 @@ var Topology = (function (_super) {
|
|
560
560
|
_this.needCache = false;
|
561
561
|
};
|
562
562
|
_this.onkeydown = function (key) {
|
563
|
-
if (_this.
|
563
|
+
if (_this.data.locked ||
|
564
564
|
key.target.tagName === 'INPUT' ||
|
565
565
|
key.target.tagName === 'TEXTAREA') {
|
566
566
|
return;
|
@@ -571,7 +571,7 @@ var Topology = (function (_super) {
|
|
571
571
|
switch (key.key) {
|
572
572
|
case 'a':
|
573
573
|
case 'A':
|
574
|
-
_this.activeLayer.setPens(_this.
|
574
|
+
_this.activeLayer.setPens(_this.data.pens);
|
575
575
|
_this.dispatch('multi', _this.activeLayer.pens);
|
576
576
|
done = true;
|
577
577
|
break;
|
@@ -709,7 +709,7 @@ var Topology = (function (_super) {
|
|
709
709
|
}
|
710
710
|
};
|
711
711
|
_this.subcribeAnimateMoved = Store.subscribe(this.generateStoreKey('LT:rectChanged'), function (e) {
|
712
|
-
_this.activeLayer.updateLines(_this.
|
712
|
+
_this.activeLayer.updateLines(_this.data.pens);
|
713
713
|
});
|
714
714
|
_this.subcribeMediaEnd = Store.subscribe(this.generateStoreKey('mediaEnd'), function (node) {
|
715
715
|
if (node.nextPlay) {
|
@@ -722,7 +722,7 @@ var Topology = (function (_super) {
|
|
722
722
|
if (window.location.pathname.includes('workspace')) {
|
723
723
|
return
|
724
724
|
}
|
725
|
-
_this.hidePenByTag(_this.
|
725
|
+
_this.hidePenByTag(_this.data.pens, e);
|
726
726
|
const obj = e ? JSON.parse(e) : {}
|
727
727
|
const visibleRange = obj.visibleRange
|
728
728
|
if (visibleRange == '1') {
|
@@ -733,10 +733,10 @@ var Topology = (function (_super) {
|
|
733
733
|
_this.divLayer.canvas.onmousedown = this.onmousedown;
|
734
734
|
_this.divLayer.canvas.onmouseup = this.onmouseup;
|
735
735
|
_this.divLayer.canvas.onwheel = function (event) {
|
736
|
-
if (_this.
|
736
|
+
if (_this.options.disableScale) {
|
737
737
|
return;
|
738
738
|
}
|
739
|
-
switch (_this.
|
739
|
+
switch (_this.options.scaleKey) {
|
740
740
|
case KeyType.None:
|
741
741
|
break;
|
742
742
|
case KeyType.Ctrl:
|
@@ -771,17 +771,17 @@ var Topology = (function (_super) {
|
|
771
771
|
} else {
|
772
772
|
if (event.layerX && event.layerY) {
|
773
773
|
_this.scale(0.9, {x: event.layerX, y: event.layerY});
|
774
|
-
|
774
|
+
_this.canvas.scale(0.9, {x: event.layerX, y: event.layerY});
|
775
775
|
} else {
|
776
776
|
_this.scale(0.9);
|
777
|
-
|
777
|
+
_this.canvas.scale(0.9);
|
778
778
|
}
|
779
779
|
}
|
780
780
|
_this.divLayer.canvas.focus();
|
781
781
|
return false;
|
782
782
|
};
|
783
783
|
_this.cache();
|
784
|
-
switch (_this.
|
784
|
+
switch (_this.options.keydown) {
|
785
785
|
case KeydownType.Document:
|
786
786
|
document.onkeydown = _this.onkeydown;
|
787
787
|
break;
|
@@ -795,7 +795,6 @@ var Topology = (function (_super) {
|
|
795
795
|
clearTimeout(timer);
|
796
796
|
}
|
797
797
|
timer = setTimeout(function () {
|
798
|
-
_this.resize();
|
799
798
|
_this.overflow();
|
800
799
|
_this.render();
|
801
800
|
}, 100);
|
@@ -804,26 +803,26 @@ var Topology = (function (_super) {
|
|
804
803
|
return _this;
|
805
804
|
}
|
806
805
|
// Render or redraw
|
807
|
-
Topology.prototype.render = function (noFocus) {
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
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
|
+
}
|
827
826
|
};
|
828
827
|
Topology.prototype.resize = function (size) {
|
829
828
|
this.canvasResize(size);
|
@@ -853,12 +852,12 @@ var Topology = (function (_super) {
|
|
853
852
|
}
|
854
853
|
if (json.name === 'lineAlone') {
|
855
854
|
_this.addLine({
|
856
|
-
name: _this.
|
855
|
+
name: _this.data.lineName,
|
857
856
|
from: new Point(json.rect.x, json.rect.y),
|
858
|
-
fromArrow: _this.
|
857
|
+
fromArrow: _this.data.fromArrowType,
|
859
858
|
to: new Point(json.rect.x + json.rect.width, json.rect.y + json.rect.height),
|
860
|
-
toArrow: _this.
|
861
|
-
strokeStyle: _this.
|
859
|
+
toArrow: _this.data.toArrowType,
|
860
|
+
strokeStyle: _this.options.color,
|
862
861
|
}, true);
|
863
862
|
}
|
864
863
|
|
@@ -867,7 +866,7 @@ var Topology = (function (_super) {
|
|
867
866
|
// console.log('创建自定义组件 ', json);
|
868
867
|
|
869
868
|
console.log('store 中的 自定义 ', Store.get('defineNode'));
|
870
|
-
if (_this.
|
869
|
+
if (_this.data.locked) return
|
871
870
|
// let defineNode = Store.get('defineNode');
|
872
871
|
// let nodesList = Store.get('defineNode').pens;
|
873
872
|
let defineNode = JSON.parse(localStorage.getItem("defineNode_"))
|
@@ -889,7 +888,7 @@ var Topology = (function (_super) {
|
|
889
888
|
|
890
889
|
// console.log('push之前的node', node);
|
891
890
|
|
892
|
-
_this.
|
891
|
+
_this.data.pens.push(node);
|
893
892
|
|
894
893
|
renderNodesList.push(node);
|
895
894
|
}
|
@@ -905,7 +904,6 @@ var Topology = (function (_super) {
|
|
905
904
|
|
906
905
|
} else {
|
907
906
|
var node = new Node(json);
|
908
|
-
if(node.name === 'echarts') node.dash = 4;
|
909
907
|
node.setTID(_this.id);
|
910
908
|
node.clearChildrenIds();
|
911
909
|
_this.addNode(node, true);
|
@@ -913,7 +911,7 @@ var Topology = (function (_super) {
|
|
913
911
|
_this.dispatch('LT:addDiv', node);
|
914
912
|
}
|
915
913
|
if (node.name === 'formTable') {
|
916
|
-
_this.
|
914
|
+
_this.data.dataConstruct[node.id] = {
|
917
915
|
id: node.id,
|
918
916
|
name: 'table'
|
919
917
|
}
|
@@ -922,35 +920,32 @@ var Topology = (function (_super) {
|
|
922
920
|
});
|
923
921
|
this.divLayer.canvas.focus();
|
924
922
|
};
|
925
|
-
Topology.prototype.addNode = function (node, focus
|
923
|
+
Topology.prototype.addNode = function (node, focus) {
|
926
924
|
if (focus === void 0) {
|
927
925
|
focus = false;
|
928
926
|
}
|
929
|
-
if (this.
|
927
|
+
if (this.data.locked || !drawNodeFns[node.name]) {
|
930
928
|
return null;
|
931
929
|
}
|
932
930
|
// if it's not a Node
|
933
931
|
if (!node.init) {
|
934
932
|
node = new Node(node);
|
935
933
|
}
|
936
|
-
if (!node.strokeStyle && this.
|
937
|
-
node.strokeStyle = this.
|
934
|
+
if (!node.strokeStyle && this.options.color) {
|
935
|
+
node.strokeStyle = this.options.color;
|
938
936
|
}
|
939
937
|
for (var key in node.font) {
|
940
938
|
if (!node.font[key]) {
|
941
|
-
node.font[key] = this.
|
939
|
+
node.font[key] = this.options.font[key];
|
942
940
|
}
|
943
941
|
}
|
944
|
-
if (this.
|
945
|
-
node.scale(this.
|
942
|
+
if (this.data.scale !== 1) {
|
943
|
+
node.scale(this.data.scale);
|
946
944
|
}
|
947
|
-
this.
|
948
|
-
this.setSwitchTabData(node, this.
|
945
|
+
this.data.pens.push(node);
|
946
|
+
this.setSwitchTabData(node, this.data.pens.length-1);
|
949
947
|
if (focus) {
|
950
|
-
|
951
|
-
this.activeLayer.setPens([node]);
|
952
|
-
this.dispatch('addNode', node);
|
953
|
-
}
|
948
|
+
this.activeLayer.setPens([node]);
|
954
949
|
this.render();
|
955
950
|
this.animate(true);
|
956
951
|
this.cache();
|
@@ -962,14 +957,14 @@ var Topology = (function (_super) {
|
|
962
957
|
if (focus === void 0) {
|
963
958
|
focus = false;
|
964
959
|
}
|
965
|
-
if (this.
|
960
|
+
if (this.data.locked) {
|
966
961
|
return null;
|
967
962
|
}
|
968
963
|
if (!line.clone) {
|
969
964
|
line = new Line(line);
|
970
965
|
line.calcControlPoints(true);
|
971
966
|
}
|
972
|
-
this.
|
967
|
+
this.data.pens.push(line);
|
973
968
|
if (focus) {
|
974
969
|
this.activeLayer.setPens([line]);
|
975
970
|
this.render();
|
@@ -982,10 +977,10 @@ var Topology = (function (_super) {
|
|
982
977
|
// open - redraw by the data
|
983
978
|
Topology.prototype.open = function (topoJSon) {
|
984
979
|
this.conversionData(topoJSon);
|
985
|
-
Store.set(this.generateStoreKey('LT:scale'), this.
|
986
|
-
this.dispatch('scale', this.
|
987
|
-
this.
|
988
|
-
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;
|
989
984
|
this.caches.list = [];
|
990
985
|
this.divLayer.clear();
|
991
986
|
this.cache();
|
@@ -995,22 +990,22 @@ var Topology = (function (_super) {
|
|
995
990
|
this.showGrid();
|
996
991
|
};
|
997
992
|
Topology.prototype.overflow = function () {
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
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
|
+
}
|
1014
1009
|
};
|
1015
1010
|
Topology.prototype.getMoveIn = function (pt) {
|
1016
1011
|
this.lastHoverNode = this.moveIn.hoverNode;
|
@@ -1020,13 +1015,13 @@ var Topology = (function (_super) {
|
|
1020
1015
|
this.moveIn.lineControlPoint = null;
|
1021
1016
|
this.moveIn.hoverLine = null;
|
1022
1017
|
this.hoverLayer.hoverAnchorIndex = -1;
|
1023
|
-
if (!this.
|
1018
|
+
if (!this.data.locked &&
|
1024
1019
|
!(this.activeLayer.pens.length === 1 && this.activeLayer.pens[0].type) &&
|
1025
1020
|
!this.activeLayer.locked() &&
|
1026
1021
|
this.activeLayer.rotateCPs[0] &&
|
1027
1022
|
this.activeLayer.rotateCPs[0].hit(pt, 15)) {
|
1028
1023
|
this.moveIn.type = this.moveInType.Rotate;
|
1029
|
-
var cursor = this.
|
1024
|
+
var cursor = this.options.rotateCursor;
|
1030
1025
|
this.divLayer.canvas.style.cursor = cursor.includes('/')
|
1031
1026
|
? "url(\"" + cursor + "\"), auto"
|
1032
1027
|
: cursor;
|
@@ -1036,9 +1031,9 @@ var Topology = (function (_super) {
|
|
1036
1031
|
pointInRect(pt, this.activeLayer.sizeCPs)) {
|
1037
1032
|
this.moveIn.type = this.moveInType.Nodes;
|
1038
1033
|
}
|
1039
|
-
if (!this.
|
1034
|
+
if (!this.data.locked &&
|
1040
1035
|
!this.activeLayer.locked() &&
|
1041
|
-
!this.
|
1036
|
+
!this.options.hideSizeCP) {
|
1042
1037
|
if (this.activeLayer.pens.length > 1 ||
|
1043
1038
|
(!this.activeLayer.pens[0].type && !this.activeLayer.pens[0].hideSizeCP)) {
|
1044
1039
|
for (var i = 0; i < this.activeLayer.sizeCPs.length; ++i) {
|
@@ -1052,7 +1047,7 @@ var Topology = (function (_super) {
|
|
1052
1047
|
}
|
1053
1048
|
}
|
1054
1049
|
// In active pen.
|
1055
|
-
if (!this.
|
1050
|
+
if (!this.data.locked) {
|
1056
1051
|
for (var _i = 0, _a = this.activeLayer.pens; _i < _a.length; _i++) {
|
1057
1052
|
var item = _a[_i];
|
1058
1053
|
if (item instanceof Line && !item.locked) {
|
@@ -1073,13 +1068,13 @@ var Topology = (function (_super) {
|
|
1073
1068
|
}
|
1074
1069
|
}
|
1075
1070
|
this.divLayer.canvas.style.cursor = 'default';
|
1076
|
-
var len = this.
|
1071
|
+
var len = this.data.pens.length;
|
1077
1072
|
for (var i = len - 1; i > -1; --i) {
|
1078
|
-
if (this.
|
1079
|
-
this.inNode(pt, this.
|
1073
|
+
if (this.data.pens[i].type === PenType.Node &&
|
1074
|
+
this.inNode(pt, this.data.pens[i])) {
|
1080
1075
|
return;
|
1081
|
-
} else if (this.
|
1082
|
-
this.inLine(pt, this.
|
1076
|
+
} else if (this.data.pens[i].type === PenType.Line &&
|
1077
|
+
this.inLine(pt, this.data.pens[i])) {
|
1083
1078
|
// 需要优先判断十分在节点锚点上
|
1084
1079
|
// return;
|
1085
1080
|
}
|
@@ -1112,7 +1107,7 @@ var Topology = (function (_super) {
|
|
1112
1107
|
if (inChild === void 0) {
|
1113
1108
|
inChild = false;
|
1114
1109
|
}
|
1115
|
-
if (this.
|
1110
|
+
if (this.data.locked === Lock.NoEvent ||
|
1116
1111
|
(!node.visible && !window.location.pathname.includes('workspace')) ||
|
1117
1112
|
node.locked === Lock.NoEvent) {
|
1118
1113
|
return null;
|
@@ -1133,22 +1128,21 @@ var Topology = (function (_super) {
|
|
1133
1128
|
}
|
1134
1129
|
return child;
|
1135
1130
|
}
|
1136
|
-
if(!(node instanceof Node)) node = new Node(node);
|
1137
1131
|
if (node.hit(pt)) {
|
1138
1132
|
this.moveIn.hoverNode = node;
|
1139
1133
|
this.moveIn.type = this.moveInType.Nodes;
|
1140
1134
|
// 非绘画页面下禁止不包含点击、双击事件的节点选中鼠标样式
|
1141
1135
|
if (!this.checkNodeOfClickType(node)) {
|
1142
|
-
if (!this.
|
1136
|
+
if (!this.data.locked && !node.locked) {
|
1143
1137
|
this.divLayer.canvas.style.cursor = 'move';
|
1144
1138
|
} else {
|
1145
|
-
this.divLayer.canvas.style.cursor = this.
|
1139
|
+
this.divLayer.canvas.style.cursor = this.options.hoverCursor;
|
1146
1140
|
}
|
1147
1141
|
}
|
1148
1142
|
// Too small
|
1149
|
-
if (!this.
|
1143
|
+
if (!this.data.locked &&
|
1150
1144
|
!node.locked &&
|
1151
|
-
!(this.
|
1145
|
+
!(this.options.hideAnchor ||
|
1152
1146
|
node.hideAnchor ||
|
1153
1147
|
node.rect.width < 20 ||
|
1154
1148
|
node.rect.height < 20)) {
|
@@ -1171,9 +1165,9 @@ var Topology = (function (_super) {
|
|
1171
1165
|
}
|
1172
1166
|
return node;
|
1173
1167
|
}
|
1174
|
-
if (this.
|
1168
|
+
if (this.options.hideAnchor ||
|
1175
1169
|
node.hideAnchor ||
|
1176
|
-
this.
|
1170
|
+
this.data.locked ||
|
1177
1171
|
node.locked) {
|
1178
1172
|
return null;
|
1179
1173
|
}
|
@@ -1205,8 +1199,8 @@ var Topology = (function (_super) {
|
|
1205
1199
|
if (line.from.hit(point, 5)) {
|
1206
1200
|
this.moveIn.type = this.moveInType.LineFrom;
|
1207
1201
|
this.moveIn.hoverLine = line;
|
1208
|
-
if (this.
|
1209
|
-
this.divLayer.canvas.style.cursor = this.
|
1202
|
+
if (this.data.locked || line.locked) {
|
1203
|
+
this.divLayer.canvas.style.cursor = this.options.hoverCursor;
|
1210
1204
|
} else {
|
1211
1205
|
this.divLayer.canvas.style.cursor = 'move';
|
1212
1206
|
}
|
@@ -1215,8 +1209,8 @@ var Topology = (function (_super) {
|
|
1215
1209
|
if (line.to.hit(point, 5)) {
|
1216
1210
|
this.moveIn.type = this.moveInType.LineTo;
|
1217
1211
|
this.moveIn.hoverLine = line;
|
1218
|
-
if (this.
|
1219
|
-
this.divLayer.canvas.style.cursor = this.
|
1212
|
+
if (this.data.locked || line.locked) {
|
1213
|
+
this.divLayer.canvas.style.cursor = this.options.hoverCursor;
|
1220
1214
|
} else {
|
1221
1215
|
this.divLayer.canvas.style.cursor = 'move';
|
1222
1216
|
}
|
@@ -1225,7 +1219,7 @@ var Topology = (function (_super) {
|
|
1225
1219
|
if (line.pointIn(point)) {
|
1226
1220
|
this.moveIn.type = this.moveInType.LineMove;
|
1227
1221
|
this.moveIn.hoverLine = line;
|
1228
|
-
this.divLayer.canvas.style.cursor = this.
|
1222
|
+
this.divLayer.canvas.style.cursor = this.options.hoverCursor;
|
1229
1223
|
if (line.from.id || line.to.id) {
|
1230
1224
|
this.moveIn.type = this.moveInType.Line;
|
1231
1225
|
}
|
@@ -1235,7 +1229,7 @@ var Topology = (function (_super) {
|
|
1235
1229
|
};
|
1236
1230
|
Topology.prototype.getLineDock = function (point) {
|
1237
1231
|
this.hoverLayer.dockAnchor = null;
|
1238
|
-
for (var _i = 0, _a = this.
|
1232
|
+
for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
|
1239
1233
|
var item = _a[_i];
|
1240
1234
|
if (item instanceof Node) {
|
1241
1235
|
if (item.rect.hit(point, 10)) {
|
@@ -1302,7 +1296,7 @@ var Topology = (function (_super) {
|
|
1302
1296
|
rect.ey = rect.y + rect.height;
|
1303
1297
|
}
|
1304
1298
|
this.activeLayer.pens = [];
|
1305
|
-
for (var _i = 0, _a = this.
|
1299
|
+
for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
|
1306
1300
|
var item = _a[_i];
|
1307
1301
|
if (item.locked === Lock.NoEvent) {
|
1308
1302
|
continue;
|
@@ -1349,7 +1343,7 @@ var Topology = (function (_super) {
|
|
1349
1343
|
x: 0,
|
1350
1344
|
y: 0,
|
1351
1345
|
};
|
1352
|
-
if (noDock || this.
|
1346
|
+
if (noDock || this.options.disableDockLine) {
|
1353
1347
|
return offset;
|
1354
1348
|
}
|
1355
1349
|
var x = 0;
|
@@ -1358,7 +1352,7 @@ var Topology = (function (_super) {
|
|
1358
1352
|
var disY = dockOffset;
|
1359
1353
|
for (var _i = 0, _a = this.activeLayer.dockWatchers; _i < _a.length; _i++) {
|
1360
1354
|
var activePt = _a[_i];
|
1361
|
-
for (var _b = 0, _c = this.
|
1355
|
+
for (var _b = 0, _c = this.data.pens; _b < _c.length; _b++) {
|
1362
1356
|
var item = _c[_b];
|
1363
1357
|
if (!(item instanceof Node) ||
|
1364
1358
|
this.activeLayer.has(item) ||
|
@@ -1391,9 +1385,9 @@ var Topology = (function (_super) {
|
|
1391
1385
|
if (this.caches.index < this.caches.list.length - 1) {
|
1392
1386
|
this.caches.list.splice(this.caches.index + 1, this.caches.list.length - this.caches.index - 1);
|
1393
1387
|
}
|
1394
|
-
var data =
|
1388
|
+
var data = new TopologyData(this.data);
|
1395
1389
|
this.caches.list.push(data);
|
1396
|
-
if (this.caches.list.length > this.
|
1390
|
+
if (this.caches.list.length > this.options.cacheLen) {
|
1397
1391
|
this.caches.list.shift();
|
1398
1392
|
}
|
1399
1393
|
this.caches.index = this.caches.list.length - 1;
|
@@ -1426,31 +1420,31 @@ var Topology = (function (_super) {
|
|
1426
1420
|
if (noRedo === void 0) {
|
1427
1421
|
noRedo = false;
|
1428
1422
|
}
|
1429
|
-
if (this.
|
1423
|
+
if (this.data.locked || this.caches.index < 1) {
|
1430
1424
|
return;
|
1431
1425
|
}
|
1432
1426
|
this.divLayer.clear();
|
1433
|
-
var data =
|
1434
|
-
this.
|
1435
|
-
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);
|
1436
1430
|
this.render(true);
|
1437
1431
|
this.divLayer.render();
|
1438
1432
|
if (noRedo) {
|
1439
1433
|
this.caches.list.splice(this.caches.index + 1, this.caches.list.length - this.caches.index - 1);
|
1440
1434
|
}
|
1441
|
-
this.dispatch('undo', this.
|
1435
|
+
this.dispatch('undo', this.data);
|
1442
1436
|
};
|
1443
1437
|
Topology.prototype.redo = function () {
|
1444
|
-
if (this.
|
1438
|
+
if (this.data.locked || this.caches.index > this.caches.list.length - 2) {
|
1445
1439
|
return;
|
1446
1440
|
}
|
1447
1441
|
this.divLayer.clear();
|
1448
|
-
var data =
|
1449
|
-
this.
|
1450
|
-
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);
|
1451
1445
|
this.render(true);
|
1452
1446
|
this.divLayer.render();
|
1453
|
-
this.dispatch('redo', this.
|
1447
|
+
this.dispatch('redo', this.data);
|
1454
1448
|
};
|
1455
1449
|
Topology.prototype.toImage = function (type, quality, callback, padding, thumbnail) {
|
1456
1450
|
if (thumbnail === void 0) {
|
@@ -1514,13 +1508,13 @@ var Topology = (function (_super) {
|
|
1514
1508
|
}
|
1515
1509
|
var found = this.findIndex(pen);
|
1516
1510
|
if (found > -1) {
|
1517
|
-
if (this.
|
1518
|
-
this.divLayer.removeDiv(this.
|
1511
|
+
if (this.data.pens[found].type === PenType.Node) {
|
1512
|
+
this.divLayer.removeDiv(this.data.pens[found]);
|
1519
1513
|
}
|
1520
|
-
if (this.
|
1514
|
+
if (this.options.disableEmptyLine) {
|
1521
1515
|
this.delEmptyLines(pen.id);
|
1522
1516
|
}
|
1523
|
-
pens.push.apply(pens, this.
|
1517
|
+
pens.push.apply(pens, this.data.pens.splice(found, 1));
|
1524
1518
|
this.setSwitchTabData(pen, found, 'delete');
|
1525
1519
|
--i;
|
1526
1520
|
}
|
@@ -1534,16 +1528,16 @@ var Topology = (function (_super) {
|
|
1534
1528
|
this.dispatch('delete', pens);
|
1535
1529
|
};
|
1536
1530
|
Topology.prototype.delEmptyLines = function (deleteedId) {
|
1537
|
-
for (var i = 0; i < this.
|
1538
|
-
if (this.
|
1531
|
+
for (var i = 0; i < this.data.pens.length; i++) {
|
1532
|
+
if (this.data.pens[i].type !== PenType.Line) {
|
1539
1533
|
continue;
|
1540
1534
|
}
|
1541
|
-
var line = this.
|
1535
|
+
var line = this.data.pens[i];
|
1542
1536
|
if (!line.from.id ||
|
1543
1537
|
!line.to.id ||
|
1544
1538
|
line.from.id === deleteedId ||
|
1545
1539
|
line.to.id === deleteedId) {
|
1546
|
-
this.
|
1540
|
+
this.data.pens.splice(i, 1);
|
1547
1541
|
this.animateLayer.pens.delete(line.id);
|
1548
1542
|
--i;
|
1549
1543
|
}
|
@@ -1552,8 +1546,8 @@ var Topology = (function (_super) {
|
|
1552
1546
|
Topology.prototype.removeNode = function (node) {
|
1553
1547
|
var i = this.findIndex(node);
|
1554
1548
|
if (i > -1) {
|
1555
|
-
this.divLayer.removeDiv(this.
|
1556
|
-
var nodes = this.
|
1549
|
+
this.divLayer.removeDiv(this.data.pens[i]);
|
1550
|
+
var nodes = this.data.pens.splice(i, 1);
|
1557
1551
|
this.dispatch('delete', nodes);
|
1558
1552
|
}
|
1559
1553
|
this.render(true);
|
@@ -1562,28 +1556,28 @@ var Topology = (function (_super) {
|
|
1562
1556
|
Topology.prototype.removeLine = function (line) {
|
1563
1557
|
var i = this.findIndex(line);
|
1564
1558
|
if (i > -1) {
|
1565
|
-
var lines = this.
|
1559
|
+
var lines = this.data.pens.splice(i, 1);
|
1566
1560
|
this.dispatch('delete', lines);
|
1567
1561
|
}
|
1568
1562
|
this.render(true);
|
1569
1563
|
this.cache();
|
1570
1564
|
};
|
1571
1565
|
Topology.prototype.cut = function () {
|
1572
|
-
if (this.
|
1566
|
+
if (this.data.locked) {
|
1573
1567
|
return;
|
1574
1568
|
}
|
1575
|
-
this.clipboard = {
|
1569
|
+
this.clipboard = new TopologyData({
|
1576
1570
|
pens: [],
|
1577
|
-
};
|
1571
|
+
});
|
1578
1572
|
for (var i = 0; i < this.activeLayer.pens.length; i++) {
|
1579
1573
|
var pen = this.activeLayer.pens[i];
|
1580
1574
|
this.clipboard.pens.push(pen.clone());
|
1581
1575
|
var found = this.findIndex(pen);
|
1582
1576
|
if (found > -1) {
|
1583
1577
|
if (pen.type === PenType.Node) {
|
1584
|
-
this.divLayer.removeDiv(this.
|
1578
|
+
this.divLayer.removeDiv(this.data.pens[found]);
|
1585
1579
|
}
|
1586
|
-
this.
|
1580
|
+
this.data.pens.splice(found, 1);
|
1587
1581
|
--i;
|
1588
1582
|
}
|
1589
1583
|
}
|
@@ -1600,9 +1594,9 @@ var Topology = (function (_super) {
|
|
1600
1594
|
return item.animatePlay;
|
1601
1595
|
});
|
1602
1596
|
if(isAnimate) return false;
|
1603
|
-
this.clipboard = {
|
1597
|
+
this.clipboard = new TopologyData({
|
1604
1598
|
pens: [],
|
1605
|
-
};
|
1599
|
+
});
|
1606
1600
|
for (var _i = 0, _a = this.activeLayer.pens; _i < _a.length; _i++) {
|
1607
1601
|
var pen = _a[_i];
|
1608
1602
|
this.clipboard.pens.push(pen.clone());
|
@@ -1610,7 +1604,7 @@ var Topology = (function (_super) {
|
|
1610
1604
|
return true;
|
1611
1605
|
};
|
1612
1606
|
Topology.prototype.paste = function () {
|
1613
|
-
if (!this.clipboard || this.
|
1607
|
+
if (!this.clipboard || this.data.locked) {
|
1614
1608
|
return;
|
1615
1609
|
}
|
1616
1610
|
this.hoverLayer.node = null;
|
@@ -1651,9 +1645,9 @@ var Topology = (function (_super) {
|
|
1651
1645
|
}
|
1652
1646
|
pen.controlPoints = controlPoints;
|
1653
1647
|
}
|
1654
|
-
this.
|
1648
|
+
this.data.pens.push(pen);
|
1655
1649
|
this.activeLayer.add(pen);
|
1656
|
-
this.setSwitchTabData(pen, this.
|
1650
|
+
this.setSwitchTabData(pen, this.data.pens.length-1);
|
1657
1651
|
}
|
1658
1652
|
this.render();
|
1659
1653
|
this.animate(true);
|
@@ -1672,9 +1666,9 @@ var Topology = (function (_super) {
|
|
1672
1666
|
}
|
1673
1667
|
};
|
1674
1668
|
Topology.prototype.bind = function (item, exite, dataType, index) {
|
1675
|
-
this.clipboard = {
|
1669
|
+
this.clipboard = new TopologyData({
|
1676
1670
|
pens: [],
|
1677
|
-
};
|
1671
|
+
});
|
1678
1672
|
for (var _i = 0, _a = this.activeLayer.pens; _i < _a.length; _i++) {
|
1679
1673
|
var pen = _a[_i];
|
1680
1674
|
pen.data = []
|
@@ -1686,20 +1680,46 @@ var Topology = (function (_super) {
|
|
1686
1680
|
}
|
1687
1681
|
};
|
1688
1682
|
Topology.prototype.bindInfo = async function (item, pen, type, index) {
|
1689
|
-
if (
|
1690
|
-
|
1691
|
-
|
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
|
+
}
|
1692
1700
|
// 绑定悬浮文字
|
1693
1701
|
pen.title = item.touchpname
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
} else if (
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
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
|
+
})
|
1703
1723
|
// 绑定悬浮文字
|
1704
1724
|
pen.title = item.bak
|
1705
1725
|
if (pen.subName && pen.subName == 'temp') {
|
@@ -1733,16 +1753,22 @@ var Topology = (function (_super) {
|
|
1733
1753
|
}]
|
1734
1754
|
})
|
1735
1755
|
}
|
1736
|
-
} else if (
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
//
|
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)
|
1746
1772
|
return pen
|
1747
1773
|
};
|
1748
1774
|
Topology.prototype.newId = function (node, idMaps) {
|
@@ -1789,15 +1815,15 @@ var Topology = (function (_super) {
|
|
1789
1815
|
cache && this.cache();
|
1790
1816
|
};
|
1791
1817
|
Topology.prototype.lock = function (lock) {
|
1792
|
-
this.
|
1793
|
-
for (var _i = 0, _a = this.
|
1818
|
+
this.data.locked = lock;
|
1819
|
+
for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
|
1794
1820
|
var item = _a[_i];
|
1795
1821
|
item.addToDiv && item.addToDiv();
|
1796
1822
|
}
|
1797
|
-
this.dispatch('locked', this.
|
1823
|
+
this.dispatch('locked', this.data.locked);
|
1798
1824
|
};
|
1799
1825
|
Topology.prototype.lockPens = function (pens, lock) {
|
1800
|
-
for (var _i = 0, _a = this.
|
1826
|
+
for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
|
1801
1827
|
var item = _a[_i];
|
1802
1828
|
for (var _b = 0, pens_2 = pens; _b < pens_2.length; _b++) {
|
1803
1829
|
var pen = pens_2[_b];
|
@@ -1815,30 +1841,30 @@ var Topology = (function (_super) {
|
|
1815
1841
|
};
|
1816
1842
|
Topology.prototype.up = function (pen) {
|
1817
1843
|
var i = this.findIndex(pen);
|
1818
|
-
if (i > -1 && i !== this.
|
1819
|
-
this.
|
1820
|
-
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);
|
1821
1847
|
}
|
1822
1848
|
};
|
1823
1849
|
Topology.prototype.top = function (pen) {
|
1824
1850
|
var i = this.findIndex(pen);
|
1825
1851
|
if (i > -1) {
|
1826
|
-
this.
|
1827
|
-
this.
|
1852
|
+
this.data.pens.push(this.data.pens[i]);
|
1853
|
+
this.data.pens.splice(i, 1);
|
1828
1854
|
}
|
1829
1855
|
};
|
1830
1856
|
Topology.prototype.down = function (pen) {
|
1831
1857
|
var i = this.findIndex(pen);
|
1832
1858
|
if (i > -1 && i !== 0) {
|
1833
|
-
this.
|
1834
|
-
this.
|
1859
|
+
this.data.pens.splice(i - 1, 0, this.data.pens[i]);
|
1860
|
+
this.data.pens.splice(i + 1, 1);
|
1835
1861
|
}
|
1836
1862
|
};
|
1837
1863
|
Topology.prototype.bottom = function (pen) {
|
1838
1864
|
var i = this.findIndex(pen);
|
1839
1865
|
if (i > -1) {
|
1840
|
-
this.
|
1841
|
-
this.
|
1866
|
+
this.data.pens.unshift(this.data.pens[i]);
|
1867
|
+
this.data.pens.splice(i + 1, 1);
|
1842
1868
|
}
|
1843
1869
|
};
|
1844
1870
|
Topology.prototype.combine = function (pens, stand, temp) {
|
@@ -1854,7 +1880,7 @@ var Topology = (function (_super) {
|
|
1854
1880
|
var item = pens_3[_i];
|
1855
1881
|
var i = this.findIndex(item);
|
1856
1882
|
if (i > -1) {
|
1857
|
-
this.
|
1883
|
+
this.data.pens.splice(i, 1);
|
1858
1884
|
}
|
1859
1885
|
}
|
1860
1886
|
var node = new Node({
|
@@ -1879,7 +1905,7 @@ var Topology = (function (_super) {
|
|
1879
1905
|
item.calcRectInParent(node);
|
1880
1906
|
node.children.push(item);
|
1881
1907
|
}
|
1882
|
-
this.
|
1908
|
+
this.data.pens.push(node);
|
1883
1909
|
this.activeLayer.setPens([node]);
|
1884
1910
|
this.dispatch('node', node);
|
1885
1911
|
this.cache();
|
@@ -1897,11 +1923,11 @@ var Topology = (function (_super) {
|
|
1897
1923
|
item.parentId = undefined;
|
1898
1924
|
item.rectInParent = undefined;
|
1899
1925
|
item.locked = Lock.None;
|
1900
|
-
this.
|
1926
|
+
this.data.pens.push(item);
|
1901
1927
|
}
|
1902
1928
|
var i = this.findIndex(nodeChildren);
|
1903
1929
|
if (i > -1 && nodeChildren.name === 'combine') {
|
1904
|
-
this.
|
1930
|
+
this.data.pens.splice(i, 1);
|
1905
1931
|
} else {
|
1906
1932
|
nodeChildren.children = null;
|
1907
1933
|
}
|
@@ -1912,7 +1938,7 @@ var Topology = (function (_super) {
|
|
1912
1938
|
Topology.prototype.find = function (idOrTag, pens) {
|
1913
1939
|
var _this = this;
|
1914
1940
|
if (!pens) {
|
1915
|
-
pens = this.
|
1941
|
+
pens = this.data.pens;
|
1916
1942
|
}
|
1917
1943
|
var result = [];
|
1918
1944
|
pens.forEach(function (item) {
|
@@ -1929,28 +1955,28 @@ var Topology = (function (_super) {
|
|
1929
1955
|
return result;
|
1930
1956
|
};
|
1931
1957
|
Topology.prototype.findIndex = function (pen) {
|
1932
|
-
for (var i = 0; i < this.
|
1933
|
-
if (pen.id === this.
|
1958
|
+
for (var i = 0; i < this.data.pens.length; ++i) {
|
1959
|
+
if (pen.id === this.data.pens[i].id) {
|
1934
1960
|
return i;
|
1935
1961
|
}
|
1936
1962
|
}
|
1937
1963
|
return -1;
|
1938
1964
|
};
|
1939
1965
|
Topology.prototype.anchor = function (anchor) {
|
1940
|
-
this.
|
1966
|
+
this.options.hideAnchor = anchor
|
1941
1967
|
this.dispatch('hideAnchor', anchor);
|
1942
1968
|
};
|
1943
1969
|
// scale for scaled canvas:
|
1944
1970
|
// > 1, expand
|
1945
1971
|
// < 1, reduce
|
1946
1972
|
Topology.prototype.scale = function (scale, center, w, h) {
|
1947
|
-
if (this.
|
1948
|
-
this.
|
1973
|
+
if (this.data.scale * scale < this.options.minScale ||
|
1974
|
+
this.data.scale * scale > this.options.maxScale) {
|
1949
1975
|
return;
|
1950
1976
|
}
|
1951
|
-
this.
|
1977
|
+
this.data.scale *= scale;
|
1952
1978
|
!center && (center = this.getRect().center);
|
1953
|
-
for (var _i = 0, _a = this.
|
1979
|
+
for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
|
1954
1980
|
var item = _a[_i];
|
1955
1981
|
item.scale(scale, center, w, h);
|
1956
1982
|
}
|
@@ -1959,18 +1985,18 @@ var Topology = (function (_super) {
|
|
1959
1985
|
pen.scale(scale, center);
|
1960
1986
|
}
|
1961
1987
|
});
|
1962
|
-
Store.set(this.generateStoreKey('LT:scale'), this.
|
1988
|
+
Store.set(this.generateStoreKey('LT:scale'), this.data.scale);
|
1963
1989
|
this.render();
|
1964
1990
|
this.cache();
|
1965
|
-
this.dispatch('scale', this.
|
1991
|
+
this.dispatch('scale', this.data.scale);
|
1966
1992
|
};
|
1967
1993
|
// scale for origin canvas:
|
1968
1994
|
Topology.prototype.scaleTo = function (scale) {
|
1969
|
-
this.scale(scale / this.
|
1970
|
-
this.
|
1995
|
+
this.scale(scale / this.data.scale);
|
1996
|
+
this.data.scale = scale;
|
1971
1997
|
};
|
1972
1998
|
Topology.prototype.round = function () {
|
1973
|
-
for (var _i = 0, _a = this.
|
1999
|
+
for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
|
1974
2000
|
var item = _a[_i];
|
1975
2001
|
if (item instanceof Node) {
|
1976
2002
|
item.round();
|
@@ -1981,7 +2007,7 @@ var Topology = (function (_super) {
|
|
1981
2007
|
if (!this.hasView())
|
1982
2008
|
return;
|
1983
2009
|
// 1. 重置画布尺寸为容器尺寸
|
1984
|
-
var parentElem = this.
|
2010
|
+
var parentElem = this.canvas.parentElem;
|
1985
2011
|
var width = parentElem.offsetWidth, height = parentElem.offsetHeight;
|
1986
2012
|
this.resize({
|
1987
2013
|
width: width,
|
@@ -1990,7 +2016,7 @@ var Topology = (function (_super) {
|
|
1990
2016
|
// 2. 图形居中
|
1991
2017
|
this.centerView(viewPadding);
|
1992
2018
|
// 3. 获取设置的留白值
|
1993
|
-
var padding = formatPadding(viewPadding || this.
|
2019
|
+
var padding = formatPadding(viewPadding || this.options.viewPadding);
|
1994
2020
|
// 4. 获取图形尺寸
|
1995
2021
|
var rect = this.getRect();
|
1996
2022
|
// 6. 计算缩放比
|
@@ -2003,7 +2029,7 @@ var Topology = (function (_super) {
|
|
2003
2029
|
this.scale(ratio);
|
2004
2030
|
};
|
2005
2031
|
Topology.prototype.showTipText = function (data, pos) {
|
2006
|
-
if (this.
|
2032
|
+
if (this.data.locked && data.title) {
|
2007
2033
|
this.divLayer.canvas.title = data.title;
|
2008
2034
|
this.tip = data.id;
|
2009
2035
|
}
|
@@ -2014,15 +2040,15 @@ var Topology = (function (_super) {
|
|
2014
2040
|
return;
|
2015
2041
|
}
|
2016
2042
|
this.scrolling = true;
|
2017
|
-
this.
|
2018
|
-
this.
|
2043
|
+
this.parentElem.scrollLeft += x;
|
2044
|
+
this.parentElem.scrollTop += y;
|
2019
2045
|
setTimeout(function () {
|
2020
2046
|
_this.scrolling = false;
|
2021
2047
|
}, 700);
|
2022
2048
|
};
|
2023
2049
|
Topology.prototype.toComponent = function (pens) {
|
2024
2050
|
if (!pens) {
|
2025
|
-
pens = this.
|
2051
|
+
pens = this.data.pens;
|
2026
2052
|
}
|
2027
2053
|
var rect = this.getRect(pens);
|
2028
2054
|
var node = new Node({
|
@@ -2063,7 +2089,7 @@ var Topology = (function (_super) {
|
|
2063
2089
|
attr = 'text';
|
2064
2090
|
}
|
2065
2091
|
var pen;
|
2066
|
-
this.
|
2092
|
+
this.data.pens.forEach(function (item) {
|
2067
2093
|
if (item.id === idOrTag || item.tags.indexOf(idOrTag) > -1) {
|
2068
2094
|
pen = item;
|
2069
2095
|
}
|
@@ -2075,7 +2101,7 @@ var Topology = (function (_super) {
|
|
2075
2101
|
attr = 'text';
|
2076
2102
|
}
|
2077
2103
|
var pen;
|
2078
|
-
this.
|
2104
|
+
this.data.pens.forEach(function (item) {
|
2079
2105
|
if (item.id === idOrTag || item.tags.indexOf(idOrTag) > -1) {
|
2080
2106
|
pen = item;
|
2081
2107
|
}
|
@@ -2088,12 +2114,11 @@ var Topology = (function (_super) {
|
|
2088
2114
|
this.gridElem.style.left = '0';
|
2089
2115
|
this.gridElem.style.top = '0';
|
2090
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>";
|
2091
|
-
this.
|
2117
|
+
this.parentElem.appendChild(this.gridElem);
|
2092
2118
|
};
|
2093
2119
|
Topology.prototype.showGrid = function (show) {
|
2094
|
-
if(!this.store || !this.store.data) return;
|
2095
2120
|
if (show === undefined) {
|
2096
|
-
show = this.
|
2121
|
+
show = this.data.grid;
|
2097
2122
|
}
|
2098
2123
|
this.gridElem.style.width = this.canvas.width + 'px';
|
2099
2124
|
this.gridElem.style.height = this.canvas.height + 'px';
|
@@ -2184,7 +2209,7 @@ var Topology = (function (_super) {
|
|
2184
2209
|
canvas.style.height = 500 + 'px';
|
2185
2210
|
canvas.style.zIndex = 1;
|
2186
2211
|
canvas.setAttribute('id', 'arbitraryCanvas');
|
2187
|
-
this.
|
2212
|
+
this.parentElem.appendChild(canvas)
|
2188
2213
|
};
|
2189
2214
|
Topology.prototype.createArbitraryGraph = function () {
|
2190
2215
|
|