Class: UppKonvaModel
Defined in: upp-konva-model.ts:41
Live scene state bound to the upp-konva host (engine via UppKonvaStage and floorPlanModel).
model.area: live shapes andkindDTO.model.sceneModel(internal): same instance as the host’s internal floor plan.modedefaults toVIEW. UseEDITfor drag and the Konva transformer.- After
area.source,applyAreaFromSource, orarea.notifyPresentationDirty(), the scene updates;data-only mutations viashape.syncPresentationToStage()do not fire structuralonModelChanged. To delete rows:UppKonvaShape.remove(),UppKonvaArea.removeShapes, orUppKonvaGroup.remove(). - The host syncs structural engine changes back to the public area (including tables and
data.shape). - The host’s
(onSelect)deliversarea.shapesinstances aligned with the canvas. - In
EDIT,pushUndoSnapshot/undooperate on copies of thearea.sourceDTO.
See
../component/upp-konva-component.ts
Implements
UppKonvaDestroy
Constructors
Constructor
new UppKonvaModel(
area):UppKonvaModel
Defined in: upp-konva-model.ts:52
Creates the model, the live area, and the internal Konva engine.
Parameters
area
Initial DTO (width, height, shapes with kind per row). Optional: name, orientation, mode,
presentation preferences, etc.
Returns
UppKonvaModel
Properties
marginPx
marginPx: [
number,number,number,number]
Defined in: upp-konva-model.ts:98
CSS pixel margins between the host edge and the usable plan rectangle: [top, right, bottom, left].
onModelChanged
onModelChanged: (() =>
void) |null=null
Defined in: upp-konva-model.ts:108
Optional callback fired only when the structural shape list changes (id + kind order), not for purely visual
mutations or in-place geometry edits.
pixelRatioMax
pixelRatioMax:
number=2
Defined in: upp-konva-model.ts:100
Upper bound for devicePixelRatio applied to Konva canvases.
viewZoom
viewZoom:
number=1
Defined in: upp-konva-model.ts:102
Multiplier (≥ 0.25) on the automatic framing scale of the plan.
Accessors
area
Get Signature
get area():
UppKonvaArea
Defined in: upp-konva-model.ts:114
Live floor-plan area (same instance for the model’s lifetime).
To apply data: applyAreaFromSource or assign area.source.
Returns
canUndo
Get Signature
get canUndo():
boolean
Defined in: upp-konva-model.ts:158
Whether at least one snapshot exists for undo().
Returns
boolean
mode
Get Signature
get mode():
UppKonvaEditMode
Defined in: upp-konva-model.ts:122
Canvas interaction mode: VIEW (read-only / selection) or EDIT (transformer, drag).
Does not emit onModelChanged.
Returns
Set Signature
set mode(
value):void
Defined in: upp-konva-model.ts:126
Parameters
value
Returns
void
presentationEpoch
Get Signature
get presentationEpoch():
number
Defined in: upp-konva-model.ts:153
Presentation repaint counter from the engine (same value the upp-konva host uses for [presentationEpoch]).
Useful for diagnostics or demos; not part of the persisted plan contract.
Returns
number
theme
Get Signature
get theme():
UppKonvaTheme|null
Defined in: upp-konva-model.ts:136
Theme preset (UPPKONVA_*); combinable with the upp-konva [theme] input.
Returns
UppKonvaTheme | null
Set Signature
set theme(
value):void
Defined in: upp-konva-model.ts:140
Parameters
value
UppKonvaTheme | null | undefined
Returns
void
Methods
applyAreaFromSource()
applyAreaFromSource(
source):void
Defined in: upp-konva-model.ts:174
Replaces area contents from a DTO without changing the model.area reference (assigns area.source internally).
Parameters
source
Full UppKonvaAreaSource.
Returns
void
Remarks
onModelChanged fires only when the structural shape list changes (id + kind order). Room-only or
orientation-only changes repaint without that signal.
doDestroy()
doDestroy():
void
Defined in: upp-konva-model.ts:79
Unsubscribes and tears down shapes. Idempotent; call when destroying the component that owns the model.
Returns
void
Implementation of
UppKonvaDestroy.doDestroy
doRefresh()
doRefresh():
void
Defined in: upp-konva-model.ts:242
Requests a canvas repaint without firing onModelChanged.
Returns
void
exportModel()
exportModel():
string
Defined in: upp-konva-model.ts:256
Serializes the plan to versioned document JSON (includes schemaVersion when applicable).
Returns
string
JSON string; empty string if the model was already destroyed.
exportToPng()
exportToPng(
options?):Promise<Blob|null>
Defined in: upp-konva-model.ts:292
Exports a PNG snapshot of the mounted canvas.
Parameters
options?
UppFloorPlanExportPngOptions
Engine export options (resolution, etc.).
Returns
Promise<Blob | null>
Image Blob, or null if the stage is not ready or the model was destroyed.
importModel()
importModel(
json):boolean
Defined in: upp-konva-model.ts:269
Parses a JSON document and replaces area contents when valid.
Parameters
json
string
Document produced by exportModel or compatible with the package schema.
Returns
boolean
true when applied successfully.
pushUndoSnapshot()
pushUndoSnapshot():
void
Defined in: upp-konva-model.ts:195
Pushes a copy of area.source for undo() (only in EDIT). Skips consecutive duplicates.
The upp-konva host calls this before applying geometry from the stage.
Returns
void
undo()
undo():
boolean
Defined in: upp-konva-model.ts:221
Restores the last snapshot pushed via pushUndoSnapshot.
Returns
boolean
true when a state was restored.