@inweb/viewer-visualize 25.4.4 → 25.4.7
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 +158 -19
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +84 -18
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Markup/Api/IMarkupArrow.d.ts +31 -0
- package/lib/Viewer/Markup/Api/IMarkupCloud.d.ts +36 -0
- package/lib/Viewer/Markup/Api/IMarkupColorable.d.ts +11 -0
- package/lib/Viewer/Markup/Api/IMarkupEllipse.d.ts +36 -0
- package/lib/Viewer/Markup/Api/IMarkupImage.d.ts +36 -0
- package/lib/Viewer/Markup/Api/IMarkupLine.d.ts +27 -0
- package/lib/Viewer/Markup/Api/IMarkupObject.d.ts +37 -1
- package/lib/Viewer/Markup/Api/IMarkupRectangle.d.ts +36 -0
- package/lib/Viewer/Markup/Api/IMarkupText.d.ts +28 -0
- package/lib/Viewer/Markup/IMarkup.d.ts +85 -0
- package/lib/Viewer/Markup/Impl/Konva/MarkupColor.d.ts +17 -0
- package/lib/Viewer/Markup/Impl/Visualize/VisualizeMarkup.d.ts +0 -1
- package/lib/Viewer/Markup/MarkupFactory.d.ts +6 -0
- package/lib/Viewer/Viewer.d.ts +2 -0
- package/package.json +4 -4
- package/src/Viewer/Markup/Api/IMarkupArrow.ts +57 -0
- package/src/Viewer/Markup/Api/IMarkupCloud.ts +63 -0
- package/src/Viewer/Markup/Api/IMarkupColorable.ts +35 -0
- package/src/Viewer/Markup/Api/IMarkupEllipse.ts +63 -0
- package/src/Viewer/Markup/Api/IMarkupImage.ts +63 -0
- package/src/Viewer/Markup/Api/IMarkupLine.ts +52 -0
- package/src/Viewer/Markup/Api/IMarkupObject.ts +65 -2
- package/src/Viewer/Markup/Api/IMarkupRectangle.ts +63 -0
- package/src/Viewer/Markup/Api/IMarkupText.ts +54 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaArrow.ts +30 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaCloud.ts +6 -4
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.ts +21 -2
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaImage.ts +19 -9
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaLine.ts +6 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +19 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +19 -0
- package/src/Viewer/Markup/IMarkup.ts +120 -0
- package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +29 -4
- package/src/Viewer/Markup/Impl/Konva/MarkupColor.ts +40 -0
- package/src/Viewer/Markup/Impl/Visualize/VisualizeMarkup.ts +0 -4
- package/src/Viewer/Markup/MarkupFactory.ts +29 -0
- package/src/Viewer/Viewer.ts +4 -2
package/dist/viewer-visualize.js
CHANGED
|
@@ -3023,12 +3023,41 @@
|
|
|
3023
3023
|
}
|
|
3024
3024
|
}
|
|
3025
3025
|
|
|
3026
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
3027
|
+
// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
|
|
3028
|
+
// All rights reserved.
|
|
3029
|
+
//
|
|
3030
|
+
// This software and its documentation and related materials are owned by
|
|
3031
|
+
// the Alliance. The software may only be incorporated into application
|
|
3032
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
3033
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
3034
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
3035
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
3036
|
+
// protected by copyright law and international treaty provisions. Application
|
|
3037
|
+
// programs incorporating this software must include the following statement
|
|
3038
|
+
// with their copyright notices:
|
|
3039
|
+
//
|
|
3040
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
3041
|
+
// license agreement with Open Design Alliance.
|
|
3042
|
+
// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
|
|
3043
|
+
// All rights reserved.
|
|
3044
|
+
//
|
|
3045
|
+
// By use of this software, its documentation or related materials, you
|
|
3046
|
+
// acknowledge and accept the above terms.
|
|
3047
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
3048
|
+
/**
|
|
3049
|
+
* Version of the markup support. Old = "Visualize", New = "Konva"
|
|
3050
|
+
*/
|
|
3026
3051
|
var MarkupType;
|
|
3027
3052
|
(function (MarkupType) {
|
|
3028
3053
|
MarkupType[MarkupType["Unknown"] = 0] = "Unknown";
|
|
3029
3054
|
MarkupType["Konva"] = "Konva";
|
|
3030
3055
|
MarkupType["Visualize"] = "Visualize";
|
|
3031
3056
|
})(MarkupType || (MarkupType = {}));
|
|
3057
|
+
/**
|
|
3058
|
+
* Defines type of markup object. For old Visualize markup ({@link MarkupType}) only "Line" and
|
|
3059
|
+
* "Text" markup objects are supported.
|
|
3060
|
+
*/
|
|
3032
3061
|
var MarkupMode;
|
|
3033
3062
|
(function (MarkupMode) {
|
|
3034
3063
|
MarkupMode["Line"] = "Line";
|
|
@@ -14465,6 +14494,28 @@
|
|
|
14465
14494
|
var libExports = lib$1.exports;
|
|
14466
14495
|
var Konva = /*@__PURE__*/getDefaultExportFromCjs(libExports);
|
|
14467
14496
|
|
|
14497
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
14498
|
+
// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
|
|
14499
|
+
// All rights reserved.
|
|
14500
|
+
//
|
|
14501
|
+
// This software and its documentation and related materials are owned by
|
|
14502
|
+
// the Alliance. The software may only be incorporated into application
|
|
14503
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
14504
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
14505
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
14506
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
14507
|
+
// protected by copyright law and international treaty provisions. Application
|
|
14508
|
+
// programs incorporating this software must include the following statement
|
|
14509
|
+
// with their copyright notices:
|
|
14510
|
+
//
|
|
14511
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
14512
|
+
// license agreement with Open Design Alliance.
|
|
14513
|
+
// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
|
|
14514
|
+
// All rights reserved.
|
|
14515
|
+
//
|
|
14516
|
+
// By use of this software, its documentation or related materials, you
|
|
14517
|
+
// acknowledge and accept the above terms.
|
|
14518
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
14468
14519
|
class MarkupColor {
|
|
14469
14520
|
/**
|
|
14470
14521
|
* Color in #000000 format
|
|
@@ -14472,12 +14523,29 @@
|
|
|
14472
14523
|
get HexColor() {
|
|
14473
14524
|
return "#" + this._hex;
|
|
14474
14525
|
}
|
|
14526
|
+
/**
|
|
14527
|
+
* Color as object with r,g,b properties
|
|
14528
|
+
*/
|
|
14475
14529
|
get RGB() {
|
|
14476
14530
|
return { r: this.R, g: this.G, b: this.B };
|
|
14477
14531
|
}
|
|
14532
|
+
/**
|
|
14533
|
+
* Create an instance of Color
|
|
14534
|
+
*
|
|
14535
|
+
* @param r - Red color in [0,255] range
|
|
14536
|
+
* @param g - Green color in [0,255] range
|
|
14537
|
+
* @param b - Blue color in [0,255] range
|
|
14538
|
+
*/
|
|
14478
14539
|
constructor(r, g, b) {
|
|
14479
14540
|
this.setColor(r, g, b);
|
|
14480
14541
|
}
|
|
14542
|
+
/**
|
|
14543
|
+
* Set Color for current instance
|
|
14544
|
+
*
|
|
14545
|
+
* @param r - Red color in [0,255] range
|
|
14546
|
+
* @param g - Green color in [0,255] range
|
|
14547
|
+
* @param b - Blue color in [0,255] range
|
|
14548
|
+
*/
|
|
14481
14549
|
setColor(r, g, b) {
|
|
14482
14550
|
this.R = r;
|
|
14483
14551
|
this.G = g;
|
|
@@ -14520,6 +14588,11 @@
|
|
|
14520
14588
|
strokeScaleEnabled: false,
|
|
14521
14589
|
dash: LineTypeSpecs.get(params.type) || [],
|
|
14522
14590
|
});
|
|
14591
|
+
this._ref.on("transform", (e) => {
|
|
14592
|
+
const attrs = e.target.attrs;
|
|
14593
|
+
if (attrs.rotation !== this.getRotation())
|
|
14594
|
+
this.setRotation(attrs.rotation);
|
|
14595
|
+
});
|
|
14523
14596
|
this._ref.id(this._ref._id.toString());
|
|
14524
14597
|
}
|
|
14525
14598
|
ref() {
|
|
@@ -14616,6 +14689,20 @@
|
|
|
14616
14689
|
draggable: true,
|
|
14617
14690
|
rotation: (_c = params.rotation) !== null && _c !== void 0 ? _c : 0,
|
|
14618
14691
|
});
|
|
14692
|
+
this._ref.on("transform", (e) => {
|
|
14693
|
+
const attrs = e.target.attrs;
|
|
14694
|
+
if (attrs.rotation !== this.getRotation())
|
|
14695
|
+
this.setRotation(attrs.rotation);
|
|
14696
|
+
const newWidth = this._ref.width() * attrs.scaleX;
|
|
14697
|
+
const newHeight = this._ref.height() * attrs.scaleY;
|
|
14698
|
+
if (Math.abs(attrs.scaleX - 1) > 10e-6) {
|
|
14699
|
+
this.setFontSize(Math.round((this.getFontSize() * newWidth) / this._ref.width()));
|
|
14700
|
+
}
|
|
14701
|
+
if (Math.abs(attrs.scaleY - 1) > 10e-6) {
|
|
14702
|
+
this.setFontSize(Math.round((this.getFontSize() * newHeight) / this._ref.height()));
|
|
14703
|
+
}
|
|
14704
|
+
this._ref.scale({ x: 1, y: 1 });
|
|
14705
|
+
});
|
|
14619
14706
|
this._ref.id(this._ref._id.toString());
|
|
14620
14707
|
}
|
|
14621
14708
|
ref() {
|
|
@@ -14694,6 +14781,20 @@
|
|
|
14694
14781
|
draggable: true,
|
|
14695
14782
|
strokeScaleEnabled: false,
|
|
14696
14783
|
});
|
|
14784
|
+
this._ref.on("transform", (e) => {
|
|
14785
|
+
const attrs = e.target.attrs;
|
|
14786
|
+
if (attrs.rotation !== this.getRotation())
|
|
14787
|
+
this.setRotation(attrs.rotation);
|
|
14788
|
+
const newWidth = this._ref.width() * attrs.scaleX;
|
|
14789
|
+
const newHeight = this._ref.height() * attrs.scaleY;
|
|
14790
|
+
if (Math.abs(attrs.scaleX - 1) > 10e-6) {
|
|
14791
|
+
this.setWidth(newWidth);
|
|
14792
|
+
}
|
|
14793
|
+
if (Math.abs(attrs.scaleY - 1) > 10e-6) {
|
|
14794
|
+
this.setHeight(newHeight);
|
|
14795
|
+
}
|
|
14796
|
+
this._ref.scale({ x: 1, y: 1 });
|
|
14797
|
+
});
|
|
14697
14798
|
this._ref.id(this._ref._id.toString());
|
|
14698
14799
|
}
|
|
14699
14800
|
getPosition() {
|
|
@@ -14778,6 +14879,20 @@
|
|
|
14778
14879
|
draggable: true,
|
|
14779
14880
|
strokeScaleEnabled: false,
|
|
14780
14881
|
});
|
|
14882
|
+
this._ref.on("transform", (e) => {
|
|
14883
|
+
const attrs = e.target.attrs;
|
|
14884
|
+
if (attrs.rotation !== this.getRotation())
|
|
14885
|
+
this.setRotation(attrs.rotation);
|
|
14886
|
+
const newRadiusX = this._ref.radiusX() * attrs.scaleX;
|
|
14887
|
+
const newRadiusY = this._ref.radiusY() * attrs.scaleY;
|
|
14888
|
+
if (Math.abs(attrs.scaleX - 1) > 10e-6) {
|
|
14889
|
+
this.setRadiusX(newRadiusX);
|
|
14890
|
+
}
|
|
14891
|
+
if (Math.abs(attrs.scaleY - 1) > 10e-6) {
|
|
14892
|
+
this.setRadiusY(newRadiusY);
|
|
14893
|
+
}
|
|
14894
|
+
this._ref.scale({ x: 1, y: 1 });
|
|
14895
|
+
});
|
|
14781
14896
|
this._ref.id(this._ref._id.toString());
|
|
14782
14897
|
}
|
|
14783
14898
|
getPosition() {
|
|
@@ -14790,13 +14905,13 @@
|
|
|
14790
14905
|
return this._ref.radiusX();
|
|
14791
14906
|
}
|
|
14792
14907
|
setRadiusX(r) {
|
|
14793
|
-
this._ref.
|
|
14908
|
+
this._ref.radiusX(r);
|
|
14794
14909
|
}
|
|
14795
14910
|
getRadiusY() {
|
|
14796
14911
|
return this._ref.radiusY();
|
|
14797
14912
|
}
|
|
14798
14913
|
setRadiusY(r) {
|
|
14799
|
-
this._ref.
|
|
14914
|
+
this._ref.radiusY(r);
|
|
14800
14915
|
}
|
|
14801
14916
|
getLineWidth() {
|
|
14802
14917
|
return this._ref.strokeWidth();
|
|
@@ -14840,6 +14955,7 @@
|
|
|
14840
14955
|
}
|
|
14841
14956
|
}
|
|
14842
14957
|
|
|
14958
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
14843
14959
|
class KonvaArrow {
|
|
14844
14960
|
constructor(params, ref = null) {
|
|
14845
14961
|
var _a, _b;
|
|
@@ -14860,6 +14976,11 @@
|
|
|
14860
14976
|
draggable: true,
|
|
14861
14977
|
strokeScaleEnabled: false,
|
|
14862
14978
|
});
|
|
14979
|
+
this._ref.on("transform", (e) => {
|
|
14980
|
+
const attrs = e.target.attrs;
|
|
14981
|
+
if (attrs.rotation !== this.getRotation())
|
|
14982
|
+
this.setRotation(attrs.rotation);
|
|
14983
|
+
});
|
|
14863
14984
|
this._ref.id(this._ref._id.toString());
|
|
14864
14985
|
}
|
|
14865
14986
|
ref() {
|
|
@@ -14879,6 +15000,7 @@
|
|
|
14879
15000
|
}
|
|
14880
15001
|
setColor(hex) {
|
|
14881
15002
|
this._ref.stroke(hex);
|
|
15003
|
+
this._ref.fill(hex);
|
|
14882
15004
|
}
|
|
14883
15005
|
getRotation() {
|
|
14884
15006
|
return this._ref.rotation();
|
|
@@ -14957,6 +15079,20 @@
|
|
|
14957
15079
|
this._ratio = this._ref.height() === 0 || this._ref.width() === 0 ? 1 : this._ref.height() / this._ref.width();
|
|
14958
15080
|
};
|
|
14959
15081
|
this._canvasImage.src = params.src;
|
|
15082
|
+
this._ref.on("transform", (e) => {
|
|
15083
|
+
const attrs = e.target.attrs;
|
|
15084
|
+
if (attrs.rotation !== this.getRotation())
|
|
15085
|
+
this.setRotation(attrs.rotation);
|
|
15086
|
+
const newWidth = this._ref.width() * attrs.scaleX;
|
|
15087
|
+
const newHeight = this._ref.height() * attrs.scaleY;
|
|
15088
|
+
if (Math.abs(attrs.scaleX - 1) > 10e-6) {
|
|
15089
|
+
this.setWidth(newWidth);
|
|
15090
|
+
}
|
|
15091
|
+
if (Math.abs(attrs.scaleY - 1) > 10e-6) {
|
|
15092
|
+
this.setHeight(newHeight);
|
|
15093
|
+
}
|
|
15094
|
+
this._ref.scale({ x: 1, y: 1 });
|
|
15095
|
+
});
|
|
14960
15096
|
this._ref.id(this._ref._id.toString());
|
|
14961
15097
|
}
|
|
14962
15098
|
getSrc() {
|
|
@@ -14991,13 +15127,6 @@
|
|
|
14991
15127
|
type() {
|
|
14992
15128
|
return "image";
|
|
14993
15129
|
}
|
|
14994
|
-
// we can break Liskov Substitution Principle, need to use separate IColorable
|
|
14995
|
-
// getColor(): string {
|
|
14996
|
-
// return this._ref.fill();
|
|
14997
|
-
// }
|
|
14998
|
-
// setColor(hex: string) {
|
|
14999
|
-
// this._ref.fill(hex);
|
|
15000
|
-
// }
|
|
15001
15130
|
getRotation() {
|
|
15002
15131
|
return this._ref.rotation();
|
|
15003
15132
|
}
|
|
@@ -15093,19 +15222,21 @@
|
|
|
15093
15222
|
this._ref.className = "Cloud";
|
|
15094
15223
|
this._ref.on("transform", (e) => {
|
|
15095
15224
|
const attrs = e.target.attrs;
|
|
15096
|
-
|
|
15097
|
-
|
|
15225
|
+
if (attrs.rotation !== this.getRotation())
|
|
15226
|
+
this.setRotation(attrs.rotation);
|
|
15098
15227
|
const newWidth = this._ref.width() * attrs.scaleX;
|
|
15099
15228
|
const newHeight = this._ref.height() * attrs.scaleY;
|
|
15229
|
+
const minWidth = 100;
|
|
15230
|
+
const minHeight = 100;
|
|
15100
15231
|
if (newWidth < minWidth || newHeight < minHeight) {
|
|
15101
15232
|
this._ref.scale({ x: 1, y: 1 });
|
|
15102
15233
|
return;
|
|
15103
15234
|
}
|
|
15104
15235
|
if (Math.abs(attrs.scaleX - 1) > 10e-6) {
|
|
15105
|
-
this.
|
|
15236
|
+
this.setWidth(newWidth);
|
|
15106
15237
|
}
|
|
15107
15238
|
if (Math.abs(attrs.scaleY - 1) > 10e-6) {
|
|
15108
|
-
this.
|
|
15239
|
+
this.setHeight(newHeight);
|
|
15109
15240
|
}
|
|
15110
15241
|
this._ref.scale({ x: 1, y: 1 });
|
|
15111
15242
|
});
|
|
@@ -15179,6 +15310,7 @@
|
|
|
15179
15310
|
}
|
|
15180
15311
|
}
|
|
15181
15312
|
|
|
15313
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
15182
15314
|
// move to separate class and create factory with enum?
|
|
15183
15315
|
const MarkupMode2Konva = new Map([
|
|
15184
15316
|
[
|
|
@@ -15391,7 +15523,7 @@
|
|
|
15391
15523
|
let object;
|
|
15392
15524
|
let zIndex = this._zIndex;
|
|
15393
15525
|
// TODO: factory?
|
|
15394
|
-
switch (type) {
|
|
15526
|
+
switch (type.toLocaleLowerCase()) {
|
|
15395
15527
|
case "line":
|
|
15396
15528
|
object = new KonvaLine(params);
|
|
15397
15529
|
zIndex = 1;
|
|
@@ -16160,8 +16292,9 @@
|
|
|
16160
16292
|
addImage(position, src, width, height, id) {
|
|
16161
16293
|
if (!position)
|
|
16162
16294
|
return;
|
|
16295
|
+
let konvaImage;
|
|
16163
16296
|
if (src) {
|
|
16164
|
-
|
|
16297
|
+
konvaImage = new KonvaImage({
|
|
16165
16298
|
position,
|
|
16166
16299
|
src,
|
|
16167
16300
|
width,
|
|
@@ -16178,7 +16311,7 @@
|
|
|
16178
16311
|
}
|
|
16179
16312
|
}
|
|
16180
16313
|
this.removeImageInput();
|
|
16181
|
-
return;
|
|
16314
|
+
return konvaImage;
|
|
16182
16315
|
}
|
|
16183
16316
|
}
|
|
16184
16317
|
|
|
@@ -16462,9 +16595,6 @@
|
|
|
16462
16595
|
viewpoint.description = new Date().toDateString();
|
|
16463
16596
|
return viewpoint;
|
|
16464
16597
|
}
|
|
16465
|
-
getLayer() {
|
|
16466
|
-
throw new Error("Not implemented yet");
|
|
16467
|
-
}
|
|
16468
16598
|
createObject(type, params) {
|
|
16469
16599
|
throw new Error("Not implemented yet");
|
|
16470
16600
|
}
|
|
@@ -16482,7 +16612,14 @@
|
|
|
16482
16612
|
}
|
|
16483
16613
|
}
|
|
16484
16614
|
|
|
16615
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
16485
16616
|
class MarkupFactory {
|
|
16617
|
+
/**
|
|
16618
|
+
* Initialize {@link IMarkup} instance
|
|
16619
|
+
*
|
|
16620
|
+
* @param markupType - Specifies version of the markup support. Two variants of markup
|
|
16621
|
+
* support are implemented: old "Visualize" and new "Konva". Default is "Konva". {@link MarkupType}
|
|
16622
|
+
*/
|
|
16486
16623
|
static createMarkup(markupType) {
|
|
16487
16624
|
let markup;
|
|
16488
16625
|
switch (markupType) {
|
|
@@ -16526,6 +16663,8 @@
|
|
|
16526
16663
|
* @param params.enableAutoUpdate - Enable auto-update of the viewer after any changes. If
|
|
16527
16664
|
* the auto-update is disabled, you need to update the `VisualizeJS` viewer and the active
|
|
16528
16665
|
* dragger manually using the `update` event. Default is `true`.
|
|
16666
|
+
* @param params.markupType - Specifies version of the markup support. Two variants of markup
|
|
16667
|
+
* support are implemented: old "Visualize" and new "Konva". Default is "Konva". {@link MarkupType}
|
|
16529
16668
|
*/
|
|
16530
16669
|
constructor(client, params = {}) {
|
|
16531
16670
|
var _a, _b;
|