@inweb/viewer-visualize 25.7.10 → 25.8.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.
|
@@ -1571,31 +1571,37 @@ const MarkupMode2Konva = {
|
|
|
1571
1571
|
},
|
|
1572
1572
|
Line: {
|
|
1573
1573
|
name: "Line",
|
|
1574
|
-
initializer: ref => new KonvaLine(
|
|
1574
|
+
initializer: (ref, params = null) => new KonvaLine(params, ref),
|
|
1575
|
+
zIndex: 1
|
|
1575
1576
|
},
|
|
1576
1577
|
Text: {
|
|
1577
1578
|
name: "Text",
|
|
1578
|
-
initializer: ref => new KonvaText(
|
|
1579
|
+
initializer: (ref, params = null) => new KonvaText(params, ref)
|
|
1579
1580
|
},
|
|
1580
1581
|
Rectangle: {
|
|
1581
1582
|
name: "Rect",
|
|
1582
|
-
initializer: ref => new KonvaRectangle(
|
|
1583
|
+
initializer: (ref, params = null) => new KonvaRectangle(params, ref),
|
|
1584
|
+
zIndex: 1
|
|
1583
1585
|
},
|
|
1584
1586
|
Ellipse: {
|
|
1585
1587
|
name: "Ellipse",
|
|
1586
|
-
initializer: ref => new KonvaEllipse(
|
|
1588
|
+
initializer: (ref, params = null) => new KonvaEllipse(params, ref),
|
|
1589
|
+
zIndex: 1
|
|
1587
1590
|
},
|
|
1588
1591
|
Arrow: {
|
|
1589
1592
|
name: "Arrow",
|
|
1590
|
-
initializer: ref => new KonvaArrow(
|
|
1593
|
+
initializer: (ref, params = null) => new KonvaArrow(params, ref),
|
|
1594
|
+
zIndex: 1
|
|
1591
1595
|
},
|
|
1592
1596
|
Image: {
|
|
1593
1597
|
name: "Image",
|
|
1594
|
-
initializer: ref => new KonvaImage(
|
|
1598
|
+
initializer: (ref, params = null) => new KonvaImage(params, ref),
|
|
1599
|
+
zIndex: 0
|
|
1595
1600
|
},
|
|
1596
1601
|
Cloud: {
|
|
1597
1602
|
name: "Cloud",
|
|
1598
|
-
initializer: ref => new KonvaCloud(null, ref)
|
|
1603
|
+
initializer: ref => new KonvaCloud(null, ref),
|
|
1604
|
+
zIndex: 1
|
|
1599
1605
|
}
|
|
1600
1606
|
};
|
|
1601
1607
|
|
|
@@ -1626,10 +1632,10 @@ class KonvaMarkup {
|
|
|
1626
1632
|
this.pan = event => {
|
|
1627
1633
|
const dX = event.dX / window.devicePixelRatio;
|
|
1628
1634
|
const dY = event.dY / window.devicePixelRatio;
|
|
1629
|
-
|
|
1635
|
+
this.getObjects().forEach((obj => obj.ref().move({
|
|
1630
1636
|
x: dX,
|
|
1631
1637
|
y: dY
|
|
1632
|
-
})))
|
|
1638
|
+
})));
|
|
1633
1639
|
};
|
|
1634
1640
|
this.redirectToViewer = event => {
|
|
1635
1641
|
if (this._viewer) this._viewer.emit(event);
|
|
@@ -1682,8 +1688,8 @@ class KonvaMarkup {
|
|
|
1682
1688
|
clearOverlay() {
|
|
1683
1689
|
this.removeTextInput();
|
|
1684
1690
|
this.removeImageInput();
|
|
1685
|
-
this.
|
|
1686
|
-
|
|
1691
|
+
this.clearSelected();
|
|
1692
|
+
this.getObjects().forEach((obj => obj.ref().destroy()));
|
|
1687
1693
|
}
|
|
1688
1694
|
getMarkupColor() {
|
|
1689
1695
|
return this._markupColor.RGB;
|
|
@@ -1691,23 +1697,19 @@ class KonvaMarkup {
|
|
|
1691
1697
|
setMarkupColor(r, g, b) {
|
|
1692
1698
|
this._markupColor.setColor(r, g, b);
|
|
1693
1699
|
}
|
|
1694
|
-
colorizeAllMarkup(r
|
|
1695
|
-
const
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
const konvaObj = konvaShape.initializer(ref);
|
|
1700
|
-
if (konvaObj.setColor) konvaObj.setColor(hex);
|
|
1701
|
-
}));
|
|
1700
|
+
colorizeAllMarkup(r, g, b) {
|
|
1701
|
+
const hexColor = new MarkupColor(r, g, b).HexColor;
|
|
1702
|
+
this.getObjects().forEach((obj => {
|
|
1703
|
+
const colorable = obj;
|
|
1704
|
+
if (colorable && colorable.setColor) colorable.setColor(hexColor);
|
|
1702
1705
|
}));
|
|
1703
1706
|
this._konvaLayer.draw();
|
|
1704
1707
|
}
|
|
1705
1708
|
colorizeSelectedMarkups(r, g, b) {
|
|
1709
|
+
const hexColor = new MarkupColor(r, g, b).HexColor;
|
|
1706
1710
|
this.getSelectedObjects().forEach((obj => {
|
|
1707
1711
|
const colorable = obj;
|
|
1708
|
-
if (colorable && colorable.setColor)
|
|
1709
|
-
colorable.setColor(new MarkupColor(r, g, b).HexColor);
|
|
1710
|
-
}
|
|
1712
|
+
if (colorable && colorable.setColor) colorable.setColor(hexColor);
|
|
1711
1713
|
}));
|
|
1712
1714
|
}
|
|
1713
1715
|
setViewpoint(viewpoint) {
|
|
@@ -1750,110 +1752,29 @@ class KonvaMarkup {
|
|
|
1750
1752
|
return this;
|
|
1751
1753
|
}
|
|
1752
1754
|
createObject(type, params) {
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
object = new KonvaLine(params);
|
|
1758
|
-
zIndex = 1;
|
|
1759
|
-
break;
|
|
1760
|
-
|
|
1761
|
-
case "text":
|
|
1762
|
-
object = new KonvaText(params);
|
|
1763
|
-
break;
|
|
1764
|
-
|
|
1765
|
-
case "rectangle":
|
|
1766
|
-
object = new KonvaRectangle(params);
|
|
1767
|
-
zIndex = 1;
|
|
1768
|
-
break;
|
|
1769
|
-
|
|
1770
|
-
case "ellipse":
|
|
1771
|
-
object = new KonvaEllipse(params);
|
|
1772
|
-
zIndex = 1;
|
|
1773
|
-
break;
|
|
1774
|
-
|
|
1775
|
-
case "arrow":
|
|
1776
|
-
object = new KonvaArrow(params);
|
|
1777
|
-
break;
|
|
1778
|
-
|
|
1779
|
-
case "image":
|
|
1780
|
-
object = new KonvaImage(params);
|
|
1781
|
-
zIndex = 0;
|
|
1782
|
-
break;
|
|
1783
|
-
|
|
1784
|
-
case "cloud":
|
|
1785
|
-
object = new KonvaCloud(params);
|
|
1786
|
-
zIndex = 1;
|
|
1787
|
-
break;
|
|
1788
|
-
|
|
1789
|
-
default:
|
|
1790
|
-
throw new Error("Markup CreateObject - unsupported type has been detected.");
|
|
1791
|
-
}
|
|
1755
|
+
var _a;
|
|
1756
|
+
const konvaShape = MarkupMode2Konva[type];
|
|
1757
|
+
if (!konvaShape || !konvaShape.initializer) throw new Error(`Markup CreateObject - unsupported markup type ${type}`);
|
|
1758
|
+
const object = konvaShape.initializer(null, params);
|
|
1792
1759
|
this.addObject(object);
|
|
1793
|
-
object.setZIndex(zIndex);
|
|
1760
|
+
object.setZIndex((_a = konvaShape.zIndex) !== null && _a !== void 0 ? _a : this._zIndex);
|
|
1794
1761
|
this._zIndex++;
|
|
1795
1762
|
return object;
|
|
1796
1763
|
}
|
|
1797
1764
|
getObjects() {
|
|
1798
1765
|
const objects = [];
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
this.konvaLayerFind("Text").forEach((text => {
|
|
1803
|
-
objects.push(new KonvaText(null, text));
|
|
1804
|
-
}));
|
|
1805
|
-
this.konvaLayerFind("Rectangle").forEach((rectangle => {
|
|
1806
|
-
objects.push(new KonvaRectangle(null, rectangle));
|
|
1807
|
-
}));
|
|
1808
|
-
this.konvaLayerFind("Ellipse").forEach((ellipse => {
|
|
1809
|
-
objects.push(new KonvaEllipse(null, ellipse));
|
|
1810
|
-
}));
|
|
1811
|
-
this.konvaLayerFind("Arrow").forEach((arrow => {
|
|
1812
|
-
objects.push(new KonvaArrow(null, arrow));
|
|
1813
|
-
}));
|
|
1814
|
-
this.konvaLayerFind("Image").forEach((image => {
|
|
1815
|
-
objects.push(new KonvaImage(null, image));
|
|
1816
|
-
}));
|
|
1817
|
-
this.konvaLayerFind("Cloud").forEach((cloud => {
|
|
1818
|
-
objects.push(new KonvaCloud(null, cloud));
|
|
1766
|
+
Object.keys(MarkupMode2Konva).forEach((type => {
|
|
1767
|
+
const konvaShape = MarkupMode2Konva[type];
|
|
1768
|
+
this.konvaLayerFind(type).forEach((ref => objects.push(konvaShape.initializer(ref))));
|
|
1819
1769
|
}));
|
|
1820
1770
|
return objects;
|
|
1821
1771
|
}
|
|
1822
1772
|
getSelectedObjects() {
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
const
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
objects.push(new KonvaLine(null, obj));
|
|
1829
|
-
break;
|
|
1830
|
-
|
|
1831
|
-
case "Text":
|
|
1832
|
-
objects.push(new KonvaText(null, obj));
|
|
1833
|
-
break;
|
|
1834
|
-
|
|
1835
|
-
case "Rect":
|
|
1836
|
-
objects.push(new KonvaRectangle(null, obj));
|
|
1837
|
-
break;
|
|
1838
|
-
|
|
1839
|
-
case "Ellipse":
|
|
1840
|
-
objects.push(new KonvaEllipse(null, obj));
|
|
1841
|
-
break;
|
|
1842
|
-
|
|
1843
|
-
case "Arrow":
|
|
1844
|
-
objects.push(new KonvaArrow(null, obj));
|
|
1845
|
-
break;
|
|
1846
|
-
|
|
1847
|
-
case "Image":
|
|
1848
|
-
objects.push(new KonvaImage(null, obj));
|
|
1849
|
-
break;
|
|
1850
|
-
|
|
1851
|
-
case "Cloud":
|
|
1852
|
-
objects.push(new KonvaCloud(null, obj));
|
|
1853
|
-
break;
|
|
1854
|
-
}
|
|
1855
|
-
}));
|
|
1856
|
-
return objects;
|
|
1773
|
+
return this._konvaTransformer.nodes().map((ref => {
|
|
1774
|
+
const name = ref.className;
|
|
1775
|
+
const konvaShape = Object.values(MarkupMode2Konva).find((shape => shape.name === name));
|
|
1776
|
+
return konvaShape ? konvaShape.initializer(ref) : null;
|
|
1777
|
+
})).filter((x => x));
|
|
1857
1778
|
}
|
|
1858
1779
|
selectObjects(objects) {
|
|
1859
1780
|
const selectedObjs = this._konvaTransformer.nodes().concat(objects.map((x => x.ref())));
|
|
@@ -1916,8 +1837,8 @@ class KonvaMarkup {
|
|
|
1916
1837
|
addObject(object) {
|
|
1917
1838
|
this._konvaLayer.add(object.ref());
|
|
1918
1839
|
}
|
|
1919
|
-
konvaLayerFind(
|
|
1920
|
-
const konvaShape = MarkupMode2Konva[
|
|
1840
|
+
konvaLayerFind(type) {
|
|
1841
|
+
const konvaShape = MarkupMode2Konva[type];
|
|
1921
1842
|
if (konvaShape && konvaShape.initializer) {
|
|
1922
1843
|
return this._konvaLayer.find(konvaShape.name).filter((ref => ref.parent === this._konvaLayer));
|
|
1923
1844
|
}
|