@inweb/viewer-visualize 25.8.8 → 25.8.9
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 +29 -16
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +39 -16
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Draggers/MeasureLineDragger/index.d.ts +1 -0
- package/package.json +5 -5
- package/src/Viewer/Draggers/MeasureLineDragger/index.ts +10 -0
- package/src/Viewer/Viewer.ts +14 -6
|
@@ -827,7 +827,7 @@ class KonvaLine {
|
|
|
827
827
|
this._ref = ref;
|
|
828
828
|
return;
|
|
829
829
|
}
|
|
830
|
-
if (!params.points) return;
|
|
830
|
+
if (!params || !params.points) return;
|
|
831
831
|
const konvaPoints = [];
|
|
832
832
|
params.points.forEach((point => konvaPoints.push(point.x, point.y)));
|
|
833
833
|
this._ref = new Konva.Line({
|
|
@@ -929,7 +929,7 @@ class KonvaText {
|
|
|
929
929
|
this._ref = ref;
|
|
930
930
|
return;
|
|
931
931
|
}
|
|
932
|
-
if (!params || !params.text) return;
|
|
932
|
+
if (!params || !params.position || !params.text) return;
|
|
933
933
|
this._ref = new Konva.Text({
|
|
934
934
|
x: params.position.x,
|
|
935
935
|
y: params.position.y,
|
|
@@ -1031,7 +1031,7 @@ class KonvaRectangle {
|
|
|
1031
1031
|
this._ref = ref;
|
|
1032
1032
|
return;
|
|
1033
1033
|
}
|
|
1034
|
-
if (!params.position) return;
|
|
1034
|
+
if (!params || !params.position) return;
|
|
1035
1035
|
this._ref = new Konva.Rect({
|
|
1036
1036
|
stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
|
|
1037
1037
|
strokeWidth: (_b = params.lineWidth) !== null && _b !== void 0 ? _b : 4,
|
|
@@ -1141,7 +1141,7 @@ class KonvaEllipse {
|
|
|
1141
1141
|
this._ref = ref;
|
|
1142
1142
|
return;
|
|
1143
1143
|
}
|
|
1144
|
-
if (!params.position) return;
|
|
1144
|
+
if (!params || !params.position || !params.radius) return;
|
|
1145
1145
|
this._ref = new Konva.Ellipse({
|
|
1146
1146
|
stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
|
|
1147
1147
|
strokeWidth: (_b = params.lineWidth) !== null && _b !== void 0 ? _b : 4,
|
|
@@ -1263,7 +1263,7 @@ class KonvaArrow {
|
|
|
1263
1263
|
this._ref = ref;
|
|
1264
1264
|
return;
|
|
1265
1265
|
}
|
|
1266
|
-
if (!params.start || !params.end) return;
|
|
1266
|
+
if (!params || !params.start || !params.end) return;
|
|
1267
1267
|
this._ref = new Konva.Arrow({
|
|
1268
1268
|
stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
|
|
1269
1269
|
fill: (_b = params.color) !== null && _b !== void 0 ? _b : "#ff0000",
|
|
@@ -1357,6 +1357,7 @@ class KonvaArrow {
|
|
|
1357
1357
|
|
|
1358
1358
|
class KonvaImage {
|
|
1359
1359
|
constructor(params, ref = null) {
|
|
1360
|
+
var _a, _b;
|
|
1360
1361
|
this._ratio = 1;
|
|
1361
1362
|
if (ref) {
|
|
1362
1363
|
if (ref.height() === 0 || ref.width() === 0) return;
|
|
@@ -1365,14 +1366,14 @@ class KonvaImage {
|
|
|
1365
1366
|
this._ratio = this._ref.height() / this._ref.width();
|
|
1366
1367
|
return;
|
|
1367
1368
|
}
|
|
1368
|
-
if (!params.position || !params.src) return;
|
|
1369
|
+
if (!params || !params.position || !params.src) return;
|
|
1369
1370
|
this._canvasImage = new Image;
|
|
1370
1371
|
this._ref = new Konva.Image({
|
|
1371
1372
|
x: params.position.x,
|
|
1372
1373
|
y: params.position.y,
|
|
1373
1374
|
image: this._canvasImage,
|
|
1374
|
-
width: params.width,
|
|
1375
|
-
height: params.height,
|
|
1375
|
+
width: (_a = params.width) !== null && _a !== void 0 ? _a : 0,
|
|
1376
|
+
height: (_b = params.height) !== null && _b !== void 0 ? _b : 0,
|
|
1376
1377
|
draggable: true
|
|
1377
1378
|
});
|
|
1378
1379
|
this._canvasImage.onload = () => {
|
|
@@ -1480,7 +1481,7 @@ class KonvaCloud {
|
|
|
1480
1481
|
this._ref = ref;
|
|
1481
1482
|
return;
|
|
1482
1483
|
}
|
|
1483
|
-
if (!params
|
|
1484
|
+
if (!params || !params.position) return;
|
|
1484
1485
|
const arcRadius = 16;
|
|
1485
1486
|
this._ref = new Konva.Shape({
|
|
1486
1487
|
x: params.position.x,
|
|
@@ -1684,7 +1685,7 @@ const MarkupMode2Konva = {
|
|
|
1684
1685
|
},
|
|
1685
1686
|
Cloud: {
|
|
1686
1687
|
name: "Cloud",
|
|
1687
|
-
initializer: ref => new KonvaCloud(
|
|
1688
|
+
initializer: (ref, params = null) => new KonvaCloud(params, ref),
|
|
1688
1689
|
zIndex: 1
|
|
1689
1690
|
}
|
|
1690
1691
|
};
|
|
@@ -3152,6 +3153,14 @@ class MeasureLineDragger extends OdBaseDragger {
|
|
|
3152
3153
|
pt2[1] -= pt1[1];
|
|
3153
3154
|
return Math.min(pt2[0], pt2[1]) / 120;
|
|
3154
3155
|
}
|
|
3156
|
+
start(x, y) {
|
|
3157
|
+
this.createNewMeasureIfNeed();
|
|
3158
|
+
const point = this.getViewer().getSnapPoint(x, y, this.gripingRadius);
|
|
3159
|
+
if (point) {
|
|
3160
|
+
this.firstPoint = point;
|
|
3161
|
+
this.previewMeasureLine.setStartPoint(this.firstPoint);
|
|
3162
|
+
}
|
|
3163
|
+
}
|
|
3155
3164
|
drag(x, y) {
|
|
3156
3165
|
this.createNewMeasureIfNeed();
|
|
3157
3166
|
const point = this.getViewer().getSnapPoint(x, y, this.gripingRadius);
|
|
@@ -5532,10 +5541,24 @@ class Viewer extends EventEmitter2 {
|
|
|
5532
5541
|
return extHeight !== 0;
|
|
5533
5542
|
}
|
|
5534
5543
|
screenToWorld(position) {
|
|
5535
|
-
|
|
5544
|
+
if (!this.visualizeJs) return {
|
|
5545
|
+
x: position.x,
|
|
5546
|
+
y: position.y,
|
|
5547
|
+
z: 0
|
|
5548
|
+
};
|
|
5549
|
+
const worldPoint = this.visViewer().screenToWorld(position.x * window.devicePixelRatio, position.y * window.devicePixelRatio);
|
|
5550
|
+
const result = {
|
|
5551
|
+
x: worldPoint[0],
|
|
5552
|
+
y: worldPoint[1],
|
|
5553
|
+
z: worldPoint[2]
|
|
5554
|
+
};
|
|
5555
|
+
return result;
|
|
5536
5556
|
}
|
|
5537
5557
|
worldToScreen(position) {
|
|
5538
|
-
if (!this.visualizeJs) return
|
|
5558
|
+
if (!this.visualizeJs) return {
|
|
5559
|
+
x: position.x,
|
|
5560
|
+
y: position.y
|
|
5561
|
+
};
|
|
5539
5562
|
const activeView = this.visViewer().activeView;
|
|
5540
5563
|
const worldMatrix = activeView.worldToDeviceMatrix;
|
|
5541
5564
|
const worldPoint = this.visLib().Point3d.createFromArray([ position.x, position.y, position.z ]);
|
|
@@ -5558,12 +5581,12 @@ class Viewer extends EventEmitter2 {
|
|
|
5558
5581
|
};
|
|
5559
5582
|
const projMatrix = this.visViewer().activeView.projectionMatrix;
|
|
5560
5583
|
const tolerance = 1e-6;
|
|
5561
|
-
const x = projMatrix.get(
|
|
5562
|
-
if (x > tolerance || x < -tolerance) result.x = 1 /
|
|
5584
|
+
const x = projMatrix.get(0, 0);
|
|
5585
|
+
if (x > tolerance || x < -tolerance) result.x = 1 / x;
|
|
5563
5586
|
const y = projMatrix.get(1, 1);
|
|
5564
|
-
if (y > tolerance || y < -tolerance) result.y = 1 /
|
|
5587
|
+
if (y > tolerance || y < -tolerance) result.y = 1 / y;
|
|
5565
5588
|
const z = projMatrix.get(2, 2);
|
|
5566
|
-
if (z > tolerance || z < -tolerance) result.z = 1 /
|
|
5589
|
+
if (z > tolerance || z < -tolerance) result.z = 1 / z;
|
|
5567
5590
|
return result;
|
|
5568
5591
|
}
|
|
5569
5592
|
getSelected() {
|