@mlightcad/cad-simple-viewer 1.7.3 → 1.7.4
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/cad-simple-viewer.js +7595 -6922
- package/dist/cad-simple-viewer.umd.cjs +80 -80
- package/dist/mtext-renderer-worker.js +2191 -2124
- package/lib/app/AcApDocManager.d.ts +14 -0
- package/lib/app/AcApDocManager.d.ts.map +1 -1
- package/lib/app/AcApDocManager.js +46 -9
- package/lib/app/AcApDocManager.js.map +1 -1
- package/lib/app/AcApOpenDatabaseOptions.d.ts +7 -8
- package/lib/app/AcApOpenDatabaseOptions.d.ts.map +1 -1
- package/lib/command/AcApZoomCmd.d.ts +3 -0
- package/lib/command/AcApZoomCmd.d.ts.map +1 -1
- package/lib/command/AcApZoomCmd.js +20 -6
- package/lib/command/AcApZoomCmd.js.map +1 -1
- package/lib/command/convert/AcApConvertToRasterImageCmd.d.ts +4 -2
- package/lib/command/convert/AcApConvertToRasterImageCmd.d.ts.map +1 -1
- package/lib/command/convert/AcApConvertToRasterImageCmd.js +33 -17
- package/lib/command/convert/AcApConvertToRasterImageCmd.js.map +1 -1
- package/lib/command/markup/AcApMarkupCalloutCmd.d.ts.map +1 -1
- package/lib/command/markup/AcApMarkupCalloutCmd.js +8 -4
- package/lib/command/markup/AcApMarkupCalloutCmd.js.map +1 -1
- package/lib/command/markup/AcApMarkupShapeCallout.d.ts.map +1 -1
- package/lib/command/markup/AcApMarkupShapeCallout.js +8 -4
- package/lib/command/markup/AcApMarkupShapeCallout.js.map +1 -1
- package/lib/command/markup/AcApMarkupUtil.d.ts.map +1 -1
- package/lib/command/markup/AcApMarkupUtil.js +6 -4
- package/lib/command/markup/AcApMarkupUtil.js.map +1 -1
- package/lib/command/measure/AcApMeasureAngleArc.d.ts +9 -2
- package/lib/command/measure/AcApMeasureAngleArc.d.ts.map +1 -1
- package/lib/command/measure/AcApMeasureAngleArc.js +9 -2
- package/lib/command/measure/AcApMeasureAngleArc.js.map +1 -1
- package/lib/command/measure/AcApMeasureAngleCmd.d.ts.map +1 -1
- package/lib/command/measure/AcApMeasureAngleCmd.js +17 -4
- package/lib/command/measure/AcApMeasureAngleCmd.js.map +1 -1
- package/lib/command/measure/AcApMeasureArcCmd.d.ts.map +1 -1
- package/lib/command/measure/AcApMeasureArcCmd.js +12 -8
- package/lib/command/measure/AcApMeasureArcCmd.js.map +1 -1
- package/lib/command/measure/AcApMeasureAreaCmd.d.ts.map +1 -1
- package/lib/command/measure/AcApMeasureAreaCmd.js +17 -4
- package/lib/command/measure/AcApMeasureAreaCmd.js.map +1 -1
- package/lib/command/measure/AcApMeasureContinuousCmd.d.ts.map +1 -1
- package/lib/command/measure/AcApMeasureContinuousCmd.js +36 -6
- package/lib/command/measure/AcApMeasureContinuousCmd.js.map +1 -1
- package/lib/command/measure/AcApMeasureDistanceCmd.d.ts.map +1 -1
- package/lib/command/measure/AcApMeasureDistanceCmd.js +28 -8
- package/lib/command/measure/AcApMeasureDistanceCmd.js.map +1 -1
- package/lib/command/measure/AcApMeasurementStore.d.ts.map +1 -1
- package/lib/command/measure/AcApMeasurementStore.js +44 -28
- package/lib/command/measure/AcApMeasurementStore.js.map +1 -1
- package/lib/command/measure/entity/AcApMeasureAngleEntity.d.ts.map +1 -1
- package/lib/command/measure/entity/AcApMeasureAngleEntity.js +43 -7
- package/lib/command/measure/entity/AcApMeasureAngleEntity.js.map +1 -1
- package/lib/command/measure/entity/AcApMeasureArcEntity.d.ts.map +1 -1
- package/lib/command/measure/entity/AcApMeasureArcEntity.js +46 -8
- package/lib/command/measure/entity/AcApMeasureArcEntity.js.map +1 -1
- package/lib/command/measure/entity/AcApMeasureAreaEntity.d.ts.map +1 -1
- package/lib/command/measure/entity/AcApMeasureAreaEntity.js +43 -7
- package/lib/command/measure/entity/AcApMeasureAreaEntity.js.map +1 -1
- package/lib/command/measure/entity/AcApMeasureDistanceEntity.d.ts.map +1 -1
- package/lib/command/measure/entity/AcApMeasureDistanceEntity.js +56 -8
- package/lib/command/measure/entity/AcApMeasureDistanceEntity.js.map +1 -1
- package/lib/command/measure/entity/AcApMeasureEntity.d.ts +8 -0
- package/lib/command/measure/entity/AcApMeasureEntity.d.ts.map +1 -1
- package/lib/command/measure/entity/AcApMeasureEntity.js +16 -1
- package/lib/command/measure/entity/AcApMeasureEntity.js.map +1 -1
- package/lib/command/measure/entity/AcApMeasureEntityGrips.d.ts.map +1 -1
- package/lib/command/measure/entity/AcApMeasureEntityGrips.js +2 -1
- package/lib/command/measure/entity/AcApMeasureEntityGrips.js.map +1 -1
- package/lib/command/overlay/AcApHtmlLivePreview.d.ts +6 -0
- package/lib/command/overlay/AcApHtmlLivePreview.d.ts.map +1 -1
- package/lib/command/overlay/AcApHtmlLivePreview.js +9 -2
- package/lib/command/overlay/AcApHtmlLivePreview.js.map +1 -1
- package/lib/command/overlay/AcApOverlayDrawUtil.d.ts +5 -0
- package/lib/command/overlay/AcApOverlayDrawUtil.d.ts.map +1 -1
- package/lib/command/overlay/AcApOverlayDrawUtil.js +54 -23
- package/lib/command/overlay/AcApOverlayDrawUtil.js.map +1 -1
- package/lib/editor/global/AcEdConditionWaiter.d.ts +3 -0
- package/lib/editor/global/AcEdConditionWaiter.d.ts.map +1 -1
- package/lib/editor/global/AcEdConditionWaiter.js +9 -2
- package/lib/editor/global/AcEdConditionWaiter.js.map +1 -1
- package/lib/editor/view/AcEdBaseView.d.ts +14 -1
- package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
- package/lib/editor/view/AcEdBaseView.js.map +1 -1
- package/lib/i18n/ar/main.d.ts +2 -0
- package/lib/i18n/ar/main.d.ts.map +1 -1
- package/lib/i18n/ar/main.js +2 -0
- package/lib/i18n/ar/main.js.map +1 -1
- package/lib/i18n/cs/main.d.ts +2 -0
- package/lib/i18n/cs/main.d.ts.map +1 -1
- package/lib/i18n/cs/main.js +2 -0
- package/lib/i18n/cs/main.js.map +1 -1
- package/lib/i18n/en/main.d.ts +2 -0
- package/lib/i18n/en/main.d.ts.map +1 -1
- package/lib/i18n/en/main.js +2 -0
- package/lib/i18n/en/main.js.map +1 -1
- package/lib/i18n/tr/main.d.ts +2 -0
- package/lib/i18n/tr/main.d.ts.map +1 -1
- package/lib/i18n/tr/main.js +2 -0
- package/lib/i18n/tr/main.js.map +1 -1
- package/lib/i18n/zh/main.d.ts +2 -0
- package/lib/i18n/zh/main.d.ts.map +1 -1
- package/lib/i18n/zh/main.js +2 -0
- package/lib/i18n/zh/main.js.map +1 -1
- package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.d.ts +11 -0
- package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.d.ts.map +1 -1
- package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.js +92 -0
- package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.js.map +1 -1
- package/lib/ui/icons.d.ts +2 -0
- package/lib/ui/icons.d.ts.map +1 -1
- package/lib/ui/icons.js +2 -0
- package/lib/ui/icons.js.map +1 -1
- package/lib/util/AcApDrawingExtents.d.ts +29 -0
- package/lib/util/AcApDrawingExtents.d.ts.map +1 -0
- package/lib/util/AcApDrawingExtents.js +34 -0
- package/lib/util/AcApDrawingExtents.js.map +1 -0
- package/lib/util/AcApFontUtil.d.ts +18 -0
- package/lib/util/AcApFontUtil.d.ts.map +1 -1
- package/lib/util/AcApFontUtil.js +126 -0
- package/lib/util/AcApFontUtil.js.map +1 -1
- package/lib/util/AcApMeasureBadgeFont.d.ts +99 -0
- package/lib/util/AcApMeasureBadgeFont.d.ts.map +1 -0
- package/lib/util/AcApMeasureBadgeFont.js +207 -0
- package/lib/util/AcApMeasureBadgeFont.js.map +1 -0
- package/lib/util/AcApMeasurementUnits.d.ts.map +1 -1
- package/lib/util/AcApMeasurementUnits.js +41 -2
- package/lib/util/AcApMeasurementUnits.js.map +1 -1
- package/lib/util/index.d.ts +2 -0
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +2 -0
- package/lib/util/index.js.map +1 -1
- package/lib/view/AcTrExtentCluster.d.ts +10 -0
- package/lib/view/AcTrExtentCluster.d.ts.map +1 -1
- package/lib/view/AcTrExtentCluster.js +76 -0
- package/lib/view/AcTrExtentCluster.js.map +1 -1
- package/lib/view/AcTrIntelligentExtents.d.ts +8 -0
- package/lib/view/AcTrIntelligentExtents.d.ts.map +1 -1
- package/lib/view/AcTrIntelligentExtents.js +247 -10
- package/lib/view/AcTrIntelligentExtents.js.map +1 -1
- package/lib/view/AcTrLayer.d.ts +4 -0
- package/lib/view/AcTrLayer.d.ts.map +1 -1
- package/lib/view/AcTrLayer.js +6 -0
- package/lib/view/AcTrLayer.js.map +1 -1
- package/lib/view/AcTrLayout.d.ts +36 -0
- package/lib/view/AcTrLayout.d.ts.map +1 -1
- package/lib/view/AcTrLayout.js +121 -0
- package/lib/view/AcTrLayout.js.map +1 -1
- package/lib/view/AcTrScene.d.ts +4 -0
- package/lib/view/AcTrScene.d.ts.map +1 -1
- package/lib/view/AcTrScene.js +6 -0
- package/lib/view/AcTrScene.js.map +1 -1
- package/lib/view/AcTrView2d.d.ts +11 -5
- package/lib/view/AcTrView2d.d.ts.map +1 -1
- package/lib/view/AcTrView2d.js +161 -50
- package/lib/view/AcTrView2d.js.map +1 -1
- package/lib/view/AcTrWorkSlice.d.ts +23 -0
- package/lib/view/AcTrWorkSlice.d.ts.map +1 -0
- package/lib/view/AcTrWorkSlice.js +92 -0
- package/lib/view/AcTrWorkSlice.js.map +1 -0
- package/package.json +8 -8
- package/src/ui/icons.ts +5 -0
package/lib/view/AcTrView2d.js
CHANGED
|
@@ -99,7 +99,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
99
99
|
import { AcCmUiYieldGate, AcDbAttribute, AcDbBlockReference, acdbHostApplicationServices, AcDbMText, AcDbRasterImage, AcDbRay, AcDbSysVarManager, AcDbViewport, AcDbXline, AcGeBox2d, AcGePoint2d, acgiForegroundColorForBackground, log } from '@mlightcad/data-model';
|
|
100
100
|
import { AcDbSystemVariables } from '@mlightcad/data-model';
|
|
101
101
|
import { FontManager } from '@mlightcad/mtext-renderer';
|
|
102
|
-
import { AcTrEntity, AcTrGlyphEntity, AcTrGroup, AcTrMTextRenderer, AcTrRenderer, AcTrViewportView, hasPendingComplexLineTypeGlyphs } from '@mlightcad/three-renderer';
|
|
102
|
+
import { AcTrEntity, AcTrGlyphEntity, AcTrGroup, AcTrMTextRenderer, AcTrRenderer, AcTrViewportView, hasPendingComplexLineTypeGlyphs, setAcTrDrawOrderZAllocator } from '@mlightcad/three-renderer';
|
|
103
103
|
import { AcTrMatrixUtil } from '@mlightcad/three-renderer';
|
|
104
104
|
import * as THREE from 'three';
|
|
105
105
|
import Stats from 'three/examples/jsm/libs/stats.module';
|
|
@@ -122,7 +122,7 @@ import { shouldExtendBboxForDirectEntity, tryBuildDirectEntityMeta } from './AcT
|
|
|
122
122
|
import { AcTrEntityDisplayController } from './AcTrEntityDisplayController';
|
|
123
123
|
import { assertAcTrGroupWcsBboxesConsistent, unionGroupWcsChildBoxes } from './AcTrGroupWcsBboxAssert';
|
|
124
124
|
import { AcTrInheritedLayerMaterialMapper } from './AcTrInheritedLayerMaterialMapper';
|
|
125
|
-
import {
|
|
125
|
+
import { computeIntelligentExtentsAsync } from './AcTrIntelligentExtents';
|
|
126
126
|
import { AcTrLayer } from './AcTrLayer';
|
|
127
127
|
import { AcTrLayerAppearanceController } from './AcTrLayerAppearanceController';
|
|
128
128
|
import { AcTrLayout } from './AcTrLayout';
|
|
@@ -131,6 +131,7 @@ import { AcTrLayoutViewManager } from './AcTrLayoutViewManager';
|
|
|
131
131
|
import { sortPickResults } from './AcTrPickResultUtil';
|
|
132
132
|
import { AcTrProgressiveOpenFitController } from './AcTrProgressiveOpenFitController';
|
|
133
133
|
import { AcTrScene } from './AcTrScene';
|
|
134
|
+
import { AcTrWorkSlice } from './AcTrWorkSlice';
|
|
134
135
|
import { shouldRegenDatabaseAfterFontLoad } from './fontLoadRegen';
|
|
135
136
|
/**
|
|
136
137
|
* Default view option values
|
|
@@ -385,6 +386,9 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
385
386
|
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
|
|
386
387
|
renderer.setSize(_this.width, _this.height);
|
|
387
388
|
_this._renderer = new AcTrRenderer(renderer);
|
|
389
|
+
// Shared across all layer batched groups so later entities (e.g. wipeouts)
|
|
390
|
+
// occlude earlier linework via depth, matching AutoCAD draw order.
|
|
391
|
+
setAcTrDrawOrderZAllocator(function () { return _this._renderer.allocateDrawOrderZ(); });
|
|
388
392
|
var fontMapping = AcApSettingManager.instance.fontMapping;
|
|
389
393
|
_this._renderer.setFontMapping(fontMapping);
|
|
390
394
|
_this._renderer.events.fontNotFound.addEventListener(function (args) {
|
|
@@ -1042,6 +1046,9 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
1042
1046
|
// Style-manager changeForeground only updates cache entries; batch
|
|
1043
1047
|
// containers own private material clones and must be repainted too.
|
|
1044
1048
|
this._scene.repaintForegroundMaterials(acgiForegroundColorForBackground(value));
|
|
1049
|
+
// Wipeouts track the canvas background (isBackgroundFill); repaint their
|
|
1050
|
+
// batch-owned clones the same way as ACI-7 foreground materials.
|
|
1051
|
+
this._scene.repaintBackgroundMaterials(value);
|
|
1045
1052
|
this.resyncForegroundLayersForBackground();
|
|
1046
1053
|
if (this._readingMode.isEnabled) {
|
|
1047
1054
|
this._readingMode.noteLayoutBackground(value);
|
|
@@ -1561,7 +1568,7 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
1561
1568
|
_this.endProgressiveOpenFit();
|
|
1562
1569
|
return;
|
|
1563
1570
|
}
|
|
1564
|
-
_this._progressiveOpenFit.applyFinalFit(function () { return _this.
|
|
1571
|
+
_this._progressiveOpenFit.applyFinalFit(function () { return _this.getDrawingExtents(); });
|
|
1565
1572
|
_this.endProgressiveOpenFit();
|
|
1566
1573
|
var originalBtrId = layoutBtrId !== null && layoutBtrId !== void 0 ? layoutBtrId : _this.activeLayoutBtrId;
|
|
1567
1574
|
if (originalBtrId) {
|
|
@@ -1593,27 +1600,87 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
1593
1600
|
AcTrView2d.prototype.zoomToSmartExtents = function (timeout) {
|
|
1594
1601
|
var _this = this;
|
|
1595
1602
|
if (timeout === void 0) { timeout = 0; }
|
|
1596
|
-
|
|
1597
|
-
var
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1603
|
+
return new Promise(function (resolve, reject) {
|
|
1604
|
+
var waiter = new AcEdConditionWaiter(function () { return !_this.isProcessingEntities; }, function () {
|
|
1605
|
+
void (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1606
|
+
var smart, error_2;
|
|
1607
|
+
var _this = this;
|
|
1608
|
+
return __generator(this, function (_a) {
|
|
1609
|
+
switch (_a.label) {
|
|
1610
|
+
case 0:
|
|
1611
|
+
_a.trys.push([0, 2, , 3]);
|
|
1612
|
+
return [4 /*yield*/, this.resolveSmartFitBox()];
|
|
1613
|
+
case 1:
|
|
1614
|
+
smart = _a.sent();
|
|
1615
|
+
if (smart) {
|
|
1616
|
+
this.zoomTo(smart);
|
|
1617
|
+
this._isDirty = true;
|
|
1618
|
+
this.endProgressiveOpenFit();
|
|
1619
|
+
resolve();
|
|
1620
|
+
return [2 /*return*/];
|
|
1621
|
+
}
|
|
1622
|
+
this._progressiveOpenFit.applyFinalFit(function () {
|
|
1623
|
+
return _this.getDrawingExtents();
|
|
1624
|
+
});
|
|
1625
|
+
this.endProgressiveOpenFit();
|
|
1626
|
+
resolve();
|
|
1627
|
+
return [3 /*break*/, 3];
|
|
1628
|
+
case 2:
|
|
1629
|
+
error_2 = _a.sent();
|
|
1630
|
+
// Always clear progressive-open framing so a failed smart fit
|
|
1631
|
+
// cannot leave the open-fit overlay/state stuck indefinitely.
|
|
1632
|
+
this.endProgressiveOpenFit();
|
|
1633
|
+
reject(error_2);
|
|
1634
|
+
return [3 /*break*/, 3];
|
|
1635
|
+
case 3: return [2 /*return*/];
|
|
1636
|
+
}
|
|
1637
|
+
});
|
|
1638
|
+
}); })();
|
|
1639
|
+
}, 300, timeout);
|
|
1640
|
+
waiter.start();
|
|
1641
|
+
});
|
|
1608
1642
|
};
|
|
1609
1643
|
/**
|
|
1610
1644
|
* Resolves intelligent zoom extents from spatial-index entity boxes.
|
|
1645
|
+
* Reuses the layout cache until entity geometry extents are invalidated.
|
|
1646
|
+
* Collects and clusters cooperatively so the UI thread stays responsive.
|
|
1611
1647
|
*/
|
|
1612
1648
|
AcTrView2d.prototype.resolveSmartFitBox = function () {
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
return
|
|
1616
|
-
|
|
1649
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1650
|
+
var activeLayout, cached, generation, work, entries, smart;
|
|
1651
|
+
return __generator(this, function (_a) {
|
|
1652
|
+
switch (_a.label) {
|
|
1653
|
+
case 0:
|
|
1654
|
+
activeLayout = this._scene.activeLayout;
|
|
1655
|
+
if (!activeLayout)
|
|
1656
|
+
return [2 /*return*/, undefined];
|
|
1657
|
+
cached = activeLayout.cachedSmartExtents;
|
|
1658
|
+
if (cached) {
|
|
1659
|
+
return [2 /*return*/, cached];
|
|
1660
|
+
}
|
|
1661
|
+
generation = activeLayout.smartExtentsGeneration;
|
|
1662
|
+
work = new AcTrWorkSlice();
|
|
1663
|
+
return [4 /*yield*/, activeLayout.collectSpatialExtentBoxesAsync(work)];
|
|
1664
|
+
case 1:
|
|
1665
|
+
entries = _a.sent();
|
|
1666
|
+
return [4 /*yield*/, computeIntelligentExtentsAsync(entries, work)
|
|
1667
|
+
// Geometry changed while we yielded: discard this result (a newer cache
|
|
1668
|
+
// may already exist; otherwise the caller falls back to drawing extents).
|
|
1669
|
+
];
|
|
1670
|
+
case 2:
|
|
1671
|
+
smart = _a.sent();
|
|
1672
|
+
// Geometry changed while we yielded: discard this result (a newer cache
|
|
1673
|
+
// may already exist; otherwise the caller falls back to drawing extents).
|
|
1674
|
+
if (activeLayout.smartExtentsGeneration !== generation) {
|
|
1675
|
+
return [2 /*return*/, activeLayout.cachedSmartExtents];
|
|
1676
|
+
}
|
|
1677
|
+
if (smart) {
|
|
1678
|
+
activeLayout.cachedSmartExtents = smart;
|
|
1679
|
+
}
|
|
1680
|
+
return [2 /*return*/, smart];
|
|
1681
|
+
}
|
|
1682
|
+
});
|
|
1683
|
+
});
|
|
1617
1684
|
};
|
|
1618
1685
|
/**
|
|
1619
1686
|
* @inheritdoc
|
|
@@ -1667,7 +1734,9 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
1667
1734
|
return entity;
|
|
1668
1735
|
return undefined;
|
|
1669
1736
|
}
|
|
1670
|
-
if (entity instanceof AcDbAttribute
|
|
1737
|
+
if (entity instanceof AcDbAttribute ||
|
|
1738
|
+
entity.type === 'Attrib' ||
|
|
1739
|
+
entity.type === 'Attribute') {
|
|
1671
1740
|
var owner = AcApDocManager.instance.curDocument.database.tables.blockTable.getEntityById(entity.ownerId);
|
|
1672
1741
|
if (owner instanceof AcDbBlockReference &&
|
|
1673
1742
|
owner.attributeIterator().count > 0) {
|
|
@@ -2344,10 +2413,14 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
2344
2413
|
this._externallyFramedLayouts.add(layoutBtrId);
|
|
2345
2414
|
};
|
|
2346
2415
|
/**
|
|
2347
|
-
*
|
|
2348
|
-
*
|
|
2416
|
+
* Returns the 2D box of drawable geometry in the active layout.
|
|
2417
|
+
*
|
|
2418
|
+
* Uses {@link AcTrScene.box}, which is derived from batch geometry — not
|
|
2419
|
+
* database header `EXTMIN`/`EXTMAX`, which are often stale on real DWGs.
|
|
2420
|
+
*
|
|
2421
|
+
* @inheritdoc
|
|
2349
2422
|
*/
|
|
2350
|
-
AcTrView2d.prototype.
|
|
2423
|
+
AcTrView2d.prototype.getDrawingExtents = function () {
|
|
2351
2424
|
var sceneBox = this._scene.box;
|
|
2352
2425
|
if (sceneBox && !sceneBox.isEmpty()) {
|
|
2353
2426
|
return AcTrGeometryUtil.threeBox3dToGeBox2d(sceneBox);
|
|
@@ -2375,7 +2448,7 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
2375
2448
|
* populated. Many parsers leave this empty (we've seen `(0,0)-(0,0)`),
|
|
2376
2449
|
* so it sits below the viewport-based heuristic.
|
|
2377
2450
|
*
|
|
2378
|
-
* 4. **`
|
|
2451
|
+
* 4. **`getDrawingExtents`** (entity extents from batch geometry) —
|
|
2379
2452
|
* last-resort fallback for layouts with no viewports and no
|
|
2380
2453
|
* sensible limits/extents (e.g. a freshly created empty paper).
|
|
2381
2454
|
* Vulnerable to scale-mismatch outliers, but better than no zoom.
|
|
@@ -2421,7 +2494,7 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
2421
2494
|
_this.zoomTo(new AcGeBox2d({ x: extents.min.x, y: extents.min.y }, { x: extents.max.x, y: extents.max.y }));
|
|
2422
2495
|
}
|
|
2423
2496
|
else {
|
|
2424
|
-
var box = _this.
|
|
2497
|
+
var box = _this.getDrawingExtents();
|
|
2425
2498
|
if (box) {
|
|
2426
2499
|
_this.zoomTo(box);
|
|
2427
2500
|
}
|
|
@@ -2447,6 +2520,7 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
2447
2520
|
this.resetDeferredGeometryQueue();
|
|
2448
2521
|
this._entityProcessingIdleAt = 0;
|
|
2449
2522
|
this._scene.clear();
|
|
2523
|
+
this._renderer.resetDrawOrderZ();
|
|
2450
2524
|
this._isDirty = true;
|
|
2451
2525
|
this._missedImages.clear();
|
|
2452
2526
|
this._initializedLayouts.clear();
|
|
@@ -3000,7 +3074,8 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
3000
3074
|
* @param database - Database whose text style table has just been filled.
|
|
3001
3075
|
*/
|
|
3002
3076
|
AcTrView2d.prototype.startTextStyleFontPreload = function (database) {
|
|
3003
|
-
var _a;
|
|
3077
|
+
var e_12, _a;
|
|
3078
|
+
var _b;
|
|
3004
3079
|
var epoch = this._convertEpoch;
|
|
3005
3080
|
if (this._textStyleFontPreloadEpoch === epoch &&
|
|
3006
3081
|
this._textStyleFontPreloadPromise) {
|
|
@@ -3009,9 +3084,33 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
3009
3084
|
this._textStyleFontPreloadEpoch = epoch;
|
|
3010
3085
|
var names = [];
|
|
3011
3086
|
try {
|
|
3012
|
-
|
|
3087
|
+
var table = database.tables.textStyleTable;
|
|
3088
|
+
names = __spreadArray([], __read(((_b = table.fonts) !== null && _b !== void 0 ? _b : [])), false);
|
|
3089
|
+
// `fonts` is DXF group 3/4 file names only. TrueType styles store the
|
|
3090
|
+
// face on `font` / `extendedFont` (仿宋, SimHei).
|
|
3091
|
+
if (table.newIterator) {
|
|
3092
|
+
try {
|
|
3093
|
+
for (var _c = __values(table.newIterator()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
3094
|
+
var record = _d.value;
|
|
3095
|
+
var style = record.textStyle;
|
|
3096
|
+
if (style === null || style === void 0 ? void 0 : style.font)
|
|
3097
|
+
names.push(style.font);
|
|
3098
|
+
if (style === null || style === void 0 ? void 0 : style.bigFont)
|
|
3099
|
+
names.push(style.bigFont);
|
|
3100
|
+
if (style === null || style === void 0 ? void 0 : style.extendedFont)
|
|
3101
|
+
names.push(style.extendedFont);
|
|
3102
|
+
}
|
|
3103
|
+
}
|
|
3104
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
3105
|
+
finally {
|
|
3106
|
+
try {
|
|
3107
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
3108
|
+
}
|
|
3109
|
+
finally { if (e_12) throw e_12.error; }
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3013
3112
|
}
|
|
3014
|
-
catch (
|
|
3113
|
+
catch (_e) {
|
|
3015
3114
|
names = [];
|
|
3016
3115
|
}
|
|
3017
3116
|
// Style fonts alone are not enough: awaitFontsBeforeDraw only *awaits*
|
|
@@ -3026,12 +3125,24 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
3026
3125
|
return;
|
|
3027
3126
|
}
|
|
3028
3127
|
var mtextRenderer = AcTrMTextRenderer.getInstance();
|
|
3029
|
-
|
|
3128
|
+
// Same deadline as AcApDocManager.installFontFileLoadTimeout. Covers both
|
|
3129
|
+
// main-thread requestFonts and worker-pool loadFonts so a stalled CDN
|
|
3130
|
+
// cannot pin deferred glyph jobs / the open overlay indefinitely.
|
|
3131
|
+
var preloadTimeoutMs = 30000;
|
|
3132
|
+
var preload = Promise.all([
|
|
3030
3133
|
FontManager.instance.requestFonts(preloadNames),
|
|
3031
3134
|
// Worker isolates have their own FontManager; main-thread requestFonts
|
|
3032
3135
|
// alone does not populate them before asyncRenderMText.
|
|
3033
3136
|
mtextRenderer.loadFonts(fallbackFonts)
|
|
3034
|
-
])
|
|
3137
|
+
]);
|
|
3138
|
+
this._textStyleFontPreloadPromise = Promise.race([
|
|
3139
|
+
preload,
|
|
3140
|
+
new Promise(function (_, reject) {
|
|
3141
|
+
setTimeout(function () {
|
|
3142
|
+
reject(new Error("Text-style font preload timed out after ".concat(preloadTimeoutMs, "ms")));
|
|
3143
|
+
}, preloadTimeoutMs);
|
|
3144
|
+
})
|
|
3145
|
+
]).then(function () { return undefined; }, function () {
|
|
3035
3146
|
// Glyph draw still falls back via FontManager defaults / '?'.
|
|
3036
3147
|
});
|
|
3037
3148
|
};
|
|
@@ -3160,8 +3271,8 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
3160
3271
|
*/
|
|
3161
3272
|
AcTrView2d.prototype.redrawGlyphEntitiesAfterFontLoad = function (epoch, fontName) {
|
|
3162
3273
|
return __awaiter(this, void 0, void 0, function () {
|
|
3163
|
-
var redrawEpoch, glyphs, _a, _b, layout, glyphs_1, glyphs_1_1, glyph,
|
|
3164
|
-
var
|
|
3274
|
+
var redrawEpoch, glyphs, _a, _b, layout, glyphs_1, glyphs_1_1, glyph, e_13_1, defaults, normalized_1, msSinceIdle, db;
|
|
3275
|
+
var e_14, _c, e_13, _d;
|
|
3165
3276
|
var _e, _f;
|
|
3166
3277
|
return __generator(this, function (_g) {
|
|
3167
3278
|
switch (_g.label) {
|
|
@@ -3183,12 +3294,12 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
3183
3294
|
});
|
|
3184
3295
|
}
|
|
3185
3296
|
}
|
|
3186
|
-
catch (
|
|
3297
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
3187
3298
|
finally {
|
|
3188
3299
|
try {
|
|
3189
3300
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
3190
3301
|
}
|
|
3191
|
-
finally { if (
|
|
3302
|
+
finally { if (e_14) throw e_14.error; }
|
|
3192
3303
|
}
|
|
3193
3304
|
_g.label = 1;
|
|
3194
3305
|
case 1:
|
|
@@ -3211,14 +3322,14 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
3211
3322
|
return [3 /*break*/, 2];
|
|
3212
3323
|
case 5: return [3 /*break*/, 8];
|
|
3213
3324
|
case 6:
|
|
3214
|
-
|
|
3215
|
-
|
|
3325
|
+
e_13_1 = _g.sent();
|
|
3326
|
+
e_13 = { error: e_13_1 };
|
|
3216
3327
|
return [3 /*break*/, 8];
|
|
3217
3328
|
case 7:
|
|
3218
3329
|
try {
|
|
3219
3330
|
if (glyphs_1_1 && !glyphs_1_1.done && (_d = glyphs_1.return)) _d.call(glyphs_1);
|
|
3220
3331
|
}
|
|
3221
|
-
finally { if (
|
|
3332
|
+
finally { if (e_13) throw e_13.error; }
|
|
3222
3333
|
return [7 /*endfinally*/];
|
|
3223
3334
|
case 8:
|
|
3224
3335
|
if (glyphs.length > 0) {
|
|
@@ -3388,7 +3499,7 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
3388
3499
|
* paper layouts.
|
|
3389
3500
|
*/
|
|
3390
3501
|
AcTrView2d.prototype.ensureViewportViews = function (blockTableRecord, layoutView) {
|
|
3391
|
-
var
|
|
3502
|
+
var e_15, _a;
|
|
3392
3503
|
var iterator = blockTableRecord.newIterator();
|
|
3393
3504
|
try {
|
|
3394
3505
|
for (var iterator_2 = __values(iterator), iterator_2_1 = iterator_2.next(); !iterator_2_1.done; iterator_2_1 = iterator_2.next()) {
|
|
@@ -3401,12 +3512,12 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
3401
3512
|
layoutView.addViewport(viewportView);
|
|
3402
3513
|
}
|
|
3403
3514
|
}
|
|
3404
|
-
catch (
|
|
3515
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
3405
3516
|
finally {
|
|
3406
3517
|
try {
|
|
3407
3518
|
if (iterator_2_1 && !iterator_2_1.done && (_a = iterator_2.return)) _a.call(iterator_2);
|
|
3408
3519
|
}
|
|
3409
|
-
finally { if (
|
|
3520
|
+
finally { if (e_15) throw e_15.error; }
|
|
3410
3521
|
}
|
|
3411
3522
|
};
|
|
3412
3523
|
/**
|
|
@@ -3441,7 +3552,7 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
3441
3552
|
return new Promise(function (resolve) { return setTimeout(resolve, 0); });
|
|
3442
3553
|
};
|
|
3443
3554
|
_loop_4 = function (i) {
|
|
3444
|
-
var entity, shouldConvert, objectId_1, convertGen_1, directMeta, added, superseded, threeEntity_1, isMultiLayerGroup, deferGeometry, isExtendBbox_1, commitEntity, layoutView, viewportView, fileName,
|
|
3555
|
+
var entity, shouldConvert, objectId_1, convertGen_1, directMeta, added, superseded, threeEntity_1, isMultiLayerGroup, deferGeometry, isExtendBbox_1, commitEntity, layoutView, viewportView, fileName, error_3, didYield;
|
|
3445
3556
|
return __generator(this, function (_e) {
|
|
3446
3557
|
switch (_e.label) {
|
|
3447
3558
|
case 0:
|
|
@@ -3502,7 +3613,7 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
3502
3613
|
this_3.applySessionHiddenObjectState(entity.objectId);
|
|
3503
3614
|
if (progressive) {
|
|
3504
3615
|
this_3.markProgressiveDirty();
|
|
3505
|
-
this_3._progressiveOpenFit.afterGeometryBatch(function () { return _this.
|
|
3616
|
+
this_3._progressiveOpenFit.afterGeometryBatch(function () { return _this.getDrawingExtents(); }, i);
|
|
3506
3617
|
}
|
|
3507
3618
|
}
|
|
3508
3619
|
}
|
|
@@ -3579,7 +3690,7 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
3579
3690
|
threeEntity_1.dispose();
|
|
3580
3691
|
if (progressive) {
|
|
3581
3692
|
this.markProgressiveDirty();
|
|
3582
|
-
this._progressiveOpenFit.afterGeometryBatch(function () { return _this.
|
|
3693
|
+
this._progressiveOpenFit.afterGeometryBatch(function () { return _this.getDrawingExtents(); }, i);
|
|
3583
3694
|
}
|
|
3584
3695
|
return [2 /*return*/];
|
|
3585
3696
|
}
|
|
@@ -3621,8 +3732,8 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
3621
3732
|
}
|
|
3622
3733
|
return [3 /*break*/, 11];
|
|
3623
3734
|
case 9:
|
|
3624
|
-
|
|
3625
|
-
log.error("[AcTrView2d] Failed to convert entity ".concat(entity.objectId, " (").concat(entity.type, "):"),
|
|
3735
|
+
error_3 = _e.sent();
|
|
3736
|
+
log.error("[AcTrView2d] Failed to convert entity ".concat(entity.objectId, " (").concat(entity.type, "):"), error_3);
|
|
3626
3737
|
return [3 /*break*/, 11];
|
|
3627
3738
|
case 10:
|
|
3628
3739
|
// Counter was reset in clear() when the epoch advanced; do not
|
|
@@ -3687,7 +3798,7 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
3687
3798
|
AcTrView2d.prototype.handleGroup = function (group_1, progressive_1) {
|
|
3688
3799
|
return __awaiter(this, arguments, void 0, function (group, progressive, epoch, convertGen) {
|
|
3689
3800
|
var objectId, children, objectsGroupByLayer, children_1, children_1_1, child, renderContext, groupObjectId, groupLayerName, groupChildBoxes, aggregateSpatialBbox, registeredChildIndex;
|
|
3690
|
-
var
|
|
3801
|
+
var e_16, _a;
|
|
3691
3802
|
var _this = this;
|
|
3692
3803
|
var _b, _c;
|
|
3693
3804
|
if (epoch === void 0) { epoch = this._convertEpoch; }
|
|
@@ -3737,12 +3848,12 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
3737
3848
|
child.parent = null;
|
|
3738
3849
|
}
|
|
3739
3850
|
}
|
|
3740
|
-
catch (
|
|
3851
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
3741
3852
|
finally {
|
|
3742
3853
|
try {
|
|
3743
3854
|
if (children_1_1 && !children_1_1.done && (_a = children_1.return)) _a.call(children_1);
|
|
3744
3855
|
}
|
|
3745
|
-
finally { if (
|
|
3856
|
+
finally { if (e_16) throw e_16.error; }
|
|
3746
3857
|
}
|
|
3747
3858
|
renderContext = group.renderContext;
|
|
3748
3859
|
groupObjectId = group.objectId;
|
|
@@ -3822,7 +3933,7 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
3822
3933
|
if (progressive) {
|
|
3823
3934
|
this.markProgressiveDirty();
|
|
3824
3935
|
this._progressiveOpenFit.afterGeometryBatch(function () {
|
|
3825
|
-
return _this.
|
|
3936
|
+
return _this.getDrawingExtents();
|
|
3826
3937
|
});
|
|
3827
3938
|
}
|
|
3828
3939
|
return [2 /*return*/];
|
|
@@ -3855,7 +3966,7 @@ var AcTrView2d = /** @class */ (function (_super) {
|
|
|
3855
3966
|
if (!this._openLineworkFramePending || this.isConvertingEntities) {
|
|
3856
3967
|
return;
|
|
3857
3968
|
}
|
|
3858
|
-
var box = this.
|
|
3969
|
+
var box = this.getDrawingExtents();
|
|
3859
3970
|
if (!box || box.isEmpty()) {
|
|
3860
3971
|
this._openLineworkFramePending = false;
|
|
3861
3972
|
return;
|