@inweb/viewer-visualize 25.7.0 → 25.7.2
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/LICENSE +2 -2
- package/dist/viewer-visualize.js +330 -295
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +164 -149
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Markup/Api/IMarkupLine.d.ts +4 -0
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaLine.d.ts +2 -3
- package/lib/Viewer/Markup/IMarkup.d.ts +28 -32
- package/lib/Viewer/Markup/IWorldTransform.d.ts +39 -0
- package/lib/Viewer/Markup/Impl/Konva/KonvaMarkup.d.ts +11 -6
- package/lib/Viewer/Markup/Impl/Konva/MarkupColor.d.ts +3 -0
- package/lib/Viewer/Markup/Impl/Visualize/VisualizeMarkup.d.ts +4 -4
- package/lib/Viewer/Markup/MarkupFactory.d.ts +10 -10
- package/lib/Viewer/Viewer.d.ts +60 -42
- package/lib/index.d.ts +12 -0
- package/package.json +5 -5
- package/src/Viewer/Commands/ApplyModelTransform.ts +2 -2
- package/src/Viewer/Commands/ClearMarkup.ts +2 -2
- package/src/Viewer/Commands/ClearSlices.ts +2 -2
- package/src/Viewer/Commands/CreatePreview.ts +2 -2
- package/src/Viewer/Commands/Explode.ts +2 -2
- package/src/Viewer/Commands/GetDefaultViewPositions.ts +2 -2
- package/src/Viewer/Commands/GetModels.ts +2 -2
- package/src/Viewer/Commands/GetSelected.ts +2 -2
- package/src/Viewer/Commands/HideSelected.ts +2 -2
- package/src/Viewer/Commands/IsolateSelected.ts +2 -2
- package/src/Viewer/Commands/RegenerateAll.ts +2 -2
- package/src/Viewer/Commands/ResetView.ts +2 -2
- package/src/Viewer/Commands/SelectModel.ts +2 -2
- package/src/Viewer/Commands/SetActiveDragger.ts +2 -2
- package/src/Viewer/Commands/SetDefaultViewPosition.ts +2 -2
- package/src/Viewer/Commands/SetMarkupColor.ts +2 -2
- package/src/Viewer/Commands/SetSelected.ts +2 -2
- package/src/Viewer/Commands/ShowAll.ts +2 -2
- package/src/Viewer/Commands/Unselect.ts +2 -2
- package/src/Viewer/Commands/ZoomToExtents.ts +2 -2
- package/src/Viewer/Commands/ZoomToObjects.ts +2 -2
- package/src/Viewer/Commands/ZoomToSelected.ts +2 -2
- package/src/Viewer/Commands/index.ts +2 -2
- package/src/Viewer/Draggers/Actions/OrbitAction.ts +2 -2
- package/src/Viewer/Draggers/Actions/PanAction.ts +2 -2
- package/src/Viewer/Draggers/Actions/ZoomAction.ts +2 -2
- package/src/Viewer/Draggers/Common/Geometry.ts +2 -2
- package/src/Viewer/Draggers/Common/GestureManager.ts +2 -2
- package/src/Viewer/Draggers/Common/OdBaseDragger.ts +2 -2
- package/src/Viewer/Draggers/Common/OdaGeAction.ts +2 -2
- package/src/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.ts +2 -2
- package/src/Viewer/Draggers/MeasureLineDragger/MeasureUtils.ts +2 -2
- package/src/Viewer/Draggers/MeasureLineDragger/index.ts +2 -2
- package/src/Viewer/Draggers/OdBaseCuttingPlaneDragger.ts +2 -2
- package/src/Viewer/Draggers/OdCuttingPlaneXAxisDragger.ts +2 -2
- package/src/Viewer/Draggers/OdCuttingPlaneYAxisDragger.ts +2 -2
- package/src/Viewer/Draggers/OdCuttingPlaneZAxisDragger.ts +2 -2
- package/src/Viewer/Draggers/OdOrbitDragger.ts +2 -2
- package/src/Viewer/Draggers/OdPanDragger.ts +2 -2
- package/src/Viewer/Draggers/OdZoomDragger.ts +2 -2
- package/src/Viewer/Draggers/OdZoomWheelDragger.ts +2 -2
- package/src/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.ts +2 -2
- package/src/Viewer/Draggers/OdZoomWindowDragger/index.ts +2 -2
- package/src/Viewer/Draggers/OdaLineDragger.ts +2 -2
- package/src/Viewer/Draggers/OdaTextDragger.ts +2 -2
- package/src/Viewer/Draggers/OdaWalkDragger.ts +2 -2
- package/src/Viewer/Draggers/OrbitAroundBuildingDragger.ts +2 -2
- package/src/Viewer/Loaders/BaseLoader.ts +2 -2
- package/src/Viewer/Loaders/LoaderFactory.ts +2 -2
- package/src/Viewer/Loaders/TCSLoader.ts +2 -2
- package/src/Viewer/Loaders/VsfXLoader.ts +2 -2
- package/src/Viewer/Loaders/VsfXPartialLoader.ts +2 -2
- package/src/Viewer/Loaders/VsfXStreamingLoader.ts +2 -2
- package/src/Viewer/Markup/Api/IMarkupLine.ts +5 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaArrow.ts +1 -1
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaCloud.ts +1 -1
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.ts +1 -1
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaLine.ts +4 -5
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +1 -1
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +1 -1
- package/src/Viewer/Markup/IMarkup.ts +34 -35
- package/src/Viewer/Markup/IWorldTransform.ts +46 -0
- package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +85 -161
- package/src/Viewer/Markup/Impl/Konva/MarkupColor.ts +3 -0
- package/src/Viewer/Markup/Impl/Visualize/VisualizeMarkup.ts +45 -10
- package/src/Viewer/Markup/MarkupFactory.ts +16 -20
- package/src/Viewer/Viewer.ts +103 -95
- package/src/Viewer/utils.ts +2 -2
- package/src/index.ts +14 -2
package/dist/viewer-visualize.js
CHANGED
|
@@ -369,6 +369,15 @@
|
|
|
369
369
|
|
|
370
370
|
const CANVAS_EVENTS = CanvasEvents;
|
|
371
371
|
|
|
372
|
+
class Dragger {
|
|
373
|
+
constructor(viewer) {
|
|
374
|
+
this.name = "";
|
|
375
|
+
}
|
|
376
|
+
initialize() {}
|
|
377
|
+
dispose() {}
|
|
378
|
+
updatePreview() {}
|
|
379
|
+
}
|
|
380
|
+
|
|
372
381
|
///////////////////////////////////////////////////////////////////////////////
|
|
373
382
|
const composeMatrixFromTransform = (translate, rotate, scale, modelCenter, matrix) => {
|
|
374
383
|
const translateMatrix = matrix.setTranslation([translate.x, translate.y, translate.z]);
|
|
@@ -714,11 +723,11 @@
|
|
|
714
723
|
off(type, listener) {
|
|
715
724
|
return this.removeEventListener(type, listener);
|
|
716
725
|
}
|
|
717
|
-
emit(
|
|
718
|
-
if (typeof
|
|
719
|
-
type:
|
|
726
|
+
emit(type, ...args) {
|
|
727
|
+
if (typeof type === "string") return this.emitEvent({
|
|
728
|
+
type: type,
|
|
720
729
|
args: args
|
|
721
|
-
}); else if (typeof
|
|
730
|
+
}); else if (typeof type === "object") return this.emitEvent(type); else return false;
|
|
722
731
|
}
|
|
723
732
|
}
|
|
724
733
|
|
|
@@ -1771,7 +1780,7 @@
|
|
|
1771
1780
|
}
|
|
1772
1781
|
|
|
1773
1782
|
///////////////////////////////////////////////////////////////////////////////
|
|
1774
|
-
// Copyright (C) 2002-
|
|
1783
|
+
// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
|
|
1775
1784
|
// All rights reserved.
|
|
1776
1785
|
//
|
|
1777
1786
|
// This software and its documentation and related materials are owned by
|
|
@@ -1786,7 +1795,7 @@
|
|
|
1786
1795
|
//
|
|
1787
1796
|
// This application incorporates Open Design Alliance software pursuant to a
|
|
1788
1797
|
// license agreement with Open Design Alliance.
|
|
1789
|
-
// Open Design Alliance Copyright (C) 2002-
|
|
1798
|
+
// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
|
|
1790
1799
|
// All rights reserved.
|
|
1791
1800
|
//
|
|
1792
1801
|
// By use of this software, its documentation or related materials, you
|
|
@@ -1979,7 +1988,7 @@
|
|
|
1979
1988
|
}
|
|
1980
1989
|
|
|
1981
1990
|
///////////////////////////////////////////////////////////////////////////////
|
|
1982
|
-
// Copyright (C) 2002-
|
|
1991
|
+
// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
|
|
1983
1992
|
// All rights reserved.
|
|
1984
1993
|
//
|
|
1985
1994
|
// This software and its documentation and related materials are owned by
|
|
@@ -1994,7 +2003,7 @@
|
|
|
1994
2003
|
//
|
|
1995
2004
|
// This application incorporates Open Design Alliance software pursuant to a
|
|
1996
2005
|
// license agreement with Open Design Alliance.
|
|
1997
|
-
// Open Design Alliance Copyright (C) 2002-
|
|
2006
|
+
// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
|
|
1998
2007
|
// All rights reserved.
|
|
1999
2008
|
//
|
|
2000
2009
|
// By use of this software, its documentation or related materials, you
|
|
@@ -2073,7 +2082,7 @@
|
|
|
2073
2082
|
}
|
|
2074
2083
|
|
|
2075
2084
|
///////////////////////////////////////////////////////////////////////////////
|
|
2076
|
-
// Copyright (C) 2002-
|
|
2085
|
+
// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
|
|
2077
2086
|
// All rights reserved.
|
|
2078
2087
|
//
|
|
2079
2088
|
// This software and its documentation and related materials are owned by
|
|
@@ -2088,7 +2097,7 @@
|
|
|
2088
2097
|
//
|
|
2089
2098
|
// This application incorporates Open Design Alliance software pursuant to a
|
|
2090
2099
|
// license agreement with Open Design Alliance.
|
|
2091
|
-
// Open Design Alliance Copyright (C) 2002-
|
|
2100
|
+
// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
|
|
2092
2101
|
// All rights reserved.
|
|
2093
2102
|
//
|
|
2094
2103
|
// By use of this software, its documentation or related materials, you
|
|
@@ -2596,7 +2605,7 @@
|
|
|
2596
2605
|
}
|
|
2597
2606
|
|
|
2598
2607
|
///////////////////////////////////////////////////////////////////////////////
|
|
2599
|
-
// Copyright (C) 2002-
|
|
2608
|
+
// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
|
|
2600
2609
|
// All rights reserved.
|
|
2601
2610
|
//
|
|
2602
2611
|
// This software and its documentation and related materials are owned by
|
|
@@ -2611,7 +2620,7 @@
|
|
|
2611
2620
|
//
|
|
2612
2621
|
// This application incorporates Open Design Alliance software pursuant to a
|
|
2613
2622
|
// license agreement with Open Design Alliance.
|
|
2614
|
-
// Open Design Alliance Copyright (C) 2002-
|
|
2623
|
+
// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
|
|
2615
2624
|
// All rights reserved.
|
|
2616
2625
|
//
|
|
2617
2626
|
// By use of this software, its documentation or related materials, you
|
|
@@ -2660,7 +2669,7 @@
|
|
|
2660
2669
|
};
|
|
2661
2670
|
|
|
2662
2671
|
///////////////////////////////////////////////////////////////////////////////
|
|
2663
|
-
// Copyright (C) 2002-
|
|
2672
|
+
// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
|
|
2664
2673
|
// All rights reserved.
|
|
2665
2674
|
//
|
|
2666
2675
|
// This software and its documentation and related materials are owned by
|
|
@@ -2675,7 +2684,7 @@
|
|
|
2675
2684
|
//
|
|
2676
2685
|
// This application incorporates Open Design Alliance software pursuant to a
|
|
2677
2686
|
// license agreement with Open Design Alliance.
|
|
2678
|
-
// Open Design Alliance Copyright (C) 2002-
|
|
2687
|
+
// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
|
|
2679
2688
|
// All rights reserved.
|
|
2680
2689
|
//
|
|
2681
2690
|
// By use of this software, its documentation or related materials, you
|
|
@@ -3027,53 +3036,6 @@
|
|
|
3027
3036
|
}
|
|
3028
3037
|
}
|
|
3029
3038
|
|
|
3030
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
3031
|
-
// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
|
|
3032
|
-
// All rights reserved.
|
|
3033
|
-
//
|
|
3034
|
-
// This software and its documentation and related materials are owned by
|
|
3035
|
-
// the Alliance. The software may only be incorporated into application
|
|
3036
|
-
// programs owned by members of the Alliance, subject to a signed
|
|
3037
|
-
// Membership Agreement and Supplemental Software License Agreement with the
|
|
3038
|
-
// Alliance. The structure and organization of this software are the valuable
|
|
3039
|
-
// trade secrets of the Alliance and its suppliers. The software is also
|
|
3040
|
-
// protected by copyright law and international treaty provisions. Application
|
|
3041
|
-
// programs incorporating this software must include the following statement
|
|
3042
|
-
// with their copyright notices:
|
|
3043
|
-
//
|
|
3044
|
-
// This application incorporates Open Design Alliance software pursuant to a
|
|
3045
|
-
// license agreement with Open Design Alliance.
|
|
3046
|
-
// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
|
|
3047
|
-
// All rights reserved.
|
|
3048
|
-
//
|
|
3049
|
-
// By use of this software, its documentation or related materials, you
|
|
3050
|
-
// acknowledge and accept the above terms.
|
|
3051
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
3052
|
-
/**
|
|
3053
|
-
* Version of the markup support. Old = "Visualize", New = "Konva"
|
|
3054
|
-
*/
|
|
3055
|
-
var MarkupType;
|
|
3056
|
-
(function (MarkupType) {
|
|
3057
|
-
MarkupType[MarkupType["Unknown"] = 0] = "Unknown";
|
|
3058
|
-
MarkupType["Konva"] = "Konva";
|
|
3059
|
-
MarkupType["Visualize"] = "Visualize";
|
|
3060
|
-
})(MarkupType || (MarkupType = {}));
|
|
3061
|
-
/**
|
|
3062
|
-
* Defines type of markup object. For old Visualize markup ({@link MarkupType}) only "Line" and
|
|
3063
|
-
* "Text" markup objects are supported.
|
|
3064
|
-
*/
|
|
3065
|
-
var MarkupMode;
|
|
3066
|
-
(function (MarkupMode) {
|
|
3067
|
-
MarkupMode["SelectMarkup"] = "SelectMarkup";
|
|
3068
|
-
MarkupMode["Line"] = "Line";
|
|
3069
|
-
MarkupMode["Text"] = "Text";
|
|
3070
|
-
MarkupMode["Rectangle"] = "Rectangle";
|
|
3071
|
-
MarkupMode["Ellipse"] = "Ellipse";
|
|
3072
|
-
MarkupMode["Arrow"] = "Arrow";
|
|
3073
|
-
MarkupMode["Image"] = "Image";
|
|
3074
|
-
MarkupMode["Cloud"] = "Cloud";
|
|
3075
|
-
})(MarkupMode || (MarkupMode = {}));
|
|
3076
|
-
|
|
3077
3039
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
3078
3040
|
|
|
3079
3041
|
function getDefaultExportFromCjs (x) {
|
|
@@ -3106,7 +3068,7 @@
|
|
|
3106
3068
|
: {};
|
|
3107
3069
|
exports.Konva = {
|
|
3108
3070
|
_global: exports.glob,
|
|
3109
|
-
version: '9.3.
|
|
3071
|
+
version: '9.3.13',
|
|
3110
3072
|
isBrowser: detectBrowser(),
|
|
3111
3073
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
3112
3074
|
dblClickWindow: 400,
|
|
@@ -3127,6 +3089,7 @@
|
|
|
3127
3089
|
_mouseDblClickPointerId: null,
|
|
3128
3090
|
_touchDblClickPointerId: null,
|
|
3129
3091
|
_pointerDblClickPointerId: null,
|
|
3092
|
+
_fixTextRendering: false,
|
|
3130
3093
|
pixelRatio: (typeof window !== 'undefined' && window.devicePixelRatio) || 1,
|
|
3131
3094
|
dragDistance: 3,
|
|
3132
3095
|
angleDeg: true,
|
|
@@ -7258,6 +7221,7 @@
|
|
|
7258
7221
|
DragAndDrop_1.DD.justDragged = false;
|
|
7259
7222
|
Global_1.Konva['_' + eventType + 'ListenClick'] = true;
|
|
7260
7223
|
if (!shape || !shape.isListening()) {
|
|
7224
|
+
this[eventType + 'ClickStartShape'] = undefined;
|
|
7261
7225
|
return;
|
|
7262
7226
|
}
|
|
7263
7227
|
if (Global_1.Konva.capturePointerEventsEnabled) {
|
|
@@ -7565,7 +7529,14 @@
|
|
|
7565
7529
|
exports.Stage = Stage;
|
|
7566
7530
|
Stage.prototype.nodeType = STAGE;
|
|
7567
7531
|
(0, Global_2._registerNode)(Stage);
|
|
7568
|
-
Factory_1.Factory.addGetterSetter(Stage, 'container');
|
|
7532
|
+
Factory_1.Factory.addGetterSetter(Stage, 'container');
|
|
7533
|
+
if (Global_1.Konva.isBrowser) {
|
|
7534
|
+
document.addEventListener('visibilitychange', () => {
|
|
7535
|
+
exports.stages.forEach((stage) => {
|
|
7536
|
+
stage.batchDraw();
|
|
7537
|
+
});
|
|
7538
|
+
});
|
|
7539
|
+
}
|
|
7569
7540
|
} (Stage));
|
|
7570
7541
|
|
|
7571
7542
|
var Layer$1 = {};
|
|
@@ -7845,8 +7816,17 @@
|
|
|
7845
7816
|
};
|
|
7846
7817
|
}
|
|
7847
7818
|
getClientRect(config = {}) {
|
|
7819
|
+
let hasCachedParent = false;
|
|
7820
|
+
let parent = this.getParent();
|
|
7821
|
+
while (parent) {
|
|
7822
|
+
if (parent.isCached()) {
|
|
7823
|
+
hasCachedParent = true;
|
|
7824
|
+
break;
|
|
7825
|
+
}
|
|
7826
|
+
parent = parent.getParent();
|
|
7827
|
+
}
|
|
7848
7828
|
const skipTransform = config.skipTransform;
|
|
7849
|
-
const relativeTo = config.relativeTo;
|
|
7829
|
+
const relativeTo = config.relativeTo || (hasCachedParent && this.getStage()) || undefined;
|
|
7850
7830
|
const fillRect = this.getSelfRect();
|
|
7851
7831
|
const applyStroke = !config.skipStroke && this.hasStroke();
|
|
7852
7832
|
const strokeWidth = (applyStroke && this.strokeWidth()) || 0;
|
|
@@ -9169,7 +9149,7 @@
|
|
|
9169
9149
|
const Shape_1$f = Shape;
|
|
9170
9150
|
const Global_1$g = Global;
|
|
9171
9151
|
const Validators_1$u = Validators;
|
|
9172
|
-
const Global_2$
|
|
9152
|
+
const Global_2$3 = Global;
|
|
9173
9153
|
class Arc extends Shape_1$f.Shape {
|
|
9174
9154
|
_sceneFunc(context) {
|
|
9175
9155
|
var angle = Global_1$g.Konva.getAngle(this.angle()), clockwise = this.clockwise();
|
|
@@ -9216,7 +9196,7 @@
|
|
|
9216
9196
|
Arc.prototype._centroid = true;
|
|
9217
9197
|
Arc.prototype.className = 'Arc';
|
|
9218
9198
|
Arc.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
|
|
9219
|
-
(0, Global_2$
|
|
9199
|
+
(0, Global_2$3._registerNode)(Arc);
|
|
9220
9200
|
Factory_1$v.Factory.addGetterSetter(Arc, 'innerRadius', 0, (0, Validators_1$u.getNumberValidator)());
|
|
9221
9201
|
Factory_1$v.Factory.addGetterSetter(Arc, 'outerRadius', 0, (0, Validators_1$u.getNumberValidator)());
|
|
9222
9202
|
Factory_1$v.Factory.addGetterSetter(Arc, 'angle', 0, (0, Validators_1$u.getNumberValidator)());
|
|
@@ -10366,51 +10346,29 @@
|
|
|
10366
10346
|
return null;
|
|
10367
10347
|
}
|
|
10368
10348
|
static getPointOnLine(dist, P1x, P1y, P2x, P2y, fromX, fromY) {
|
|
10369
|
-
|
|
10370
|
-
|
|
10349
|
+
fromX = fromX !== null && fromX !== void 0 ? fromX : P1x;
|
|
10350
|
+
fromY = fromY !== null && fromY !== void 0 ? fromY : P1y;
|
|
10351
|
+
const len = this.getLineLength(P1x, P1y, P2x, P2y);
|
|
10352
|
+
if (len < 1e-10) {
|
|
10353
|
+
return { x: P1x, y: P1y };
|
|
10371
10354
|
}
|
|
10372
|
-
if (fromY === undefined) {
|
|
10373
|
-
fromY = P1y;
|
|
10374
|
-
}
|
|
10375
|
-
var m = (P2y - P1y) / (P2x - P1x + 0.00000001);
|
|
10376
|
-
var run = Math.sqrt((dist * dist) / (1 + m * m));
|
|
10377
|
-
if (P2x < P1x) {
|
|
10378
|
-
run *= -1;
|
|
10379
|
-
}
|
|
10380
|
-
var rise = m * run;
|
|
10381
|
-
var pt;
|
|
10382
10355
|
if (P2x === P1x) {
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10392
|
-
|
|
10393
|
-
|
|
10394
|
-
|
|
10395
|
-
|
|
10396
|
-
|
|
10397
|
-
|
|
10398
|
-
|
|
10399
|
-
ix = P1x + u * (P2x - P1x);
|
|
10400
|
-
iy = P1y + u * (P2y - P1y);
|
|
10401
|
-
var pRise = this.getLineLength(fromX, fromY, ix, iy);
|
|
10402
|
-
var pRun = Math.sqrt(dist * dist - pRise * pRise);
|
|
10403
|
-
run = Math.sqrt((pRun * pRun) / (1 + m * m));
|
|
10404
|
-
if (P2x < P1x) {
|
|
10405
|
-
run *= -1;
|
|
10406
|
-
}
|
|
10407
|
-
rise = m * run;
|
|
10408
|
-
pt = {
|
|
10409
|
-
x: ix + run,
|
|
10410
|
-
y: iy + rise,
|
|
10411
|
-
};
|
|
10412
|
-
}
|
|
10413
|
-
return pt;
|
|
10356
|
+
return { x: fromX, y: fromY + (P2y > P1y ? dist : -dist) };
|
|
10357
|
+
}
|
|
10358
|
+
const m = (P2y - P1y) / (P2x - P1x);
|
|
10359
|
+
const run = Math.sqrt((dist * dist) / (1 + m * m)) * (P2x < P1x ? -1 : 1);
|
|
10360
|
+
const rise = m * run;
|
|
10361
|
+
if (Math.abs(fromY - P1y - m * (fromX - P1x)) < 1e-10) {
|
|
10362
|
+
return { x: fromX + run, y: fromY + rise };
|
|
10363
|
+
}
|
|
10364
|
+
const u = ((fromX - P1x) * (P2x - P1x) + (fromY - P1y) * (P2y - P1y)) / (len * len);
|
|
10365
|
+
const ix = P1x + u * (P2x - P1x);
|
|
10366
|
+
const iy = P1y + u * (P2y - P1y);
|
|
10367
|
+
const pRise = this.getLineLength(fromX, fromY, ix, iy);
|
|
10368
|
+
const pRun = Math.sqrt(dist * dist - pRise * pRise);
|
|
10369
|
+
const adjustedRun = Math.sqrt((pRun * pRun) / (1 + m * m)) * (P2x < P1x ? -1 : 1);
|
|
10370
|
+
const adjustedRise = m * adjustedRun;
|
|
10371
|
+
return { x: ix + adjustedRun, y: iy + adjustedRise };
|
|
10414
10372
|
}
|
|
10415
10373
|
static getPointOnCubicBezier(pct, P1x, P1y, P2x, P2y, P3x, P3y, P4x, P4y) {
|
|
10416
10374
|
function CB1(t) {
|
|
@@ -11597,8 +11555,9 @@
|
|
|
11597
11555
|
const Util_1$5 = Util;
|
|
11598
11556
|
const Factory_1$i = Factory;
|
|
11599
11557
|
const Shape_1$3 = Shape;
|
|
11600
|
-
const Validators_1$i = Validators;
|
|
11601
11558
|
const Global_1$3 = Global;
|
|
11559
|
+
const Validators_1$i = Validators;
|
|
11560
|
+
const Global_2$2 = Global;
|
|
11602
11561
|
function stringToArray(string) {
|
|
11603
11562
|
return Array.from(string);
|
|
11604
11563
|
}
|
|
@@ -11675,15 +11634,22 @@
|
|
|
11675
11634
|
}
|
|
11676
11635
|
var padding = this.padding(), fontSize = this.fontSize(), lineHeightPx = this.lineHeight() * fontSize, verticalAlign = this.verticalAlign(), direction = this.direction(), alignY = 0, align = this.align(), totalWidth = this.getWidth(), letterSpacing = this.letterSpacing(), fill = this.fill(), textDecoration = this.textDecoration(), shouldUnderline = textDecoration.indexOf('underline') !== -1, shouldLineThrough = textDecoration.indexOf('line-through') !== -1, n;
|
|
11677
11636
|
direction = direction === INHERIT ? context.direction : direction;
|
|
11678
|
-
var translateY = 0;
|
|
11679
11637
|
var translateY = lineHeightPx / 2;
|
|
11638
|
+
var baseline = MIDDLE;
|
|
11639
|
+
if (Global_1$3.Konva._fixTextRendering) {
|
|
11640
|
+
var metrics = this.measureSize('M');
|
|
11641
|
+
baseline = 'alphabetic';
|
|
11642
|
+
translateY =
|
|
11643
|
+
(metrics.fontBoundingBoxAscent - metrics.fontBoundingBoxDescent) / 2 +
|
|
11644
|
+
lineHeightPx / 2;
|
|
11645
|
+
}
|
|
11680
11646
|
var lineTranslateX = 0;
|
|
11681
11647
|
var lineTranslateY = 0;
|
|
11682
11648
|
if (direction === RTL) {
|
|
11683
11649
|
context.setAttr('direction', direction);
|
|
11684
11650
|
}
|
|
11685
11651
|
context.setAttr('font', this._getContextFont());
|
|
11686
|
-
context.setAttr('textBaseline',
|
|
11652
|
+
context.setAttr('textBaseline', baseline);
|
|
11687
11653
|
context.setAttr('textAlign', LEFT);
|
|
11688
11654
|
if (verticalAlign === MIDDLE) {
|
|
11689
11655
|
alignY = (this.getHeight() - textArrLen * lineHeightPx - padding * 2) / 2;
|
|
@@ -11706,12 +11672,17 @@
|
|
|
11706
11672
|
if (shouldUnderline) {
|
|
11707
11673
|
context.save();
|
|
11708
11674
|
context.beginPath();
|
|
11709
|
-
|
|
11675
|
+
let yOffset = Global_1$3.Konva._fixTextRendering
|
|
11676
|
+
? Math.round(fontSize / 4)
|
|
11677
|
+
: Math.round(fontSize / 2);
|
|
11678
|
+
const x = lineTranslateX;
|
|
11679
|
+
const y = translateY + lineTranslateY + yOffset;
|
|
11680
|
+
context.moveTo(x, y);
|
|
11710
11681
|
spacesNumber = text.split(' ').length - 1;
|
|
11711
11682
|
oneWord = spacesNumber === 0;
|
|
11712
11683
|
lineWidth =
|
|
11713
11684
|
align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;
|
|
11714
|
-
context.lineTo(
|
|
11685
|
+
context.lineTo(x + Math.round(lineWidth), y);
|
|
11715
11686
|
context.lineWidth = fontSize / 15;
|
|
11716
11687
|
const gradient = this._getLinearGradient();
|
|
11717
11688
|
context.strokeStyle = gradient || fill;
|
|
@@ -11721,14 +11692,15 @@
|
|
|
11721
11692
|
if (shouldLineThrough) {
|
|
11722
11693
|
context.save();
|
|
11723
11694
|
context.beginPath();
|
|
11724
|
-
|
|
11695
|
+
let yOffset = Global_1$3.Konva._fixTextRendering ? -Math.round(fontSize / 4) : 0;
|
|
11696
|
+
context.moveTo(lineTranslateX, translateY + lineTranslateY + yOffset);
|
|
11725
11697
|
spacesNumber = text.split(' ').length - 1;
|
|
11726
11698
|
oneWord = spacesNumber === 0;
|
|
11727
11699
|
lineWidth =
|
|
11728
11700
|
align === JUSTIFY && lastLine && !oneWord
|
|
11729
11701
|
? totalWidth - padding * 2
|
|
11730
11702
|
: width;
|
|
11731
|
-
context.lineTo(lineTranslateX + Math.round(lineWidth), translateY + lineTranslateY);
|
|
11703
|
+
context.lineTo(lineTranslateX + Math.round(lineWidth), translateY + lineTranslateY + yOffset);
|
|
11732
11704
|
context.lineWidth = fontSize / 15;
|
|
11733
11705
|
const gradient = this._getLinearGradient();
|
|
11734
11706
|
context.strokeStyle = gradient || fill;
|
|
@@ -11800,12 +11772,25 @@
|
|
|
11800
11772
|
return this.textHeight;
|
|
11801
11773
|
}
|
|
11802
11774
|
measureSize(text) {
|
|
11775
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
11803
11776
|
var _context = getDummyContext(), fontSize = this.fontSize(), metrics;
|
|
11804
11777
|
_context.save();
|
|
11805
11778
|
_context.font = this._getContextFont();
|
|
11806
11779
|
metrics = _context.measureText(text);
|
|
11807
11780
|
_context.restore();
|
|
11781
|
+
const scaleFactor = fontSize / 100;
|
|
11808
11782
|
return {
|
|
11783
|
+
actualBoundingBoxAscent: (_a = metrics.actualBoundingBoxAscent) !== null && _a !== void 0 ? _a : 71.58203125 * scaleFactor,
|
|
11784
|
+
actualBoundingBoxDescent: (_b = metrics.actualBoundingBoxDescent) !== null && _b !== void 0 ? _b : 0,
|
|
11785
|
+
actualBoundingBoxLeft: (_c = metrics.actualBoundingBoxLeft) !== null && _c !== void 0 ? _c : -7.421875 * scaleFactor,
|
|
11786
|
+
actualBoundingBoxRight: (_d = metrics.actualBoundingBoxRight) !== null && _d !== void 0 ? _d : 75.732421875 * scaleFactor,
|
|
11787
|
+
alphabeticBaseline: (_e = metrics.alphabeticBaseline) !== null && _e !== void 0 ? _e : 0,
|
|
11788
|
+
emHeightAscent: (_f = metrics.emHeightAscent) !== null && _f !== void 0 ? _f : 100 * scaleFactor,
|
|
11789
|
+
emHeightDescent: (_g = metrics.emHeightDescent) !== null && _g !== void 0 ? _g : -20 * scaleFactor,
|
|
11790
|
+
fontBoundingBoxAscent: (_h = metrics.fontBoundingBoxAscent) !== null && _h !== void 0 ? _h : 91 * scaleFactor,
|
|
11791
|
+
fontBoundingBoxDescent: (_j = metrics.fontBoundingBoxDescent) !== null && _j !== void 0 ? _j : 21 * scaleFactor,
|
|
11792
|
+
hangingBaseline: (_k = metrics.hangingBaseline) !== null && _k !== void 0 ? _k : 72.80000305175781 * scaleFactor,
|
|
11793
|
+
ideographicBaseline: (_l = metrics.ideographicBaseline) !== null && _l !== void 0 ? _l : -21 * scaleFactor,
|
|
11809
11794
|
width: metrics.width,
|
|
11810
11795
|
height: fontSize,
|
|
11811
11796
|
};
|
|
@@ -11966,7 +11951,7 @@
|
|
|
11966
11951
|
'lineHeight',
|
|
11967
11952
|
'letterSpacing',
|
|
11968
11953
|
];
|
|
11969
|
-
(0,
|
|
11954
|
+
(0, Global_2$2._registerNode)(Text);
|
|
11970
11955
|
Factory_1$i.Factory.overWriteSetter(Text, 'width', (0, Validators_1$i.getNumberOrAutoValidator)());
|
|
11971
11956
|
Factory_1$i.Factory.overWriteSetter(Text, 'height', (0, Validators_1$i.getNumberOrAutoValidator)());
|
|
11972
11957
|
Factory_1$i.Factory.addGetterSetter(Text, 'direction', INHERIT);
|
|
@@ -12674,6 +12659,9 @@
|
|
|
12674
12659
|
});
|
|
12675
12660
|
}
|
|
12676
12661
|
_handleMouseDown(e) {
|
|
12662
|
+
if (this._transforming) {
|
|
12663
|
+
return;
|
|
12664
|
+
}
|
|
12677
12665
|
this._movingAnchorName = e.target.name().split(' ')[0];
|
|
12678
12666
|
var attrs = this._getNodeRect();
|
|
12679
12667
|
var width = attrs.width;
|
|
@@ -14521,6 +14509,47 @@
|
|
|
14521
14509
|
// By use of this software, its documentation or related materials, you
|
|
14522
14510
|
// acknowledge and accept the above terms.
|
|
14523
14511
|
///////////////////////////////////////////////////////////////////////////////
|
|
14512
|
+
/**
|
|
14513
|
+
* Defines type of markup object. For `VisualizeJS` markup only the `Line` and `Text` markup
|
|
14514
|
+
* objects are supported.
|
|
14515
|
+
*/
|
|
14516
|
+
var MarkupMode;
|
|
14517
|
+
(function (MarkupMode) {
|
|
14518
|
+
MarkupMode["SelectMarkup"] = "SelectMarkup";
|
|
14519
|
+
MarkupMode["Line"] = "Line";
|
|
14520
|
+
MarkupMode["Text"] = "Text";
|
|
14521
|
+
MarkupMode["Rectangle"] = "Rectangle";
|
|
14522
|
+
MarkupMode["Ellipse"] = "Ellipse";
|
|
14523
|
+
MarkupMode["Arrow"] = "Arrow";
|
|
14524
|
+
MarkupMode["Image"] = "Image";
|
|
14525
|
+
MarkupMode["Cloud"] = "Cloud";
|
|
14526
|
+
})(MarkupMode || (MarkupMode = {}));
|
|
14527
|
+
|
|
14528
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
14529
|
+
// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
|
|
14530
|
+
// All rights reserved.
|
|
14531
|
+
//
|
|
14532
|
+
// This software and its documentation and related materials are owned by
|
|
14533
|
+
// the Alliance. The software may only be incorporated into application
|
|
14534
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
14535
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
14536
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
14537
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
14538
|
+
// protected by copyright law and international treaty provisions. Application
|
|
14539
|
+
// programs incorporating this software must include the following statement
|
|
14540
|
+
// with their copyright notices:
|
|
14541
|
+
//
|
|
14542
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
14543
|
+
// license agreement with Open Design Alliance.
|
|
14544
|
+
// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
|
|
14545
|
+
// All rights reserved.
|
|
14546
|
+
//
|
|
14547
|
+
// By use of this software, its documentation or related materials, you
|
|
14548
|
+
// acknowledge and accept the above terms.
|
|
14549
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
14550
|
+
/**
|
|
14551
|
+
* Markup color.
|
|
14552
|
+
*/
|
|
14524
14553
|
class MarkupColor {
|
|
14525
14554
|
/**
|
|
14526
14555
|
* Color in #000000 format
|
|
@@ -15454,9 +15483,14 @@
|
|
|
15454
15483
|
},
|
|
15455
15484
|
],
|
|
15456
15485
|
]);
|
|
15486
|
+
/**
|
|
15487
|
+
* 2D markup core.
|
|
15488
|
+
*/
|
|
15457
15489
|
class KonvaMarkup {
|
|
15458
15490
|
constructor() {
|
|
15459
15491
|
this._isInitialized = false;
|
|
15492
|
+
this._markupIsActive = false;
|
|
15493
|
+
this._markupColor = new MarkupColor(255, 0, 0);
|
|
15460
15494
|
this._zIndex = 1;
|
|
15461
15495
|
this._markupContainerName = "markupContainer";
|
|
15462
15496
|
this.lineWidth = 4;
|
|
@@ -15494,15 +15528,17 @@
|
|
|
15494
15528
|
Object.values(MarkupMode).forEach((mode) => this.konvaLayerFind(mode).forEach((x) => x.move({ x: dX, y: dY })));
|
|
15495
15529
|
};
|
|
15496
15530
|
this.redirectToViewer = (event) => {
|
|
15497
|
-
this._viewer
|
|
15531
|
+
if (this._viewer)
|
|
15532
|
+
this._viewer.emit(event);
|
|
15498
15533
|
};
|
|
15499
15534
|
}
|
|
15500
|
-
initialize(
|
|
15535
|
+
initialize(canvas, canvasEvents, viewer, worldTransformer) {
|
|
15501
15536
|
if (!Konva)
|
|
15502
|
-
throw new Error('
|
|
15537
|
+
throw new Error('Markup: Error during initialization. Konva is not initialized. Update node_modules or add to your page <script src="https://unpkg.com/konva@9/konva.min.js"></script>');
|
|
15503
15538
|
this._viewer = viewer;
|
|
15539
|
+
this._worldTransformer = worldTransformer;
|
|
15504
15540
|
this._canvasOriginal = canvas;
|
|
15505
|
-
this._canvasEvents = canvasEvents;
|
|
15541
|
+
this._canvasEvents = canvasEvents !== null && canvasEvents !== void 0 ? canvasEvents : [];
|
|
15506
15542
|
this._markupContainer = document.createElement("div");
|
|
15507
15543
|
this._markupContainer.id = this._markupContainerName;
|
|
15508
15544
|
this._markupContainer.style.position = "absolute";
|
|
@@ -15512,33 +15548,36 @@
|
|
|
15512
15548
|
this._markupContainer.style.outline = "0px";
|
|
15513
15549
|
const parentDiv = this._canvasOriginal.parentElement;
|
|
15514
15550
|
parentDiv.appendChild(this._markupContainer);
|
|
15515
|
-
this._markupColor
|
|
15516
|
-
this._markupIsActive = false;
|
|
15551
|
+
this._markupColor.setColor(255, 0, 0);
|
|
15517
15552
|
this.initializeKonva();
|
|
15518
15553
|
this.resize();
|
|
15519
15554
|
this._canvasEvents.forEach((x) => this._markupContainer.addEventListener(x, this.redirectToViewer));
|
|
15520
|
-
this._viewer
|
|
15521
|
-
|
|
15522
|
-
|
|
15555
|
+
if (this._viewer) {
|
|
15556
|
+
this._viewer.addEventListener("resize", this.resize);
|
|
15557
|
+
this._viewer.addEventListener("changeactivedragger", this.changeActiveDragger);
|
|
15558
|
+
this._viewer.addEventListener("pan", this.pan);
|
|
15559
|
+
}
|
|
15523
15560
|
this._isInitialized = true;
|
|
15524
15561
|
}
|
|
15525
15562
|
dispose() {
|
|
15526
15563
|
if (!this._isInitialized)
|
|
15527
15564
|
return;
|
|
15565
|
+
if (this._viewer) {
|
|
15566
|
+
this._viewer.removeEventListener("pan", this.pan);
|
|
15567
|
+
this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
|
|
15568
|
+
this._viewer.removeEventListener("resize", this.resize);
|
|
15569
|
+
}
|
|
15528
15570
|
this._canvasEvents.forEach((x) => this._markupContainer.removeEventListener(x, this.redirectToViewer));
|
|
15529
|
-
this._viewer.removeEventListener("pan", this.pan);
|
|
15530
|
-
this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
|
|
15531
|
-
this._viewer.removeEventListener("resize", this.resize);
|
|
15532
15571
|
this.destroyKonva();
|
|
15533
15572
|
this._markupContainer.remove();
|
|
15534
15573
|
this._markupContainer = undefined;
|
|
15535
15574
|
this._canvasOriginal = undefined;
|
|
15536
15575
|
this._viewer = undefined;
|
|
15576
|
+
this._worldTransformer = undefined;
|
|
15577
|
+
this._markupIsActive = false;
|
|
15537
15578
|
this._isInitialized = false;
|
|
15538
15579
|
}
|
|
15539
|
-
|
|
15540
|
-
return null;
|
|
15541
|
-
}
|
|
15580
|
+
syncOverlay() { }
|
|
15542
15581
|
clearOverlay() {
|
|
15543
15582
|
this.removeTextInput();
|
|
15544
15583
|
this.removeImageInput();
|
|
@@ -15577,9 +15616,6 @@
|
|
|
15577
15616
|
this.loadMarkup(viewpoint);
|
|
15578
15617
|
}
|
|
15579
15618
|
getViewpoint() {
|
|
15580
|
-
// TODO: at the current 25.2 state we need VisualizeJS here and below. In the future we need to use it as an external interface.
|
|
15581
|
-
if (!this._viewer.visualizeJs)
|
|
15582
|
-
return {};
|
|
15583
15619
|
const viewpoint = {
|
|
15584
15620
|
lines: [],
|
|
15585
15621
|
texts: [],
|
|
@@ -15600,7 +15636,7 @@
|
|
|
15600
15636
|
return viewpoint;
|
|
15601
15637
|
}
|
|
15602
15638
|
createObject(type, params) {
|
|
15603
|
-
let object;
|
|
15639
|
+
let object = null;
|
|
15604
15640
|
let zIndex = this._zIndex;
|
|
15605
15641
|
// TODO: factory?
|
|
15606
15642
|
switch (type.toLocaleLowerCase()) {
|
|
@@ -15996,9 +16032,7 @@
|
|
|
15996
16032
|
// we need getAbsoluteTransform because inside Konva position starts from {0, 0}
|
|
15997
16033
|
// https://stackoverflow.com/a/57641487 - check answer's comments
|
|
15998
16034
|
const atPoint = absoluteTransform.point({ x: linePoints[i], y: linePoints[i + 1] });
|
|
15999
|
-
const worldPoint = this.
|
|
16000
|
-
.visViewer()
|
|
16001
|
-
.screenToWorld(atPoint.x * window.devicePixelRatio, atPoint.y * window.devicePixelRatio);
|
|
16035
|
+
const worldPoint = this._worldTransformer.screenToWorld(atPoint);
|
|
16002
16036
|
worldPoints.push(worldPoint);
|
|
16003
16037
|
}
|
|
16004
16038
|
const konvaLine = new KonvaLine(null, line);
|
|
@@ -16015,25 +16049,20 @@
|
|
|
16015
16049
|
getMarkupTexts() {
|
|
16016
16050
|
const texts = [];
|
|
16017
16051
|
const textSize = 0.02;
|
|
16018
|
-
|
|
16019
|
-
const projMtrx = this._viewer.visViewer().activeView.projectionMatrix;
|
|
16020
|
-
const mtrxNumber = projMtrx.get(1, 1);
|
|
16021
|
-
const tol = 1.0e-6;
|
|
16022
|
-
if (mtrxNumber > tol || mtrxNumber < -tol) {
|
|
16023
|
-
textScale = 1 / mtrxNumber;
|
|
16024
|
-
}
|
|
16052
|
+
const textScale = this._worldTransformer.getScale();
|
|
16025
16053
|
this.konvaLayerFind(MarkupMode.Text).forEach((text) => {
|
|
16026
16054
|
if (!text)
|
|
16027
16055
|
return;
|
|
16028
|
-
const position = this.
|
|
16029
|
-
.
|
|
16030
|
-
|
|
16056
|
+
const position = this._worldTransformer.screenToWorld({
|
|
16057
|
+
x: text.x(),
|
|
16058
|
+
y: text.y(),
|
|
16059
|
+
});
|
|
16031
16060
|
const shape = new KonvaText(null, text);
|
|
16032
16061
|
texts.push({
|
|
16033
16062
|
id: shape.id(),
|
|
16034
16063
|
position: this.getPoint3dFromArray(position),
|
|
16035
16064
|
text: shape.getText(),
|
|
16036
|
-
text_size: textSize * textScale,
|
|
16065
|
+
text_size: textSize * textScale.y,
|
|
16037
16066
|
angle: shape.getRotation(),
|
|
16038
16067
|
color: shape.getColor(),
|
|
16039
16068
|
font_size: shape.getFontSize(),
|
|
@@ -16045,9 +16074,7 @@
|
|
|
16045
16074
|
const rectangles = [];
|
|
16046
16075
|
this.konvaLayerFind(MarkupMode.Rectangle).forEach((rect) => {
|
|
16047
16076
|
const position = rect.position();
|
|
16048
|
-
const worldPoint = this.
|
|
16049
|
-
.visViewer()
|
|
16050
|
-
.screenToWorld(position.x * window.devicePixelRatio, position.y * window.devicePixelRatio);
|
|
16077
|
+
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
16051
16078
|
const shape = new KonvaRectangle(null, rect);
|
|
16052
16079
|
rectangles.push({
|
|
16053
16080
|
id: shape.id(),
|
|
@@ -16064,9 +16091,7 @@
|
|
|
16064
16091
|
const ellipses = [];
|
|
16065
16092
|
this.konvaLayerFind(MarkupMode.Ellipse).forEach((ellipse) => {
|
|
16066
16093
|
const position = ellipse.position();
|
|
16067
|
-
const worldPoint = this.
|
|
16068
|
-
.visViewer()
|
|
16069
|
-
.screenToWorld(position.x * window.devicePixelRatio, position.y * window.devicePixelRatio);
|
|
16094
|
+
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
16070
16095
|
const shape = new KonvaEllipse(null, ellipse);
|
|
16071
16096
|
ellipses.push({
|
|
16072
16097
|
id: shape.id(),
|
|
@@ -16084,13 +16109,9 @@
|
|
|
16084
16109
|
// we need getAbsoluteTransform because inside Konva position starts from {0, 0}
|
|
16085
16110
|
const absoluteTransform = arrow.getAbsoluteTransform();
|
|
16086
16111
|
const atStartPoint = absoluteTransform.point({ x: arrow.points()[0], y: arrow.points()[1] });
|
|
16087
|
-
const worldStartPoint = this.
|
|
16088
|
-
.visViewer()
|
|
16089
|
-
.screenToWorld(atStartPoint.x * window.devicePixelRatio, atStartPoint.y * window.devicePixelRatio);
|
|
16112
|
+
const worldStartPoint = this._worldTransformer.screenToWorld(atStartPoint);
|
|
16090
16113
|
const atEndPoint = absoluteTransform.point({ x: arrow.points()[2], y: arrow.points()[3] });
|
|
16091
|
-
const worldEndPoint = this.
|
|
16092
|
-
.visViewer()
|
|
16093
|
-
.screenToWorld(atEndPoint.x * window.devicePixelRatio, atEndPoint.y * window.devicePixelRatio);
|
|
16114
|
+
const worldEndPoint = this._worldTransformer.screenToWorld(atEndPoint);
|
|
16094
16115
|
const shape = new KonvaArrow(null, arrow);
|
|
16095
16116
|
arrows.push({
|
|
16096
16117
|
id: shape.id(),
|
|
@@ -16105,9 +16126,7 @@
|
|
|
16105
16126
|
const images = [];
|
|
16106
16127
|
this.konvaLayerFind(MarkupMode.Image).forEach((image) => {
|
|
16107
16128
|
const position = image.position();
|
|
16108
|
-
const worldPoint = this.
|
|
16109
|
-
.visViewer()
|
|
16110
|
-
.screenToWorld(position.x * window.devicePixelRatio, position.y * window.devicePixelRatio);
|
|
16129
|
+
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
16111
16130
|
const shape = new KonvaImage(null, image);
|
|
16112
16131
|
images.push({
|
|
16113
16132
|
id: shape.id(),
|
|
@@ -16123,9 +16142,7 @@
|
|
|
16123
16142
|
const clouds = [];
|
|
16124
16143
|
this.konvaLayerFind(MarkupMode.Cloud).forEach((cloud) => {
|
|
16125
16144
|
const position = cloud.position();
|
|
16126
|
-
const worldPoint = this.
|
|
16127
|
-
.visViewer()
|
|
16128
|
-
.screenToWorld(position.x * window.devicePixelRatio, position.y * window.devicePixelRatio);
|
|
16145
|
+
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
16129
16146
|
const shape = new KonvaCloud(null, cloud);
|
|
16130
16147
|
clouds.push({
|
|
16131
16148
|
id: shape.id(),
|
|
@@ -16143,36 +16160,36 @@
|
|
|
16143
16160
|
(_a = viewpoint.lines) === null || _a === void 0 ? void 0 : _a.forEach((vpLine) => {
|
|
16144
16161
|
const linePoints = [];
|
|
16145
16162
|
vpLine.points.forEach((point) => {
|
|
16146
|
-
const screenPoint =
|
|
16163
|
+
const screenPoint = this._worldTransformer.worldToScreen(point);
|
|
16147
16164
|
linePoints.push(screenPoint.x);
|
|
16148
16165
|
linePoints.push(screenPoint.y);
|
|
16149
16166
|
});
|
|
16150
16167
|
this.addLine(linePoints, vpLine.color, vpLine.type, vpLine.width, vpLine.id);
|
|
16151
16168
|
});
|
|
16152
16169
|
(_b = viewpoint.texts) === null || _b === void 0 ? void 0 : _b.forEach((vpText) => {
|
|
16153
|
-
const screenPoint = worldToScreen(
|
|
16170
|
+
const screenPoint = this._worldTransformer.worldToScreen(vpText.position);
|
|
16154
16171
|
this.addText(vpText.text, screenPoint, vpText.angle, vpText.color, vpText.text_size, vpText.font_size, vpText.id);
|
|
16155
16172
|
});
|
|
16156
16173
|
(_c = viewpoint.rectangles) === null || _c === void 0 ? void 0 : _c.forEach((vpRect) => {
|
|
16157
|
-
const screenPoint = worldToScreen(
|
|
16158
|
-
this.addRectangle(
|
|
16174
|
+
const screenPoint = this._worldTransformer.worldToScreen(vpRect.position);
|
|
16175
|
+
this.addRectangle(screenPoint, vpRect.width, vpRect.height, vpRect.line_width, vpRect.color, vpRect.id);
|
|
16159
16176
|
});
|
|
16160
16177
|
(_d = viewpoint.ellipses) === null || _d === void 0 ? void 0 : _d.forEach((vpEllipse) => {
|
|
16161
|
-
const screenPoint = worldToScreen(
|
|
16162
|
-
this.addEllipse(
|
|
16178
|
+
const screenPoint = this._worldTransformer.worldToScreen(vpEllipse.position);
|
|
16179
|
+
this.addEllipse(screenPoint, vpEllipse.radius, vpEllipse.line_width, vpEllipse.color, vpEllipse.id);
|
|
16163
16180
|
});
|
|
16164
16181
|
(_e = viewpoint.arrows) === null || _e === void 0 ? void 0 : _e.forEach((vpArrow) => {
|
|
16165
|
-
const startPoint = worldToScreen(
|
|
16166
|
-
const endPoint = worldToScreen(
|
|
16167
|
-
this.addArrow(
|
|
16182
|
+
const startPoint = this._worldTransformer.worldToScreen(vpArrow.start);
|
|
16183
|
+
const endPoint = this._worldTransformer.worldToScreen(vpArrow.end);
|
|
16184
|
+
this.addArrow(startPoint, endPoint, vpArrow.color, vpArrow.id);
|
|
16168
16185
|
});
|
|
16169
16186
|
(_f = viewpoint.clouds) === null || _f === void 0 ? void 0 : _f.forEach((vpCloud) => {
|
|
16170
|
-
const screenPoint = worldToScreen(
|
|
16171
|
-
this.addCloud(
|
|
16187
|
+
const screenPoint = this._worldTransformer.worldToScreen(vpCloud.position);
|
|
16188
|
+
this.addCloud(screenPoint, vpCloud.width, vpCloud.height, vpCloud.line_width, vpCloud.color, vpCloud.id);
|
|
16172
16189
|
});
|
|
16173
16190
|
(_g = viewpoint.images) === null || _g === void 0 ? void 0 : _g.forEach((vpImage) => {
|
|
16174
|
-
const screenPoint = worldToScreen(
|
|
16175
|
-
this.addImage(
|
|
16191
|
+
const screenPoint = this._worldTransformer.worldToScreen(vpImage.position);
|
|
16192
|
+
this.addImage(screenPoint, vpImage.src, vpImage.width, vpImage.height, vpImage.id);
|
|
16176
16193
|
});
|
|
16177
16194
|
}
|
|
16178
16195
|
combineMarkupWithDrawing() {
|
|
@@ -16287,18 +16304,20 @@
|
|
|
16287
16304
|
this._imageInputPos = null;
|
|
16288
16305
|
}
|
|
16289
16306
|
addText(specifiedText, position, angle, color, textSize, fontSize, id) {
|
|
16307
|
+
const trNodes = this._konvaTransformer.nodes();
|
|
16308
|
+
if (trNodes.length > 0) {
|
|
16309
|
+
// in case of edit - remove old Konva.Text object
|
|
16310
|
+
trNodes[0].destroy();
|
|
16311
|
+
this._konvaTransformer.nodes([]);
|
|
16312
|
+
}
|
|
16313
|
+
this.removeTextInput();
|
|
16290
16314
|
if (specifiedText) {
|
|
16291
|
-
const
|
|
16315
|
+
const tolerance = 1.0e-6;
|
|
16292
16316
|
// in case we have old viewpoint without font_size
|
|
16293
|
-
if (textSize && textSize >
|
|
16317
|
+
if (textSize && textSize > tolerance && (!fontSize || fontSize < tolerance)) {
|
|
16294
16318
|
const size = 0.02;
|
|
16295
|
-
|
|
16296
|
-
|
|
16297
|
-
const mtrxNumber = projMtrx.get(1, 1);
|
|
16298
|
-
if (mtrxNumber > tol || mtrxNumber < -tol) {
|
|
16299
|
-
scale = 1 / mtrxNumber;
|
|
16300
|
-
}
|
|
16301
|
-
fontSize = textSize / (scale / size) / 34;
|
|
16319
|
+
const scale = this._worldTransformer.getScale();
|
|
16320
|
+
fontSize = textSize / (scale.y / size) / 34;
|
|
16302
16321
|
}
|
|
16303
16322
|
const konvaText = new KonvaText({
|
|
16304
16323
|
position: { x: position.x, y: position.y },
|
|
@@ -16309,15 +16328,8 @@
|
|
|
16309
16328
|
id,
|
|
16310
16329
|
});
|
|
16311
16330
|
this._konvaLayer.add(konvaText.ref());
|
|
16331
|
+
return konvaText;
|
|
16312
16332
|
}
|
|
16313
|
-
const trNodes = this._konvaTransformer.nodes();
|
|
16314
|
-
if (trNodes.length > 0) {
|
|
16315
|
-
// in case of edit - remove old Konva.Text object
|
|
16316
|
-
trNodes[0].destroy();
|
|
16317
|
-
this._konvaTransformer.nodes([]);
|
|
16318
|
-
}
|
|
16319
|
-
this.removeTextInput();
|
|
16320
|
-
return;
|
|
16321
16333
|
}
|
|
16322
16334
|
addRectangle(position, width, height, lineWidth, color, id) {
|
|
16323
16335
|
if (!position)
|
|
@@ -16523,21 +16535,43 @@
|
|
|
16523
16535
|
}
|
|
16524
16536
|
}
|
|
16525
16537
|
|
|
16538
|
+
const OVERLAY_VIEW_NAME = "$OVERLAY_VIEW_NAME";
|
|
16526
16539
|
class VisualizeMarkup {
|
|
16527
16540
|
constructor() {
|
|
16528
16541
|
this._markupColor = { r: 255, g: 0, b: 0 };
|
|
16529
16542
|
this.lineWidth = 4;
|
|
16530
16543
|
this.fontSize = 34;
|
|
16531
16544
|
}
|
|
16532
|
-
initialize(
|
|
16545
|
+
initialize(canvas, canvasEvents, viewer, worldTransformer) {
|
|
16533
16546
|
this._viewer = viewer;
|
|
16547
|
+
this._viewer.registerDragger("Line", OdaLineDragger);
|
|
16548
|
+
this._viewer.registerDragger("Text", OdaTextDragger);
|
|
16534
16549
|
}
|
|
16535
16550
|
dispose() { }
|
|
16536
|
-
|
|
16537
|
-
|
|
16538
|
-
|
|
16539
|
-
|
|
16540
|
-
|
|
16551
|
+
syncOverlay() {
|
|
16552
|
+
if (!this._viewer.visualizeJs)
|
|
16553
|
+
return;
|
|
16554
|
+
const visViewer = this._viewer.visViewer();
|
|
16555
|
+
const activeView = visViewer.activeView;
|
|
16556
|
+
let overlayView = visViewer.getViewByName(OVERLAY_VIEW_NAME);
|
|
16557
|
+
if (!overlayView) {
|
|
16558
|
+
const overlayModel = visViewer.getMarkupModel();
|
|
16559
|
+
const pDevice = visViewer.getActiveDevice();
|
|
16560
|
+
overlayView = pDevice.createView(OVERLAY_VIEW_NAME, false);
|
|
16561
|
+
overlayView.addModel(overlayModel);
|
|
16562
|
+
activeView.addSibling(overlayView);
|
|
16563
|
+
pDevice.addView(overlayView);
|
|
16564
|
+
}
|
|
16565
|
+
overlayView.viewPosition = activeView.viewPosition;
|
|
16566
|
+
overlayView.viewTarget = activeView.viewTarget;
|
|
16567
|
+
overlayView.upVector = activeView.upVector;
|
|
16568
|
+
overlayView.viewFieldWidth = activeView.viewFieldWidth;
|
|
16569
|
+
overlayView.viewFieldHeight = activeView.viewFieldHeight;
|
|
16570
|
+
const viewPort = overlayView.getViewport();
|
|
16571
|
+
overlayView.setViewport(viewPort.lowerLeft, viewPort.upperRight);
|
|
16572
|
+
overlayView.vportRect = activeView.vportRect;
|
|
16573
|
+
this._viewer.update();
|
|
16574
|
+
return overlayView;
|
|
16541
16575
|
}
|
|
16542
16576
|
clearOverlay() {
|
|
16543
16577
|
if (!this._viewer.visualizeJs)
|
|
@@ -16701,41 +16735,37 @@
|
|
|
16701
16735
|
}
|
|
16702
16736
|
|
|
16703
16737
|
///////////////////////////////////////////////////////////////////////////////
|
|
16738
|
+
/**
|
|
16739
|
+
* The markup type: `Visualize` (deprecated) or `Konva`.
|
|
16740
|
+
*/
|
|
16741
|
+
exports.MarkupType = void 0;
|
|
16742
|
+
(function (MarkupType) {
|
|
16743
|
+
MarkupType[MarkupType["Unknown"] = 0] = "Unknown";
|
|
16744
|
+
MarkupType["Konva"] = "Konva";
|
|
16745
|
+
MarkupType["Visualize"] = "Visualize";
|
|
16746
|
+
})(exports.MarkupType || (exports.MarkupType = {}));
|
|
16704
16747
|
class MarkupFactory {
|
|
16705
|
-
|
|
16706
|
-
* Initialize {@link IMarkup} instance
|
|
16707
|
-
*
|
|
16708
|
-
* @param markupType - Specifies version of the markup support. Two variants of markup
|
|
16709
|
-
* support are implemented: old "Visualize" and new "Konva". Default is "Konva". {@link MarkupType}
|
|
16710
|
-
*/
|
|
16711
|
-
static createMarkup(markupType) {
|
|
16748
|
+
static createMarkup(markupType = exports.MarkupType.Konva) {
|
|
16712
16749
|
let markup;
|
|
16713
16750
|
switch (markupType) {
|
|
16714
|
-
case MarkupType.Konva:
|
|
16715
|
-
markup =
|
|
16751
|
+
case exports.MarkupType.Konva:
|
|
16752
|
+
markup = new KonvaMarkup();
|
|
16716
16753
|
break;
|
|
16717
|
-
case MarkupType.Visualize:
|
|
16718
|
-
markup =
|
|
16754
|
+
case exports.MarkupType.Visualize:
|
|
16755
|
+
markup = new VisualizeMarkup();
|
|
16719
16756
|
break;
|
|
16720
16757
|
default:
|
|
16721
|
-
throw new Error("Error during Markup
|
|
16758
|
+
throw new Error("Error during Markup initialization. Unknown Markup type.");
|
|
16722
16759
|
}
|
|
16723
16760
|
return markup;
|
|
16724
16761
|
}
|
|
16725
|
-
static createKonva() {
|
|
16726
|
-
return new KonvaMarkup();
|
|
16727
|
-
}
|
|
16728
|
-
static createVisualize() {
|
|
16729
|
-
return new VisualizeMarkup();
|
|
16730
|
-
}
|
|
16731
16762
|
}
|
|
16732
16763
|
|
|
16733
16764
|
///////////////////////////////////////////////////////////////////////////////
|
|
16734
|
-
const OVERLAY_VIEW_NAME = "$OVERLAY_VIEW_NAME";
|
|
16735
16765
|
const isExist = (value) => value !== undefined && value !== null;
|
|
16736
16766
|
/**
|
|
16737
16767
|
* The `Client.js` library class that provides methods to integrate with the
|
|
16738
|
-
*
|
|
16768
|
+
* {@link https://cloud.opendesign.com/docs/index.html#/visualizejs | VisualizeJS} library.
|
|
16739
16769
|
*/
|
|
16740
16770
|
class Viewer extends EventEmitter2 {
|
|
16741
16771
|
/**
|
|
@@ -16749,13 +16779,13 @@
|
|
|
16749
16779
|
* _Note: Your own `VisualizeJS` library version must match the version of the `Client.js`
|
|
16750
16780
|
* you are using._
|
|
16751
16781
|
* @param params.enableAutoUpdate - Enable auto-update of the viewer after any changes. If
|
|
16752
|
-
* the auto-update is disabled, you need to
|
|
16753
|
-
*
|
|
16754
|
-
* @param params.markupType - Specifies
|
|
16755
|
-
*
|
|
16782
|
+
* the auto-update is disabled, you need to register the `update` event handler and update
|
|
16783
|
+
* the viewer and the active dragger manually. Default is `true`.
|
|
16784
|
+
* @param params.markupType - Specifies type of the markup core: `Visualize` (deprecated) or
|
|
16785
|
+
* `Konva`. Default is `Konva`.
|
|
16756
16786
|
*/
|
|
16757
16787
|
constructor(client, params = {}) {
|
|
16758
|
-
var _a
|
|
16788
|
+
var _a;
|
|
16759
16789
|
super();
|
|
16760
16790
|
this._visualizeJsUrl = "";
|
|
16761
16791
|
this.frameId = 0;
|
|
@@ -16766,7 +16796,6 @@
|
|
|
16766
16796
|
this._zoomWheelDragger = null;
|
|
16767
16797
|
this._gestureManager = null;
|
|
16768
16798
|
this._renderTime = 0;
|
|
16769
|
-
this.markup = MarkupFactory.createMarkup((_a = params.markupType) !== null && _a !== void 0 ? _a : MarkupType.Konva);
|
|
16770
16799
|
this.draggerFactory = new Map();
|
|
16771
16800
|
this.registerDragger("Pan", OdPanDragger);
|
|
16772
16801
|
this.registerDragger("Orbit", OdOrbitDragger);
|
|
@@ -16778,32 +16807,37 @@
|
|
|
16778
16807
|
this.registerDragger("CuttingPlaneYAxis", OdCuttingPlaneYAxisDragger);
|
|
16779
16808
|
this.registerDragger("CuttingPlaneZAxis", OdCuttingPlaneZAxisDragger);
|
|
16780
16809
|
this.registerDragger("Walk", OdaWalkDragger);
|
|
16781
|
-
const markupDraggers = this.markup.getDraggers();
|
|
16782
|
-
markupDraggers === null || markupDraggers === void 0 ? void 0 : markupDraggers.forEach((value, key) => {
|
|
16783
|
-
this.registerDragger(key, value);
|
|
16784
|
-
});
|
|
16785
16810
|
this.canvasEvents = CANVAS_EVENTS.slice();
|
|
16786
16811
|
this.canvaseventlistener = (event) => this.emit(event);
|
|
16787
|
-
this._enableAutoUpdate = (
|
|
16812
|
+
this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== void 0 ? _a : true;
|
|
16788
16813
|
this._isNeedRender = false;
|
|
16789
16814
|
this._isRunAsyncUpdate = false;
|
|
16790
16815
|
this.render = this.render.bind(this);
|
|
16791
16816
|
this.resize = this.resize.bind(this);
|
|
16817
|
+
this._markup = MarkupFactory.createMarkup(params.markupType);
|
|
16792
16818
|
}
|
|
16793
16819
|
/**
|
|
16794
|
-
*
|
|
16820
|
+
* Viewer options.
|
|
16795
16821
|
*/
|
|
16796
16822
|
get options() {
|
|
16797
16823
|
return this._options;
|
|
16798
16824
|
}
|
|
16799
16825
|
/**
|
|
16800
|
-
* `VisualizeJS` library URL. Use {@link
|
|
16826
|
+
* `VisualizeJS` library URL. Use {@link configure | configure()} to change library URL.
|
|
16801
16827
|
*
|
|
16802
16828
|
* @readonly
|
|
16803
16829
|
*/
|
|
16804
16830
|
get visualizeJsUrl() {
|
|
16805
16831
|
return this._visualizeJsUrl;
|
|
16806
16832
|
}
|
|
16833
|
+
/**
|
|
16834
|
+
* 2D markup core.
|
|
16835
|
+
*
|
|
16836
|
+
* @readonly
|
|
16837
|
+
*/
|
|
16838
|
+
get markup() {
|
|
16839
|
+
return this._markup;
|
|
16840
|
+
}
|
|
16807
16841
|
/**
|
|
16808
16842
|
* Change the viewer configuration parameters.
|
|
16809
16843
|
*
|
|
@@ -16815,25 +16849,19 @@
|
|
|
16815
16849
|
this._visualizeJsUrl = params.visualizeJsUrl || "https://opencloud.azureedge.net/libs/visualizejs/master/Visualize.js";
|
|
16816
16850
|
return this;
|
|
16817
16851
|
}
|
|
16818
|
-
/**
|
|
16819
|
-
* A [Viewer]{@link Viewer} event measuring progress of loading a `VisualizeJS` library.
|
|
16820
|
-
*
|
|
16821
|
-
* @property {string} type - `visualizeprogress`
|
|
16822
|
-
* @property {number} loaded - A 64-bit unsigned integer value indicating the amount of work
|
|
16823
|
-
* already performed by the underlying process. The ratio of work done can be calculated by
|
|
16824
|
-
* dividing total by the value of this property.
|
|
16825
|
-
* @property {number} total - A 64-bit unsigned integer representing the total amount of work
|
|
16826
|
-
* that the underlying process is in the progress of performing.
|
|
16827
|
-
* @event visualizeprogress
|
|
16828
|
-
*/
|
|
16829
16852
|
/**
|
|
16830
16853
|
* Load `VisualizeJS` module and initialize it with the specified canvas. Call
|
|
16831
|
-
* {@link
|
|
16854
|
+
* {@link dispose | dispose()} to release allocated resources.
|
|
16832
16855
|
*
|
|
16833
|
-
*
|
|
16834
|
-
*
|
|
16856
|
+
* Fires:
|
|
16857
|
+
*
|
|
16858
|
+
* - {@link InitializeProgressEvent | initializeprogress}
|
|
16859
|
+
*
|
|
16860
|
+
* @param canvas -
|
|
16861
|
+
* {@link https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement | HTMLCanvasElement}
|
|
16862
|
+
* for `VisualizeJS`.
|
|
16835
16863
|
* @param onProgress - A callback function that handles events measuring progress of loading
|
|
16836
|
-
* of the `VisualizeJS` library.
|
|
16864
|
+
* of the `VisualizeJS` library.
|
|
16837
16865
|
*/
|
|
16838
16866
|
async initialize(canvas, onProgress) {
|
|
16839
16867
|
this.addEventListener("optionschange", (event) => this.syncOptions(event.data));
|
|
@@ -16856,7 +16884,7 @@
|
|
|
16856
16884
|
this.visualizeJs.Viewer.create();
|
|
16857
16885
|
this.canvas = canvas;
|
|
16858
16886
|
this.canvasEvents.forEach((x) => canvas.addEventListener(x, this.canvaseventlistener));
|
|
16859
|
-
this.
|
|
16887
|
+
this._markup.initialize(this.canvas, this.canvasEvents, this, this);
|
|
16860
16888
|
this._resizeObserver = new ResizeObserver(this.resize);
|
|
16861
16889
|
this._resizeObserver.observe(canvas.parentElement);
|
|
16862
16890
|
this.resize();
|
|
@@ -16893,7 +16921,7 @@
|
|
|
16893
16921
|
if (this._resizeObserver)
|
|
16894
16922
|
this._resizeObserver.disconnect();
|
|
16895
16923
|
this._resizeObserver = undefined;
|
|
16896
|
-
this.
|
|
16924
|
+
this._markup.dispose();
|
|
16897
16925
|
if (this.canvas) {
|
|
16898
16926
|
this.canvasEvents.forEach((x) => this.canvas.removeEventListener(x, this.canvaseventlistener));
|
|
16899
16927
|
this.canvas = undefined;
|
|
@@ -17194,14 +17222,13 @@
|
|
|
17194
17222
|
return this._activeDragger;
|
|
17195
17223
|
}
|
|
17196
17224
|
/**
|
|
17197
|
-
* Set active dragger. `Viewer` must be
|
|
17198
|
-
* dragger or exception is thrown.
|
|
17225
|
+
* Set active dragger. `Viewer` must be initialized before enable dragger or exception is thrown.
|
|
17199
17226
|
*
|
|
17200
17227
|
* Fires:
|
|
17201
17228
|
*
|
|
17202
17229
|
* - {@link ChangeActiveDraggerEvent | changeactivedragger}
|
|
17203
17230
|
*
|
|
17204
|
-
* @param name - Dragger name. Can be one of the {@link
|
|
17231
|
+
* @param name - Dragger name. Can be one of the {@link draggers} list.
|
|
17205
17232
|
* @returns Returns active dragger instance or `null` if there is no dragger with the given name.
|
|
17206
17233
|
*/
|
|
17207
17234
|
setActiveDragger(name) {
|
|
@@ -17256,35 +17283,13 @@
|
|
|
17256
17283
|
* Remove markup overlay.
|
|
17257
17284
|
*/
|
|
17258
17285
|
clearOverlay() {
|
|
17259
|
-
this.
|
|
17286
|
+
this._markup.clearOverlay();
|
|
17260
17287
|
}
|
|
17261
17288
|
/**
|
|
17262
17289
|
* Synchronize markup overlay.
|
|
17263
17290
|
*/
|
|
17264
17291
|
syncOverlay() {
|
|
17265
|
-
|
|
17266
|
-
return;
|
|
17267
|
-
const visViewer = this.visViewer();
|
|
17268
|
-
const activeView = visViewer.activeView;
|
|
17269
|
-
let overlayView = visViewer.getViewByName(OVERLAY_VIEW_NAME);
|
|
17270
|
-
if (!overlayView) {
|
|
17271
|
-
const overlayModel = visViewer.getMarkupModel();
|
|
17272
|
-
const pDevice = visViewer.getActiveDevice();
|
|
17273
|
-
overlayView = pDevice.createView(OVERLAY_VIEW_NAME, false);
|
|
17274
|
-
overlayView.addModel(overlayModel);
|
|
17275
|
-
activeView.addSibling(overlayView);
|
|
17276
|
-
pDevice.addView(overlayView);
|
|
17277
|
-
}
|
|
17278
|
-
overlayView.viewPosition = activeView.viewPosition;
|
|
17279
|
-
overlayView.viewTarget = activeView.viewTarget;
|
|
17280
|
-
overlayView.upVector = activeView.upVector;
|
|
17281
|
-
overlayView.viewFieldWidth = activeView.viewFieldWidth;
|
|
17282
|
-
overlayView.viewFieldHeight = activeView.viewFieldHeight;
|
|
17283
|
-
const viewPort = overlayView.getViewport();
|
|
17284
|
-
overlayView.setViewport(viewPort.lowerLeft, viewPort.upperRight);
|
|
17285
|
-
overlayView.vportRect = activeView.vportRect;
|
|
17286
|
-
this.update();
|
|
17287
|
-
return overlayView;
|
|
17292
|
+
return this._markup.syncOverlay();
|
|
17288
17293
|
}
|
|
17289
17294
|
/**
|
|
17290
17295
|
* Returns `true` if current drawing is 3D drawing.
|
|
@@ -17300,6 +17305,38 @@
|
|
|
17300
17305
|
return extHeight !== 0;
|
|
17301
17306
|
//return visViewer.activeView.upVector[1] >= 0.95;
|
|
17302
17307
|
}
|
|
17308
|
+
screenToWorld(position) {
|
|
17309
|
+
return this.visViewer().screenToWorld(position.x * window.devicePixelRatio, position.y * window.devicePixelRatio);
|
|
17310
|
+
}
|
|
17311
|
+
worldToScreen(position) {
|
|
17312
|
+
if (!this.visualizeJs)
|
|
17313
|
+
return position;
|
|
17314
|
+
const activeView = this.visViewer().activeView;
|
|
17315
|
+
const worldMatrix = activeView.worldToDeviceMatrix;
|
|
17316
|
+
const worldPoint = this.visLib().Point3d.createFromArray([position.x, position.y, position.z]);
|
|
17317
|
+
const devicePoint = worldPoint.transformBy(worldMatrix);
|
|
17318
|
+
const result = { x: devicePoint.x / window.devicePixelRatio, y: devicePoint.y / window.devicePixelRatio };
|
|
17319
|
+
devicePoint.delete();
|
|
17320
|
+
worldPoint.delete();
|
|
17321
|
+
worldMatrix.delete();
|
|
17322
|
+
activeView.delete();
|
|
17323
|
+
return result;
|
|
17324
|
+
}
|
|
17325
|
+
getScale() {
|
|
17326
|
+
const result = { x: 1.0, y: 1.0, z: 1.0 };
|
|
17327
|
+
const projMatrix = this.visViewer().activeView.projectionMatrix;
|
|
17328
|
+
const tolerance = 1.0e-6;
|
|
17329
|
+
const x = projMatrix.get(1, 1);
|
|
17330
|
+
if (x > tolerance || x < -tolerance)
|
|
17331
|
+
result.x = 1 / result.x;
|
|
17332
|
+
const y = projMatrix.get(1, 1);
|
|
17333
|
+
if (y > tolerance || y < -tolerance)
|
|
17334
|
+
result.y = 1 / result.y;
|
|
17335
|
+
const z = projMatrix.get(2, 2);
|
|
17336
|
+
if (z > tolerance || z < -tolerance)
|
|
17337
|
+
result.z = 1 / result.z;
|
|
17338
|
+
return result;
|
|
17339
|
+
}
|
|
17303
17340
|
/**
|
|
17304
17341
|
* Returns a list of original handles for the selected entities.
|
|
17305
17342
|
*/
|
|
@@ -17324,7 +17361,6 @@
|
|
|
17324
17361
|
* Load model references into the viewer. References are images, fonts, or any other files to
|
|
17325
17362
|
* correct rendering of the model.
|
|
17326
17363
|
*
|
|
17327
|
-
* @async
|
|
17328
17364
|
* @param model - Instance of model with references. If a `File` instance is specified
|
|
17329
17365
|
* instead of a model, the file references will be loaded.
|
|
17330
17366
|
*/
|
|
@@ -17372,9 +17408,8 @@
|
|
|
17372
17408
|
/**
|
|
17373
17409
|
* Loads a model of a file or assembly into the viewer.
|
|
17374
17410
|
*
|
|
17375
|
-
* This method requires a
|
|
17376
|
-
*
|
|
17377
|
-
* {@link Viewer#openVsfxFile | openVsfxFile()}.
|
|
17411
|
+
* This method requires a {@link Client} instance to work. For standalone viewer instance use
|
|
17412
|
+
* {@link openVsfFile | openVsfFile()} or {@link openVsfxFile | openVsfxFile()}.
|
|
17378
17413
|
*
|
|
17379
17414
|
* Fires:
|
|
17380
17415
|
*
|
|
@@ -17386,7 +17421,6 @@
|
|
|
17386
17421
|
* - {@link GeometryEndEvent | geometryend}
|
|
17387
17422
|
* - {@link GeometryErrorEvent | geometryerror}
|
|
17388
17423
|
*
|
|
17389
|
-
* @async
|
|
17390
17424
|
* @param file - File or Assembly or Model instance to load. If a `File` instance with
|
|
17391
17425
|
* multiple models is specified, the default model will be loaded. If there is no default
|
|
17392
17426
|
* model, first availiable model will be loaded.
|
|
@@ -17499,7 +17533,7 @@
|
|
|
17499
17533
|
return this;
|
|
17500
17534
|
}
|
|
17501
17535
|
/**
|
|
17502
|
-
* Cancels asynchronous model loading started by {@link
|
|
17536
|
+
* Cancels asynchronous model loading started by {@link open | open()}.
|
|
17503
17537
|
*/
|
|
17504
17538
|
cancel() {
|
|
17505
17539
|
var _a, _b, _c;
|
|
@@ -17535,7 +17569,7 @@
|
|
|
17535
17569
|
* @returns Color with `RGB` values.
|
|
17536
17570
|
*/
|
|
17537
17571
|
getMarkupColor() {
|
|
17538
|
-
return this.
|
|
17572
|
+
return this._markup.getMarkupColor();
|
|
17539
17573
|
}
|
|
17540
17574
|
/**
|
|
17541
17575
|
* Set markup color.
|
|
@@ -17545,7 +17579,7 @@
|
|
|
17545
17579
|
* @param b - `Blue` part of color.
|
|
17546
17580
|
*/
|
|
17547
17581
|
setMarkupColor(r = 255, g = 0, b = 0) {
|
|
17548
|
-
this.
|
|
17582
|
+
this._markup.setMarkupColor(r, g, b);
|
|
17549
17583
|
const color = { r, g, b };
|
|
17550
17584
|
this.emitEvent({ type: "changemarkupcolor", data: color });
|
|
17551
17585
|
}
|
|
@@ -17557,7 +17591,7 @@
|
|
|
17557
17591
|
* @param b - `Blue` part of color.
|
|
17558
17592
|
*/
|
|
17559
17593
|
colorizeAllMarkup(r = 255, g = 0, b = 0) {
|
|
17560
|
-
this.
|
|
17594
|
+
this._markup.colorizeAllMarkup(r, g, b);
|
|
17561
17595
|
}
|
|
17562
17596
|
/**
|
|
17563
17597
|
* Colorize all selected markup entities with the specified color.
|
|
@@ -17567,7 +17601,7 @@
|
|
|
17567
17601
|
* @param b - `Blue` part of color.
|
|
17568
17602
|
*/
|
|
17569
17603
|
colorizeSelectedMarkups(r = 255, g = 0, b = 0) {
|
|
17570
|
-
this.
|
|
17604
|
+
this._markup.colorizeSelectedMarkups(r, g, b);
|
|
17571
17605
|
}
|
|
17572
17606
|
/**
|
|
17573
17607
|
* Add an empty markup entity to the overlay.
|
|
@@ -17589,21 +17623,21 @@
|
|
|
17589
17623
|
}
|
|
17590
17624
|
/**
|
|
17591
17625
|
* Draw a viewpoint. To get a list of available model viewpoints, use the
|
|
17592
|
-
*
|
|
17626
|
+
* `Model.getViewpoints()` or `File.getViewpoints()` or `Assembly.getViewpoints()`.
|
|
17593
17627
|
*
|
|
17594
17628
|
* @param viewpoint - Viewpoint data.
|
|
17595
17629
|
*/
|
|
17596
17630
|
drawViewpoint(viewpoint) {
|
|
17597
17631
|
this.setOrthogonalCameraSettings(viewpoint.orthogonal_camera);
|
|
17598
17632
|
this.setClippingPlanes(viewpoint.clipping_planes);
|
|
17599
|
-
this.
|
|
17633
|
+
this._markup.setViewpoint(viewpoint);
|
|
17600
17634
|
}
|
|
17601
17635
|
/**
|
|
17602
17636
|
* Create a viewpoint. To add a viewpoint to the list of model viewpoints, use the
|
|
17603
|
-
*
|
|
17637
|
+
* `Model.saveViewpoint()` or `File.saveViewpoint()` or . `Assembly.saveViewpoint()`.
|
|
17604
17638
|
*/
|
|
17605
17639
|
createViewpoint() {
|
|
17606
|
-
const vp = this.
|
|
17640
|
+
const vp = this._markup.getViewpoint();
|
|
17607
17641
|
vp.orthogonal_camera = this.getOrthogonalCameraSettings();
|
|
17608
17642
|
vp.clipping_planes = this.getClippingPlanes();
|
|
17609
17643
|
return vp;
|
|
@@ -17685,6 +17719,7 @@
|
|
|
17685
17719
|
|
|
17686
17720
|
exports.CANVAS_EVENTS = CANVAS_EVENTS;
|
|
17687
17721
|
exports.CanvasEvents = CanvasEvents;
|
|
17722
|
+
exports.Dragger = Dragger;
|
|
17688
17723
|
exports.OdBaseDragger = OdBaseDragger;
|
|
17689
17724
|
exports.Options = Options;
|
|
17690
17725
|
exports.Viewer = Viewer;
|