@inweb/viewer-visualize 25.4.11 → 25.5.3
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 +68 -32
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +73 -32
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Markup/IMarkup.d.ts +10 -1
- package/lib/Viewer/Markup/Impl/Konva/KonvaMarkup.d.ts +3 -1
- package/lib/Viewer/Markup/Impl/Visualize/VisualizeMarkup.d.ts +2 -0
- package/package.json +5 -5
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.ts +8 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +10 -2
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +11 -2
- package/src/Viewer/Markup/IMarkup.ts +12 -1
- package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +44 -29
- package/src/Viewer/Markup/Impl/Visualize/VisualizeMarkup.ts +3 -1
|
@@ -15,6 +15,7 @@ export declare enum MarkupType {
|
|
|
15
15
|
* "Text" markup objects are supported.
|
|
16
16
|
*/
|
|
17
17
|
export declare enum MarkupMode {
|
|
18
|
+
SelectMarkup = "SelectMarkup",
|
|
18
19
|
Line = "Line",
|
|
19
20
|
Text = "Text",
|
|
20
21
|
Rectangle = "Rectangle",
|
|
@@ -28,9 +29,17 @@ export declare enum MarkupMode {
|
|
|
28
29
|
*/
|
|
29
30
|
export interface IMarkup {
|
|
30
31
|
/**
|
|
31
|
-
* Width of the markup object line
|
|
32
|
+
* Width of the markup object line. Default is 4.
|
|
32
33
|
*/
|
|
33
34
|
lineWidth: number;
|
|
35
|
+
/**
|
|
36
|
+
* Type of the Line markup object. Available types: "solid", "dot", "dash". Default is "solid".
|
|
37
|
+
*/
|
|
38
|
+
lineType: string;
|
|
39
|
+
/**
|
|
40
|
+
* Font size of the markup text. Default is 34.
|
|
41
|
+
*/
|
|
42
|
+
fontSize: number;
|
|
34
43
|
/**
|
|
35
44
|
* Start method to init Markup support for the Viewer instance.
|
|
36
45
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeActiveDraggerEvent, IViewpoint, PanEvent } from "@inweb/viewer-core";
|
|
1
|
+
import { ChangeActiveDraggerEvent, IViewpoint, LineType, PanEvent } from "@inweb/viewer-core";
|
|
2
2
|
import { IMarkup } from "../../IMarkup";
|
|
3
3
|
import { Viewer } from "../../../Viewer";
|
|
4
4
|
import { OdBaseDragger } from "../../../Draggers/Common/OdBaseDragger";
|
|
@@ -23,6 +23,8 @@ export declare class KonvaMarkup implements IMarkup {
|
|
|
23
23
|
private _zIndex;
|
|
24
24
|
private readonly _markupContainerName;
|
|
25
25
|
lineWidth: number;
|
|
26
|
+
lineType: LineType;
|
|
27
|
+
fontSize: number;
|
|
26
28
|
initialize(viewer: Viewer, canvas: HTMLCanvasElement, canvasEvents?: string[]): void;
|
|
27
29
|
dispose(): void;
|
|
28
30
|
changeActiveDragger: (event: ChangeActiveDraggerEvent) => void;
|
|
@@ -11,6 +11,8 @@ export declare class VisualizeMarkup implements IMarkup {
|
|
|
11
11
|
b: number;
|
|
12
12
|
};
|
|
13
13
|
lineWidth: number;
|
|
14
|
+
lineType: "solid";
|
|
15
|
+
fontSize: number;
|
|
14
16
|
initialize(viewer: Viewer, canvas: HTMLCanvasElement, canvasEvents: string[]): void;
|
|
15
17
|
dispose(): void;
|
|
16
18
|
getDraggers(): Map<string, typeof OdBaseDragger>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-visualize",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.5.3",
|
|
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.11",
|
|
33
|
+
"@inweb/eventemitter2": "~25.4.11",
|
|
34
|
+
"@inweb/viewer-core": "~25.4.11"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"canvas": "^2.11.2",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"canvas": "^2.11.2",
|
|
42
42
|
"konva": "^9.2.0"
|
|
43
43
|
},
|
|
44
|
-
"visualizeJS": "https://opencloud.azureedge.net/libs/visualizejs/25.
|
|
44
|
+
"visualizeJS": "https://opencloud.azureedge.net/libs/visualizejs/25.5/Visualize.js"
|
|
45
45
|
}
|
|
@@ -44,6 +44,14 @@ export class KonvaEllipse implements IMarkupEllipse, IMarkupColorable {
|
|
|
44
44
|
const newRadiusX = this._ref.radiusX() * attrs.scaleX;
|
|
45
45
|
const newRadiusY = this._ref.radiusY() * attrs.scaleY;
|
|
46
46
|
|
|
47
|
+
const minRadiusX = 25;
|
|
48
|
+
const minRadiusY = 25;
|
|
49
|
+
|
|
50
|
+
if (newRadiusX < minRadiusX || newRadiusY < minRadiusY) {
|
|
51
|
+
this._ref.scale({ x: 1, y: 1 });
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
47
55
|
if (Math.abs(attrs.scaleX - 1) > 10e-6) {
|
|
48
56
|
this.setRadiusX(newRadiusX);
|
|
49
57
|
}
|
|
@@ -42,8 +42,16 @@ export class KonvaRectangle implements IMarkupRectangle, IMarkupColorable {
|
|
|
42
42
|
|
|
43
43
|
if (attrs.rotation !== this.getRotation()) this.setRotation(attrs.rotation);
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
let newWidth = this._ref.width() * attrs.scaleX;
|
|
46
|
+
let newHeight = this._ref.height() * attrs.scaleY;
|
|
47
|
+
|
|
48
|
+
const minWidth = 50;
|
|
49
|
+
const minHeight = 50;
|
|
50
|
+
|
|
51
|
+
if (newWidth < minWidth || newHeight < minHeight) {
|
|
52
|
+
this._ref.scale({ x: 1, y: 1 });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
47
55
|
|
|
48
56
|
if (Math.abs(attrs.scaleX - 1) > 10e-6) {
|
|
49
57
|
this.setWidth(newWidth);
|
|
@@ -36,6 +36,8 @@ export class KonvaText implements IMarkupText, IMarkupColorable {
|
|
|
36
36
|
rotation: params.rotation ?? 0,
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
+
this._ref.width(this._ref.getTextWidth());
|
|
40
|
+
|
|
39
41
|
this._ref.on("transform", (e) => {
|
|
40
42
|
const attrs = e.target.attrs;
|
|
41
43
|
|
|
@@ -44,12 +46,19 @@ export class KonvaText implements IMarkupText, IMarkupColorable {
|
|
|
44
46
|
const newWidth = this._ref.width() * attrs.scaleX;
|
|
45
47
|
const newHeight = this._ref.height() * attrs.scaleY;
|
|
46
48
|
|
|
49
|
+
const minWidth = 50;
|
|
50
|
+
|
|
51
|
+
if (newWidth < minWidth || newHeight < Math.round(this.getFontSize())) {
|
|
52
|
+
this._ref.scale({ x: 1, y: 1 });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
47
56
|
if (Math.abs(attrs.scaleX - 1) > 10e-6) {
|
|
48
|
-
this.
|
|
57
|
+
this._ref.width(newWidth);
|
|
49
58
|
}
|
|
50
59
|
|
|
51
60
|
if (Math.abs(attrs.scaleY - 1) > 10e-6) {
|
|
52
|
-
this.
|
|
61
|
+
this._ref.height(newHeight);
|
|
53
62
|
}
|
|
54
63
|
|
|
55
64
|
this._ref.scale({ x: 1, y: 1 });
|
|
@@ -41,6 +41,7 @@ export enum MarkupType {
|
|
|
41
41
|
* "Text" markup objects are supported.
|
|
42
42
|
*/
|
|
43
43
|
export enum MarkupMode {
|
|
44
|
+
SelectMarkup = "SelectMarkup",
|
|
44
45
|
Line = "Line",
|
|
45
46
|
Text = "Text",
|
|
46
47
|
Rectangle = "Rectangle",
|
|
@@ -55,10 +56,20 @@ export enum MarkupMode {
|
|
|
55
56
|
*/
|
|
56
57
|
export interface IMarkup {
|
|
57
58
|
/**
|
|
58
|
-
* Width of the markup object line
|
|
59
|
+
* Width of the markup object line. Default is 4.
|
|
59
60
|
*/
|
|
60
61
|
lineWidth: number;
|
|
61
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Type of the Line markup object. Available types: "solid", "dot", "dash". Default is "solid".
|
|
65
|
+
*/
|
|
66
|
+
lineType: string;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Font size of the markup text. Default is 34.
|
|
70
|
+
*/
|
|
71
|
+
fontSize: number;
|
|
72
|
+
|
|
62
73
|
/**
|
|
63
74
|
* Start method to init Markup support for the Viewer instance.
|
|
64
75
|
*
|
|
@@ -52,6 +52,13 @@ class KonvaShape {
|
|
|
52
52
|
|
|
53
53
|
// move to separate class and create factory with enum?
|
|
54
54
|
const MarkupMode2Konva = new Map<MarkupMode, KonvaShape>([
|
|
55
|
+
[
|
|
56
|
+
MarkupMode.SelectMarkup,
|
|
57
|
+
{
|
|
58
|
+
name: "SelectMarkup",
|
|
59
|
+
initializer: () => {},
|
|
60
|
+
},
|
|
61
|
+
],
|
|
55
62
|
[
|
|
56
63
|
MarkupMode.Line,
|
|
57
64
|
{
|
|
@@ -140,6 +147,8 @@ export class KonvaMarkup implements IMarkup {
|
|
|
140
147
|
private readonly _markupContainerName = "markupContainer";
|
|
141
148
|
|
|
142
149
|
public lineWidth = 4;
|
|
150
|
+
public lineType: LineType = "solid";
|
|
151
|
+
public fontSize = 34;
|
|
143
152
|
|
|
144
153
|
initialize(viewer: Viewer, canvas: HTMLCanvasElement, canvasEvents: string[] = []): void {
|
|
145
154
|
if (!Konva)
|
|
@@ -261,8 +270,8 @@ export class KonvaMarkup implements IMarkup {
|
|
|
261
270
|
const hex = new MarkupColor(r, g, b).HexColor;
|
|
262
271
|
Object.values(MarkupMode).forEach((mode) => {
|
|
263
272
|
this.konvaLayerFind(mode).forEach((x) => {
|
|
264
|
-
const konvaObj = MarkupMode2Konva.get(mode)
|
|
265
|
-
if (konvaObj.setColor) konvaObj.setColor(hex);
|
|
273
|
+
const konvaObj = MarkupMode2Konva.get(mode)?.initializer(x);
|
|
274
|
+
if (konvaObj && konvaObj.setColor) konvaObj.setColor(hex);
|
|
266
275
|
});
|
|
267
276
|
});
|
|
268
277
|
|
|
@@ -500,6 +509,7 @@ export class KonvaMarkup implements IMarkup {
|
|
|
500
509
|
const konvaShapes = this._konvaLayer.find(konvaShape.name).filter((x) => x.parent instanceof Konva.Layer);
|
|
501
510
|
return konvaShapes;
|
|
502
511
|
}
|
|
512
|
+
return [];
|
|
503
513
|
}
|
|
504
514
|
|
|
505
515
|
private initializeKonva(): any {
|
|
@@ -516,6 +526,7 @@ export class KonvaMarkup implements IMarkup {
|
|
|
516
526
|
|
|
517
527
|
const transformer = new Konva.Transformer({
|
|
518
528
|
shouldOverdrawWholeArea: false,
|
|
529
|
+
keepRatio: false,
|
|
519
530
|
});
|
|
520
531
|
|
|
521
532
|
this._konvaTransformer = transformer;
|
|
@@ -656,29 +667,33 @@ export class KonvaMarkup implements IMarkup {
|
|
|
656
667
|
return;
|
|
657
668
|
}
|
|
658
669
|
|
|
659
|
-
if (
|
|
660
|
-
if (
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
670
|
+
if (this._markupMode === MarkupMode.Text || this._markupMode === MarkupMode.SelectMarkup) {
|
|
671
|
+
if (e.target.className === "Text" && transformer.nodes().length === 1 && transformer.nodes()[0] === e.target) {
|
|
672
|
+
if (this._textInputRef && this._textInputRef.value)
|
|
673
|
+
this.addText(this._textInputRef.value, this._textInputPos, this._textInputAngle);
|
|
674
|
+
else
|
|
675
|
+
this.createTextInput(
|
|
676
|
+
{ x: e.target.attrs.x, y: e.target.attrs.y },
|
|
677
|
+
e.evt.pageX,
|
|
678
|
+
e.evt.pageY,
|
|
679
|
+
e.target.attrs.rotation,
|
|
680
|
+
e.target.attrs.text
|
|
681
|
+
);
|
|
682
|
+
return;
|
|
683
|
+
} else {
|
|
684
|
+
this.removeTextInput();
|
|
685
|
+
}
|
|
673
686
|
}
|
|
674
687
|
|
|
675
|
-
if (
|
|
676
|
-
if (
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
688
|
+
if (this._markupMode === MarkupMode.Image || this._markupMode === MarkupMode.SelectMarkup) {
|
|
689
|
+
if (e.target.className === "Image" && transformer.nodes().length === 1 && transformer.nodes()[0] === e.target) {
|
|
690
|
+
if (this._imageInputRef && this._imageInputRef.value)
|
|
691
|
+
this.addImage(this._imageInputPos, this._imageInputRef.value, 0, 0);
|
|
692
|
+
else this.createImageInput({ x: e.target.attrs.x, y: e.target.attrs.y });
|
|
693
|
+
return;
|
|
694
|
+
} else {
|
|
695
|
+
this.removeImageInput();
|
|
696
|
+
}
|
|
682
697
|
}
|
|
683
698
|
|
|
684
699
|
if (transformer.nodes().filter((x) => x.className === "Cloud").length > 0 || e.target.className === "Cloud") {
|
|
@@ -761,9 +776,9 @@ export class KonvaMarkup implements IMarkup {
|
|
|
761
776
|
lines.push({
|
|
762
777
|
id: konvaLine.id(),
|
|
763
778
|
points: worldPoints.map((p) => this.getPoint3dFromArray(p)),
|
|
764
|
-
color: konvaLine.getColor() || "ff0000",
|
|
765
|
-
type: konvaLine.getLineType() ||
|
|
766
|
-
width: konvaLine.getLineWidth() ||
|
|
779
|
+
color: konvaLine.getColor() || "#ff0000",
|
|
780
|
+
type: konvaLine.getLineType() || this.lineType,
|
|
781
|
+
width: konvaLine.getLineWidth() || this.lineWidth,
|
|
767
782
|
});
|
|
768
783
|
});
|
|
769
784
|
|
|
@@ -1051,7 +1066,7 @@ export class KonvaMarkup implements IMarkup {
|
|
|
1051
1066
|
|
|
1052
1067
|
const konvaLine = new KonvaLine({
|
|
1053
1068
|
points,
|
|
1054
|
-
type: type ||
|
|
1069
|
+
type: type || this.lineType,
|
|
1055
1070
|
width: width || this.lineWidth,
|
|
1056
1071
|
color: color || this._markupColor.HexColor,
|
|
1057
1072
|
id,
|
|
@@ -1073,7 +1088,7 @@ export class KonvaMarkup implements IMarkup {
|
|
|
1073
1088
|
this._textInputRef.style.top = inputY + "px";
|
|
1074
1089
|
this._textInputRef.style.left = inputX + "px";
|
|
1075
1090
|
this._textInputRef.onkeydown = (event) => {
|
|
1076
|
-
if (event.key === "Enter") {
|
|
1091
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
1077
1092
|
event.preventDefault();
|
|
1078
1093
|
this.addText(this._textInputRef.value, this._textInputPos, this._textInputAngle);
|
|
1079
1094
|
}
|
|
@@ -1176,7 +1191,7 @@ export class KonvaMarkup implements IMarkup {
|
|
|
1176
1191
|
position: { x: position.x, y: position.y },
|
|
1177
1192
|
text: specifiedText,
|
|
1178
1193
|
rotation: angle,
|
|
1179
|
-
fontSize,
|
|
1194
|
+
fontSize: fontSize || this.fontSize,
|
|
1180
1195
|
color: color || this._markupColor.HexColor,
|
|
1181
1196
|
id,
|
|
1182
1197
|
});
|
|
@@ -11,7 +11,9 @@ export class VisualizeMarkup implements IMarkup {
|
|
|
11
11
|
private _viewer: Viewer;
|
|
12
12
|
protected _markupColor = { r: 255, g: 0, b: 0 };
|
|
13
13
|
|
|
14
|
-
public lineWidth =
|
|
14
|
+
public lineWidth = 4;
|
|
15
|
+
public lineType: "solid";
|
|
16
|
+
public fontSize = 34;
|
|
15
17
|
|
|
16
18
|
initialize(viewer: Viewer, canvas: HTMLCanvasElement, canvasEvents: string[]): void {
|
|
17
19
|
this._viewer = viewer;
|