@inweb/viewer-visualize 25.4.11 → 25.5.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 +68 -32
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +73 -32
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Markup/IMarkup.d.ts +10 -1
- package/lib/Viewer/Markup/Impl/Konva/KonvaMarkup.d.ts +3 -1
- package/lib/Viewer/Markup/Impl/Visualize/VisualizeMarkup.d.ts +2 -0
- package/package.json +5 -5
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.ts +8 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +10 -2
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +11 -2
- package/src/Viewer/Markup/IMarkup.ts +12 -1
- package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +44 -29
- package/src/Viewer/Markup/Impl/Visualize/VisualizeMarkup.ts +3 -1
|
@@ -2999,6 +2999,7 @@ var MarkupType;
|
|
|
2999
2999
|
var MarkupMode;
|
|
3000
3000
|
|
|
3001
3001
|
(function(MarkupMode) {
|
|
3002
|
+
MarkupMode["SelectMarkup"] = "SelectMarkup";
|
|
3002
3003
|
MarkupMode["Line"] = "Line";
|
|
3003
3004
|
MarkupMode["Text"] = "Text";
|
|
3004
3005
|
MarkupMode["Rectangle"] = "Rectangle";
|
|
@@ -3160,16 +3161,25 @@ class KonvaText {
|
|
|
3160
3161
|
draggable: true,
|
|
3161
3162
|
rotation: (_c = params.rotation) !== null && _c !== void 0 ? _c : 0
|
|
3162
3163
|
});
|
|
3164
|
+
this._ref.width(this._ref.getTextWidth());
|
|
3163
3165
|
this._ref.on("transform", (e => {
|
|
3164
3166
|
const attrs = e.target.attrs;
|
|
3165
3167
|
if (attrs.rotation !== this.getRotation()) this.setRotation(attrs.rotation);
|
|
3166
3168
|
const newWidth = this._ref.width() * attrs.scaleX;
|
|
3167
3169
|
const newHeight = this._ref.height() * attrs.scaleY;
|
|
3170
|
+
const minWidth = 50;
|
|
3171
|
+
if (newWidth < minWidth || newHeight < Math.round(this.getFontSize())) {
|
|
3172
|
+
this._ref.scale({
|
|
3173
|
+
x: 1,
|
|
3174
|
+
y: 1
|
|
3175
|
+
});
|
|
3176
|
+
return;
|
|
3177
|
+
}
|
|
3168
3178
|
if (Math.abs(attrs.scaleX - 1) > 1e-5) {
|
|
3169
|
-
this.
|
|
3179
|
+
this._ref.width(newWidth);
|
|
3170
3180
|
}
|
|
3171
3181
|
if (Math.abs(attrs.scaleY - 1) > 1e-5) {
|
|
3172
|
-
this.
|
|
3182
|
+
this._ref.height(newHeight);
|
|
3173
3183
|
}
|
|
3174
3184
|
this._ref.scale({
|
|
3175
3185
|
x: 1,
|
|
@@ -3259,8 +3269,17 @@ class KonvaRectangle {
|
|
|
3259
3269
|
this._ref.on("transform", (e => {
|
|
3260
3270
|
const attrs = e.target.attrs;
|
|
3261
3271
|
if (attrs.rotation !== this.getRotation()) this.setRotation(attrs.rotation);
|
|
3262
|
-
|
|
3263
|
-
|
|
3272
|
+
let newWidth = this._ref.width() * attrs.scaleX;
|
|
3273
|
+
let newHeight = this._ref.height() * attrs.scaleY;
|
|
3274
|
+
const minWidth = 50;
|
|
3275
|
+
const minHeight = 50;
|
|
3276
|
+
if (newWidth < minWidth || newHeight < minHeight) {
|
|
3277
|
+
this._ref.scale({
|
|
3278
|
+
x: 1,
|
|
3279
|
+
y: 1
|
|
3280
|
+
});
|
|
3281
|
+
return;
|
|
3282
|
+
}
|
|
3264
3283
|
if (Math.abs(attrs.scaleX - 1) > 1e-5) {
|
|
3265
3284
|
this.setWidth(newWidth);
|
|
3266
3285
|
}
|
|
@@ -3363,6 +3382,15 @@ class KonvaEllipse {
|
|
|
3363
3382
|
if (attrs.rotation !== this.getRotation()) this.setRotation(attrs.rotation);
|
|
3364
3383
|
const newRadiusX = this._ref.radiusX() * attrs.scaleX;
|
|
3365
3384
|
const newRadiusY = this._ref.radiusY() * attrs.scaleY;
|
|
3385
|
+
const minRadiusX = 25;
|
|
3386
|
+
const minRadiusY = 25;
|
|
3387
|
+
if (newRadiusX < minRadiusX || newRadiusY < minRadiusY) {
|
|
3388
|
+
this._ref.scale({
|
|
3389
|
+
x: 1,
|
|
3390
|
+
y: 1
|
|
3391
|
+
});
|
|
3392
|
+
return;
|
|
3393
|
+
}
|
|
3366
3394
|
if (Math.abs(attrs.scaleX - 1) > 1e-5) {
|
|
3367
3395
|
this.setRadiusX(newRadiusX);
|
|
3368
3396
|
}
|
|
@@ -3818,7 +3846,10 @@ class KonvaCloud {
|
|
|
3818
3846
|
}
|
|
3819
3847
|
}
|
|
3820
3848
|
|
|
3821
|
-
const MarkupMode2Konva = new Map([ [ MarkupMode.
|
|
3849
|
+
const MarkupMode2Konva = new Map([ [ MarkupMode.SelectMarkup, {
|
|
3850
|
+
name: "SelectMarkup",
|
|
3851
|
+
initializer: () => {}
|
|
3852
|
+
} ], [ MarkupMode.Line, {
|
|
3822
3853
|
name: "Line",
|
|
3823
3854
|
initializer: ref => new KonvaLine(null, ref)
|
|
3824
3855
|
} ], [ MarkupMode.Text, {
|
|
@@ -3847,6 +3878,8 @@ class KonvaMarkup {
|
|
|
3847
3878
|
this._zIndex = 1;
|
|
3848
3879
|
this._markupContainerName = "markupContainer";
|
|
3849
3880
|
this.lineWidth = 4;
|
|
3881
|
+
this.lineType = "solid";
|
|
3882
|
+
this.fontSize = 34;
|
|
3850
3883
|
this.changeActiveDragger = event => {
|
|
3851
3884
|
const draggerName = event.data;
|
|
3852
3885
|
this._markupContainer.className = this._canvasOriginal.className.split(" ").filter((x => !x.startsWith("oda-cursor-"))).filter((x => x)).concat(`oda-cursor-${draggerName.toLowerCase()}`).join(" ");
|
|
@@ -3934,8 +3967,9 @@ class KonvaMarkup {
|
|
|
3934
3967
|
const hex = new MarkupColor(r, g, b).HexColor;
|
|
3935
3968
|
Object.values(MarkupMode).forEach((mode => {
|
|
3936
3969
|
this.konvaLayerFind(mode).forEach((x => {
|
|
3937
|
-
|
|
3938
|
-
|
|
3970
|
+
var _a;
|
|
3971
|
+
const konvaObj = (_a = MarkupMode2Konva.get(mode)) === null || _a === void 0 ? void 0 : _a.initializer(x);
|
|
3972
|
+
if (konvaObj && konvaObj.setColor) konvaObj.setColor(hex);
|
|
3939
3973
|
}));
|
|
3940
3974
|
}));
|
|
3941
3975
|
this._konvaLayer.draw();
|
|
@@ -4151,6 +4185,7 @@ class KonvaMarkup {
|
|
|
4151
4185
|
const konvaShapes = this._konvaLayer.find(konvaShape.name).filter((x => x.parent instanceof Konva.Layer));
|
|
4152
4186
|
return konvaShapes;
|
|
4153
4187
|
}
|
|
4188
|
+
return [];
|
|
4154
4189
|
}
|
|
4155
4190
|
initializeKonva() {
|
|
4156
4191
|
this._konvaStage = new Konva.Stage({
|
|
@@ -4165,7 +4200,8 @@ class KonvaMarkup {
|
|
|
4165
4200
|
stage.add(layer);
|
|
4166
4201
|
this._konvaLayer = layer;
|
|
4167
4202
|
const transformer = new Konva.Transformer({
|
|
4168
|
-
shouldOverdrawWholeArea: false
|
|
4203
|
+
shouldOverdrawWholeArea: false,
|
|
4204
|
+
keepRatio: false
|
|
4169
4205
|
});
|
|
4170
4206
|
this._konvaTransformer = transformer;
|
|
4171
4207
|
layer.add(transformer);
|
|
@@ -4304,23 +4340,27 @@ class KonvaMarkup {
|
|
|
4304
4340
|
transformer.nodes([]);
|
|
4305
4341
|
return;
|
|
4306
4342
|
}
|
|
4307
|
-
if (
|
|
4308
|
-
if (
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4343
|
+
if (this._markupMode === MarkupMode.Text || this._markupMode === MarkupMode.SelectMarkup) {
|
|
4344
|
+
if (e.target.className === "Text" && transformer.nodes().length === 1 && transformer.nodes()[0] === e.target) {
|
|
4345
|
+
if (this._textInputRef && this._textInputRef.value) this.addText(this._textInputRef.value, this._textInputPos, this._textInputAngle); else this.createTextInput({
|
|
4346
|
+
x: e.target.attrs.x,
|
|
4347
|
+
y: e.target.attrs.y
|
|
4348
|
+
}, e.evt.pageX, e.evt.pageY, e.target.attrs.rotation, e.target.attrs.text);
|
|
4349
|
+
return;
|
|
4350
|
+
} else {
|
|
4351
|
+
this.removeTextInput();
|
|
4352
|
+
}
|
|
4315
4353
|
}
|
|
4316
|
-
if (
|
|
4317
|
-
if (
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4354
|
+
if (this._markupMode === MarkupMode.Image || this._markupMode === MarkupMode.SelectMarkup) {
|
|
4355
|
+
if (e.target.className === "Image" && transformer.nodes().length === 1 && transformer.nodes()[0] === e.target) {
|
|
4356
|
+
if (this._imageInputRef && this._imageInputRef.value) this.addImage(this._imageInputPos, this._imageInputRef.value, 0, 0); else this.createImageInput({
|
|
4357
|
+
x: e.target.attrs.x,
|
|
4358
|
+
y: e.target.attrs.y
|
|
4359
|
+
});
|
|
4360
|
+
return;
|
|
4361
|
+
} else {
|
|
4362
|
+
this.removeImageInput();
|
|
4363
|
+
}
|
|
4324
4364
|
}
|
|
4325
4365
|
if (transformer.nodes().filter((x => x.className === "Cloud")).length > 0 || e.target.className === "Cloud") {
|
|
4326
4366
|
transformer.rotateEnabled(false);
|
|
@@ -4383,9 +4423,9 @@ class KonvaMarkup {
|
|
|
4383
4423
|
lines.push({
|
|
4384
4424
|
id: konvaLine.id(),
|
|
4385
4425
|
points: worldPoints.map((p => this.getPoint3dFromArray(p))),
|
|
4386
|
-
color: konvaLine.getColor() || "ff0000",
|
|
4387
|
-
type: konvaLine.getLineType() ||
|
|
4388
|
-
width: konvaLine.getLineWidth() ||
|
|
4426
|
+
color: konvaLine.getColor() || "#ff0000",
|
|
4427
|
+
type: konvaLine.getLineType() || this.lineType,
|
|
4428
|
+
width: konvaLine.getLineWidth() || this.lineWidth
|
|
4389
4429
|
});
|
|
4390
4430
|
}));
|
|
4391
4431
|
return lines;
|
|
@@ -4593,7 +4633,7 @@ class KonvaMarkup {
|
|
|
4593
4633
|
}
|
|
4594
4634
|
const konvaLine = new KonvaLine({
|
|
4595
4635
|
points: points,
|
|
4596
|
-
type: type ||
|
|
4636
|
+
type: type || this.lineType,
|
|
4597
4637
|
width: width || this.lineWidth,
|
|
4598
4638
|
color: color || this._markupColor.HexColor,
|
|
4599
4639
|
id: id
|
|
@@ -4613,7 +4653,7 @@ class KonvaMarkup {
|
|
|
4613
4653
|
this._textInputRef.style.top = inputY + "px";
|
|
4614
4654
|
this._textInputRef.style.left = inputX + "px";
|
|
4615
4655
|
this._textInputRef.onkeydown = event => {
|
|
4616
|
-
if (event.key === "Enter") {
|
|
4656
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
4617
4657
|
event.preventDefault();
|
|
4618
4658
|
this.addText(this._textInputRef.value, this._textInputPos, this._textInputAngle);
|
|
4619
4659
|
}
|
|
@@ -4700,7 +4740,7 @@ class KonvaMarkup {
|
|
|
4700
4740
|
},
|
|
4701
4741
|
text: specifiedText,
|
|
4702
4742
|
rotation: angle,
|
|
4703
|
-
fontSize: fontSize,
|
|
4743
|
+
fontSize: fontSize || this.fontSize,
|
|
4704
4744
|
color: color || this._markupColor.HexColor,
|
|
4705
4745
|
id: id
|
|
4706
4746
|
});
|
|
@@ -4920,7 +4960,8 @@ class VisualizeMarkup {
|
|
|
4920
4960
|
g: 0,
|
|
4921
4961
|
b: 0
|
|
4922
4962
|
};
|
|
4923
|
-
this.lineWidth =
|
|
4963
|
+
this.lineWidth = 4;
|
|
4964
|
+
this.fontSize = 34;
|
|
4924
4965
|
}
|
|
4925
4966
|
initialize(viewer, canvas, canvasEvents) {
|
|
4926
4967
|
this._viewer = viewer;
|
|
@@ -5170,7 +5211,7 @@ class Viewer extends EventEmitter2 {
|
|
|
5170
5211
|
return this._visualizeJsUrl;
|
|
5171
5212
|
}
|
|
5172
5213
|
configure(params) {
|
|
5173
|
-
this._visualizeJsUrl = params.visualizeJsUrl || "https://opencloud.azureedge.net/libs/visualizejs/25.
|
|
5214
|
+
this._visualizeJsUrl = params.visualizeJsUrl || "https://opencloud.azureedge.net/libs/visualizejs/25.5/Visualize.js";
|
|
5174
5215
|
return this;
|
|
5175
5216
|
}
|
|
5176
5217
|
async initialize(canvas, onProgress) {
|