Milo  0.1
Milo:EquationManipulationProgram
milo.h
Go to the documentation of this file.
1 #ifndef __MILO_H
2 #define __MILO_H
3 
4 /* Copyright (C) 2017 - James Terman
5  *
6  * milo is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * milo is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
29 #include <string>
30 #include <memory>
31 #include <complex>
32 #include <iostream>
33 #include <fstream>
34 #include <sstream>
35 #include <vector>
36 #include <ctime>
37 #include <algorithm>
38 #include <typeindex>
39 
40 #include "util.h"
41 #include "xml.h"
42 #include "smart.h"
43 
44 // Forward class declerations
45 namespace UI { class Graphics; }
46 class Node;
47 class Term;
48 class Expression;
49 class Input;
50 class Equation;
51 
52 // Hidden class declerations for pointers and reference
53 class Parser;
54 class EqnXMLParser;
55 
58 using Complex = std::complex<double>;
65 using EqnPtr = std::shared_ptr<Equation>;
66 
67 
72 class Node : public std::enable_shared_from_this<Node>
73 {
74 public:
86  enum Select { NONE, START, END, ALL };
87 
92  static const std::vector<std::string> select_tags;
93 
99  struct Frame { Box box; int base; };
100 
110  Node(Node* parent = nullptr, bool fNeg = false, Select s = NONE ) :
111  m_parent(parent), m_sign(!fNeg), m_select(s) {}
112 
119  Node(EqnXMLParser& in, Node* parent);
120 
121  virtual ~Node() {}
122 
123 
130  virtual std::string toString() const=0;
131 
137  virtual bool isLeaf() const { return true; }
138 
144  virtual bool isFactor() const { return true; }
145 
154  virtual Node* findNode(int x, int y);
155 
162  virtual Node* findNode(const Box& b);
163 
170  virtual int numFactors() const { return 1; }
171 
175  virtual void normalize() {}
176 
181  virtual bool simplify() { return false; }
182 
189  virtual bool less(NodePtr b) const { return this->toString() < b->toString(); }
190 
195  virtual const std::string& getName() const=0;
196 
201  virtual std::type_index getType() const=0;
203 
208  void calculateSize(UI::Graphics& gc);
209 
214  void out(XML::Stream& xml);
215 
223  void calculateOrigin(UI::Graphics& gc, int x, int y);
224 
229  void setUpDraw(UI::Graphics& gc);
230 
235  void draw(UI::Graphics& gc) const;
236 
241  void setSelect(Select s) { m_select = s; }
242 
247  Select getSelect() const { return m_select; }
248 
253  void setDrawParenthesis(bool fDrawPar) { m_fDrawParenthesis = fDrawPar; }
254 
259  bool getDrawParenthesis() const { return m_fDrawParenthesis; }
260 
265  const Frame& getFrame() const { return m_frame; }
266 
271  Node* first();
272 
277  Node* last();
278 
283  Node* getNextLeft();
284 
289  Node* getNextRight();
290 
294  void setParent(Node* parent) { m_parent = parent; }
295 
300  Node* getParent() const { return m_parent; }
301 
306  int getDepth() const { return getDepth(0); }
311  int getNth() const { return m_nth; }
312 
317  void addNth(int n) { m_nth += n; }
318 
323  void multNth(int n) { m_nth *= n; }
324 
329  void setNth(int n) { m_nth = n; }
330 
334  void negative() { m_sign = !m_sign; }
335 
340  bool getSign() const { return m_sign; }
341 
346  Complex getValue() const;
347 
354  static bool createNodeByName(std::string name, Equation& eqn);
355 
361  std::shared_ptr<Node> getSharedPtr()
362  {
363  std::shared_ptr<Node> sp;
364  try {
365  sp = this->shared_from_this();
366  }
367  catch (std::exception& ex) {
368  sp = std::shared_ptr<Node>(this);
369  }
370  return sp;
371  }
372 
373 private:
381  virtual Node* downLeft() { return nullptr; }
382 
388  virtual Node* downRight() { return nullptr; }
389 
395  virtual Node* getLeftSibling(Node*) { return nullptr; }
396 
402  virtual Node* getRightSibling(Node*) { return nullptr; }
403 
410  virtual Frame calcSize(UI::Graphics& gc)=0;
411 
418  virtual void calcOrig(UI::Graphics& gc, int x, int y)=0;
419 
424  virtual void drawNode(UI::Graphics& gc) const=0;
425 
430  virtual Complex getNodeValue() const=0;
431 
436  virtual void xml_out(XML::Stream& xml) const=0;
438 
444  int getDepth(int depth) const {
445  return (!m_parent) ? depth : m_parent->getDepth(++depth);
446  }
447 
449  bool m_sign;
453  int m_nth = 1;
454  bool m_fDrawParenthesis = false;
455 };
456 
460 class Term : public Node
461 {
462 public:
470  Term(Parser& p, Expression* parent = nullptr) : Node((Node*) parent) { while(add(p)); }
471 
478  Term(EqnXMLParser& in, Node* parent = nullptr);
479 
485  Term(NodeVector& f, Expression* parent) : Node((Node*) parent) { factors.swap(f); }
486 
493  Term(Node* node, Expression* parent = nullptr, bool fNeg = false) :
494  Node((Node*) parent, fNeg), factors(node)
495  {
496  node->setParent(this);
497  }
498 
502  ~Term() {}
504 
511  static Node* parse(Parser& p, Node* parent = nullptr);
512 
520  std::string toString() const;
521 
526  bool isLeaf() const { return false; }
527 
532  bool isFactor() const { return false; }
533 
540  Node* findNode(int x, int y);
541 
548  Node* findNode(const Box& b);
549 
554  int numFactors() const;
555 
562  void normalize();
563 
568  bool simplify();
569 
574  const std::string& getName() const { return name; }
575 
580  std::type_index getType() const { return type; }
582 
583  static const std::string name;
584  static const std::type_index type;
585 
591  void simplify(NodePtr ref, TermPtr new_term);
592 
602 
608  static void insertAfterMe(Node* me, NodePtr node);
609 
613  void setParent() { for ( auto f : factors ) f->setParent(this); }
614 
619  void setParent(Expression* parent) { Node::setParent((Node*) parent); }
620 
625  NodeIter begin() { return factors.begin(); }
626 
631  NodeIter end() { return factors.end(); }
632 
638  static NodeIter pos(Node* me);
639 
644  void multiply(double n);
645 
650  void multiply(TermPtr old_term);
651 
657  std::shared_ptr<Term> getSharedPtr()
658  {
659  return std::dynamic_pointer_cast<Term>(this->Node::getSharedPtr());
660  }
661 
662  friend class FactorIterator;
663 private:
666 
674  Node* downLeft() { return factors.front(); }
675 
681  Node* downRight() { return factors.back(); }
682 
688  Node* getLeftSibling(Node* node);
689 
696  Node* getRightSibling(Node* node);
697 
702  Complex getNodeValue() const;
703 
708  void xml_out(XML::Stream& xml) const;
709 
715  Frame calcSize(UI::Graphics& gc);
716 
723  void calcOrig(UI::Graphics& gc, int x, int y);
724 
729  void drawNode(UI::Graphics& gc) const;
731 
736  bool add(Parser& p);
737 };
738 
744 class Expression : public Node
745 {
746 public:
755  Expression(EqnXMLParser& in, Node* parent = nullptr);
756 
762  Expression(Parser& p, Node* parent = nullptr) : Node(parent)
763  {
764  while(add(p));
765  setDrawParenthesis(true);
766  }
767 
773  Expression(Term* term, Node* parent = nullptr) : Node(parent), terms(term)
774  {
775  term->setParent(this); setDrawParenthesis(true);
776  }
777 
783  Expression(Node* factor, Node* parent = nullptr) :
784  Node(parent), terms(new Term(factor, this))
785  {
786  factor->setParent(terms[0]); setDrawParenthesis(true);
787  }
788 
794 
802  std::string toString() const;
803 
808  bool isLeaf() const { return false; }
809 
816  Node* findNode(int x, int y);
817 
824  Node* findNode(const Box& b);
825 
830  int numFactors() const;
831 
838  void normalize();
839 
844  bool simplify();
845 
850  const std::string& getName() const { return name; }
851 
856  std::type_index getType() const { return type; }
858 
859  static const std::string name;
860  static const std::type_index type;
861 
866  int numTerms() const { return terms.size(); }
867 
871  void setParent() { for ( auto t : terms ) t->setParent(this); }
872 
877  TermVector::iterator begin() { return terms.begin(); }
878 
883  TermVector::iterator end() { return terms.end(); }
884 
892  static Term* getTerm(Equation& eqn, const std::string& text, Expression* parent = nullptr);
893 
900  static Term* getTerm(Parser& p, Expression* parent);
901 
908  static Node* parse(Parser& p, Node* parent);
909 
915  void add(double n);
916 
921  void add(ExpressionPtr old_expr);
922 
923  friend class FactorIterator;
924 private:
927 
935  Node* downLeft() { return terms.front(); }
936 
942  Node* downRight() { return terms.back(); }
943 
949  Node* getLeftSibling(Node* node);
950 
956  Node* getRightSibling(Node* node);
961  void xml_out(XML::Stream& xml) const;
962 
968  Frame calcSize(UI::Graphics& gc);
969 
976  void calcOrig(UI::Graphics& gc, int x, int y);
977 
982  void drawNode(UI::Graphics& gc) const;
983 
988  Complex getNodeValue() const;
990 
996  bool add(Parser& p);
997 };
998 
1003 class NodeIterator : public std::iterator< std::bidirectional_iterator_tag, Node* >
1004 {
1005 private:
1007 
1008  void next();
1009  void prev();
1010 
1011 public:
1017  NodeIterator(Node* node) : m_node(node) {}
1018 
1025  Node*& operator*() { return m_node; }
1026 
1032  Node*& operator->() { return m_node; }
1033 
1039  bool operator==(const NodeIterator& rhs) { return m_node == rhs.m_node; }
1040 
1046  bool operator!=(const NodeIterator& rhs) { return m_node != rhs.m_node; }
1047 
1052  NodeIterator& operator++() { next(); return *this; }
1053 
1060  NodeIterator operator++(int) { NodeIterator tmp(*this); next(); return tmp; }
1061 
1066  NodeIterator& operator--() { prev(); return *this; }
1067 
1074  NodeIterator operator--(int) { NodeIterator tmp(*this); prev(); return tmp; }
1076 };
1077 
1082 class FactorIterator : public std::iterator< std::bidirectional_iterator_tag, Node* >
1083 {
1084  private:
1088  unsigned int m_factor_index;
1089  unsigned int m_term_index;
1090 
1091  void next();
1092  void prev();
1093 
1094 public:
1102  FactorIterator(Node* node);
1103 
1110 
1116  FactorIterator(Expression* expr);
1118 
1125  Node*& operator*() { return m_node; }
1126 
1132  Node*& operator->() { return m_node; }
1133 
1139  bool operator==(const FactorIterator& rhs) { return m_node == rhs.m_node; }
1140 
1146  bool operator!=(const FactorIterator& rhs) { return m_node != rhs.m_node; }
1147 
1153  bool operator>(const FactorIterator& rhs);
1154 
1160  bool operator>=(const FactorIterator& rhs);
1161 
1167  bool operator<(const FactorIterator& rhs);
1168 
1174  bool operator<=(const FactorIterator& rhs);
1175 
1180  FactorIterator& operator++() { next(); return *this; }
1181 
1188  FactorIterator operator++(int) { FactorIterator tmp(*this); next(); return tmp; }
1189 
1194  FactorIterator& operator--() { prev(); return *this; }
1195 
1202  FactorIterator operator--(int) { FactorIterator tmp(*this); prev(); return tmp; }
1204 
1211  void erase();
1212 
1219  void erase(const FactorIterator& end);
1220 
1224  void mergeNextTerm();
1225 
1231  Term* splitTerm(bool fNeg = false);
1232 
1237  void replace(Term* term);
1238 
1243  void replace(Node* node);
1244 
1250  void insert(Node* node);
1251 
1258  void insertAfter(Node* node);
1259 
1265  void insert(Term* node, bool sign = true);
1266 
1272  void insertAfter(Term* term, bool sign = true);
1273 
1278  bool isBegin() { return m_factor_index == 0 && m_term_index == 0; }
1279 
1284  bool isEnd() { return !m_node; }
1285 
1290  bool isBeginTerm() { return m_factor_index == 0; }
1291 
1296  bool isEndTerm();
1297 
1303  void setNode(int factor, int term);
1304 
1309  FactorIterator getBegin() { FactorIterator tmp(*this); tmp.setNode(0, 0); return tmp; }
1310 
1315  FactorIterator getLast() { FactorIterator tmp(*this); tmp.setNode(-1, -1); return tmp; }
1317 
1318  static void swap(FactorIterator& a, FactorIterator& b);
1319 };
1320 
1327 {
1328 public:
1335  Equation(const std::string& eq);
1336 
1341  Equation(std::istream& is);
1342 
1347  Equation(const Equation& eqn) { *this = eqn; }
1348 
1354 
1362  Equation& operator=(const Equation& eqn);
1363 
1364  Equation(Equation&& eqn)=delete;
1365  Equation& operator=(Equation&& eqn)=delete;
1366 
1367 
1373  std::string toString() const { return m_root->toString(); }
1374 
1379  void xml_out(std::ostream& os) const;
1380 
1385  void xml_out(std::string& str) const;
1386 
1392  void draw(UI::Graphics& gc, bool fRefresh = false);
1393 
1398  Equation* clone();
1399 
1404  bool blink() { return m_input_index >= 0; }
1405 
1411  void getCursorOrig(int& x, int& y);
1412 
1417  void setCurrentInput(int in_sn);
1418 
1423  void addInput(Input* in) { m_inputs.push_back(in); }
1424 
1429  void removeInput(Input* in);
1430 
1436  if (m_inputs.empty() || m_input_index < 0)
1437  return nullptr;
1438  else
1439  return m_inputs[m_input_index];
1440  }
1441 
1445  void nextInput(bool fShift);
1446 
1450  FactorIterator disableCurrentInput();
1451 
1456  void setSelectStart(Node* start) { m_selectStart = start; }
1457 
1462  void setSelectEnd(Node* end) { m_selectEnd = end; }
1463 
1464  void clearSelect();
1465 
1472  void setSelect(Node* start, Node* end = nullptr);
1473 
1478  void selectNodeOrInput(Node* node);
1479 
1487  void setSelectFromNode(Node* node);
1488 
1497  Node* findNode(UI::Graphics& gc, int x, int y);
1498 
1506  Node* findNode(UI::Graphics& gc, Box b);
1507 
1515  void selectBox(UI::Graphics& gc, Node* start, Box b);
1516 
1522  void eraseSelection(Node* node);
1523 
1529  bool simplify() { m_root->normalize(); return m_root->simplify(); }
1530 
1534  void normalize() { m_root->normalize(); }
1535 
1539  NodeIterator begin() { return NodeIterator(m_root->first()); }
1540 
1544  NodeIterator end() { return NodeIterator(nullptr); }
1545 
1549  NodeIterator last() { return NodeIterator(m_root->last()); }
1550 
1557  void insert(FactorIterator& it, const std::string& text);
1558 
1559  Node* getRoot() { return m_root; }
1560 
1561  Node* getSelectStart() { return m_selectStart; }
1562 
1563  Node* getSelectEnd() { return m_selectEnd; }
1564 private:
1566  std::vector<Input*> m_inputs;
1567  int m_input_index = -1;
1568  Node* m_selectStart = nullptr;
1569  Node* m_selectEnd = nullptr;
1570 
1575  void setSelect(UI::Graphics& gc);
1576 
1580  void factor(std::string text, NodeVector& factors, Node* parent);
1581 
1586  void xml_out(XML::Stream& xml) const;
1587 
1592  void xml_in(EqnXMLParser& in);
1593 };
1594 
1599 class Input : public Node
1600 {
1601 public:
1609  Input(Parser& p, Node* parent = nullptr);
1610 
1620  Input(Equation& eqn, std::string txt = std::string(), bool current = true, Node* parent = nullptr,
1621  bool neg = false, Node::Select s = Node::Select::NONE);
1622 
1628  Input(EqnXMLParser& in, Node* parent);
1629 
1630  ~Input() {}
1631 
1632 
1640  std::string toString() const;
1641 
1646  int numFactors() const { return m_typed.size(); }
1647 
1652  const std::string& getName() const { return name; }
1653 
1658  std::type_index getType() const { return type; }
1660 
1667  bool empty() const { return m_typed.empty(); }
1668 
1673  void add(char ch) { m_typed += std::string(1, ch); }
1674 
1679  void add(const std::string& s) { m_typed += s; }
1680 
1684  void remove() { m_typed.erase(m_typed.end() - 1); }
1685 
1689  void clear() { m_typed.clear(); }
1690 
1695  const std::string& getBuffer() { return m_typed; }
1696 
1702  bool checkSN(int sn) { return m_sn == sn; }
1707  bool getCurrent() { return m_current; }
1708 
1713  void setCurrent(bool current) { m_current = current; }
1714 
1718  void makeCurrent() { m_eqn.setCurrentInput(m_sn); }
1719 
1726  FactorIterator emptyBuffer();
1727 
1734  bool unremovable() { return getParent()->numFactors() == 0; }
1736 
1745  static Input* parse(Parser& p, Node* parent = nullptr);
1746 
1747  static const std::string name;
1748  static const std::type_index type;
1749 private:
1750  int m_sn;
1751  std::string m_typed;
1752  bool m_current;
1755 
1763  Frame calcSize(UI::Graphics& gc);
1764 
1771  void calcOrig(UI::Graphics& gc, int x, int y);
1772 
1777  void drawNode(UI::Graphics& gc) const;
1778 
1783  Complex getNodeValue() const;
1784 
1789  void xml_out(XML::Stream& xml) const;
1791 
1792  static int input_sn;
1793 };
1794 
1799 {
1800 public:
1805 
1809  void save(EqnPtr eqn);
1810 
1815  EqnPtr undo();
1816 
1821  EqnPtr top();
1822 
1823 private:
1824  std::vector<std::string> m_eqns;
1825 };
1826 #endif // __MILO_H
Term(Node *node, Expression *parent=nullptr, bool fNeg=false)
Definition: milo.h:493
~Expression()
Definition: milo.h:792
void clear()
Definition: milo.h:1689
const std::string & getName() const
Definition: milo.h:574
virtual Node * downRight()
Definition: milo.h:388
virtual Node * getRightSibling(Node *)
Definition: milo.h:402
bool unremovable()
Definition: milo.h:1734
TermVector terms
Expression owns this tree a list of terms.
Definition: milo.h:925
int m_sn
Unique serial number of Input class.
Definition: milo.h:1750
Definition: milo.h:45
void negative()
Definition: milo.h:334
Equation & m_eqn
Equation class object containing this input node.
Definition: milo.h:1753
Definition: xml.h:165
FactorIterator getBegin()
Definition: milo.h:1309
Definition: milo.h:72
Box m_internal
Bounding box of this node.
Definition: milo.h:665
bool getSign() const
Definition: milo.h:340
virtual int numFactors() const
Definition: milo.h:170
static void xml_in(const string &fname)
Definition: milo_test.cpp:280
FactorIterator getLast()
Definition: milo.h:1315
bool isLeaf() const
Definition: milo.h:808
FactorIterator & operator--()
Definition: milo.h:1194
Node *& operator*()
Definition: milo.h:1025
std::string m_typed
Stored type characters from keyboard.
Definition: milo.h:1751
void setDrawParenthesis(bool fDrawPar)
Definition: milo.h:253
TermVector::iterator begin()
Definition: milo.h:877
std::shared_ptr< Equation > EqnPtr
Shared pointer for equation.
Definition: milo.h:65
bool getCurrent()
Definition: milo.h:1707
static const std::type_index type
Type of this class.
Definition: milo.h:860
Term(Parser &p, Expression *parent=nullptr)
Definition: milo.h:470
static const std::string name
Name of Input class.
Definition: milo.h:1747
std::type_index getType() const
Definition: milo.h:1658
std::complex< double > Complex
Specialized as complex double.
Definition: milo.h:58
void setParent(Node *parent)
Definition: milo.h:294
typename std::vector< SmartPtr< Node > >::iterator iterator
Definition: smart.h:88
virtual void normalize()
Definition: milo.h:175
Definition: milo.h:1798
static const std::string name
Name of Term class.
Definition: milo.h:583
Expression * m_gpExpr
Grandparent expresson of current factor.
Definition: milo.h:1087
Term(NodeVector &f, Expression *parent)
Definition: milo.h:485
Node * getParent() const
Definition: milo.h:300
bool isLeaf() const
Definition: milo.h:526
void multNth(int n)
Definition: milo.h:323
static void simplify(const string &)
Definition: milo_test.cpp:345
TermVector::iterator end()
Definition: milo.h:883
NodeVector factors
Term owns this tree.
Definition: milo.h:664
NodeIterator & operator--()
Definition: milo.h:1066
bool m_sign
True if positve.
Definition: milo.h:449
const Frame & getFrame() const
Definition: milo.h:265
void add(const std::string &s)
Definition: milo.h:1679
Definition: parser.cpp:85
Input * getCurrentInput()
Definition: milo.h:1435
bool operator==(const NodeIterator &rhs)
Definition: milo.h:1039
Select m_select
Select state of this node.
Definition: milo.h:450
~Term()
Definition: milo.h:502
static void parse(const string &eqn_str)
EqnPanel class object.
Definition: milo_test.cpp:271
static void xml_out(const string &)
Definition: milo_test.cpp:288
NodeIterator operator++(int)
Definition: milo.h:1060
std::shared_ptr< Term > getSharedPtr()
Definition: milo.h:657
void setNode(int factor, int term)
Definition: milo.cpp:437
Node * downRight()
Definition: milo.h:942
const std::string & getBuffer()
Definition: milo.h:1695
virtual bool simplify()
Definition: milo.h:181
unsigned int m_factor_index
Index of current factor in parent term.
Definition: milo.h:1088
Definition: milo.h:1003
std::type_index getType() const
Definition: milo.h:856
void addInput(Input *in)
Definition: milo.h:1423
bool isEnd()
Definition: milo.h:1284
static int input_sn
Serial number of last created Input node.
Definition: milo.h:1792
void makeCurrent()
Definition: milo.h:1718
Box m_parenthesis
Rectangle that contains paranthesis of this node.
Definition: milo.h:452
Expression(Parser &p, Node *parent=nullptr)
Definition: milo.h:762
void setParent(Expression *parent)
Definition: milo.h:619
std::vector< std::string > m_eqns
List of pointer to equation objects in undo history.
Definition: milo.h:1824
bool checkSN(int sn)
Definition: milo.h:1702
const std::string & getName() const
Definition: milo.h:850
Definition: milo.h:744
NodePtr m_root
Equation owns this tree.
Definition: milo.h:1565
void addNth(int n)
Definition: milo.h:317
void add(char ch)
Definition: milo.h:1673
static const std::vector< std::string > select_tags
Definition: milo.h:92
Node * m_node
Current factor.
Definition: milo.h:1085
std::vector< Input * > m_inputs
List of input nodes in equation.
Definition: milo.h:1566
FactorIterator operator++(int)
Definition: milo.h:1188
virtual bool isLeaf() const
Definition: milo.h:137
Node *& operator->()
Definition: milo.h:1132
bool blink()
Definition: milo.h:1404
unsigned int m_term_index
Term index of current factor in grandparent expression.
Definition: milo.h:1089
NodeIterator operator--(int)
Definition: milo.h:1074
int getDepth(int depth) const
Definition: milo.h:444
bool isBegin()
Definition: milo.h:1278
NodeIterator last()
Definition: milo.h:1549
int getDepth() const
Definition: milo.h:306
Frame m_frame
Frame of this node includes enclosing rect and vertical offset.
Definition: milo.h:451
void setSelectStart(Node *start)
Definition: milo.h:1456
NodeIterator(Node *node)
Definition: milo.h:1017
FactorIterator & operator++()
Definition: milo.h:1180
bool getDrawParenthesis() const
Definition: milo.h:259
bool operator==(const FactorIterator &rhs)
Definition: milo.h:1139
Box m_internal
Bounding box of this node.
Definition: milo.h:926
Definition: milo.h:1326
bool simplify()
Definition: milo.h:1529
Definition: milo.h:99
Node(Node *parent=nullptr, bool fNeg=false, Select s=NONE)
Definition: milo.h:110
static const std::string name
Name of this class.
Definition: milo.h:859
NodeIter begin()
Definition: milo.h:625
void setSelect(Select s)
Definition: milo.h:241
FactorIterator(NodeIterator n)
Definition: milo.h:1109
Definition: milo.h:1599
~Equation()
Definition: milo.h:1352
EqnUndoList()
Definition: milo.h:1804
Node * downLeft()
Definition: milo.h:935
virtual bool isFactor() const
Definition: milo.h:144
Definition: ui.h:357
NodeIter end()
Definition: milo.h:631
static const std::type_index type
Type of Input class.
Definition: milo.h:1748
Select getSelect() const
Definition: milo.h:247
Node *& operator->()
Definition: milo.h:1032
virtual bool less(NodePtr b) const
Definition: milo.h:189
Box m_internal
Bounding box of Input node.
Definition: milo.h:1754
int numFactors() const
Definition: milo.h:1646
bool isFactor() const
Definition: milo.h:532
bool empty() const
Definition: milo.h:1667
const std::string & getName() const
Definition: milo.h:1652
virtual ~Node()
Abstract base class needs virtual desctructor.
Definition: milo.h:121
bool isBeginTerm()
Definition: milo.h:1290
Node *& operator*()
Definition: milo.h:1125
void setCurrent(bool current)
Definition: milo.h:1713
Node * m_parent
Parent node of this node. Can be null if root.
Definition: milo.h:448
bool operator!=(const NodeIterator &rhs)
Definition: milo.h:1046
Select
Definition: milo.h:86
static void normalize(const string &)
Definition: milo_test.cpp:338
NodeIterator begin()
Definition: milo.h:1539
int numTerms() const
Definition: milo.h:866
NodeIterator & operator++()
Definition: milo.h:1052
Expression(Term *term, Node *parent=nullptr)
Definition: milo.h:773
Equation(const Equation &eqn)
Definition: milo.h:1347
static const std::type_index type
Type of Term class.
Definition: milo.h:584
Term * m_pTerm
Parent term of current factor.
Definition: milo.h:1086
Node * m_node
Current node pointed to be iterator.
Definition: milo.h:1006
void setSelectEnd(Node *end)
Definition: milo.h:1462
FactorIterator operator--(int)
Definition: milo.h:1202
std::shared_ptr< Node > getSharedPtr()
Definition: milo.h:361
bool operator!=(const FactorIterator &rhs)
Definition: milo.h:1146
NodeVector::iterator NodeIter
Iterator into vector of node pointers.
Definition: milo.h:61
Expression(Node *factor, Node *parent=nullptr)
Definition: milo.h:783
Node * downRight()
Definition: milo.h:681
std::string toString() const
Definition: milo.h:1373
void setParent()
Definition: milo.h:871
virtual Node * getLeftSibling(Node *)
Definition: milo.h:395
Node * downLeft()
Definition: milo.h:674
void setNth(int n)
Definition: milo.h:329
int getNth() const
Definition: milo.h:311
~Input()
Virtual desctructor.
Definition: milo.h:1630
void setParent()
Definition: milo.h:613
Definition: milo.h:460
virtual Node * downLeft()
Definition: milo.h:381
Definition: milo.h:1082
bool m_current
True if current active Input class object.
Definition: milo.h:1752
std::type_index getType() const
Definition: milo.h:580
void normalize()
Definition: milo.h:1534
Definition: parser.cpp:43
NodeIterator end()
Definition: milo.h:1544