@mlightcad/cad-simple-viewer 1.5.6 → 1.5.7
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 +66 -1
- package/dist/cad-simple-viewer.js +30394 -28405
- package/dist/cad-simple-viewer.umd.cjs +150 -158
- package/dist/dxf-parser-worker.js +796 -707
- package/lib/app/AcApContext.d.ts.map +1 -1
- package/lib/app/AcApContext.js +15 -5
- package/lib/app/AcApContext.js.map +1 -1
- package/lib/app/AcApDocManager.d.ts +56 -0
- package/lib/app/AcApDocManager.d.ts.map +1 -1
- package/lib/app/AcApDocManager.js +112 -14
- package/lib/app/AcApDocManager.js.map +1 -1
- package/lib/app/AcApDocument.d.ts +81 -0
- package/lib/app/AcApDocument.d.ts.map +1 -1
- package/lib/app/AcApDocument.js +154 -0
- package/lib/app/AcApDocument.js.map +1 -1
- package/lib/app/AcApLayerSessionState.d.ts +15 -0
- package/lib/app/AcApLayerSessionState.d.ts.map +1 -0
- package/lib/app/AcApLayerSessionState.js +2 -0
- package/lib/app/AcApLayerSessionState.js.map +1 -0
- package/lib/app/AcApOpenFileDialog.d.ts +35 -0
- package/lib/app/AcApOpenFileDialog.d.ts.map +1 -0
- package/lib/app/AcApOpenFileDialog.js +192 -0
- package/lib/app/AcApOpenFileDialog.js.map +1 -0
- package/lib/app/AcApWebworkerReadiness.d.ts +18 -0
- package/lib/app/AcApWebworkerReadiness.d.ts.map +1 -0
- package/lib/app/AcApWebworkerReadiness.js +126 -0
- package/lib/app/AcApWebworkerReadiness.js.map +1 -0
- package/lib/app/index.d.ts +3 -0
- package/lib/app/index.d.ts.map +1 -1
- package/lib/app/index.js +2 -0
- package/lib/app/index.js.map +1 -1
- package/lib/command/AcApOpenCmd.d.ts +3 -22
- package/lib/command/AcApOpenCmd.d.ts.map +1 -1
- package/lib/command/AcApOpenCmd.js +3 -22
- package/lib/command/AcApOpenCmd.js.map +1 -1
- package/lib/command/AcApRedoCmd.d.ts +10 -0
- package/lib/command/AcApRedoCmd.d.ts.map +1 -0
- package/lib/command/AcApRedoCmd.js +85 -0
- package/lib/command/AcApRedoCmd.js.map +1 -0
- package/lib/command/AcApUndoCmd.d.ts +10 -0
- package/lib/command/AcApUndoCmd.d.ts.map +1 -0
- package/lib/command/AcApUndoCmd.js +85 -0
- package/lib/command/AcApUndoCmd.js.map +1 -0
- package/lib/command/draw/AcApEllipseCmd.d.ts.map +1 -1
- package/lib/command/draw/AcApEllipseCmd.js +12 -4
- package/lib/command/draw/AcApEllipseCmd.js.map +1 -1
- package/lib/command/draw/AcApLineCmd.d.ts.map +1 -1
- package/lib/command/draw/AcApLineCmd.js +8 -2
- package/lib/command/draw/AcApLineCmd.js.map +1 -1
- package/lib/command/draw/AcApMLineCmd.d.ts.map +1 -1
- package/lib/command/draw/AcApMLineCmd.js +2 -0
- package/lib/command/draw/AcApMLineCmd.js.map +1 -1
- package/lib/command/draw/AcApPolylineCmd.d.ts.map +1 -1
- package/lib/command/draw/AcApPolylineCmd.js +3 -0
- package/lib/command/draw/AcApPolylineCmd.js.map +1 -1
- package/lib/command/draw/AcApSplineCmd.d.ts.map +1 -1
- package/lib/command/draw/AcApSplineCmd.js +2 -0
- package/lib/command/draw/AcApSplineCmd.js.map +1 -1
- package/lib/command/index.d.ts +2 -0
- package/lib/command/index.d.ts.map +1 -1
- package/lib/command/index.js +2 -0
- package/lib/command/index.js.map +1 -1
- package/lib/command/layer/AcApLayerCmd.d.ts +3 -187
- package/lib/command/layer/AcApLayerCmd.d.ts.map +1 -1
- package/lib/command/layer/AcApLayerCmd.js +52 -376
- package/lib/command/layer/AcApLayerCmd.js.map +1 -1
- package/lib/command/layer/AcApLayerCurCmd.d.ts +2 -27
- package/lib/command/layer/AcApLayerCurCmd.d.ts.map +1 -1
- package/lib/command/layer/AcApLayerCurCmd.js +18 -67
- package/lib/command/layer/AcApLayerCurCmd.js.map +1 -1
- package/lib/command/layer/AcApLayerDelCmd.d.ts +2 -25
- package/lib/command/layer/AcApLayerDelCmd.d.ts.map +1 -1
- package/lib/command/layer/AcApLayerDelCmd.js +22 -155
- package/lib/command/layer/AcApLayerDelCmd.js.map +1 -1
- package/lib/command/layer/AcApLayerFreezeCmd.d.ts +2 -9
- package/lib/command/layer/AcApLayerFreezeCmd.d.ts.map +1 -1
- package/lib/command/layer/AcApLayerFreezeCmd.js +27 -39
- package/lib/command/layer/AcApLayerFreezeCmd.js.map +1 -1
- package/lib/command/layer/AcApLayerIsoCmd.d.ts +2 -24
- package/lib/command/layer/AcApLayerIsoCmd.d.ts.map +1 -1
- package/lib/command/layer/AcApLayerIsoCmd.js +14 -183
- package/lib/command/layer/AcApLayerIsoCmd.js.map +1 -1
- package/lib/command/layer/AcApLayerLockCmd.d.ts +2 -33
- package/lib/command/layer/AcApLayerLockCmd.d.ts.map +1 -1
- package/lib/command/layer/AcApLayerLockCmd.js +18 -55
- package/lib/command/layer/AcApLayerLockCmd.js.map +1 -1
- package/lib/command/layer/AcApLayerMutationCmd.d.ts +13 -0
- package/lib/command/layer/AcApLayerMutationCmd.d.ts.map +1 -0
- package/lib/command/layer/AcApLayerMutationCmd.js +42 -0
- package/lib/command/layer/AcApLayerMutationCmd.js.map +1 -0
- package/lib/command/layer/AcApLayerOffCmd.d.ts +2 -2
- package/lib/command/layer/AcApLayerOffCmd.d.ts.map +1 -1
- package/lib/command/layer/AcApLayerOffCmd.js +27 -28
- package/lib/command/layer/AcApLayerOffCmd.js.map +1 -1
- package/lib/command/layer/AcApLayerOnCmd.d.ts +2 -15
- package/lib/command/layer/AcApLayerOnCmd.d.ts.map +1 -1
- package/lib/command/layer/AcApLayerOnCmd.js +6 -49
- package/lib/command/layer/AcApLayerOnCmd.js.map +1 -1
- package/lib/command/layer/AcApLayerPCmd.d.ts +2 -68
- package/lib/command/layer/AcApLayerPCmd.d.ts.map +1 -1
- package/lib/command/layer/AcApLayerPCmd.js +4 -152
- package/lib/command/layer/AcApLayerPCmd.js.map +1 -1
- package/lib/command/layer/AcApLayerThawCmd.d.ts +2 -22
- package/lib/command/layer/AcApLayerThawCmd.d.ts.map +1 -1
- package/lib/command/layer/AcApLayerThawCmd.js +6 -61
- package/lib/command/layer/AcApLayerThawCmd.js.map +1 -1
- package/lib/command/layer/AcApLayerUnisoCmd.d.ts +2 -37
- package/lib/command/layer/AcApLayerUnisoCmd.d.ts.map +1 -1
- package/lib/command/layer/AcApLayerUnisoCmd.js +7 -108
- package/lib/command/layer/AcApLayerUnisoCmd.js.map +1 -1
- package/lib/command/layer/AcApLayerUnlockCmd.d.ts +2 -33
- package/lib/command/layer/AcApLayerUnlockCmd.d.ts.map +1 -1
- package/lib/command/layer/AcApLayerUnlockCmd.js +18 -55
- package/lib/command/layer/AcApLayerUnlockCmd.js.map +1 -1
- package/lib/command/modify/AcApCopyCmd.d.ts +12 -0
- package/lib/command/modify/AcApCopyCmd.d.ts.map +1 -1
- package/lib/command/modify/AcApCopyCmd.js +67 -177
- package/lib/command/modify/AcApCopyCmd.js.map +1 -1
- package/lib/command/modify/AcApCopyPreviewJig.d.ts +21 -0
- package/lib/command/modify/AcApCopyPreviewJig.d.ts.map +1 -0
- package/lib/command/modify/AcApCopyPreviewJig.js +61 -0
- package/lib/command/modify/AcApCopyPreviewJig.js.map +1 -0
- package/lib/command/modify/AcApEraseCmd.d.ts +0 -6
- package/lib/command/modify/AcApEraseCmd.d.ts.map +1 -1
- package/lib/command/modify/AcApEraseCmd.js +11 -38
- package/lib/command/modify/AcApEraseCmd.js.map +1 -1
- package/lib/command/modify/AcApHideObjectsCmd.d.ts +0 -7
- package/lib/command/modify/AcApHideObjectsCmd.d.ts.map +1 -1
- package/lib/command/modify/AcApHideObjectsCmd.js +0 -7
- package/lib/command/modify/AcApHideObjectsCmd.js.map +1 -1
- package/lib/command/modify/AcApMoveCmd.d.ts +0 -6
- package/lib/command/modify/AcApMoveCmd.d.ts.map +1 -1
- package/lib/command/modify/AcApMoveCmd.js +26 -105
- package/lib/command/modify/AcApMoveCmd.js.map +1 -1
- package/lib/command/modify/AcApMovePreviewJig.d.ts +18 -0
- package/lib/command/modify/AcApMovePreviewJig.d.ts.map +1 -0
- package/lib/command/modify/AcApMovePreviewJig.js +45 -0
- package/lib/command/modify/AcApMovePreviewJig.js.map +1 -0
- package/lib/command/modify/AcApOffsetCmd.d.ts.map +1 -1
- package/lib/command/modify/AcApOffsetCmd.js +5 -33
- package/lib/command/modify/AcApOffsetCmd.js.map +1 -1
- package/lib/command/modify/AcApRotateCmd.d.ts +2 -2
- package/lib/command/modify/AcApRotateCmd.d.ts.map +1 -1
- package/lib/command/modify/AcApRotateCmd.js +37 -200
- package/lib/command/modify/AcApRotateCmd.js.map +1 -1
- package/lib/command/modify/AcApRotatePreviewJig.d.ts +47 -0
- package/lib/command/modify/AcApRotatePreviewJig.d.ts.map +1 -0
- package/lib/command/modify/AcApRotatePreviewJig.js +97 -0
- package/lib/command/modify/AcApRotatePreviewJig.js.map +1 -0
- package/lib/editor/command/AcEdCommand.d.ts +8 -0
- package/lib/editor/command/AcEdCommand.d.ts.map +1 -1
- package/lib/editor/command/AcEdCommand.js +48 -5
- package/lib/editor/command/AcEdCommand.js.map +1 -1
- package/lib/editor/global/eventBus.d.ts +10 -2
- package/lib/editor/global/eventBus.d.ts.map +1 -1
- package/lib/editor/global/eventBus.js.map +1 -1
- package/lib/editor/grip/AcEdGripAppearance.d.ts +18 -0
- package/lib/editor/grip/AcEdGripAppearance.d.ts.map +1 -0
- package/lib/editor/grip/AcEdGripAppearance.js +30 -0
- package/lib/editor/grip/AcEdGripAppearance.js.map +1 -0
- package/lib/editor/grip/AcEdGripEditSession.d.ts.map +1 -1
- package/lib/editor/grip/AcEdGripEditSession.js +9 -2
- package/lib/editor/grip/AcEdGripEditSession.js.map +1 -1
- package/lib/editor/grip/AcEdGripHandle.d.ts +3 -2
- package/lib/editor/grip/AcEdGripHandle.d.ts.map +1 -1
- package/lib/editor/grip/AcEdGripHandle.js +9 -6
- package/lib/editor/grip/AcEdGripHandle.js.map +1 -1
- package/lib/editor/grip/AcEdGripManager.d.ts +13 -1
- package/lib/editor/grip/AcEdGripManager.d.ts.map +1 -1
- package/lib/editor/grip/AcEdGripManager.js +54 -14
- package/lib/editor/grip/AcEdGripManager.js.map +1 -1
- package/lib/editor/input/AcEdBatchPreview.d.ts +96 -0
- package/lib/editor/input/AcEdBatchPreview.d.ts.map +1 -0
- package/lib/editor/input/AcEdBatchPreview.js +125 -0
- package/lib/editor/input/AcEdBatchPreview.js.map +1 -0
- package/lib/editor/input/AcEdPreviewJig.d.ts +1 -1
- package/lib/editor/input/AcEdPreviewJig.d.ts.map +1 -1
- package/lib/editor/input/AcEdPreviewJig.js +14 -0
- package/lib/editor/input/AcEdPreviewJig.js.map +1 -1
- package/lib/editor/input/AcEdSelectionPreviewJig.d.ts +109 -0
- package/lib/editor/input/AcEdSelectionPreviewJig.d.ts.map +1 -0
- package/lib/editor/input/AcEdSelectionPreviewJig.js +185 -0
- package/lib/editor/input/AcEdSelectionPreviewJig.js.map +1 -0
- package/lib/editor/input/index.d.ts +2 -0
- package/lib/editor/input/index.d.ts.map +1 -1
- package/lib/editor/input/index.js +2 -0
- package/lib/editor/input/index.js.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptAngleOptions.d.ts +7 -0
- package/lib/editor/input/prompt/AcEdPromptAngleOptions.d.ts.map +1 -1
- package/lib/editor/input/prompt/AcEdPromptAngleOptions.js +17 -0
- package/lib/editor/input/prompt/AcEdPromptAngleOptions.js.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInputBox.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInputBox.js +10 -2
- package/lib/editor/input/ui/AcEdFloatingInputBox.js.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInputBoxes.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInputBoxes.js +9 -4
- package/lib/editor/input/ui/AcEdFloatingInputBoxes.js.map +1 -1
- package/lib/editor/view/AcEdBaseView.d.ts +37 -2
- package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
- package/lib/editor/view/AcEdBaseView.js +14 -12
- package/lib/editor/view/AcEdBaseView.js.map +1 -1
- package/lib/editor/view/AcEdSpatialQueryResult.d.ts +28 -0
- package/lib/editor/view/AcEdSpatialQueryResult.d.ts.map +1 -1
- package/lib/editor/view/AcEdSpatialQueryResult.js +65 -1
- package/lib/editor/view/AcEdSpatialQueryResult.js.map +1 -1
- package/lib/i18n/AcApI18n.d.ts +42 -0
- package/lib/i18n/AcApI18n.d.ts.map +1 -1
- package/lib/i18n/AcApI18n.js +56 -4
- package/lib/i18n/AcApI18n.js.map +1 -1
- package/lib/i18n/en/command.d.ts +23 -0
- package/lib/i18n/en/command.d.ts.map +1 -1
- package/lib/i18n/en/command.js +23 -0
- package/lib/i18n/en/command.js.map +1 -1
- package/lib/i18n/zh/command.d.ts +23 -0
- package/lib/i18n/zh/command.d.ts.map +1 -1
- package/lib/i18n/zh/command.js +23 -0
- package/lib/i18n/zh/command.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/service/AcApEntitySelection.d.ts +42 -0
- package/lib/service/AcApEntitySelection.d.ts.map +1 -0
- package/lib/service/AcApEntitySelection.js +156 -0
- package/lib/service/AcApEntitySelection.js.map +1 -0
- package/lib/service/AcApEntityService.d.ts +115 -0
- package/lib/service/AcApEntityService.d.ts.map +1 -0
- package/lib/service/AcApEntityService.js +194 -0
- package/lib/service/AcApEntityService.js.map +1 -0
- package/lib/{command/layer → service}/AcApLayerIsoState.d.ts +6 -24
- package/lib/service/AcApLayerIsoState.d.ts.map +1 -0
- package/lib/service/AcApLayerIsoState.js +28 -0
- package/lib/service/AcApLayerIsoState.js.map +1 -0
- package/lib/service/AcApLayerService.d.ts +400 -0
- package/lib/service/AcApLayerService.d.ts.map +1 -0
- package/lib/service/AcApLayerService.js +1240 -0
- package/lib/service/AcApLayerService.js.map +1 -0
- package/lib/service/AcApLayerStore.d.ts +198 -0
- package/lib/service/AcApLayerStore.d.ts.map +1 -0
- package/lib/service/AcApLayerStore.js +335 -0
- package/lib/service/AcApLayerStore.js.map +1 -0
- package/lib/service/AcApServiceEdit.d.ts +18 -0
- package/lib/service/AcApServiceEdit.d.ts.map +1 -0
- package/lib/service/AcApServiceEdit.js +34 -0
- package/lib/service/AcApServiceEdit.js.map +1 -0
- package/lib/service/index.d.ts +16 -0
- package/lib/service/index.d.ts.map +1 -0
- package/lib/service/index.js +16 -0
- package/lib/service/index.js.map +1 -0
- package/lib/service/types.d.ts +116 -0
- package/lib/service/types.d.ts.map +1 -0
- package/lib/service/types.js +5 -0
- package/lib/service/types.js.map +1 -0
- package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.d.ts +21 -6
- package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.d.ts.map +1 -1
- package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.js +56 -10
- package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.js.map +1 -1
- package/lib/spatialIndex/AcTrLinearSpatialIndex.d.ts +2 -2
- package/lib/spatialIndex/AcTrLinearSpatialIndex.d.ts.map +1 -1
- package/lib/spatialIndex/AcTrLinearSpatialIndex.js +9 -3
- package/lib/spatialIndex/AcTrLinearSpatialIndex.js.map +1 -1
- package/lib/spatialIndex/AcTrRBushSpatialIndex.d.ts +2 -2
- package/lib/spatialIndex/AcTrRBushSpatialIndex.d.ts.map +1 -1
- package/lib/spatialIndex/AcTrRBushSpatialIndex.js +19 -5
- package/lib/spatialIndex/AcTrRBushSpatialIndex.js.map +1 -1
- package/lib/spatialIndex/AcTrSpatialIndex.d.ts +10 -1
- package/lib/spatialIndex/AcTrSpatialIndex.d.ts.map +1 -1
- package/lib/spatialIndex/AcTrSpatialIndex.js +7 -1
- package/lib/spatialIndex/AcTrSpatialIndex.js.map +1 -1
- package/lib/util/AcApDatabaseEdit.d.ts +11 -0
- package/lib/util/AcApDatabaseEdit.d.ts.map +1 -0
- package/lib/util/AcApDatabaseEdit.js +20 -0
- package/lib/util/AcApDatabaseEdit.js.map +1 -0
- package/lib/util/AcApGeTransform.d.ts +10 -0
- package/lib/util/AcApGeTransform.d.ts.map +1 -0
- package/lib/util/AcApGeTransform.js +15 -0
- package/lib/util/AcApGeTransform.js.map +1 -0
- 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/AcEdViewKeyHandler.d.ts +32 -0
- package/lib/view/AcEdViewKeyHandler.d.ts.map +1 -0
- package/lib/view/AcEdViewKeyHandler.js +101 -0
- package/lib/view/AcEdViewKeyHandler.js.map +1 -0
- package/lib/view/AcTrGroupWcsBboxAssert.d.ts +16 -0
- package/lib/view/AcTrGroupWcsBboxAssert.d.ts.map +1 -1
- package/lib/view/AcTrGroupWcsBboxAssert.js +19 -0
- package/lib/view/AcTrGroupWcsBboxAssert.js.map +1 -1
- package/lib/view/AcTrInheritedLayerMaterialMapper.d.ts +49 -0
- package/lib/view/AcTrInheritedLayerMaterialMapper.d.ts.map +1 -0
- package/lib/view/AcTrInheritedLayerMaterialMapper.js +138 -0
- package/lib/view/AcTrInheritedLayerMaterialMapper.js.map +1 -0
- package/lib/view/AcTrLayer.d.ts +26 -2
- package/lib/view/AcTrLayer.d.ts.map +1 -1
- package/lib/view/AcTrLayer.js +64 -0
- package/lib/view/AcTrLayer.js.map +1 -1
- package/lib/view/AcTrLayerAppearanceController.d.ts +55 -0
- package/lib/view/AcTrLayerAppearanceController.d.ts.map +1 -0
- package/lib/view/AcTrLayerAppearanceController.js +86 -0
- package/lib/view/AcTrLayerAppearanceController.js.map +1 -0
- package/lib/view/AcTrLayout.d.ts +36 -1
- package/lib/view/AcTrLayout.d.ts.map +1 -1
- package/lib/view/AcTrLayout.js +160 -14
- package/lib/view/AcTrLayout.js.map +1 -1
- package/lib/view/AcTrScene.d.ts +47 -1
- package/lib/view/AcTrScene.d.ts.map +1 -1
- package/lib/view/AcTrScene.js +78 -3
- package/lib/view/AcTrScene.js.map +1 -1
- package/lib/view/AcTrView2d.d.ts +50 -53
- package/lib/view/AcTrView2d.d.ts.map +1 -1
- package/lib/view/AcTrView2d.js +195 -312
- package/lib/view/AcTrView2d.js.map +1 -1
- package/lib/view/index.d.ts +3 -0
- package/lib/view/index.d.ts.map +1 -1
- package/lib/view/index.js +3 -0
- package/lib/view/index.js.map +1 -1
- package/package.json +7 -7
- package/lib/command/layer/AcApLayerIsoState.d.ts.map +0 -1
- package/lib/command/layer/AcApLayerIsoState.js +0 -53
- package/lib/command/layer/AcApLayerIsoState.js.map +0 -1
|
@@ -0,0 +1,1240 @@
|
|
|
1
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
+
if (!m) return o;
|
|
4
|
+
var i = m.call(o), r, ar = [], e;
|
|
5
|
+
try {
|
|
6
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
+
}
|
|
8
|
+
catch (error) { e = { error: error }; }
|
|
9
|
+
finally {
|
|
10
|
+
try {
|
|
11
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
+
}
|
|
13
|
+
finally { if (e) throw e.error; }
|
|
14
|
+
}
|
|
15
|
+
return ar;
|
|
16
|
+
};
|
|
17
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
18
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
19
|
+
if (ar || !(i in from)) {
|
|
20
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21
|
+
ar[i] = from[i];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
|
+
};
|
|
26
|
+
var __values = (this && this.__values) || function(o) {
|
|
27
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
28
|
+
if (m) return m.call(o);
|
|
29
|
+
if (o && typeof o.length === "number") return {
|
|
30
|
+
next: function () {
|
|
31
|
+
if (o && i >= o.length) o = void 0;
|
|
32
|
+
return { value: o && o[i++], done: !o };
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
36
|
+
};
|
|
37
|
+
import { AcCmColor, AcCmColorMethod, AcDbLayerTableRecord } from '@mlightcad/data-model';
|
|
38
|
+
import { getLayerIsoState, isSameLayerIsoState } from './AcApLayerIsoState';
|
|
39
|
+
import { acapRunServiceEdit, LAYER_EDIT_LABEL } from './AcApServiceEdit';
|
|
40
|
+
import { LAYER_FROZEN_FLAG, LAYER_LOCKED_FLAG } from './types';
|
|
41
|
+
/**
|
|
42
|
+
* Centralizes layer table mutations for commands and UI consumers.
|
|
43
|
+
*
|
|
44
|
+
* Wraps on/off, freeze/thaw, lock/unlock, color, isolation (`LAYISO`/`LAYUNISO`),
|
|
45
|
+
* deletion (`LAYDEL`), and related operations with consistent undo handling.
|
|
46
|
+
* Document-scoped session state (`LAYERP`, `LAYUNISO` snapshots) lives on
|
|
47
|
+
* {@link AcApDocument}.
|
|
48
|
+
*/
|
|
49
|
+
var AcApLayerService = /** @class */ (function () {
|
|
50
|
+
/**
|
|
51
|
+
* Creates a layer service bound to a database.
|
|
52
|
+
*
|
|
53
|
+
* @param db - Database whose layer table will be mutated.
|
|
54
|
+
*/
|
|
55
|
+
function AcApLayerService(db) {
|
|
56
|
+
this.db = db;
|
|
57
|
+
}
|
|
58
|
+
/** Opens an existing layer table record for write.
|
|
59
|
+
*
|
|
60
|
+
* @param db - Database containing the layer table.
|
|
61
|
+
* @param layerOrName - Layer record or name to open.
|
|
62
|
+
* @returns Opened layer record, or `undefined` when not found.
|
|
63
|
+
*/
|
|
64
|
+
AcApLayerService.openLayerForWrite = function (db, layerOrName) {
|
|
65
|
+
var layer = typeof layerOrName === 'string'
|
|
66
|
+
? db.tables.layerTable.getAt(layerOrName)
|
|
67
|
+
: layerOrName;
|
|
68
|
+
if (!layer)
|
|
69
|
+
return undefined;
|
|
70
|
+
return db.openObjectForWrite(layer.objectId);
|
|
71
|
+
};
|
|
72
|
+
/** Sets or clears the frozen bit on a layer record.
|
|
73
|
+
*
|
|
74
|
+
* @param layer - Layer record to modify.
|
|
75
|
+
* @param frozen - Desired frozen state.
|
|
76
|
+
*/
|
|
77
|
+
AcApLayerService.setLayerFrozenState = function (layer, frozen) {
|
|
78
|
+
var _a;
|
|
79
|
+
var flags = (_a = layer.standardFlags) !== null && _a !== void 0 ? _a : 0;
|
|
80
|
+
layer.standardFlags = frozen
|
|
81
|
+
? flags | LAYER_FROZEN_FLAG
|
|
82
|
+
: flags & ~LAYER_FROZEN_FLAG;
|
|
83
|
+
};
|
|
84
|
+
/** Sets or clears the locked bit on a layer record.
|
|
85
|
+
*
|
|
86
|
+
* @param layer - Layer record to modify.
|
|
87
|
+
* @param locked - Desired locked state.
|
|
88
|
+
*/
|
|
89
|
+
AcApLayerService.setLayerLockedState = function (layer, locked) {
|
|
90
|
+
var _a;
|
|
91
|
+
var flags = (_a = layer.standardFlags) !== null && _a !== void 0 ? _a : 0;
|
|
92
|
+
layer.standardFlags = locked
|
|
93
|
+
? flags | LAYER_LOCKED_FLAG
|
|
94
|
+
: flags & ~LAYER_LOCKED_FLAG;
|
|
95
|
+
};
|
|
96
|
+
/** Returns whether a layer is locked according to its standard flags.
|
|
97
|
+
*
|
|
98
|
+
* @param layer - Layer record to inspect.
|
|
99
|
+
* @returns `true` when the locked bit is set.
|
|
100
|
+
*/
|
|
101
|
+
AcApLayerService.isLayerLocked = function (layer) {
|
|
102
|
+
var _a;
|
|
103
|
+
return (((_a = layer.standardFlags) !== null && _a !== void 0 ? _a : 0) & LAYER_LOCKED_FLAG) !== 0;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Applies a captured `LAYERP` snapshot to a database.
|
|
107
|
+
*
|
|
108
|
+
* @param db - Database whose layer table should be updated.
|
|
109
|
+
* @param snapshot - Snapshot previously captured on the owning document.
|
|
110
|
+
* @returns `true` when the snapshot's current layer still exists.
|
|
111
|
+
*/
|
|
112
|
+
AcApLayerService.applyLayerPreviousSnapshot = function (db, snapshot) {
|
|
113
|
+
snapshot.states.forEach(function (state) {
|
|
114
|
+
var layer = AcApLayerService.openLayerForWrite(db, state.name);
|
|
115
|
+
if (!layer)
|
|
116
|
+
return;
|
|
117
|
+
layer.isOff = !state.isOn;
|
|
118
|
+
AcApLayerService.setLayerFrozenState(layer, state.isFrozen);
|
|
119
|
+
AcApLayerService.setLayerLockedState(layer, state.isLocked);
|
|
120
|
+
});
|
|
121
|
+
var currentLayer = AcApLayerService.openLayerForWrite(db, snapshot.clayer);
|
|
122
|
+
if (!currentLayer)
|
|
123
|
+
return false;
|
|
124
|
+
currentLayer.isOff = false;
|
|
125
|
+
AcApLayerService.setLayerFrozenState(currentLayer, false);
|
|
126
|
+
db.clayer = currentLayer.name;
|
|
127
|
+
return true;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Parses layer name input supporting `*` and comma-separated names.
|
|
131
|
+
*
|
|
132
|
+
* @param input - Raw user input (e.g. `A,B` or `*`).
|
|
133
|
+
* @returns Deduplicated list of layer names.
|
|
134
|
+
*/
|
|
135
|
+
AcApLayerService.prototype.parseLayerNameInput = function (input) {
|
|
136
|
+
var allNames = __spreadArray([], __read(this.db.tables.layerTable.newIterator()), false).map(function (layer) { return layer.name; });
|
|
137
|
+
var raw = input.trim();
|
|
138
|
+
if (!raw)
|
|
139
|
+
return [];
|
|
140
|
+
if (raw === '*')
|
|
141
|
+
return __spreadArray([], __read(allNames), false);
|
|
142
|
+
var names = raw
|
|
143
|
+
.split(',')
|
|
144
|
+
.map(function (v) { return v.trim(); })
|
|
145
|
+
.filter(Boolean);
|
|
146
|
+
return __spreadArray([], __read(new Set(names)), false);
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Resolves layer records by name.
|
|
150
|
+
*
|
|
151
|
+
* @param names - Layer names to look up.
|
|
152
|
+
* @returns Resolved records and names that were not found.
|
|
153
|
+
*/
|
|
154
|
+
AcApLayerService.prototype.resolveLayers = function (names) {
|
|
155
|
+
var table = this.db.tables.layerTable;
|
|
156
|
+
var layers = [];
|
|
157
|
+
var missing = [];
|
|
158
|
+
names.forEach(function (name) {
|
|
159
|
+
var layer = table.getAt(name);
|
|
160
|
+
if (layer)
|
|
161
|
+
layers.push(layer);
|
|
162
|
+
else
|
|
163
|
+
missing.push(name);
|
|
164
|
+
});
|
|
165
|
+
return { layers: layers, missing: missing };
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Returns summary rows for all layers.
|
|
169
|
+
*
|
|
170
|
+
* @returns Display-oriented summary for each layer in the table.
|
|
171
|
+
*/
|
|
172
|
+
AcApLayerService.prototype.getLayerSummaries = function () {
|
|
173
|
+
var _this = this;
|
|
174
|
+
return __spreadArray([], __read(this.db.tables.layerTable.newIterator()), false).map(function (layer) { return ({
|
|
175
|
+
name: layer.name,
|
|
176
|
+
current: _this.db.clayer === layer.name ? '*' : '',
|
|
177
|
+
on: layer.isOff ? 'No' : 'Yes',
|
|
178
|
+
frozen: layer.isFrozen ? 'Yes' : 'No',
|
|
179
|
+
locked: AcApLayerService.isLayerLocked(layer) ? 'Yes' : 'No',
|
|
180
|
+
color: layer.color.toString()
|
|
181
|
+
}); });
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Creates missing layers.
|
|
185
|
+
*
|
|
186
|
+
* @param names - Layer names to create.
|
|
187
|
+
* @returns Count of created layers and names that already existed.
|
|
188
|
+
*/
|
|
189
|
+
AcApLayerService.prototype.createLayers = function (names) {
|
|
190
|
+
var _this = this;
|
|
191
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
192
|
+
var table = _this.db.tables.layerTable;
|
|
193
|
+
var created = 0;
|
|
194
|
+
var existed = [];
|
|
195
|
+
names.forEach(function (name) {
|
|
196
|
+
if (table.has(name)) {
|
|
197
|
+
existed.push(name);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
table.add(new AcDbLayerTableRecord({
|
|
201
|
+
name: name,
|
|
202
|
+
isOff: false,
|
|
203
|
+
isPlottable: true,
|
|
204
|
+
color: new AcCmColor(AcCmColorMethod.ByACI, 7),
|
|
205
|
+
linetype: 'Continuous'
|
|
206
|
+
}));
|
|
207
|
+
created++;
|
|
208
|
+
});
|
|
209
|
+
return { created: created, existed: existed };
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Sets current layer (`CLAYER`), ensuring it is on and thawed.
|
|
214
|
+
*
|
|
215
|
+
* @param name - Layer name to make current.
|
|
216
|
+
* @returns `true` when the layer exists and was set current.
|
|
217
|
+
*/
|
|
218
|
+
AcApLayerService.prototype.setCurrentLayer = function (name) {
|
|
219
|
+
var _this = this;
|
|
220
|
+
var layer = this.db.tables.layerTable.getAt(name);
|
|
221
|
+
if (!layer)
|
|
222
|
+
return false;
|
|
223
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
224
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
225
|
+
if (!opened)
|
|
226
|
+
return false;
|
|
227
|
+
opened.isOff = false;
|
|
228
|
+
AcApLayerService.setLayerFrozenState(opened, false);
|
|
229
|
+
_this.db.clayer = opened.name;
|
|
230
|
+
return true;
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Creates a layer if missing, then makes it current.
|
|
235
|
+
*
|
|
236
|
+
* @param name - Layer name to create or activate.
|
|
237
|
+
* @returns `true` when the layer is current after the operation.
|
|
238
|
+
*/
|
|
239
|
+
AcApLayerService.prototype.makeLayer = function (name) {
|
|
240
|
+
var _this = this;
|
|
241
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
242
|
+
var table = _this.db.tables.layerTable;
|
|
243
|
+
var layer = table.getAt(name);
|
|
244
|
+
if (!layer) {
|
|
245
|
+
layer = new AcDbLayerTableRecord({
|
|
246
|
+
name: name,
|
|
247
|
+
isOff: false,
|
|
248
|
+
isPlottable: true,
|
|
249
|
+
color: new AcCmColor(AcCmColorMethod.ByACI, 7),
|
|
250
|
+
linetype: 'Continuous'
|
|
251
|
+
});
|
|
252
|
+
table.add(layer);
|
|
253
|
+
}
|
|
254
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
255
|
+
if (!opened)
|
|
256
|
+
return false;
|
|
257
|
+
opened.isOff = false;
|
|
258
|
+
AcApLayerService.setLayerFrozenState(opened, false);
|
|
259
|
+
_this.db.clayer = opened.name;
|
|
260
|
+
return true;
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* Turns a single layer on or off.
|
|
265
|
+
*
|
|
266
|
+
* When turning off the current layer, pass `{ switchCurrentLayer: true }`
|
|
267
|
+
* (as {@link AcApLayerStore} does) to move `CLAYER` first. CLI commands leave
|
|
268
|
+
* the default `false` and rely on batch helpers to skip the current layer.
|
|
269
|
+
*
|
|
270
|
+
* @param layerName - Target layer name.
|
|
271
|
+
* @param isOn - Desired visibility (`true` = on).
|
|
272
|
+
* @param options - Optional behavior when turning off the current layer.
|
|
273
|
+
* @returns `true` when the layer exists and was updated.
|
|
274
|
+
*/
|
|
275
|
+
AcApLayerService.prototype.setLayerOn = function (layerName, isOn, options) {
|
|
276
|
+
var _this = this;
|
|
277
|
+
var _a;
|
|
278
|
+
if (options === void 0) { options = {}; }
|
|
279
|
+
if (!layerName || !this.db.tables.layerTable.getAt(layerName)) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
var switchCurrentLayer = (_a = options.switchCurrentLayer) !== null && _a !== void 0 ? _a : false;
|
|
283
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
284
|
+
if (!isOn &&
|
|
285
|
+
switchCurrentLayer &&
|
|
286
|
+
!_this.switchCurrentLayerIfNeeded(layerName)) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
var layer = AcApLayerService.openLayerForWrite(_this.db, layerName);
|
|
290
|
+
if (!layer)
|
|
291
|
+
return false;
|
|
292
|
+
layer.isOff = !isOn;
|
|
293
|
+
return true;
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* Freezes or thaws a single layer.
|
|
298
|
+
*
|
|
299
|
+
* UI callers should pass `{ switchCurrentLayer: true }` when freezing the
|
|
300
|
+
* current layer so drawing continues on a visible, thawed layer.
|
|
301
|
+
*
|
|
302
|
+
* @param layerName - Target layer name.
|
|
303
|
+
* @param frozen - Desired frozen state.
|
|
304
|
+
* @param options - Optional behavior when freezing the current layer.
|
|
305
|
+
* @returns `true` when the layer exists and was updated.
|
|
306
|
+
*/
|
|
307
|
+
AcApLayerService.prototype.setLayerFrozen = function (layerName, frozen, options) {
|
|
308
|
+
var _this = this;
|
|
309
|
+
var _a;
|
|
310
|
+
if (options === void 0) { options = {}; }
|
|
311
|
+
if (!layerName || !this.db.tables.layerTable.getAt(layerName)) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
var switchCurrentLayer = (_a = options.switchCurrentLayer) !== null && _a !== void 0 ? _a : false;
|
|
315
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
316
|
+
if (frozen &&
|
|
317
|
+
switchCurrentLayer &&
|
|
318
|
+
!_this.switchCurrentLayerIfNeeded(layerName)) {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
var layer = AcApLayerService.openLayerForWrite(_this.db, layerName);
|
|
322
|
+
if (!layer)
|
|
323
|
+
return false;
|
|
324
|
+
AcApLayerService.setLayerFrozenState(layer, frozen);
|
|
325
|
+
return true;
|
|
326
|
+
});
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* Locks or unlocks a single layer.
|
|
330
|
+
*
|
|
331
|
+
* @param layerName - Target layer name.
|
|
332
|
+
* @param locked - Desired locked state.
|
|
333
|
+
* @returns `true` when the layer exists and was updated.
|
|
334
|
+
*/
|
|
335
|
+
AcApLayerService.prototype.setLayerLocked = function (layerName, locked) {
|
|
336
|
+
var _this = this;
|
|
337
|
+
if (!layerName || !this.db.tables.layerTable.getAt(layerName)) {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
341
|
+
var layer = AcApLayerService.openLayerForWrite(_this.db, layerName);
|
|
342
|
+
if (!layer)
|
|
343
|
+
return false;
|
|
344
|
+
AcApLayerService.setLayerLockedState(layer, locked);
|
|
345
|
+
return true;
|
|
346
|
+
});
|
|
347
|
+
};
|
|
348
|
+
/**
|
|
349
|
+
* Assigns line weight to a single layer.
|
|
350
|
+
*
|
|
351
|
+
* @param layerName - Target layer name.
|
|
352
|
+
* @param lineWeight - Line weight value to assign.
|
|
353
|
+
* @returns `true` when the layer exists and line weight was set.
|
|
354
|
+
*/
|
|
355
|
+
AcApLayerService.prototype.setLayerLineWeight = function (layerName, lineWeight) {
|
|
356
|
+
var _this = this;
|
|
357
|
+
if (!this.db.tables.layerTable.getAt(layerName))
|
|
358
|
+
return false;
|
|
359
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
360
|
+
var layer = AcApLayerService.openLayerForWrite(_this.db, layerName);
|
|
361
|
+
if (!layer)
|
|
362
|
+
return false;
|
|
363
|
+
layer.lineWeight = lineWeight;
|
|
364
|
+
return true;
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
/**
|
|
368
|
+
* Keeps one layer visible and turns all others off (UI quick-isolate).
|
|
369
|
+
*
|
|
370
|
+
* Does not capture a `LAYUNISO` snapshot; use {@link isolateLayers} for
|
|
371
|
+
* command semantics.
|
|
372
|
+
*
|
|
373
|
+
* @param layerName - Layer to keep visible.
|
|
374
|
+
* @returns `true` when the layer exists and isolation was applied.
|
|
375
|
+
*/
|
|
376
|
+
AcApLayerService.prototype.isolateSingleLayer = function (layerName) {
|
|
377
|
+
var _this = this;
|
|
378
|
+
if (!this.db.tables.layerTable.getAt(layerName))
|
|
379
|
+
return false;
|
|
380
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
381
|
+
var e_1, _a;
|
|
382
|
+
try {
|
|
383
|
+
for (var _b = __values(_this.db.tables.layerTable.newIterator()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
384
|
+
var layer = _c.value;
|
|
385
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
386
|
+
if (!opened)
|
|
387
|
+
continue;
|
|
388
|
+
var keepVisible = opened.name === layerName;
|
|
389
|
+
opened.isOff = !keepVisible;
|
|
390
|
+
if (keepVisible) {
|
|
391
|
+
AcApLayerService.setLayerFrozenState(opened, false);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
396
|
+
finally {
|
|
397
|
+
try {
|
|
398
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
399
|
+
}
|
|
400
|
+
finally { if (e_1) throw e_1.error; }
|
|
401
|
+
}
|
|
402
|
+
_this.db.clayer = layerName;
|
|
403
|
+
return true;
|
|
404
|
+
});
|
|
405
|
+
};
|
|
406
|
+
/**
|
|
407
|
+
* Batch toggles layer visibility.
|
|
408
|
+
*
|
|
409
|
+
* @param names - Layer names to update.
|
|
410
|
+
* @param off - `true` to turn layers off, `false` to turn them on.
|
|
411
|
+
* @param options - Optional skip rules for the current layer.
|
|
412
|
+
* @returns Names of current layers skipped when turning off.
|
|
413
|
+
*/
|
|
414
|
+
AcApLayerService.prototype.setLayersVisibility = function (names, off, options) {
|
|
415
|
+
var _this = this;
|
|
416
|
+
var _a;
|
|
417
|
+
if (options === void 0) { options = {}; }
|
|
418
|
+
var skipCurrentLayer = (_a = options.skipCurrentLayer) !== null && _a !== void 0 ? _a : true;
|
|
419
|
+
var layers = this.resolveLayers(names).layers;
|
|
420
|
+
var skippedCurrent = [];
|
|
421
|
+
acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
422
|
+
layers.forEach(function (layer) {
|
|
423
|
+
if (off && skipCurrentLayer && layer.name === _this.db.clayer) {
|
|
424
|
+
skippedCurrent.push(layer.name);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
428
|
+
if (!opened)
|
|
429
|
+
return;
|
|
430
|
+
opened.isOff = off;
|
|
431
|
+
});
|
|
432
|
+
});
|
|
433
|
+
return { skippedCurrent: skippedCurrent };
|
|
434
|
+
};
|
|
435
|
+
/**
|
|
436
|
+
* Turns on every layer in the table.
|
|
437
|
+
*
|
|
438
|
+
* @returns Number of layers changed from off to on.
|
|
439
|
+
*/
|
|
440
|
+
AcApLayerService.prototype.setAllLayersOn = function () {
|
|
441
|
+
var _this = this;
|
|
442
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
443
|
+
var e_2, _a;
|
|
444
|
+
var turnedOn = 0;
|
|
445
|
+
try {
|
|
446
|
+
for (var _b = __values(_this.db.tables.layerTable.newIterator()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
447
|
+
var layer = _c.value;
|
|
448
|
+
if (!layer.isOff)
|
|
449
|
+
continue;
|
|
450
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
451
|
+
if (!opened)
|
|
452
|
+
continue;
|
|
453
|
+
opened.isOff = false;
|
|
454
|
+
turnedOn++;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
458
|
+
finally {
|
|
459
|
+
try {
|
|
460
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
461
|
+
}
|
|
462
|
+
finally { if (e_2) throw e_2.error; }
|
|
463
|
+
}
|
|
464
|
+
return turnedOn;
|
|
465
|
+
});
|
|
466
|
+
};
|
|
467
|
+
/**
|
|
468
|
+
* Turns off every layer except the current layer.
|
|
469
|
+
*
|
|
470
|
+
* @returns Number of layers turned off.
|
|
471
|
+
*/
|
|
472
|
+
AcApLayerService.prototype.setAllLayersOffExceptCurrent = function () {
|
|
473
|
+
var _this = this;
|
|
474
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
475
|
+
var e_3, _a;
|
|
476
|
+
var currentLayer = _this.db.clayer;
|
|
477
|
+
var changed = 0;
|
|
478
|
+
try {
|
|
479
|
+
for (var _b = __values(_this.db.tables.layerTable.newIterator()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
480
|
+
var layer = _c.value;
|
|
481
|
+
if (layer.name === currentLayer || layer.isOff)
|
|
482
|
+
continue;
|
|
483
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
484
|
+
if (!opened)
|
|
485
|
+
continue;
|
|
486
|
+
opened.isOff = true;
|
|
487
|
+
changed++;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
491
|
+
finally {
|
|
492
|
+
try {
|
|
493
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
494
|
+
}
|
|
495
|
+
finally { if (e_3) throw e_3.error; }
|
|
496
|
+
}
|
|
497
|
+
return changed;
|
|
498
|
+
});
|
|
499
|
+
};
|
|
500
|
+
/**
|
|
501
|
+
* Batch toggles frozen state.
|
|
502
|
+
*
|
|
503
|
+
* @param names - Layer names to update.
|
|
504
|
+
* @param freeze - `true` to freeze, `false` to thaw.
|
|
505
|
+
* @param options - Optional skip rules for the current layer.
|
|
506
|
+
* @returns Names of current layers skipped when freezing.
|
|
507
|
+
*/
|
|
508
|
+
AcApLayerService.prototype.setLayersFrozen = function (names, freeze, options) {
|
|
509
|
+
var _this = this;
|
|
510
|
+
var _a;
|
|
511
|
+
if (options === void 0) { options = {}; }
|
|
512
|
+
var skipCurrentLayer = (_a = options.skipCurrentLayer) !== null && _a !== void 0 ? _a : true;
|
|
513
|
+
var layers = this.resolveLayers(names).layers;
|
|
514
|
+
var skippedCurrent = [];
|
|
515
|
+
acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
516
|
+
layers.forEach(function (layer) {
|
|
517
|
+
if (freeze && skipCurrentLayer && layer.name === _this.db.clayer) {
|
|
518
|
+
skippedCurrent.push(layer.name);
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
522
|
+
if (!opened)
|
|
523
|
+
return;
|
|
524
|
+
AcApLayerService.setLayerFrozenState(opened, freeze);
|
|
525
|
+
});
|
|
526
|
+
});
|
|
527
|
+
return { skippedCurrent: skippedCurrent };
|
|
528
|
+
};
|
|
529
|
+
/**
|
|
530
|
+
* Thaws all frozen layers in the table.
|
|
531
|
+
*
|
|
532
|
+
* @returns Number of layers thawed.
|
|
533
|
+
*/
|
|
534
|
+
AcApLayerService.prototype.thawAllLayers = function () {
|
|
535
|
+
var _this = this;
|
|
536
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
537
|
+
var e_4, _a;
|
|
538
|
+
var thawed = 0;
|
|
539
|
+
try {
|
|
540
|
+
for (var _b = __values(_this.db.tables.layerTable.newIterator()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
541
|
+
var layer = _c.value;
|
|
542
|
+
if (!layer.isFrozen)
|
|
543
|
+
continue;
|
|
544
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
545
|
+
if (!opened)
|
|
546
|
+
continue;
|
|
547
|
+
AcApLayerService.setLayerFrozenState(opened, false);
|
|
548
|
+
thawed++;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
552
|
+
finally {
|
|
553
|
+
try {
|
|
554
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
555
|
+
}
|
|
556
|
+
finally { if (e_4) throw e_4.error; }
|
|
557
|
+
}
|
|
558
|
+
return thawed;
|
|
559
|
+
});
|
|
560
|
+
};
|
|
561
|
+
/**
|
|
562
|
+
* Batch toggles lock state.
|
|
563
|
+
*
|
|
564
|
+
* @param names - Layer names to update.
|
|
565
|
+
* @param lock - `true` to lock, `false` to unlock.
|
|
566
|
+
*/
|
|
567
|
+
AcApLayerService.prototype.setLayersLocked = function (names, lock) {
|
|
568
|
+
var _this = this;
|
|
569
|
+
var layers = this.resolveLayers(names).layers;
|
|
570
|
+
acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
571
|
+
layers.forEach(function (layer) {
|
|
572
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
573
|
+
if (!opened)
|
|
574
|
+
return;
|
|
575
|
+
AcApLayerService.setLayerLockedState(opened, lock);
|
|
576
|
+
});
|
|
577
|
+
});
|
|
578
|
+
};
|
|
579
|
+
/**
|
|
580
|
+
* Parses color input for layer color assignment.
|
|
581
|
+
*
|
|
582
|
+
* Accepts ACI index (1–255) or color strings understood by {@link AcCmColor.fromString}.
|
|
583
|
+
*
|
|
584
|
+
* @param input - Raw color string from the user or UI.
|
|
585
|
+
* @returns Parsed color, or `undefined` when invalid.
|
|
586
|
+
*/
|
|
587
|
+
AcApLayerService.prototype.parseColorInput = function (input) {
|
|
588
|
+
var value = input.trim();
|
|
589
|
+
if (!value)
|
|
590
|
+
return undefined;
|
|
591
|
+
if (/^\d+$/.test(value)) {
|
|
592
|
+
var index = Number(value);
|
|
593
|
+
if (index >= 1 && index <= 255) {
|
|
594
|
+
return new AcCmColor(AcCmColorMethod.ByACI, index);
|
|
595
|
+
}
|
|
596
|
+
return undefined;
|
|
597
|
+
}
|
|
598
|
+
var color = AcCmColor.fromString(value);
|
|
599
|
+
if (!color)
|
|
600
|
+
return undefined;
|
|
601
|
+
if (color.isByACI) {
|
|
602
|
+
var index = color.colorIndex;
|
|
603
|
+
if (index == null || index < 1 || index > 255) {
|
|
604
|
+
return undefined;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
if (color.isByLayer || color.isByBlock)
|
|
608
|
+
return undefined;
|
|
609
|
+
return color;
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* Assigns color to a single layer.
|
|
613
|
+
*
|
|
614
|
+
* @param layerName - Target layer name.
|
|
615
|
+
* @param color - Color to assign.
|
|
616
|
+
* @returns `true` when the layer exists and color was set.
|
|
617
|
+
*/
|
|
618
|
+
AcApLayerService.prototype.setLayerColor = function (layerName, color) {
|
|
619
|
+
var _this = this;
|
|
620
|
+
if (!this.db.tables.layerTable.getAt(layerName))
|
|
621
|
+
return false;
|
|
622
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
623
|
+
var layer = AcApLayerService.openLayerForWrite(_this.db, layerName);
|
|
624
|
+
if (!layer)
|
|
625
|
+
return false;
|
|
626
|
+
layer.color = color.clone();
|
|
627
|
+
return true;
|
|
628
|
+
});
|
|
629
|
+
};
|
|
630
|
+
/**
|
|
631
|
+
* Assigns the same color to multiple layers.
|
|
632
|
+
*
|
|
633
|
+
* @param names - Layer names to update.
|
|
634
|
+
* @param color - Color to assign to each resolved layer.
|
|
635
|
+
*/
|
|
636
|
+
AcApLayerService.prototype.setLayersColor = function (names, color) {
|
|
637
|
+
var _this = this;
|
|
638
|
+
var layers = this.resolveLayers(names).layers;
|
|
639
|
+
acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
640
|
+
layers.forEach(function (layer) {
|
|
641
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
642
|
+
if (!opened)
|
|
643
|
+
return;
|
|
644
|
+
opened.color = color.clone();
|
|
645
|
+
});
|
|
646
|
+
});
|
|
647
|
+
};
|
|
648
|
+
/**
|
|
649
|
+
* Updates a layer description.
|
|
650
|
+
*
|
|
651
|
+
* @param name - Target layer name.
|
|
652
|
+
* @param description - New description text.
|
|
653
|
+
* @returns `true` when the layer exists and description was set.
|
|
654
|
+
*/
|
|
655
|
+
AcApLayerService.prototype.setLayerDescription = function (name, description) {
|
|
656
|
+
var _this = this;
|
|
657
|
+
var layer = this.db.tables.layerTable.getAt(name);
|
|
658
|
+
if (!layer)
|
|
659
|
+
return false;
|
|
660
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
661
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
662
|
+
if (!opened)
|
|
663
|
+
return false;
|
|
664
|
+
opened.description = description;
|
|
665
|
+
return true;
|
|
666
|
+
});
|
|
667
|
+
};
|
|
668
|
+
/**
|
|
669
|
+
* Moves `CLAYER` away from a layer before turning it off or freezing it.
|
|
670
|
+
*
|
|
671
|
+
* @param targetLayerName - Layer that will be turned off or frozen.
|
|
672
|
+
* @returns `true` when `CLAYER` is no longer the target layer, or target was not current.
|
|
673
|
+
*/
|
|
674
|
+
AcApLayerService.prototype.switchCurrentLayerIfNeeded = function (targetLayerName) {
|
|
675
|
+
var e_5, _a;
|
|
676
|
+
if (this.db.clayer !== targetLayerName)
|
|
677
|
+
return true;
|
|
678
|
+
var fallbackLayerName;
|
|
679
|
+
var preferredLayerName;
|
|
680
|
+
try {
|
|
681
|
+
for (var _b = __values(this.db.tables.layerTable.newIterator()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
682
|
+
var layer = _c.value;
|
|
683
|
+
if (layer.name === targetLayerName)
|
|
684
|
+
continue;
|
|
685
|
+
fallbackLayerName !== null && fallbackLayerName !== void 0 ? fallbackLayerName : (fallbackLayerName = layer.name);
|
|
686
|
+
if (!layer.isOff && !layer.isFrozen) {
|
|
687
|
+
preferredLayerName = layer.name;
|
|
688
|
+
break;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
693
|
+
finally {
|
|
694
|
+
try {
|
|
695
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
696
|
+
}
|
|
697
|
+
finally { if (e_5) throw e_5.error; }
|
|
698
|
+
}
|
|
699
|
+
var nextLayerName = preferredLayerName !== null && preferredLayerName !== void 0 ? preferredLayerName : fallbackLayerName;
|
|
700
|
+
if (!nextLayerName)
|
|
701
|
+
return false;
|
|
702
|
+
var nextCurrentLayer = AcApLayerService.openLayerForWrite(this.db, nextLayerName);
|
|
703
|
+
if (!nextCurrentLayer)
|
|
704
|
+
return false;
|
|
705
|
+
nextCurrentLayer.isOff = false;
|
|
706
|
+
AcApLayerService.setLayerFrozenState(nextCurrentLayer, false);
|
|
707
|
+
this.db.clayer = nextCurrentLayer.name;
|
|
708
|
+
return true;
|
|
709
|
+
};
|
|
710
|
+
/**
|
|
711
|
+
* Resolves the layer name of an entity.
|
|
712
|
+
*
|
|
713
|
+
* @param objectId - Entity object id.
|
|
714
|
+
* @returns Trimmed layer name, or `undefined` when the entity is missing.
|
|
715
|
+
*/
|
|
716
|
+
AcApLayerService.prototype.getLayerNameFromEntity = function (objectId) {
|
|
717
|
+
var _a;
|
|
718
|
+
var entity = this.db.tables.blockTable.getEntityById(objectId);
|
|
719
|
+
return ((_a = entity === null || entity === void 0 ? void 0 : entity.layer) === null || _a === void 0 ? void 0 : _a.trim()) || undefined;
|
|
720
|
+
};
|
|
721
|
+
/**
|
|
722
|
+
* Collects distinct layer names from a set of entity ids.
|
|
723
|
+
*
|
|
724
|
+
* @param objectIds - Entity ids to inspect.
|
|
725
|
+
* @returns Resolved layer names and names missing from the layer table.
|
|
726
|
+
*/
|
|
727
|
+
AcApLayerService.prototype.collectLayerNamesFromEntities = function (objectIds) {
|
|
728
|
+
var _this = this;
|
|
729
|
+
var names = new Set();
|
|
730
|
+
var missing = new Set();
|
|
731
|
+
objectIds.forEach(function (objectId) {
|
|
732
|
+
var layerName = _this.getLayerNameFromEntity(objectId);
|
|
733
|
+
if (!layerName)
|
|
734
|
+
return;
|
|
735
|
+
var layer = _this.db.tables.layerTable.getAt(layerName);
|
|
736
|
+
if (layer) {
|
|
737
|
+
names.add(layer.name);
|
|
738
|
+
}
|
|
739
|
+
else {
|
|
740
|
+
missing.add(layerName);
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
return { layerNames: __spreadArray([], __read(names), false), missingLayerNames: __spreadArray([], __read(missing), false) };
|
|
744
|
+
};
|
|
745
|
+
/**
|
|
746
|
+
* Freezes the layer of a picked entity (`LAYFRZ`).
|
|
747
|
+
*
|
|
748
|
+
* @param objectId - Selected entity id.
|
|
749
|
+
* @returns Outcome with previous frozen state for session undo, or a failure reason.
|
|
750
|
+
*/
|
|
751
|
+
AcApLayerService.prototype.freezeLayerByEntity = function (objectId) {
|
|
752
|
+
var _this = this;
|
|
753
|
+
var layerName = this.getLayerNameFromEntity(objectId);
|
|
754
|
+
if (!layerName) {
|
|
755
|
+
return { ok: false, reason: 'invalid_selection' };
|
|
756
|
+
}
|
|
757
|
+
var layer = this.db.tables.layerTable.getAt(layerName);
|
|
758
|
+
if (!layer) {
|
|
759
|
+
return { ok: false, reason: 'layer_not_found', layerName: layerName };
|
|
760
|
+
}
|
|
761
|
+
if (layer.name === this.db.clayer) {
|
|
762
|
+
return { ok: false, reason: 'cannot_change_current', layerName: layerName };
|
|
763
|
+
}
|
|
764
|
+
if (layer.isFrozen) {
|
|
765
|
+
return { ok: false, reason: 'already_frozen', layerName: layerName };
|
|
766
|
+
}
|
|
767
|
+
var wasFrozen = layer.isFrozen;
|
|
768
|
+
acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
769
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
770
|
+
if (!opened)
|
|
771
|
+
return;
|
|
772
|
+
AcApLayerService.setLayerFrozenState(opened, true);
|
|
773
|
+
});
|
|
774
|
+
return { ok: true, layerName: layerName, previousFrozen: wasFrozen };
|
|
775
|
+
};
|
|
776
|
+
/**
|
|
777
|
+
* Restores frozen state by layer name for `LAYFRZ` session undo.
|
|
778
|
+
*
|
|
779
|
+
* @param layerName - Target layer name.
|
|
780
|
+
* @param frozen - Frozen state to restore.
|
|
781
|
+
* @returns `true` when the layer exists and state was applied.
|
|
782
|
+
*/
|
|
783
|
+
AcApLayerService.prototype.setLayerFrozenByName = function (layerName, frozen) {
|
|
784
|
+
var _this = this;
|
|
785
|
+
var layer = this.db.tables.layerTable.getAt(layerName);
|
|
786
|
+
if (!layer)
|
|
787
|
+
return false;
|
|
788
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
789
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
790
|
+
if (!opened)
|
|
791
|
+
return false;
|
|
792
|
+
AcApLayerService.setLayerFrozenState(opened, frozen);
|
|
793
|
+
return true;
|
|
794
|
+
});
|
|
795
|
+
};
|
|
796
|
+
/**
|
|
797
|
+
* Turns off the layer of a picked entity (`LAYOFF`).
|
|
798
|
+
*
|
|
799
|
+
* @param objectId - Selected entity id.
|
|
800
|
+
* @returns Outcome with previous off state for session undo, or a failure reason.
|
|
801
|
+
*/
|
|
802
|
+
AcApLayerService.prototype.turnOffLayerByEntity = function (objectId) {
|
|
803
|
+
var _this = this;
|
|
804
|
+
var layerName = this.getLayerNameFromEntity(objectId);
|
|
805
|
+
if (!layerName) {
|
|
806
|
+
return { ok: false, reason: 'invalid_selection' };
|
|
807
|
+
}
|
|
808
|
+
var layer = this.db.tables.layerTable.getAt(layerName);
|
|
809
|
+
if (!layer) {
|
|
810
|
+
return { ok: false, reason: 'layer_not_found', layerName: layerName };
|
|
811
|
+
}
|
|
812
|
+
if (layer.name === this.db.clayer) {
|
|
813
|
+
return { ok: false, reason: 'cannot_change_current', layerName: layerName };
|
|
814
|
+
}
|
|
815
|
+
if (layer.isOff) {
|
|
816
|
+
return { ok: false, reason: 'already_off', layerName: layerName };
|
|
817
|
+
}
|
|
818
|
+
var wasOff = layer.isOff;
|
|
819
|
+
acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
820
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
821
|
+
if (!opened)
|
|
822
|
+
return;
|
|
823
|
+
opened.isOff = true;
|
|
824
|
+
});
|
|
825
|
+
return { ok: true, layerName: layerName, previousOff: wasOff };
|
|
826
|
+
};
|
|
827
|
+
/**
|
|
828
|
+
* Restores off state by layer name for `LAYOFF` session undo.
|
|
829
|
+
*
|
|
830
|
+
* @param layerName - Target layer name.
|
|
831
|
+
* @param off - Off state to restore.
|
|
832
|
+
* @returns `true` when the layer exists and state was applied.
|
|
833
|
+
*/
|
|
834
|
+
AcApLayerService.prototype.setLayerOffByName = function (layerName, off) {
|
|
835
|
+
var _this = this;
|
|
836
|
+
var layer = this.db.tables.layerTable.getAt(layerName);
|
|
837
|
+
if (!layer)
|
|
838
|
+
return false;
|
|
839
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
840
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
841
|
+
if (!opened)
|
|
842
|
+
return false;
|
|
843
|
+
opened.isOff = off;
|
|
844
|
+
return true;
|
|
845
|
+
});
|
|
846
|
+
};
|
|
847
|
+
/**
|
|
848
|
+
* Locks the layer of a picked entity (`LAYLCK`).
|
|
849
|
+
*
|
|
850
|
+
* @param objectId - Selected entity id.
|
|
851
|
+
* @returns Success or failure outcome.
|
|
852
|
+
*/
|
|
853
|
+
AcApLayerService.prototype.lockLayerByEntity = function (objectId) {
|
|
854
|
+
var _this = this;
|
|
855
|
+
var layerName = this.getLayerNameFromEntity(objectId);
|
|
856
|
+
if (!layerName) {
|
|
857
|
+
return { ok: false, reason: 'invalid_selection' };
|
|
858
|
+
}
|
|
859
|
+
var layer = this.db.tables.layerTable.getAt(layerName);
|
|
860
|
+
if (!layer) {
|
|
861
|
+
return { ok: false, reason: 'layer_not_found', layerName: layerName };
|
|
862
|
+
}
|
|
863
|
+
if (AcApLayerService.isLayerLocked(layer)) {
|
|
864
|
+
return { ok: false, reason: 'already_locked', layerName: layerName };
|
|
865
|
+
}
|
|
866
|
+
acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
867
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
868
|
+
if (!opened)
|
|
869
|
+
return;
|
|
870
|
+
AcApLayerService.setLayerLockedState(opened, true);
|
|
871
|
+
});
|
|
872
|
+
return { ok: true, layerName: layerName };
|
|
873
|
+
};
|
|
874
|
+
/**
|
|
875
|
+
* Unlocks the layer of a picked entity (`LAYULK`).
|
|
876
|
+
*
|
|
877
|
+
* @param objectId - Selected entity id.
|
|
878
|
+
* @returns Success or failure outcome.
|
|
879
|
+
*/
|
|
880
|
+
AcApLayerService.prototype.unlockLayerByEntity = function (objectId) {
|
|
881
|
+
var _this = this;
|
|
882
|
+
var layerName = this.getLayerNameFromEntity(objectId);
|
|
883
|
+
if (!layerName) {
|
|
884
|
+
return { ok: false, reason: 'invalid_selection' };
|
|
885
|
+
}
|
|
886
|
+
var layer = this.db.tables.layerTable.getAt(layerName);
|
|
887
|
+
if (!layer) {
|
|
888
|
+
return { ok: false, reason: 'layer_not_found', layerName: layerName };
|
|
889
|
+
}
|
|
890
|
+
if (!AcApLayerService.isLayerLocked(layer)) {
|
|
891
|
+
return { ok: false, reason: 'already_unlocked', layerName: layerName };
|
|
892
|
+
}
|
|
893
|
+
acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
894
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
895
|
+
if (!opened)
|
|
896
|
+
return;
|
|
897
|
+
AcApLayerService.setLayerLockedState(opened, false);
|
|
898
|
+
});
|
|
899
|
+
return { ok: true, layerName: layerName };
|
|
900
|
+
};
|
|
901
|
+
/**
|
|
902
|
+
* Isolates layers by name using `LAYISO` semantics.
|
|
903
|
+
*
|
|
904
|
+
* Target layers are turned on, thawed, and unlocked. Other layers are turned off
|
|
905
|
+
* or locked depending on `isolationMode`. `LockAndFade` locks only; the viewer
|
|
906
|
+
* does not render a fade effect.
|
|
907
|
+
*
|
|
908
|
+
* @param layerNames - Names of layers to keep visible.
|
|
909
|
+
* @param isolationMode - How non-isolated layers are hidden.
|
|
910
|
+
* @returns Isolation result with undo snapshot, or `undefined` when `layerNames` is empty.
|
|
911
|
+
*/
|
|
912
|
+
AcApLayerService.prototype.isolateLayers = function (layerNames, isolationMode) {
|
|
913
|
+
var _this = this;
|
|
914
|
+
if (layerNames.length === 0)
|
|
915
|
+
return undefined;
|
|
916
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
917
|
+
var e_6, _a, e_7, _b, e_8, _c;
|
|
918
|
+
var table = _this.db.tables.layerTable;
|
|
919
|
+
var targetNames = new Set(layerNames);
|
|
920
|
+
var targetLayer = table.getAt(layerNames[0]);
|
|
921
|
+
var currentLayerBefore = _this.db.clayer;
|
|
922
|
+
var beforeStates = new Map();
|
|
923
|
+
try {
|
|
924
|
+
for (var _d = __values(table.newIterator()), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
925
|
+
var layer = _e.value;
|
|
926
|
+
beforeStates.set(layer.name, getLayerIsoState(layer));
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
930
|
+
finally {
|
|
931
|
+
try {
|
|
932
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
933
|
+
}
|
|
934
|
+
finally { if (e_6) throw e_6.error; }
|
|
935
|
+
}
|
|
936
|
+
if (targetLayer) {
|
|
937
|
+
_this.db.clayer = targetLayer.name;
|
|
938
|
+
}
|
|
939
|
+
var affectedLayerNames = new Set();
|
|
940
|
+
try {
|
|
941
|
+
for (var _f = __values(table.newIterator()), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
942
|
+
var layer = _g.value;
|
|
943
|
+
var opened = AcApLayerService.openLayerForWrite(_this.db, layer);
|
|
944
|
+
if (!opened)
|
|
945
|
+
continue;
|
|
946
|
+
if (targetNames.has(opened.name)) {
|
|
947
|
+
if (opened.isOff) {
|
|
948
|
+
opened.isOff = false;
|
|
949
|
+
affectedLayerNames.add(opened.name);
|
|
950
|
+
}
|
|
951
|
+
if (opened.isFrozen) {
|
|
952
|
+
AcApLayerService.setLayerFrozenState(opened, false);
|
|
953
|
+
affectedLayerNames.add(opened.name);
|
|
954
|
+
}
|
|
955
|
+
if (AcApLayerService.isLayerLocked(opened)) {
|
|
956
|
+
AcApLayerService.setLayerLockedState(opened, false);
|
|
957
|
+
affectedLayerNames.add(opened.name);
|
|
958
|
+
}
|
|
959
|
+
continue;
|
|
960
|
+
}
|
|
961
|
+
if (isolationMode === 'Off') {
|
|
962
|
+
if (!opened.isOff) {
|
|
963
|
+
opened.isOff = true;
|
|
964
|
+
affectedLayerNames.add(opened.name);
|
|
965
|
+
}
|
|
966
|
+
continue;
|
|
967
|
+
}
|
|
968
|
+
if (!AcApLayerService.isLayerLocked(opened)) {
|
|
969
|
+
AcApLayerService.setLayerLockedState(opened, true);
|
|
970
|
+
affectedLayerNames.add(opened.name);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
975
|
+
finally {
|
|
976
|
+
try {
|
|
977
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
978
|
+
}
|
|
979
|
+
finally { if (e_7) throw e_7.error; }
|
|
980
|
+
}
|
|
981
|
+
var snapshots = [];
|
|
982
|
+
try {
|
|
983
|
+
for (var _h = __values(table.newIterator()), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
984
|
+
var layer = _j.value;
|
|
985
|
+
var before = beforeStates.get(layer.name);
|
|
986
|
+
if (!before)
|
|
987
|
+
continue;
|
|
988
|
+
var isolated = getLayerIsoState(layer);
|
|
989
|
+
if (!isSameLayerIsoState(before, isolated)) {
|
|
990
|
+
snapshots.push({
|
|
991
|
+
name: layer.name,
|
|
992
|
+
before: before,
|
|
993
|
+
isolated: isolated
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
999
|
+
finally {
|
|
1000
|
+
try {
|
|
1001
|
+
if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
|
|
1002
|
+
}
|
|
1003
|
+
finally { if (e_8) throw e_8.error; }
|
|
1004
|
+
}
|
|
1005
|
+
var isoSnapshot = {
|
|
1006
|
+
currentLayerBefore: currentLayerBefore,
|
|
1007
|
+
currentLayerAfter: _this.db.clayer,
|
|
1008
|
+
layers: snapshots
|
|
1009
|
+
};
|
|
1010
|
+
return {
|
|
1011
|
+
layerNames: layerNames,
|
|
1012
|
+
affectedLayerCount: affectedLayerNames.size,
|
|
1013
|
+
isoSnapshot: isoSnapshot
|
|
1014
|
+
};
|
|
1015
|
+
});
|
|
1016
|
+
};
|
|
1017
|
+
/**
|
|
1018
|
+
* Restores a `LAYISO` snapshot.
|
|
1019
|
+
*
|
|
1020
|
+
* @param snapshot - Snapshot previously produced by {@link isolateLayers}.
|
|
1021
|
+
* @returns Number of layers whose state was restored.
|
|
1022
|
+
*/
|
|
1023
|
+
AcApLayerService.prototype.unisolateFromSnapshot = function (snapshot) {
|
|
1024
|
+
var _this = this;
|
|
1025
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
1026
|
+
var e_9, _a;
|
|
1027
|
+
var table = _this.db.tables.layerTable;
|
|
1028
|
+
var restoredLayers = 0;
|
|
1029
|
+
try {
|
|
1030
|
+
for (var _b = __values(snapshot.layers), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1031
|
+
var entry = _c.value;
|
|
1032
|
+
if (!table.getAt(entry.name))
|
|
1033
|
+
continue;
|
|
1034
|
+
if (_this.restoreLayerIfUnchanged(entry)) {
|
|
1035
|
+
restoredLayers++;
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
1040
|
+
finally {
|
|
1041
|
+
try {
|
|
1042
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1043
|
+
}
|
|
1044
|
+
finally { if (e_9) throw e_9.error; }
|
|
1045
|
+
}
|
|
1046
|
+
if (_this.db.clayer === snapshot.currentLayerAfter &&
|
|
1047
|
+
snapshot.currentLayerBefore !== snapshot.currentLayerAfter &&
|
|
1048
|
+
table.getAt(snapshot.currentLayerBefore)) {
|
|
1049
|
+
_this.db.clayer = snapshot.currentLayerBefore;
|
|
1050
|
+
}
|
|
1051
|
+
return restoredLayers;
|
|
1052
|
+
});
|
|
1053
|
+
};
|
|
1054
|
+
/**
|
|
1055
|
+
* Collects entity snapshots on a layer for `LAYDEL` undo.
|
|
1056
|
+
*
|
|
1057
|
+
* @param layerName - Layer whose entities should be snapshotted.
|
|
1058
|
+
* @returns Cloned entities with owner and object ids.
|
|
1059
|
+
*/
|
|
1060
|
+
AcApLayerService.prototype.collectLayerEntities = function (layerName) {
|
|
1061
|
+
var e_10, _a, e_11, _b;
|
|
1062
|
+
var snapshots = [];
|
|
1063
|
+
try {
|
|
1064
|
+
for (var _c = __values(this.db.tables.blockTable.newIterator()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1065
|
+
var blockRecord = _d.value;
|
|
1066
|
+
try {
|
|
1067
|
+
for (var _e = (e_11 = void 0, __values(blockRecord.newIterator())), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
1068
|
+
var entity = _f.value;
|
|
1069
|
+
if (entity.layer !== layerName)
|
|
1070
|
+
continue;
|
|
1071
|
+
snapshots.push({
|
|
1072
|
+
ownerId: blockRecord.objectId,
|
|
1073
|
+
objectId: entity.objectId,
|
|
1074
|
+
entity: entity.clone()
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
1079
|
+
finally {
|
|
1080
|
+
try {
|
|
1081
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
1082
|
+
}
|
|
1083
|
+
finally { if (e_11) throw e_11.error; }
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
1088
|
+
finally {
|
|
1089
|
+
try {
|
|
1090
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
1091
|
+
}
|
|
1092
|
+
finally { if (e_10) throw e_10.error; }
|
|
1093
|
+
}
|
|
1094
|
+
return snapshots;
|
|
1095
|
+
};
|
|
1096
|
+
/**
|
|
1097
|
+
* Removes entities previously captured for `LAYDEL`.
|
|
1098
|
+
*
|
|
1099
|
+
* @param deletedEntities - Entity snapshots to erase from their owners.
|
|
1100
|
+
*/
|
|
1101
|
+
AcApLayerService.prototype.removeLayerEntities = function (deletedEntities) {
|
|
1102
|
+
var _this = this;
|
|
1103
|
+
var idsByOwner = new Map();
|
|
1104
|
+
deletedEntities.forEach(function (_a) {
|
|
1105
|
+
var _b;
|
|
1106
|
+
var ownerId = _a.ownerId, objectId = _a.objectId;
|
|
1107
|
+
var ids = (_b = idsByOwner.get(ownerId)) !== null && _b !== void 0 ? _b : [];
|
|
1108
|
+
ids.push(objectId);
|
|
1109
|
+
idsByOwner.set(ownerId, ids);
|
|
1110
|
+
});
|
|
1111
|
+
idsByOwner.forEach(function (ids, ownerId) {
|
|
1112
|
+
var _a;
|
|
1113
|
+
(_a = _this.db.tables.blockTable.getIdAt(ownerId)) === null || _a === void 0 ? void 0 : _a.removeEntity(ids);
|
|
1114
|
+
});
|
|
1115
|
+
};
|
|
1116
|
+
/**
|
|
1117
|
+
* Deletes a layer and all entities on it (`LAYDEL`).
|
|
1118
|
+
*
|
|
1119
|
+
* Layer `0` and the current layer cannot be deleted.
|
|
1120
|
+
*
|
|
1121
|
+
* @param layerName - Name of the layer to delete.
|
|
1122
|
+
* @returns Success with undo snapshots, or a failure reason.
|
|
1123
|
+
*/
|
|
1124
|
+
AcApLayerService.prototype.deleteLayer = function (layerName) {
|
|
1125
|
+
var _this = this;
|
|
1126
|
+
var layer = this.db.tables.layerTable.getAt(layerName);
|
|
1127
|
+
if (!layer) {
|
|
1128
|
+
return { ok: false, reason: 'not_found', layerName: layerName };
|
|
1129
|
+
}
|
|
1130
|
+
if (layer.name === '0') {
|
|
1131
|
+
return { ok: false, reason: 'layer_0', layerName: layerName };
|
|
1132
|
+
}
|
|
1133
|
+
if (layer.name === this.db.clayer) {
|
|
1134
|
+
return { ok: false, reason: 'current_layer', layerName: layerName };
|
|
1135
|
+
}
|
|
1136
|
+
return acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
1137
|
+
var deletedEntities = _this.collectLayerEntities(layer.name);
|
|
1138
|
+
_this.removeLayerEntities(deletedEntities);
|
|
1139
|
+
var deletedLayer = layer.clone();
|
|
1140
|
+
_this.db.tables.layerTable.remove(layer.name);
|
|
1141
|
+
_this.db.events.layerErased.dispatch({ database: _this.db, layer: layer });
|
|
1142
|
+
return {
|
|
1143
|
+
ok: true,
|
|
1144
|
+
layerName: layer.name,
|
|
1145
|
+
layer: deletedLayer,
|
|
1146
|
+
entities: deletedEntities
|
|
1147
|
+
};
|
|
1148
|
+
});
|
|
1149
|
+
};
|
|
1150
|
+
/**
|
|
1151
|
+
* Restores a deleted layer and its entities for `LAYDEL` session undo.
|
|
1152
|
+
*
|
|
1153
|
+
* @param layer - Cloned layer table record to re-add.
|
|
1154
|
+
* @param entities - Entity snapshots to append back to their owners.
|
|
1155
|
+
*/
|
|
1156
|
+
AcApLayerService.prototype.restoreDeletedLayer = function (layer, entities) {
|
|
1157
|
+
var _this = this;
|
|
1158
|
+
acapRunServiceEdit(this.db, LAYER_EDIT_LABEL, function () {
|
|
1159
|
+
if (!_this.db.tables.layerTable.has(layer.name)) {
|
|
1160
|
+
_this.db.tables.layerTable.add(layer.clone());
|
|
1161
|
+
}
|
|
1162
|
+
var entitiesByOwner = new Map();
|
|
1163
|
+
entities.forEach(function (_a) {
|
|
1164
|
+
var _b;
|
|
1165
|
+
var ownerId = _a.ownerId, entity = _a.entity;
|
|
1166
|
+
var list = (_b = entitiesByOwner.get(ownerId)) !== null && _b !== void 0 ? _b : [];
|
|
1167
|
+
list.push(entity.clone());
|
|
1168
|
+
entitiesByOwner.set(ownerId, list);
|
|
1169
|
+
});
|
|
1170
|
+
entitiesByOwner.forEach(function (list, ownerId) {
|
|
1171
|
+
var _a;
|
|
1172
|
+
var owner = (_a = _this.db.tables.blockTable.getIdAt(ownerId)) !== null && _a !== void 0 ? _a : _this.db.tables.blockTable.modelSpace;
|
|
1173
|
+
owner.appendEntity(list);
|
|
1174
|
+
});
|
|
1175
|
+
});
|
|
1176
|
+
};
|
|
1177
|
+
/**
|
|
1178
|
+
* Restores one layer from an isolation snapshot when its post-isolation state still matches.
|
|
1179
|
+
*
|
|
1180
|
+
* @param snapshot - Per-layer before/after isolation snapshot.
|
|
1181
|
+
* @returns `true` when at least one flag was restored.
|
|
1182
|
+
*/
|
|
1183
|
+
AcApLayerService.prototype.restoreLayerIfUnchanged = function (snapshot) {
|
|
1184
|
+
var layer = this.db.tables.layerTable.getAt(snapshot.name);
|
|
1185
|
+
if (!layer)
|
|
1186
|
+
return false;
|
|
1187
|
+
var opened = AcApLayerService.openLayerForWrite(this.db, layer);
|
|
1188
|
+
if (!opened)
|
|
1189
|
+
return false;
|
|
1190
|
+
var restored = false;
|
|
1191
|
+
if (opened.isOff === snapshot.isolated.isOff &&
|
|
1192
|
+
opened.isOff !== snapshot.before.isOff) {
|
|
1193
|
+
opened.isOff = snapshot.before.isOff;
|
|
1194
|
+
restored = true;
|
|
1195
|
+
}
|
|
1196
|
+
if (opened.isFrozen === snapshot.isolated.isFrozen &&
|
|
1197
|
+
opened.isFrozen !== snapshot.before.isFrozen) {
|
|
1198
|
+
AcApLayerService.setLayerFrozenState(opened, snapshot.before.isFrozen);
|
|
1199
|
+
restored = true;
|
|
1200
|
+
}
|
|
1201
|
+
if (AcApLayerService.isLayerLocked(opened) === snapshot.isolated.isLocked &&
|
|
1202
|
+
AcApLayerService.isLayerLocked(opened) !== snapshot.before.isLocked) {
|
|
1203
|
+
AcApLayerService.setLayerLockedState(opened, snapshot.before.isLocked);
|
|
1204
|
+
restored = true;
|
|
1205
|
+
}
|
|
1206
|
+
return restored;
|
|
1207
|
+
};
|
|
1208
|
+
/**
|
|
1209
|
+
* Resolves live layer-table traits for rendering and style synchronization.
|
|
1210
|
+
*
|
|
1211
|
+
* @param layerName - Name of the layer to resolve from the layer table.
|
|
1212
|
+
* @returns Resolved sub-entity traits, or undefined when the layer is missing.
|
|
1213
|
+
*/
|
|
1214
|
+
AcApLayerService.prototype.getEffectiveLayerTraits = function (layerName) {
|
|
1215
|
+
return AcApLayerService.resolveLayerTraits(this.db, layerName);
|
|
1216
|
+
};
|
|
1217
|
+
/**
|
|
1218
|
+
* Resolves live layer-table traits from the given database.
|
|
1219
|
+
*
|
|
1220
|
+
* @param db - Database whose layer table supplies the record.
|
|
1221
|
+
* @param layerName - Name of the layer to resolve.
|
|
1222
|
+
* @returns Resolved sub-entity traits, or undefined when the layer is missing.
|
|
1223
|
+
*/
|
|
1224
|
+
AcApLayerService.resolveLayerTraits = function (db, layerName) {
|
|
1225
|
+
var layer = db.tables.layerTable.getAt(layerName);
|
|
1226
|
+
if (!layer) {
|
|
1227
|
+
return undefined;
|
|
1228
|
+
}
|
|
1229
|
+
return {
|
|
1230
|
+
layer: layer.name,
|
|
1231
|
+
color: layer.color.clone(),
|
|
1232
|
+
lineType: layer.lineStyle,
|
|
1233
|
+
lineWeight: layer.lineWeight,
|
|
1234
|
+
transparency: layer.transparency
|
|
1235
|
+
};
|
|
1236
|
+
};
|
|
1237
|
+
return AcApLayerService;
|
|
1238
|
+
}());
|
|
1239
|
+
export { AcApLayerService };
|
|
1240
|
+
//# sourceMappingURL=AcApLayerService.js.map
|