MyScript Interactive Ink SDK 4.5.0
Public Member Functions | List of all members
myscript::iink::MathSolverController Class Referenceabstract

#include <MathSolverController.h>

Public Member Functions

virtual ~MathSolverController ()=default
 
virtual std::vector< String > getAvailableActions (const String &blockId, std::shared_ptr< ParameterSet > overrideConfiguration=nullptr)=0
 
virtual String getActionOutput (const String &blockId, const String &action, MimeType mimeType, std::shared_ptr< ParameterSet > overrideConfiguration=nullptr)=0
 
virtual void applyAction (const String &blockId, const String &action, std::shared_ptr< ParameterSet > overrideConfiguration=nullptr)=0
 
virtual MathDiagnostic getDiagnostic (const String &blockId, const String &task, std::shared_ptr< ParameterSet > overrideConfiguration=nullptr)=0
 
virtual std::vector< MathEvaluationVariables > getEvaluables (const String &blockId)=0
 
virtual std::vector< std::vector< graphics::PointD > > evaluate (const String &blockId, const MathEvaluationVariables &variables, double from, double to, int pointCount, std::shared_ptr< ParameterSet > overrideConfiguration=nullptr)=0
 
virtual MathVariableDefinition asVariableDefinition (const String &blockId)=0
 
virtual std::vector< MathVariableDefinitions > getVariableDefinitions ()=0
 
virtual std::vector< MathVariableInfo > getVariables (const String &blockId)=0
 
virtual double getVariableValue (const String &blockId, const String &name)=0
 
virtual void setVariableValue (const String &blockId, const String &name, double value)=0
 
virtual bool removeVariableValue (const String &blockId, const String &name)=0
 
virtual std::shared_ptr< MathExternalExpression > parseExternalExpression (const String &expression, MimeType mimeType)=0
 

Detailed Description

The MathSolverController allows to configure and run math operations on an editor.

Note
following limitation applies: the part managed by the associated editor must be a "Raw Content" and the specified blocks must be of type "Math".
See also
Editor.
OffscreenEditor.
Since
4.0

Constructor & Destructor Documentation

◆ ~MathSolverController()

virtual myscript::iink::MathSolverController::~MathSolverController ( )
virtualdefault

Member Function Documentation

◆ getAvailableActions()

virtual std::vector< String > myscript::iink::MathSolverController::getAvailableActions ( const String &  blockId,
std::shared_ptr< ParameterSet >  overrideConfiguration = nullptr 
)
pure virtual

Returns the available actions for the specified block.

Parameters
blockIdthe identifier of the block.
overrideConfigurationthe extra configuration used.
Returns
an array of the available actions.
Exceptions
std::invalid_argumentwhen blockId is invalid.
std::invalid_argumentwhen overrideConfiguration is invalid.
std::runtime_errorwhen associated part type is not "Raw Content" or block type is not "Math".

◆ getActionOutput()

virtual String myscript::iink::MathSolverController::getActionOutput ( const String &  blockId,
const String &  action,
MimeType  mimeType,
std::shared_ptr< ParameterSet >  overrideConfiguration = nullptr 
)
pure virtual

Returns the output for the given action and the specified block.

Parameters
blockIdthe identifier of the block.
actionthe action operated by the math solver.
mimeTypethe MIME type that specifies the output format, either JIIX or LATEX.
overrideConfigurationthe extra configuration used.
Returns
a string representing the output formatted with the given MIME type.
Exceptions
std::invalid_argumentwhen blockId is invalid.
std::invalid_argumentwhen action is invalid
std::invalid_argumentwhen the specified MIME type is not supported.
std::invalid_argumentwhen overrideConfiguration is invalid.
std::runtime_errorwhen associated part type is not "Raw Content" or block type is not "Math".

◆ applyAction()

virtual void myscript::iink::MathSolverController::applyAction ( const String &  blockId,
const String &  action,
std::shared_ptr< ParameterSet >  overrideConfiguration = nullptr 
)
pure virtual

Applies the solved action of the specified block to the rendering.

