@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
|
@@ -365,6 +365,15 @@ const CanvasEvents = [ "click", "contextmenu", "dblclick", "mousedown", "mousele
|
|
|
365
365
|
|
|
366
366
|
const CANVAS_EVENTS = CanvasEvents;
|
|
367
367
|
|
|
368
|
+
class Dragger {
|
|
369
|
+
constructor(viewer) {
|
|
370
|
+
this.name = "";
|
|
371
|
+
}
|
|
372
|
+
initialize() {}
|
|
373
|
+
dispose() {}
|
|
374
|
+
updatePreview() {}
|
|
375
|
+
}
|
|
376
|
+
|
|
368
377
|
const composeMatrixFromTransform = (translate, rotate, scale, modelCenter, matrix) => {
|
|
369
378
|
const translateMatrix = matrix.setTranslation([ translate.x, translate.y, translate.z ]);
|
|
370
379
|
const rotateMatrix = matrix.setToRotation(rotate.angle, [ rotate.x, rotate.y, rotate.z ], modelCenter);
|
|
@@ -727,11 +736,11 @@ class EventEmitter2 {
|
|
|
727
736
|
off(type, listener) {
|
|
728
737
|
return this.removeEventListener(type, listener);
|
|
729
738
|
}
|
|
730
|
-
emit(
|
|
731
|
-
if (typeof
|
|
732
|
-
type:
|
|
739
|
+
emit(type, ...args) {
|
|
740
|
+
if (typeof type === "string") return this.emitEvent({
|
|
741
|
+
type: type,
|
|
733
742
|
args: args
|
|
734
|
-
}); else if (typeof
|
|
743
|
+
}); else if (typeof type === "object") return this.emitEvent(type); else return false;
|
|
735
744
|
}
|
|
736
745
|
}
|
|
737
746
|
|
|
@@ -2992,14 +3001,6 @@ class LoaderFactory {
|
|
|
2992
3001
|
}
|
|
2993
3002
|
}
|
|
2994
3003
|
|
|
2995
|
-
var MarkupType;
|
|
2996
|
-
|
|
2997
|
-
(function(MarkupType) {
|
|
2998
|
-
MarkupType[MarkupType["Unknown"] = 0] = "Unknown";
|
|
2999
|
-
MarkupType["Konva"] = "Konva";
|
|
3000
|
-
MarkupType["Visualize"] = "Visualize";
|
|
3001
|
-
})(MarkupType || (MarkupType = {}));
|
|
3002
|
-
|
|
3003
3004
|
var MarkupMode;
|
|
3004
3005
|
|
|
3005
3006
|
(function(MarkupMode) {
|
|
@@ -3901,6 +3902,8 @@ const MarkupMode2Konva = new Map([ [ MarkupMode.SelectMarkup, {
|
|
|
3901
3902
|
class KonvaMarkup {
|
|
3902
3903
|
constructor() {
|
|
3903
3904
|
this._isInitialized = false;
|
|
3905
|
+
this._markupIsActive = false;
|
|
3906
|
+
this._markupColor = new MarkupColor(255, 0, 0);
|
|
3904
3907
|
this._zIndex = 1;
|
|
3905
3908
|
this._markupContainerName = "markupContainer";
|
|
3906
3909
|
this.lineWidth = 4;
|
|
@@ -3935,14 +3938,15 @@ class KonvaMarkup {
|
|
|
3935
3938
|
})))));
|
|
3936
3939
|
};
|
|
3937
3940
|
this.redirectToViewer = event => {
|
|
3938
|
-
this._viewer.emit(event);
|
|
3941
|
+
if (this._viewer) this._viewer.emit(event);
|
|
3939
3942
|
};
|
|
3940
3943
|
}
|
|
3941
|
-
initialize(
|
|
3942
|
-
if (!Konva) throw new Error('
|
|
3944
|
+
initialize(canvas, canvasEvents, viewer, worldTransformer) {
|
|
3945
|
+
if (!Konva) 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>');
|
|
3943
3946
|
this._viewer = viewer;
|
|
3947
|
+
this._worldTransformer = worldTransformer;
|
|
3944
3948
|
this._canvasOriginal = canvas;
|
|
3945
|
-
this._canvasEvents = canvasEvents;
|
|
3949
|
+
this._canvasEvents = canvasEvents !== null && canvasEvents !== void 0 ? canvasEvents : [];
|
|
3946
3950
|
this._markupContainer = document.createElement("div");
|
|
3947
3951
|
this._markupContainer.id = this._markupContainerName;
|
|
3948
3952
|
this._markupContainer.style.position = "absolute";
|
|
@@ -3951,32 +3955,35 @@ class KonvaMarkup {
|
|
|
3951
3955
|
this._markupContainer.style.outline = "0px";
|
|
3952
3956
|
const parentDiv = this._canvasOriginal.parentElement;
|
|
3953
3957
|
parentDiv.appendChild(this._markupContainer);
|
|
3954
|
-
this._markupColor
|
|
3955
|
-
this._markupIsActive = false;
|
|
3958
|
+
this._markupColor.setColor(255, 0, 0);
|
|
3956
3959
|
this.initializeKonva();
|
|
3957
3960
|
this.resize();
|
|
3958
3961
|
this._canvasEvents.forEach((x => this._markupContainer.addEventListener(x, this.redirectToViewer)));
|
|
3959
|
-
this._viewer
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
+
if (this._viewer) {
|
|
3963
|
+
this._viewer.addEventListener("resize", this.resize);
|
|
3964
|
+
this._viewer.addEventListener("changeactivedragger", this.changeActiveDragger);
|
|
3965
|
+
this._viewer.addEventListener("pan", this.pan);
|
|
3966
|
+
}
|
|
3962
3967
|
this._isInitialized = true;
|
|
3963
3968
|
}
|
|
3964
3969
|
dispose() {
|
|
3965
3970
|
if (!this._isInitialized) return;
|
|
3971
|
+
if (this._viewer) {
|
|
3972
|
+
this._viewer.removeEventListener("pan", this.pan);
|
|
3973
|
+
this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
|
|
3974
|
+
this._viewer.removeEventListener("resize", this.resize);
|
|
3975
|
+
}
|
|
3966
3976
|
this._canvasEvents.forEach((x => this._markupContainer.removeEventListener(x, this.redirectToViewer)));
|
|
3967
|
-
this._viewer.removeEventListener("pan", this.pan);
|
|
3968
|
-
this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
|
|
3969
|
-
this._viewer.removeEventListener("resize", this.resize);
|
|
3970
3977
|
this.destroyKonva();
|
|
3971
3978
|
this._markupContainer.remove();
|
|
3972
3979
|
this._markupContainer = undefined;
|
|
3973
3980
|
this._canvasOriginal = undefined;
|
|
3974
3981
|
this._viewer = undefined;
|
|
3982
|
+
this._worldTransformer = undefined;
|
|
3983
|
+
this._markupIsActive = false;
|
|
3975
3984
|
this._isInitialized = false;
|
|
3976
3985
|
}
|
|
3977
|
-
|
|
3978
|
-
return null;
|
|
3979
|
-
}
|
|
3986
|
+
syncOverlay() {}
|
|
3980
3987
|
clearOverlay() {
|
|
3981
3988
|
this.removeTextInput();
|
|
3982
3989
|
this.removeImageInput();
|
|
@@ -4018,7 +4025,6 @@ class KonvaMarkup {
|
|
|
4018
4025
|
this.loadMarkup(viewpoint);
|
|
4019
4026
|
}
|
|
4020
4027
|
getViewpoint() {
|
|
4021
|
-
if (!this._viewer.visualizeJs) return {};
|
|
4022
4028
|
const viewpoint = {
|
|
4023
4029
|
lines: [],
|
|
4024
4030
|
texts: [],
|
|
@@ -4039,7 +4045,7 @@ class KonvaMarkup {
|
|
|
4039
4045
|
return viewpoint;
|
|
4040
4046
|
}
|
|
4041
4047
|
createObject(type, params) {
|
|
4042
|
-
let object;
|
|
4048
|
+
let object = null;
|
|
4043
4049
|
let zIndex = this._zIndex;
|
|
4044
4050
|
switch (type.toLocaleLowerCase()) {
|
|
4045
4051
|
case "line":
|
|
@@ -4443,7 +4449,7 @@ class KonvaMarkup {
|
|
|
4443
4449
|
x: linePoints[i],
|
|
4444
4450
|
y: linePoints[i + 1]
|
|
4445
4451
|
});
|
|
4446
|
-
const worldPoint = this.
|
|
4452
|
+
const worldPoint = this._worldTransformer.screenToWorld(atPoint);
|
|
4447
4453
|
worldPoints.push(worldPoint);
|
|
4448
4454
|
}
|
|
4449
4455
|
const konvaLine = new KonvaLine(null, line);
|
|
@@ -4460,22 +4466,19 @@ class KonvaMarkup {
|
|
|
4460
4466
|
getMarkupTexts() {
|
|
4461
4467
|
const texts = [];
|
|
4462
4468
|
const textSize = .02;
|
|
4463
|
-
|
|
4464
|
-
const projMtrx = this._viewer.visViewer().activeView.projectionMatrix;
|
|
4465
|
-
const mtrxNumber = projMtrx.get(1, 1);
|
|
4466
|
-
const tol = 1e-6;
|
|
4467
|
-
if (mtrxNumber > tol || mtrxNumber < -tol) {
|
|
4468
|
-
textScale = 1 / mtrxNumber;
|
|
4469
|
-
}
|
|
4469
|
+
const textScale = this._worldTransformer.getScale();
|
|
4470
4470
|
this.konvaLayerFind(MarkupMode.Text).forEach((text => {
|
|
4471
4471
|
if (!text) return;
|
|
4472
|
-
const position = this.
|
|
4472
|
+
const position = this._worldTransformer.screenToWorld({
|
|
4473
|
+
x: text.x(),
|
|
4474
|
+
y: text.y()
|
|
4475
|
+
});
|
|
4473
4476
|
const shape = new KonvaText(null, text);
|
|
4474
4477
|
texts.push({
|
|
4475
4478
|
id: shape.id(),
|
|
4476
4479
|
position: this.getPoint3dFromArray(position),
|
|
4477
4480
|
text: shape.getText(),
|
|
4478
|
-
text_size: textSize * textScale,
|
|
4481
|
+
text_size: textSize * textScale.y,
|
|
4479
4482
|
angle: shape.getRotation(),
|
|
4480
4483
|
color: shape.getColor(),
|
|
4481
4484
|
font_size: shape.getFontSize()
|
|
@@ -4487,7 +4490,7 @@ class KonvaMarkup {
|
|
|
4487
4490
|
const rectangles = [];
|
|
4488
4491
|
this.konvaLayerFind(MarkupMode.Rectangle).forEach((rect => {
|
|
4489
4492
|
const position = rect.position();
|
|
4490
|
-
const worldPoint = this.
|
|
4493
|
+
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
4491
4494
|
const shape = new KonvaRectangle(null, rect);
|
|
4492
4495
|
rectangles.push({
|
|
4493
4496
|
id: shape.id(),
|
|
@@ -4504,7 +4507,7 @@ class KonvaMarkup {
|
|
|
4504
4507
|
const ellipses = [];
|
|
4505
4508
|
this.konvaLayerFind(MarkupMode.Ellipse).forEach((ellipse => {
|
|
4506
4509
|
const position = ellipse.position();
|
|
4507
|
-
const worldPoint = this.
|
|
4510
|
+
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
4508
4511
|
const shape = new KonvaEllipse(null, ellipse);
|
|
4509
4512
|
ellipses.push({
|
|
4510
4513
|
id: shape.id(),
|
|
@@ -4527,12 +4530,12 @@ class KonvaMarkup {
|
|
|
4527
4530
|
x: arrow.points()[0],
|
|
4528
4531
|
y: arrow.points()[1]
|
|
4529
4532
|
});
|
|
4530
|
-
const worldStartPoint = this.
|
|
4533
|
+
const worldStartPoint = this._worldTransformer.screenToWorld(atStartPoint);
|
|
4531
4534
|
const atEndPoint = absoluteTransform.point({
|
|
4532
4535
|
x: arrow.points()[2],
|
|
4533
4536
|
y: arrow.points()[3]
|
|
4534
4537
|
});
|
|
4535
|
-
const worldEndPoint = this.
|
|
4538
|
+
const worldEndPoint = this._worldTransformer.screenToWorld(atEndPoint);
|
|
4536
4539
|
const shape = new KonvaArrow(null, arrow);
|
|
4537
4540
|
arrows.push({
|
|
4538
4541
|
id: shape.id(),
|
|
@@ -4547,7 +4550,7 @@ class KonvaMarkup {
|
|
|
4547
4550
|
const images = [];
|
|
4548
4551
|
this.konvaLayerFind(MarkupMode.Image).forEach((image => {
|
|
4549
4552
|
const position = image.position();
|
|
4550
|
-
const worldPoint = this.
|
|
4553
|
+
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
4551
4554
|
const shape = new KonvaImage(null, image);
|
|
4552
4555
|
images.push({
|
|
4553
4556
|
id: shape.id(),
|
|
@@ -4563,7 +4566,7 @@ class KonvaMarkup {
|
|
|
4563
4566
|
const clouds = [];
|
|
4564
4567
|
this.konvaLayerFind(MarkupMode.Cloud).forEach((cloud => {
|
|
4565
4568
|
const position = cloud.position();
|
|
4566
|
-
const worldPoint = this.
|
|
4569
|
+
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
4567
4570
|
const shape = new KonvaCloud(null, cloud);
|
|
4568
4571
|
clouds.push({
|
|
4569
4572
|
id: shape.id(),
|
|
@@ -4581,57 +4584,36 @@ class KonvaMarkup {
|
|
|
4581
4584
|
(_a = viewpoint.lines) === null || _a === void 0 ? void 0 : _a.forEach((vpLine => {
|
|
4582
4585
|
const linePoints = [];
|
|
4583
4586
|
vpLine.points.forEach((point => {
|
|
4584
|
-
const screenPoint =
|
|
4587
|
+
const screenPoint = this._worldTransformer.worldToScreen(point);
|
|
4585
4588
|
linePoints.push(screenPoint.x);
|
|
4586
4589
|
linePoints.push(screenPoint.y);
|
|
4587
4590
|
}));
|
|
4588
4591
|
this.addLine(linePoints, vpLine.color, vpLine.type, vpLine.width, vpLine.id);
|
|
4589
4592
|
}));
|
|
4590
4593
|
(_b = viewpoint.texts) === null || _b === void 0 ? void 0 : _b.forEach((vpText => {
|
|
4591
|
-
const screenPoint = worldToScreen(
|
|
4594
|
+
const screenPoint = this._worldTransformer.worldToScreen(vpText.position);
|
|
4592
4595
|
this.addText(vpText.text, screenPoint, vpText.angle, vpText.color, vpText.text_size, vpText.font_size, vpText.id);
|
|
4593
4596
|
}));
|
|
4594
4597
|
(_c = viewpoint.rectangles) === null || _c === void 0 ? void 0 : _c.forEach((vpRect => {
|
|
4595
|
-
const screenPoint = worldToScreen(
|
|
4596
|
-
this.addRectangle(
|
|
4597
|
-
x: screenPoint.x,
|
|
4598
|
-
y: screenPoint.y
|
|
4599
|
-
}, vpRect.width, vpRect.height, vpRect.line_width, vpRect.color, vpRect.id);
|
|
4598
|
+
const screenPoint = this._worldTransformer.worldToScreen(vpRect.position);
|
|
4599
|
+
this.addRectangle(screenPoint, vpRect.width, vpRect.height, vpRect.line_width, vpRect.color, vpRect.id);
|
|
4600
4600
|
}));
|
|
4601
4601
|
(_d = viewpoint.ellipses) === null || _d === void 0 ? void 0 : _d.forEach((vpEllipse => {
|
|
4602
|
-
const screenPoint = worldToScreen(
|
|
4603
|
-
this.addEllipse(
|
|
4604
|
-
x: screenPoint.x,
|
|
4605
|
-
y: screenPoint.y
|
|
4606
|
-
}, {
|
|
4607
|
-
x: vpEllipse.radius.x,
|
|
4608
|
-
y: vpEllipse.radius.y
|
|
4609
|
-
}, vpEllipse.line_width, vpEllipse.color, vpEllipse.id);
|
|
4602
|
+
const screenPoint = this._worldTransformer.worldToScreen(vpEllipse.position);
|
|
4603
|
+
this.addEllipse(screenPoint, vpEllipse.radius, vpEllipse.line_width, vpEllipse.color, vpEllipse.id);
|
|
4610
4604
|
}));
|
|
4611
4605
|
(_e = viewpoint.arrows) === null || _e === void 0 ? void 0 : _e.forEach((vpArrow => {
|
|
4612
|
-
const startPoint = worldToScreen(
|
|
4613
|
-
const endPoint = worldToScreen(
|
|
4614
|
-
this.addArrow(
|
|
4615
|
-
x: startPoint.x,
|
|
4616
|
-
y: startPoint.y
|
|
4617
|
-
}, {
|
|
4618
|
-
x: endPoint.x,
|
|
4619
|
-
y: endPoint.y
|
|
4620
|
-
}, vpArrow.color, vpArrow.id);
|
|
4606
|
+
const startPoint = this._worldTransformer.worldToScreen(vpArrow.start);
|
|
4607
|
+
const endPoint = this._worldTransformer.worldToScreen(vpArrow.end);
|
|
4608
|
+
this.addArrow(startPoint, endPoint, vpArrow.color, vpArrow.id);
|
|
4621
4609
|
}));
|
|
4622
4610
|
(_f = viewpoint.clouds) === null || _f === void 0 ? void 0 : _f.forEach((vpCloud => {
|
|
4623
|
-
const screenPoint = worldToScreen(
|
|
4624
|
-
this.addCloud(
|
|
4625
|
-
x: screenPoint.x,
|
|
4626
|
-
y: screenPoint.y
|
|
4627
|
-
}, vpCloud.width, vpCloud.height, vpCloud.line_width, vpCloud.color, vpCloud.id);
|
|
4611
|
+
const screenPoint = this._worldTransformer.worldToScreen(vpCloud.position);
|
|
4612
|
+
this.addCloud(screenPoint, vpCloud.width, vpCloud.height, vpCloud.line_width, vpCloud.color, vpCloud.id);
|
|
4628
4613
|
}));
|
|
4629
4614
|
(_g = viewpoint.images) === null || _g === void 0 ? void 0 : _g.forEach((vpImage => {
|
|
4630
|
-
const screenPoint = worldToScreen(
|
|
4631
|
-
this.addImage(
|
|
4632
|
-
x: screenPoint.x,
|
|
4633
|
-
y: screenPoint.y
|
|
4634
|
-
}, vpImage.src, vpImage.width, vpImage.height, vpImage.id);
|
|
4615
|
+
const screenPoint = this._worldTransformer.worldToScreen(vpImage.position);
|
|
4616
|
+
this.addImage(screenPoint, vpImage.src, vpImage.width, vpImage.height, vpImage.id);
|
|
4635
4617
|
}));
|
|
4636
4618
|
}
|
|
4637
4619
|
combineMarkupWithDrawing() {
|
|
@@ -4748,17 +4730,18 @@ class KonvaMarkup {
|
|
|
4748
4730
|
this._imageInputPos = null;
|
|
4749
4731
|
}
|
|
4750
4732
|
addText(specifiedText, position, angle, color, textSize, fontSize, id) {
|
|
4733
|
+
const trNodes = this._konvaTransformer.nodes();
|
|
4734
|
+
if (trNodes.length > 0) {
|
|
4735
|
+
trNodes[0].destroy();
|
|
4736
|
+
this._konvaTransformer.nodes([]);
|
|
4737
|
+
}
|
|
4738
|
+
this.removeTextInput();
|
|
4751
4739
|
if (specifiedText) {
|
|
4752
|
-
const
|
|
4753
|
-
if (textSize && textSize >
|
|
4740
|
+
const tolerance = 1e-6;
|
|
4741
|
+
if (textSize && textSize > tolerance && (!fontSize || fontSize < tolerance)) {
|
|
4754
4742
|
const size = .02;
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
const mtrxNumber = projMtrx.get(1, 1);
|
|
4758
|
-
if (mtrxNumber > tol || mtrxNumber < -tol) {
|
|
4759
|
-
scale = 1 / mtrxNumber;
|
|
4760
|
-
}
|
|
4761
|
-
fontSize = textSize / (scale / size) / 34;
|
|
4743
|
+
const scale = this._worldTransformer.getScale();
|
|
4744
|
+
fontSize = textSize / (scale.y / size) / 34;
|
|
4762
4745
|
}
|
|
4763
4746
|
const konvaText = new KonvaText({
|
|
4764
4747
|
position: {
|
|
@@ -4772,14 +4755,8 @@ class KonvaMarkup {
|
|
|
4772
4755
|
id: id
|
|
4773
4756
|
});
|
|
4774
4757
|
this._konvaLayer.add(konvaText.ref());
|
|
4758
|
+
return konvaText;
|
|
4775
4759
|
}
|
|
4776
|
-
const trNodes = this._konvaTransformer.nodes();
|
|
4777
|
-
if (trNodes.length > 0) {
|
|
4778
|
-
trNodes[0].destroy();
|
|
4779
|
-
this._konvaTransformer.nodes([]);
|
|
4780
|
-
}
|
|
4781
|
-
this.removeTextInput();
|
|
4782
|
-
return;
|
|
4783
4760
|
}
|
|
4784
4761
|
addRectangle(position, width, height, lineWidth, color, id) {
|
|
4785
4762
|
if (!position) return;
|
|
@@ -4980,6 +4957,8 @@ class OdaTextDragger extends OdBaseDragger {
|
|
|
4980
4957
|
}
|
|
4981
4958
|
}
|
|
4982
4959
|
|
|
4960
|
+
const OVERLAY_VIEW_NAME = "$OVERLAY_VIEW_NAME";
|
|
4961
|
+
|
|
4983
4962
|
class VisualizeMarkup {
|
|
4984
4963
|
constructor() {
|
|
4985
4964
|
this._markupColor = {
|
|
@@ -4990,12 +4969,35 @@ class VisualizeMarkup {
|
|
|
4990
4969
|
this.lineWidth = 4;
|
|
4991
4970
|
this.fontSize = 34;
|
|
4992
4971
|
}
|
|
4993
|
-
initialize(
|
|
4972
|
+
initialize(canvas, canvasEvents, viewer, worldTransformer) {
|
|
4994
4973
|
this._viewer = viewer;
|
|
4974
|
+
this._viewer.registerDragger("Line", OdaLineDragger);
|
|
4975
|
+
this._viewer.registerDragger("Text", OdaTextDragger);
|
|
4995
4976
|
}
|
|
4996
4977
|
dispose() {}
|
|
4997
|
-
|
|
4998
|
-
|
|
4978
|
+
syncOverlay() {
|
|
4979
|
+
if (!this._viewer.visualizeJs) return;
|
|
4980
|
+
const visViewer = this._viewer.visViewer();
|
|
4981
|
+
const activeView = visViewer.activeView;
|
|
4982
|
+
let overlayView = visViewer.getViewByName(OVERLAY_VIEW_NAME);
|
|
4983
|
+
if (!overlayView) {
|
|
4984
|
+
const overlayModel = visViewer.getMarkupModel();
|
|
4985
|
+
const pDevice = visViewer.getActiveDevice();
|
|
4986
|
+
overlayView = pDevice.createView(OVERLAY_VIEW_NAME, false);
|
|
4987
|
+
overlayView.addModel(overlayModel);
|
|
4988
|
+
activeView.addSibling(overlayView);
|
|
4989
|
+
pDevice.addView(overlayView);
|
|
4990
|
+
}
|
|
4991
|
+
overlayView.viewPosition = activeView.viewPosition;
|
|
4992
|
+
overlayView.viewTarget = activeView.viewTarget;
|
|
4993
|
+
overlayView.upVector = activeView.upVector;
|
|
4994
|
+
overlayView.viewFieldWidth = activeView.viewFieldWidth;
|
|
4995
|
+
overlayView.viewFieldHeight = activeView.viewFieldHeight;
|
|
4996
|
+
const viewPort = overlayView.getViewport();
|
|
4997
|
+
overlayView.setViewport(viewPort.lowerLeft, viewPort.upperRight);
|
|
4998
|
+
overlayView.vportRect = activeView.vportRect;
|
|
4999
|
+
this._viewer.update();
|
|
5000
|
+
return overlayView;
|
|
4999
5001
|
}
|
|
5000
5002
|
clearOverlay() {
|
|
5001
5003
|
if (!this._viewer.visualizeJs) return;
|
|
@@ -5165,38 +5167,38 @@ class VisualizeMarkup {
|
|
|
5165
5167
|
}
|
|
5166
5168
|
}
|
|
5167
5169
|
|
|
5170
|
+
var MarkupType;
|
|
5171
|
+
|
|
5172
|
+
(function(MarkupType) {
|
|
5173
|
+
MarkupType[MarkupType["Unknown"] = 0] = "Unknown";
|
|
5174
|
+
MarkupType["Konva"] = "Konva";
|
|
5175
|
+
MarkupType["Visualize"] = "Visualize";
|
|
5176
|
+
})(MarkupType || (MarkupType = {}));
|
|
5177
|
+
|
|
5168
5178
|
class MarkupFactory {
|
|
5169
|
-
static createMarkup(markupType) {
|
|
5179
|
+
static createMarkup(markupType = MarkupType.Konva) {
|
|
5170
5180
|
let markup;
|
|
5171
5181
|
switch (markupType) {
|
|
5172
5182
|
case MarkupType.Konva:
|
|
5173
|
-
markup =
|
|
5183
|
+
markup = new KonvaMarkup;
|
|
5174
5184
|
break;
|
|
5175
5185
|
|
|
5176
5186
|
case MarkupType.Visualize:
|
|
5177
|
-
markup =
|
|
5187
|
+
markup = new VisualizeMarkup;
|
|
5178
5188
|
break;
|
|
5179
5189
|
|
|
5180
5190
|
default:
|
|
5181
|
-
throw new Error("Error during Markup
|
|
5191
|
+
throw new Error("Error during Markup initialization. Unknown Markup type.");
|
|
5182
5192
|
}
|
|
5183
5193
|
return markup;
|
|
5184
5194
|
}
|
|
5185
|
-
static createKonva() {
|
|
5186
|
-
return new KonvaMarkup;
|
|
5187
|
-
}
|
|
5188
|
-
static createVisualize() {
|
|
5189
|
-
return new VisualizeMarkup;
|
|
5190
|
-
}
|
|
5191
5195
|
}
|
|
5192
5196
|
|
|
5193
|
-
const OVERLAY_VIEW_NAME = "$OVERLAY_VIEW_NAME";
|
|
5194
|
-
|
|
5195
5197
|
const isExist = value => value !== undefined && value !== null;
|
|
5196
5198
|
|
|
5197
5199
|
class Viewer extends EventEmitter2 {
|
|
5198
5200
|
constructor(client, params = {}) {
|
|
5199
|
-
var _a
|
|
5201
|
+
var _a;
|
|
5200
5202
|
super();
|
|
5201
5203
|
this._visualizeJsUrl = "";
|
|
5202
5204
|
this.frameId = 0;
|
|
@@ -5207,7 +5209,6 @@ class Viewer extends EventEmitter2 {
|
|
|
5207
5209
|
this._zoomWheelDragger = null;
|
|
5208
5210
|
this._gestureManager = null;
|
|
5209
5211
|
this._renderTime = 0;
|
|
5210
|
-
this.markup = MarkupFactory.createMarkup((_a = params.markupType) !== null && _a !== void 0 ? _a : MarkupType.Konva);
|
|
5211
5212
|
this.draggerFactory = new Map;
|
|
5212
5213
|
this.registerDragger("Pan", OdPanDragger);
|
|
5213
5214
|
this.registerDragger("Orbit", OdOrbitDragger);
|
|
@@ -5219,17 +5220,14 @@ class Viewer extends EventEmitter2 {
|
|
|
5219
5220
|
this.registerDragger("CuttingPlaneYAxis", OdCuttingPlaneYAxisDragger);
|
|
5220
5221
|
this.registerDragger("CuttingPlaneZAxis", OdCuttingPlaneZAxisDragger);
|
|
5221
5222
|
this.registerDragger("Walk", OdaWalkDragger);
|
|
5222
|
-
const markupDraggers = this.markup.getDraggers();
|
|
5223
|
-
markupDraggers === null || markupDraggers === void 0 ? void 0 : markupDraggers.forEach(((value, key) => {
|
|
5224
|
-
this.registerDragger(key, value);
|
|
5225
|
-
}));
|
|
5226
5223
|
this.canvasEvents = CANVAS_EVENTS.slice();
|
|
5227
5224
|
this.canvaseventlistener = event => this.emit(event);
|
|
5228
|
-
this._enableAutoUpdate = (
|
|
5225
|
+
this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== void 0 ? _a : true;
|
|
5229
5226
|
this._isNeedRender = false;
|
|
5230
5227
|
this._isRunAsyncUpdate = false;
|
|
5231
5228
|
this.render = this.render.bind(this);
|
|
5232
5229
|
this.resize = this.resize.bind(this);
|
|
5230
|
+
this._markup = MarkupFactory.createMarkup(params.markupType);
|
|
5233
5231
|
}
|
|
5234
5232
|
get options() {
|
|
5235
5233
|
return this._options;
|
|
@@ -5237,6 +5235,9 @@ class Viewer extends EventEmitter2 {
|
|
|
5237
5235
|
get visualizeJsUrl() {
|
|
5238
5236
|
return this._visualizeJsUrl;
|
|
5239
5237
|
}
|
|
5238
|
+
get markup() {
|
|
5239
|
+
return this._markup;
|
|
5240
|
+
}
|
|
5240
5241
|
configure(params) {
|
|
5241
5242
|
this._visualizeJsUrl = params.visualizeJsUrl || "https://opencloud.azureedge.net/libs/visualizejs/master/Visualize.js";
|
|
5242
5243
|
return this;
|
|
@@ -5270,7 +5271,7 @@ class Viewer extends EventEmitter2 {
|
|
|
5270
5271
|
this.visualizeJs.Viewer.create();
|
|
5271
5272
|
this.canvas = canvas;
|
|
5272
5273
|
this.canvasEvents.forEach((x => canvas.addEventListener(x, this.canvaseventlistener)));
|
|
5273
|
-
this.
|
|
5274
|
+
this._markup.initialize(this.canvas, this.canvasEvents, this, this);
|
|
5274
5275
|
this._resizeObserver = new ResizeObserver(this.resize);
|
|
5275
5276
|
this._resizeObserver.observe(canvas.parentElement);
|
|
5276
5277
|
this.resize();
|
|
@@ -5303,7 +5304,7 @@ class Viewer extends EventEmitter2 {
|
|
|
5303
5304
|
this._zoomWheelDragger = undefined;
|
|
5304
5305
|
if (this._resizeObserver) this._resizeObserver.disconnect();
|
|
5305
5306
|
this._resizeObserver = undefined;
|
|
5306
|
-
this.
|
|
5307
|
+
this._markup.dispose();
|
|
5307
5308
|
if (this.canvas) {
|
|
5308
5309
|
this.canvasEvents.forEach((x => this.canvas.removeEventListener(x, this.canvaseventlistener)));
|
|
5309
5310
|
this.canvas = undefined;
|
|
@@ -5572,31 +5573,10 @@ class Viewer extends EventEmitter2 {
|
|
|
5572
5573
|
this.update();
|
|
5573
5574
|
}
|
|
5574
5575
|
clearOverlay() {
|
|
5575
|
-
this.
|
|
5576
|
+
this._markup.clearOverlay();
|
|
5576
5577
|
}
|
|
5577
5578
|
syncOverlay() {
|
|
5578
|
-
|
|
5579
|
-
const visViewer = this.visViewer();
|
|
5580
|
-
const activeView = visViewer.activeView;
|
|
5581
|
-
let overlayView = visViewer.getViewByName(OVERLAY_VIEW_NAME);
|
|
5582
|
-
if (!overlayView) {
|
|
5583
|
-
const overlayModel = visViewer.getMarkupModel();
|
|
5584
|
-
const pDevice = visViewer.getActiveDevice();
|
|
5585
|
-
overlayView = pDevice.createView(OVERLAY_VIEW_NAME, false);
|
|
5586
|
-
overlayView.addModel(overlayModel);
|
|
5587
|
-
activeView.addSibling(overlayView);
|
|
5588
|
-
pDevice.addView(overlayView);
|
|
5589
|
-
}
|
|
5590
|
-
overlayView.viewPosition = activeView.viewPosition;
|
|
5591
|
-
overlayView.viewTarget = activeView.viewTarget;
|
|
5592
|
-
overlayView.upVector = activeView.upVector;
|
|
5593
|
-
overlayView.viewFieldWidth = activeView.viewFieldWidth;
|
|
5594
|
-
overlayView.viewFieldHeight = activeView.viewFieldHeight;
|
|
5595
|
-
const viewPort = overlayView.getViewport();
|
|
5596
|
-
overlayView.setViewport(viewPort.lowerLeft, viewPort.upperRight);
|
|
5597
|
-
overlayView.vportRect = activeView.vportRect;
|
|
5598
|
-
this.update();
|
|
5599
|
-
return overlayView;
|
|
5579
|
+
return this._markup.syncOverlay();
|
|
5600
5580
|
}
|
|
5601
5581
|
is3D() {
|
|
5602
5582
|
if (!this.visualizeJs) return false;
|
|
@@ -5607,6 +5587,41 @@ class Viewer extends EventEmitter2 {
|
|
|
5607
5587
|
const extHeight = max[2] - min[2];
|
|
5608
5588
|
return extHeight !== 0;
|
|
5609
5589
|
}
|
|
5590
|
+
screenToWorld(position) {
|
|
5591
|
+
return this.visViewer().screenToWorld(position.x * window.devicePixelRatio, position.y * window.devicePixelRatio);
|
|
5592
|
+
}
|
|
5593
|
+
worldToScreen(position) {
|
|
5594
|
+
if (!this.visualizeJs) return position;
|
|
5595
|
+
const activeView = this.visViewer().activeView;
|
|
5596
|
+
const worldMatrix = activeView.worldToDeviceMatrix;
|
|
5597
|
+
const worldPoint = this.visLib().Point3d.createFromArray([ position.x, position.y, position.z ]);
|
|
5598
|
+
const devicePoint = worldPoint.transformBy(worldMatrix);
|
|
5599
|
+
const result = {
|
|
5600
|
+
x: devicePoint.x / window.devicePixelRatio,
|
|
5601
|
+
y: devicePoint.y / window.devicePixelRatio
|
|
5602
|
+
};
|
|
5603
|
+
devicePoint.delete();
|
|
5604
|
+
worldPoint.delete();
|
|
5605
|
+
worldMatrix.delete();
|
|
5606
|
+
activeView.delete();
|
|
5607
|
+
return result;
|
|
5608
|
+
}
|
|
5609
|
+
getScale() {
|
|
5610
|
+
const result = {
|
|
5611
|
+
x: 1,
|
|
5612
|
+
y: 1,
|
|
5613
|
+
z: 1
|
|
5614
|
+
};
|
|
5615
|
+
const projMatrix = this.visViewer().activeView.projectionMatrix;
|
|
5616
|
+
const tolerance = 1e-6;
|
|
5617
|
+
const x = projMatrix.get(1, 1);
|
|
5618
|
+
if (x > tolerance || x < -tolerance) result.x = 1 / result.x;
|
|
5619
|
+
const y = projMatrix.get(1, 1);
|
|
5620
|
+
if (y > tolerance || y < -tolerance) result.y = 1 / result.y;
|
|
5621
|
+
const z = projMatrix.get(2, 2);
|
|
5622
|
+
if (z > tolerance || z < -tolerance) result.z = 1 / result.z;
|
|
5623
|
+
return result;
|
|
5624
|
+
}
|
|
5610
5625
|
getSelected() {
|
|
5611
5626
|
return this.executeCommand("getSelected");
|
|
5612
5627
|
}
|
|
@@ -5792,10 +5807,10 @@ class Viewer extends EventEmitter2 {
|
|
|
5792
5807
|
return this;
|
|
5793
5808
|
}
|
|
5794
5809
|
getMarkupColor() {
|
|
5795
|
-
return this.
|
|
5810
|
+
return this._markup.getMarkupColor();
|
|
5796
5811
|
}
|
|
5797
5812
|
setMarkupColor(r = 255, g = 0, b = 0) {
|
|
5798
|
-
this.
|
|
5813
|
+
this._markup.setMarkupColor(r, g, b);
|
|
5799
5814
|
const color = {
|
|
5800
5815
|
r: r,
|
|
5801
5816
|
g: g,
|
|
@@ -5807,10 +5822,10 @@ class Viewer extends EventEmitter2 {
|
|
|
5807
5822
|
});
|
|
5808
5823
|
}
|
|
5809
5824
|
colorizeAllMarkup(r = 255, g = 0, b = 0) {
|
|
5810
|
-
this.
|
|
5825
|
+
this._markup.colorizeAllMarkup(r, g, b);
|
|
5811
5826
|
}
|
|
5812
5827
|
colorizeSelectedMarkups(r = 255, g = 0, b = 0) {
|
|
5813
|
-
this.
|
|
5828
|
+
this._markup.colorizeSelectedMarkups(r, g, b);
|
|
5814
5829
|
}
|
|
5815
5830
|
addMarkupEntity(entityName) {
|
|
5816
5831
|
if (!this.visualizeJs) return null;
|
|
@@ -5829,10 +5844,10 @@ class Viewer extends EventEmitter2 {
|
|
|
5829
5844
|
drawViewpoint(viewpoint) {
|
|
5830
5845
|
this.setOrthogonalCameraSettings(viewpoint.orthogonal_camera);
|
|
5831
5846
|
this.setClippingPlanes(viewpoint.clipping_planes);
|
|
5832
|
-
this.
|
|
5847
|
+
this._markup.setViewpoint(viewpoint);
|
|
5833
5848
|
}
|
|
5834
5849
|
createViewpoint() {
|
|
5835
|
-
const vp = this.
|
|
5850
|
+
const vp = this._markup.getViewpoint();
|
|
5836
5851
|
vp.orthogonal_camera = this.getOrthogonalCameraSettings();
|
|
5837
5852
|
vp.clipping_planes = this.getClippingPlanes();
|
|
5838
5853
|
return vp;
|
|
@@ -5909,5 +5924,5 @@ class Viewer extends EventEmitter2 {
|
|
|
5909
5924
|
}
|
|
5910
5925
|
}
|
|
5911
5926
|
|
|
5912
|
-
export { CANVAS_EVENTS, CanvasEvents, OdBaseDragger, Options, Viewer, commands, defaultOptions };
|
|
5927
|
+
export { CANVAS_EVENTS, CanvasEvents, Dragger, MarkupType, OdBaseDragger, Options, Viewer, commands, defaultOptions };
|
|
5913
5928
|
//# sourceMappingURL=viewer-visualize.module.js.map
|