@inweb/viewer-visualize 27.1.5 → 27.1.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 +330 -317
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +210 -295
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Components/GestureManagerComponent.d.ts +0 -1
- package/lib/Viewer/Components/ZoomWheelComponent.d.ts +0 -1
- package/lib/Viewer/Draggers/Common/GestureManager.d.ts +1 -0
- package/lib/Viewer/Draggers/Common/OdBaseDragger.d.ts +0 -4
- package/lib/Viewer/Draggers/MeasureLineDragger/index.d.ts +0 -1
- package/lib/Viewer/Draggers/OdZoomWheelDragger.d.ts +7 -1
- package/lib/Viewer/Draggers/OdaFlyDragger.d.ts +0 -1
- package/lib/Viewer/Draggers/OdaWalkDragger.d.ts +0 -1
- package/lib/Viewer/Viewer.d.ts +5 -42
- package/package.json +5 -5
- package/src/Viewer/Components/GestureManagerComponent.ts +0 -3
- package/src/Viewer/Components/ZoomWheelComponent.ts +0 -3
- package/src/Viewer/Draggers/Actions/OrbitAction.ts +1 -1
- package/src/Viewer/Draggers/Actions/PanAction.ts +1 -1
- package/src/Viewer/Draggers/Actions/ZoomAction.ts +1 -1
- package/src/Viewer/Draggers/Common/GestureManager.ts +9 -0
- package/src/Viewer/Draggers/Common/OdBaseDragger.ts +33 -30
- package/src/Viewer/Draggers/MeasureLineDragger/index.ts +9 -6
- package/src/Viewer/Draggers/OdZoomWheelDragger.ts +29 -21
- package/src/Viewer/Draggers/OdaFlyDragger.ts +0 -4
- package/src/Viewer/Draggers/OdaWalkDragger.ts +0 -4
- package/src/Viewer/Draggers/index.ts +4 -0
- package/src/Viewer/Markup/Visualize/VisualizeMarkup.ts +13 -7
- package/src/Viewer/Viewer.ts +16 -168
package/dist/viewer-visualize.js
CHANGED
|
@@ -264,10 +264,6 @@
|
|
|
264
264
|
static defaults() {
|
|
265
265
|
return defaultOptions();
|
|
266
266
|
}
|
|
267
|
-
notifierChangeEvent() {
|
|
268
|
-
console.warn("Options.notifierChangeEvent() has been deprecated since 25.3 and will be removed in a future release, use Options.change() instead.");
|
|
269
|
-
this.change();
|
|
270
|
-
}
|
|
271
267
|
change() {
|
|
272
268
|
if (this._emitter !== undefined) {
|
|
273
269
|
this.saveToStorage();
|
|
@@ -709,17 +705,27 @@
|
|
|
709
705
|
this.needInputText = false;
|
|
710
706
|
this.mouseDownPosition = { x: 0, y: 0 };
|
|
711
707
|
this.autoSelect = false;
|
|
712
|
-
this.
|
|
713
|
-
this.
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
this.
|
|
717
|
-
this.
|
|
718
|
-
this.
|
|
719
|
-
this.
|
|
708
|
+
this.pointerdown = this.pointerdown.bind(this);
|
|
709
|
+
this.pointerup = this.pointerup.bind(this);
|
|
710
|
+
this.pointercancel = this.pointercancel.bind(this);
|
|
711
|
+
this.pointermove = this.pointermove.bind(this);
|
|
712
|
+
this.click = this.click.bind(this);
|
|
713
|
+
this.dblclick = this.dblclick.bind(this);
|
|
714
|
+
this.subject.addEventListener("pointerdown", this.pointerdown);
|
|
715
|
+
this.subject.addEventListener("pointerup", this.pointerup);
|
|
716
|
+
this.subject.addEventListener("pointercancel", this.pointercancel);
|
|
717
|
+
this.subject.addEventListener("pointermove", this.pointermove);
|
|
718
|
+
this.subject.addEventListener("click", this.click);
|
|
719
|
+
this.subject.addEventListener("dblclick", this.dblclick);
|
|
720
|
+
this.getViewer().setEnableAutoSelect(false);
|
|
720
721
|
}
|
|
721
722
|
dispose() {
|
|
722
|
-
this.
|
|
723
|
+
this.subject.removeEventListener("pointerdown", this.pointerdown);
|
|
724
|
+
this.subject.removeEventListener("pointerup", this.pointerup);
|
|
725
|
+
this.subject.removeEventListener("pointercancel", this.pointercancel);
|
|
726
|
+
this.subject.removeEventListener("pointermove", this.pointermove);
|
|
727
|
+
this.subject.removeEventListener("click", this.click);
|
|
728
|
+
this.subject.removeEventListener("dblclick", this.dblclick);
|
|
723
729
|
}
|
|
724
730
|
relativeCoords(event) {
|
|
725
731
|
return { x: event.offsetX * window.devicePixelRatio, y: event.offsetY * window.devicePixelRatio };
|
|
@@ -770,13 +776,13 @@
|
|
|
770
776
|
const x = relCoord.x;
|
|
771
777
|
const y = relCoord.y;
|
|
772
778
|
const isNotDragging = Math.abs(x - this.mouseDownPosition.x) < CLICK_DELTA && Math.abs(y - this.mouseDownPosition.y) < CLICK_DELTA;
|
|
773
|
-
if (
|
|
779
|
+
if (this.autoSelect && isNotDragging) {
|
|
774
780
|
viewer.unselect();
|
|
775
781
|
viewer.select(x, y, x, y);
|
|
776
782
|
this.subject.update();
|
|
777
783
|
const selectionSet = viewer.getSelected();
|
|
778
|
-
this.
|
|
779
|
-
this.
|
|
784
|
+
this.subject.emitEvent({ type: "select", data: selectionSet, handles: this.subject.getSelected() });
|
|
785
|
+
this.subject.emitEvent({ type: "select2", data: selectionSet, handles: this.subject.getSelected2() });
|
|
780
786
|
}
|
|
781
787
|
}
|
|
782
788
|
dblclick(ev) {
|
|
@@ -791,17 +797,15 @@
|
|
|
791
797
|
clickView.delete();
|
|
792
798
|
this.subject.update();
|
|
793
799
|
}
|
|
794
|
-
else {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
this.deleteAll([itr, entity]);
|
|
804
|
-
}
|
|
800
|
+
else if (this.autoSelect) {
|
|
801
|
+
const pSelected = viewer.getSelected();
|
|
802
|
+
if (!pSelected.isNull() && pSelected.numItems() !== 0) {
|
|
803
|
+
const itr = pSelected.getIterator();
|
|
804
|
+
const entity = itr.getEntity();
|
|
805
|
+
viewer.zoomToEntity(entity);
|
|
806
|
+
this.subject.emitEvent({ type: "zoomtoentity", data: entity });
|
|
807
|
+
this.subject.update();
|
|
808
|
+
this.deleteAll([itr, entity]);
|
|
805
809
|
}
|
|
806
810
|
}
|
|
807
811
|
device.delete();
|
|
@@ -821,7 +825,6 @@
|
|
|
821
825
|
(_a = obj === null || obj === void 0 ? void 0 : obj.delete) === null || _a === void 0 ? void 0 : _a.call(obj);
|
|
822
826
|
}
|
|
823
827
|
}
|
|
824
|
-
updatePreview() { }
|
|
825
828
|
static set isGestureActive(value) {
|
|
826
829
|
if (OdBaseDragger._isGestureActive === value) {
|
|
827
830
|
return;
|
|
@@ -1199,23 +1202,23 @@
|
|
|
1199
1202
|
this.rulerUnit = (_a = subject.options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
|
|
1200
1203
|
this.rulerPrecision = (_b = subject.options.rulerPrecision) !== null && _b !== void 0 ? _b : "Default";
|
|
1201
1204
|
this.items = [];
|
|
1202
|
-
this.canvasEvents.push("resize", "optionsChange");
|
|
1203
|
-
}
|
|
1204
|
-
initialize() {
|
|
1205
|
-
super.initialize();
|
|
1206
1205
|
this.m_overlayElement = document.createElement("div");
|
|
1207
1206
|
this.m_overlayElement.style.background = "rgba(0,0,0,0)";
|
|
1208
1207
|
this.m_overlayElement.style.position = "fixed";
|
|
1209
1208
|
this.m_overlayElement.style.zIndex = "1";
|
|
1210
1209
|
this.m_overlayElement.style.pointerEvents = "none";
|
|
1211
1210
|
document.body.appendChild(this.m_overlayElement);
|
|
1211
|
+
this.optionsChange = this.optionsChange.bind(this);
|
|
1212
|
+
this.updatePreview = this.updatePreview.bind(this);
|
|
1212
1213
|
this.subject.addEventListener("optionschange", this.optionsChange);
|
|
1214
|
+
this.subject.addEventListener("render", this.updatePreview);
|
|
1213
1215
|
this.resize();
|
|
1214
1216
|
}
|
|
1215
1217
|
dispose() {
|
|
1216
1218
|
super.dispose();
|
|
1217
1219
|
this.m_overlayElement.remove();
|
|
1218
1220
|
this.subject.removeEventListener("optionschange", this.optionsChange);
|
|
1221
|
+
this.subject.removeEventListener("render", this.updatePreview);
|
|
1219
1222
|
}
|
|
1220
1223
|
updatePreview() {
|
|
1221
1224
|
this.items.forEach((item) => item.update());
|
|
@@ -1556,7 +1559,6 @@
|
|
|
1556
1559
|
class OdaWalkDragger extends OdBaseDragger {
|
|
1557
1560
|
constructor(subject) {
|
|
1558
1561
|
super(subject);
|
|
1559
|
-
this.viewer = undefined;
|
|
1560
1562
|
this.multiplier = 5;
|
|
1561
1563
|
this.baseSpeed = 1;
|
|
1562
1564
|
this.keyPressMap = new Set();
|
|
@@ -1571,9 +1573,6 @@
|
|
|
1571
1573
|
this.autoSelect = true;
|
|
1572
1574
|
this.isJoyStickMoving = false;
|
|
1573
1575
|
this.addJoyStickDragger(subject.canvas.parentElement);
|
|
1574
|
-
}
|
|
1575
|
-
initialize() {
|
|
1576
|
-
super.initialize();
|
|
1577
1576
|
this.viewer = this.getViewer();
|
|
1578
1577
|
window.addEventListener("keydown", this.keydown, false);
|
|
1579
1578
|
window.addEventListener("keyup", this.keyup, false);
|
|
@@ -1836,7 +1835,6 @@
|
|
|
1836
1835
|
class OdaFlyDragger extends OdBaseDragger {
|
|
1837
1836
|
constructor(subject) {
|
|
1838
1837
|
super(subject);
|
|
1839
|
-
this.viewer = undefined;
|
|
1840
1838
|
this.multiplier = 5;
|
|
1841
1839
|
this.speed = 1;
|
|
1842
1840
|
this.keyPressMap = new Set();
|
|
@@ -1851,9 +1849,6 @@
|
|
|
1851
1849
|
this.autoSelect = true;
|
|
1852
1850
|
this.isJoyStickMoving = false;
|
|
1853
1851
|
this.addJoyStickDragger(subject.canvas.parentElement);
|
|
1854
|
-
}
|
|
1855
|
-
initialize() {
|
|
1856
|
-
super.initialize();
|
|
1857
1852
|
this.viewer = this.getViewer();
|
|
1858
1853
|
window.addEventListener("keydown", this.keydown, false);
|
|
1859
1854
|
window.addEventListener("keyup", this.keyup, false);
|
|
@@ -2292,7 +2287,6 @@
|
|
|
2292
2287
|
this._beginInteractivity();
|
|
2293
2288
|
}
|
|
2294
2289
|
action(x, y) {
|
|
2295
|
-
var _a, _b;
|
|
2296
2290
|
const view = this.getViewer().activeView;
|
|
2297
2291
|
const corners = view.vportRect;
|
|
2298
2292
|
const size = Math.max(Math.abs(corners[2] - corners[0]), Math.abs(corners[3] - corners[1]));
|
|
@@ -2322,7 +2316,7 @@
|
|
|
2322
2316
|
const extView = this.getViewer().getActiveTvExtendedView();
|
|
2323
2317
|
extView.setView(viewParams.position, viewParams.target, viewParams.upVector, viewParams.viewFieldWidth, viewParams.viewFieldHeight, viewParams.perspective);
|
|
2324
2318
|
extView.delete();
|
|
2325
|
-
|
|
2319
|
+
this._subject.update();
|
|
2326
2320
|
this._subject.emitEvent({
|
|
2327
2321
|
type: "orbit",
|
|
2328
2322
|
});
|
|
@@ -2509,7 +2503,6 @@
|
|
|
2509
2503
|
this._beginInteractivity();
|
|
2510
2504
|
}
|
|
2511
2505
|
action(x, y, absoluteX, absoluteY) {
|
|
2512
|
-
var _a, _b;
|
|
2513
2506
|
const { Vector3d } = this._m_module;
|
|
2514
2507
|
const params = this._getViewParams();
|
|
2515
2508
|
const pt = this.screenToWorld(x, y);
|
|
@@ -2526,7 +2519,7 @@
|
|
|
2526
2519
|
targetWithDelta.delete();
|
|
2527
2520
|
position.delete();
|
|
2528
2521
|
positionWithDelta.delete();
|
|
2529
|
-
|
|
2522
|
+
this._subject.update();
|
|
2530
2523
|
this._subject.emitEvent({
|
|
2531
2524
|
type: "pan",
|
|
2532
2525
|
x: absoluteX,
|
|
@@ -2575,11 +2568,10 @@
|
|
|
2575
2568
|
this._subject = subject;
|
|
2576
2569
|
}
|
|
2577
2570
|
action(x, y, zoomFactor, absoluteX, absoluteY) {
|
|
2578
|
-
var _a, _b;
|
|
2579
2571
|
const viewer = this._m_module.getViewer();
|
|
2580
2572
|
viewer.zoomAt(zoomFactor, x, y);
|
|
2581
2573
|
this._subject.deviceAutoRegeneration();
|
|
2582
|
-
|
|
2574
|
+
this._subject.update();
|
|
2583
2575
|
this._subject.emitEvent({
|
|
2584
2576
|
type: "zoomat",
|
|
2585
2577
|
data: zoomFactor,
|
|
@@ -2627,11 +2619,27 @@
|
|
|
2627
2619
|
class OdZoomWheelDragger extends OdBaseDragger {
|
|
2628
2620
|
constructor(subject) {
|
|
2629
2621
|
super(subject);
|
|
2630
|
-
this.
|
|
2622
|
+
this.wheel = this.wheel.bind(this);
|
|
2623
|
+
this.subject.addEventListener("wheel", this.wheel);
|
|
2631
2624
|
this._zoomAction = new ZoomAction(this.m_module, this.subject);
|
|
2632
2625
|
this._endInteractivityTimeOutId = undefined;
|
|
2633
2626
|
this._isEnableInteractivityMode = false;
|
|
2634
2627
|
}
|
|
2628
|
+
dispose() {
|
|
2629
|
+
super.dispose();
|
|
2630
|
+
this.subject.removeEventListener("wheel", this.wheel);
|
|
2631
|
+
if (this._endInteractivityTimeOutId) {
|
|
2632
|
+
clearTimeout(this._endInteractivityTimeOutId);
|
|
2633
|
+
this.endInteractivity();
|
|
2634
|
+
this._isEnableInteractivityMode = false;
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
pointerdown() { }
|
|
2638
|
+
pointerup() { }
|
|
2639
|
+
pointercancel() { }
|
|
2640
|
+
pointermove() { }
|
|
2641
|
+
click() { }
|
|
2642
|
+
dblclick() { }
|
|
2635
2643
|
wheel(event) {
|
|
2636
2644
|
if (!this.subject.options.enableZoomWheel) {
|
|
2637
2645
|
return;
|
|
@@ -2651,13 +2659,6 @@
|
|
|
2651
2659
|
if (this._endInteractivityTimeOutId) {
|
|
2652
2660
|
clearTimeout(this._endInteractivityTimeOutId);
|
|
2653
2661
|
}
|
|
2654
|
-
if (!this._isEnableInteractivityMode) {
|
|
2655
|
-
this._isEnableInteractivityMode = true;
|
|
2656
|
-
this.beginInteractivity();
|
|
2657
|
-
}
|
|
2658
|
-
if (this._endInteractivityTimeOutId) {
|
|
2659
|
-
clearTimeout(this._endInteractivityTimeOutId);
|
|
2660
|
-
}
|
|
2661
2662
|
this.subject.update(true);
|
|
2662
2663
|
this._endInteractivityTimeOutId = setTimeout(() => {
|
|
2663
2664
|
this._endInteractivityTimeOutId = undefined;
|
|
@@ -2666,13 +2667,6 @@
|
|
|
2666
2667
|
}, INTERACTIVITY_TIME_OUT);
|
|
2667
2668
|
}
|
|
2668
2669
|
}
|
|
2669
|
-
dispose() {
|
|
2670
|
-
if (this._endInteractivityTimeOutId) {
|
|
2671
|
-
clearTimeout(this._endInteractivityTimeOutId);
|
|
2672
|
-
this.endInteractivity();
|
|
2673
|
-
this._isEnableInteractivityMode = false;
|
|
2674
|
-
}
|
|
2675
|
-
}
|
|
2676
2670
|
}
|
|
2677
2671
|
|
|
2678
2672
|
class OdSelectionFrame {
|
|
@@ -2892,6 +2886,127 @@
|
|
|
2892
2886
|
}
|
|
2893
2887
|
}
|
|
2894
2888
|
|
|
2889
|
+
const MARKUP_ENTITY_LINE = "$MarkupTempEntity_Line";
|
|
2890
|
+
class OdaLineDragger extends OdBaseDragger {
|
|
2891
|
+
constructor(subject) {
|
|
2892
|
+
super(subject);
|
|
2893
|
+
this.press = false;
|
|
2894
|
+
}
|
|
2895
|
+
dispose() {
|
|
2896
|
+
super.dispose();
|
|
2897
|
+
this.end();
|
|
2898
|
+
this.points = null;
|
|
2899
|
+
this.drawPoints = null;
|
|
2900
|
+
}
|
|
2901
|
+
start(x, y) {
|
|
2902
|
+
const point = this.getViewer().screenToWorld(x, y);
|
|
2903
|
+
this.drawPoints = [point[0], point[1], point[2]];
|
|
2904
|
+
}
|
|
2905
|
+
drag(x, y) {
|
|
2906
|
+
if (this.isDragging) {
|
|
2907
|
+
const point = this.getViewer().screenToWorld(x, y);
|
|
2908
|
+
this.drawPoints.push(point[0], point[1], point[2]);
|
|
2909
|
+
this._updateFrame();
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
end() {
|
|
2913
|
+
if (this.entity) {
|
|
2914
|
+
this.entity.delete();
|
|
2915
|
+
this.drawPoints = null;
|
|
2916
|
+
this.entity = null;
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
_updateFrame() {
|
|
2920
|
+
if (this.entity) {
|
|
2921
|
+
const model = this.getViewer().getMarkupModel();
|
|
2922
|
+
model.removeEntity(this.entity);
|
|
2923
|
+
model.delete();
|
|
2924
|
+
this.entity.delete();
|
|
2925
|
+
}
|
|
2926
|
+
this.entity = this.getActiveMarkupEntity(MARKUP_ENTITY_LINE);
|
|
2927
|
+
const entityPtr = this.entity.openObject();
|
|
2928
|
+
entityPtr.appendPolyline(this.drawPoints).delete();
|
|
2929
|
+
entityPtr.delete();
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2932
|
+
|
|
2933
|
+
const MARKUP_ENTITY_TEXT = "$MarkupTempEntity_Text";
|
|
2934
|
+
class OdaTextDragger extends OdBaseDragger {
|
|
2935
|
+
constructor(subject) {
|
|
2936
|
+
super(subject);
|
|
2937
|
+
this.TEXT_HEIGHT_ALIGN = 24;
|
|
2938
|
+
this.press = false;
|
|
2939
|
+
}
|
|
2940
|
+
dispose() {
|
|
2941
|
+
var _a;
|
|
2942
|
+
super.dispose();
|
|
2943
|
+
(_a = this.textRef) === null || _a === void 0 ? void 0 : _a.remove();
|
|
2944
|
+
this.textRef = null;
|
|
2945
|
+
}
|
|
2946
|
+
_finishInput() {
|
|
2947
|
+
var _a;
|
|
2948
|
+
if (this.textRef && this.textRef.value.trimLeft()) {
|
|
2949
|
+
this._updateFrame();
|
|
2950
|
+
}
|
|
2951
|
+
(_a = this.textRef) === null || _a === void 0 ? void 0 : _a.remove();
|
|
2952
|
+
this.textRef = null;
|
|
2953
|
+
}
|
|
2954
|
+
start(x, y, absoluteX, absoluteY) {
|
|
2955
|
+
if (!this.textRef) {
|
|
2956
|
+
this.textRef = document.createElement("textarea");
|
|
2957
|
+
this.textRef.style.zIndex = "9999";
|
|
2958
|
+
this.textRef.style.position = "absolute";
|
|
2959
|
+
this.textRef.style.display = "block";
|
|
2960
|
+
this.textRef.style.top = absoluteY + "px";
|
|
2961
|
+
this.textRef.style.left = absoluteX + "px";
|
|
2962
|
+
this.textRef.onkeypress = (event) => {
|
|
2963
|
+
if (event.key === "Enter") {
|
|
2964
|
+
event.preventDefault();
|
|
2965
|
+
this._finishInput();
|
|
2966
|
+
}
|
|
2967
|
+
};
|
|
2968
|
+
document.body.appendChild(this.textRef);
|
|
2969
|
+
this.press = true;
|
|
2970
|
+
this.m_center = this.screenToWorld(x, y + this.TEXT_HEIGHT_ALIGN);
|
|
2971
|
+
this.needInputText = true;
|
|
2972
|
+
}
|
|
2973
|
+
else {
|
|
2974
|
+
this._finishInput();
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
_updateFrame() {
|
|
2978
|
+
this.entity = this.getActiveMarkupEntity(MARKUP_ENTITY_TEXT);
|
|
2979
|
+
const entityPtr = this.entity.openObject();
|
|
2980
|
+
const view = this.getViewer().activeView;
|
|
2981
|
+
const pos = this.toPoint(view.viewPosition);
|
|
2982
|
+
const target = this.toPoint(view.viewTarget);
|
|
2983
|
+
const eyeToWorld = view.eyeToWorldMatrix;
|
|
2984
|
+
const eyeDir = pos.sub(target).asVector();
|
|
2985
|
+
const xDir = this.toVector([1.0, 0.0, 0.0]);
|
|
2986
|
+
const direction = xDir.transformBy(eyeToWorld);
|
|
2987
|
+
const mtrx = this.createMatrix3d();
|
|
2988
|
+
mtrx.setToWorldToPlane(this.toGeVector(eyeDir));
|
|
2989
|
+
direction.transformBy(mtrx);
|
|
2990
|
+
const angel = -Math.atan2(-direction.y, direction.x);
|
|
2991
|
+
const textSize = 0.02;
|
|
2992
|
+
let textScale = 1.0;
|
|
2993
|
+
const projMtrx = view.projectionMatrix;
|
|
2994
|
+
const mtrxNumber = projMtrx.get(1, 1);
|
|
2995
|
+
const tol = 1.0e-6;
|
|
2996
|
+
if (!(mtrxNumber < tol && mtrxNumber > -tol)) {
|
|
2997
|
+
textScale = 1 / mtrxNumber;
|
|
2998
|
+
}
|
|
2999
|
+
const geomData = entityPtr.appendText(this.toGePoint(this.m_center), this.textRef.value.trimLeft());
|
|
3000
|
+
const textPtr = geomData.openAsText();
|
|
3001
|
+
textPtr.setNormal(this.toGeVector(eyeDir));
|
|
3002
|
+
textPtr.setRotation(angel);
|
|
3003
|
+
textPtr.setTextSize(textSize * textScale);
|
|
3004
|
+
textPtr.delete();
|
|
3005
|
+
geomData.delete();
|
|
3006
|
+
entityPtr.delete();
|
|
3007
|
+
}
|
|
3008
|
+
}
|
|
3009
|
+
|
|
2895
3010
|
const draggers = draggersRegistry("visualizejs");
|
|
2896
3011
|
draggers.registerDragger("Pan", (viewer) => new OdPanDragger(viewer));
|
|
2897
3012
|
draggers.registerDragger("Orbit", (viewer) => new OdOrbitDragger(viewer));
|
|
@@ -2905,6 +3020,8 @@
|
|
|
2905
3020
|
draggers.registerDragger("CuttingPlaneZAxis", (viewer) => new OdCuttingPlaneZAxisDragger(viewer));
|
|
2906
3021
|
draggers.registerDragger("Walk", (viewer) => new OdaWalkDragger(viewer));
|
|
2907
3022
|
draggers.registerDragger("Fly", (viewer) => new OdaFlyDragger(viewer));
|
|
3023
|
+
draggers.registerDragger("Line", (viewer) => new OdaLineDragger(viewer));
|
|
3024
|
+
draggers.registerDragger("Text", (viewer) => new OdaTextDragger(viewer));
|
|
2908
3025
|
|
|
2909
3026
|
const composeMatrixFromTransform = (transform, modelCenter, visLib) => {
|
|
2910
3027
|
const { translate, scale, rotation } = transform;
|
|
@@ -3501,10 +3618,8 @@
|
|
|
3501
3618
|
|
|
3502
3619
|
class ZoomWheelComponent {
|
|
3503
3620
|
constructor(viewer) {
|
|
3504
|
-
this.viewer = viewer;
|
|
3505
3621
|
this.zoomWheelDragger = new OdZoomWheelDragger(viewer);
|
|
3506
3622
|
this.zoomWheelDragger.name = "ZoomWheel";
|
|
3507
|
-
this.zoomWheelDragger.initialize();
|
|
3508
3623
|
}
|
|
3509
3624
|
dispose() {
|
|
3510
3625
|
this.zoomWheelDragger.dispose();
|
|
@@ -3536,6 +3651,12 @@
|
|
|
3536
3651
|
this._orbitAction = new OrbitAction(this.m_module, this.subject, this.beginInteractivity, this.endInteractivity);
|
|
3537
3652
|
this._panAction = new PanAction(this.m_module, this.subject, this.beginInteractivity, this.endInteractivity, this.getViewParams, this.setViewParams);
|
|
3538
3653
|
this._zoomAction = new ZoomAction(this.m_module, this.subject);
|
|
3654
|
+
this.pointerleave = this.pointerleave.bind(this);
|
|
3655
|
+
this.subject.addEventListener("pointerleave", this.pointerleave);
|
|
3656
|
+
}
|
|
3657
|
+
dispose() {
|
|
3658
|
+
super.dispose();
|
|
3659
|
+
this.subject.removeEventListener("pointerleave", this.pointerleave);
|
|
3539
3660
|
}
|
|
3540
3661
|
getMiddlePoint(events) {
|
|
3541
3662
|
if (events.size !== 2) {
|
|
@@ -3692,9 +3813,7 @@
|
|
|
3692
3813
|
|
|
3693
3814
|
class GestureManagerComponent {
|
|
3694
3815
|
constructor(viewer) {
|
|
3695
|
-
this.viewer = viewer;
|
|
3696
3816
|
this.gestureManager = new GestureManager(viewer);
|
|
3697
|
-
this.gestureManager.initialize();
|
|
3698
3817
|
}
|
|
3699
3818
|
dispose() {
|
|
3700
3819
|
this.gestureManager.dispose();
|
|
@@ -4351,7 +4470,7 @@
|
|
|
4351
4470
|
: {};
|
|
4352
4471
|
const Konva$2 = {
|
|
4353
4472
|
_global: glob,
|
|
4354
|
-
version: '10.0
|
|
4473
|
+
version: '10.2.0',
|
|
4355
4474
|
isBrowser: detectBrowser(),
|
|
4356
4475
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
4357
4476
|
dblClickWindow: 400,
|
|
@@ -4723,7 +4842,7 @@ js: import "konva/skia-backend";
|
|
|
4723
4842
|
let _isCanvasFarblingActive = null;
|
|
4724
4843
|
const req = (typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame) ||
|
|
4725
4844
|
function (f) {
|
|
4726
|
-
setTimeout(f,
|
|
4845
|
+
setTimeout(f, 16);
|
|
4727
4846
|
};
|
|
4728
4847
|
const Util = {
|
|
4729
4848
|
_isElement(obj) {
|
|
@@ -6520,8 +6639,8 @@ js: import "konva/skia-backend";
|
|
|
6520
6639
|
}
|
|
6521
6640
|
clearCache() {
|
|
6522
6641
|
if (this._cache.has(CANVAS)) {
|
|
6523
|
-
const { scene, filter, hit
|
|
6524
|
-
Util.releaseCanvas(scene, filter, hit
|
|
6642
|
+
const { scene, filter, hit } = this._cache.get(CANVAS);
|
|
6643
|
+
Util.releaseCanvas(scene._canvas, filter._canvas, hit._canvas);
|
|
6525
6644
|
this._cache.delete(CANVAS);
|
|
6526
6645
|
}
|
|
6527
6646
|
this._clearSelfAndDescendantCache();
|
|
@@ -6604,11 +6723,11 @@ js: import "konva/skia-backend";
|
|
|
6604
6723
|
sceneContext.stroke();
|
|
6605
6724
|
sceneContext.restore();
|
|
6606
6725
|
}
|
|
6726
|
+
Util.releaseCanvas(bufferCanvas._canvas);
|
|
6607
6727
|
this._cache.set(CANVAS, {
|
|
6608
6728
|
scene: cachedSceneCanvas,
|
|
6609
6729
|
filter: cachedFilterCanvas,
|
|
6610
6730
|
hit: cachedHitCanvas,
|
|
6611
|
-
buffer: bufferCanvas,
|
|
6612
6731
|
x: x,
|
|
6613
6732
|
y: y,
|
|
6614
6733
|
});
|
|
@@ -7633,19 +7752,20 @@ js: import "konva/skia-backend";
|
|
|
7633
7752
|
}
|
|
7634
7753
|
}
|
|
7635
7754
|
_getProtoListeners(eventType) {
|
|
7636
|
-
var _a, _b
|
|
7637
|
-
const
|
|
7755
|
+
var _a, _b;
|
|
7756
|
+
const { nodeType } = this;
|
|
7757
|
+
const allListeners = Node.protoListenerMap.get(nodeType) || {};
|
|
7638
7758
|
let events = allListeners === null || allListeners === void 0 ? void 0 : allListeners[eventType];
|
|
7639
7759
|
if (events === undefined) {
|
|
7640
7760
|
events = [];
|
|
7641
7761
|
let obj = Object.getPrototypeOf(this);
|
|
7642
7762
|
while (obj) {
|
|
7643
|
-
const hierarchyEvents = (
|
|
7763
|
+
const hierarchyEvents = (_b = (_a = obj.eventListeners) === null || _a === void 0 ? void 0 : _a[eventType]) !== null && _b !== void 0 ? _b : [];
|
|
7644
7764
|
events.push(...hierarchyEvents);
|
|
7645
7765
|
obj = Object.getPrototypeOf(obj);
|
|
7646
7766
|
}
|
|
7647
7767
|
allListeners[eventType] = events;
|
|
7648
|
-
|
|
7768
|
+
Node.protoListenerMap.set(nodeType, allListeners);
|
|
7649
7769
|
}
|
|
7650
7770
|
return events;
|
|
7651
7771
|
}
|
|
@@ -7835,6 +7955,7 @@ js: import "konva/skia-backend";
|
|
|
7835
7955
|
return no;
|
|
7836
7956
|
}
|
|
7837
7957
|
}
|
|
7958
|
+
Node.protoListenerMap = new Map();
|
|
7838
7959
|
Node.prototype.nodeType = 'Node';
|
|
7839
7960
|
Node.prototype._attrsAffectingSize = [];
|
|
7840
7961
|
Node.prototype.eventListeners = {};
|
|
@@ -9292,7 +9413,15 @@ js: import "konva/skia-backend";
|
|
|
9292
9413
|
stage = this.getStage();
|
|
9293
9414
|
const bc = bufferCanvas || stage.bufferCanvas;
|
|
9294
9415
|
const bufferContext = bc.getContext();
|
|
9295
|
-
|
|
9416
|
+
if (bufferCanvas) {
|
|
9417
|
+
bufferContext.save();
|
|
9418
|
+
bufferContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
9419
|
+
bufferContext.clearRect(0, 0, bc.width, bc.height);
|
|
9420
|
+
bufferContext.restore();
|
|
9421
|
+
}
|
|
9422
|
+
else {
|
|
9423
|
+
bufferContext.clear();
|
|
9424
|
+
}
|
|
9296
9425
|
bufferContext.save();
|
|
9297
9426
|
bufferContext._applyLineJoin(this);
|
|
9298
9427
|
bufferContext._applyMiterLimit(this);
|
|
@@ -10585,6 +10714,35 @@ js: import "konva/skia-backend";
|
|
|
10585
10714
|
}
|
|
10586
10715
|
return allPoints;
|
|
10587
10716
|
}
|
|
10717
|
+
function getBezierExtremaPoints(points) {
|
|
10718
|
+
const axisPoints = [
|
|
10719
|
+
[points[0], points[2], points[4], points[6]],
|
|
10720
|
+
[points[1], points[3], points[5], points[7]],
|
|
10721
|
+
];
|
|
10722
|
+
const extremaTs = [];
|
|
10723
|
+
for (const axis of axisPoints) {
|
|
10724
|
+
const a = -3 * axis[0] + 9 * axis[1] - 9 * axis[2] + 3 * axis[3];
|
|
10725
|
+
if (a !== 0) {
|
|
10726
|
+
const b = 6 * axis[0] - 12 * axis[1] + 6 * axis[2];
|
|
10727
|
+
const c = -3 * axis[0] + 3 * axis[1];
|
|
10728
|
+
const discriminant = b * b - 4 * a * c;
|
|
10729
|
+
if (discriminant >= 0) {
|
|
10730
|
+
const d = Math.sqrt(discriminant);
|
|
10731
|
+
extremaTs.push((-b + d) / (2 * a));
|
|
10732
|
+
extremaTs.push((-b - d) / (2 * a));
|
|
10733
|
+
}
|
|
10734
|
+
}
|
|
10735
|
+
}
|
|
10736
|
+
return extremaTs
|
|
10737
|
+
.filter((t) => t > 0 && t < 1)
|
|
10738
|
+
.flatMap((t) => axisPoints.map((axis) => {
|
|
10739
|
+
const mt = 1 - t;
|
|
10740
|
+
return (mt * mt * mt * axis[0] +
|
|
10741
|
+
3 * mt * mt * t * axis[1] +
|
|
10742
|
+
3 * mt * t * t * axis[2] +
|
|
10743
|
+
t * t * t * axis[3]);
|
|
10744
|
+
}));
|
|
10745
|
+
}
|
|
10588
10746
|
class Line extends Shape {
|
|
10589
10747
|
constructor(config) {
|
|
10590
10748
|
super(config);
|
|
@@ -10686,6 +10844,15 @@ js: import "konva/skia-backend";
|
|
|
10686
10844
|
points[points.length - 1],
|
|
10687
10845
|
];
|
|
10688
10846
|
}
|
|
10847
|
+
else if (this.bezier()) {
|
|
10848
|
+
points = [
|
|
10849
|
+
points[0],
|
|
10850
|
+
points[1],
|
|
10851
|
+
...getBezierExtremaPoints(this.points()),
|
|
10852
|
+
points[points.length - 2],
|
|
10853
|
+
points[points.length - 1],
|
|
10854
|
+
];
|
|
10855
|
+
}
|
|
10689
10856
|
else {
|
|
10690
10857
|
points = this.points();
|
|
10691
10858
|
}
|
|
@@ -12975,7 +13142,7 @@ js: import "konva/skia-backend";
|
|
|
12975
13142
|
if (!this.text()) {
|
|
12976
13143
|
return;
|
|
12977
13144
|
}
|
|
12978
|
-
let 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(), charRenderFunc = this.charRenderFunc(), fill = this.fill(), textDecoration = this.textDecoration(), shouldUnderline = textDecoration.indexOf('underline') !== -1, shouldLineThrough = textDecoration.indexOf('line-through') !== -1, n;
|
|
13145
|
+
let 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(), charRenderFunc = this.charRenderFunc(), fill = this.fill(), textDecoration = this.textDecoration(), underlineOffset = this.underlineOffset(), shouldUnderline = textDecoration.indexOf('underline') !== -1, shouldLineThrough = textDecoration.indexOf('line-through') !== -1, n;
|
|
12979
13146
|
direction = direction === INHERIT ? context.direction : direction;
|
|
12980
13147
|
let translateY = lineHeightPx / 2;
|
|
12981
13148
|
let baseline = MIDDLE;
|
|
@@ -13013,9 +13180,9 @@ js: import "konva/skia-backend";
|
|
|
13013
13180
|
if (shouldUnderline) {
|
|
13014
13181
|
context.save();
|
|
13015
13182
|
context.beginPath();
|
|
13016
|
-
const yOffset = !Konva$2.legacyTextRendering
|
|
13183
|
+
const yOffset = underlineOffset !== null && underlineOffset !== void 0 ? underlineOffset : (!Konva$2.legacyTextRendering
|
|
13017
13184
|
? Math.round(fontSize / 4)
|
|
13018
|
-
: Math.round(fontSize / 2);
|
|
13185
|
+
: Math.round(fontSize / 2));
|
|
13019
13186
|
const x = lineTranslateX;
|
|
13020
13187
|
const y = translateY + lineTranslateY + yOffset;
|
|
13021
13188
|
context.moveTo(x, y);
|
|
@@ -13334,6 +13501,7 @@ js: import "konva/skia-backend";
|
|
|
13334
13501
|
Factory.addGetterSetter(Text, 'letterSpacing', 0, getNumberValidator());
|
|
13335
13502
|
Factory.addGetterSetter(Text, 'text', '', getStringValidator());
|
|
13336
13503
|
Factory.addGetterSetter(Text, 'textDecoration', '');
|
|
13504
|
+
Factory.addGetterSetter(Text, 'underlineOffset', undefined, getNumberValidator());
|
|
13337
13505
|
Factory.addGetterSetter(Text, 'charRenderFunc', undefined);
|
|
13338
13506
|
|
|
13339
13507
|
const EMPTY_STRING = '', NORMAL = 'normal';
|
|
@@ -13602,6 +13770,7 @@ js: import "konva/skia-backend";
|
|
|
13602
13770
|
const ATTR_CHANGE_LIST = [
|
|
13603
13771
|
'resizeEnabledChange',
|
|
13604
13772
|
'rotateAnchorOffsetChange',
|
|
13773
|
+
'rotateAnchorAngleChange',
|
|
13605
13774
|
'rotateEnabledChange',
|
|
13606
13775
|
'enabledAnchorsChange',
|
|
13607
13776
|
'anchorSizeChange',
|
|
@@ -13999,11 +14168,38 @@ js: import "konva/skia-backend";
|
|
|
13999
14168
|
sceneFunc(ctx, shape) {
|
|
14000
14169
|
const tr = shape.getParent();
|
|
14001
14170
|
const padding = tr.padding();
|
|
14171
|
+
const width = shape.width();
|
|
14172
|
+
const height = shape.height();
|
|
14002
14173
|
ctx.beginPath();
|
|
14003
|
-
ctx.rect(-padding, -padding,
|
|
14004
|
-
ctx.moveTo(shape.width() / 2, -padding);
|
|
14174
|
+
ctx.rect(-padding, -padding, width + padding * 2, height + padding * 2);
|
|
14005
14175
|
if (tr.rotateEnabled() && tr.rotateLineVisible()) {
|
|
14006
|
-
|
|
14176
|
+
const rotateAnchorAngle = tr.rotateAnchorAngle();
|
|
14177
|
+
const rotateAnchorOffset = tr.rotateAnchorOffset();
|
|
14178
|
+
const rad = Util.degToRad(rotateAnchorAngle);
|
|
14179
|
+
const dirX = Math.sin(rad);
|
|
14180
|
+
const dirY = -Math.cos(rad);
|
|
14181
|
+
const cx = width / 2;
|
|
14182
|
+
const cy = height / 2;
|
|
14183
|
+
let t = Infinity;
|
|
14184
|
+
if (dirY < 0) {
|
|
14185
|
+
t = Math.min(t, -cy / dirY);
|
|
14186
|
+
}
|
|
14187
|
+
else if (dirY > 0) {
|
|
14188
|
+
t = Math.min(t, (height - cy) / dirY);
|
|
14189
|
+
}
|
|
14190
|
+
if (dirX < 0) {
|
|
14191
|
+
t = Math.min(t, -cx / dirX);
|
|
14192
|
+
}
|
|
14193
|
+
else if (dirX > 0) {
|
|
14194
|
+
t = Math.min(t, (width - cx) / dirX);
|
|
14195
|
+
}
|
|
14196
|
+
const edgeX = cx + dirX * t;
|
|
14197
|
+
const edgeY = cy + dirY * t;
|
|
14198
|
+
const sign = Util._sign(height);
|
|
14199
|
+
const endX = edgeX + dirX * rotateAnchorOffset * sign;
|
|
14200
|
+
const endY = edgeY + dirY * rotateAnchorOffset * sign;
|
|
14201
|
+
ctx.moveTo(edgeX, edgeY);
|
|
14202
|
+
ctx.lineTo(endX, endY);
|
|
14007
14203
|
}
|
|
14008
14204
|
ctx.fillStrokeShape(shape);
|
|
14009
14205
|
},
|
|
@@ -14085,7 +14281,8 @@ js: import "konva/skia-backend";
|
|
|
14085
14281
|
const attrs = this._getNodeRect();
|
|
14086
14282
|
x = anchorNode.x() - attrs.width / 2;
|
|
14087
14283
|
y = -anchorNode.y() + attrs.height / 2;
|
|
14088
|
-
|
|
14284
|
+
const rotateAnchorAngleRad = Konva$2.getAngle(this.rotateAnchorAngle());
|
|
14285
|
+
let delta = Math.atan2(-y, x) + Math.PI / 2 - rotateAnchorAngleRad;
|
|
14089
14286
|
if (attrs.height < 0) {
|
|
14090
14287
|
delta -= Math.PI;
|
|
14091
14288
|
}
|
|
@@ -14480,9 +14677,32 @@ js: import "konva/skia-backend";
|
|
|
14480
14677
|
offsetY: anchorSize / 2 - padding,
|
|
14481
14678
|
visible: resizeEnabled && enabledAnchors.indexOf('bottom-right') >= 0,
|
|
14482
14679
|
});
|
|
14680
|
+
const rotateAnchorAngle = this.rotateAnchorAngle();
|
|
14681
|
+
const rotateAnchorOffset = this.rotateAnchorOffset();
|
|
14682
|
+
const rad = Util.degToRad(rotateAnchorAngle);
|
|
14683
|
+
const dirX = Math.sin(rad);
|
|
14684
|
+
const dirY = -Math.cos(rad);
|
|
14685
|
+
const cx = width / 2;
|
|
14686
|
+
const cy = height / 2;
|
|
14687
|
+
let t = Infinity;
|
|
14688
|
+
if (dirY < 0) {
|
|
14689
|
+
t = Math.min(t, -cy / dirY);
|
|
14690
|
+
}
|
|
14691
|
+
else if (dirY > 0) {
|
|
14692
|
+
t = Math.min(t, (height - cy) / dirY);
|
|
14693
|
+
}
|
|
14694
|
+
if (dirX < 0) {
|
|
14695
|
+
t = Math.min(t, -cx / dirX);
|
|
14696
|
+
}
|
|
14697
|
+
else if (dirX > 0) {
|
|
14698
|
+
t = Math.min(t, (width - cx) / dirX);
|
|
14699
|
+
}
|
|
14700
|
+
const edgeX = cx + dirX * t;
|
|
14701
|
+
const edgeY = cy + dirY * t;
|
|
14702
|
+
const sign = Util._sign(height);
|
|
14483
14703
|
this._batchChangeChild('.rotater', {
|
|
14484
|
-
x:
|
|
14485
|
-
y:
|
|
14704
|
+
x: edgeX + dirX * rotateAnchorOffset * sign,
|
|
14705
|
+
y: edgeY + dirY * rotateAnchorOffset * sign - padding * dirY,
|
|
14486
14706
|
visible: this.rotateEnabled(),
|
|
14487
14707
|
});
|
|
14488
14708
|
this._batchChangeChild('.back', {
|
|
@@ -14570,6 +14790,7 @@ js: import "konva/skia-backend";
|
|
|
14570
14790
|
Factory.addGetterSetter(Transformer, 'rotateLineVisible', true);
|
|
14571
14791
|
Factory.addGetterSetter(Transformer, 'rotationSnaps', []);
|
|
14572
14792
|
Factory.addGetterSetter(Transformer, 'rotateAnchorOffset', 50, getNumberValidator());
|
|
14793
|
+
Factory.addGetterSetter(Transformer, 'rotateAnchorAngle', 0, getNumberValidator());
|
|
14573
14794
|
Factory.addGetterSetter(Transformer, 'rotateAnchorCursor', 'crosshair');
|
|
14574
14795
|
Factory.addGetterSetter(Transformer, 'rotationSnapTolerance', 5, getNumberValidator());
|
|
14575
14796
|
Factory.addGetterSetter(Transformer, 'borderEnabled', true);
|
|
@@ -17817,127 +18038,6 @@ js: import "konva/skia-backend";
|
|
|
17817
18038
|
}
|
|
17818
18039
|
}
|
|
17819
18040
|
|
|
17820
|
-
const MARKUP_ENTITY_LINE = "$MarkupTempEntity_Line";
|
|
17821
|
-
class OdaLineDragger extends OdBaseDragger {
|
|
17822
|
-
constructor(subject) {
|
|
17823
|
-
super(subject);
|
|
17824
|
-
this.press = false;
|
|
17825
|
-
}
|
|
17826
|
-
dispose() {
|
|
17827
|
-
super.dispose();
|
|
17828
|
-
this.end();
|
|
17829
|
-
this.points = null;
|
|
17830
|
-
this.drawPoints = null;
|
|
17831
|
-
}
|
|
17832
|
-
start(x, y) {
|
|
17833
|
-
const point = this.getViewer().screenToWorld(x, y);
|
|
17834
|
-
this.drawPoints = [point[0], point[1], point[2]];
|
|
17835
|
-
}
|
|
17836
|
-
drag(x, y) {
|
|
17837
|
-
if (this.isDragging) {
|
|
17838
|
-
const point = this.getViewer().screenToWorld(x, y);
|
|
17839
|
-
this.drawPoints.push(point[0], point[1], point[2]);
|
|
17840
|
-
this._updateFrame();
|
|
17841
|
-
}
|
|
17842
|
-
}
|
|
17843
|
-
end() {
|
|
17844
|
-
if (this.entity) {
|
|
17845
|
-
this.entity.delete();
|
|
17846
|
-
this.drawPoints = null;
|
|
17847
|
-
this.entity = null;
|
|
17848
|
-
}
|
|
17849
|
-
}
|
|
17850
|
-
_updateFrame() {
|
|
17851
|
-
if (this.entity) {
|
|
17852
|
-
const model = this.getViewer().getMarkupModel();
|
|
17853
|
-
model.removeEntity(this.entity);
|
|
17854
|
-
model.delete();
|
|
17855
|
-
this.entity.delete();
|
|
17856
|
-
}
|
|
17857
|
-
this.entity = this.getActiveMarkupEntity(MARKUP_ENTITY_LINE);
|
|
17858
|
-
const entityPtr = this.entity.openObject();
|
|
17859
|
-
entityPtr.appendPolyline(this.drawPoints).delete();
|
|
17860
|
-
entityPtr.delete();
|
|
17861
|
-
}
|
|
17862
|
-
}
|
|
17863
|
-
|
|
17864
|
-
const MARKUP_ENTITY_TEXT = "$MarkupTempEntity_Text";
|
|
17865
|
-
class OdaTextDragger extends OdBaseDragger {
|
|
17866
|
-
constructor(subject) {
|
|
17867
|
-
super(subject);
|
|
17868
|
-
this.TEXT_HEIGHT_ALIGN = 24;
|
|
17869
|
-
this.press = false;
|
|
17870
|
-
}
|
|
17871
|
-
dispose() {
|
|
17872
|
-
var _a;
|
|
17873
|
-
super.dispose();
|
|
17874
|
-
(_a = this.textRef) === null || _a === void 0 ? void 0 : _a.remove();
|
|
17875
|
-
this.textRef = null;
|
|
17876
|
-
}
|
|
17877
|
-
_finishInput() {
|
|
17878
|
-
var _a;
|
|
17879
|
-
if (this.textRef && this.textRef.value.trimLeft()) {
|
|
17880
|
-
this._updateFrame();
|
|
17881
|
-
}
|
|
17882
|
-
(_a = this.textRef) === null || _a === void 0 ? void 0 : _a.remove();
|
|
17883
|
-
this.textRef = null;
|
|
17884
|
-
}
|
|
17885
|
-
start(x, y, absoluteX, absoluteY) {
|
|
17886
|
-
if (!this.textRef) {
|
|
17887
|
-
this.textRef = document.createElement("textarea");
|
|
17888
|
-
this.textRef.style.zIndex = "9999";
|
|
17889
|
-
this.textRef.style.position = "absolute";
|
|
17890
|
-
this.textRef.style.display = "block";
|
|
17891
|
-
this.textRef.style.top = absoluteY + "px";
|
|
17892
|
-
this.textRef.style.left = absoluteX + "px";
|
|
17893
|
-
this.textRef.onkeypress = (event) => {
|
|
17894
|
-
if (event.key === "Enter") {
|
|
17895
|
-
event.preventDefault();
|
|
17896
|
-
this._finishInput();
|
|
17897
|
-
}
|
|
17898
|
-
};
|
|
17899
|
-
document.body.appendChild(this.textRef);
|
|
17900
|
-
this.press = true;
|
|
17901
|
-
this.m_center = this.screenToWorld(x, y + this.TEXT_HEIGHT_ALIGN);
|
|
17902
|
-
this.needInputText = true;
|
|
17903
|
-
}
|
|
17904
|
-
else {
|
|
17905
|
-
this._finishInput();
|
|
17906
|
-
}
|
|
17907
|
-
}
|
|
17908
|
-
_updateFrame() {
|
|
17909
|
-
this.entity = this.getActiveMarkupEntity(MARKUP_ENTITY_TEXT);
|
|
17910
|
-
const entityPtr = this.entity.openObject();
|
|
17911
|
-
const view = this.getViewer().activeView;
|
|
17912
|
-
const pos = this.toPoint(view.viewPosition);
|
|
17913
|
-
const target = this.toPoint(view.viewTarget);
|
|
17914
|
-
const eyeToWorld = view.eyeToWorldMatrix;
|
|
17915
|
-
const eyeDir = pos.sub(target).asVector();
|
|
17916
|
-
const xDir = this.toVector([1.0, 0.0, 0.0]);
|
|
17917
|
-
const direction = xDir.transformBy(eyeToWorld);
|
|
17918
|
-
const mtrx = this.createMatrix3d();
|
|
17919
|
-
mtrx.setToWorldToPlane(this.toGeVector(eyeDir));
|
|
17920
|
-
direction.transformBy(mtrx);
|
|
17921
|
-
const angel = -Math.atan2(-direction.y, direction.x);
|
|
17922
|
-
const textSize = 0.02;
|
|
17923
|
-
let textScale = 1.0;
|
|
17924
|
-
const projMtrx = view.projectionMatrix;
|
|
17925
|
-
const mtrxNumber = projMtrx.get(1, 1);
|
|
17926
|
-
const tol = 1.0e-6;
|
|
17927
|
-
if (!(mtrxNumber < tol && mtrxNumber > -tol)) {
|
|
17928
|
-
textScale = 1 / mtrxNumber;
|
|
17929
|
-
}
|
|
17930
|
-
const geomData = entityPtr.appendText(this.toGePoint(this.m_center), this.textRef.value.trimLeft());
|
|
17931
|
-
const textPtr = geomData.openAsText();
|
|
17932
|
-
textPtr.setNormal(this.toGeVector(eyeDir));
|
|
17933
|
-
textPtr.setRotation(angel);
|
|
17934
|
-
textPtr.setTextSize(textSize * textScale);
|
|
17935
|
-
textPtr.delete();
|
|
17936
|
-
geomData.delete();
|
|
17937
|
-
entityPtr.delete();
|
|
17938
|
-
}
|
|
17939
|
-
}
|
|
17940
|
-
|
|
17941
18041
|
class VisualizeMarkup {
|
|
17942
18042
|
constructor() {
|
|
17943
18043
|
this._markupColor = { r: 255, g: 0, b: 0 };
|
|
@@ -17946,8 +18046,6 @@ js: import "konva/skia-backend";
|
|
|
17946
18046
|
}
|
|
17947
18047
|
initialize(container, containerEvents, viewer, worldTransformer) {
|
|
17948
18048
|
this._viewer = viewer;
|
|
17949
|
-
this._viewer.registerDragger("Line", OdaLineDragger);
|
|
17950
|
-
this._viewer.registerDragger("Text", OdaTextDragger);
|
|
17951
18049
|
}
|
|
17952
18050
|
dispose() { }
|
|
17953
18051
|
syncOverlay() { }
|
|
@@ -17986,7 +18084,7 @@ js: import "konva/skia-backend";
|
|
|
17986
18084
|
this._viewer.update();
|
|
17987
18085
|
}
|
|
17988
18086
|
colorizeSelectedMarkups(r = 255, g = 0, b = 0) {
|
|
17989
|
-
|
|
18087
|
+
console.warn("VisualizeMarkup: colorizeSelectedMarkups() not implemented yet");
|
|
17990
18088
|
}
|
|
17991
18089
|
setViewpoint(viewpoint) {
|
|
17992
18090
|
function getLogicalPoint3dAsArray(point3d) {
|
|
@@ -18096,19 +18194,28 @@ js: import "konva/skia-backend";
|
|
|
18096
18194
|
return ((_a = visLib.canvas) === null || _a === void 0 ? void 0 : _a.toDataURL(type, quality)) || "";
|
|
18097
18195
|
}
|
|
18098
18196
|
enableEditMode(mode) {
|
|
18197
|
+
if (mode === "Line" || mode === "Text")
|
|
18198
|
+
this._viewer.setActiveDragger(mode);
|
|
18099
18199
|
return this;
|
|
18100
18200
|
}
|
|
18101
18201
|
createObject(type, params) {
|
|
18202
|
+
console.warn("VisualizeMarkup: createObject() not implemented yet");
|
|
18102
18203
|
return undefined;
|
|
18103
18204
|
}
|
|
18104
18205
|
getObjects() {
|
|
18206
|
+
console.warn("VisualizeMarkup: getObjects() not implemented yet");
|
|
18105
18207
|
return [];
|
|
18106
18208
|
}
|
|
18107
18209
|
getSelectedObjects() {
|
|
18210
|
+
console.warn("VisualizeMarkup: getSelectedObjects() not implemented yet");
|
|
18108
18211
|
return [];
|
|
18109
18212
|
}
|
|
18110
|
-
selectObjects(objects) {
|
|
18111
|
-
|
|
18213
|
+
selectObjects(objects) {
|
|
18214
|
+
console.warn("VisualizeMarkup: selectObjects() not implemented yet");
|
|
18215
|
+
}
|
|
18216
|
+
clearSelected() {
|
|
18217
|
+
console.warn("VisualizeMarkup: clearSelected() not implemented yet");
|
|
18218
|
+
}
|
|
18112
18219
|
}
|
|
18113
18220
|
|
|
18114
18221
|
class MarkupFactory {
|
|
@@ -18149,7 +18256,7 @@ js: import "konva/skia-backend";
|
|
|
18149
18256
|
this._renderNeeded = false;
|
|
18150
18257
|
this._renderTime = 0;
|
|
18151
18258
|
this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== void 0 ? _a : true;
|
|
18152
|
-
this.
|
|
18259
|
+
this._maxRegenTime = 0;
|
|
18153
18260
|
this.render = this.render.bind(this);
|
|
18154
18261
|
this.update = this.update.bind(this);
|
|
18155
18262
|
this._markup = MarkupFactory.createMarkup(params.markupType);
|
|
@@ -18255,18 +18362,6 @@ js: import "konva/skia-backend";
|
|
|
18255
18362
|
this.emitEvent({ type: "resize", width, height });
|
|
18256
18363
|
this.update(true);
|
|
18257
18364
|
}
|
|
18258
|
-
resize() {
|
|
18259
|
-
console.warn("Viewer.resize() has been deprecated since 26.9 and will be removed in a future release, use Viewer.setSize() instead.");
|
|
18260
|
-
if (!this.visualizeJs)
|
|
18261
|
-
return this;
|
|
18262
|
-
if (!this.canvas.parentElement)
|
|
18263
|
-
return this;
|
|
18264
|
-
const { width, height } = this.canvas.parentElement.getBoundingClientRect();
|
|
18265
|
-
if (!width || !height)
|
|
18266
|
-
return this;
|
|
18267
|
-
this.setSize(width, height);
|
|
18268
|
-
return this;
|
|
18269
|
-
}
|
|
18270
18365
|
update(force = false) {
|
|
18271
18366
|
const time = performance.now();
|
|
18272
18367
|
force = force || time - this._renderTime >= this._updateDelay;
|
|
@@ -18278,11 +18373,8 @@ js: import "konva/skia-backend";
|
|
|
18278
18373
|
this.emitEvent({ type: "update", force });
|
|
18279
18374
|
}
|
|
18280
18375
|
render(time) {
|
|
18281
|
-
var _a, _b;
|
|
18282
18376
|
if (!this.visualizeJs)
|
|
18283
18377
|
return;
|
|
18284
|
-
if (this._isRunAsyncUpdate)
|
|
18285
|
-
return;
|
|
18286
18378
|
const renderNeeded = this.visViewer().isRunningAnimation() || this._renderNeeded;
|
|
18287
18379
|
if (!renderNeeded)
|
|
18288
18380
|
return;
|
|
@@ -18291,8 +18383,7 @@ js: import "konva/skia-backend";
|
|
|
18291
18383
|
const deltaTime = (time - this._renderTime) / 1000;
|
|
18292
18384
|
this._renderTime = time;
|
|
18293
18385
|
this._renderNeeded = !this.visViewer().getActiveDevice().isValid();
|
|
18294
|
-
this.visViewer().update();
|
|
18295
|
-
(_b = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
18386
|
+
this.visViewer().update(this._maxRegenTime);
|
|
18296
18387
|
this.emitEvent({ type: "render", time, deltaTime });
|
|
18297
18388
|
}
|
|
18298
18389
|
async loadReferences(model) {
|
|
@@ -18310,12 +18401,12 @@ js: import "konva/skia-backend";
|
|
|
18310
18401
|
await model
|
|
18311
18402
|
.getReferences(abortController.signal)
|
|
18312
18403
|
.then((data) => (references = data.references))
|
|
18313
|
-
.catch((e) => console.error("Cannot load model references.", e));
|
|
18404
|
+
.catch((e) => console.error("Viewer: Cannot load model references.", e));
|
|
18314
18405
|
for (const file of references) {
|
|
18315
18406
|
await this.client
|
|
18316
18407
|
.downloadFile(file.id, undefined, abortController.signal)
|
|
18317
18408
|
.then((arrayBuffer) => { var _a; return (_a = this.visualizeJs) === null || _a === void 0 ? void 0 : _a.getViewer().addEmbeddedFile(file.name, new Uint8Array(arrayBuffer)); })
|
|
18318
|
-
.catch((e) => console.error(`Cannot load reference file ${file.name}.`, e));
|
|
18409
|
+
.catch((e) => console.error(`Viewer: Cannot load reference file ${file.name}.`, e));
|
|
18319
18410
|
}
|
|
18320
18411
|
return this;
|
|
18321
18412
|
}
|
|
@@ -18376,56 +18467,6 @@ js: import "konva/skia-backend";
|
|
|
18376
18467
|
this.update(true);
|
|
18377
18468
|
return this;
|
|
18378
18469
|
}
|
|
18379
|
-
openVsfFile(buffer) {
|
|
18380
|
-
console.warn("Viewer.openVsfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
|
|
18381
|
-
if (!this.visualizeJs)
|
|
18382
|
-
return this;
|
|
18383
|
-
this.cancel();
|
|
18384
|
-
this.clear();
|
|
18385
|
-
this.emitEvent({ type: "open", mode: "file", file: "", buffer });
|
|
18386
|
-
const visViewer = this.visViewer();
|
|
18387
|
-
this.emitEvent({ type: "geometrystart", file: "", buffer });
|
|
18388
|
-
try {
|
|
18389
|
-
const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
18390
|
-
visViewer.parseFile(data);
|
|
18391
|
-
this.syncOptions();
|
|
18392
|
-
this.syncOverlay();
|
|
18393
|
-
this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
|
|
18394
|
-
this.emitEvent({ type: "databasechunk", data, file: "", buffer });
|
|
18395
|
-
}
|
|
18396
|
-
catch (error) {
|
|
18397
|
-
this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
|
|
18398
|
-
throw error;
|
|
18399
|
-
}
|
|
18400
|
-
this.emitEvent({ type: "geometryend", file: "", buffer });
|
|
18401
|
-
this.update(true);
|
|
18402
|
-
return this;
|
|
18403
|
-
}
|
|
18404
|
-
openVsfxFile(buffer) {
|
|
18405
|
-
console.warn("Viewer.openVsfxFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
|
|
18406
|
-
if (!this.visualizeJs)
|
|
18407
|
-
return this;
|
|
18408
|
-
this.cancel();
|
|
18409
|
-
this.clear();
|
|
18410
|
-
this.emitEvent({ type: "open", mode: "file", file: "", buffer });
|
|
18411
|
-
const visViewer = this.visViewer();
|
|
18412
|
-
this.emitEvent({ type: "geometrystart", file: "", buffer });
|
|
18413
|
-
try {
|
|
18414
|
-
const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
18415
|
-
visViewer.parseVsfx(data);
|
|
18416
|
-
this.syncOptions();
|
|
18417
|
-
this.syncOverlay();
|
|
18418
|
-
this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
|
|
18419
|
-
this.emitEvent({ type: "databasechunk", data, file: "", buffer });
|
|
18420
|
-
}
|
|
18421
|
-
catch (error) {
|
|
18422
|
-
this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
|
|
18423
|
-
throw error;
|
|
18424
|
-
}
|
|
18425
|
-
this.emitEvent({ type: "geometryend", file: "", buffer });
|
|
18426
|
-
this.update(true);
|
|
18427
|
-
return this;
|
|
18428
|
-
}
|
|
18429
18470
|
cancel() {
|
|
18430
18471
|
var _a;
|
|
18431
18472
|
(_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
|
|
@@ -18637,15 +18678,10 @@ js: import "konva/skia-backend";
|
|
|
18637
18678
|
collect() {
|
|
18638
18679
|
this.executeCommand("collect");
|
|
18639
18680
|
}
|
|
18640
|
-
registerDragger(name, dragger) {
|
|
18641
|
-
console.warn("Viewer.registerDragger() has been deprecated since 25.12 and will be removed in a future release, use draggers('visualizejs').registerDragger() instead.");
|
|
18642
|
-
draggers.registerDragger(name, (viewer) => new dragger(viewer));
|
|
18643
|
-
}
|
|
18644
18681
|
activeDragger() {
|
|
18645
18682
|
return this._activeDragger;
|
|
18646
18683
|
}
|
|
18647
18684
|
setActiveDragger(name = "") {
|
|
18648
|
-
var _a, _b;
|
|
18649
18685
|
if (!this._activeDragger || this._activeDragger.name !== name) {
|
|
18650
18686
|
const oldDragger = this._activeDragger;
|
|
18651
18687
|
let newDragger = null;
|
|
@@ -18655,10 +18691,7 @@ js: import "konva/skia-backend";
|
|
|
18655
18691
|
}
|
|
18656
18692
|
if (this.visualizeJs) {
|
|
18657
18693
|
newDragger = draggers.createDragger(name, this);
|
|
18658
|
-
|
|
18659
|
-
this._activeDragger = newDragger;
|
|
18660
|
-
(_b = (_a = this._activeDragger).initialize) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
18661
|
-
}
|
|
18694
|
+
this._activeDragger = newDragger;
|
|
18662
18695
|
}
|
|
18663
18696
|
const canvas = this.canvas;
|
|
18664
18697
|
if (canvas) {
|
|
@@ -18864,51 +18897,34 @@ js: import "konva/skia-backend";
|
|
|
18864
18897
|
const model = visViewer.getMarkupModel();
|
|
18865
18898
|
const entityId = model.appendEntity(entityName);
|
|
18866
18899
|
const entityPtr = entityId.openObject();
|
|
18867
|
-
const color = this.getMarkupColor();
|
|
18900
|
+
const color = this.markup.getMarkupColor();
|
|
18868
18901
|
entityPtr.setColor(color.r, color.g, color.b);
|
|
18869
18902
|
entityPtr.setLineWeight(2);
|
|
18870
18903
|
entityPtr.delete();
|
|
18871
18904
|
this.update();
|
|
18872
18905
|
return entityId;
|
|
18873
18906
|
}
|
|
18874
|
-
getMarkupColor() {
|
|
18875
|
-
console.warn("Viewer.getMarkupColor() has been deprecated since 25.11 and will be removed in a future release, use Viewer.markup.getMarkupColor() instead.");
|
|
18876
|
-
return this._markup.getMarkupColor();
|
|
18877
|
-
}
|
|
18878
|
-
setMarkupColor(r = 255, g = 0, b = 0) {
|
|
18879
|
-
console.warn("Viewer.setMarkupColor() has been deprecated since 25.11 and will be removed in a future release, use Viewer.markup.setMarkupColor() instead.");
|
|
18880
|
-
this._markup.setMarkupColor(r, g, b);
|
|
18881
|
-
}
|
|
18882
|
-
colorizeAllMarkup(r = 255, g = 0, b = 0) {
|
|
18883
|
-
console.warn("Viewer.colorizeAllMarkup() has been deprecated since 25.11 and will be removed in a future release, use Viewer.markup.colorizeAllMarkup() instead.");
|
|
18884
|
-
this._markup.colorizeAllMarkup(r, g, b);
|
|
18885
|
-
}
|
|
18886
|
-
colorizeSelectedMarkups(r = 255, g = 0, b = 0) {
|
|
18887
|
-
this._markup.colorizeSelectedMarkups(r, g, b);
|
|
18888
|
-
}
|
|
18889
18907
|
scheduleUpdateAsync(maxScheduleUpdateTimeInMs = 50) {
|
|
18890
18908
|
return new Promise((resolve, reject) => {
|
|
18891
18909
|
setTimeout(() => {
|
|
18892
|
-
|
|
18910
|
+
this._maxRegenTime = maxScheduleUpdateTimeInMs;
|
|
18893
18911
|
try {
|
|
18894
|
-
|
|
18895
|
-
(_a = this.visViewer()) === null || _a === void 0 ? void 0 : _a.update(maxScheduleUpdateTimeInMs);
|
|
18896
|
-
(_c = (_b = this._activeDragger) === null || _b === void 0 ? void 0 : _b.updatePreview) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
18897
|
-
}
|
|
18898
|
-
this.emitEvent({ type: "update", force: false });
|
|
18912
|
+
this.update(true);
|
|
18899
18913
|
resolve();
|
|
18900
18914
|
}
|
|
18901
18915
|
catch (e) {
|
|
18902
|
-
console.error(e);
|
|
18916
|
+
console.error("Viewer: Async update error.", e);
|
|
18903
18917
|
reject();
|
|
18904
18918
|
}
|
|
18919
|
+
finally {
|
|
18920
|
+
this._maxRegenTime = 0;
|
|
18921
|
+
}
|
|
18905
18922
|
}, 0);
|
|
18906
18923
|
});
|
|
18907
18924
|
}
|
|
18908
18925
|
async updateAsync(maxScheduleUpdateTimeInMs = 50, maxScheduleUpdateCount = 50) {
|
|
18909
18926
|
if (!this.visualizeJs)
|
|
18910
18927
|
return;
|
|
18911
|
-
this._isRunAsyncUpdate = true;
|
|
18912
18928
|
try {
|
|
18913
18929
|
const device = this.visViewer().getActiveDevice();
|
|
18914
18930
|
for (let iterationCount = 0; !device.isValid() && iterationCount < maxScheduleUpdateCount; iterationCount++) {
|
|
@@ -18917,10 +18933,7 @@ js: import "konva/skia-backend";
|
|
|
18917
18933
|
await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
|
|
18918
18934
|
}
|
|
18919
18935
|
catch (e) {
|
|
18920
|
-
console.error(e);
|
|
18921
|
-
}
|
|
18922
|
-
finally {
|
|
18923
|
-
this._isRunAsyncUpdate = false;
|
|
18936
|
+
console.error("Viewer: Async update error.", e);
|
|
18924
18937
|
}
|
|
18925
18938
|
}
|
|
18926
18939
|
deviceAutoRegeneration() {
|