@inweb/viewer-visualize 25.4.10 → 25.5.0

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.
@@ -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.4.10",
3
+ "version": "25.5.0",
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.10",
33
- "@inweb/eventemitter2": "~25.4.10",
34
- "@inweb/viewer-core": "~25.4.10"
32
+ "@inweb/client": "~25.5.0",
33
+ "@inweb/eventemitter2": "~25.5.0",
34
+ "@inweb/viewer-core": "~25.5.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "canvas": "^2.11.2",
@@ -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
- const newWidth = this._ref.width() * attrs.scaleX;
46
- const newHeight = this._ref.height() * attrs.scaleY;
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);
@@ -46,6 +46,13 @@ export class KonvaText implements IMarkupText, IMarkupColorable {
46
46
  const newWidth = this._ref.width() * attrs.scaleX;
47
47
  const newHeight = this._ref.height() * attrs.scaleY;
48
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
+
49
56
  if (Math.abs(attrs.scaleX - 1) > 10e-6) {
50
57
  this._ref.width(newWidth);
51
58
  }
@@ -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).initializer(x);
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,7 +667,7 @@ export class KonvaMarkup implements IMarkup {
656
667
  return;
657
668
  }
658
669
 
659
- if (this._markupMode === MarkupMode.Text) {
670
+ if (this._markupMode === MarkupMode.Text || this._markupMode === MarkupMode.SelectMarkup) {
660
671
  if (e.target.className === "Text" && transformer.nodes().length === 1 && transformer.nodes()[0] === e.target) {
661
672
  if (this._textInputRef && this._textInputRef.value)
662
673
  this.addText(this._textInputRef.value, this._textInputPos, this._textInputAngle);
@@ -674,7 +685,7 @@ export class KonvaMarkup implements IMarkup {
674
685
  }
675
686
  }
676
687
 
677
- if (this._markupMode === MarkupMode.Image) {
688
+ if (this._markupMode === MarkupMode.Image || this._markupMode === MarkupMode.SelectMarkup) {
678
689
  if (e.target.className === "Image" && transformer.nodes().length === 1 && transformer.nodes()[0] === e.target) {
679
690
  if (this._imageInputRef && this._imageInputRef.value)
680
691
  this.addImage(this._imageInputPos, this._imageInputRef.value, 0, 0);
@@ -765,9 +776,9 @@ export class KonvaMarkup implements IMarkup {
765
776
  lines.push({
766
777
  id: konvaLine.id(),
767
778
  points: worldPoints.map((p) => this.getPoint3dFromArray(p)),
768
- color: konvaLine.getColor() || "ff0000",
769
- type: konvaLine.getLineType() || "solid",
770
- width: konvaLine.getLineWidth() || 3,
779
+ color: konvaLine.getColor() || "#ff0000",
780
+ type: konvaLine.getLineType() || this.lineType,
781
+ width: konvaLine.getLineWidth() || this.lineWidth,
771
782
  });
772
783
  });
773
784
 
@@ -1055,7 +1066,7 @@ export class KonvaMarkup implements IMarkup {
1055
1066
 
1056
1067
  const konvaLine = new KonvaLine({
1057
1068
  points,
1058
- type: type || "solid",
1069
+ type: type || this.lineType,
1059
1070
  width: width || this.lineWidth,
1060
1071
  color: color || this._markupColor.HexColor,
1061
1072
  id,
@@ -1180,7 +1191,7 @@ export class KonvaMarkup implements IMarkup {
1180
1191
  position: { x: position.x, y: position.y },
1181
1192
  text: specifiedText,
1182
1193
  rotation: angle,
1183
- fontSize,
1194
+ fontSize: fontSize || this.fontSize,
1184
1195
  color: color || this._markupColor.HexColor,
1185
1196
  id,
1186
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 = 0;
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;