@mlightcad/cad-simple-viewer 1.0.0 → 1.0.2

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 (136) hide show
  1. package/README.md +296 -2
  2. package/dist/index.js +1348 -122
  3. package/dist/index.umd.cjs +2 -2
  4. package/lib/app/AcApContext.d.ts +45 -3
  5. package/lib/app/AcApContext.d.ts.map +1 -1
  6. package/lib/app/AcApContext.js +43 -3
  7. package/lib/app/AcApContext.js.map +1 -1
  8. package/lib/app/AcApDocCreator.d.ts +68 -2
  9. package/lib/app/AcApDocCreator.d.ts.map +1 -1
  10. package/lib/app/AcApDocCreator.js +67 -2
  11. package/lib/app/AcApDocCreator.js.map +1 -1
  12. package/lib/app/AcApDocManager.d.ts +227 -12
  13. package/lib/app/AcApDocManager.d.ts.map +1 -1
  14. package/lib/app/AcApDocManager.js +229 -17
  15. package/lib/app/AcApDocManager.js.map +1 -1
  16. package/lib/app/AcApDocument.d.ts +77 -3
  17. package/lib/app/AcApDocument.d.ts.map +1 -1
  18. package/lib/app/AcApDocument.js +75 -3
  19. package/lib/app/AcApDocument.js.map +1 -1
  20. package/lib/app/AcApFontLoader.d.ts +32 -0
  21. package/lib/app/AcApFontLoader.d.ts.map +1 -1
  22. package/lib/app/AcApFontLoader.js +30 -0
  23. package/lib/app/AcApFontLoader.js.map +1 -1
  24. package/lib/app/AcApSettingManager.d.ts +191 -3
  25. package/lib/app/AcApSettingManager.d.ts.map +1 -1
  26. package/lib/app/AcApSettingManager.js +161 -0
  27. package/lib/app/AcApSettingManager.js.map +1 -1
  28. package/lib/command/AcApConvertToSvgCmd.d.ts +26 -0
  29. package/lib/command/AcApConvertToSvgCmd.d.ts.map +1 -1
  30. package/lib/command/AcApConvertToSvgCmd.js +26 -0
  31. package/lib/command/AcApConvertToSvgCmd.js.map +1 -1
  32. package/lib/command/AcApOpenCmd.d.ts +31 -0
  33. package/lib/command/AcApOpenCmd.d.ts.map +1 -1
  34. package/lib/command/AcApOpenCmd.js +31 -0
  35. package/lib/command/AcApOpenCmd.js.map +1 -1
  36. package/lib/command/AcApPanCmd.d.ts +25 -0
  37. package/lib/command/AcApPanCmd.d.ts.map +1 -1
  38. package/lib/command/AcApPanCmd.js +25 -0
  39. package/lib/command/AcApPanCmd.js.map +1 -1
  40. package/lib/command/AcApQNewCmd.d.ts +26 -0
  41. package/lib/command/AcApQNewCmd.d.ts.map +1 -1
  42. package/lib/command/AcApQNewCmd.js +26 -0
  43. package/lib/command/AcApQNewCmd.js.map +1 -1
  44. package/lib/command/AcApSelectCmd.d.ts +26 -0
  45. package/lib/command/AcApSelectCmd.d.ts.map +1 -1
  46. package/lib/command/AcApSelectCmd.js +26 -0
  47. package/lib/command/AcApSelectCmd.js.map +1 -1
  48. package/lib/command/AcApSvgConvertor.d.ts +48 -0
  49. package/lib/command/AcApSvgConvertor.d.ts.map +1 -1
  50. package/lib/command/AcApSvgConvertor.js +48 -0
  51. package/lib/command/AcApSvgConvertor.js.map +1 -1
  52. package/lib/command/AcApZoomCmd.d.ts +29 -0
  53. package/lib/command/AcApZoomCmd.d.ts.map +1 -1
  54. package/lib/command/AcApZoomCmd.js +29 -0
  55. package/lib/command/AcApZoomCmd.js.map +1 -1
  56. package/lib/command/AcApZoomToBoxCmd.d.ts +57 -0
  57. package/lib/command/AcApZoomToBoxCmd.d.ts.map +1 -1
  58. package/lib/command/AcApZoomToBoxCmd.js +57 -0
  59. package/lib/command/AcApZoomToBoxCmd.js.map +1 -1
  60. package/lib/editor/command/AcEdCommand.d.ts +118 -9
  61. package/lib/editor/command/AcEdCommand.d.ts.map +1 -1
  62. package/lib/editor/command/AcEdCommand.js +113 -9
  63. package/lib/editor/command/AcEdCommand.js.map +1 -1
  64. package/lib/editor/command/AcEdCommandStack.d.ts +59 -5
  65. package/lib/editor/command/AcEdCommandStack.d.ts.map +1 -1
  66. package/lib/editor/command/AcEdCommandStack.js +48 -5
  67. package/lib/editor/command/AcEdCommandStack.js.map +1 -1
  68. package/lib/editor/global/eventBus.d.ts +76 -7
  69. package/lib/editor/global/eventBus.d.ts.map +1 -1
  70. package/lib/editor/global/eventBus.js +38 -0
  71. package/lib/editor/global/eventBus.js.map +1 -1
  72. package/lib/editor/input/AcEdBaseInput.d.ts +65 -1
  73. package/lib/editor/input/AcEdBaseInput.d.ts.map +1 -1
  74. package/lib/editor/input/AcEdBaseInput.js +62 -1
  75. package/lib/editor/input/AcEdBaseInput.js.map +1 -1
  76. package/lib/editor/input/AcEdBoxSelector.d.ts +81 -0
  77. package/lib/editor/input/AcEdBoxSelector.d.ts.map +1 -1
  78. package/lib/editor/input/AcEdBoxSelector.js +80 -0
  79. package/lib/editor/input/AcEdBoxSelector.js.map +1 -1
  80. package/lib/editor/input/AcEdCursorManager.d.ts +95 -8
  81. package/lib/editor/input/AcEdCursorManager.d.ts.map +1 -1
  82. package/lib/editor/input/AcEdCursorManager.js +95 -11
  83. package/lib/editor/input/AcEdCursorManager.js.map +1 -1
  84. package/lib/editor/input/AcEdInputPoint.d.ts +38 -1
  85. package/lib/editor/input/AcEdInputPoint.d.ts.map +1 -1
  86. package/lib/editor/input/AcEdInputPoint.js +38 -1
  87. package/lib/editor/input/AcEdInputPoint.js.map +1 -1
  88. package/lib/editor/input/AcEdJig.d.ts +166 -0
  89. package/lib/editor/input/AcEdJig.d.ts.map +1 -1
  90. package/lib/editor/input/AcEdJig.js +164 -0
  91. package/lib/editor/input/AcEdJig.js.map +1 -1
  92. package/lib/editor/input/AcEdJigLoop.d.ts +49 -0
  93. package/lib/editor/input/AcEdJigLoop.d.ts.map +1 -1
  94. package/lib/editor/input/AcEdJigLoop.js +48 -0
  95. package/lib/editor/input/AcEdJigLoop.js.map +1 -1
  96. package/lib/editor/input/AcEdSelectionSet.d.ts +122 -2
  97. package/lib/editor/input/AcEdSelectionSet.d.ts.map +1 -1
  98. package/lib/editor/input/AcEdSelectionSet.js +117 -1
  99. package/lib/editor/input/AcEdSelectionSet.js.map +1 -1
  100. package/lib/editor/input/AcEditor.d.ts +90 -6
  101. package/lib/editor/input/AcEditor.d.ts.map +1 -1
  102. package/lib/editor/input/AcEditor.js +86 -6
  103. package/lib/editor/input/AcEditor.js.map +1 -1
  104. package/lib/editor/view/AcEdBaseView.d.ts +163 -16
  105. package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
  106. package/lib/editor/view/AcEdBaseView.js +94 -5
  107. package/lib/editor/view/AcEdBaseView.js.map +1 -1
  108. package/lib/util/AcTrGeometryUtil.d.ts +65 -0
  109. package/lib/util/AcTrGeometryUtil.d.ts.map +1 -1
  110. package/lib/util/AcTrGeometryUtil.js +65 -0
  111. package/lib/util/AcTrGeometryUtil.js.map +1 -1
  112. package/lib/view/AcTrLayer.d.ts +40 -5
  113. package/lib/view/AcTrLayer.d.ts.map +1 -1
  114. package/lib/view/AcTrLayer.js +34 -5
  115. package/lib/view/AcTrLayer.js.map +1 -1
  116. package/lib/view/AcTrLayout.d.ts +122 -23
  117. package/lib/view/AcTrLayout.d.ts.map +1 -1
  118. package/lib/view/AcTrLayout.js +103 -23
  119. package/lib/view/AcTrLayout.js.map +1 -1
  120. package/lib/view/AcTrLayoutView.d.ts +74 -16
  121. package/lib/view/AcTrLayoutView.d.ts.map +1 -1
  122. package/lib/view/AcTrLayoutView.js +65 -16
  123. package/lib/view/AcTrLayoutView.js.map +1 -1
  124. package/lib/view/AcTrLayoutViewManager.d.ts +58 -12
  125. package/lib/view/AcTrLayoutViewManager.d.ts.map +1 -1
  126. package/lib/view/AcTrLayoutViewManager.js +56 -12
  127. package/lib/view/AcTrLayoutViewManager.js.map +1 -1
  128. package/lib/view/AcTrScene.d.ts +48 -4
  129. package/lib/view/AcTrScene.d.ts.map +1 -1
  130. package/lib/view/AcTrScene.js +44 -4
  131. package/lib/view/AcTrScene.js.map +1 -1
  132. package/lib/view/AcTrView2d.d.ts +71 -0
  133. package/lib/view/AcTrView2d.d.ts.map +1 -1
  134. package/lib/view/AcTrView2d.js +65 -0
  135. package/lib/view/AcTrView2d.js.map +1 -1
  136. package/package.json +8 -4
