UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

120 lines (119 loc) 7.55 kB
import type SliceAnalysis from "../../../analysis/SliceAnalysis.js"; import type AnalysisView3D from "./AnalysisView3D.js"; import type { AbortOptions } from "../../../core/promiseUtils.js"; import type { SlicePlacementResult } from "./Slice/types.js"; /** * Represents the analysis view of a [SliceAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/SliceAnalysis/) * after it has been added to [SceneView.analyses](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#analyses). * * The SliceAnalysisView3D is responsible for rendering a [SliceAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/SliceAnalysis/) * using custom visualizations. * * It allows to create a new slice interactively using the [place()](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/SliceAnalysisView3D/#place) method, * exclude layers from slicing using the [pickLayerToExclude()](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/SliceAnalysisView3D/#pickLayerToExclude) method, * or make an existing analysis editable by enabling the [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/SliceAnalysisView3D/#interactive) property. * * While multiple [SliceAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/SliceAnalysis/) can be added to * [SceneView.analyses](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#analyses), only one [SliceAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/SliceAnalysis/) can be * actively slicing the scene. The [SliceAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/SliceAnalysis/) which * is currently actively slicing the scene can be controlled by setting the [active](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/SliceAnalysisView3D/#active) property on its analysis view to `true`. * * The view for an analysis can be retrieved using [SceneView.whenAnalysisView()](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#whenAnalysisView) * similar to how layer views are retrieved for layers using [SceneView.whenLayerView()](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#whenLayerView). * * ```js * // retrieve analysis view for analysis * const sliceAnalysis = new SliceAnalysis(); * view.analyses.add(sliceAnalysis); // add to the scene view * const sliceAnalysisView = await view.whenAnalysisView(sliceAnalysis); * ``` * * @see [SliceAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/SliceAnalysis/) * @see [SlicePlane](https://developers.arcgis.com/javascript/latest/references/core/analysis/SlicePlane/) * @see [Slice component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-slice/) * @see [Sample - Analysis objects](https://developers.arcgis.com/javascript/latest/sample-code/analysis-objects/) */ export default abstract class SliceAnalysisView3D extends AnalysisView3D { /** * Only one [SliceAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/SliceAnalysis/) at a time can be active in a [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). * When a slice analysis view is activated by setting this property to `true`, all other slice analysis views are automatically deactivated. * * @default true */ accessor active: boolean; /** * The slice analysis object associated with the analysis view. * * @since 4.24 */ get analysis(): SliceAnalysis; /** * Enables interactivity for the associated [analysis](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/SliceAnalysisView3D/#analysis). When set to `true`, manipulators will be displayed, * allowing users to click and drag to edit the analysis if it has a valid * [SliceAnalysis.shape](https://developers.arcgis.com/javascript/latest/references/core/analysis/SliceAnalysis/#shape). * * This property is automatically set to `true` when the analysis is assigned to a * [Slice component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-slice/). * * @default false * @since 4.24 */ accessor interactive: boolean; /** @since 4.24 */ get type(): "slice-view-3d"; /** * When `true`, the analysis is visualized in the view. * * @since 4.24 */ get visible(): boolean; set visible(value: boolean | null | undefined); /** * Starts an interactive operation to pick a layer to exclude from the slice analysis. * * If the user clicks on the ground, the * [SliceAnalysis.excludeGroundSurface](https://developers.arcgis.com/javascript/latest/references/core/analysis/SliceAnalysis/#excludeGroundSurface) property is set to `true`. * Otherwise, the clicked layer is added to the * [SliceAnalysis.excludedLayers](https://developers.arcgis.com/javascript/latest/references/core/analysis/SliceAnalysis/#excludedLayers). * * This method can only be called when the analysis has a valid shape. Otherwise, an error is thrown. * Calling this method sets [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/SliceAnalysisView3D/#interactive) and [active](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/SliceAnalysisView3D/#active) to `true`. * * @param options - An object specifying additional options. * @returns A promise which resolves when the operation is completed successfully or rejected if it is * canceled. * @since 4.33 */ pickLayerToExclude(options?: AbortOptions | null | undefined): Promise<void>; /** * Starts the interactive placement of a slice plane. * * If the analysis does not have a [SliceAnalysis.shape](https://developers.arcgis.com/javascript/latest/references/core/analysis/SliceAnalysis/#shape) yet, the method allows * placing the slice plane interactively in the view. If the analysis already has a shape, clicking in the view will * replace the existing shape with a new one. * * The placement operation will finish when the user presses the escape key. * To stop the placing programmatically, pass an abort signal as an argument when calling the method. * * Calling this method sets [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/SliceAnalysisView3D/#interactive) and [active](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/SliceAnalysisView3D/#active) to `true`. * * @param options - An object specifying additional options. * @returns A promise which resolves * when the operation is completed successfully or rejected if it is canceled. * @since 4.33 * @example * const abortController = new AbortController(); * * try { * await analysisView.place({ signal: abortController.signal }); * } catch (error) { * if (error.name === "AbortError") { * console.log("Placement operation was cancelled."); * } * } * * // cancel the placement operation at some later point * abortController.abort(); */ place(options?: AbortOptions | null | undefined): Promise<SlicePlacementResult>; }