editor › Globals › IModelElement
Interface: IModelElement
A model element is part of the meta-level data structure. They convey high-level information and offer high-level modification methods.
A model element, for instance, is a Mesh that represents a volume, an Asset that defines what asset ID should be placed where, or an OrnamentDescriptor that knows what engravings should be drawn.
Model elements can depend on each other (see IModelElement.conceptsThisDependsOn) by using Anchors as a flexible way of defining the details (e.g. where on the mesh is the ornament placed?) of the dependency.
Model elements should be the ultimate source of truth, everything else should be generated based on the element's information and all modification should be done on the element to achieve a unidirectional data/change flow.
Model elements and Anchors should be designed so they are easily serializable/deserializable using serializer classes. They should be designed to be the target long-term storage format.
A model element usually has a realizer that transforms it into PhysicalObjects and Joints. There may be multiple ways to realize a model element, however, an element is only realized by one realizer at a time.
Hierarchy
- IModelElement
Implemented by
- CellDescriptor
- ParametricHoleDescriptor
- PlaceholderDescriptor
- RoundCornerDescriptor
- RoundEdgeDescriptor
- TessellationDescriptor
Index
Methods
- destroy
- disable
- enable
- getAssembly
- getChangeEventEmitter
- getElementsThisDependsOn
- getIsValid
- isEnabled
- setAssembly
Methods
destroy
▸ destroy(): void
Defined in src/model/data/Concepts/IModelElement.ts:64
This method should be called right before the model element's subgraph is removed from the assembly. In it, the ModelElement should destroy all anchors and deregister from any events to prevent memory leaks.
Returns: void
Optional disable
▸ disable(realizer1: any): void
Defined in src/model/data/Concepts/IModelElement.ts:70
Do not realize and undo realization. Used to disable realization persistently (eg a parametric hole disables other ornaments).
Parameters:
| Name | Type |
|---|---|
realizer1 |
any |
Returns: void
Optional enable
▸ enable(): void
Defined in src/model/data/Concepts/IModelElement.ts:75
Enable realization again and emit a change event.
Returns: void
getAssembly
▸ getAssembly(): Assembly
Defined in src/model/data/Concepts/IModelElement.ts:47
Get the assembly this concept belongs to
Returns: Assembly
getChangeEventEmitter
▸ getChangeEventEmitter(): IPublicEventEmitterInterface‹IModelElementEvent›
Defined in src/model/data/Concepts/IModelElement.ts:42
Should be emitted when the model element changes, so that the realization can be updated. As invalidity should not cause destructive actions, the event should not be emitted if the model element became invalid.
Returns: IPublicEventEmitterInterface‹IModelElementEvent›
getElementsThisDependsOn
▸ getElementsThisDependsOn(): IModelElement[]
Defined in src/model/data/Concepts/IModelElement.ts:35
A model element may depend on other model elements, i.e. if a model element A links to another ModelElement B with an anchor (and B being the anchor's target), A depends on B.
Such dependencies should make sense semantically, e.g. an Ornament depends on a Mesh via an anchor that points to a specific place on the mesh. They are used to determine the order in which model elements are realized.
ToDo: for the sake of consistency, one could refactor this to getModelElementDependencyDefiners, as with ToDo: IPositionableElement.getTransformsDefiner()
Returns: IModelElement[]
getIsValid
▸ getIsValid(): boolean
Defined in src/model/data/Concepts/IModelElement.ts:58
Returns: boolean
whether the model element currently is valid or not. As with IAnchor.getIsValid(), this should be lazily evaluated and no destructive action should be automatically performed if a ModelElement is invalid.
Optional isEnabled
▸ isEnabled(): boolean
Defined in src/model/data/Concepts/IModelElement.ts:80
Whether the realization is enabled.
Returns: boolean
setAssembly
▸ setAssembly(assembly: Assembly): any
Defined in src/model/data/Concepts/IModelElement.ts:52
Change the assembly this element belongs to. This should only be called by assemblies themselves.
Parameters:
| Name | Type |
|---|---|
assembly |
Assembly |
Returns: any