@inweb/viewer-visualize 25.8.11 → 25.8.13

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.
@@ -857,7 +857,7 @@ class KonvaLine {
857
857
  this._ref.draggable(value);
858
858
  }
859
859
  type() {
860
- return "line";
860
+ return "Line";
861
861
  }
862
862
  getColor() {
863
863
  return this._ref.stroke();
@@ -977,7 +977,7 @@ class KonvaText {
977
977
  this._ref.draggable(value);
978
978
  }
979
979
  type() {
980
- return "text";
980
+ return "Text";
981
981
  }
982
982
  getColor() {
983
983
  return this._ref.fill();
@@ -1102,7 +1102,7 @@ class KonvaRectangle {
1102
1102
  this._ref.draggable(value);
1103
1103
  }
1104
1104
  type() {
1105
- return "rectangle";
1105
+ return "Rectangle";
1106
1106
  }
1107
1107
  getColor() {
1108
1108
  return this._ref.stroke();
@@ -1230,7 +1230,7 @@ class KonvaEllipse {
1230
1230
  this._ref.draggable(value);
1231
1231
  }
1232
1232
  type() {
1233
- return "ellipse";
1233
+ return "Ellipse";
1234
1234
  }
1235
1235
  getColor() {
1236
1236
  return this._ref.stroke();
@@ -1291,7 +1291,7 @@ class KonvaArrow {
1291
1291
  this._ref.draggable(value);
1292
1292
  }
1293
1293
  type() {
1294
- return "arrow";
1294
+ return "Arrow";
1295
1295
  }
1296
1296
  getColor() {
1297
1297
  return this._ref.stroke();
@@ -1444,7 +1444,7 @@ class KonvaImage {
1444
1444
  this._ref.draggable(value);
1445
1445
  }
1446
1446
  type() {
1447
- return "image";
1447
+ return "Image";
1448
1448
  }
1449
1449
  getRotation() {
1450
1450
  return this._ref.rotation();
@@ -1595,7 +1595,7 @@ class KonvaCloud {
1595
1595
  this._ref.draggable(value);
1596
1596
  }
1597
1597
  type() {
1598
- return "cloud";
1598
+ return "Cloud";
1599
1599
  }
1600
1600
  getColor() {
1601
1601
  return this._ref.stroke();
@@ -1655,8 +1655,7 @@ const MarkupMode2Konva = {
1655
1655
  },
1656
1656
  Line: {
1657
1657
  name: "Line",
1658
- initializer: (ref, params = null) => new KonvaLine(params, ref),
1659
- zIndex: 1
1658
+ initializer: (ref, params = null) => new KonvaLine(params, ref)
1660
1659
  },
1661
1660
  Text: {
1662
1661
  name: "Text",
@@ -1664,28 +1663,23 @@ const MarkupMode2Konva = {
1664
1663
  },
1665
1664
  Rectangle: {
1666
1665
  name: "Rect",
1667
- initializer: (ref, params = null) => new KonvaRectangle(params, ref),
1668
- zIndex: 1
1666
+ initializer: (ref, params = null) => new KonvaRectangle(params, ref)
1669
1667
  },
1670
1668
  Ellipse: {
1671
1669
  name: "Ellipse",
1672
- initializer: (ref, params = null) => new KonvaEllipse(params, ref),
1673
- zIndex: 1
1670
+ initializer: (ref, params = null) => new KonvaEllipse(params, ref)
1674
1671
  },
1675
1672
  Arrow: {
1676
1673
  name: "Arrow",
1677
- initializer: (ref, params = null) => new KonvaArrow(params, ref),
1678
- zIndex: 1
1674
+ initializer: (ref, params = null) => new KonvaArrow(params, ref)
1679
1675
  },
1680
1676
  Image: {
1681
1677
  name: "Image",
1682
- initializer: (ref, params = null) => new KonvaImage(params, ref),
1683
- zIndex: 0
1678
+ initializer: (ref, params = null) => new KonvaImage(params, ref)
1684
1679
  },
1685
1680
  Cloud: {
1686
1681
  name: "Cloud",
1687
- initializer: (ref, params = null) => new KonvaCloud(params, ref),
1688
- zIndex: 1
1682
+ initializer: (ref, params = null) => new KonvaCloud(params, ref)
1689
1683
  }
1690
1684
  };
1691
1685
 
@@ -1694,7 +1688,6 @@ class KonvaMarkup {
1694
1688
  this._pointerEvents = [];
1695
1689
  this._markupIsActive = false;
1696
1690
  this._markupColor = new MarkupColor(255, 0, 0);
1697
- this._zIndex = 1;
1698
1691
  this.lineWidth = 4;
1699
1692
  this.lineType = "solid";
1700
1693
  this.fontSize = 34;
@@ -1794,6 +1787,9 @@ class KonvaMarkup {
1794
1787
  }
1795
1788
  setViewpoint(viewpoint) {
1796
1789
  var _a, _b, _c, _d, _e, _f, _g, _h;
1790
+ this.clearSelected();
1791
+ this.removeTextInput();
1792
+ this.removeImageInput();
1797
1793
  const markupColor = ((_a = viewpoint.custom_fields) === null || _a === void 0 ? void 0 : _a.markup_color) || {
1798
1794
  r: 255,
1799
1795
  g: 0,
@@ -1856,6 +1852,8 @@ class KonvaMarkup {
1856
1852
  enableEditMode(mode) {
1857
1853
  if (!mode || !MarkupMode2Konva[mode]) {
1858
1854
  this.clearSelected();
1855
+ this.removeTextInput();
1856
+ this.removeImageInput();
1859
1857
  this._markupIsActive = false;
1860
1858
  } else {
1861
1859
  this._markupMode = mode;
@@ -1864,13 +1862,10 @@ class KonvaMarkup {
1864
1862
  return this;
1865
1863
  }
1866
1864
  createObject(type, params) {
1867
- var _a;
1868
1865
  const konvaShape = MarkupMode2Konva[type];
1869
1866
  if (!konvaShape || !konvaShape.initializer) throw new Error(`Markup CreateObject - unsupported markup type ${type}`);
1870
1867
  const object = konvaShape.initializer(null, params);
1871
1868
  this.addObject(object);
1872
- object.setZIndex((_a = konvaShape.zIndex) !== null && _a !== void 0 ? _a : this._zIndex);
1873
- this._zIndex++;
1874
1869
  return object;
1875
1870
  }
1876
1871
  getObjects() {
@@ -1898,13 +1893,13 @@ class KonvaMarkup {
1898
1893
  if (this._konvaTransformer) this._konvaTransformer.nodes([]);
1899
1894
  }
1900
1895
  addObject(object) {
1901
- if (this._konvaLayer) this._konvaLayer.add(object.ref());
1896
+ if (object.type() === "Image") this._groupImages.add(object.ref()); else if (object.type() === "Text") this._groupTexts.add(object.ref()); else this._groupGeometry.add(object.ref());
1902
1897
  }
1903
1898
  konvaLayerFind(type) {
1904
1899
  if (!this._konvaLayer) return [];
1905
1900
  const konvaShape = MarkupMode2Konva[type];
1906
1901
  if (!konvaShape || !konvaShape.initializer) return [];
1907
- return this._konvaLayer.find(konvaShape.name).filter((ref => ref.parent === this._konvaLayer));
1902
+ return this._konvaLayer.find(konvaShape.name).filter((ref => ref.parent === this._konvaLayer || ref.parent === this._groupImages || ref.parent === this._groupGeometry || ref.parent === this._groupTexts));
1908
1903
  }
1909
1904
  initializeKonva() {
1910
1905
  const stage = new Konva.Stage({
@@ -1917,6 +1912,12 @@ class KonvaMarkup {
1917
1912
  pixelRation: window.devicePixelRatio
1918
1913
  });
1919
1914
  stage.add(layer);
1915
+ this._groupImages = new Konva.Group;
1916
+ layer.add(this._groupImages);
1917
+ this._groupGeometry = new Konva.Group;
1918
+ layer.add(this._groupGeometry);
1919
+ this._groupTexts = new Konva.Group;
1920
+ layer.add(this._groupTexts);
1920
1921
  this._konvaLayer = layer;
1921
1922
  const transformer = new Konva.Transformer({
1922
1923
  shouldOverdrawWholeArea: false,
@@ -2082,7 +2083,7 @@ class KonvaMarkup {
2082
2083
  this.removeImageInput();
2083
2084
  }
2084
2085
  }
2085
- if (transformer.nodes().filter((x => x.className === "Cloud")).length > 0 || e.target.className === "Cloud") {
2086
+ if (transformer.nodes().filter((x => x.className === "Cloud" || x.className === "Image")).length > 0 || e.target.className === "Cloud" || e.target.className === "Image") {
2086
2087
  transformer.rotateEnabled(false);
2087
2088
  } else {
2088
2089
  transformer.rotateEnabled(true);
@@ -2115,8 +2116,13 @@ class KonvaMarkup {
2115
2116
  }
2116
2117
  destroyKonva() {
2117
2118
  var _a;
2119
+ this.removeTextInput();
2120
+ this.removeImageInput();
2118
2121
  this.clearOverlay();
2119
2122
  (_a = this._konvaStage) === null || _a === void 0 ? void 0 : _a.destroy();
2123
+ this._groupImages = undefined;
2124
+ this._groupGeometry = undefined;
2125
+ this._groupTexts = undefined;
2120
2126
  this._konvaLayer = undefined;
2121
2127
  this._konvaTransformer = undefined;
2122
2128
  this._konvaStage = undefined;
@@ -2313,6 +2319,9 @@ class KonvaMarkup {
2313
2319
  this._textInputRef.style.display = "block";
2314
2320
  this._textInputRef.style.top = inputY + "px";
2315
2321
  this._textInputRef.style.left = inputX + "px";
2322
+ this._textInputRef.style.fontSize = `${this.fontSize}px`;
2323
+ this._textInputRef.style.color = `${this._markupColor.HexColor}`;
2324
+ this._textInputRef.style.fontFamily = "Calibri";
2316
2325
  this._textInputRef.onkeydown = event => {
2317
2326
  if (event.key === "Enter" && !event.shiftKey) {
2318
2327
  event.preventDefault();
@@ -4743,24 +4752,24 @@ class VsfXPartialLoader extends BaseLoader {
4743
4752
  type: "geometrystart",
4744
4753
  model: this.model
4745
4754
  });
4746
- await this.model.downloadResource(this.model.database, chunkLoadHandler, abortController.signal).catch((error => {
4747
- if (!servicePartAborted) throw error;
4755
+ await this.model.downloadResource(this.model.database, chunkLoadHandler, abortController.signal).catch((e => {
4756
+ if (!servicePartAborted) throw e;
4748
4757
  }));
4749
4758
  this.viewer.emitEvent({
4750
4759
  type: "geometryend",
4751
4760
  model: this.model
4752
4761
  });
4753
- } catch (error) {
4762
+ } catch (e) {
4754
4763
  if (pendingRequestsTimerId) {
4755
4764
  window.clearTimeout(pendingRequestsTimerId);
4756
4765
  pendingRequestsTimerId = 0;
4757
4766
  }
4758
4767
  this.viewer.emitEvent({
4759
4768
  type: "geometryerror",
4760
- data: error,
4769
+ data: e,
4761
4770
  model: this.model
4762
4771
  });
4763
- throw error;
4772
+ throw e;
4764
4773
  }
4765
4774
  }
4766
4775
  }