Skip to content

Commit

Permalink
refactor(drawings): improve types
Browse files Browse the repository at this point in the history
  • Loading branch information
zouyaoji committed Mar 9, 2022
1 parent df80823 commit c7a0f63
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 97 deletions.
22 changes: 13 additions & 9 deletions packages/components/drawings/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default defineComponent({
background: options[`${camelize(drawing)}ActionOpts`].color,
color: options[`${camelize(drawing)}ActionOpts`].textColor
},
actionClass: `vc-draw-${drawing} vc-draw-button${drawing === (instance.proxy as any).selectedDrawingActionInstance?.name ? ' active' : ''}`,
actionClass: `vc-draw-${drawing} vc-draw-button`,
actionRef: ref<VcFabActionRef>(null!),
actionOpts: options[`${camelize(drawing)}ActionOpts`] as VcActionTooltipProps,
cmp: getDrawingCmp(drawing),
Expand Down Expand Up @@ -121,19 +121,15 @@ export type VcDrawingsSlots = {
}
export interface VcDrawingsRef extends VcComponentPublicInstance<VcDrawingsProps> {
/**
* Get the drawing action instances.
* Get or set the editingActionName.
*/
drawingActionInstances: Array<VcDrawingActionInstance>
/**
* Get the selected drawing action instance.
*/
selectedDrawingActionInstance: VcDrawingActionInstance
editingActionName?: string
/**
* Clear all drawing results.
*/
clearAll: () => void
/**
* End listening for the ScreenSpaceEventHandler event.
* End listening for the ScreenSpaceEventHandler events.
*/
deactivate: () => void
/**
Expand All @@ -150,7 +146,15 @@ export interface VcDrawingsRef extends VcComponentPublicInstance<VcDrawingsProps
*/
getFabRef: () => VcFabRef
/**
* Get the drawingActionInstance.
* Get the drawingActionInstance by action name.
*/
getDrawingActionInstance: (actionName: string) => VcDrawingActionInstance
/**
* Get the drawing action instances.
*/
getDrawingActionInstances: () => Array<VcDrawingActionInstance>
/**
* Get the selected drawing action instance.
*/
getSelectedDrawingActionInstance: () => VcDrawingActionInstance
}
48 changes: 34 additions & 14 deletions packages/components/drawings/src/pin/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author: zouyaoji@https://github.com/zouyaoji
* @Date: 2021-10-11 09:17:22
* @LastEditTime: 2022-03-06 22:44:26
* @LastEditTime: 2022-03-08 21:44:21
* @LastEditors: zouyaoji
* @Description:
* @FilePath: \vue-cesium@next\packages\components\drawings\src\pin\index.ts
Expand All @@ -13,7 +13,15 @@ import useDrawingPoint from '@vue-cesium/composables/use-drawing/use-drawing-poi
import type { VcBillboardProps, VcLabelProps, VcPointProps } from '../../../primitive-collections'
import { drawingEmit } from '@vue-cesium/utils/emits'
import type { VcComponentInternalInstance, VcComponentPublicInstance, VcReadyObject } from '@vue-cesium/utils/types'
import { VcDrawingPreRenderDatas, VcDrawTipOpts, VcEditorOpts, VcPointDrawing } from '@vue-cesium/utils/drawing-types'
import {
VcDrawingDrawEvt,
VcDrawingEditorEvt,
VcDrawingMouseEvt,
VcDrawingPreRenderDatas,
VcDrawTipOpts,
VcEditorOpts,
VcPointDrawing
} from '@vue-cesium/utils/drawing-types'

export default defineComponent({
name: 'VcDrawingPin',
Expand All @@ -35,51 +43,51 @@ export type VcDrawingPinProps = {
/**
* Specify whether to respond to mouse pick events.
*/
enableMouseEvent: boolean
enableMouseEvent?: boolean
/**
* Specify Whether the drawing object is visible.
*/
show: boolean
show?: boolean
/**
* Specify whether the drawing result can be edited.
*/
editable: boolean
editable?: boolean
/**
* Specify drawing hints.
*/
drawtip: VcDrawTipOpts
drawtip?: VcDrawTipOpts
/**
* Specify parameters for drawing points.
*/
pointOpts: VcPointProps
pointOpts?: VcPointProps
/**
* Specify parameters for drawing billbords.
*/
billboardOpts: VcBillboardProps
billboardOpts?: VcBillboardProps
/**
* Specify parameters for drawing labels.
*/
labelOpts: VcLabelProps
labelOpts?: VcLabelProps
/**
* Specify the heightReference.
*/
heightReference: number
heightReference?: number
/**
* Specify whether the depthTest is disabled.
*/
disableDepthTest: number
disableDepthTest?: number
/**
* Specify editor options.
*/
editorOpts: VcEditorOpts
editorOpts?: VcEditorOpts
/**
* Specify editor mode.
*/
mode: number
mode?: number
/**
* Specify prerender datas.
*/
preRenderDatas: VcDrawingPreRenderDatas
preRenderDatas?: VcDrawingPreRenderDatas
/**
* Triggers before the VcDrawingPin is loaded.
*/
Expand All @@ -92,6 +100,18 @@ export type VcDrawingPinProps = {
* Triggers when the VcDrawingPin is destroyed.
*/
onDestroyed?: (instance: VcComponentInternalInstance) => void
/**
* Triggers when drawing.
*/
onDrawEvt?: (evt: VcDrawingDrawEvt, viewer: Cesium.Viewer) => void
/**
* Triggers when the editor button is clicked.
*/
onEditorEvt?: (evt: VcDrawingEditorEvt, viewer: Cesium.Viewer) => void
/**
* Triggers when the mouse is over or out on the drawing point.
*/
onMouseEvt?: (evt: VcDrawingMouseEvt, viewer: Cesium.Viewer) => void
}

export interface VcDrawingPinRef extends VcComponentPublicInstance<VcDrawingPinProps> {
Expand Down
44 changes: 32 additions & 12 deletions packages/components/drawings/src/point/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author: zouyaoji@https://github.com/zouyaoji
* @Date: 2021-10-11 09:17:22
* @LastEditTime: 2022-03-06 22:44:32
* @LastEditTime: 2022-03-08 21:44:40
* @LastEditors: zouyaoji
* @Description:
* @FilePath: \vue-cesium@next\packages\components\drawings\src\point\index.ts
Expand All @@ -11,7 +11,15 @@ import { useDrawingActionProps } from '@vue-cesium/composables/use-drawing/props
import useDrawingPoint from '@vue-cesium/composables/use-drawing/use-drawing-point'
import { drawingEmit } from '@vue-cesium/utils/emits'
import { VcComponentInternalInstance, VcComponentPublicInstance, VcReadyObject } from '@vue-cesium/utils/types'
import { VcDrawingPreRenderDatas, VcDrawTipOpts, VcEditorOpts, VcPointDrawing } from '@vue-cesium/utils/drawing-types'
import {
VcDrawingDrawEvt,
VcDrawingEditorEvt,
VcDrawingMouseEvt,
VcDrawingPreRenderDatas,
VcDrawTipOpts,
VcEditorOpts,
VcPointDrawing
} from '@vue-cesium/utils/drawing-types'
import { VcPointProps } from '../../../primitive-collections'

export default defineComponent({
Expand All @@ -32,43 +40,43 @@ export type VcDrawingPointProps = {
/**
* Specify whether to respond to mouse pick events.
*/
enableMouseEvent: boolean
enableMouseEvent?: boolean
/**
* Specify Whether the drawing object is visible.
*/
show: boolean
show?: boolean
/**
* Specify whether the drawing result can be edited.
*/
editable: boolean
editable?: boolean
/**
* Specify drawing hints.
*/
drawtip: VcDrawTipOpts
drawtip?: VcDrawTipOpts
/**
* Specify parameters for drawing points.
*/
pointOpts: VcPointProps
pointOpts?: VcPointProps
/**
* Specify the heightReference.
*/
heightReference: number
heightReference?: number
/**
* Specify whether the depthTest is disabled.
*/
disableDepthTest: number
disableDepthTest?: number
/**
* Specify editor options.
*/
editorOpts: VcEditorOpts
editorOpts?: VcEditorOpts
/**
* Specify editor mode.
*/
mode: number
mode?: number
/**
* Specify prerender datas.
*/
preRenderDatas: VcDrawingPreRenderDatas
preRenderDatas?: VcDrawingPreRenderDatas
/**
* Triggers before the VcDrawingPoint is loaded.
*/
Expand All @@ -81,6 +89,18 @@ export type VcDrawingPointProps = {
* Triggers when the VcDrawingPoint is destroyed.
*/
onDestroyed?: (instance: VcComponentInternalInstance) => void
/**
* Triggers when drawing.
*/
onDrawEvt?: (evt: VcDrawingDrawEvt, viewer: Cesium.Viewer) => void
/**
* Triggers when the editor button is clicked.
*/
onEditorEvt?: (evt: VcDrawingEditorEvt, viewer: Cesium.Viewer) => void
/**
* Triggers when the mouse is over or out on the drawing point.
*/
onMouseEvt?: (evt: VcDrawingMouseEvt, viewer: Cesium.Viewer) => void
}

export interface VcDrawingPointRef extends VcComponentPublicInstance<VcDrawingPointProps> {
Expand Down
52 changes: 36 additions & 16 deletions packages/components/drawings/src/polygon/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author: zouyaoji@https://github.com/zouyaoji
* @Date: 2021-09-16 09:28:13
* @LastEditTime: 2022-03-06 22:43:20
* @LastEditTime: 2022-03-08 21:44:58
* @LastEditors: zouyaoji
* @Description:
* @FilePath: \vue-cesium@next\packages\components\drawings\src\polygon\index.ts
Expand All @@ -14,7 +14,15 @@ import { drawingEmit } from '@vue-cesium/utils/emits'
import type { VcGeometryPolylineProps } from '../../../geometries'
import type { VcPointProps, VcPolygonProps } from '../../../primitive-collections'
import type { VcPrimitiveGroundPolylineProps, VcPrimitiveProps } from '../../../primitives'
import { VcDrawingPreRenderDatas, VcDrawTipOpts, VcEditorOpts, VcPolylineDrawing } from '@vue-cesium/utils/drawing-types'
import {
VcDrawingDrawEvt,
VcDrawingEditorEvt,
VcDrawingMouseEvt,
VcDrawingPreRenderDatas,
VcDrawTipOpts,
VcEditorOpts,
VcPolylineDrawing
} from '@vue-cesium/utils/drawing-types'
import { VcComponentInternalInstance, VcComponentPublicInstance, VcReadyObject } from '@vue-cesium/utils/types'

export default defineComponent({
Expand All @@ -39,59 +47,59 @@ export type VcDrawingPolygonProps = {
/**
* Specify whether to respond to mouse pick events.
*/
enableMouseEvent: boolean
enableMouseEvent?: boolean
/**
* Specify Whether the drawing object is visible.
*/
show: boolean
show?: boolean
/**
* Specify whether the drawing result can be edited.
*/
editable: boolean
editable?: boolean
/**
* Specify drawing hints.
*/
drawtip: VcDrawTipOpts
drawtip?: VcDrawTipOpts
/**
* Specify parameters for drawing points.
*/
pointOpts: VcPointProps
pointOpts?: VcPointProps
/**
* Specify parameters for drawing polylines.
*/
polylineOpts: VcGeometryPolylineProps
polylineOpts?: VcGeometryPolylineProps
/**
* Specify parameters for drawing primitives.
*/
primitiveOpts: VcPrimitiveProps & VcPrimitiveGroundPolylineProps
primitiveOpts?: VcPrimitiveProps & VcPrimitiveGroundPolylineProps
/**
* Specify parameters for drawing polygons.
*/
polygonOpts: VcPolygonProps
polygonOpts?: VcPolygonProps
/**
* Specify whether a line segment will be added between the last and first line positions to make this line a loop.
*/
loop: boolean
loop?: boolean
/**
* Specify whether the drawing result object is attached to the ground or 3dtiles. Only polyline and polygon objects work.
*/
clampToGround: boolean
clampToGround?: boolean
/**
* Specify whether the depthTest is disabled.
*/
disableDepthTest: boolean
disableDepthTest?: boolean
/**
* Specify editor options.
*/
editorOpts: VcEditorOpts
editorOpts?: VcEditorOpts
/**
* Specify editor mode.
*/
mode: number
mode?: number
/**
* Specify prerender datas.
*/
preRenderDatas: VcDrawingPreRenderDatas
preRenderDatas?: VcDrawingPreRenderDatas
/**
* Triggers before the VcDrawingPolygon is loaded.
*/
Expand All @@ -104,6 +112,18 @@ export type VcDrawingPolygonProps = {
* Triggers when the VcDrawingPolygon is destroyed.
*/
onDestroyed?: (instance: VcComponentInternalInstance) => void
/**
* Triggers when drawing.
*/
onDrawEvt?: (evt: VcDrawingDrawEvt, viewer: Cesium.Viewer) => void
/**
* Triggers when the editor button is clicked.
*/
onEditorEvt?: (evt: VcDrawingEditorEvt, viewer: Cesium.Viewer) => void
/**
* Triggers when the mouse is over or out on the drawing point.
*/
onMouseEvt?: (evt: VcDrawingMouseEvt, viewer: Cesium.Viewer) => void
}

export interface VcDrawingPolygonRef extends VcComponentPublicInstance<VcDrawingPolygonProps> {
Expand Down
Loading

0 comments on commit c7a0f63

Please sign in to comment.