@@ -1,16 +1,51 @@
1
1
  import { AcDbObjectId } from '@mlightcad/data-model';
2
2
  import { AcTrBatchedGroup, AcTrBatchedGroupStats, AcTrEntity } from '@mlightcad/three-renderer';
3
3
  import * as THREE from 'three';
4
+ /**
5
+ * Statistics for a CAD layer including name and batched rendering metrics.
6
+ *
7
+ * Extends the standard batched group statistics with layer-specific information.
8
+ */
4
9
  export type AcTrLayerStats = AcTrBatchedGroupStats & {
10
+ /** The name of the layer */
5
11
  name: string;
6
12
  };
7
13
  /**
8
- * The class is used to render layer in AutoCAD.
14
+ * Represents a CAD layer for organizing and rendering entities in Three.js.
15
+ *
16
+ * This class manages a collection of CAD entities that belong to the same logical layer.
17
+ * It provides:
18
+ * - Entity organization and grouping
19
+ * - Layer visibility control
20
+ * - Efficient batched rendering through Three.js groups
21
+ * - Performance monitoring and statistics
22
+ *
23
+ * ## Technical Notes
24
+ * Unlike Three.js built-in layers (which only support 32 layers), this implementation
25
+ * uses Three.js groups to represent AutoCAD layers, allowing unlimited layer support.
26
+ * Each AutoCAD layer corresponds to one Three.js group containing all entities.
27
+ *
28
+ * ## Performance Benefits
29
+ * - Batched rendering reduces draw calls
30
+ * - Efficient visibility toggling for entire layers
31
+ * - Optimized entity grouping for better GPU performance
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * // Create a new layer
36
+ * const layer = new AcTrLayer('Dimensions');
37
+ *
38
+ * // Add entities to the layer
39
+ * const line = new AcTrLine(startPoint, endPoint);
40
+ * layer.add(line);
41
+ *
42
+ * // Control layer visibility
43
+ * layer.visible = false; // Hide all entities in this layer
9
44
  *
10
- * Notes:
11
- * Layers provided by THREE.js aren't used to control visibility of entities because it supports 32 layers only.
12
- * Instead groups are used to represent layers in AutoCAD. One AutoCAD layer is represented by one group in
13
- * THREE.js.
45
+ * // Get layer statistics
46
+ * const stats = layer.stats;
47
+ * console.log(`Layer ${stats.name} has ${stats.entityCount} entities`);
48
+ * ```
14
49
  */
