@inweb/viewer-visualize 25.8.2 → 25.8.3
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.
|
@@ -1722,45 +1722,76 @@ class KonvaMarkup {
|
|
|
1722
1722
|
}
|
|
1723
1723
|
colorizeAllMarkup(r, g, b) {
|
|
1724
1724
|
const hexColor = new MarkupColor(r, g, b).HexColor;
|
|
1725
|
-
this.getObjects().
|
|
1726
|
-
|
|
1727
|
-
|
|
1725
|
+
this.getObjects().filter((obj => {
|
|
1726
|
+
var _a;
|
|
1727
|
+
return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor);
|
|
1728
1728
|
}));
|
|
1729
|
-
this._konvaLayer.draw();
|
|
1730
1729
|
}
|
|
1731
1730
|
colorizeSelectedMarkups(r, g, b) {
|
|
1732
1731
|
const hexColor = new MarkupColor(r, g, b).HexColor;
|
|
1733
|
-
this.getSelectedObjects().
|
|
1734
|
-
|
|
1735
|
-
|
|
1732
|
+
this.getSelectedObjects().filter((obj => {
|
|
1733
|
+
var _a;
|
|
1734
|
+
return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor);
|
|
1736
1735
|
}));
|
|
1737
1736
|
}
|
|
1738
1737
|
setViewpoint(viewpoint) {
|
|
1739
|
-
|
|
1738
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1739
|
+
const markupColor = ((_a = viewpoint.custom_fields) === null || _a === void 0 ? void 0 : _a.markup_color) || {
|
|
1740
1740
|
r: 255,
|
|
1741
1741
|
g: 0,
|
|
1742
1742
|
b: 0
|
|
1743
1743
|
};
|
|
1744
1744
|
this.setMarkupColor(markupColor.r, markupColor.g, markupColor.b);
|
|
1745
|
-
|
|
1745
|
+
(_b = viewpoint.lines) === null || _b === void 0 ? void 0 : _b.forEach((line => {
|
|
1746
|
+
const linePoints = [];
|
|
1747
|
+
line.points.forEach((point => {
|
|
1748
|
+
const screenPoint = this._worldTransformer.worldToScreen(point);
|
|
1749
|
+
linePoints.push(screenPoint.x);
|
|
1750
|
+
linePoints.push(screenPoint.y);
|
|
1751
|
+
}));
|
|
1752
|
+
this.addLine(linePoints, line.color, line.type, line.width, line.id);
|
|
1753
|
+
}));
|
|
1754
|
+
(_c = viewpoint.texts) === null || _c === void 0 ? void 0 : _c.forEach((text => {
|
|
1755
|
+
const screenPoint = this._worldTransformer.worldToScreen(text.position);
|
|
1756
|
+
this.addText(text.text, screenPoint, text.angle, text.color, text.text_size, text.font_size, text.id);
|
|
1757
|
+
}));
|
|
1758
|
+
(_d = viewpoint.rectangles) === null || _d === void 0 ? void 0 : _d.forEach((rect => {
|
|
1759
|
+
const screenPoint = this._worldTransformer.worldToScreen(rect.position);
|
|
1760
|
+
this.addRectangle(screenPoint, rect.width, rect.height, rect.line_width, rect.color, rect.id);
|
|
1761
|
+
}));
|
|
1762
|
+
(_e = viewpoint.ellipses) === null || _e === void 0 ? void 0 : _e.forEach((ellipse => {
|
|
1763
|
+
const screenPoint = this._worldTransformer.worldToScreen(ellipse.position);
|
|
1764
|
+
this.addEllipse(screenPoint, ellipse.radius, ellipse.line_width, ellipse.color, ellipse.id);
|
|
1765
|
+
}));
|
|
1766
|
+
(_f = viewpoint.arrows) === null || _f === void 0 ? void 0 : _f.forEach((arrow => {
|
|
1767
|
+
const startPoint = this._worldTransformer.worldToScreen(arrow.start);
|
|
1768
|
+
const endPoint = this._worldTransformer.worldToScreen(arrow.end);
|
|
1769
|
+
this.addArrow(startPoint, endPoint, arrow.color, arrow.id);
|
|
1770
|
+
}));
|
|
1771
|
+
(_g = viewpoint.clouds) === null || _g === void 0 ? void 0 : _g.forEach((cloud => {
|
|
1772
|
+
const screenPoint = this._worldTransformer.worldToScreen(cloud.position);
|
|
1773
|
+
this.addCloud(screenPoint, cloud.width, cloud.height, cloud.line_width, cloud.color, cloud.id);
|
|
1774
|
+
}));
|
|
1775
|
+
(_h = viewpoint.images) === null || _h === void 0 ? void 0 : _h.forEach((image => {
|
|
1776
|
+
const screenPoint = this._worldTransformer.worldToScreen(image.position);
|
|
1777
|
+
this.addImage(screenPoint, image.src, image.width, image.height, image.id);
|
|
1778
|
+
}));
|
|
1746
1779
|
}
|
|
1747
1780
|
getViewpoint() {
|
|
1748
|
-
const viewpoint = {
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1781
|
+
const viewpoint = {};
|
|
1782
|
+
viewpoint.lines = this.getMarkupLines();
|
|
1783
|
+
viewpoint.texts = this.getMarkupTexts();
|
|
1784
|
+
viewpoint.arrows = this.getMarkupArrows();
|
|
1785
|
+
viewpoint.clouds = this.getMarkupClouds();
|
|
1786
|
+
viewpoint.ellipses = this.getMarkupEllipses();
|
|
1787
|
+
viewpoint.images = this.getMarkupImages();
|
|
1788
|
+
viewpoint.rectangles = this.getMarkupRectangles();
|
|
1789
|
+
viewpoint.custom_fields = {
|
|
1790
|
+
markup_color: this.getMarkupColor()
|
|
1756
1791
|
};
|
|
1757
1792
|
viewpoint.snapshot = {
|
|
1758
1793
|
data: this.combineMarkupWithDrawing()
|
|
1759
1794
|
};
|
|
1760
|
-
viewpoint.custom_fields = {
|
|
1761
|
-
markup_color: this.getMarkupColor()
|
|
1762
|
-
};
|
|
1763
|
-
this.fillViewpointShapes(viewpoint);
|
|
1764
1795
|
viewpoint.description = (new Date).toDateString();
|
|
1765
1796
|
return viewpoint;
|
|
1766
1797
|
}
|
|
@@ -1806,50 +1837,6 @@ class KonvaMarkup {
|
|
|
1806
1837
|
clearSelected() {
|
|
1807
1838
|
this._konvaTransformer.nodes([]);
|
|
1808
1839
|
}
|
|
1809
|
-
fillViewpointShapes(viewpoint) {
|
|
1810
|
-
const markupLines = this.getMarkupLines();
|
|
1811
|
-
if (markupLines && markupLines.length > 0) {
|
|
1812
|
-
markupLines === null || markupLines === void 0 ? void 0 : markupLines.forEach((line => {
|
|
1813
|
-
viewpoint.lines.push(line);
|
|
1814
|
-
}));
|
|
1815
|
-
}
|
|
1816
|
-
const markupTexts = this.getMarkupTexts();
|
|
1817
|
-
if (markupTexts && markupTexts.length > 0) {
|
|
1818
|
-
markupTexts === null || markupTexts === void 0 ? void 0 : markupTexts.forEach((text => {
|
|
1819
|
-
viewpoint.texts.push(text);
|
|
1820
|
-
}));
|
|
1821
|
-
}
|
|
1822
|
-
const markupRectangles = this.getMarkupRectangles();
|
|
1823
|
-
if (markupRectangles && markupRectangles.length > 0) {
|
|
1824
|
-
markupRectangles === null || markupRectangles === void 0 ? void 0 : markupRectangles.forEach((rectangle => {
|
|
1825
|
-
viewpoint.rectangles.push(rectangle);
|
|
1826
|
-
}));
|
|
1827
|
-
}
|
|
1828
|
-
const markupEllipses = this.getMarkupEllipses();
|
|
1829
|
-
if (markupEllipses && markupEllipses.length > 0) {
|
|
1830
|
-
markupEllipses === null || markupEllipses === void 0 ? void 0 : markupEllipses.forEach((ellipse => {
|
|
1831
|
-
viewpoint.ellipses.push(ellipse);
|
|
1832
|
-
}));
|
|
1833
|
-
}
|
|
1834
|
-
const markupArrows = this.getMarkupArrows();
|
|
1835
|
-
if (markupArrows && markupArrows.length > 0) {
|
|
1836
|
-
markupArrows === null || markupArrows === void 0 ? void 0 : markupArrows.forEach((arrow => {
|
|
1837
|
-
viewpoint.arrows.push(arrow);
|
|
1838
|
-
}));
|
|
1839
|
-
}
|
|
1840
|
-
const markupImages = this.getMarkupImages();
|
|
1841
|
-
if (markupImages && markupImages.length > 0) {
|
|
1842
|
-
markupImages === null || markupImages === void 0 ? void 0 : markupImages.forEach((image => {
|
|
1843
|
-
viewpoint.images.push(image);
|
|
1844
|
-
}));
|
|
1845
|
-
}
|
|
1846
|
-
const markupClouds = this.getMarkupClouds();
|
|
1847
|
-
if (markupClouds && markupClouds.length > 0) {
|
|
1848
|
-
markupClouds === null || markupClouds === void 0 ? void 0 : markupClouds.forEach((cloud => {
|
|
1849
|
-
viewpoint.clouds.push(cloud);
|
|
1850
|
-
}));
|
|
1851
|
-
}
|
|
1852
|
-
}
|
|
1853
1840
|
addObject(object) {
|
|
1854
1841
|
this._konvaLayer.add(object.ref());
|
|
1855
1842
|
}
|
|
@@ -2080,11 +2067,11 @@ class KonvaMarkup {
|
|
|
2080
2067
|
}
|
|
2081
2068
|
getMarkupLines() {
|
|
2082
2069
|
const lines = [];
|
|
2083
|
-
this.konvaLayerFind("Line").forEach((
|
|
2084
|
-
const linePoints =
|
|
2070
|
+
this.konvaLayerFind("Line").forEach((ref => {
|
|
2071
|
+
const linePoints = ref.points();
|
|
2085
2072
|
if (!linePoints) return;
|
|
2086
2073
|
const worldPoints = [];
|
|
2087
|
-
const absoluteTransform =
|
|
2074
|
+
const absoluteTransform = ref.getAbsoluteTransform();
|
|
2088
2075
|
for (let i = 0; i < linePoints.length; i += 2) {
|
|
2089
2076
|
const atPoint = absoluteTransform.point({
|
|
2090
2077
|
x: linePoints[i],
|
|
@@ -2093,14 +2080,15 @@ class KonvaMarkup {
|
|
|
2093
2080
|
const worldPoint = this._worldTransformer.screenToWorld(atPoint);
|
|
2094
2081
|
worldPoints.push(worldPoint);
|
|
2095
2082
|
}
|
|
2096
|
-
const konvaLine = new KonvaLine(null,
|
|
2097
|
-
|
|
2083
|
+
const konvaLine = new KonvaLine(null, ref);
|
|
2084
|
+
const line = {
|
|
2098
2085
|
id: konvaLine.id(),
|
|
2099
2086
|
points: worldPoints,
|
|
2100
2087
|
color: konvaLine.getColor() || "#ff0000",
|
|
2101
2088
|
type: konvaLine.getLineType() || this.lineType,
|
|
2102
2089
|
width: konvaLine.getLineWidth() || this.lineWidth
|
|
2103
|
-
}
|
|
2090
|
+
};
|
|
2091
|
+
lines.push(line);
|
|
2104
2092
|
}));
|
|
2105
2093
|
return lines;
|
|
2106
2094
|
}
|
|
@@ -2108,15 +2096,14 @@ class KonvaMarkup {
|
|
|
2108
2096
|
const texts = [];
|
|
2109
2097
|
const textSize = .02;
|
|
2110
2098
|
const textScale = this._worldTransformer.getScale();
|
|
2111
|
-
this.konvaLayerFind("Text").forEach((
|
|
2112
|
-
if (!text) return;
|
|
2099
|
+
this.konvaLayerFind("Text").forEach((ref => {
|
|
2113
2100
|
const position = {
|
|
2114
|
-
x:
|
|
2115
|
-
y:
|
|
2101
|
+
x: ref.x(),
|
|
2102
|
+
y: ref.y()
|
|
2116
2103
|
};
|
|
2117
2104
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
2118
|
-
const shape = new KonvaText(null,
|
|
2119
|
-
|
|
2105
|
+
const shape = new KonvaText(null, ref);
|
|
2106
|
+
const text = {
|
|
2120
2107
|
id: shape.id(),
|
|
2121
2108
|
position: worldPoint,
|
|
2122
2109
|
text: shape.getText(),
|
|
@@ -2124,140 +2111,109 @@ class KonvaMarkup {
|
|
|
2124
2111
|
angle: shape.getRotation(),
|
|
2125
2112
|
color: shape.getColor(),
|
|
2126
2113
|
font_size: shape.getFontSize()
|
|
2127
|
-
}
|
|
2114
|
+
};
|
|
2115
|
+
texts.push(text);
|
|
2128
2116
|
}));
|
|
2129
2117
|
return texts;
|
|
2130
2118
|
}
|
|
2131
2119
|
getMarkupRectangles() {
|
|
2132
2120
|
const rectangles = [];
|
|
2133
|
-
this.konvaLayerFind("Rectangle").forEach((
|
|
2134
|
-
const position =
|
|
2121
|
+
this.konvaLayerFind("Rectangle").forEach((ref => {
|
|
2122
|
+
const position = ref.position();
|
|
2135
2123
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
2136
|
-
const shape = new KonvaRectangle(null,
|
|
2137
|
-
|
|
2124
|
+
const shape = new KonvaRectangle(null, ref);
|
|
2125
|
+
const rectangle = {
|
|
2138
2126
|
id: shape.id(),
|
|
2139
2127
|
position: worldPoint,
|
|
2140
2128
|
width: shape.getWidth(),
|
|
2141
2129
|
height: shape.getHeigth(),
|
|
2142
2130
|
line_width: shape.getLineWidth(),
|
|
2143
2131
|
color: shape.getColor()
|
|
2144
|
-
}
|
|
2132
|
+
};
|
|
2133
|
+
rectangles.push(rectangle);
|
|
2145
2134
|
}));
|
|
2146
2135
|
return rectangles;
|
|
2147
2136
|
}
|
|
2148
2137
|
getMarkupEllipses() {
|
|
2149
2138
|
const ellipses = [];
|
|
2150
|
-
this.konvaLayerFind("Ellipse").forEach((
|
|
2151
|
-
const position =
|
|
2139
|
+
this.konvaLayerFind("Ellipse").forEach((ref => {
|
|
2140
|
+
const position = ref.position();
|
|
2152
2141
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
2153
|
-
const shape = new KonvaEllipse(null,
|
|
2154
|
-
|
|
2142
|
+
const shape = new KonvaEllipse(null, ref);
|
|
2143
|
+
const ellipse = {
|
|
2155
2144
|
id: shape.id(),
|
|
2156
2145
|
position: worldPoint,
|
|
2157
2146
|
radius: {
|
|
2158
|
-
x:
|
|
2159
|
-
y:
|
|
2147
|
+
x: ref.getRadiusX(),
|
|
2148
|
+
y: ref.getRadiusY()
|
|
2160
2149
|
},
|
|
2161
2150
|
line_width: shape.getLineWidth(),
|
|
2162
2151
|
color: shape.getColor()
|
|
2163
|
-
}
|
|
2152
|
+
};
|
|
2153
|
+
ellipses.push(ellipse);
|
|
2164
2154
|
}));
|
|
2165
2155
|
return ellipses;
|
|
2166
2156
|
}
|
|
2167
2157
|
getMarkupArrows() {
|
|
2168
2158
|
const arrows = [];
|
|
2169
|
-
this.konvaLayerFind("Arrow").forEach((
|
|
2170
|
-
const absoluteTransform =
|
|
2159
|
+
this.konvaLayerFind("Arrow").forEach((ref => {
|
|
2160
|
+
const absoluteTransform = ref.getAbsoluteTransform();
|
|
2171
2161
|
const atStartPoint = absoluteTransform.point({
|
|
2172
|
-
x:
|
|
2173
|
-
y:
|
|
2162
|
+
x: ref.points()[0],
|
|
2163
|
+
y: ref.points()[1]
|
|
2174
2164
|
});
|
|
2175
2165
|
const worldStartPoint = this._worldTransformer.screenToWorld(atStartPoint);
|
|
2176
2166
|
const atEndPoint = absoluteTransform.point({
|
|
2177
|
-
x:
|
|
2178
|
-
y:
|
|
2167
|
+
x: ref.points()[2],
|
|
2168
|
+
y: ref.points()[3]
|
|
2179
2169
|
});
|
|
2180
2170
|
const worldEndPoint = this._worldTransformer.screenToWorld(atEndPoint);
|
|
2181
|
-
const shape = new KonvaArrow(null,
|
|
2182
|
-
|
|
2171
|
+
const shape = new KonvaArrow(null, ref);
|
|
2172
|
+
const arrow = {
|
|
2183
2173
|
id: shape.id(),
|
|
2184
2174
|
start: worldStartPoint,
|
|
2185
2175
|
end: worldEndPoint,
|
|
2186
2176
|
color: shape.getColor()
|
|
2187
|
-
}
|
|
2177
|
+
};
|
|
2178
|
+
arrows.push(arrow);
|
|
2188
2179
|
}));
|
|
2189
2180
|
return arrows;
|
|
2190
2181
|
}
|
|
2191
2182
|
getMarkupImages() {
|
|
2192
2183
|
const images = [];
|
|
2193
|
-
this.konvaLayerFind("Image").forEach((
|
|
2194
|
-
const position =
|
|
2184
|
+
this.konvaLayerFind("Image").forEach((ref => {
|
|
2185
|
+
const position = ref.position();
|
|
2195
2186
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
2196
|
-
const shape = new KonvaImage(null,
|
|
2197
|
-
|
|
2187
|
+
const shape = new KonvaImage(null, ref);
|
|
2188
|
+
const image = {
|
|
2198
2189
|
id: shape.id(),
|
|
2199
2190
|
position: worldPoint,
|
|
2200
2191
|
src: shape.getSrc(),
|
|
2201
2192
|
width: shape.getWidth(),
|
|
2202
2193
|
height: shape.getHeight()
|
|
2203
|
-
}
|
|
2194
|
+
};
|
|
2195
|
+
images.push(image);
|
|
2204
2196
|
}));
|
|
2205
2197
|
return images;
|
|
2206
2198
|
}
|
|
2207
2199
|
getMarkupClouds() {
|
|
2208
2200
|
const clouds = [];
|
|
2209
|
-
this.konvaLayerFind("Cloud").forEach((
|
|
2210
|
-
const position =
|
|
2201
|
+
this.konvaLayerFind("Cloud").forEach((ref => {
|
|
2202
|
+
const position = ref.position();
|
|
2211
2203
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
2212
|
-
const shape = new KonvaCloud(null,
|
|
2213
|
-
|
|
2204
|
+
const shape = new KonvaCloud(null, ref);
|
|
2205
|
+
const cloud = {
|
|
2214
2206
|
id: shape.id(),
|
|
2215
2207
|
position: worldPoint,
|
|
2216
2208
|
width: shape.getWidth(),
|
|
2217
2209
|
height: shape.getHeigth(),
|
|
2218
2210
|
line_width: shape.getLineWidth(),
|
|
2219
2211
|
color: shape.getColor()
|
|
2220
|
-
}
|
|
2212
|
+
};
|
|
2213
|
+
clouds.push(cloud);
|
|
2221
2214
|
}));
|
|
2222
2215
|
return clouds;
|
|
2223
2216
|
}
|
|
2224
|
-
loadMarkup(viewpoint) {
|
|
2225
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2226
|
-
(_a = viewpoint.lines) === null || _a === void 0 ? void 0 : _a.forEach((vpLine => {
|
|
2227
|
-
const linePoints = [];
|
|
2228
|
-
vpLine.points.forEach((point => {
|
|
2229
|
-
const screenPoint = this._worldTransformer.worldToScreen(point);
|
|
2230
|
-
linePoints.push(screenPoint.x);
|
|
2231
|
-
linePoints.push(screenPoint.y);
|
|
2232
|
-
}));
|
|
2233
|
-
this.addLine(linePoints, vpLine.color, vpLine.type, vpLine.width, vpLine.id);
|
|
2234
|
-
}));
|
|
2235
|
-
(_b = viewpoint.texts) === null || _b === void 0 ? void 0 : _b.forEach((vpText => {
|
|
2236
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpText.position);
|
|
2237
|
-
this.addText(vpText.text, screenPoint, vpText.angle, vpText.color, vpText.text_size, vpText.font_size, vpText.id);
|
|
2238
|
-
}));
|
|
2239
|
-
(_c = viewpoint.rectangles) === null || _c === void 0 ? void 0 : _c.forEach((vpRect => {
|
|
2240
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpRect.position);
|
|
2241
|
-
this.addRectangle(screenPoint, vpRect.width, vpRect.height, vpRect.line_width, vpRect.color, vpRect.id);
|
|
2242
|
-
}));
|
|
2243
|
-
(_d = viewpoint.ellipses) === null || _d === void 0 ? void 0 : _d.forEach((vpEllipse => {
|
|
2244
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpEllipse.position);
|
|
2245
|
-
this.addEllipse(screenPoint, vpEllipse.radius, vpEllipse.line_width, vpEllipse.color, vpEllipse.id);
|
|
2246
|
-
}));
|
|
2247
|
-
(_e = viewpoint.arrows) === null || _e === void 0 ? void 0 : _e.forEach((vpArrow => {
|
|
2248
|
-
const startPoint = this._worldTransformer.worldToScreen(vpArrow.start);
|
|
2249
|
-
const endPoint = this._worldTransformer.worldToScreen(vpArrow.end);
|
|
2250
|
-
this.addArrow(startPoint, endPoint, vpArrow.color, vpArrow.id);
|
|
2251
|
-
}));
|
|
2252
|
-
(_f = viewpoint.clouds) === null || _f === void 0 ? void 0 : _f.forEach((vpCloud => {
|
|
2253
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpCloud.position);
|
|
2254
|
-
this.addCloud(screenPoint, vpCloud.width, vpCloud.height, vpCloud.line_width, vpCloud.color, vpCloud.id);
|
|
2255
|
-
}));
|
|
2256
|
-
(_g = viewpoint.images) === null || _g === void 0 ? void 0 : _g.forEach((vpImage => {
|
|
2257
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpImage.position);
|
|
2258
|
-
this.addImage(screenPoint, vpImage.src, vpImage.width, vpImage.height, vpImage.id);
|
|
2259
|
-
}));
|
|
2260
|
-
}
|
|
2261
2217
|
combineMarkupWithDrawing() {
|
|
2262
2218
|
this.clearSelected();
|
|
2263
2219
|
const tempCanvas = document.createElement("canvas");
|
|
@@ -2286,8 +2242,7 @@ class KonvaMarkup {
|
|
|
2286
2242
|
color: color || this._markupColor.HexColor,
|
|
2287
2243
|
id: id
|
|
2288
2244
|
});
|
|
2289
|
-
|
|
2290
|
-
this._konvaLayer.add(obj);
|
|
2245
|
+
this._konvaLayer.add(konvaLine.ref());
|
|
2291
2246
|
return konvaLine;
|
|
2292
2247
|
}
|
|
2293
2248
|
createTextInput(pos, inputX, inputY, angle, text) {
|
|
@@ -2369,33 +2324,32 @@ class KonvaMarkup {
|
|
|
2369
2324
|
this._imageInputPos = null;
|
|
2370
2325
|
}
|
|
2371
2326
|
addText(specifiedText, position, angle, color, textSize, fontSize, id) {
|
|
2327
|
+
if (!specifiedText) return;
|
|
2372
2328
|
const trNodes = this._konvaTransformer.nodes();
|
|
2373
2329
|
if (trNodes.length > 0) {
|
|
2374
2330
|
trNodes[0].destroy();
|
|
2375
2331
|
this._konvaTransformer.nodes([]);
|
|
2376
2332
|
}
|
|
2377
2333
|
this.removeTextInput();
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
return konvaText;
|
|
2398
|
-
}
|
|
2334
|
+
const tolerance = 1e-6;
|
|
2335
|
+
if (textSize && textSize > tolerance && (!fontSize || fontSize < tolerance)) {
|
|
2336
|
+
const size = .02;
|
|
2337
|
+
const scale = this._worldTransformer.getScale();
|
|
2338
|
+
fontSize = textSize / (scale.y / size) / 34;
|
|
2339
|
+
}
|
|
2340
|
+
const konvaText = new KonvaText({
|
|
2341
|
+
position: {
|
|
2342
|
+
x: position.x,
|
|
2343
|
+
y: position.y
|
|
2344
|
+
},
|
|
2345
|
+
text: specifiedText,
|
|
2346
|
+
rotation: angle,
|
|
2347
|
+
fontSize: fontSize || this.fontSize,
|
|
2348
|
+
color: color || this._markupColor.HexColor,
|
|
2349
|
+
id: id
|
|
2350
|
+
});
|
|
2351
|
+
this._konvaLayer.add(konvaText.ref());
|
|
2352
|
+
return konvaText;
|
|
2399
2353
|
}
|
|
2400
2354
|
addRectangle(position, width, height, lineWidth, color, id) {
|
|
2401
2355
|
if (!position) return;
|
|
@@ -2407,8 +2361,7 @@ class KonvaMarkup {
|
|
|
2407
2361
|
color: color || this._markupColor.HexColor,
|
|
2408
2362
|
id: id
|
|
2409
2363
|
});
|
|
2410
|
-
|
|
2411
|
-
this._konvaLayer.add(obj);
|
|
2364
|
+
this._konvaLayer.add(konvaRectangle.ref());
|
|
2412
2365
|
return konvaRectangle;
|
|
2413
2366
|
}
|
|
2414
2367
|
addEllipse(position, radius, lineWidth, color, id) {
|
|
@@ -2420,8 +2373,7 @@ class KonvaMarkup {
|
|
|
2420
2373
|
color: color || this._markupColor.HexColor,
|
|
2421
2374
|
id: id
|
|
2422
2375
|
});
|
|
2423
|
-
|
|
2424
|
-
this._konvaLayer.add(obj);
|
|
2376
|
+
this._konvaLayer.add(konvaEllipse.ref());
|
|
2425
2377
|
return konvaEllipse;
|
|
2426
2378
|
}
|
|
2427
2379
|
addArrow(start, end, color, id) {
|
|
@@ -2432,8 +2384,7 @@ class KonvaMarkup {
|
|
|
2432
2384
|
color: color || this._markupColor.HexColor,
|
|
2433
2385
|
id: id
|
|
2434
2386
|
});
|
|
2435
|
-
|
|
2436
|
-
this._konvaLayer.add(obj);
|
|
2387
|
+
this._konvaLayer.add(konvaArrow.ref());
|
|
2437
2388
|
return konvaArrow;
|
|
2438
2389
|
}
|
|
2439
2390
|
addCloud(position, width, height, lineWidth, color, id) {
|
|
@@ -2446,30 +2397,25 @@ class KonvaMarkup {
|
|
|
2446
2397
|
lineWidth: lineWidth || this.lineWidth,
|
|
2447
2398
|
id: id
|
|
2448
2399
|
});
|
|
2449
|
-
|
|
2450
|
-
this._konvaLayer.add(obj);
|
|
2400
|
+
this._konvaLayer.add(konvaCloud.ref());
|
|
2451
2401
|
return konvaCloud;
|
|
2452
2402
|
}
|
|
2453
2403
|
addImage(position, src, width, height, id) {
|
|
2454
|
-
if (!position) return;
|
|
2455
|
-
|
|
2456
|
-
if (
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
src: src,
|
|
2460
|
-
width: width,
|
|
2461
|
-
height: height,
|
|
2462
|
-
id: id
|
|
2463
|
-
});
|
|
2464
|
-
const obj = konvaImage.ref();
|
|
2465
|
-
this._konvaLayer.add(obj);
|
|
2466
|
-
const trNodes = this._konvaTransformer.nodes();
|
|
2467
|
-
if (trNodes.length > 0) {
|
|
2468
|
-
trNodes[0].destroy();
|
|
2469
|
-
this._konvaTransformer.nodes([]);
|
|
2470
|
-
}
|
|
2404
|
+
if (!position || !src) return;
|
|
2405
|
+
const trNodes = this._konvaTransformer.nodes();
|
|
2406
|
+
if (trNodes.length > 0) {
|
|
2407
|
+
trNodes[0].destroy();
|
|
2408
|
+
this._konvaTransformer.nodes([]);
|
|
2471
2409
|
}
|
|
2472
2410
|
this.removeImageInput();
|
|
2411
|
+
const konvaImage = new KonvaImage({
|
|
2412
|
+
position: position,
|
|
2413
|
+
src: src,
|
|
2414
|
+
width: width,
|
|
2415
|
+
height: height,
|
|
2416
|
+
id: id
|
|
2417
|
+
});
|
|
2418
|
+
this._konvaLayer.add(konvaImage.ref());
|
|
2473
2419
|
return konvaImage;
|
|
2474
2420
|
}
|
|
2475
2421
|
}
|