construct::ui::EditorScope
The construct builder for the expredit::Scope that the ExpressionEditor uses.
| Declared in | src/libs/libconstruct/construct/ui/EditorScope.hpp |
| Inherits | expredit::Scope |
| Group | construct |
Detailed description
The generic scope machinery is in expredit::Scope (§EXP-3). This class adds only the construct population of that scope. fromModel() fills it from a construct model: the instances, the varsets, the built-in variables, the math constants and the GLSL function list that the engine generates. forComponent() fills it for a formula inside a component definition.
The class was ExpressionContext until Phase 10c.
Member function documentation
componentPartParameters
[static] QList<construct::ui::ComponentPartParameter> EditorScope::componentPartParameters(const construct::component::ComponentDefinition &definition, const construct::registry::IDefinitionSource *primitives = nullptr, const construct::component::ComponentRegistry *components = nullptr)
Every editable parameter of every named part of a component definition: what a formula inside the component can read.
One list for two readers. The component dialog's Add menu offers each entry as "part ▸ parameter", and a choice adds a component parameter whose formula is ComponentPartParameter::reference() (construct-field-defects §CFD-D-11 item 1; the owner's answer to question 2 of §CFD-6). forComponent() puts the same entries in the formula editor's scope. A second enumeration would let the menu offer a name the editor marks red.
A part is a node of the definition's structure. Its name is its name in the component's namespace: the compiler gives each expanded core that name as its provenance's local name, and the expression manager binds `name.parameter` to it (§CPF-A3.2). A part without a name cannot be written in a formula and is left out.
A primitive part offers the parameters of its definition, as the parameter pickers do (fromModel()), minus the child slots, which are references and not values. The value is the part's own literal when it holds one, else the definition's default: a part parameter bound to an expression has no value of its own in the definition. A nested component offers its component parameters (`inner.p`, §CPF-A3.2), with the value the node sets, else the component's own.
definition is the component whose parts are listed. primitives is the definition source in which a primitive part resolves: the source of the document (overlay and catalog, as the compiler resolves it), or null for the shared Registry. components is the registry in which a nested component resolves, or null to leave nested components out.
Returns the entries, part by part in structure order. The parameters of each part are in the order of its definition.
forComponent
[static] construct::ui::EditorScope EditorScope::forComponent(const construct::component::ComponentDefinition &definition, const construct::registry::IDefinitionSource *primitives = nullptr, const construct::component::ComponentRegistry *components = nullptr)
The scope a formula in the component dialog is written in.
A component definition holds its own namespace and names no document (construct-component-parity §CPF-S7.1 rule 1): a derived parameter reads other component parameters, as `scallop_d = rim_d / 2` does in the pilot (rule 3). So the scope is the component's parameters by name, its own parts and their parameters (`rim.majorDiameter`, as the expression manager names them in a component scope, §CPF-A3.2), the built-in variables, math and the GLSL functions. A document name is not offered, because the component could not resolve it.
The owner asked for the same completion the expression editor gives elsewhere (construct-field-defects D11). The parts come from componentPartParameters(), the list the dialog's Add menu offers, so a formula the menu writes is one this scope accepts (§CFD-D-11).
definition is the component whose Parameters table is edited. primitives is where the parameters of a primitive part are found. When it is null, the shared Registry is used. components is where the parameters of a nested component are found. When it is null, nested components are left out.
Returns a scope for an ExpressionEditor in the Formula column of the table.