15
50
  export declare class AcTrLayer {
16
51
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"AcTrLayer.d.ts","sourceRoot":"","sources":["../../src/view/AcTrLayer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACX,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,MAAM,MAAM,cAAc,GAAG,qBAAqB,GAAG;IACnD,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;GAOG;AACH,qBAAa,SAAS;IACpB;;OAEG;IACH,OAAO,CAAC,KAAK,CAAQ;IACrB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAkB;IAEhC;;;OAGG;gBACS,IAAI,EAAE,MAAM;IAKxB;;OAEG;IACH,IAAI,IAAI,IAGQ,MAAM,CADrB;IACD,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,EAErB;IAED,IAAI,OAAO,IAGQ,OAAO,CADzB;IACD,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,EAEzB;IAED,IAAI,cAAc,qBAEjB;IAED;;OAEG;IACH,IAAI,KAAK,IAKF,cAAc,CACpB;IAED;;OAEG;IACH,IAAI,WAAW,WAEd;IAED;;;OAGG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM;IAIlC;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,YAAY;IAIhC;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,UAAU;IAI5B;;;;OAIG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS;IAI5D;;;;OAIG;IACH,MAAM,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO;IAKxC;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO;IAMnC;;OA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AI5B;;;;OAIG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS;IAI5D;;;;OAIG;IACH,MAAM,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO;IAKxC;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO;IAMnC;;OAEG;IACH,KAAK,CAAC,GAAG,EAAE,YAAY,EAAE;IAMzB;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,YAAY,EAAE;IAM3B;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,YAAY,EAAE;IAM1B;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,YAAY,EAAE;CAK7B"}
@@ -11,12 +11,41 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { AcTrBatchedGroup } from '@mlightcad/three-renderer';
13
13
  /**
14
- * The class is used to render layer in AutoCAD.
14
+ * Represents a CAD layer for organizing and rendering entities in Three.js.
15
15
  *
16
- * Notes:
17
- * Layers provided by THREE.js aren't used to control visibility of entities because it supports 32 layers only.
18
- * Instead groups are used to represent layers in AutoCAD. One AutoCAD layer is represented by one group in
19
- * THREE.js.
16
+ * This class manages a collection of CAD entities that belong to the same logical layer.
17
+ * It provides:
18
+ * - Entity organization and grouping
19
+ * - Layer visibility control
20
+ * - Efficient batched rendering through Three.js groups
21
+ * - Performance monitoring and statistics
22
+ *
23
+ * ## Technical Notes
24
+ * Unlike Three.js built-in layers (which only support 32 layers), this implementation
25
+ * uses Three.js groups to represent AutoCAD layers, allowing unlimited layer support.
26
+ * Each AutoCAD layer corresponds to one Three.js group containing all entities.
27
+ *
28
+ * ## Performance Benefits
29
+ * - Batched rendering reduces draw calls
30
+ * - Efficient visibility toggling for entire layers
31
+ * - Optimized entity grouping for better GPU performance
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * // Create a new layer
36
+ * const layer = new AcTrLayer('Dimensions');
37
+ *
38
+ * // Add entities to the layer
39
+ * const line = new AcTrLine(startPoint, endPoint);
40
+ * layer.add(line);
41
+ *
42
+ * // Control layer visibility
43
+ * layer.visible = false; // Hide all entities in this layer
44
+ *
45
+ * // Get layer statistics
46
+ * const stats = layer.stats;
47
+ * console.log(`Layer ${stats.name} has ${stats.entityCount} entities`);
48
+ * ```
20
49
  */
21
50
  var AcTrLayer = /** @class */ (function () {
22
51
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"AcTrLayer.js","sourceRoot":"","sources":["../../src/view/AcTrLayer.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,EACL,gBAAgB,EAGjB,MAAM,2BAA2B,CAAA;AAOlC;;;;;;;GAOG;AACH;IAUE;;;OAGG;IACH,mBAAY,IAAY;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAA;QACpC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;IACnB,CAAC;IAKD,sBAAI,2BAAI;QAHR;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,KAAK,CAAA;QACnB,CAAC;aACD,UAAS,KAAa;YACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QACpB,CAAC;;;OAHA;IAKD,sBAAI,8BAAO;aAAX;YACE,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAA;QAC5B,CAAC;aACD,UAAY,KAAc;YACxB,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,KAAK,CAAA;QAC7B,CAAC;;;OAHA;IAKD,sBAAI,qCAAc;aAAlB;YACE,OAAO,IAAI,CAAC,MAAM,CAAA;QACpB,CAAC;;;OAAA;IAKD,sBAAI,4BAAK;QAHT;;WAEG;aACH;YACE,IAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAA;YAC3C,OAAO,WACL,IAAI,EAAE,IAAI,CAAC,KAAK,IACb,iBAAiB,CACH,CAAA;QACrB,CAAC;;;OAAA;IAKD,sBAAI,kCAAW;QAHf;;WAEG;aACH;YACE,OA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AE,CAAC,CAAA;QACvB,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,2BAAO,GAAP,UAAQ,GAAmB;QAA3B,iBAIC;QAHC,GAAG,CAAC,OAAO,CAAC,UAAA,EAAE;YACZ,KAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QACzB,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,0BAAM,GAAN,UAAO,GAAmB;QAA1B,iBAIC;QAHC,GAAG,CAAC,OAAO,CAAC,UAAA,EAAE;YACZ,KAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,4BAAQ,GAAR,UAAS,GAAmB;QAA5B,iBAIC;QAHC,GAAG,CAAC,OAAO,CAAC,UAAA,EAAE;YACZ,KAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;QAC1B,CAAC,CAAC,CAAA;IACJ,CAAC;IACH,gBAAC;AAAD,CAAC,AArJD,IAqJC"}
@@ -3,111 +3,210 @@ import { AcTrEntity, AcTrObject } from '@mlightcad/three-renderer';
3
3
  import * as THREE from 'three';
4
4
  import { AcEdSpatialQueryResultItem } from '../editor';
5
5
  import { AcTrLayer, AcTrLayerStats } from './AcTrLayer';
6
+ /**
7
+ * Interface representing statistics for a layout.
8
+ * Provides detailed information about the layout's content including
9
+ * layer statistics and memory usage breakdown.
10
+ */
6
11
  export interface AcTrLayoutStats {
12
+ /** Statistics for each layer in the layout */
7
13
  layers: AcTrLayerStats[];
14
+ /** Summary statistics for the entire layout */
8
15
  summary: {
16
+ /** Total number of entities across all layers */
9
17
  entityCount: number;
18
+ /** Memory usage breakdown by object type */
10
19
  totalSize: {
20
+ /** Memory used by line geometries (bytes) */
11
21
  line: number;
22
+ /** Memory used by mesh geometries (bytes) */
12
23
  mesh: number;
24
+ /** Memory used by point geometries (bytes) */
13
25
  point: number;
26
+ /** Total geometry memory usage (bytes) */
14
27
  geometry: number;
28
+ /** Memory used by entity mappings (bytes) */
15
29
  mapping: number;
16
30
  };
17
31
  };
18
32
  }
19
33
  /**
20
- * This class represents objects contained in one AuotCAD layout (model space or paper space).
34
+ * This class represents objects contained in one AutoCAD layout (model space or paper space).
35
+ *
36
+ * A layout manages the organization and rendering of CAD entities within a specific coordinate space.
37
+ * It provides functionality for:
38
+ * - Managing entities organized by layers
39
+ * - Spatial indexing for efficient entity queries
40
+ * - Bounding box management for view operations
41
+ * - Entity selection and highlighting
42
+ * - Memory usage tracking and statistics
43
+ *
44
+ * Layouts use a spatial index (R-tree) for fast entity lookup operations and maintain
45
+ * a hierarchical structure where entities are grouped by layers for efficient rendering
46
+ * and visibility management.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const layout = new AcTrLayout();
51
+ * layout.addEntity(entity);
52
+ * const entities = layout.search(boundingBox);
53
+ * layout.select(['entity1', 'entity2']);
54
+ * ```
21
55
  */
22
56
  export declare class AcTrLayout {
57
+ /** The group that contains all entities in this layout */
23
58
  private _group;
59
+ /** Spatial index tree for efficient entity queries */
24
60
  private _indexTree;
61
+ /** Bounding box containing all entities in this layout */
25
62
  private _box;
63
+ /** Map of layers indexed by layer name */
26
64
  private _layers;
65
+ /** Optional object for displaying snap points */
27
66
  private _snapPointsObject?;
67
+ /**
68
+ * Creates a new layout instance.
69
+ * Initializes the layout with empty collections and a spatial index.
70
+ */
28
71
  constructor();
29
72
  /**
30
73
  * The internal THREE.js object to use by scene. This is internally used only. Try to avoid using it.
31
74
  * @internal
32
75
  */
33
76
  get internalObject(): THREE.Group<THREE.Object3DEventMap>;
77
+ /**
78
+ * Gets the map of layers in this layout.
79
+ *
80
+ * @returns Map of layer names to layer objects
81
+ */
34
82
  get layers(): Map<string, AcTrLayer>;
83
+ /**
84
+ * Gets the bounding box that contains all entities in this layout.
85
+ *
86
+ * @returns The layout's bounding box
87
+ */
35
88
  get box(): THREE.Box3;
36
89
  /**
37
- * The visibility of this layout
90
+ * The visibility of this layout.
91
+ * When set to false, the entire layout and all its contents are hidden.
38
92
  */
39
93
  get visible(): boolean;
40
94
  set visible(value: boolean);
41
95
  /**
42
- * The number of entities stored in this layer
96
+ * The number of entities stored in this layout.
97
+ * Calculates the total by summing entities across all layers.
43
98
  */
44
99
  get entityCount(): number;
45
100
  /**
46
- * The statistics of this layout
101
+ * The statistics of this layout.
102
+ * Provides detailed information about memory usage and entity counts.
47
103
  */
48
104
  get stats(): AcTrLayoutStats;
105
+ /**
106
+ * Clears all entities from the layout.
107
+ * Removes all layers, resets the bounding box, and clears the spatial index.
108
+ *
109
+ * @returns This layout instance for method chaining
110
+ */
49
111
  clear(): this;
50
112
  /**
51
- * Re-render points with latest point style settings
52
- * @param displayMode Input display mode of points
113
+ * Re-render points with latest point style settings.
114
+ * Updates the visual representation of all point entities across all layers.
115
+ *
116
+ * @param displayMode - Input display mode of points
53
117
  */
54
118
  rerenderPoints(displayMode: number): void;
55
119
  /**
56
120
  * Return true if the object with the specified object id is intersected with the ray by using raycast.
57
- * @param objectId Input object id of object to check for intersection with the ray.
58
- * @param raycaster Input raycaster to check intersection
121
+ *
122
+ * @param objectId - Input object id of object to check for intersection with the ray.
123
+ * @param raycaster - Input raycaster to check intersection
124
+ * @returns True if the object intersects with the ray, false otherwise
59
125
  */
60
126
  isIntersectWith(objectId: string, raycaster: THREE.Raycaster): boolean | undefined;
61
127
  /**
62
128
  * Add one AutoCAD entity into this layout. If layer group referenced by the entity doesn't exist, create one
63
129
  * layer group and add this entity this group.
64
- * @param entity Input AutoCAD entity to be added into this layout.
65
- * @param extendBbox Input the flag whether to extend the bounding box of the scene by union the bounding box
66
- * of the specified entity.
130
+ *
131
+ * @param entity - Input AutoCAD entity to be added into this layout.
132
+ * @param extendBbox - Input the flag whether to extend the bounding box of the scene by union the bounding box
133
+ * of the specified entity. Defaults to true.
134
+ * @returns This layout instance for method chaining
135
+ *
136
+ * @throws {Error} When entity is missing required objectId or layerName
67
137
  */
68
138
  addEntity(entity: AcTrEntity, extendBbox?: boolean): this;
69
139
  /**
70
140
  * Remove the specified entity from this layout.
71
- * @param objectId Input the object id of the entity to remove
141
+ *
142
+ * @param objectId - Input the object id of the entity to remove
72
143
  * @returns Return true if remove the specified entity successfully. Otherwise, return false.
73
144
  */
74
145
  remove(objectId: AcDbObjectId): boolean;
75
146
  /**
76
147
  * Update the specified entity in this layout.
77
- * @param objectId Input the entity to update
148
+ *
149
+ * @param entity - Input the entity to update
78
150
  * @returns Return true if update the specified entity successfully. Otherwise, return false.
79
151
  */
80
152
  update(entity: AcTrEntity): boolean;
81
153
  /**
82
- * Hover the specified entities
154
+ * Hover the specified entities.
155
+ * Applies hover highlighting to the entities with the given IDs.
156
+ *
157
+ * @param ids - Array of entity object IDs to hover
83
158
  */
84
159
  hover(ids: AcDbObjectId[]): void;
85
160
  /**
86
- * Unhover the specified entities
161
+ * Unhover the specified entities.
162
+ * Removes hover highlighting from the entities with the given IDs.
163
+ *
164
+ * @param ids - Array of entity object IDs to unhover
87
165
  */
88
166
  unhover(ids: AcDbObjectId[]): void;
89
167
  /**
90
- * Select the specified entities
168
+ * Select the specified entities.
169
+ * Applies selection highlighting to the entities with the given IDs.
170
+ *
171
+ * @param ids - Array of entity object IDs to select
91
172
  */
92
173
  select(ids: AcDbObjectId[]): void;
93
174
  /**
94
- * Unselect the specified entities
175
+ * Unselect the specified entities.
176
+ * Removes selection highlighting from the entities with the given IDs.
177
+ *
178
+ * @param ids - Array of entity object IDs to unselect
95
179
  */
96
180
  unselect(ids: AcDbObjectId[]): void;
181
+ /**
182
+ * Sets the snap points object for this layout.
183
+ * Replaces any existing snap points object with the new one.
184
+ *
185
+ * @param object - The snap points object to display
186
+ */
97
187
  setSnapObject(object: AcTrObject): void;
98
188
  /**
99
189
  * Search entities intersected or contained in the specified bounding box.
100
- * @param box Input the query bounding box
101
- * @returns Return query results
190
+ * Uses the spatial index for efficient querying of entities within the given bounds.
191
+ *
192
+ * @param box - Input the query bounding box (2D or 3D)
193
+ * @returns Return query results containing entity IDs and their bounds
102
194
  */
103
195
  search(box: AcGeBox2d | AcGeBox3d): AcEdSpatialQueryResultItem[];
196
+ /**
197
+ * Finds the layer containing the entity with the specified object ID.
198
+ *
199
+ * @param objectId - The object ID to search for
200
+ * @returns The layer containing the entity, or undefined if not found
201
+ */
104
202
  private getLayerByObjectId;
105
203
  /**
106
204
  * Get layer group by name. If the layer doesn't exist, create one layer group into this layout.
107
- * @param name Input layer name
108
- * @param createIfNotExist Input one flag to indicate whether to create layer group if it doesn't exist in
109
- * this layout.
110
- * @returns Return matched layer
205
+ *
206
+ * @param name - Input layer name
207
+ * @param createIfNotExist - Input one flag to indicate whether to create layer group if it doesn't exist in
208
+ * this layout. Defaults to true.
209
+ * @returns Return matched layer, or undefined if not found and createIfNotExist is false
111
210
  */
112
211
  private getLayer;
113
212
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AcTrLayout.d.ts","sourceRoot":"","sources":["../../src/view/AcTrLayout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAC1E,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAElE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEvD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAA;QACnB,SAAS,EAAE;YACT,IAAI,EAAE,MAAM,CAAA;YACZ,IAAI,EAAE,MAAM,CAAA;YACZ,KAAK,EAAE,MAAM,CAAA;YACb,QAAQ,EAAE,MAAM,CAAA;YAChB,OAAO,EAAE,MAAM,CAAA;SAChB,CAAA;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N;IAED;;;OAGG;IACH,IAAI,OAAO,IAGQ,OAAO,CADzB;IACD,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,EAEzB;IAED;;;OAGG;IACH,IAAI,WAAW,WAId;IAED;;;OAGG;IACH,IAAI,KAAK,IA+BF,eAAe,CACrB;IAED;;;;;OAKG;IACH,KAAK;IAUL;;;;;OAKG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM;IAMlC;;;;;;OAMG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS;IAK5D;;;;;;;;;;OAUG;IACH,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,GAAE,OAAc;IA2BxD;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,YAAY;IAO7B;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,UAAU;IAOzB;;;;;OAKG;IACH,KAAK,CAAC,GAAG,EAAE,YAAY,EAAE;IASzB;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,YAAY,EAAE;IAS3B;;;;;OAKG;IACH,MAAM,CAAC,GAAG,EAAE,YAAY,EAAE;IAS1B;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,YAAY,EAAE;IAS5B;;;;;OAKG;IACH,aAAa,CAAC,MAAM,EAAE,UAAU;IAQhC;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,SAAS,GAAG,SAAS;IAUjC;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAO1B;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ;CASjB"}
@@ -29,9 +29,33 @@ import RBush from 'rbush';
29
29
  import * as THREE from 'three';
30
30
  import { AcTrLayer } from './AcTrLayer';
31
31
  /**
32
- * This class represents objects contained in one AuotCAD layout (model space or paper space).
32
+ * This class represents objects contained in one AutoCAD layout (model space or paper space).
33
+ *
34
+ * A layout manages the organization and rendering of CAD entities within a specific coordinate space.
35
+ * It provides functionality for:
36
+ * - Managing entities organized by layers
37
+ * - Spatial indexing for efficient entity queries
38
+ * - Bounding box management for view operations
39
+ * - Entity selection and highlighting
40
+ * - Memory usage tracking and statistics
41
+ *
42
+ * Layouts use a spatial index (R-tree) for fast entity lookup operations and maintain
43
+ * a hierarchical structure where entities are grouped by layers for efficient rendering
44
+ * and visibility management.
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const layout = new AcTrLayout();
49
+ * layout.addEntity(entity);
50
+ * const entities = layout.search(boundingBox);
51
+ * layout.select(['entity1', 'entity2']);
52
+ * ```
33
53
  */
34
54
  var AcTrLayout = /** @class */ (function () {
55
+ /**
56
+ * Creates a new layout instance.
57
+ * Initializes the layout with empty collections and a spatial index.
58
+ */
35
59
  function AcTrLayout() {
36
60
  this._group = new THREE.Group();
37
61
  this._indexTree = new RBush();
@@ -50,6 +74,11 @@ var AcTrLayout = /** @class */ (function () {
50
74
  configurable: true
51
75
  });
52
76
  Object.defineProperty(AcTrLayout.prototype, "layers", {
77
+ /**
78
+ * Gets the map of layers in this layout.
79
+ *
80
+ * @returns Map of layer names to layer objects
81
+ */
53
82
  get: function () {
54
83
  return this._layers;
55
84
  },
@@ -57,6 +86,11 @@ var AcTrLayout = /** @class */ (function () {
57
86
  configurable: true
58
87
  });
59
88
  Object.defineProperty(AcTrLayout.prototype, "box", {
89
+ /**
90
+ * Gets the bounding box that contains all entities in this layout.
91
+ *
92
+ * @returns The layout's bounding box
93
+ */
60
94
  get: function () {
61
95
  return this._box;
62
96
  },
@@ -65,7 +99,8 @@ var AcTrLayout = /** @class */ (function () {
65
99
  });
66
100
  Object.defineProperty(AcTrLayout.prototype, "visible", {
67
101
  /**
68
- * The visibility of this layout
102
+ * The visibility of this layout.
103
+ * When set to false, the entire layout and all its contents are hidden.
69
104
  */
70
105
  get: function () {
71
106
  return this._group.visible;
@@ -78,7 +113,8 @@ var AcTrLayout = /** @class */ (function () {
78
113
  });
79
114
  Object.defineProperty(AcTrLayout.prototype, "entityCount", {
80
115
  /**
81
- * The number of entities stored in this layer
116
+ * The number of entities stored in this layout.
117
+ * Calculates the total by summing entities across all layers.
82
118
  */
83
119
  get: function () {
84
120
  var count = 0;
@@ -90,7 +126,8 @@ var AcTrLayout = /** @class */ (function () {
90
126
  });
91
127
  Object.defineProperty(AcTrLayout.prototype, "stats", {
92
128
  /**
93
- * The statistics of this layout
129
+ * The statistics of this layout.
130
+ * Provides detailed information about memory usage and entity counts.
94
131
  */
95
132
  get: function () {
96
133
  var layers = [];
@@ -128,6 +165,12 @@ var AcTrLayout = /** @class */ (function () {
128
165
  enumerable: false,
129
166
  configurable: true
130
167
  });
168
+ /**
169
+ * Clears all entities from the layout.
170
+ * Removes all layers, resets the bounding box, and clears the spatial index.
171
+ *
172
+ * @returns This layout instance for method chaining
173
+ */
131
174
  AcTrLayout.prototype.clear = function () {
132
175
  var _this = this;
133
176
  this._layers.forEach(function (layer) {
@@ -139,8 +182,10 @@ var AcTrLayout = /** @class */ (function () {
139
182
  return this;
140
183
  };
141
184
  /**
142
- * Re-render points with latest point style settings
143
- * @param displayMode Input display mode of points
185
+ * Re-render points with latest point style settings.
186
+ * Updates the visual representation of all point entities across all layers.
187
+ *
188
+ * @param displayMode - Input display mode of points
144
189
  */
145
190
  AcTrLayout.prototype.rerenderPoints = function (displayMode) {
146
191
  this._layers.forEach(function (layer) {
@@ -149,8 +194,10 @@ var AcTrLayout = /** @class */ (function () {
149
194
  };
150
195
  /**
151
196
  * Return true if the object with the specified object id is intersected with the ray by using raycast.
152
- * @param objectId Input object id of object to check for intersection with the ray.
153
- * @param raycaster Input raycaster to check intersection
197
+ *
198
+ * @param objectId - Input object id of object to check for intersection with the ray.
199
+ * @param raycaster - Input raycaster to check intersection
200
+ * @returns True if the object intersects with the ray, false otherwise
154
201
  */
155
202
  AcTrLayout.prototype.isIntersectWith = function (objectId, raycaster) {
156
203
  var layer = this.getLayerByObjectId(objectId);
@@ -159,9 +206,13 @@ var AcTrLayout = /** @class */ (function () {
159
206
  /**
160
207
  * Add one AutoCAD entity into this layout. If layer group referenced by the entity doesn't exist, create one
161
208
  * layer group and add this entity this group.
162
- * @param entity Input AutoCAD entity to be added into this layout.
163
- * @param extendBbox Input the flag whether to extend the bounding box of the scene by union the bounding box
164
- * of the specified entity.
209
+ *
210
+ * @param entity - Input AutoCAD entity to be added into this layout.
211
+ * @param extendBbox - Input the flag whether to extend the bounding box of the scene by union the bounding box
212
+ * of the specified entity. Defaults to true.
213
+ * @returns This layout instance for method chaining
214
+ *
215
+ * @throws {Error} When entity is missing required objectId or layerName
165
216
  */
166
217
  AcTrLayout.prototype.addEntity = function (entity, extendBbox) {
167
218
  if (extendBbox === void 0) { extendBbox = true; }
@@ -190,7 +241,8 @@ var AcTrLayout = /** @class */ (function () {
190
241
  };
191
242
  /**
192
243
  * Remove the specified entity from this layout.
193
- * @param objectId Input the object id of the entity to remove
244
+ *
245
+ * @param objectId - Input the object id of the entity to remove
194
246
  * @returns Return true if remove the specified entity successfully. Otherwise, return false.
195
247
  */
196
248
  AcTrLayout.prototype.remove = function (objectId) {
@@ -213,7 +265,8 @@ var AcTrLayout = /** @class */ (function () {
213
265
  };
214
266
  /**
215
267
  * Update the specified entity in this layout.
216
- * @param objectId Input the entity to update
268
+ *
269
+ * @param entity - Input the entity to update
217
270
  * @returns Return true if update the specified entity successfully. Otherwise, return false.
218
271
  */
219
272
  AcTrLayout.prototype.update = function (entity) {
@@ -235,7 +288,10 @@ var AcTrLayout = /** @class */ (function () {
235
288
  return false;
236
289
  };
237
290
  /**
238
- * Hover the specified entities
291
+ * Hover the specified entities.
292
+ * Applies hover highlighting to the entities with the given IDs.
293
+ *
294
+ * @param ids - Array of entity object IDs to hover
239
295
  */
240
296
  AcTrLayout.prototype.hover = function (ids) {
241
297
  var _this = this;
@@ -247,7 +303,10 @@ var AcTrLayout = /** @class */ (function () {
247
303
  });
248
304
  };
249
305
  /**
250
- * Unhover the specified entities
306
+ * Unhover the specified entities.
307
+ * Removes hover highlighting from the entities with the given IDs.
308
+ *
309
+ * @param ids - Array of entity object IDs to unhover
251
310
  */
252
311
  AcTrLayout.prototype.unhover = function (ids) {
253
312
  var _this = this;
@@ -259,7 +318,10 @@ var AcTrLayout = /** @class */ (function () {
259
318
  });
260
319
  };
261
320
  /**
262
- * Select the specified entities
321
+ * Select the specified entities.
322
+ * Applies selection highlighting to the entities with the given IDs.
323
+ *
324
+ * @param ids - Array of entity object IDs to select
263
325
  */
264
326
  AcTrLayout.prototype.select = function (ids) {
265
327
  var _this = this;
@@ -271,7 +333,10 @@ var AcTrLayout = /** @class */ (function () {
271
333
  });
272
334
  };
273
335
  /**
274
- * Unselect the specified entities
336
+ * Unselect the specified entities.
337
+ * Removes selection highlighting from the entities with the given IDs.
338
+ *
339
+ * @param ids - Array of entity object IDs to unselect
275
340
  */
276
341
  AcTrLayout.prototype.unselect = function (ids) {
277
342
  var _this = this;
@@ -282,6 +347,12 @@ var AcTrLayout = /** @class */ (function () {
282
347
  }
283
348
  });
284
349
  };
350
+ /**
351
+ * Sets the snap points object for this layout.
352
+ * Replaces any existing snap points object with the new one.
353
+ *
354
+ * @param object - The snap points object to display
355
+ */
285
356
  AcTrLayout.prototype.setSnapObject = function (object) {
286
357
  if (this._snapPointsObject) {
287
358
  this._group.remove(this._snapPointsObject);
@@ -291,8 +362,10 @@ var AcTrLayout = /** @class */ (function () {
291
362
  };
292
363
  /**
293
364
  * Search entities intersected or contained in the specified bounding box.
294
- * @param box Input the query bounding box
295
- * @returns Return query results
365
+ * Uses the spatial index for efficient querying of entities within the given bounds.
366
+ *
367
+ * @param box - Input the query bounding box (2D or 3D)
368
+ * @returns Return query results containing entity IDs and their bounds
296
369
  */
297
370
  AcTrLayout.prototype.search = function (box) {
298
371
  var results = this._indexTree.search({
@@ -303,6 +376,12 @@ var AcTrLayout = /** @class */ (function () {
303
376
  });
304
377
  return results;
305
378
  };
379
+ /**
380
+ * Finds the layer containing the entity with the specified object ID.
381
+ *
382
+ * @param objectId - The object ID to search for
383
+ * @returns The layer containing the entity, or undefined if not found
384
+ */
306
385
  AcTrLayout.prototype.getLayerByObjectId = function (objectId) {
307
386
  var e_3, _a;
308
387
  try {
@@ -323,10 +402,11 @@ var AcTrLayout = /** @class */ (function () {
323
402
  };
324
403
  /**
325
404
  * Get layer group by name. If the layer doesn't exist, create one layer group into this layout.
326
- * @param name Input layer name
327
- * @param createIfNotExist Input one flag to indicate whether to create layer group if it doesn't exist in
328
- * this layout.
329
- * @returns Return matched layer
405
+ *
406
+ * @param name - Input layer name
407
+ * @param createIfNotExist - Input one flag to indicate whether to create layer group if it doesn't exist in
408
+ * this layout. Defaults to true.
409
+ * @returns Return matched layer, or undefined if not found and createIfNotExist is false
330
410
  */
331
411
  AcTrLayout.prototype.getLayer = function (name, createIfNotExist) {
332
412
  if (createIfNotExist === void 0) { createIfNotExist = true; }