OMD Documentation

omdEquationSequenceNode

Represents a sequence of equations or mathematical expressions, designed for step-by-step calculations and visual problem-solving. This node manages the vertical layout of multiple steps, ensuring elements like equals signs are vertically aligned for readability. It also provides robust provenance tracking, simplification capabilities, and filtering options for displaying different levels of detail.

Class Definition

export class omdEquationSequenceNode extends omdNode

Constructor

new omdEquationSequenceNode(steps)

Creates a new omdEquationSequenceNode instance.

Upon construction, the sequence initializes its internal state, sets up layout helpers, and builds a comprehensive node map for provenance tracking across all steps.

Static Properties

OPERATION_MAP

A static map that links common operation names (e.g., 'add') to the corresponding method names on omdEquationNode (e.g., 'addToBothSides').

{
    'add': 'addToBothSides',
    'subtract': 'subtractFromBothSides',
    'multiply': 'multiplyBothSides',
    'divide': 'divideBothSides',
}

Static Methods

fromStringArray(stepStrings)

Creates an omdEquationSequenceNode instance from an array of equation strings. Each string must contain an equals sign (=).

fromSteps(stepsArray)

Creates an omdEquationSequenceNode instance from an array of expression strings. This method is more flexible than fromStringArray as it can parse both full equations (containing =) and general mathematical expressions.

Public Properties

Public Methods

getCurrentEquation()

Retrieves the last omdEquationNode in the sequence, which typically represents the current working equation.

getCurrentStep()

Retrieves the currently active step node based on currentStepIndex and visibility. It prioritizes visible equation nodes.

addStep(step, descriptionOrOptions, importance)

Adds a new step to the sequence. This method supports multiple signatures:

setDefaultEquationBackground(style)

Sets a default background style that will be applied to all new omdEquationNode steps added to the sequence. It also applies the style to existing omdEquationNode steps immediately.

rebuildNodeMap()

Rebuilds the internal nodeMap, which is a comprehensive map of all omdNode instances within the entire sequence, including historical nodes referenced in provenance chains. This is crucial for accurate highlighting and provenance tracking.

recordSimplificationHistory(name, affectedNodes, message, metadata)

Records a simplification step in the sequence's history.

getSimplificationHistory()

Retrieves the complete simplification history for this sequence.

clearSimplificationHistory()

Clears all recorded simplification history entries.

setFontSize(fontSize)

Sets the font size for the entire sequence and propagates this setting to all individual steps. This triggers a re-computation of dimensions and layout.

applyEquationOperation(value, operation)

Applies a specified arithmetic operation to the current equation in the sequence and adds the result as a new step. This method also adds an omdOperationDisplayNode to visually represent the operation.

applyEquationFunction(functionName)

Applies a mathematical function (e.g., 'sqrt', 'log') to both sides of the current equation in the sequence and adds the result as a new step.

simplify()

Applies one round of simplification rules to the last step in the sequence. If simplifications are applied, a new step is added to the sequence.

simplifyAll(maxIterations)

Repeatedly calls simplify() until no more simplifications can be applied or maxIterations is reached. This adds multiple simplification steps to the sequence.

evaluate(variables)

Evaluates the current step in the sequence with the given variables and logs the result to the console.

validateSequenceProvenance()

Validates the integrity of provenance tracking across all steps in the sequence.

select() / deselect() / highlight(color) / clearProvenanceHighlights()

These methods override the default omdNode behavior. The omdEquationSequenceNode itself does not highlight or respond to selection events directly. Instead, these methods propagate the calls to their child steps, allowing individual steps to be highlighted or selected.

computeDimensions()

Calculates the overall dimensions (width and height) of the entire sequence, determining the correct alignment point for all equals signs.

updateLayout()

Positions each step vertically and aligns their equals signs to the calculated alignment point, ensuring a clean, readable layout.

toMathJSNode()

Converts the sequence to a math.js-compatible AST node. Currently, this returns the AST of the last step in the sequence.

Navigates to a specific step in the sequence by setting currentStepIndex.

nextStep()

Navigates to the next step in the sequence.

previousStep()

Navigates to the previous step in the sequence.

getFilteredSteps(maxImportance)

Retrieves steps filtered by their importance level.

renderCurrentStep()

Renders only the current step of the sequence.

toString()

Converts the entire sequence to a multi-line string representation, including step descriptions.

clear()

Removes all steps from the sequence, clears all associated data (descriptions, importance levels, history), and resets the sequence to its initial state.

show() / hide()

Overrides omdNode's show() and hide() to also update the visibility of the layout manager.

updateStepsVisibility(visibilityPredicate)

Updates the visibility of multiple steps at once based on a provided predicate function. Also applies font weights based on stepMark.

Internal Methods

↑ Top