@inweb/viewer-visualize 25.8.1 → 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.
package/dist/viewer-visualize.js
CHANGED
|
@@ -13160,45 +13160,76 @@
|
|
|
13160
13160
|
}
|
|
13161
13161
|
colorizeAllMarkup(r, g, b) {
|
|
13162
13162
|
const hexColor = new MarkupColor(r, g, b).HexColor;
|
|
13163
|
-
this.getObjects().
|
|
13164
|
-
|
|
13165
|
-
|
|
13163
|
+
this.getObjects().filter((obj => {
|
|
13164
|
+
var _a;
|
|
13165
|
+
return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor);
|
|
13166
13166
|
}));
|
|
13167
|
-
this._konvaLayer.draw();
|
|
13168
13167
|
}
|
|
13169
13168
|
colorizeSelectedMarkups(r, g, b) {
|
|
13170
13169
|
const hexColor = new MarkupColor(r, g, b).HexColor;
|
|
13171
|
-
this.getSelectedObjects().
|
|
13172
|
-
|
|
13173
|
-
|
|
13170
|
+
this.getSelectedObjects().filter((obj => {
|
|
13171
|
+
var _a;
|
|
13172
|
+
return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor);
|
|
13174
13173
|
}));
|
|
13175
13174
|
}
|
|
13176
13175
|
setViewpoint(viewpoint) {
|
|
13177
|
-
|
|
13176
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13177
|
+
const markupColor = ((_a = viewpoint.custom_fields) === null || _a === void 0 ? void 0 : _a.markup_color) || {
|
|
13178
13178
|
r: 255,
|
|
13179
13179
|
g: 0,
|
|
13180
13180
|
b: 0
|
|
13181
13181
|
};
|
|
13182
13182
|
this.setMarkupColor(markupColor.r, markupColor.g, markupColor.b);
|
|
13183
|
-
|
|
13183
|
+
(_b = viewpoint.lines) === null || _b === void 0 ? void 0 : _b.forEach((line => {
|
|
13184
|
+
const linePoints = [];
|
|
13185
|
+
line.points.forEach((point => {
|
|
13186
|
+
const screenPoint = this._worldTransformer.worldToScreen(point);
|
|
13187
|
+
linePoints.push(screenPoint.x);
|
|
13188
|
+
linePoints.push(screenPoint.y);
|
|
13189
|
+
}));
|
|
13190
|
+
this.addLine(linePoints, line.color, line.type, line.width, line.id);
|
|
13191
|
+
}));
|
|
13192
|
+
(_c = viewpoint.texts) === null || _c === void 0 ? void 0 : _c.forEach((text => {
|
|
13193
|
+
const screenPoint = this._worldTransformer.worldToScreen(text.position);
|
|
13194
|
+
this.addText(text.text, screenPoint, text.angle, text.color, text.text_size, text.font_size, text.id);
|
|
13195
|
+
}));
|
|
13196
|
+
(_d = viewpoint.rectangles) === null || _d === void 0 ? void 0 : _d.forEach((rect => {
|
|
13197
|
+
const screenPoint = this._worldTransformer.worldToScreen(rect.position);
|
|
13198
|
+
this.addRectangle(screenPoint, rect.width, rect.height, rect.line_width, rect.color, rect.id);
|
|
13199
|
+
}));
|
|
13200
|
+
(_e = viewpoint.ellipses) === null || _e === void 0 ? void 0 : _e.forEach((ellipse => {
|
|
13201
|
+
const screenPoint = this._worldTransformer.worldToScreen(ellipse.position);
|
|
13202
|
+
this.addEllipse(screenPoint, ellipse.radius, ellipse.line_width, ellipse.color, ellipse.id);
|
|
13203
|
+
}));
|
|
13204
|
+
(_f = viewpoint.arrows) === null || _f === void 0 ? void 0 : _f.forEach((arrow => {
|
|
13205
|
+
const startPoint = this._worldTransformer.worldToScreen(arrow.start);
|
|
13206
|
+
const endPoint = this._worldTransformer.worldToScreen(arrow.end);
|
|
13207
|
+
this.addArrow(startPoint, endPoint, arrow.color, arrow.id);
|
|
13208
|
+
}));
|
|
13209
|
+
(_g = viewpoint.clouds) === null || _g === void 0 ? void 0 : _g.forEach((cloud => {
|
|
13210
|
+
const screenPoint = this._worldTransformer.worldToScreen(cloud.position);
|
|
13211
|
+
this.addCloud(screenPoint, cloud.width, cloud.height, cloud.line_width, cloud.color, cloud.id);
|
|
13212
|
+
}));
|
|
13213
|
+
(_h = viewpoint.images) === null || _h === void 0 ? void 0 : _h.forEach((image => {
|
|
13214
|
+
const screenPoint = this._worldTransformer.worldToScreen(image.position);
|
|
13215
|
+
this.addImage(screenPoint, image.src, image.width, image.height, image.id);
|
|
13216
|
+
}));
|
|
13184
13217
|
}
|
|
13185
13218
|
getViewpoint() {
|
|
13186
|
-
const viewpoint = {
|
|
13187
|
-
|
|
13188
|
-
|
|
13189
|
-
|
|
13190
|
-
|
|
13191
|
-
|
|
13192
|
-
|
|
13193
|
-
|
|
13219
|
+
const viewpoint = {};
|
|
13220
|
+
viewpoint.lines = this.getMarkupLines();
|
|
13221
|
+
viewpoint.texts = this.getMarkupTexts();
|
|
13222
|
+
viewpoint.arrows = this.getMarkupArrows();
|
|
13223
|
+
viewpoint.clouds = this.getMarkupClouds();
|
|
13224
|
+
viewpoint.ellipses = this.getMarkupEllipses();
|
|
13225
|
+
viewpoint.images = this.getMarkupImages();
|
|
13226
|
+
viewpoint.rectangles = this.getMarkupRectangles();
|
|
13227
|
+
viewpoint.custom_fields = {
|
|
13228
|
+
markup_color: this.getMarkupColor()
|
|
13194
13229
|
};
|
|
13195
13230
|
viewpoint.snapshot = {
|
|
13196
13231
|
data: this.combineMarkupWithDrawing()
|
|
13197
13232
|
};
|
|
13198
|
-
viewpoint.custom_fields = {
|
|
13199
|
-
markup_color: this.getMarkupColor()
|
|
13200
|
-
};
|
|
13201
|
-
this.fillViewpointShapes(viewpoint);
|
|
13202
13233
|
viewpoint.description = (new Date).toDateString();
|
|
13203
13234
|
return viewpoint;
|
|
13204
13235
|
}
|
|
@@ -13244,50 +13275,6 @@
|
|
|
13244
13275
|
clearSelected() {
|
|
13245
13276
|
this._konvaTransformer.nodes([]);
|
|
13246
13277
|
}
|
|
13247
|
-
fillViewpointShapes(viewpoint) {
|
|
13248
|
-
const markupLines = this.getMarkupLines();
|
|
13249
|
-
if (markupLines && markupLines.length > 0) {
|
|
13250
|
-
markupLines === null || markupLines === void 0 ? void 0 : markupLines.forEach((line => {
|
|
13251
|
-
viewpoint.lines.push(line);
|
|
13252
|
-
}));
|
|
13253
|
-
}
|
|
13254
|
-
const markupTexts = this.getMarkupTexts();
|
|
13255
|
-
if (markupTexts && markupTexts.length > 0) {
|
|
13256
|
-
markupTexts === null || markupTexts === void 0 ? void 0 : markupTexts.forEach((text => {
|
|
13257
|
-
viewpoint.texts.push(text);
|
|
13258
|
-
}));
|
|
13259
|
-
}
|
|
13260
|
-
const markupRectangles = this.getMarkupRectangles();
|
|
13261
|
-
if (markupRectangles && markupRectangles.length > 0) {
|
|
13262
|
-
markupRectangles === null || markupRectangles === void 0 ? void 0 : markupRectangles.forEach((rectangle => {
|
|
13263
|
-
viewpoint.rectangles.push(rectangle);
|
|
13264
|
-
}));
|
|
13265
|
-
}
|
|
13266
|
-
const markupEllipses = this.getMarkupEllipses();
|
|
13267
|
-
if (markupEllipses && markupEllipses.length > 0) {
|
|
13268
|
-
markupEllipses === null || markupEllipses === void 0 ? void 0 : markupEllipses.forEach((ellipse => {
|
|
13269
|
-
viewpoint.ellipses.push(ellipse);
|
|
13270
|
-
}));
|
|
13271
|
-
}
|
|
13272
|
-
const markupArrows = this.getMarkupArrows();
|
|
13273
|
-
if (markupArrows && markupArrows.length > 0) {
|
|
13274
|
-
markupArrows === null || markupArrows === void 0 ? void 0 : markupArrows.forEach((arrow => {
|
|
13275
|
-
viewpoint.arrows.push(arrow);
|
|
13276
|
-
}));
|
|
13277
|
-
}
|
|
13278
|
-
const markupImages = this.getMarkupImages();
|
|
13279
|
-
if (markupImages && markupImages.length > 0) {
|
|
13280
|
-
markupImages === null || markupImages === void 0 ? void 0 : markupImages.forEach((image => {
|
|
13281
|
-
viewpoint.images.push(image);
|
|
13282
|
-
}));
|
|
13283
|
-
}
|
|
13284
|
-
const markupClouds = this.getMarkupClouds();
|
|
13285
|
-
if (markupClouds && markupClouds.length > 0) {
|
|
13286
|
-
markupClouds === null || markupClouds === void 0 ? void 0 : markupClouds.forEach((cloud => {
|
|
13287
|
-
viewpoint.clouds.push(cloud);
|
|
13288
|
-
}));
|
|
13289
|
-
}
|
|
13290
|
-
}
|
|
13291
13278
|
addObject(object) {
|
|
13292
13279
|
this._konvaLayer.add(object.ref());
|
|
13293
13280
|
}
|
|
@@ -13518,11 +13505,11 @@
|
|
|
13518
13505
|
}
|
|
13519
13506
|
getMarkupLines() {
|
|
13520
13507
|
const lines = [];
|
|
13521
|
-
this.konvaLayerFind("Line").forEach((
|
|
13522
|
-
const linePoints =
|
|
13508
|
+
this.konvaLayerFind("Line").forEach((ref => {
|
|
13509
|
+
const linePoints = ref.points();
|
|
13523
13510
|
if (!linePoints) return;
|
|
13524
13511
|
const worldPoints = [];
|
|
13525
|
-
const absoluteTransform =
|
|
13512
|
+
const absoluteTransform = ref.getAbsoluteTransform();
|
|
13526
13513
|
for (let i = 0; i < linePoints.length; i += 2) {
|
|
13527
13514
|
const atPoint = absoluteTransform.point({
|
|
13528
13515
|
x: linePoints[i],
|
|
@@ -13531,14 +13518,15 @@
|
|
|
13531
13518
|
const worldPoint = this._worldTransformer.screenToWorld(atPoint);
|
|
13532
13519
|
worldPoints.push(worldPoint);
|
|
13533
13520
|
}
|
|
13534
|
-
const konvaLine = new KonvaLine(null,
|
|
13535
|
-
|
|
13521
|
+
const konvaLine = new KonvaLine(null, ref);
|
|
13522
|
+
const line = {
|
|
13536
13523
|
id: konvaLine.id(),
|
|
13537
13524
|
points: worldPoints,
|
|
13538
13525
|
color: konvaLine.getColor() || "#ff0000",
|
|
13539
13526
|
type: konvaLine.getLineType() || this.lineType,
|
|
13540
13527
|
width: konvaLine.getLineWidth() || this.lineWidth
|
|
13541
|
-
}
|
|
13528
|
+
};
|
|
13529
|
+
lines.push(line);
|
|
13542
13530
|
}));
|
|
13543
13531
|
return lines;
|
|
13544
13532
|
}
|
|
@@ -13546,15 +13534,14 @@
|
|
|
13546
13534
|
const texts = [];
|
|
13547
13535
|
const textSize = .02;
|
|
13548
13536
|
const textScale = this._worldTransformer.getScale();
|
|
13549
|
-
this.konvaLayerFind("Text").forEach((
|
|
13550
|
-
if (!text) return;
|
|
13537
|
+
this.konvaLayerFind("Text").forEach((ref => {
|
|
13551
13538
|
const position = {
|
|
13552
|
-
x:
|
|
13553
|
-
y:
|
|
13539
|
+
x: ref.x(),
|
|
13540
|
+
y: ref.y()
|
|
13554
13541
|
};
|
|
13555
13542
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
13556
|
-
const shape = new KonvaText(null,
|
|
13557
|
-
|
|
13543
|
+
const shape = new KonvaText(null, ref);
|
|
13544
|
+
const text = {
|
|
13558
13545
|
id: shape.id(),
|
|
13559
13546
|
position: worldPoint,
|
|
13560
13547
|
text: shape.getText(),
|
|
@@ -13562,140 +13549,109 @@
|
|
|
13562
13549
|
angle: shape.getRotation(),
|
|
13563
13550
|
color: shape.getColor(),
|
|
13564
13551
|
font_size: shape.getFontSize()
|
|
13565
|
-
}
|
|
13552
|
+
};
|
|
13553
|
+
texts.push(text);
|
|
13566
13554
|
}));
|
|
13567
13555
|
return texts;
|
|
13568
13556
|
}
|
|
13569
13557
|
getMarkupRectangles() {
|
|
13570
13558
|
const rectangles = [];
|
|
13571
|
-
this.konvaLayerFind("Rectangle").forEach((
|
|
13572
|
-
const position =
|
|
13559
|
+
this.konvaLayerFind("Rectangle").forEach((ref => {
|
|
13560
|
+
const position = ref.position();
|
|
13573
13561
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
13574
|
-
const shape = new KonvaRectangle(null,
|
|
13575
|
-
|
|
13562
|
+
const shape = new KonvaRectangle(null, ref);
|
|
13563
|
+
const rectangle = {
|
|
13576
13564
|
id: shape.id(),
|
|
13577
13565
|
position: worldPoint,
|
|
13578
13566
|
width: shape.getWidth(),
|
|
13579
13567
|
height: shape.getHeigth(),
|
|
13580
13568
|
line_width: shape.getLineWidth(),
|
|
13581
13569
|
color: shape.getColor()
|
|
13582
|
-
}
|
|
13570
|
+
};
|
|
13571
|
+
rectangles.push(rectangle);
|
|
13583
13572
|
}));
|
|
13584
13573
|
return rectangles;
|
|
13585
13574
|
}
|
|
13586
13575
|
getMarkupEllipses() {
|
|
13587
13576
|
const ellipses = [];
|
|
13588
|
-
this.konvaLayerFind("Ellipse").forEach((
|
|
13589
|
-
const position =
|
|
13577
|
+
this.konvaLayerFind("Ellipse").forEach((ref => {
|
|
13578
|
+
const position = ref.position();
|
|
13590
13579
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
13591
|
-
const shape = new KonvaEllipse(null,
|
|
13592
|
-
|
|
13580
|
+
const shape = new KonvaEllipse(null, ref);
|
|
13581
|
+
const ellipse = {
|
|
13593
13582
|
id: shape.id(),
|
|
13594
13583
|
position: worldPoint,
|
|
13595
13584
|
radius: {
|
|
13596
|
-
x:
|
|
13597
|
-
y:
|
|
13585
|
+
x: ref.getRadiusX(),
|
|
13586
|
+
y: ref.getRadiusY()
|
|
13598
13587
|
},
|
|
13599
13588
|
line_width: shape.getLineWidth(),
|
|
13600
13589
|
color: shape.getColor()
|
|
13601
|
-
}
|
|
13590
|
+
};
|
|
13591
|
+
ellipses.push(ellipse);
|
|
13602
13592
|
}));
|
|
13603
13593
|
return ellipses;
|
|
13604
13594
|
}
|
|
13605
13595
|
getMarkupArrows() {
|
|
13606
13596
|
const arrows = [];
|
|
13607
|
-
this.konvaLayerFind("Arrow").forEach((
|
|
13608
|
-
const absoluteTransform =
|
|
13597
|
+
this.konvaLayerFind("Arrow").forEach((ref => {
|
|
13598
|
+
const absoluteTransform = ref.getAbsoluteTransform();
|
|
13609
13599
|
const atStartPoint = absoluteTransform.point({
|
|
13610
|
-
x:
|
|
13611
|
-
y:
|
|
13600
|
+
x: ref.points()[0],
|
|
13601
|
+
y: ref.points()[1]
|
|
13612
13602
|
});
|
|
13613
13603
|
const worldStartPoint = this._worldTransformer.screenToWorld(atStartPoint);
|
|
13614
13604
|
const atEndPoint = absoluteTransform.point({
|
|
13615
|
-
x:
|
|
13616
|
-
y:
|
|
13605
|
+
x: ref.points()[2],
|
|
13606
|
+
y: ref.points()[3]
|
|
13617
13607
|
});
|
|
13618
13608
|
const worldEndPoint = this._worldTransformer.screenToWorld(atEndPoint);
|
|
13619
|
-
const shape = new KonvaArrow(null,
|
|
13620
|
-
|
|
13609
|
+
const shape = new KonvaArrow(null, ref);
|
|
13610
|
+
const arrow = {
|
|
13621
13611
|
id: shape.id(),
|
|
13622
13612
|
start: worldStartPoint,
|
|
13623
13613
|
end: worldEndPoint,
|
|
13624
13614
|
color: shape.getColor()
|
|
13625
|
-
}
|
|
13615
|
+
};
|
|
13616
|
+
arrows.push(arrow);
|
|
13626
13617
|
}));
|
|
13627
13618
|
return arrows;
|
|
13628
13619
|
}
|
|
13629
13620
|
getMarkupImages() {
|
|
13630
13621
|
const images = [];
|
|
13631
|
-
this.konvaLayerFind("Image").forEach((
|
|
13632
|
-
const position =
|
|
13622
|
+
this.konvaLayerFind("Image").forEach((ref => {
|
|
13623
|
+
const position = ref.position();
|
|
13633
13624
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
13634
|
-
const shape = new KonvaImage(null,
|
|
13635
|
-
|
|
13625
|
+
const shape = new KonvaImage(null, ref);
|
|
13626
|
+
const image = {
|
|
13636
13627
|
id: shape.id(),
|
|
13637
13628
|
position: worldPoint,
|
|
13638
13629
|
src: shape.getSrc(),
|
|
13639
13630
|
width: shape.getWidth(),
|
|
13640
13631
|
height: shape.getHeight()
|
|
13641
|
-
}
|
|
13632
|
+
};
|
|
13633
|
+
images.push(image);
|
|
13642
13634
|
}));
|
|
13643
13635
|
return images;
|
|
13644
13636
|
}
|
|
13645
13637
|
getMarkupClouds() {
|
|
13646
13638
|
const clouds = [];
|
|
13647
|
-
this.konvaLayerFind("Cloud").forEach((
|
|
13648
|
-
const position =
|
|
13639
|
+
this.konvaLayerFind("Cloud").forEach((ref => {
|
|
13640
|
+
const position = ref.position();
|
|
13649
13641
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
13650
|
-
const shape = new KonvaCloud(null,
|
|
13651
|
-
|
|
13642
|
+
const shape = new KonvaCloud(null, ref);
|
|
13643
|
+
const cloud = {
|
|
13652
13644
|
id: shape.id(),
|
|
13653
13645
|
position: worldPoint,
|
|
13654
13646
|
width: shape.getWidth(),
|
|
13655
13647
|
height: shape.getHeigth(),
|
|
13656
13648
|
line_width: shape.getLineWidth(),
|
|
13657
13649
|
color: shape.getColor()
|
|
13658
|
-
}
|
|
13650
|
+
};
|
|
13651
|
+
clouds.push(cloud);
|
|
13659
13652
|
}));
|
|
13660
13653
|
return clouds;
|
|
13661
13654
|
}
|
|
13662
|
-
loadMarkup(viewpoint) {
|
|
13663
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
13664
|
-
(_a = viewpoint.lines) === null || _a === void 0 ? void 0 : _a.forEach((vpLine => {
|
|
13665
|
-
const linePoints = [];
|
|
13666
|
-
vpLine.points.forEach((point => {
|
|
13667
|
-
const screenPoint = this._worldTransformer.worldToScreen(point);
|
|
13668
|
-
linePoints.push(screenPoint.x);
|
|
13669
|
-
linePoints.push(screenPoint.y);
|
|
13670
|
-
}));
|
|
13671
|
-
this.addLine(linePoints, vpLine.color, vpLine.type, vpLine.width, vpLine.id);
|
|
13672
|
-
}));
|
|
13673
|
-
(_b = viewpoint.texts) === null || _b === void 0 ? void 0 : _b.forEach((vpText => {
|
|
13674
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpText.position);
|
|
13675
|
-
this.addText(vpText.text, screenPoint, vpText.angle, vpText.color, vpText.text_size, vpText.font_size, vpText.id);
|
|
13676
|
-
}));
|
|
13677
|
-
(_c = viewpoint.rectangles) === null || _c === void 0 ? void 0 : _c.forEach((vpRect => {
|
|
13678
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpRect.position);
|
|
13679
|
-
this.addRectangle(screenPoint, vpRect.width, vpRect.height, vpRect.line_width, vpRect.color, vpRect.id);
|
|
13680
|
-
}));
|
|
13681
|
-
(_d = viewpoint.ellipses) === null || _d === void 0 ? void 0 : _d.forEach((vpEllipse => {
|
|
13682
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpEllipse.position);
|
|
13683
|
-
this.addEllipse(screenPoint, vpEllipse.radius, vpEllipse.line_width, vpEllipse.color, vpEllipse.id);
|
|
13684
|
-
}));
|
|
13685
|
-
(_e = viewpoint.arrows) === null || _e === void 0 ? void 0 : _e.forEach((vpArrow => {
|
|
13686
|
-
const startPoint = this._worldTransformer.worldToScreen(vpArrow.start);
|
|
13687
|
-
const endPoint = this._worldTransformer.worldToScreen(vpArrow.end);
|
|
13688
|
-
this.addArrow(startPoint, endPoint, vpArrow.color, vpArrow.id);
|
|
13689
|
-
}));
|
|
13690
|
-
(_f = viewpoint.clouds) === null || _f === void 0 ? void 0 : _f.forEach((vpCloud => {
|
|
13691
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpCloud.position);
|
|
13692
|
-
this.addCloud(screenPoint, vpCloud.width, vpCloud.height, vpCloud.line_width, vpCloud.color, vpCloud.id);
|
|
13693
|
-
}));
|
|
13694
|
-
(_g = viewpoint.images) === null || _g === void 0 ? void 0 : _g.forEach((vpImage => {
|
|
13695
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpImage.position);
|
|
13696
|
-
this.addImage(screenPoint, vpImage.src, vpImage.width, vpImage.height, vpImage.id);
|
|
13697
|
-
}));
|
|
13698
|
-
}
|
|
13699
13655
|
combineMarkupWithDrawing() {
|
|
13700
13656
|
this.clearSelected();
|
|
13701
13657
|
const tempCanvas = document.createElement("canvas");
|
|
@@ -13724,8 +13680,7 @@
|
|
|
13724
13680
|
color: color || this._markupColor.HexColor,
|
|
13725
13681
|
id: id
|
|
13726
13682
|
});
|
|
13727
|
-
|
|
13728
|
-
this._konvaLayer.add(obj);
|
|
13683
|
+
this._konvaLayer.add(konvaLine.ref());
|
|
13729
13684
|
return konvaLine;
|
|
13730
13685
|
}
|
|
13731
13686
|
createTextInput(pos, inputX, inputY, angle, text) {
|
|
@@ -13807,33 +13762,32 @@
|
|
|
13807
13762
|
this._imageInputPos = null;
|
|
13808
13763
|
}
|
|
13809
13764
|
addText(specifiedText, position, angle, color, textSize, fontSize, id) {
|
|
13765
|
+
if (!specifiedText) return;
|
|
13810
13766
|
const trNodes = this._konvaTransformer.nodes();
|
|
13811
13767
|
if (trNodes.length > 0) {
|
|
13812
13768
|
trNodes[0].destroy();
|
|
13813
13769
|
this._konvaTransformer.nodes([]);
|
|
13814
13770
|
}
|
|
13815
13771
|
this.removeTextInput();
|
|
13816
|
-
|
|
13817
|
-
|
|
13818
|
-
|
|
13819
|
-
|
|
13820
|
-
|
|
13821
|
-
|
|
13822
|
-
|
|
13823
|
-
|
|
13824
|
-
|
|
13825
|
-
|
|
13826
|
-
|
|
13827
|
-
|
|
13828
|
-
|
|
13829
|
-
|
|
13830
|
-
|
|
13831
|
-
|
|
13832
|
-
|
|
13833
|
-
|
|
13834
|
-
|
|
13835
|
-
return konvaText;
|
|
13836
|
-
}
|
|
13772
|
+
const tolerance = 1e-6;
|
|
13773
|
+
if (textSize && textSize > tolerance && (!fontSize || fontSize < tolerance)) {
|
|
13774
|
+
const size = .02;
|
|
13775
|
+
const scale = this._worldTransformer.getScale();
|
|
13776
|
+
fontSize = textSize / (scale.y / size) / 34;
|
|
13777
|
+
}
|
|
13778
|
+
const konvaText = new KonvaText({
|
|
13779
|
+
position: {
|
|
13780
|
+
x: position.x,
|
|
13781
|
+
y: position.y
|
|
13782
|
+
},
|
|
13783
|
+
text: specifiedText,
|
|
13784
|
+
rotation: angle,
|
|
13785
|
+
fontSize: fontSize || this.fontSize,
|
|
13786
|
+
color: color || this._markupColor.HexColor,
|
|
13787
|
+
id: id
|
|
13788
|
+
});
|
|
13789
|
+
this._konvaLayer.add(konvaText.ref());
|
|
13790
|
+
return konvaText;
|
|
13837
13791
|
}
|
|
13838
13792
|
addRectangle(position, width, height, lineWidth, color, id) {
|
|
13839
13793
|
if (!position) return;
|
|
@@ -13845,8 +13799,7 @@
|
|
|
13845
13799
|
color: color || this._markupColor.HexColor,
|
|
13846
13800
|
id: id
|
|
13847
13801
|
});
|
|
13848
|
-
|
|
13849
|
-
this._konvaLayer.add(obj);
|
|
13802
|
+
this._konvaLayer.add(konvaRectangle.ref());
|
|
13850
13803
|
return konvaRectangle;
|
|
13851
13804
|
}
|
|
13852
13805
|
addEllipse(position, radius, lineWidth, color, id) {
|
|
@@ -13858,8 +13811,7 @@
|
|
|
13858
13811
|
color: color || this._markupColor.HexColor,
|
|
13859
13812
|
id: id
|
|
13860
13813
|
});
|
|
13861
|
-
|
|
13862
|
-
this._konvaLayer.add(obj);
|
|
13814
|
+
this._konvaLayer.add(konvaEllipse.ref());
|
|
13863
13815
|
return konvaEllipse;
|
|
13864
13816
|
}
|
|
13865
13817
|
addArrow(start, end, color, id) {
|
|
@@ -13870,8 +13822,7 @@
|
|
|
13870
13822
|
color: color || this._markupColor.HexColor,
|
|
13871
13823
|
id: id
|
|
13872
13824
|
});
|
|
13873
|
-
|
|
13874
|
-
this._konvaLayer.add(obj);
|
|
13825
|
+
this._konvaLayer.add(konvaArrow.ref());
|
|
13875
13826
|
return konvaArrow;
|
|
13876
13827
|
}
|
|
13877
13828
|
addCloud(position, width, height, lineWidth, color, id) {
|
|
@@ -13884,30 +13835,25 @@
|
|
|
13884
13835
|
lineWidth: lineWidth || this.lineWidth,
|
|
13885
13836
|
id: id
|
|
13886
13837
|
});
|
|
13887
|
-
|
|
13888
|
-
this._konvaLayer.add(obj);
|
|
13838
|
+
this._konvaLayer.add(konvaCloud.ref());
|
|
13889
13839
|
return konvaCloud;
|
|
13890
13840
|
}
|
|
13891
13841
|
addImage(position, src, width, height, id) {
|
|
13892
|
-
if (!position) return;
|
|
13893
|
-
|
|
13894
|
-
if (
|
|
13895
|
-
|
|
13896
|
-
|
|
13897
|
-
src: src,
|
|
13898
|
-
width: width,
|
|
13899
|
-
height: height,
|
|
13900
|
-
id: id
|
|
13901
|
-
});
|
|
13902
|
-
const obj = konvaImage.ref();
|
|
13903
|
-
this._konvaLayer.add(obj);
|
|
13904
|
-
const trNodes = this._konvaTransformer.nodes();
|
|
13905
|
-
if (trNodes.length > 0) {
|
|
13906
|
-
trNodes[0].destroy();
|
|
13907
|
-
this._konvaTransformer.nodes([]);
|
|
13908
|
-
}
|
|
13842
|
+
if (!position || !src) return;
|
|
13843
|
+
const trNodes = this._konvaTransformer.nodes();
|
|
13844
|
+
if (trNodes.length > 0) {
|
|
13845
|
+
trNodes[0].destroy();
|
|
13846
|
+
this._konvaTransformer.nodes([]);
|
|
13909
13847
|
}
|
|
13910
13848
|
this.removeImageInput();
|
|
13849
|
+
const konvaImage = new KonvaImage({
|
|
13850
|
+
position: position,
|
|
13851
|
+
src: src,
|
|
13852
|
+
width: width,
|
|
13853
|
+
height: height,
|
|
13854
|
+
id: id
|
|
13855
|
+
});
|
|
13856
|
+
this._konvaLayer.add(konvaImage.ref());
|
|
13911
13857
|
return konvaImage;
|
|
13912
13858
|
}
|
|
13913
13859
|
}
|