@inweb/viewer-visualize 25.4.10 → 25.5.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.
- package/dist/viewer-visualize.js +43 -12
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +50 -14
- 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/KonvaEllipse.ts +8 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +10 -2
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +7 -0
- package/src/Viewer/Markup/IMarkup.ts +12 -1
- package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +20 -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";
|
|
@@ -3166,6 +3167,14 @@ class KonvaText {
|
|
|
3166
3167
|
if (attrs.rotation !== this.getRotation()) this.setRotation(attrs.rotation);
|
|
3167
3168
|
const newWidth = this._ref.width() * attrs.scaleX;
|
|
3168
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
|
+
}
|
|
3169
3178
|
if (Math.abs(attrs.scaleX - 1) > 1e-5) {
|
|
3170
3179
|
this._ref.width(newWidth);
|
|
3171
3180
|
}
|
|
@@ -3260,8 +3269,17 @@ class KonvaRectangle {
|
|
|
3260
3269
|
this._ref.on("transform", (e => {
|
|
3261
3270
|
const attrs = e.target.attrs;
|
|
3262
3271
|
if (attrs.rotation !== this.getRotation()) this.setRotation(attrs.rotation);
|
|
3263
|
-
|
|
3264
|
-
|
|
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
|
+
}
|
|
3265
3283
|
if (Math.abs(attrs.scaleX - 1) > 1e-5) {
|
|
3266
3284
|
this.setWidth(newWidth);
|
|
3267
3285
|
}
|
|
@@ -3364,6 +3382,15 @@ class KonvaEllipse {
|
|
|
3364
3382
|
if (attrs.rotation !== this.getRotation()) this.setRotation(attrs.rotation);
|
|
3365
3383
|
const newRadiusX = this._ref.radiusX() * attrs.scaleX;
|
|
3366
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
|
+
}
|
|
3367
3394
|
if (Math.abs(attrs.scaleX - 1) > 1e-5) {
|
|
3368
3395
|
this.setRadiusX(newRadiusX);
|
|
3369
3396
|
}
|
|
@@ -3819,7 +3846,10 @@ class KonvaCloud {
|
|
|
3819
3846
|
}
|
|
3820
3847
|
}
|
|
3821
3848
|
|
|
3822
|
-
const MarkupMode2Konva = new Map([ [ MarkupMode.
|
|
3849
|
+
const MarkupMode2Konva = new Map([ [ MarkupMode.SelectMarkup, {
|
|
3850
|
+
name: "SelectMarkup",
|
|
3851
|
+
initializer: () => {}
|
|
3852
|
+
} ], [ MarkupMode.Line, {
|
|
3823
3853
|
name: "Line",
|
|
3824
3854
|
initializer: ref => new KonvaLine(null, ref)
|
|
3825
3855
|
} ], [ MarkupMode.Text, {
|
|
@@ -3848,6 +3878,8 @@ class KonvaMarkup {
|
|
|
3848
3878
|
this._zIndex = 1;
|
|
3849
3879
|
this._markupContainerName = "markupContainer";
|
|
3850
3880
|
this.lineWidth = 4;
|
|
3881
|
+
this.lineType = "solid";
|
|
3882
|
+
this.fontSize = 34;
|
|
3851
3883
|
this.changeActiveDragger = event => {
|
|
3852
3884
|
const draggerName = event.data;
|
|
3853
3885
|
this._markupContainer.className = this._canvasOriginal.className.split(" ").filter((x => !x.startsWith("oda-cursor-"))).filter((x => x)).concat(`oda-cursor-${draggerName.toLowerCase()}`).join(" ");
|
|
@@ -3935,8 +3967,9 @@ class KonvaMarkup {
|
|
|
3935
3967
|
const hex = new MarkupColor(r, g, b).HexColor;
|
|
3936
3968
|
Object.values(MarkupMode).forEach((mode => {
|
|
3937
3969
|
this.konvaLayerFind(mode).forEach((x => {
|
|
3938
|
-
|
|
3939
|
-
|
|
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);
|
|
3940
3973
|
}));
|
|
3941
3974
|
}));
|
|
3942
3975
|
this._konvaLayer.draw();
|
|
@@ -4152,6 +4185,7 @@ class KonvaMarkup {
|
|
|
4152
4185
|
const konvaShapes = this._konvaLayer.find(konvaShape.name).filter((x => x.parent instanceof Konva.Layer));
|
|
4153
4186
|
return konvaShapes;
|
|
4154
4187
|
}
|
|
4188
|
+
return [];
|
|
4155
4189
|
}
|
|
4156
4190
|
initializeKonva() {
|
|
4157
4191
|
this._konvaStage = new Konva.Stage({
|
|
@@ -4166,7 +4200,8 @@ class KonvaMarkup {
|
|
|
4166
4200
|
stage.add(layer);
|
|
4167
4201
|
this._konvaLayer = layer;
|
|
4168
4202
|
const transformer = new Konva.Transformer({
|
|
4169
|
-
shouldOverdrawWholeArea: false
|
|
4203
|
+
shouldOverdrawWholeArea: false,
|
|
4204
|
+
keepRatio: false
|
|
4170
4205
|
});
|
|
4171
4206
|
this._konvaTransformer = transformer;
|
|
4172
4207
|
layer.add(transformer);
|
|
@@ -4305,7 +4340,7 @@ class KonvaMarkup {
|
|
|
4305
4340
|
transformer.nodes([]);
|
|
4306
4341
|
return;
|
|
4307
4342
|
}
|
|
4308
|
-
if (this._markupMode === MarkupMode.Text) {
|
|
4343
|
+
if (this._markupMode === MarkupMode.Text || this._markupMode === MarkupMode.SelectMarkup) {
|
|
4309
4344
|
if (e.target.className === "Text" && transformer.nodes().length === 1 && transformer.nodes()[0] === e.target) {
|
|
4310
4345
|
if (this._textInputRef && this._textInputRef.value) this.addText(this._textInputRef.value, this._textInputPos, this._textInputAngle); else this.createTextInput({
|
|
4311
4346
|
x: e.target.attrs.x,
|
|
@@ -4316,7 +4351,7 @@ class KonvaMarkup {
|
|
|
4316
4351
|
this.removeTextInput();
|
|
4317
4352
|
}
|
|
4318
4353
|
}
|
|
4319
|
-
if (this._markupMode === MarkupMode.Image) {
|
|
4354
|
+
if (this._markupMode === MarkupMode.Image || this._markupMode === MarkupMode.SelectMarkup) {
|
|
4320
4355
|
if (e.target.className === "Image" && transformer.nodes().length === 1 && transformer.nodes()[0] === e.target) {
|
|
4321
4356
|
if (this._imageInputRef && this._imageInputRef.value) this.addImage(this._imageInputPos, this._imageInputRef.value, 0, 0); else this.createImageInput({
|
|
4322
4357
|
x: e.target.attrs.x,
|
|
@@ -4388,9 +4423,9 @@ class KonvaMarkup {
|
|
|
4388
4423
|
lines.push({
|
|
4389
4424
|
id: konvaLine.id(),
|
|
4390
4425
|
points: worldPoints.map((p => this.getPoint3dFromArray(p))),
|
|
4391
|
-
color: konvaLine.getColor() || "ff0000",
|
|
4392
|
-
type: konvaLine.getLineType() ||
|
|
4393
|
-
width: konvaLine.getLineWidth() ||
|
|
4426
|
+
color: konvaLine.getColor() || "#ff0000",
|
|
4427
|
+
type: konvaLine.getLineType() || this.lineType,
|
|
4428
|
+
width: konvaLine.getLineWidth() || this.lineWidth
|
|
4394
4429
|
});
|
|
4395
4430
|
}));
|
|
4396
4431
|
return lines;
|
|
@@ -4598,7 +4633,7 @@ class KonvaMarkup {
|
|
|
4598
4633
|
}
|
|
4599
4634
|
const konvaLine = new KonvaLine({
|
|
4600
4635
|
points: points,
|
|
4601
|
-
type: type ||
|
|
4636
|
+
type: type || this.lineType,
|
|
4602
4637
|
width: width || this.lineWidth,
|
|
4603
4638
|
color: color || this._markupColor.HexColor,
|
|
4604
4639
|
id: id
|
|
@@ -4705,7 +4740,7 @@ class KonvaMarkup {
|
|
|
4705
4740
|
},
|
|
4706
4741
|
text: specifiedText,
|
|
4707
4742
|
rotation: angle,
|
|
4708
|
-
fontSize: fontSize,
|
|
4743
|
+
fontSize: fontSize || this.fontSize,
|
|
4709
4744
|
color: color || this._markupColor.HexColor,
|
|
4710
4745
|
id: id
|
|
4711
4746
|
});
|
|
@@ -4925,7 +4960,8 @@ class VisualizeMarkup {
|
|
|
4925
4960
|
g: 0,
|
|
4926
4961
|
b: 0
|
|
4927
4962
|
};
|
|
4928
|
-
this.lineWidth =
|
|
4963
|
+
this.lineWidth = 4;
|
|
4964
|
+
this.fontSize = 34;
|
|
4929
4965
|
}
|
|
4930
4966
|
initialize(viewer, canvas, canvasEvents) {
|
|
4931
4967
|
this._viewer = viewer;
|