Draw

data class Draw(val entityType: DrawableEntityType, val pendingVertices: List<GeoPosition>, val style: ShapeStyle = DEFAULT_STYLE, val activeDrag: DrawMode.Draw.ActiveDrag? = null, val targetEntityId: EntityId? = null) : DrawMode

A new shape is being sketched. pendingVertices holds the points placed so far. This is a draft, not yet a real entity — it isn't subject to com.tcsappdev.worldwinddraw.core.geometry.DrawnPolygon/ com.tcsappdev.worldwinddraw.core.geometry.DrawnPolyline's minimum-vertex-count rules until DrawEvent.FinishDrawing actually commits it as one (see DrawEngineReducer), using style for the new entity.

The draft can be reshaped before it is finished, the same two ways an existing shape can (see Edit): drag one of the points to move it, or drag the handle on the middle of an edge to grow a new point there. activeDrag is non-null only between a DragStart and its DragEnd. Points have no ids here (the draft is just positions, addressed by index), and — unlike editing a real entity — it isn't undone by repository commands, because the draft isn't an entity yet. Instead each step is recorded as a change of the whole mode (see UndoableModeChange), so undo/redo walk through the sketching step by step.

With targetEntityId set the draft is not a new shape but one more ring of that polygon — another part, or a hole in one, which of the two follows from where it is drawn (see com.tcsappdev.worldwinddraw.core.geometry.DrawnPolygon). Finishing then adds the ring to it instead of creating an entity, and leaves the engine editing that polygon (like finishing any drawing, that ends the drawing session and is not itself something undo can take back; the ring can be deleted again, see DrawEvent.DeleteSelectedRing). Only meaningful for DrawableEntityType.Polygon.

Constructors

Link copied to clipboard
constructor(entityType: DrawableEntityType, pendingVertices: List<GeoPosition>, style: ShapeStyle = DEFAULT_STYLE, activeDrag: DrawMode.Draw.ActiveDrag? = null, targetEntityId: EntityId? = null)

Types

Link copied to clipboard
sealed interface ActiveDrag

What an in-progress drag inside Draw is doing.

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

How many edges the draft currently has — each gets a midpoint handle. A closed polygon has as many edges as points (the last one wraps around); a polygon with only 2 points is still just a line, and a polyline has one fewer edge than points. A marker has none.

Link copied to clipboard
Link copied to clipboard

Whether the draft's last point connects back to the first: only a polygon with the 3 points it takes to enclose anything.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open fun styleStateFor(entityId: EntityId): StyleState

Which StyleState should be rendered in while the engine is in this mode: StyleState.EDITING or StyleState.SELECTED for the one entity Edit/Select names, StyleState.DEFAULT for every other entity and every other mode. HOVER and DISABLED aren't derivable from a mode — nothing in the engine produces them yet.