@inweb/viewer-visualize 25.5.4 → 25.6.1
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 +135 -56
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +115 -56
- 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 +4 -4
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaArrow.ts +1 -1
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaCloud.ts +14 -11
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.ts +24 -11
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaImage.ts +25 -11
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaLine.ts +1 -1
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +18 -7
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +15 -5
- package/src/Viewer/Markup/IMarkup.ts +12 -1
- package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +21 -9
- 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";
|
|
@@ -3062,7 +3063,7 @@ class KonvaLine {
|
|
|
3062
3063
|
});
|
|
3063
3064
|
this._ref.on("transform", (e => {
|
|
3064
3065
|
const attrs = e.target.attrs;
|
|
3065
|
-
if (attrs.rotation !== this.
|
|
3066
|
+
if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
|
|
3066
3067
|
}));
|
|
3067
3068
|
this._ref.id(this._ref._id.toString());
|
|
3068
3069
|
}
|
|
@@ -3163,13 +3164,20 @@ class KonvaText {
|
|
|
3163
3164
|
this._ref.width(this._ref.getTextWidth());
|
|
3164
3165
|
this._ref.on("transform", (e => {
|
|
3165
3166
|
const attrs = e.target.attrs;
|
|
3166
|
-
if (attrs.rotation !== this.
|
|
3167
|
-
const
|
|
3168
|
-
const
|
|
3169
|
-
|
|
3167
|
+
if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
|
|
3168
|
+
const scaleByX = Math.abs(attrs.scaleX - 1) > 1e-5;
|
|
3169
|
+
const scaleByY = Math.abs(attrs.scaleY - 1) > 1e-5;
|
|
3170
|
+
let newWidth = this._ref.width();
|
|
3171
|
+
if (scaleByX) newWidth *= attrs.scaleX;
|
|
3172
|
+
let newHeight = this._ref.height();
|
|
3173
|
+
if (scaleByY) newHeight *= attrs.scaleY;
|
|
3174
|
+
const minWidth = 50;
|
|
3175
|
+
if (newWidth < minWidth) newWidth = minWidth;
|
|
3176
|
+
if (newHeight < Math.round(this.getFontSize())) newHeight = Math.round(this.getFontSize());
|
|
3177
|
+
if (scaleByX) {
|
|
3170
3178
|
this._ref.width(newWidth);
|
|
3171
3179
|
}
|
|
3172
|
-
if (
|
|
3180
|
+
if (scaleByY) {
|
|
3173
3181
|
this._ref.height(newHeight);
|
|
3174
3182
|
}
|
|
3175
3183
|
this._ref.scale({
|
|
@@ -3259,14 +3267,22 @@ class KonvaRectangle {
|
|
|
3259
3267
|
});
|
|
3260
3268
|
this._ref.on("transform", (e => {
|
|
3261
3269
|
const attrs = e.target.attrs;
|
|
3262
|
-
if (attrs.rotation !== this.
|
|
3263
|
-
const
|
|
3264
|
-
const
|
|
3265
|
-
|
|
3266
|
-
|
|
3270
|
+
if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
|
|
3271
|
+
const scaleByX = Math.abs(attrs.scaleX - 1) > 1e-5;
|
|
3272
|
+
const scaleByY = Math.abs(attrs.scaleY - 1) > 1e-5;
|
|
3273
|
+
let newWidth = this._ref.width();
|
|
3274
|
+
if (scaleByX) newWidth *= attrs.scaleX;
|
|
3275
|
+
let newHeight = this._ref.height();
|
|
3276
|
+
if (scaleByY) newHeight *= attrs.scaleY;
|
|
3277
|
+
const minWidth = 50;
|
|
3278
|
+
const minHeight = 50;
|
|
3279
|
+
if (newWidth < minWidth) newWidth = minWidth;
|
|
3280
|
+
if (newHeight < minHeight) newHeight = minHeight;
|
|
3281
|
+
if (scaleByX) {
|
|
3282
|
+
this._ref.width(newWidth);
|
|
3267
3283
|
}
|
|
3268
|
-
if (
|
|
3269
|
-
this.
|
|
3284
|
+
if (scaleByY) {
|
|
3285
|
+
this._ref.height(newHeight);
|
|
3270
3286
|
}
|
|
3271
3287
|
this._ref.scale({
|
|
3272
3288
|
x: 1,
|
|
@@ -3361,14 +3377,34 @@ class KonvaEllipse {
|
|
|
3361
3377
|
});
|
|
3362
3378
|
this._ref.on("transform", (e => {
|
|
3363
3379
|
const attrs = e.target.attrs;
|
|
3364
|
-
if (attrs.rotation !== this.
|
|
3365
|
-
const
|
|
3366
|
-
const
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
if (
|
|
3371
|
-
|
|
3380
|
+
if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
|
|
3381
|
+
const scaleByX = Math.abs(attrs.scaleX - 1) > 1e-5;
|
|
3382
|
+
const scaleByY = Math.abs(attrs.scaleY - 1) > 1e-5;
|
|
3383
|
+
let newRadiusX = this._ref.radiusX();
|
|
3384
|
+
if (scaleByX) newRadiusX *= attrs.scaleX;
|
|
3385
|
+
let newRadiusY = this._ref.radiusY();
|
|
3386
|
+
if (scaleByY) newRadiusY *= attrs.scaleY;
|
|
3387
|
+
const minRadiusX = 25;
|
|
3388
|
+
const minRadiusY = 25;
|
|
3389
|
+
if (newRadiusX < minRadiusX) newRadiusX = minRadiusX;
|
|
3390
|
+
if (newRadiusY < minRadiusY) newRadiusY = minRadiusY;
|
|
3391
|
+
if (e.evt.ctrlKey || e.evt.shiftKey) {
|
|
3392
|
+
if (scaleByX) {
|
|
3393
|
+
this._ref.radius({
|
|
3394
|
+
x: newRadiusX,
|
|
3395
|
+
y: newRadiusX
|
|
3396
|
+
});
|
|
3397
|
+
} else {
|
|
3398
|
+
this._ref.radius({
|
|
3399
|
+
x: newRadiusY,
|
|
3400
|
+
y: newRadiusY
|
|
3401
|
+
});
|
|
3402
|
+
}
|
|
3403
|
+
} else {
|
|
3404
|
+
this._ref.radius({
|
|
3405
|
+
x: newRadiusX,
|
|
3406
|
+
y: newRadiusY
|
|
3407
|
+
});
|
|
3372
3408
|
}
|
|
3373
3409
|
this._ref.scale({
|
|
3374
3410
|
x: 1,
|
|
@@ -3461,7 +3497,7 @@ class KonvaArrow {
|
|
|
3461
3497
|
});
|
|
3462
3498
|
this._ref.on("transform", (e => {
|
|
3463
3499
|
const attrs = e.target.attrs;
|
|
3464
|
-
if (attrs.rotation !== this.
|
|
3500
|
+
if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
|
|
3465
3501
|
}));
|
|
3466
3502
|
this._ref.id(this._ref._id.toString());
|
|
3467
3503
|
}
|
|
@@ -3568,14 +3604,28 @@ class KonvaImage {
|
|
|
3568
3604
|
this._canvasImage.src = params.src;
|
|
3569
3605
|
this._ref.on("transform", (e => {
|
|
3570
3606
|
const attrs = e.target.attrs;
|
|
3571
|
-
if (attrs.rotation !== this.
|
|
3572
|
-
const
|
|
3573
|
-
const
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
if (
|
|
3578
|
-
|
|
3607
|
+
if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
|
|
3608
|
+
const scaleByX = Math.abs(attrs.scaleX - 1) > 1e-5;
|
|
3609
|
+
const scaleByY = Math.abs(attrs.scaleY - 1) > 1e-5;
|
|
3610
|
+
let newWidth = this._ref.width();
|
|
3611
|
+
if (scaleByX) newWidth *= attrs.scaleX;
|
|
3612
|
+
let newHeight = this._ref.height();
|
|
3613
|
+
if (scaleByY) newHeight *= attrs.scaleY;
|
|
3614
|
+
if (e.evt.ctrlKey || e.evt.shiftKey) {
|
|
3615
|
+
if (scaleByX) {
|
|
3616
|
+
this._ref.width(newWidth);
|
|
3617
|
+
this._ref.height(newWidth * this._ratio);
|
|
3618
|
+
} else {
|
|
3619
|
+
this._ref.width(newHeight / this._ratio);
|
|
3620
|
+
this._ref.height(newHeight);
|
|
3621
|
+
}
|
|
3622
|
+
} else {
|
|
3623
|
+
if (scaleByX) {
|
|
3624
|
+
this._ref.width(newWidth);
|
|
3625
|
+
}
|
|
3626
|
+
if (scaleByY) {
|
|
3627
|
+
this._ref.height(newHeight);
|
|
3628
|
+
}
|
|
3579
3629
|
}
|
|
3580
3630
|
this._ref.scale({
|
|
3581
3631
|
x: 1,
|
|
@@ -3725,23 +3775,22 @@ class KonvaCloud {
|
|
|
3725
3775
|
this._ref.className = "Cloud";
|
|
3726
3776
|
this._ref.on("transform", (e => {
|
|
3727
3777
|
const attrs = e.target.attrs;
|
|
3728
|
-
if (attrs.rotation !== this.
|
|
3729
|
-
const
|
|
3730
|
-
const
|
|
3778
|
+
if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
|
|
3779
|
+
const scaleByX = Math.abs(attrs.scaleX - 1) > 1e-5;
|
|
3780
|
+
const scaleByY = Math.abs(attrs.scaleY - 1) > 1e-5;
|
|
3781
|
+
let newWidth = this._ref.width();
|
|
3782
|
+
if (scaleByX) newWidth *= attrs.scaleX;
|
|
3783
|
+
let newHeight = this._ref.height();
|
|
3784
|
+
if (scaleByY) newHeight *= attrs.scaleY;
|
|
3731
3785
|
const minWidth = 100;
|
|
3732
3786
|
const minHeight = 100;
|
|
3733
|
-
if (newWidth < minWidth
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
});
|
|
3738
|
-
return;
|
|
3739
|
-
}
|
|
3740
|
-
if (Math.abs(attrs.scaleX - 1) > 1e-5) {
|
|
3741
|
-
this.setWidth(newWidth);
|
|
3787
|
+
if (newWidth < minWidth) newWidth = minWidth;
|
|
3788
|
+
if (newHeight < minHeight) newHeight = minHeight;
|
|
3789
|
+
if (scaleByX) {
|
|
3790
|
+
this._ref.width(newWidth);
|
|
3742
3791
|
}
|
|
3743
|
-
if (
|
|
3744
|
-
this.
|
|
3792
|
+
if (scaleByY) {
|
|
3793
|
+
this._ref.height(newHeight);
|
|
3745
3794
|
}
|
|
3746
3795
|
this._ref.scale({
|
|
3747
3796
|
x: 1,
|
|
@@ -3819,7 +3868,10 @@ class KonvaCloud {
|
|
|
3819
3868
|
}
|
|
3820
3869
|
}
|
|
3821
3870
|
|
|
3822
|
-
const MarkupMode2Konva = new Map([ [ MarkupMode.
|
|
3871
|
+
const MarkupMode2Konva = new Map([ [ MarkupMode.SelectMarkup, {
|
|
3872
|
+
name: "SelectMarkup",
|
|
3873
|
+
initializer: () => {}
|
|
3874
|
+
} ], [ MarkupMode.Line, {
|
|
3823
3875
|
name: "Line",
|
|
3824
3876
|
initializer: ref => new KonvaLine(null, ref)
|
|
3825
3877
|
} ], [ MarkupMode.Text, {
|
|
@@ -3848,6 +3900,8 @@ class KonvaMarkup {
|
|
|
3848
3900
|
this._zIndex = 1;
|
|
3849
3901
|
this._markupContainerName = "markupContainer";
|
|
3850
3902
|
this.lineWidth = 4;
|
|
3903
|
+
this.lineType = "solid";
|
|
3904
|
+
this.fontSize = 34;
|
|
3851
3905
|
this.changeActiveDragger = event => {
|
|
3852
3906
|
const draggerName = event.data;
|
|
3853
3907
|
this._markupContainer.className = this._canvasOriginal.className.split(" ").filter((x => !x.startsWith("oda-cursor-"))).filter((x => x)).concat(`oda-cursor-${draggerName.toLowerCase()}`).join(" ");
|
|
@@ -3935,8 +3989,9 @@ class KonvaMarkup {
|
|
|
3935
3989
|
const hex = new MarkupColor(r, g, b).HexColor;
|
|
3936
3990
|
Object.values(MarkupMode).forEach((mode => {
|
|
3937
3991
|
this.konvaLayerFind(mode).forEach((x => {
|
|
3938
|
-
|
|
3939
|
-
|
|
3992
|
+
var _a;
|
|
3993
|
+
const konvaObj = (_a = MarkupMode2Konva.get(mode)) === null || _a === void 0 ? void 0 : _a.initializer(x);
|
|
3994
|
+
if (konvaObj && konvaObj.setColor) konvaObj.setColor(hex);
|
|
3940
3995
|
}));
|
|
3941
3996
|
}));
|
|
3942
3997
|
this._konvaLayer.draw();
|
|
@@ -4152,6 +4207,7 @@ class KonvaMarkup {
|
|
|
4152
4207
|
const konvaShapes = this._konvaLayer.find(konvaShape.name).filter((x => x.parent instanceof Konva.Layer));
|
|
4153
4208
|
return konvaShapes;
|
|
4154
4209
|
}
|
|
4210
|
+
return [];
|
|
4155
4211
|
}
|
|
4156
4212
|
initializeKonva() {
|
|
4157
4213
|
this._konvaStage = new Konva.Stage({
|
|
@@ -4166,7 +4222,9 @@ class KonvaMarkup {
|
|
|
4166
4222
|
stage.add(layer);
|
|
4167
4223
|
this._konvaLayer = layer;
|
|
4168
4224
|
const transformer = new Konva.Transformer({
|
|
4169
|
-
shouldOverdrawWholeArea: false
|
|
4225
|
+
shouldOverdrawWholeArea: false,
|
|
4226
|
+
keepRatio: false,
|
|
4227
|
+
flipEnabled: false
|
|
4170
4228
|
});
|
|
4171
4229
|
this._konvaTransformer = transformer;
|
|
4172
4230
|
layer.add(transformer);
|
|
@@ -4305,7 +4363,7 @@ class KonvaMarkup {
|
|
|
4305
4363
|
transformer.nodes([]);
|
|
4306
4364
|
return;
|
|
4307
4365
|
}
|
|
4308
|
-
if (this._markupMode === MarkupMode.Text) {
|
|
4366
|
+
if (this._markupMode === MarkupMode.Text || this._markupMode === MarkupMode.SelectMarkup) {
|
|
4309
4367
|
if (e.target.className === "Text" && transformer.nodes().length === 1 && transformer.nodes()[0] === e.target) {
|
|
4310
4368
|
if (this._textInputRef && this._textInputRef.value) this.addText(this._textInputRef.value, this._textInputPos, this._textInputAngle); else this.createTextInput({
|
|
4311
4369
|
x: e.target.attrs.x,
|
|
@@ -4316,7 +4374,7 @@ class KonvaMarkup {
|
|
|
4316
4374
|
this.removeTextInput();
|
|
4317
4375
|
}
|
|
4318
4376
|
}
|
|
4319
|
-
if (this._markupMode === MarkupMode.Image) {
|
|
4377
|
+
if (this._markupMode === MarkupMode.Image || this._markupMode === MarkupMode.SelectMarkup) {
|
|
4320
4378
|
if (e.target.className === "Image" && transformer.nodes().length === 1 && transformer.nodes()[0] === e.target) {
|
|
4321
4379
|
if (this._imageInputRef && this._imageInputRef.value) this.addImage(this._imageInputPos, this._imageInputRef.value, 0, 0); else this.createImageInput({
|
|
4322
4380
|
x: e.target.attrs.x,
|
|
@@ -4388,9 +4446,9 @@ class KonvaMarkup {
|
|
|
4388
4446
|
lines.push({
|
|
4389
4447
|
id: konvaLine.id(),
|
|
4390
4448
|
points: worldPoints.map((p => this.getPoint3dFromArray(p))),
|
|
4391
|
-
color: konvaLine.getColor() || "ff0000",
|
|
4392
|
-
type: konvaLine.getLineType() ||
|
|
4393
|
-
width: konvaLine.getLineWidth() ||
|
|
4449
|
+
color: konvaLine.getColor() || "#ff0000",
|
|
4450
|
+
type: konvaLine.getLineType() || this.lineType,
|
|
4451
|
+
width: konvaLine.getLineWidth() || this.lineWidth
|
|
4394
4452
|
});
|
|
4395
4453
|
}));
|
|
4396
4454
|
return lines;
|
|
@@ -4598,7 +4656,7 @@ class KonvaMarkup {
|
|
|
4598
4656
|
}
|
|
4599
4657
|
const konvaLine = new KonvaLine({
|
|
4600
4658
|
points: points,
|
|
4601
|
-
type: type ||
|
|
4659
|
+
type: type || this.lineType,
|
|
4602
4660
|
width: width || this.lineWidth,
|
|
4603
4661
|
color: color || this._markupColor.HexColor,
|
|
4604
4662
|
id: id
|
|
@@ -4705,7 +4763,7 @@ class KonvaMarkup {
|
|
|
4705
4763
|
},
|
|
4706
4764
|
text: specifiedText,
|
|
4707
4765
|
rotation: angle,
|
|
4708
|
-
fontSize: fontSize,
|
|
4766
|
+
fontSize: fontSize || this.fontSize,
|
|
4709
4767
|
color: color || this._markupColor.HexColor,
|
|
4710
4768
|
id: id
|
|
4711
4769
|
});
|
|
@@ -4925,7 +4983,8 @@ class VisualizeMarkup {
|
|
|
4925
4983
|
g: 0,
|
|
4926
4984
|
b: 0
|
|
4927
4985
|
};
|
|
4928
|
-
this.lineWidth =
|
|
4986
|
+
this.lineWidth = 4;
|
|
4987
|
+
this.fontSize = 34;
|
|
4929
4988
|
}
|
|
4930
4989
|
initialize(viewer, canvas, canvasEvents) {
|
|
4931
4990
|
this._viewer = viewer;
|