Skip to main content

Class: RestoreGeometry

Defined in: src/diagram/commands.ts:31

Command to restore element positions and sizes, link geometry (vertices) on a canvas.

Example:

const capturedGeometry = RestoreGeometry.capture(model);
// ... (move elements, change link vertices) ...
restoreGeometry = capturedGeometry.filterOutUnchanged();
if (restoreGeometry.hasChanges()) {
model.history.registerToUndo(restoreGeometry);
}

Implements​

Accessors​

title​

Get Signature​

get title(): TranslatedText

Defined in: src/diagram/commands.ts:68

Command title to display in the UI.

Returns​

TranslatedText

Command title to display in the UI.

Implementation of​

Command.title

Methods​

filterOutUnchanged()​

filterOutUnchanged(): RestoreGeometry

Defined in: src/diagram/commands.ts:87

Creates a derived RestoreGeometry command by removing any geometry state which is equal to the current diagram content geometry state.

This is useful to avoid adding a command without actual changes to the command history and to reduce the amount of memory to store captured geometry withing the command.

Returns​

RestoreGeometry


hasChanges()​

hasChanges(): boolean

Defined in: src/diagram/commands.ts:76

Returns true if command contains any captured geometry state to restore, otherwise false.

Returns​

boolean


invoke()​

invoke(): RestoreGeometry

Defined in: src/diagram/commands.ts:101

Performs the command action.

Returns​

RestoreGeometry

Inverse command to reverse changes done by the action.

Implementation of​

Command.invoke


capture()​

static capture(graph): RestoreGeometry

Defined in: src/diagram/commands.ts:46

Creates RestoreGeometry command with captured geometry for all diagram content.

Parameters​

ParameterType

graph

GraphStructure

Returns​

RestoreGeometry


capturePartial()​

static capturePartial(elements, links): RestoreGeometry

Defined in: src/diagram/commands.ts:54

Creates RestoreGeometry command with captured geometry for the specified subset of a diagram content.

Parameters​

ParameterType

elements

readonly Element[]

links

readonly Link[]

Returns​

RestoreGeometry