@inweb/viewer-visualize 26.11.0 → 26.11.1
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/README.md +4 -6
- package/dist/viewer-visualize.js +29 -97
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +29 -89
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.d.ts +1 -5
- package/lib/Viewer/Draggers/MeasureLineDragger/index.d.ts +2 -3
- package/package.json +6 -6
- package/src/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.ts +13 -44
- package/src/Viewer/Draggers/MeasureLineDragger/index.ts +18 -53
|
@@ -402,9 +402,8 @@ class MeasureLineItem {
|
|
|
402
402
|
this.htmlElemTitle = null;
|
|
403
403
|
this.startPoint = null;
|
|
404
404
|
this.endPoint = null;
|
|
405
|
-
this.scale = 1.0;
|
|
406
405
|
this.unit = "";
|
|
407
|
-
this.
|
|
406
|
+
this.scale = 1.0;
|
|
408
407
|
this.size = 10.0;
|
|
409
408
|
this.lineThickness = 2;
|
|
410
409
|
this.style = {
|
|
@@ -489,9 +488,10 @@ class MeasureLineItem {
|
|
|
489
488
|
this.htmlElemLine.style.background = this.style.background;
|
|
490
489
|
this.htmlElemLine.style.zIndex = "1";
|
|
491
490
|
this.htmlElemLine.style.height = `${height}px`;
|
|
492
|
-
const distance = this.getDistance()
|
|
491
|
+
const distance = `${this.getDistance()} ${this.unit}`;
|
|
493
492
|
const pX = p1.x + dx / 2;
|
|
494
493
|
const pY = p1.y + dy / 2;
|
|
494
|
+
const widthTitle = distance.length * 10;
|
|
495
495
|
this.htmlElemTitle = createHtmlElementIfNeed(this.htmlElemTitle, this.targetElement, "ruler-value");
|
|
496
496
|
this.htmlElemTitle.style.display = "block";
|
|
497
497
|
this.htmlElemTitle.style.cursor = "pointer";
|
|
@@ -499,8 +499,9 @@ class MeasureLineItem {
|
|
|
499
499
|
this.htmlElemTitle.style.color = "white";
|
|
500
500
|
this.htmlElemTitle.style.position = "Absolute";
|
|
501
501
|
this.htmlElemTitle.style.top = `${pY}px`;
|
|
502
|
-
this.htmlElemTitle.style.left = `${pX}px`;
|
|
503
|
-
this.htmlElemTitle.style.
|
|
502
|
+
this.htmlElemTitle.style.left = `${pX - widthTitle / 2}px`;
|
|
503
|
+
this.htmlElemTitle.style.width = `${widthTitle}px`;
|
|
504
|
+
this.htmlElemTitle.style.transformOrigin = "0px 0px";
|
|
504
505
|
this.htmlElemTitle.style.borderRadius = "5px";
|
|
505
506
|
this.htmlElemTitle.style.boxShadow = this.style.boxShadow;
|
|
506
507
|
this.htmlElemTitle.style.border = "none";
|
|
@@ -508,7 +509,7 @@ class MeasureLineItem {
|
|
|
508
509
|
this.htmlElemTitle.style.zIndex = "3";
|
|
509
510
|
this.htmlElemTitle.style.padding = "2px";
|
|
510
511
|
this.htmlElemTitle.style.textAlign = "center";
|
|
511
|
-
this.htmlElemTitle.innerHTML =
|
|
512
|
+
this.htmlElemTitle.innerHTML = `${distance}`;
|
|
512
513
|
}
|
|
513
514
|
else {
|
|
514
515
|
this.htmlElemLine.style.display = "none";
|
|
@@ -518,43 +519,11 @@ class MeasureLineItem {
|
|
|
518
519
|
}
|
|
519
520
|
getDistance() {
|
|
520
521
|
let distance = getDistance(this.startPoint, this.endPoint, this.moduleInstance);
|
|
521
|
-
if (Math.abs(this.scale) >
|
|
522
|
-
distance
|
|
522
|
+
if (Math.abs(this.scale - 1.0) > 10e-5) {
|
|
523
|
+
distance = (distance / this.scale).toFixed(2);
|
|
524
|
+
}
|
|
523
525
|
return distance;
|
|
524
526
|
}
|
|
525
|
-
calculatePrecision(value) {
|
|
526
|
-
const distance = Math.abs(value);
|
|
527
|
-
if (distance >= 1000)
|
|
528
|
-
return 0;
|
|
529
|
-
if (distance >= 10)
|
|
530
|
-
return 1;
|
|
531
|
-
if (distance >= 0.1)
|
|
532
|
-
return 2;
|
|
533
|
-
if (distance >= 0.001)
|
|
534
|
-
return 3;
|
|
535
|
-
return distance > 0 ? Math.floor(-Math.log10(distance)) + 1 : 2;
|
|
536
|
-
}
|
|
537
|
-
formatDistance(distance) {
|
|
538
|
-
let digits;
|
|
539
|
-
if (this.precision === "Auto")
|
|
540
|
-
digits = this.calculatePrecision(distance);
|
|
541
|
-
else if (Number.isFinite(this.precision))
|
|
542
|
-
digits = this.precision;
|
|
543
|
-
else
|
|
544
|
-
digits = parseFloat(this.precision);
|
|
545
|
-
if (!Number.isFinite(digits))
|
|
546
|
-
digits = 2;
|
|
547
|
-
else if (digits < 0)
|
|
548
|
-
digits = 0;
|
|
549
|
-
else if (digits > 10)
|
|
550
|
-
digits = 10;
|
|
551
|
-
let result = distance.toFixed(digits);
|
|
552
|
-
if (this.precision === "Auto")
|
|
553
|
-
result = result.replace(/\.0+$/, "").replace(/\.$/, "");
|
|
554
|
-
if (+result !== distance)
|
|
555
|
-
result = "~ " + result;
|
|
556
|
-
return `${result} ${this.unit}`;
|
|
557
|
-
}
|
|
558
527
|
setStartPoint(gePoint) {
|
|
559
528
|
this.startPoint = gePoint;
|
|
560
529
|
this.drawMeasureLine();
|
|
@@ -587,10 +556,6 @@ class MeasureLineItem {
|
|
|
587
556
|
this.scale = scale;
|
|
588
557
|
this.drawMeasureLine();
|
|
589
558
|
}
|
|
590
|
-
setPrecision(precision) {
|
|
591
|
-
this.precision = precision;
|
|
592
|
-
this.drawMeasureLine();
|
|
593
|
-
}
|
|
594
559
|
setStyle(style) {
|
|
595
560
|
this.style = style;
|
|
596
561
|
this.drawMeasureLine();
|
|
@@ -613,14 +578,14 @@ function renameUnit(table, unit) {
|
|
|
613
578
|
}
|
|
614
579
|
class MeasureLineDragger extends OdBaseDragger {
|
|
615
580
|
constructor(subject) {
|
|
616
|
-
var _a
|
|
581
|
+
var _a;
|
|
617
582
|
super(subject);
|
|
618
583
|
this.lineThickness = 2;
|
|
619
584
|
this.press = false;
|
|
620
585
|
this.gripingRadius = 5.0;
|
|
621
586
|
this.firstPoint = null;
|
|
622
587
|
this.secondPoint = null;
|
|
623
|
-
this.
|
|
588
|
+
this.renameUnitTable = {
|
|
624
589
|
Millimeters: "mm",
|
|
625
590
|
Centimeters: "cm",
|
|
626
591
|
Meters: "m",
|
|
@@ -630,14 +595,13 @@ class MeasureLineDragger extends OdBaseDragger {
|
|
|
630
595
|
Kilometers: "km",
|
|
631
596
|
Miles: "mi",
|
|
632
597
|
Micrometers: "µm",
|
|
633
|
-
Mils: "mil",
|
|
634
598
|
MicroInches: "µin",
|
|
635
599
|
Default: "unit",
|
|
636
600
|
};
|
|
637
|
-
this.rulerUnit = (_a = subject.options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
|
|
638
|
-
this.rulerPrecision = (_b = subject.options.rulerPrecision) !== null && _b !== void 0 ? _b : "Default";
|
|
639
601
|
this.items = [];
|
|
640
|
-
this.canvasEvents.push("resize"
|
|
602
|
+
this.canvasEvents.push("resize");
|
|
603
|
+
this.oldRulerUnit = (_a = subject.options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
|
|
604
|
+
this.optionsChange = this.optionsChange.bind(this);
|
|
641
605
|
}
|
|
642
606
|
initialize() {
|
|
643
607
|
super.initialize();
|
|
@@ -732,9 +696,8 @@ class MeasureLineDragger extends OdBaseDragger {
|
|
|
732
696
|
const viewer = this.m_module.getViewer();
|
|
733
697
|
const item = new MeasureLineItem(this.m_overlayElement, viewer, this.m_module);
|
|
734
698
|
item.lineThickness = this.lineThickness || item.lineThickness;
|
|
735
|
-
const isDefaultUnit = this.rulerUnit === "Default";
|
|
736
|
-
|
|
737
|
-
item.setUnit(renameUnit(this.rulerUnitTable, isDefaultUnit ? viewer.getUnit() : this.rulerUnit));
|
|
699
|
+
const isDefaultUnit = !this.subject.options.rulerUnit || this.subject.options.rulerUnit === "Default";
|
|
700
|
+
item.setUnit(renameUnit(this.renameUnitTable, isDefaultUnit ? viewer.getUnit() : this.subject.options.rulerUnit));
|
|
738
701
|
if (!isDefaultUnit) {
|
|
739
702
|
const fromUnit = this.getKUnitByName(viewer.getUnit());
|
|
740
703
|
const toUnit = this.getKUnitByName(this.subject.options.rulerUnit);
|
|
@@ -745,49 +708,29 @@ class MeasureLineDragger extends OdBaseDragger {
|
|
|
745
708
|
else {
|
|
746
709
|
item.setConversionFactor(1.0);
|
|
747
710
|
}
|
|
748
|
-
if (!isDefaultPrecision) {
|
|
749
|
-
item.setPrecision(this.rulerPrecision);
|
|
750
|
-
}
|
|
751
|
-
else {
|
|
752
|
-
item.setPrecision(2);
|
|
753
|
-
}
|
|
754
711
|
this.items.push(item);
|
|
755
712
|
return item;
|
|
756
713
|
}
|
|
757
714
|
optionsChange(event) {
|
|
758
|
-
var _a
|
|
715
|
+
var _a;
|
|
759
716
|
const options = event.data;
|
|
760
717
|
const toUnitName = (_a = options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
|
|
761
|
-
|
|
762
|
-
const unitChanged = this.rulerUnit !== toUnitName;
|
|
763
|
-
const precisionChanged = this.rulerPrecision !== toPrecision;
|
|
764
|
-
if (!unitChanged && !precisionChanged)
|
|
718
|
+
if (this.oldRulerUnit === toUnitName)
|
|
765
719
|
return;
|
|
766
|
-
this.
|
|
767
|
-
this.rulerPrecision = toPrecision;
|
|
720
|
+
this.oldRulerUnit = toUnitName;
|
|
768
721
|
const drawingUnit = this.m_module.getViewer().getUnit();
|
|
769
722
|
const eToUnit = this.getKUnitByName(toUnitName);
|
|
770
723
|
const eFromUnit = this.getKUnitByName(drawingUnit);
|
|
771
724
|
this.items.forEach((item) => {
|
|
772
|
-
if (
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
item.setConversionFactor(1.0);
|
|
776
|
-
}
|
|
777
|
-
else {
|
|
778
|
-
item.setUnit(renameUnit(this.rulerUnitTable, toUnitName));
|
|
779
|
-
const multiplier = this.m_module.getViewer().getUnitsConversionCoef(eFromUnit, eToUnit);
|
|
780
|
-
this.conversionFactor = 1 / multiplier;
|
|
781
|
-
item.setConversionFactor(this.conversionFactor);
|
|
782
|
-
}
|
|
725
|
+
if (toUnitName === "Default") {
|
|
726
|
+
item.setUnit(renameUnit(this.renameUnitTable, drawingUnit));
|
|
727
|
+
item.setConversionFactor(1.0);
|
|
783
728
|
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
item.setPrecision(toPrecision);
|
|
790
|
-
}
|
|
729
|
+
else {
|
|
730
|
+
item.setUnit(renameUnit(this.renameUnitTable, toUnitName));
|
|
731
|
+
const multiplier = this.m_module.getViewer().getUnitsConversionCoef(eFromUnit, eToUnit);
|
|
732
|
+
this.conversionFactor = 1 / multiplier;
|
|
733
|
+
item.setConversionFactor(this.conversionFactor);
|
|
791
734
|
}
|
|
792
735
|
});
|
|
793
736
|
}
|
|
@@ -821,9 +764,6 @@ class MeasureLineDragger extends OdBaseDragger {
|
|
|
821
764
|
case "Micrometers":
|
|
822
765
|
eUnit = this.m_module.Units.kMicrometers;
|
|
823
766
|
break;
|
|
824
|
-
case "Mils":
|
|
825
|
-
eUnit = this.m_module.Units.kMils;
|
|
826
|
-
break;
|
|
827
767
|
case "MicroInches":
|
|
828
768
|
eUnit = this.m_module.Units.kMicroInches;
|
|
829
769
|
break;
|
|
@@ -3986,7 +3926,7 @@ class Viewer extends EventEmitter2 {
|
|
|
3986
3926
|
return this._markup;
|
|
3987
3927
|
}
|
|
3988
3928
|
configure(params) {
|
|
3989
|
-
this._visualizeJsUrl = params.visualizeJsUrl || "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/
|
|
3929
|
+
this._visualizeJsUrl = params.visualizeJsUrl || "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/26.11/Visualize.js";
|
|
3990
3930
|
this._crossOrigin = params.crossOrigin;
|
|
3991
3931
|
return this;
|
|
3992
3932
|
}
|