|
Milo
0.1
Milo:EquationManipulationProgram
|
#include <milo.h>

Public Member Functions | |
| std::string | toString () const |
| void | xml_out (std::ostream &os) const |
| void | xml_out (std::string &str) const |
| void | draw (UI::Graphics &gc, bool fRefresh=false) |
| Equation * | clone () |
| bool | blink () |
| void | getCursorOrig (int &x, int &y) |
| void | setCurrentInput (int in_sn) |
| void | addInput (Input *in) |
| void | removeInput (Input *in) |
| Input * | getCurrentInput () |
| void | nextInput (bool fShift) |
| FactorIterator | disableCurrentInput () |
| void | setSelectStart (Node *start) |
| void | setSelectEnd (Node *end) |
| void | clearSelect () |
| Clear current selection. | |
| void | setSelect (Node *start, Node *end=nullptr) |
| void | selectNodeOrInput (Node *node) |
| void | setSelectFromNode (Node *node) |
| Node * | findNode (UI::Graphics &gc, int x, int y) |
| Node * | findNode (UI::Graphics &gc, Box b) |
| void | selectBox (UI::Graphics &gc, Node *start, Box b) |
| void | eraseSelection (Node *node) |
| bool | simplify () |
| void | normalize () |
| NodeIterator | begin () |
| NodeIterator | end () |
| NodeIterator | last () |
| void | insert (FactorIterator &it, const std::string &text) |
| Node * | getRoot () |
| Node * | getSelectStart () |
| Node * | getSelectEnd () |
Constructors and Virtual Destructor | |
| Equation (const std::string &eq) | |
| Equation (std::istream &is) | |
| Equation (const Equation &eqn) | |
| ~Equation () | |
Overloaded Equal Operators | |
| Equation & | operator= (const Equation &eqn) |
| Equation (Equation &&eqn)=delete | |
| No move copy constructor. | |
| Equation & | operator= (Equation &&eqn)=delete |
| No move equal operator. | |
Private Member Functions | |
| void | setSelect (UI::Graphics &gc) |
| void | factor (std::string text, NodeVector &factors, Node *parent) |
| void | xml_out (XML::Stream &xml) const |
| void | xml_in (EqnXMLParser &in) |
Private Attributes | |
| NodePtr | m_root |
| Equation owns this tree. | |
| std::vector< Input * > | m_inputs |
| List of input nodes in equation. | |
| int | m_input_index = -1 |
| Index of current input. | |
| Node * | m_selectStart = nullptr |
| Node at start of selection. | |
| Node * | m_selectEnd = nullptr |
| Node at end of selection. | |
Holds the node tree that represents a mathematical equation. It also provides an interface for manipulating the nodes to algebraically transform the equation and to save, load and draw an equation.
| Equation::Equation | ( | const std::string & | eq | ) |
Constructor to load an equation represented by string such as 'a+b/c'.
| eq | String containing equation to be created. |
| Equation::Equation | ( | std::istream & | is | ) |
Constructor to load an equation from xml.
| is | Input stream containing xml. |
|
inline |
Copy constructor based on overloaded equal operator.
| eqn | Equation class object to be copied |
|
inline |
Destructor deletes node tree to clean up after itself.
|
inline |
Add new input node to this equation's list of inputs.
| in | New input node. |
|
inline |
Get left most node of equation.
|
inline |
Check where there is an active input in this equation object.
| Equation * Equation::clone | ( | ) |
Get equation object that is copy of this equation object.
| FactorIterator Equation::disableCurrentInput | ( | ) |
Remove current input node.
| void Equation::draw | ( | UI::Graphics & | gc, |
| bool | fRefresh = false |
||
| ) |
Draw equation in given graphic context.
| gc | Grahics context. |
| fRefresh | If true, complete all drawing to graphics context. |
|
inline |
Get end iterator of equation.
| void Equation::eraseSelection | ( | Node * | node | ) |
Erase current selection and replace with new node. If node parameter is null, selection will just be erased.
| node | Node to replace current selection. |
|
private |
Helper static function that parses term in string, load factors into array.
| Node * Equation::findNode | ( | UI::Graphics & | gc, |
| int | x, | ||
| int | y | ||
| ) |
Query root node for deepest node at coordinates x, y in given graphics context. Call findNode method of root node. If input node found, delete it and search again.
| gc | Graphics context. |
| x | Horizontal coordinate. |
| y | Vertical coordinate. |
| Node * Equation::findNode | ( | UI::Graphics & | gc, |
| Box | b | ||
| ) |
Query root node for shallowest factor node at inside rectangle box in given graphics context. Call findNode(UI::Graphics&, Box&) method of root node.
| gc | Graphics context. |
| b | Bounding box |
|
inline |
Get current input node.
| void Equation::getCursorOrig | ( | int & | x, |
| int & | y | ||
| ) |
Get coordinates of current active input.
| [out] | x | Horizontal origin of curosr. |
| [out] | y | Vertical origin cursor. |
| void Equation::insert | ( | FactorIterator & | it, |
| const std::string & | text | ||
| ) |
Use iterator to insert factors from parsed string.
| [in,out] | it | Iterator to position to insert factors. On exit points to factor after last factor inserted. |
| text | String to get parsed factors. |
|
inline |
Get right most node of equation.
| void Equation::nextInput | ( | bool | fShift | ) |
Get next input in list after current input node.
|
inline |
Normalize equation to standard format.
Overloaded equal operator that copies node tree from another object. Given equation object is serialized to xml and then deserialized into this object.
| eqn | Equation class object to be copied. |
| void Equation::removeInput | ( | Input * | in | ) |
Remove input node from equation's list of input nodes.
| in | Input node to be removed. |
| void Equation::selectBox | ( | UI::Graphics & | gc, |
| Node * | start, | ||
| Box | b | ||
| ) |
Select region starting from Node object start to last node still in bounding rectangle b.
| gc | Graphics context. |
| start | Starting node. |
| b | Bounding box. |
| void Equation::selectNodeOrInput | ( | Node * | node | ) |
| void Equation::setCurrentInput | ( | int | in_sn | ) |
Set current active input node.
| in_sn | Serial number of new active input. |
|
private |
Draw current selection in graphics context.
| gc | Graphics context. |
|
inline |
Set end of selection.
| void Equation::setSelectFromNode | ( | Node * | node | ) |
Set selection of this equation from selection state of node. If node has selection set to start, set as start of selection. If node has selection set to end, set as end of selection. If node has selection set to all, set as start and end of selection. return node Node whose selection state is referenced.
|
inline |
Set start of selection.
|
inline |
Simplify equation algebracially. Call normalize() method of root node and then simplifly().
|
inline |
Get string representation of equation. Example: '(a+b/c)'.
|
private |
| void Equation::xml_out | ( | std::ostream & | os | ) | const |
Serialize equation as xml to output stream.
| os | Output stream. |
| void Equation::xml_out | ( | std::string & | str | ) | const |
Serialize equation as xml to string.
| str | Output string object. |
|
private |
Output equation into output xml stream.
1.8.11