@mlightcad/cad-simple-viewer 1.7.6 → 1.7.7-preview.0

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.
Files changed (110) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +190 -190
  3. package/dist/cad-simple-viewer.js +5892 -5754
  4. package/dist/cad-simple-viewer.umd.cjs +114 -114
  5. package/dist/mtext-renderer-worker.js +14124 -8730
  6. package/find.ts +7 -7
  7. package/icons.ts +7 -7
  8. package/lib/app/AcApDocManager.d.ts.map +1 -1
  9. package/lib/app/AcApDocManager.js +56 -66
  10. package/lib/app/AcApDocManager.js.map +1 -1
  11. package/lib/app/AcApOpenDatabaseOptions.d.ts +8 -2
  12. package/lib/app/AcApOpenDatabaseOptions.d.ts.map +1 -1
  13. package/lib/command/convert/AcApEntityPreviewCmd.d.ts.map +1 -1
  14. package/lib/command/convert/AcApEntityPreviewCmd.js +1 -0
  15. package/lib/command/convert/AcApEntityPreviewCmd.js.map +1 -1
  16. package/lib/command/convert/AcApRasterImageConvertor.d.ts +17 -8
  17. package/lib/command/convert/AcApRasterImageConvertor.d.ts.map +1 -1
  18. package/lib/command/convert/AcApRasterImageConvertor.js +50 -12
  19. package/lib/command/convert/AcApRasterImageConvertor.js.map +1 -1
  20. package/lib/command/draw/AcApHatchCmd.d.ts.map +1 -1
  21. package/lib/command/draw/AcApHatchCmd.js +1 -0
  22. package/lib/command/draw/AcApHatchCmd.js.map +1 -1
  23. package/lib/command/layer/AcApLayerIsoCmd.d.ts.map +1 -1
  24. package/lib/command/layer/AcApLayerIsoCmd.js +1 -0
  25. package/lib/command/layer/AcApLayerIsoCmd.js.map +1 -1
  26. package/lib/editor/grip/AcEdGripEditSession.d.ts.map +1 -1
  27. package/lib/editor/grip/AcEdGripEditSession.js +6 -1
  28. package/lib/editor/grip/AcEdGripEditSession.js.map +1 -1
  29. package/lib/editor/grip/AcEdGripManager.d.ts.map +1 -1
  30. package/lib/editor/grip/AcEdGripManager.js +2 -1
  31. package/lib/editor/grip/AcEdGripManager.js.map +1 -1
  32. package/lib/editor/input/prompt/AcEdPromptSelectionOptions.d.ts +8 -0
  33. package/lib/editor/input/prompt/AcEdPromptSelectionOptions.d.ts.map +1 -1
  34. package/lib/editor/input/prompt/AcEdPromptSelectionOptions.js +16 -0
  35. package/lib/editor/input/prompt/AcEdPromptSelectionOptions.js.map +1 -1
  36. package/lib/editor/input/ui/AcEdInputManager.d.ts.map +1 -1
  37. package/lib/editor/input/ui/AcEdInputManager.js +6 -6
  38. package/lib/editor/input/ui/AcEdInputManager.js.map +1 -1
  39. package/lib/editor/view/AcEdBaseView.d.ts +16 -0
  40. package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
  41. package/lib/editor/view/AcEdBaseView.js +38 -0
  42. package/lib/editor/view/AcEdBaseView.js.map +1 -1
  43. package/lib/i18n/ar/main.d.ts +1 -0
  44. package/lib/i18n/ar/main.d.ts.map +1 -1
  45. package/lib/i18n/ar/main.js +1 -0
  46. package/lib/i18n/ar/main.js.map +1 -1
  47. package/lib/i18n/cs/main.d.ts +1 -0
  48. package/lib/i18n/cs/main.d.ts.map +1 -1
  49. package/lib/i18n/cs/main.js +1 -0
  50. package/lib/i18n/cs/main.js.map +1 -1
  51. package/lib/i18n/en/main.d.ts +1 -0
  52. package/lib/i18n/en/main.d.ts.map +1 -1
  53. package/lib/i18n/en/main.js +1 -0
  54. package/lib/i18n/en/main.js.map +1 -1
  55. package/lib/i18n/tr/main.d.ts +1 -0
  56. package/lib/i18n/tr/main.d.ts.map +1 -1
  57. package/lib/i18n/tr/main.js +1 -0
  58. package/lib/i18n/tr/main.js.map +1 -1
  59. package/lib/i18n/zh/main.d.ts +1 -0
  60. package/lib/i18n/zh/main.d.ts.map +1 -1
  61. package/lib/i18n/zh/main.js +1 -0
  62. package/lib/i18n/zh/main.js.map +1 -1
  63. package/lib/service/AcApEntitySelection.d.ts.map +1 -1
  64. package/lib/service/AcApEntitySelection.js +34 -4
  65. package/lib/service/AcApEntitySelection.js.map +1 -1
  66. package/lib/service/AcApEntityService.d.ts.map +1 -1
  67. package/lib/service/AcApEntityService.js +11 -0
  68. package/lib/service/AcApEntityService.js.map +1 -1
  69. package/lib/service/AcApLayerService.d.ts +8 -1
  70. package/lib/service/AcApLayerService.d.ts.map +1 -1
  71. package/lib/service/AcApLayerService.js +10 -0
  72. package/lib/service/AcApLayerService.js.map +1 -1
  73. package/lib/service/AcApLockedLayer.d.ts +23 -0
  74. package/lib/service/AcApLockedLayer.d.ts.map +1 -0
  75. package/lib/service/AcApLockedLayer.js +94 -0
  76. package/lib/service/AcApLockedLayer.js.map +1 -0
  77. package/lib/service/index.d.ts +1 -0
  78. package/lib/service/index.d.ts.map +1 -1
  79. package/lib/service/index.js +1 -0
  80. package/lib/service/index.js.map +1 -1
  81. package/lib/ui/icons.d.ts +5 -2
  82. package/lib/ui/icons.d.ts.map +1 -1
  83. package/lib/ui/icons.js +5 -2
  84. package/lib/ui/icons.js.map +1 -1
  85. package/lib/util/AcApLayoutViewFraming.d.ts +68 -0
  86. package/lib/util/AcApLayoutViewFraming.d.ts.map +1 -0
  87. package/lib/util/AcApLayoutViewFraming.js +146 -0
  88. package/lib/util/AcApLayoutViewFraming.js.map +1 -0
  89. package/lib/util/index.d.ts +1 -0
  90. package/lib/util/index.d.ts.map +1 -1
  91. package/lib/util/index.js +1 -0
  92. package/lib/util/index.js.map +1 -1
  93. package/lib/view/AcTrDirectBatch.d.ts +4 -14
  94. package/lib/view/AcTrDirectBatch.d.ts.map +1 -1
  95. package/lib/view/AcTrDirectBatch.js +4 -120
  96. package/lib/view/AcTrDirectBatch.js.map +1 -1
  97. package/lib/view/AcTrScene.d.ts +1 -1
  98. package/lib/view/AcTrScene.d.ts.map +1 -1
  99. package/lib/view/AcTrView2d.d.ts +32 -36
  100. package/lib/view/AcTrView2d.d.ts.map +1 -1
  101. package/lib/view/AcTrView2d.js +82 -65
  102. package/lib/view/AcTrView2d.js.map +1 -1
  103. package/lib/view/AcTrViewSessionState.d.ts +7 -0
  104. package/lib/view/AcTrViewSessionState.d.ts.map +1 -1
  105. package/package.json +11 -11
  106. package/src/find/AcApFindNavigator.ts +190 -190
  107. package/src/find/findDrawing.ts +211 -211
  108. package/src/find/findText.ts +624 -624
  109. package/src/find/index.ts +2 -2
  110. package/src/ui/icons.ts +411 -408