Note
following limitation applies: incompatible with Offscreen interactivity service.
Parameters
blockIdthe identifier of the block.
actionthe action used by the math solver.
overrideConfigurationthe extra configuration used.
Exceptions
std::invalid_argumentwhen blockId is invalid.
std::invalid_argumentwhen action is invalid.
std::invalid_argumentwhen overrideConfiguration is invalid.
std::runtime_errorwhen associated part type is not "Raw Content" or block type is not "Math".
std::runtime_errorwhen associated with an offscreen editor.

◆ getDiagnostic()

virtual MathDiagnostic myscript::iink::MathSolverController::getDiagnostic ( const String &  blockId,
const String &  task,
std::shared_ptr< ParameterSet >  overrideConfiguration = nullptr 
)
pure virtual

Returns the diagnostic info for the given task and the specified block.

Parameters
blockIdthe identifier of the block.
taskthe task to diagnose: either "numerical-computation" or "evaluation".
overrideConfigurationthe extra configuration used.
Returns
a diagnostic code.
Exceptions
std::invalid_argumentwhen blockId is invalid.
std::invalid_argumentwhen task is invalid.
std::invalid_argumentwhen overrideConfiguration is invalid.
std::runtime_errorwhen associated part type is not "Raw Content" or block type is not "Math".
Since
4.1

◆ getEvaluables()

virtual std::vector< MathEvaluationVariables > myscript::iink::MathSolverController::getEvaluables ( const String &  blockId)
pure virtual

Returns the list of variable names that can be evaluated in the specified block. A block with no syntax error can be evaluated when it contains:

  • a variable definition
  • a single (multi-occurrence) undefined variable and no equal sign
  • an equal sign and two undefined variables, with at least one being a single-occurrence Returns an empty list if block cannot be evaluated.

Example: a math block containing "y = x^3 + 2x + 1" can evaluate: { in:"x", out:"y" } a math block containing "2 * y = x - 1" can evaluate: {{ in:"x", out:"y" }, { in:"y", out:"x" }} a math block containing "y = 3 * 4" can evaluate: { in:"", out:"y" } a math block containing "sin(x) + x/2" can evaluate: { in:"x", out:"" }

Note
in case both variables can be evaluated interchangeably, the first returned MathEvaluationVariables will use the (leftmost) isolated variable as output if any. Example: "y = cos(x) + 1" will always return: {{ in:"x", out:"y" }, { in:"y", out:"x" }} in that order.
Parameters
blockIdthe identifier of the block.
Returns
a list of MathEvaluationVariables that can be evaluated.
Exceptions
std::invalid_argumentwhen blockId is invalid.
std::runtime_errorwhen associated part type is not "Raw Content" or block type is not "Math".
Since
4.1

◆ evaluate()

virtual std::vector< std::vector< graphics::PointD > > myscript::iink::MathSolverController::evaluate ( const String &  blockId,
const MathEvaluationVariables &  variables,
double  from,
double  to,
int  pointCount,
std::shared_ptr< ParameterSet >  overrideConfiguration = nullptr 
)
pure virtual

Returns the list of points resulting from evaluating the given variables in the specified block.

Example: for "y = 2x", evaluate(blockId, { in:"x", out:"y" }, -1, 1, 3) returns { {-1, -2}, {0, 0}, {1, 2} }

Parameters
blockIdthe identifier of the block.
variablesthe variables to evaluate.
fromthe start of the range to evaluate.
tothe end of the range to evaluate.
pointCountthe number of values to evaluate between [from, to].
overrideConfigurationthe extra configuration used.
Returns
a list of evaluated points, representing continuous parts of a curve. With point.x being the input value and point.y the evaluated variable output.
Exceptions
std::invalid_argumentwhen blockId is invalid.
std::invalid_argumentwhen variables are not evaluables.
std::invalid_argumentwhen from or to is not a number.
std::invalid_argumentwhen from is greater than to.
std::invalid_argumentwhen pointCount is not in [1, 10000].
std::invalid_argumentwhen overrideConfiguration is invalid.
std::runtime_errorwhen associated part type is not "Raw Content" or block type is not "Math".
Since
4.1

