Skip to content

editorGlobalsIModelElementRealizer

Interface: IModelElementRealizer ‹ModelElement

A IModelElement realizer is responsible for translating a IModelElement into the realm of concrete PhysicalObjects and Joints.

Type parameters

ModelElement: IModelElement

Hierarchy

  • IModelElementRealizer

Implemented by

Index

Methods

Methods

beforeExport

beforeExport(): Promise‹void› | void

Defined in src/model/data/Concepts/Realization/IModelElementRealizer.ts:93

This will be called before Export, so that the realizer can make specific modifications to the modelelement and generated physical objects. This will only happen to cloned assemblies, so it doesn't affect the model seen in the editor.

Returns: Promise‹void› | void


checkValidityAndCleanUp

checkValidityAndCleanUp(): void

Defined in src/model/data/Concepts/Realization/IModelElementRealizer.ts:40

Check if the associated ModelElements and anchors are valid and clean up invalid elements by calling modelElement.destroy() and then subsequently removing its sub-graph from the assembly. (Consequently, onRemove() will be called, so physical objects should still be cleaned up in that method)

Realizers do this kind of work because there need to be well-defined, high-level points in which the ModelElement structure is cleaned up, as automatic cleanup leads to more problems than its convenience may suggest. Realizers are a good place for this, as they are called before a frame is rendered and after all tool logic is done.

Returns: void


Optional destroy

destroy(): void

Defined in src/model/data/Concepts/Realization/IModelElementRealizer.ts:122

When this Realizer is not referenced anymore, call this method. It should then perform any necessary cleanups of listeners etc. to avoid memory leaks.

Returns: void


findModelElement

findModelElementDesiredType›(desiredType: any, interactionData: IInteractionData, maxDistance?: number, strategy?: FindModelElementReturnStrategy): FoundModelElements‹DesiredType›

Defined in src/model/data/Concepts/Realization/IModelElementRealizer.ts:111

Queries the realizer for instances of desiredType. DesiredType will be enforced but not checked on the element field of the results.

Type parameters:

DesiredType

Parameters:

Name Type Description
desiredType any Which class the element field in the results should be an instance of. Used to tell the realizer what to look for, not for any typechecking. Might be an IModelElement, Mesh, MeshElement, MeshAnnotation or similar. Have a look at the realizer's implementation.
interactionData IInteractionData Used for computing distances and taking shortcuts when searching for best or first. Won't be changed.
maxDistance? number Elements with distances greater than maxDistance are ignored. Metric is up to the realizer (general rule of thumb: clicked objects get distance 0, not clicked objects get distance to the element's anchor and not the element's nearest point). Keep in mind that maxDistance = Infinity should return all elements.
strategy? FindModelElementReturnStrategy What to return, see IModelElementRealizer

Returns: FoundModelElements‹DesiredType›

An array of elements with their realizer and distance.


getAdditionalExportSvg

getAdditionalExportSvg(): Promise‹string | null›

Defined in src/model/data/Concepts/Realization/IModelElementRealizer.ts:86

There may be additional SVG parts that should be placed into the export. These should be returned as an svg string

Returns: Promise‹string | null›


getModelElement

getModelElement(): ModelElement

Defined in src/model/data/Concepts/Realization/IModelElementRealizer.ts:22

Reference to the IModelElement that is realized

Returns: ModelElement


onRemove

onRemove(removePhysicalObjects: boolean): void

Defined in src/model/data/Concepts/Realization/IModelElementRealizer.ts:80

Called when the concept is removed from the assembly, the realizer should remove what it has created.

Parameters:

Name Type
removePhysicalObjects boolean

Returns: void


realize

realize(targets: RealizedList, lastChangeEvent: IModelElementEvent, lastTransformsChangeEvent: ITransformsChangeEvent, hintManager?: any): Promise‹void› | void

Defined in src/model/data/Concepts/Realization/IModelElementRealizer.ts:55

Called when the realizer should realize / update the realization of the IModelElement.

Parameters:

Name Type Description
targets RealizedList model elements with their realizer (in the order of the IModelElement.getElementsThisDependsOn()). They have been realized before this instance.
lastChangeEvent IModelElementEvent the most recent change event that was emitted by the IModelElement (will only be provided once and cleared afterwards)
lastTransformsChangeEvent ITransformsChangeEvent the most recent transforms change event, if the element is a IPositionableElement (will only be provided once and cleared afterwards)
hintManager? any -

Returns: Promise‹void› | void

The return can either be void, in case of a synchronous call, or a Promise that resolves when the realization finished


recreateWith

recreateWith(otherModelElement: ModelElement): IModelElementRealizer‹ModelElement›

Defined in src/model/data/Concepts/Realization/IModelElementRealizer.ts:75

Realizers must be able to "clone" themselves, as in: produce a new instance with same settings for a given compatible IModelElement of same type.

Parameters:

Name Type Description
otherModelElement ModelElement the model element to be realized. Perform typeChecks in order to make sure that it is compatible.

Returns: IModelElementRealizer‹ModelElement›


setAssembly

setAssembly(assembly: Assembly): void

Defined in src/model/data/Concepts/Realization/IModelElementRealizer.ts:28

Sets the assembly that is supposed to contain the realization result

Parameters:

Name Type Description
assembly Assembly -

Returns: void


setPermanent

setPermanent(): void

Defined in src/model/data/Concepts/Realization/IModelElementRealizer.ts:66

Updates the realized element's properties based on the realization. Called at the end of a tool interaction.

Returns: void