@@ -105,6 +105,7 @@ import * as THREE from 'three';
105
105
  import Stats from 'three/examples/jsm/libs/stats.module';
106
106
  import { CSS2DRenderer } from 'three/examples/jsm/renderers/CSS2DRenderer.js';
107
107
  import { AcApDocManager, AcApSettingManager } from '../app';
108
+ import { AcApOpenViewMode } from '../app/AcApOpenDatabaseOptions';
108
109
  import { AcApZoomCmd } from '../command/AcApZoomCmd';
109
110
  import { isMarkupHtmlTextEditing } from '../command/markup/AcApMarkupTextEdit';
110
111
  import { notifyMeasurementLayoutChanged } from '../command/measure/AcApMeasurementStore';
@@ -115,6 +116,7 @@ import { acedEntityIntersectsSelectionBox, acedNeedsCrossingGeometryRefine } fro
115
116
  import { isEffectiveSpatialQueryHit } from '../editor/view/AcEdSpatialQueryResult';
116
117
  import { AcTrGeometryUtil } from '../util';
117
118
  import { acapRunDatabaseEdit } from '../util/AcApDatabaseEdit';
119
+ import { acapResolveLayoutFrameBox } from '../util/AcApLayoutViewFraming';
118
120
  import { collectTextStyleFontNames, planTextStyleFontPreload } from '../util/AcApTextStyleFontPreload';
