DrawEvent

sealed interface DrawEvent

A user interaction, translated from whatever input system the host app uses (e.g. WWK pick/gesture callbacks in wwk-adapter) into a form DrawEngineReducer can act on without knowing anything about that platform.

Inheritors

Types

Link copied to clipboard

Draws the selected (or edited) shape over every other one, as one undo step: it is given a place one above the highest. Ignored in any other mode, when it is the only shape, or when it is already above all the others.

Link copied to clipboard
data class Click(val position: GeoPosition, val hitEntityId: EntityId?, val hitVertexId: VertexId? = null) : DrawEvent

A tap/click at position. hitEntityId is whatever the adapter's own picking determined was under that point, or null for empty space — hit-testing happens in the adapter, not recomputed here.

Link copied to clipboard
data class CutBy(val cutterId: EntityId, val idPrefix: String) : DrawEvent

An explicit request to cut the polygon cutterId out of the polygon that is currently selected or being edited: the selected one loses the part the other covers (and is removed if nothing is left, which leaves the selection), and cutterId stays as it is. Ids of new vertices and the cases where nothing happens are as for MergeWith. Undoable.

Link copied to clipboard

An explicit request (e.g. a host UI "Delete" button) to delete the shape that is currently selected or being edited. A no-op in any other mode — there is no "current shape" then, and deleting is deliberately not by-id so a host can't delete something the user isn't looking at by passing a stale id. Leaves the engine idle. Unlike finishing a drawing, this is an undo step: undo brings the shape back (see DrawStateMachine).

Link copied to clipboard

Removes the whole ring of a polygon that holds the vertex selected while editing — a part, or a hole — as one undo step. Ignored when nothing is selected, or when that ring is the polygon's only one (delete the shape instead).

Link copied to clipboard

Removes the vertex selected while editing (the one last tapped or grabbed, DrawMode.Edit.selectedVertexId) as one undo step. Ignored when nothing is selected, or when removing it would leave its ring with too few vertices (a polygon ring needs 3, a polyline 2): the shape stays as it is and the vertex stays selected.

Link copied to clipboard
data class DragEnd(val position: GeoPosition, val newVertexId: VertexId? = null) : DrawEvent

The drag ends at position. newVertexId is a fresh id the adapter generates only when the drag that's ending was a DrawMode.Edit.ActiveDrag.NewVertex one (the adapter knows this because it's the same gesture whose DragStart it built) — it's what the reducer uses to finally construct the one real com.tcsappdev.worldwinddraw.core.history.commands.AddVertexCommand for the whole gesture. null here on a NewVertex drag just skips the insert (a graceful no-op), matching how null fields elsewhere in DrawEvent mean "the adapter couldn't/didn't supply this," not an error.

Link copied to clipboard
data class DragMove(val position: GeoPosition) : DrawEvent

The drag continues at position. What's being dragged is already known from the DragStart that began it.

Link copied to clipboard
data class DragStart(val position: GeoPosition, val hitVertexId: VertexId?, val hitEntityId: EntityId?, val hitEdgeIndex: Int? = null, val hitDraftPointIndex: Int? = null, val hitDraftEdgeIndex: Int? = null, val hitMarker: Boolean = false, val hitSpanPrevId: VertexId? = null, val hitSpanNextId: VertexId? = null, val hitRingIndex: Int = 0) : DrawEvent

A drag gesture begins at position. hitEntityId identifies which shape (if any) was grabbed. Exactly one of hitVertexId (an existing vertex) or hitEdgeIndex (a midpoint handle, not yet a real vertex — see DrawMode.Edit.ActiveDrag.NewVertex) should be set for a drag the reducer acts on; both null (with hitEntityId also often null) means empty space or a whole-shape grab this library doesn't support yet.

Link copied to clipboard
data class FinishDrawing(val entityId: EntityId, val vertexIds: List<VertexId>) : DrawEvent

An explicit request (e.g. a host UI "Finish" button) to commit DrawMode.Draw's pendingVertices as a real entity. entityId and vertexIds are generated by the caller for the same reason DragEnd.newVertexId is: the reducer must stay pure, so it can't invent ids itself. vertexIds must have exactly one id per pending vertex — the caller reads pendingVertices.size from the current state right before dispatching this, so a mismatch means the state changed out from under it, and the reducer treats that as a no-op rather than guessing which ids belong to which point. Dispatched while not in DrawMode.Draw, or with too few points for the entity type, is also a no-op — a host should gate its "Finish" button on both, but the reducer doesn't trust it to.

Link copied to clipboard
data class MergeWith(val otherId: EntityId, val idPrefix: String) : DrawEvent

An explicit request to merge the polygon otherId into the polygon that is currently selected or being edited: the selected one becomes the union of the two (keeping its id and look) and otherId is gone. New vertices (where the outlines cross) get ids made from idPrefix (<idPrefix>-1, <idPrefix>-2, ...), which the host picks so that they are free. Does nothing in any other mode, if either shape is missing or isn't a polygon, if they are the same shape, if either isn't a valid polygon, or if the state machine was given no com.tcsappdev.worldwinddraw.core.overlay.OverlayEngine. Undoable.

Link copied to clipboard
data class ModeChange(val mode: DrawMode) : DrawEvent

An explicit request (e.g. a host UI button) to switch to mode, regardless of the current mode.

Link copied to clipboard
data class ResizeMarker(val size: Float) : DrawEvent

An explicit request (e.g. a host UI "+" / "-" button) to set the size of the marker that is currently selected or being edited to size (screen pixels, the marker's longest side). A no-op in any other mode, and if the selected shape isn't a marker. Undoable.

Link copied to clipboard

The opposite of BringToFront: draws the selected (or edited) shape below every other one.

Link copied to clipboard
data class SetDescription(val description: String?) : DrawEvent

An explicit request to give the shape that is currently selected or being edited the description description (null for none; see com.tcsappdev.worldwinddraw.core.geometry.DrawableEntity.description). A no-op in any other mode. Undoable.

Link copied to clipboard
data class SetMarkerLabel(val label: MarkerLabel?) : DrawEvent

An explicit request to give the marker that is currently selected or being edited the text label, or to take its text away with null. A no-op in any other mode, and if the selected shape isn't a marker. Undoable.

Link copied to clipboard
data class SetProperties(val properties: Map<String, String>) : DrawEvent

An explicit request to give the shape that is currently selected or being edited the properties properties, replacing all it had (an empty map for none; see com.tcsappdev.worldwinddraw.core.geometry.DrawableEntity.properties). A no-op in any other mode. Undoable.

Link copied to clipboard
data class SetZIndex(val zIndex: Int) : DrawEvent

An explicit request to put the shape that is currently selected or being edited at zIndex in the drawing order (see com.tcsappdev.worldwinddraw.core.geometry.DrawableEntity.zIndex). A no-op in any other mode. Undoable.

Link copied to clipboard
data class SimplifyShape(val keepFraction: Float) : DrawEvent

Cuts the selected (or edited) polygon or polyline down to about keepFraction of its vertices, as one undo step: the least important points go first (see Visvalingam), the kept ones are original vertices, and a polygon keeps at least 3 and a polyline 2. Ignored if no such shape is selected or nothing would be removed. Heavy reductions of a detailed shape can make its outline cross itself, so a host should not offer to go all the way down.