@inweb/viewer-visualize 25.8.20 → 25.8.21

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.
@@ -767,24 +767,24 @@ async function autoTransformAllModelsToCentralPoint(viewer, model) {
767
767
  commands("VisualizeJS").registerCommand("autoTransformAllModelsToCentralPoint", autoTransformAllModelsToCentralPoint);
768
768
 
769
769
  class MarkupColor {
770
- get HexColor() {
771
- return "#" + this._hex;
770
+ constructor(r, g, b) {
771
+ this.setColor(r, g, b);
772
+ }
773
+ asHex() {
774
+ return "#" + this.HEX;
772
775
  }
773
- get RGB() {
776
+ asRGB() {
774
777
  return {
775
778
  r: this.R,
776
779
  g: this.G,
777
780
  b: this.B
778
781
  };
779
782
  }
780
- constructor(r, g, b) {
781
- this.setColor(r, g, b);
782
- }
783
783
  setColor(r, g, b) {
784
784
  this.R = r;
785
785
  this.G = g;
786
786
  this.B = b;
787
- this._hex = this.rgbToHex(r, g, b);
787
+ this.HEX = this.rgbToHex(r, g, b);
788
788
  }
789
789
  rgbToHex(r, g, b) {
790
790
  const valueToHex = c => {
@@ -1749,7 +1749,7 @@ const MarkupMode2Konva = {
1749
1749
 
1750
1750
  class KonvaMarkup {
1751
1751
  constructor() {
1752
- this._pointerEvents = [];
1752
+ this._containerEvents = [];
1753
1753
  this._markupIsActive = false;
1754
1754
  this._markupColor = new MarkupColor(255, 0, 0);
1755
1755
  this.lineWidth = 4;
@@ -1781,12 +1781,12 @@ class KonvaMarkup {
1781
1781
  if (this._viewer) this._viewer.emit(event);
1782
1782
  };
1783
1783
  }
1784
- initialize(container, pointerEvents, viewer, worldTransformer) {
1784
+ initialize(container, containerEvents, viewer, worldTransformer) {
1785
1785
  if (!Konva) throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"><\/script> to your page?');
1786
1786
  this._viewer = viewer;
1787
1787
  this._worldTransformer = worldTransformer !== null && worldTransformer !== void 0 ? worldTransformer : new WorldTransform;
1788
1788
  this._container = container;
1789
- this._pointerEvents = pointerEvents !== null && pointerEvents !== void 0 ? pointerEvents : [];
1789
+ this._containerEvents = containerEvents !== null && containerEvents !== void 0 ? containerEvents : [];
1790
1790
  this._markupContainer = document.createElement("div");
1791
1791
  this._markupContainer.id = "markup-container";
1792
1792
  this._markupContainer.style.position = "absolute";
@@ -1800,7 +1800,7 @@ class KonvaMarkup {
1800
1800
  this._markupColor.setColor(255, 0, 0);
1801
1801
  this.initializeKonva();
1802
1802
  if (this._viewer) {
1803
- this._pointerEvents.forEach((x => this._markupContainer.addEventListener(x, this.redirectToViewer)));
1803
+ this._containerEvents.forEach((x => this._markupContainer.addEventListener(x, this.redirectToViewer)));
1804
1804
  this._viewer.addEventListener("changeactivedragger", this.changeActiveDragger);
1805
1805
  this._viewer.addEventListener("pan", this.pan);
1806
1806
  }
@@ -1810,7 +1810,7 @@ class KonvaMarkup {
1810
1810
  if (this._viewer) {
1811
1811
  this._viewer.removeEventListener("pan", this.pan);
1812
1812
  this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
1813
- this._pointerEvents.forEach((x => this._markupContainer.removeEventListener(x, this.redirectToViewer)));
1813
+ this._containerEvents.forEach((x => this._markupContainer.removeEventListener(x, this.redirectToViewer)));
1814
1814
  }
1815
1815
  this.destroyKonva();
1816
1816
  (_a = this._resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
@@ -1830,20 +1830,20 @@ class KonvaMarkup {
1830
1830
  this.getObjects().forEach((obj => obj.delete()));
1831
1831
  }
1832
1832
  getMarkupColor() {
1833
- return this._markupColor.RGB;
1833
+ return this._markupColor.asRGB();
1834
1834
  }
1835
1835
  setMarkupColor(r, g, b) {
1836
1836
  this._markupColor.setColor(r, g, b);
1837
1837
  }
1838
1838
  colorizeAllMarkup(r, g, b) {
1839
- const hexColor = new MarkupColor(r, g, b).HexColor;
1839
+ const hexColor = new MarkupColor(r, g, b).asHex();
1840
1840
  this.getObjects().filter((obj => {
1841
1841
  var _a;
1842
1842
  return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor);
1843
1843
  }));
1844
1844
  }
1845
1845
  colorizeSelectedMarkups(r, g, b) {
1846
- const hexColor = new MarkupColor(r, g, b).HexColor;
1846
+ const hexColor = new MarkupColor(r, g, b).asHex();
1847
1847
  this.getSelectedObjects().filter((obj => {
1848
1848
  var _a;
1849
1849
  return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor);
@@ -2367,7 +2367,7 @@ class KonvaMarkup {
2367
2367
  points: points,
2368
2368
  type: type || this.lineType,
2369
2369
  width: width || this.lineWidth,
2370
- color: color || this._markupColor.HexColor,
2370
+ color: color || this._markupColor.asHex(),
2371
2371
  id: id
2372
2372
  });
2373
2373
  this.addObject(konvaLine);
@@ -2384,7 +2384,7 @@ class KonvaMarkup {
2384
2384
  this._textInputRef.style.top = inputY + "px";
2385
2385
  this._textInputRef.style.left = inputX + "px";
2386
2386
  this._textInputRef.style.fontSize = `${this.fontSize}px`;
2387
- this._textInputRef.style.color = `${this._markupColor.HexColor}`;
2387
+ this._textInputRef.style.color = `${this._markupColor.asHex()}`;
2388
2388
  this._textInputRef.style.fontFamily = "Calibri";
2389
2389
  this._textInputRef.onkeydown = event => {
2390
2390
  if (event.key === "Enter" && !event.shiftKey) {
@@ -2474,7 +2474,7 @@ class KonvaMarkup {
2474
2474
  text: text,
2475
2475
  rotation: angle,
2476
2476
  fontSize: fontSize || this.fontSize,
2477
- color: color || this._markupColor.HexColor,
2477
+ color: color || this._markupColor.asHex(),
2478
2478
  id: id
2479
2479
  });
2480
2480
  this.addObject(konvaText);
@@ -2487,7 +2487,7 @@ class KonvaMarkup {
2487
2487
  width: width,
2488
2488
  height: height,
2489
2489
  lineWidth: lineWidth || this.lineWidth,
2490
- color: color || this._markupColor.HexColor,
2490
+ color: color || this._markupColor.asHex(),
2491
2491
  id: id
2492
2492
  });
2493
2493
  this.addObject(konvaRectangle);
@@ -2499,7 +2499,7 @@ class KonvaMarkup {
2499
2499
  position: position,
2500
2500
  radius: radius,
2501
2501
  lineWidth: lineWidth,
2502
- color: color || this._markupColor.HexColor,
2502
+ color: color || this._markupColor.asHex(),
2503
2503
  id: id
2504
2504
  });
2505
2505
  this.addObject(konvaEllipse);
@@ -2510,7 +2510,7 @@ class KonvaMarkup {
2510
2510
  const konvaArrow = new KonvaArrow({
2511
2511
  start: start,
2512
2512
  end: end,
2513
- color: color || this._markupColor.HexColor,
2513
+ color: color || this._markupColor.asHex(),
2514
2514
  id: id
2515
2515
  });
2516
2516
  this.addObject(konvaArrow);
@@ -2522,7 +2522,7 @@ class KonvaMarkup {
2522
2522
  position: position,
2523
2523
  width: width,
2524
2524
  height: height,
2525
- color: color || this._markupColor.HexColor,
2525
+ color: color || this._markupColor.asHex(),
2526
2526
  lineWidth: lineWidth || this.lineWidth,
2527
2527
  id: id
2528
2528
  });
@@ -4985,7 +4985,7 @@ class VisualizeMarkup {
4985
4985
  this.lineWidth = 4;
4986
4986
  this.fontSize = 34;
4987
4987
  }
4988
- initialize(canvas, canvasEvents, viewer, worldTransformer) {
4988
+ initialize(container, containerEvents, viewer, worldTransformer) {
4989
4989
  this._viewer = viewer;
4990
4990
  this._viewer.registerDragger("Line", OdaLineDragger);
4991
4991
  this._viewer.registerDragger("Text", OdaTextDragger);