119
121
  import { ACAP_READING_MODE_BACKGROUND, AcApReadingModeState } from './AcApReadingMode';
120
122
  import { trySelectReviewOverlay, trySelectReviewOverlaysByBox } from './AcEdReviewOverlayPick';
@@ -247,6 +249,12 @@ var AcTrView2d = /** @class */ (function (_super) {
247
249
  * race during document open.
248
250
  */
249
251
  _this._externallyFramedLayouts = new Set();
252
+ /**
253
+ * Open options → Initial view (`Extents` / `Saved`) for this document.
254
+ * Applied at document open for the startup layout, and again on the
255
+ * **first visit** to every other layout the user has not framed yet.
256
+ */
257
+ _this._openViewMode = AcApOpenViewMode.Extents;
250
258
  /**
251
259
  * Layer names with an in-flight {@link convertMissingEntitiesOnLayer} pass.
252
260
  *
@@ -2334,8 +2342,9 @@ var AcTrView2d = /** @class */ (function (_super) {
2334
2342
  var idsAdded = [];
2335
2343
  var results = this.pick(point);
2336
2344
  results.forEach(function (item) { return idsAdded.push(item.id); });
2337
- if (idsAdded.length > 0)
2338
- this.selectionSet.add(idsAdded);
2345
+ var selectable = this.selectableIds(idsAdded, 'add');
2346
+ if (selectable.length > 0)
2347
+ this.selectionSet.add(selectable);
2339
2348
  };
2340
2349
  /**
2341
2350
  * @inheritdoc
@@ -2754,6 +2763,15 @@ var AcTrView2d = /** @class */ (function (_super) {
2754
2763
  this._initializedLayouts.add(layoutBtrId);
2755
2764
  this._externallyFramedLayouts.add(layoutBtrId);
2756
2765
  };
2766
+ /**
2767
+ * Records the Open options → Initial view choice for this document.
2768
+ *
2769
+ * Used by {@link applyInitialZoom} on the first visit to any layout that
2770
+ * was not already framed at open time.
2771
+ */
2772
+ AcTrView2d.prototype.setOpenViewMode = function (mode) {
2773
+ this._openViewMode = mode;
2774
+ };
2757
2775
  /**
2758
2776
  * Whether the layout has already been visited (or framed by the
2759
2777
  * application layer), i.e. a switch to it will not run the first-visit
@@ -2781,41 +2799,18 @@ var AcTrView2d = /** @class */ (function (_super) {
2781
2799
  return undefined;
2782
2800
  };
2783
2801
  /**
2784
- * Applies the initial zoom-to-fit for a layout the user just switched
2785
- * into for the first time. Picks the best available "what should the
2786
- * camera frame?" signal in this order:
2787
- *
2788
- * 1. **`AcDbLayout.limits`** (LIMMIN/LIMMAX) — only when it actually
2789
- * contains the layout's viewports. Many real DWGs ship with garbage
2790
- * limits (e.g. `(0,0)-(12,9)` from a legacy template setup) that
2791
- * don't reflect the actual paper sheet. We reject those by
2792
- * checking containment against `viewportsBoundingBox`.
2802
+ * Applies Open options → Initial view for a layout the user just switched
2803
+ * into for the **first** time ({@link setOpenViewMode}).
2793
2804
  *
2794
- * 2. **`AcTrLayoutView.viewportsBoundingBox`** — bounding box of all
2795
- * real user viewports in the layout. In production sheets viewports
2796
- * typically span 70-90% of the paper, so this is a great proxy for
2797
- * the printable area and (crucially) ignores outliers like title
2798
- * blocks authored in a different unit/scale.
2805
+ * - **Saved + model**: VPORT `*ACTIVE`, else geometry fallback.
2806
+ * - **Saved + paper**: {@link acapResolveLayoutFrameBox} with limits
2807
+ * trusted only when they contain real viewports (rejects template
2808
+ * `(0,0)-(12,9)`), then viewports → layout extents → entity box.
2809
+ * - **Extents**: frame converted geometry (and paper viewports as a
2810
+ * content proxy). Does not prefer LIMMIN/LIMMAX over drawable bounds.
2799
2811
  *
2800
- * 3. **`AcDbLayout.extents`** — the layout's own EXTMIN/EXTMAX, if
2801
- * populated. Many parsers leave this empty (we've seen `(0,0)-(0,0)`),
2802
- * so it sits below the viewport-based heuristic.
2803
- *
2804
- * 4. **`getDrawingExtents`** (entity extents from batch geometry) —
2805
- * last-resort fallback for layouts with no viewports and no
2806
- * sensible limits/extents (e.g. a freshly created empty paper).
2807
- * Vulnerable to scale-mismatch outliers, but better than no zoom.
2808
- *
2809
- * **Critically, this runs through `AcEdConditionWaiter`**: at the
2810
- * moment `layoutSwitched` fires, the layout's entities (including its
2811
- * `AcDbViewport`s) have not yet been batch-converted into the scene
2812
- * — `loadLayoutEntitiesIfNeeded` chunked-converts via the progressive
2813
- * convert queue (or direct `batchConvert`).
2814
- * Without the waiter, `viewportsBoundingBox` returns undefined and
2815
- * the strategy degrades into (1) zooming to garbage `limits`, or
2816
- * (4) zooming to an empty scene box. The waiter polls
2817
- * {@link isProcessingEntities} (convert queue + deferred glyph jobs)
2818
- * and only fires the heuristic once conversion and text geometry finish.
2812
+ * Runs through {@link AcEdConditionWaiter} so viewport / entity convert
2813
+ * finishes before framing.
2819
2814
  */
2820
2815
  AcTrView2d.prototype.applyInitialZoom = function (btrId, layout) {
2821
2816
  var _this = this;
@@ -2823,40 +2818,58 @@ var AcTrView2d = /** @class */ (function (_super) {
2823
2818
  if (_this._externallyFramedLayouts.delete(btrId)) {
2824
2819
  return;
2825
2820
  }
2826
- var limits = layout.limits;
2827
- var layoutView = _this._layoutViewManager.getAt(btrId);
2828
- var vpsBox = layoutView === null || layoutView === void 0 ? void 0 : layoutView.viewportsBoundingBox;
2829
- var limitsContainsViewports = (function () {
2830
- if (!limits || limits.isEmpty())
2831
- return false;
2832
- if (!vpsBox)
2833
- return true;
2834
- return (limits.min.x <= vpsBox.min.x &&
2835
- limits.min.y <= vpsBox.min.y &&
2836
- limits.max.x >= vpsBox.max.x &&
2837
- limits.max.y >= vpsBox.max.y);
2838
- })();
2839
- if (limits && !limits.isEmpty() && limitsContainsViewports) {
2840
- _this.zoomTo(limits);
2841
- }
2842
- else if (vpsBox) {
2843
- _this.zoomTo(vpsBox);
2844
- }
2845
- else if (layout.extents && !layout.extents.isEmpty()) {
2846
- var extents = layout.extents;
2847
- _this.zoomTo(new AcGeBox2d({ x: extents.min.x, y: extents.min.y }, { x: extents.max.x, y: extents.max.y }));
2848
- }
2849
- else {
2850
- var box = _this.getDrawingExtents();
2851
- if (box) {
2852
- _this.zoomTo(box);
2853
- }
2821
+ var box = _this.resolveFirstVisitFrameBox(btrId, layout);
2822
+ if (box) {
2823
+ _this.zoomTo(box);
2854
2824
  }
2855
2825
  _this._isDirty = true;
2856
2826
  AcApZoomCmd.rememberOriginalView(_this, btrId);
2857
2827
  }, 300, 0);
2858
2828
  waiter.start();
2859
2829
  };
2830
+ /**
2831
+ * Resolves the camera box for a layout's first visit from
2832
+ * {@link _openViewMode}.
2833
+ */
2834
+ AcTrView2d.prototype.resolveFirstVisitFrameBox = function (btrId, layout) {
2835
+ var _a, _b;
2836
+ var isModelSpace = btrId === this.modelSpaceBtrId;
2837
+ var wantSaved = this._openViewMode === AcApOpenViewMode.Saved;
2838
+ if (wantSaved && isModelSpace) {
2839
+ var db = AcApDocManager.instance.curDocument.database;
2840
+ var aspect = this.width / Math.max(this.height, 1);
2841
+ var savedBox = db.tables.viewportTable.getActiveVportBox(aspect);
2842
+ if (savedBox)
2843
+ return savedBox;
2844
+ }
2845
+ var layoutView = this._layoutViewManager.getAt(btrId);
2846
+ var extents = layout.extents;
2847
+ var layoutExtents = extents && !extents.isEmpty()
2848
+ ? {
2849
+ min: { x: extents.min.x, y: extents.min.y },
2850
+ max: { x: extents.max.x, y: extents.max.y }
2851
+ }
2852
+ : undefined;
2853
+ var entityBox = this.getDrawingExtents();
2854
+ var viewportsBox = layoutView === null || layoutView === void 0 ? void 0 : layoutView.viewportsBoundingBox;
2855
+ if (wantSaved && !isModelSpace) {
2856
+ // Paper Saved: trust LIMMIN/LIMMAX only when they contain viewports.
2857
+ return (_a = acapResolveLayoutFrameBox({
2858
+ limits: layout.limits,
2859
+ viewportsBox: viewportsBox,
2860
+ layoutExtents: layoutExtents,
2861
+ entityBox: entityBox
2862
+ })) === null || _a === void 0 ? void 0 : _a.box;
2863
+ }
2864
+ // Extents (any layout), or Saved model fallback without *ACTIVE:
2865
+ // prefer drawable content; never lead with template model/paper limits.
2866
+ return (_b = acapResolveLayoutFrameBox({
2867
+ limits: undefined,
2868
+ viewportsBox: isModelSpace ? undefined : viewportsBox,
2869
+ layoutExtents: layoutExtents,
2870
+ entityBox: entityBox
2871
+ })) === null || _b === void 0 ? void 0 : _b.box;
2872
+ };
2860
2873
  /**
2861
2874
  * Invalidates in-flight progressive convert and empties convert / deferred
2862
2875
  * queues without tearing down the renderer or DOM.
@@ -2889,6 +2902,7 @@ var AcTrView2d = /** @class */ (function (_super) {
2889
2902
  this._missedImages.clear();
2890
2903
  this._initializedLayouts.clear();
2891
2904
  this._externallyFramedLayouts.clear();
2905
+ this._openViewMode = AcApOpenViewMode.Extents;
2892
2906
  this._loadingLayouts.clear();
2893
2907
  this._renderer.dispose();
2894
2908
  // Drop block templates when the scene is torn down (next open / close).
@@ -2906,6 +2920,7 @@ var AcTrView2d = /** @class */ (function (_super) {
2906
2920
  layoutViewManager: this._layoutViewManager,
2907
2921
  initializedLayouts: this._initializedLayouts,
2908
2922
  externallyFramedLayouts: this._externallyFramedLayouts,
2923
+ openViewMode: this._openViewMode,
2909
2924
  loadingLayouts: this._loadingLayouts,
2910
2925
  missedImages: this._missedImages,
2911
2926
  missedFonts: this._renderer.snapshotMissedFonts(),
@@ -2918,7 +2933,7 @@ var AcTrView2d = /** @class */ (function (_super) {
2918
2933
  * @param state - Snapshot previously returned by {@link captureSessionState} or {@link beginNewSession}.
2919
2934
  */
2920
2935
  AcTrView2d.prototype.restoreSessionState = function (state) {
2921
- var _a;
2936
+ var _a, _b;
2922
2937
  this._convertEpoch++;
2923
2938
  this.clearFontLoadedRedrawTimer();
2924
2939
  this.cancelOpenLineworkFrame();
@@ -2933,9 +2948,10 @@ var AcTrView2d = /** @class */ (function (_super) {
2933
2948
  this._layoutViewManager = state.layoutViewManager;
2934
2949
  this._initializedLayouts = state.initializedLayouts;
2935
2950
  this._externallyFramedLayouts = state.externallyFramedLayouts;
2951
+ this._openViewMode = (_a = state.openViewMode) !== null && _a !== void 0 ? _a : AcApOpenViewMode.Extents;
2936
2952
  this._loadingLayouts = state.loadingLayouts;
2937
2953
  this._missedImages = state.missedImages;
2938
- this._renderer.replaceMissedFonts((_a = state.missedFonts) !== null && _a !== void 0 ? _a : {});
2954
+ this._renderer.replaceMissedFonts((_b = state.missedFonts) !== null && _b !== void 0 ? _b : {});
2939
2955
  this.rebindLayerAppearance();
2940
2956
  this._layoutViewManager.resize(this.width, this.height);
2941
2957
  this.selectionSet.clear();
@@ -2966,6 +2982,7 @@ var AcTrView2d = /** @class */ (function (_super) {
2966
2982
  this._layoutViewManager = new AcTrLayoutViewManager();
2967
2983
  this._initializedLayouts = new Set();
2968
2984
  this._externallyFramedLayouts = new Set();
2985
+ this._openViewMode = AcApOpenViewMode.Extents;
2969
2986
  this._loadingLayouts = new Set();
2970
2987
  this._missedImages = new Map();
2971
2988
  this._renderer.clearMissedFonts();