@inweb/viewer-visualize 25.4.6 → 25.4.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inweb/viewer-visualize",
3
- "version": "25.4.6",
3
+ "version": "25.4.7",
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.6",
33
- "@inweb/eventemitter2": "~25.4.6",
34
- "@inweb/viewer-core": "~25.4.6"
32
+ "@inweb/client": "~25.4.7",
33
+ "@inweb/eventemitter2": "~25.4.7",
34
+ "@inweb/viewer-core": "~25.4.7"
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
- const minWidth = 100;
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._ref.width(newWidth);
112
+ this.setWidth(newWidth);
111
113
  }
112
114
 
113
115
  if (Math.abs(attrs.scaleY - 1) > 10e-6) {
114
- this._ref.height(newHeight);
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.radius({ x: r, y: this._ref.radiusY() });
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.radius({ x: this._ref.radiusX(), y: r });
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,25 @@ export class KonvaText implements IMarkupText, IMarkupColorable {
36
36
  rotation: params.rotation ?? 0,
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 newWidth = this._ref.width() * attrs.scaleX;
45
+ const newHeight = this._ref.height() * attrs.scaleY;
46
+
47
+ if (Math.abs(attrs.scaleX - 1) > 10e-6) {
48
+ this.setFontSize(Math.round((this.getFontSize() * newWidth) / this._ref.width()));
49
+ }
50
+
51
+ if (Math.abs(attrs.scaleY - 1) > 10e-6) {
52
+ this.setFontSize(Math.round((this.getFontSize() * newHeight) / this._ref.height()));
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