◆ asVariableDefinition()

virtual MathVariableDefinition myscript::iink::MathSolverController::asVariableDefinition ( const String &  blockId)
pure virtual

Checks if the specified block represents a variable definition and returns the associated information. A block represents a variable definition if it is an equation with a single variable on the left of the equal sign and at least one constant expression on the right (first value is used). Example: "a = 1/2" or "b = 1/3 = 0.33"

Parameters
blockIdthe identifier of the block.
Returns
the name and value of the defined variable if any, otherwise an invalid definition.
Exceptions
std::invalid_argumentwhen blockId is invalid.
std::runtime_errorwhen associated part type is not "Raw Content" or block type is not "Math".
Since
4.1

◆ getVariableDefinitions()

virtual std::vector< MathVariableDefinitions > myscript::iink::MathSolverController::getVariableDefinitions ( )
pure virtual

Returns the list of all variable definitions.

Returns
the list of all variable definitions.
Exceptions
std::runtime_errorwhen associated part type is not "Raw Content".
Since
4.2

◆ getVariables()

virtual std::vector< MathVariableInfo > myscript::iink::MathSolverController::getVariables ( const String &  blockId)
pure virtual

Retrieves information about defined variables, associated with the specified block or from global variables.

Parameters
blockIdthe identifier of the block whose variables are to be retrieved, or empty for global variables.
Returns
a vector containing the information of all variables.
Exceptions
std::invalid_argumentwhen blockId is invalid.
std::runtime_errorwhen associated part type is not "Raw Content" or block type is not "Math".
Since
4.1

◆ getVariableValue()

virtual double myscript::iink::MathSolverController::getVariableValue ( const String &  blockId,
const String &  name 
)
pure virtual

Returns the value associated with the given variable name, for the specified block or as global variable.

Parameters
blockIdthe identifier of the block, or empty for global variable.
namethe variable name.
Returns
a variable value.
Exceptions
std::invalid_argumentwhen blockId is invalid.
std::invalid_argumentif name is not an existing variable name.
std::runtime_errorwhen associated part type is not "Raw Content" or block type is not "Math".
Since
4.1

◆ setVariableValue()

virtual void myscript::iink::MathSolverController::setVariableValue ( const String &  blockId,
const String &  name,
double  value 
)
pure virtual

Sets the value associated with the given variable name, for the specified block or as global variable.

Note
API variables have priority over BLOCK variables, which have priority over API_GLOBAL variables. PREDEFINED variables cannot be redefined.
Parameters
blockIdthe identifier of the block, or empty for global variable.
namethe variable name.
valuethe variable value.
Exceptions
std::invalid_argumentwhen blockId is invalid.
std::invalid_argumentwhen name is an invalid variable name.
std::invalid_argumentwhen value is an invalid variable value.
std::runtime_errorwhen associated part type is not "Raw Content" or block type is not "Math".
Since
4.1

◆ removeVariableValue()

virtual bool myscript::iink::MathSolverController::removeVariableValue ( const String &  blockId,
const String &  name 
)
pure virtual

Removes the definition of the given variable name, for the specified block or as global variable.

Parameters
blockIdthe identifier of the block, or empty for global variable.
namethe variable name.
Returns
true if the variable existed, otherwise false.
Exceptions
std::invalid_argumentwhen blockId is invalid.
std::runtime_errorwhen associated part type is not "Raw Content" or block type is not "Math".
Since
4.1

◆ parseExternalExpression()

virtual std::shared_ptr< MathExternalExpression > myscript::iink::MathSolverController::parseExternalExpression ( const String &  expression,
MimeType  mimeType 
)
pure virtual

Creates a math external expression from a string, using a copy of Editor current configuration.

Parameters
expressionthe math expression to parse.
mimeTypethe mime type of the expression. Only MimeType::LATEX is currently supported.
Returns
a math external expression.
Exceptions
std::invalid_argumentwhen expression is invalid.
std::invalid_argumentwhen the specified MIME type is not supported.
Since
4.2

The documentation for this class was generated from the following file: