Class: SketchSphereDrawTool

SketchSphereDrawTool

new SketchSphereDrawTool(options)

sketchEditor/base/drawTools/SketchSphereDrawTool.js, line 10

球体草图绘制工具。

通过中心点和拖拽半径创建三维球体符号,适用于三维场景中的球体绘制、平移、缩放、高度调整和旋转编辑。 工具以点几何作为球心,并通过 ObjectSymbol3DLayer 的宽度、深度和高度维护球体尺寸。

Name Type Default Description
options Object {} 可选

构造参数。

Name Type Default Description
view MapView | SceneView 可选

地图视图对象,提供拾取、坐标转换和交互事件能力。

layer GraphicsLayer 可选

草图图层对象,用于承载绘制完成的球体要素。

sketchStyle SketchStyle | SketchStyle3D 可选

草图符号样式。工具会从点符号样式中读取 ObjectSymbol3DLayer。

entityHeight Number 500 可选

初始实体高度,保留用于与其他三维实体工具保持一致。

entityType String 'sphere' 可选

实体类型,默认创建球体。

Example

创建球体绘制工具

// ES5 引入方式
const { SketchSphereDrawTool } = zondy.tool.sketch

// ES6 引入方式
import { SketchSphereDrawTool } from '@mapgis/webclient-common'

const drawTool = new SketchSphereDrawTool({
  view,
  layer,
  entityType: 'sphere'
})
drawTool.start()

Extends

Members

arcTypeNumber

弧线类型

editOptionObject

草图选中编辑配置项

elevationInfoSketchStyle

图形高程模式参数

extensionOptionsObject

草图编辑的扩展属性,可以通过该属性传入草图编辑额外需要的参数

草图图层

sketchStageSketchStage

草图绘图形集合

sketchStyleSketchStyle

草图符号

typeString

草图工具类型名

undoRedoManagerString

草图撤销回退管理器

地图视图

Methods

inherited _getProjectionOnRotatedAxes(rotationAngle, startPoint, endPoint){Object}

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 3294

计算点2到中心点在旋转后坐标轴上的投影距离

Name Type Description
rotationAngle number

旋转角度(弧度)

startPoint Object

起始点(中心点),格式 { x, y }

endPoint Object

终止点(目标点),格式 { x, y }

Returns:
Type Description
Object 返回 { x, y } 表示在旋转后坐标系中的投影距离

inherited _getProjectionOnRotatedAxes1(rotation, startPoint, endPoint){Object}

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 3331

计算点到坐标轴方向的分量

Name Type Description
rotation number

坐标系旋转角度(弧度,正值为顺时针)

startPoint Object

起点(原点)像素坐标 {x, y}

endPoint Object

终点(P点)像素坐标 {x, y}

Returns:
Type Description
Object 返回 {x, y} - 点在旋转后坐标系的x轴和y轴方向上的分量距离

inherited _getSphereCenterPoint()

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 4041

获取立体几何的中心点

inherited _rotatePoint(angleDegrees, P, Q){Object}

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 3384

计算点Q绕点P旋转后的坐标

Name Type Description
angleDegrees number

旋转角度(度),逆时针为正,顺时针为负

P Object

旋转中心点坐标

Q Object

旋转前Q点坐标

Returns:
Type Description
Object Q点旋转后的坐标

addFeature(point, radius, radiusUnit, sketchStyle, attributes, layer){void}

sketchEditor/base/drawTools/SketchSphereDrawTool.js, line 195

添加球体草图要素。

根据球心、半径和半径单位创建点几何三维球体要素,并添加到目标图层。

Name Type Description
point Point | Array.<Number>

球心点。

radius Number

球体半径。

radiusUnit RadiusUnit

半径单位。

sketchStyle SketchStyle | SketchStyle3D

符号样式参数。当前实现保留该参数以兼容调用签名。

attributes Object 可选

写入球体要素的属性对象。

layer GraphicsLayer 可选

要素添加到的目标图层。

Returns:
Type Description
void

inherited addVertex(point, index)

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 1954

当前草图图形中插入新的顶点

Name Type Description
point Point

新增/插入顶点

index Number

新增点的索引值,索引值从0开始

drawFeature(){void}

sketchEditor/base/drawTools/SketchSphereDrawTool.js, line 71

开始鼠标拖拽绘制球体。

鼠标按下确定球心,拖拽距离作为球体半径并同步更新三维符号尺寸,鼠标抬起后完成绘制。

Returns:
Type Description
void

inherited getDistanceByPixel(pixel){Number}

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 1975

根据像素单位获取距离

Name Type Description
pixel Number

编辑状态码

Returns:
Type Description
Number 距离

inherited getMidScaleCoordinates(coordinates, direction, extent, startPoint, movePoint, oriCoordinates){Number}

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 2106

获取图形通过四个中点缩放后的坐标

Name Type Description
coordinates Array

坐标数组

direction String

方向

extent Extent

图形extent范围

startPoint Point

移动前的点

movePoint Point

移动后的点

oriCoordinates Point

图形原始坐标

Returns:
Type Description
Number 缩放后的坐标

inherited getPanCoordinates(coordinates, deltaX, deltaY, pointType, extent){Number}

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 1993

获取平移后的坐标

Name Type Description
coordinates Array

坐标数组

deltaX Number

x轴偏移量

deltaY Number

y轴偏移量

pointType Number

点属性类型

extent Number

点所在范围

Returns:
Type Description
Number 平移后的坐标

inherited getScaleCoordinates(coordinates, direction, extent, startPoint, movePoint, oriCoordinates){Number}

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 2023

获取图形通过四个顶点缩放后的坐标

Name Type Description
coordinates Array

坐标数组

direction String

方向

extent Extent

图形extent范围

startPoint Point

移动前的点

movePoint Point

移动后的点

oriCoordinates Point

图形原始坐标

Returns:
Type Description
Number 缩放后的坐标

inherited removeDrawTool()

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 1922

清除草图绘制工具

inherited removeVertex(index)

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 1967

移除草图图形的某个顶点

Name Type Description
index Number

需移除的顶点的索引值,索引值从0开始

selectFeature(feature, event, options){void}

sketchEditor/base/drawTools/SketchSphereDrawTool.js, line 318

选中球体草图要素。

选中时同步缓存当前要素和符号高度,并交由父类加载整体编辑辅助图形。

Name Type Description
feature Feature

被选中的球体要素。

event Object

选中事件参数。

options Object

选中附加参数。

Returns:
Type Description
void

inherited selectFeatureRotate(feature)

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 3814

选中feature图形旋转

Name Type Description
feature Feature

被选中feature对象

selectFeatureVertex(feature){void}

sketchEditor/base/drawTools/SketchSphereDrawTool.js, line 811

进入球体顶点编辑状态。

当前实现主要面向锥体类资源的顶点编辑辅助;非锥体资源会直接返回。

Name Type Description
feature Feature

被选中的球体或锥体要素。

Returns:
Type Description
void

inherited setSketchStyle(sketchStyle)

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 1742

设置草图样式

Name Type Description
sketchStyle SketchStyle

inherited setSnapAndReferGeometries(geometries)

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 2874

设置捕获和线造区边界参考几何图形集合

Name Type Description
geometries Array.<Geometry>

可选,几何图形集合。

inherited setSnapFeatures(features)

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 3808

设置捕获和线造区边界参考几何图形集合

Name Type Description
features Array.<Geometry>

可选,几何图形集合。

inherited start()

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 176

开始绘制草图

startPanGraphics(feature, event){void}

sketchEditor/base/drawTools/SketchSphereDrawTool.js, line 618

开始平移球体或切换编辑状态。

拖拽时更新球心位置并同步辅助图形;单击时根据编辑配置切换到缩放或旋转辅助状态。

Name Type Description
feature Feature

被拾取的球体要素。

event Object

拾取事件参数。

Returns:
Type Description
void

inherited stop()

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 189

停止绘制草图

inherited updateFeature(point, feature)

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 1900

更新feature

Name Type Description
point Point

待更新的位置

feature Feature

被更新的feature

inherited updateVertex(point, index)

sketchEditor/base/drawTools/SketchBaseDrawTool.js, line 1961

更新当前草图图形的某个顶点

Name Type Description
point Point

新的顶点

index Number

需更新的顶点的索引值,索引值从0开始