@inweb/viewer-visualize 25.4.6 → 25.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/viewer-visualize.js +99 -32
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +102 -29
- package/dist/viewer-visualize.module.js.map +1 -1
- package/package.json +4 -4
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaArrow.ts +7 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaCloud.ts +6 -4
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.ts +21 -2
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaImage.ts +19 -9
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaLine.ts +6 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +19 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +21 -0
- package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +26 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-visualize",
|
|
3
|
-
"version": "25.4.
|
|
3
|
+
"version": "25.4.10",
|
|
4
4
|
"description": "3D CAD and BIM data Viewer powered by Visualize",
|
|
5
5
|
"homepage": "https://cloud.opendesign.com/docs/index.html",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"ts-docs": "typedoc"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@inweb/client": "~25.4.
|
|
33
|
-
"@inweb/eventemitter2": "~25.4.
|
|
34
|
-
"@inweb/viewer-core": "~25.4.
|
|
32
|
+
"@inweb/client": "~25.4.10",
|
|
33
|
+
"@inweb/eventemitter2": "~25.4.10",
|
|
34
|
+
"@inweb/viewer-core": "~25.4.10"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"canvas": "^2.11.2",
|
|
@@ -56,6 +56,12 @@ export class KonvaArrow implements IMarkupArrow, IMarkupColorable {
|
|
|
56
56
|
strokeScaleEnabled: false,
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
+
this._ref.on("transform", (e) => {
|
|
60
|
+
const attrs = e.target.attrs;
|
|
61
|
+
|
|
62
|
+
if (attrs.rotation !== this.getRotation()) this.setRotation(attrs.rotation);
|
|
63
|
+
});
|
|
64
|
+
|
|
59
65
|
this._ref.id(this._ref._id.toString());
|
|
60
66
|
}
|
|
61
67
|
|
|
@@ -81,6 +87,7 @@ export class KonvaArrow implements IMarkupArrow, IMarkupColorable {
|
|
|
81
87
|
|
|
82
88
|
setColor(hex: string) {
|
|
83
89
|
this._ref.stroke(hex);
|
|
90
|
+
this._ref.fill(hex);
|
|
84
91
|
}
|
|
85
92
|
|
|
86
93
|
getRotation(): number {
|
|
@@ -95,23 +95,25 @@ export class KonvaCloud implements IMarkupCloud, IMarkupColorable {
|
|
|
95
95
|
this._ref.on("transform", (e) => {
|
|
96
96
|
const attrs = e.target.attrs;
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
const minHeight = 100;
|
|
98
|
+
if (attrs.rotation !== this.getRotation()) this.setRotation(attrs.rotation);
|
|
100
99
|
|
|
101
100
|
const newWidth = this._ref.width() * attrs.scaleX;
|
|
102
101
|
const newHeight = this._ref.height() * attrs.scaleY;
|
|
103
102
|
|
|
103
|
+
const minWidth = 100;
|
|
104
|
+
const minHeight = 100;
|
|
105
|
+
|
|
104
106
|
if (newWidth < minWidth || newHeight < minHeight) {
|
|
105
107
|
this._ref.scale({ x: 1, y: 1 });
|
|
106
108
|
return;
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
if (Math.abs(attrs.scaleX - 1) > 10e-6) {
|
|
110
|
-
this.
|
|
112
|
+
this.setWidth(newWidth);
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
if (Math.abs(attrs.scaleY - 1) > 10e-6) {
|
|
114
|
-
this.
|
|
116
|
+
this.setHeight(newHeight);
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
this._ref.scale({ x: 1, y: 1 });
|
|
@@ -36,6 +36,25 @@ export class KonvaEllipse implements IMarkupEllipse, IMarkupColorable {
|
|
|
36
36
|
strokeScaleEnabled: false,
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
+
this._ref.on("transform", (e) => {
|
|
40
|
+
const attrs = e.target.attrs;
|
|
41
|
+
|
|
42
|
+
if (attrs.rotation !== this.getRotation()) this.setRotation(attrs.rotation);
|
|
43
|
+
|
|
44
|
+
const newRadiusX = this._ref.radiusX() * attrs.scaleX;
|
|
45
|
+
const newRadiusY = this._ref.radiusY() * attrs.scaleY;
|
|
46
|
+
|
|
47
|
+
if (Math.abs(attrs.scaleX - 1) > 10e-6) {
|
|
48
|
+
this.setRadiusX(newRadiusX);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (Math.abs(attrs.scaleY - 1) > 10e-6) {
|
|
52
|
+
this.setRadiusY(newRadiusY);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
this._ref.scale({ x: 1, y: 1 });
|
|
56
|
+
});
|
|
57
|
+
|
|
39
58
|
this._ref.id(this._ref._id.toString());
|
|
40
59
|
}
|
|
41
60
|
|
|
@@ -52,7 +71,7 @@ export class KonvaEllipse implements IMarkupEllipse, IMarkupColorable {
|
|
|
52
71
|
}
|
|
53
72
|
|
|
54
73
|
setRadiusX(r: number) {
|
|
55
|
-
this._ref.
|
|
74
|
+
this._ref.radiusX(r);
|
|
56
75
|
}
|
|
57
76
|
|
|
58
77
|
getRadiusY(): number {
|
|
@@ -60,7 +79,7 @@ export class KonvaEllipse implements IMarkupEllipse, IMarkupColorable {
|
|
|
60
79
|
}
|
|
61
80
|
|
|
62
81
|
setRadiusY(r: number) {
|
|
63
|
-
this._ref.
|
|
82
|
+
this._ref.radiusY(r);
|
|
64
83
|
}
|
|
65
84
|
|
|
66
85
|
getLineWidth(): number {
|
|
@@ -40,6 +40,25 @@ export class KonvaImage implements IMarkupImage {
|
|
|
40
40
|
|
|
41
41
|
this._canvasImage.src = params.src;
|
|
42
42
|
|
|
43
|
+
this._ref.on("transform", (e) => {
|
|
44
|
+
const attrs = e.target.attrs;
|
|
45
|
+
|
|
46
|
+
if (attrs.rotation !== this.getRotation()) this.setRotation(attrs.rotation);
|
|
47
|
+
|
|
48
|
+
const newWidth = this._ref.width() * attrs.scaleX;
|
|
49
|
+
const newHeight = this._ref.height() * attrs.scaleY;
|
|
50
|
+
|
|
51
|
+
if (Math.abs(attrs.scaleX - 1) > 10e-6) {
|
|
52
|
+
this.setWidth(newWidth);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (Math.abs(attrs.scaleY - 1) > 10e-6) {
|
|
56
|
+
this.setHeight(newHeight);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
this._ref.scale({ x: 1, y: 1 });
|
|
60
|
+
});
|
|
61
|
+
|
|
43
62
|
this._ref.id(this._ref._id.toString());
|
|
44
63
|
}
|
|
45
64
|
|
|
@@ -85,15 +104,6 @@ export class KonvaImage implements IMarkupImage {
|
|
|
85
104
|
return "image";
|
|
86
105
|
}
|
|
87
106
|
|
|
88
|
-
// we can break Liskov Substitution Principle, need to use separate IColorable
|
|
89
|
-
// getColor(): string {
|
|
90
|
-
// return this._ref.fill();
|
|
91
|
-
// }
|
|
92
|
-
|
|
93
|
-
// setColor(hex: string) {
|
|
94
|
-
// this._ref.fill(hex);
|
|
95
|
-
// }
|
|
96
|
-
|
|
97
107
|
getRotation(): number {
|
|
98
108
|
return this._ref.rotation();
|
|
99
109
|
}
|
|
@@ -38,6 +38,12 @@ export class KonvaLine implements IMarkupLine, IMarkupColorable {
|
|
|
38
38
|
dash: LineTypeSpecs.get(params.type) || [],
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
+
this._ref.on("transform", (e) => {
|
|
42
|
+
const attrs = e.target.attrs;
|
|
43
|
+
|
|
44
|
+
if (attrs.rotation !== this.getRotation()) this.setRotation(attrs.rotation);
|
|
45
|
+
});
|
|
46
|
+
|
|
41
47
|
this._ref.id(this._ref._id.toString());
|
|
42
48
|
}
|
|
43
49
|
|
|
@@ -37,6 +37,25 @@ export class KonvaRectangle implements IMarkupRectangle, IMarkupColorable {
|
|
|
37
37
|
strokeScaleEnabled: false,
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
+
this._ref.on("transform", (e) => {
|
|
41
|
+
const attrs = e.target.attrs;
|
|
42
|
+
|
|
43
|
+
if (attrs.rotation !== this.getRotation()) this.setRotation(attrs.rotation);
|
|
44
|
+
|
|
45
|
+
const newWidth = this._ref.width() * attrs.scaleX;
|
|
46
|
+
const newHeight = this._ref.height() * attrs.scaleY;
|
|
47
|
+
|
|
48
|
+
if (Math.abs(attrs.scaleX - 1) > 10e-6) {
|
|
49
|
+
this.setWidth(newWidth);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (Math.abs(attrs.scaleY - 1) > 10e-6) {
|
|
53
|
+
this.setHeight(newHeight);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this._ref.scale({ x: 1, y: 1 });
|
|
57
|
+
});
|
|
58
|
+
|
|
40
59
|
this._ref.id(this._ref._id.toString());
|
|
41
60
|
}
|
|
42
61
|
|
|
@@ -36,6 +36,27 @@ export class KonvaText implements IMarkupText, IMarkupColorable {
|
|
|
36
36
|
rotation: params.rotation ?? 0,
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
+
this._ref.width(this._ref.getTextWidth());
|
|
40
|
+
|
|
41
|
+
this._ref.on("transform", (e) => {
|
|
42
|
+
const attrs = e.target.attrs;
|
|
43
|
+
|
|
44
|
+
if (attrs.rotation !== this.getRotation()) this.setRotation(attrs.rotation);
|
|
45
|
+
|
|
46
|
+
const newWidth = this._ref.width() * attrs.scaleX;
|
|
47
|
+
const newHeight = this._ref.height() * attrs.scaleY;
|
|
48
|
+
|
|
49
|
+
if (Math.abs(attrs.scaleX - 1) > 10e-6) {
|
|
50
|
+
this._ref.width(newWidth);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (Math.abs(attrs.scaleY - 1) > 10e-6) {
|
|
54
|
+
this._ref.height(newHeight);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this._ref.scale({ x: 1, y: 1 });
|
|
58
|
+
});
|
|
59
|
+
|
|
39
60
|
this._ref.id(this._ref._id.toString());
|
|
40
61
|
}
|
|
41
62
|
|
|
@@ -656,29 +656,33 @@ export class KonvaMarkup implements IMarkup {
|
|
|
656
656
|
return;
|
|
657
657
|
}
|
|
658
658
|
|
|
659
|
-
if (
|
|
660
|
-
if (
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
659
|
+
if (this._markupMode === MarkupMode.Text) {
|
|
660
|
+
if (e.target.className === "Text" && transformer.nodes().length === 1 && transformer.nodes()[0] === e.target) {
|
|
661
|
+
if (this._textInputRef && this._textInputRef.value)
|
|
662
|
+
this.addText(this._textInputRef.value, this._textInputPos, this._textInputAngle);
|
|
663
|
+
else
|
|
664
|
+
this.createTextInput(
|
|
665
|
+
{ x: e.target.attrs.x, y: e.target.attrs.y },
|
|
666
|
+
e.evt.pageX,
|
|
667
|
+
e.evt.pageY,
|
|
668
|
+
e.target.attrs.rotation,
|
|
669
|
+
e.target.attrs.text
|
|
670
|
+
);
|
|
671
|
+
return;
|
|
672
|
+
} else {
|
|
673
|
+
this.removeTextInput();
|
|
674
|
+
}
|
|
673
675
|
}
|
|
674
676
|
|
|
675
|
-
if (
|
|
676
|
-
if (
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
677
|
+
if (this._markupMode === MarkupMode.Image) {
|
|
678
|
+
if (e.target.className === "Image" && transformer.nodes().length === 1 && transformer.nodes()[0] === e.target) {
|
|
679
|
+
if (this._imageInputRef && this._imageInputRef.value)
|
|
680
|
+
this.addImage(this._imageInputPos, this._imageInputRef.value, 0, 0);
|
|
681
|
+
else this.createImageInput({ x: e.target.attrs.x, y: e.target.attrs.y });
|
|
682
|
+
return;
|
|
683
|
+
} else {
|
|
684
|
+
this.removeImageInput();
|
|
685
|
+
}
|
|
682
686
|
}
|
|
683
687
|
|
|
684
688
|
if (transformer.nodes().filter((x) => x.className === "Cloud").length > 0 || e.target.className === "Cloud") {
|
|
@@ -1073,7 +1077,7 @@ export class KonvaMarkup implements IMarkup {
|
|
|
1073
1077
|
this._textInputRef.style.top = inputY + "px";
|
|
1074
1078
|
this._textInputRef.style.left = inputX + "px";
|
|
1075
1079
|
this._textInputRef.onkeydown = (event) => {
|
|
1076
|
-
if (event.key === "Enter") {
|
|
1080
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
1077
1081
|
event.preventDefault();
|
|
1078
1082
|
this.addText(this._textInputRef.value, this._textInputPos, this._textInputAngle);
|
|
1079
1083
|
}
|