@inweb/viewer-visualize 25.8.8 → 25.8.10
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 +30 -18
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +40 -18
- 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,22 +1357,22 @@ 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
|
-
if (ref.height() === 0 || ref.width() === 0) return;
|
|
1363
1363
|
this._ref = ref;
|
|
1364
1364
|
this._canvasImage = ref.image();
|
|
1365
|
-
this._ratio = this._ref.height() / this._ref.width();
|
|
1365
|
+
this._ratio = this._ref.height() === 0 || this._ref.width() === 0 ? 1 : this._ref.height() / this._ref.width();
|
|
1366
1366
|
return;
|
|
1367
1367
|
}
|
|
1368
|
-
if (!params.position || !params.src) return;
|
|
1368
|
+
if (!params || !params.position || !params.src) return;
|
|
1369
1369
|
this._canvasImage = new Image;
|
|
1370
1370
|
this._ref = new Konva.Image({
|
|
1371
1371
|
x: params.position.x,
|
|
1372
1372
|
y: params.position.y,
|
|
1373
1373
|
image: this._canvasImage,
|
|
1374
|
-
width: params.width,
|
|
1375
|
-
height: params.height,
|
|
1374
|
+
width: (_a = params.width) !== null && _a !== void 0 ? _a : 0,
|
|
1375
|
+
height: (_b = params.height) !== null && _b !== void 0 ? _b : 0,
|
|
1376
1376
|
draggable: true
|
|
1377
1377
|
});
|
|
1378
1378
|
this._canvasImage.onload = () => {
|
|
@@ -1480,7 +1480,7 @@ class KonvaCloud {
|
|
|
1480
1480
|
this._ref = ref;
|
|
1481
1481
|
return;
|
|
1482
1482
|
}
|
|
1483
|
-
if (!params
|
|
1483
|
+
if (!params || !params.position) return;
|
|
1484
1484
|
const arcRadius = 16;
|
|
1485
1485
|
this._ref = new Konva.Shape({
|
|
1486
1486
|
x: params.position.x,
|
|
@@ -1684,7 +1684,7 @@ const MarkupMode2Konva = {
|
|
|
1684
1684
|
},
|
|
1685
1685
|
Cloud: {
|
|
1686
1686
|
name: "Cloud",
|
|
1687
|
-
initializer: ref => new KonvaCloud(
|
|
1687
|
+
initializer: (ref, params = null) => new KonvaCloud(params, ref),
|
|
1688
1688
|
zIndex: 1
|
|
1689
1689
|
}
|
|
1690
1690
|
};
|
|
@@ -3152,6 +3152,14 @@ class MeasureLineDragger extends OdBaseDragger {
|
|
|
3152
3152
|
pt2[1] -= pt1[1];
|
|
3153
3153
|
return Math.min(pt2[0], pt2[1]) / 120;
|
|
3154
3154
|
}
|
|
3155
|
+
start(x, y) {
|
|
3156
|
+
this.createNewMeasureIfNeed();
|
|
3157
|
+
const point = this.getViewer().getSnapPoint(x, y, this.gripingRadius);
|
|
3158
|
+
if (point) {
|
|
3159
|
+
this.firstPoint = point;
|
|
3160
|
+
this.previewMeasureLine.setStartPoint(this.firstPoint);
|
|
3161
|
+
}
|
|
3162
|
+
}
|
|
3155
3163
|
drag(x, y) {
|
|
3156
3164
|
this.createNewMeasureIfNeed();
|
|
3157
3165
|
const point = this.getViewer().getSnapPoint(x, y, this.gripingRadius);
|
|
@@ -5532,10 +5540,24 @@ class Viewer extends EventEmitter2 {
|
|
|
5532
5540
|
return extHeight !== 0;
|
|
5533
5541
|
}
|
|
5534
5542
|
screenToWorld(position) {
|
|
5535
|
-
|
|
5543
|
+
if (!this.visualizeJs) return {
|
|
5544
|
+
x: position.x,
|
|
5545
|
+
y: position.y,
|
|
5546
|
+
z: 0
|
|
5547
|
+
};
|
|
5548
|
+
const worldPoint = this.visViewer().screenToWorld(position.x * window.devicePixelRatio, position.y * window.devicePixelRatio);
|
|
5549
|
+
const result = {
|
|
5550
|
+
x: worldPoint[0],
|
|
5551
|
+
y: worldPoint[1],
|
|
5552
|
+
z: worldPoint[2]
|
|
5553
|
+
};
|
|
5554
|
+
return result;
|
|
5536
5555
|
}
|
|
5537
5556
|
worldToScreen(position) {
|
|
5538
|
-
if (!this.visualizeJs) return
|
|
5557
|
+
if (!this.visualizeJs) return {
|
|
5558
|
+
x: position.x,
|
|
5559
|
+
y: position.y
|
|
5560
|
+
};
|
|
5539
5561
|
const activeView = this.visViewer().activeView;
|
|
5540
5562
|
const worldMatrix = activeView.worldToDeviceMatrix;
|
|
5541
5563
|
const worldPoint = this.visLib().Point3d.createFromArray([ position.x, position.y, position.z ]);
|
|
@@ -5558,12 +5580,12 @@ class Viewer extends EventEmitter2 {
|
|
|
5558
5580
|
};
|
|
5559
5581
|
const projMatrix = this.visViewer().activeView.projectionMatrix;
|
|
5560
5582
|
const tolerance = 1e-6;
|
|
5561
|
-
const x = projMatrix.get(
|
|
5562
|
-
if (x > tolerance || x < -tolerance) result.x = 1 /
|
|
5583
|
+
const x = projMatrix.get(0, 0);
|
|
5584
|
+
if (x > tolerance || x < -tolerance) result.x = 1 / x;
|
|
5563
5585
|
const y = projMatrix.get(1, 1);
|
|
5564
|
-
if (y > tolerance || y < -tolerance) result.y = 1 /
|
|
5586
|
+
if (y > tolerance || y < -tolerance) result.y = 1 / y;
|
|
5565
5587
|
const z = projMatrix.get(2, 2);
|
|
5566
|
-
if (z > tolerance || z < -tolerance) result.z = 1 /
|
|
5588
|
+
if (z > tolerance || z < -tolerance) result.z = 1 / z;
|
|
5567
5589
|
return result;
|
|
5568
5590
|
}
|
|
5569
5591
|
getSelected() {
|