Milo  0.1
Milo:EquationManipulationProgram
Static Public Member Functions | Static Public Attributes | Static Private Member Functions | List of all members
Power Class Reference

#include <nodes.h>

Inheritance diagram for Power:
Inheritance graph
[legend]
Collaboration diagram for Power:
Collaboration graph
[legend]

Public Member Functions

Constructor and Virtual Destructor
 Power (Node *one, Node *two, Node *parent, bool neg=false, Node::Select s=Node::Select::NONE)
 
 Power (EqnXMLParser &in, Node *parent)
 
 ~Power ()
 
Virtual Public Member Functions
const std::string & getName () const
 
std::type_index getType () const
 
void normalize ()
 
bool simplify ()
 
- Public Member Functions inherited from Binary
ExpressionPtr getFirstExpression ()
 
ExpressionPtr getSecondExpression ()
 
 Binary (char op, Node *one, Node *two, Node *parent, bool neg, Node::Select s)
 
 Binary (EqnXMLParser &in, Node *parent)
 
virtual ~Binary ()
 
std::string toString () const
 
bool isLeaf () const
 
Node * findNode (int x, int y)
 
Node * findNode (const Box &b)
 
int numFactors () const
 
- Public Member Functions inherited from Node
void calculateSize (UI::Graphics &gc)
 
void out (XML::Stream &xml)
 
void calculateOrigin (UI::Graphics &gc, int x, int y)
 
void setUpDraw (UI::Graphics &gc)
 
void draw (UI::Graphics &gc) const
 
void setSelect (Select s)
 
Select getSelect () const
 
void setDrawParenthesis (bool fDrawPar)
 
bool getDrawParenthesis () const
 
const Frame & getFrame () const
 
Node * first ()
 
Node * last ()
 
Node * getNextLeft ()
 
Node * getNextRight ()
 
void setParent (Node *parent)
 
Node * getParent () const
 
int getDepth () const
 
int getNth () const
 
void addNth (int n)
 
void multNth (int n)
 
void setNth (int n)
 
void negative ()
 
bool getSign () const
 
Complex getValue () const
 
std::shared_ptr< Node > getSharedPtr ()
 
 Node (Node *parent=nullptr, bool fNeg=false, Select s=NONE)
 
 Node (EqnXMLParser &in, Node *parent)
 
virtual ~Node ()
 Abstract base class needs virtual desctructor.
 
virtual bool isFactor () const
 
virtual bool less (NodePtr b) const
 

Static Public Member Functions

static bool create (Equation &eqn)
 
static bool simplify (NodeVector &factors)
 
- Static Public Member Functions inherited from Binary
static Node * parse (Parser &p, Node *one, Node *parent)
 
- Static Public Member Functions inherited from Node
static bool createNodeByName (std::string name, Equation &eqn)
 

Static Public Attributes

static const std::string name = "power"
 Name of Power class.
 
static const std::type_index type = typeid(Power)
 Type of Power class.
 
- Static Public Attributes inherited from Node
static const std::vector< std::string > select_tags = { "NONE", "START", "END", "ALL" }
 

Private Member Functions

Virtual Private Member Functions
Frame calcSize (UI::Graphics &gc)
 
void calcOrig (UI::Graphics &gc, int x, int y)
 
void drawNode (UI::Graphics &gc) const
 
Complex getNodeValue () const
 

Static Private Member Functions

static bool simplify (NodeVector::iterator a, NodeVector::iterator b)
 

Additional Inherited Members

- Public Types inherited from Node
enum  Select { NONE, START, END, ALL }
 
- Protected Attributes inherited from Binary
char m_op
 Character repesentation of operator.
 
NodePtr m_first
 First expression owned by this object.
 
NodePtr m_second
 Second expression owned by this object.
 
Box m_internal
 Bounding box of this node.
 

Detailed Description

Represents the Power operator. Inherits from Binary class and is drawn with the first expression to the power of the second expression.

Constructor & Destructor Documentation

Power::Power ( Node *  one,
Node *  two,
Node *  parent,
bool  neg = false,
Node::Select  s = Node::Select::NONE 
)
inline

Constructor for Power class.

Parameters
oneFirst expression.
twoSecond expression.
parentParent node.
negIf true, node is negative.
sSelection state of node.
Power::Power ( EqnXMLParser &  in,
Node *  parent 
)
inline

XML constructor for Divide class. Read in XML for Divide class.

Parameters
inXML input stream.
parentParent node object.
Power::~Power ( )
inline

Abstract base class needs virtual destructor.

Member Function Documentation

void Power::calcOrig ( UI::Graphics &  gc,
int  x,
int  y 
)
privatevirtual

Calculate origin of this node offset from the point (x,y) given it.

Parameters
gcGraphics context.
xHorizontal origin.
yVertical origin.

Implements Node.

Node::Frame Power::calcSize ( UI::Graphics &  gc)
privatevirtual

Calculate size of this node in given graphics context.

Parameters
gcGraphics context.
Returns
Return frame containing size of this node.

Implements Node.

bool Power::create ( Equation &  eqn)
static

Static helper function to create new Power node object. Create a new power node object at the eqn's current input.

Parameters
eqnEquation to create new power object.
Returns
bool True, if power object created.
void Power::drawNode ( UI::Graphics &  gc) const
privatevirtual

Draw this node in the given graphical context.

Parameters
gcGraphical context.

Implements Node.

const std::string& Power::getName ( ) const
inlinevirtual

Get name of this class.

Returns
Name of this class.

Implements Node.

Complex Power::getNodeValue ( ) const
privatevirtual

Get value of this subtree.

Returns
Complex value of this subtree.

Implements Node.

std::type_index Power::getType ( ) const
inlinevirtual

Get name of this class.

Returns
Name of this class.

Implements Node.

void Power::normalize ( )
virtual

Refactor subtree to a standard form. For Power class, replace (ab)^2(c^d)^2 with (a^2)(b^2)c^(2d)

Reimplemented from Node.

bool Power::simplify ( )
virtual

Attempt to algebraically simplify the subtree this node is the root.

Returns
True, if subtree was changed.

Reimplemented from Node.

bool Power::simplify ( NodeVector &  factors)
static

Static helper function for simplifying Power expressions. Simplify each node in the vector against every other node.

Returns
True, if node vector was changed.
bool Power::simplify ( NodeVector::iterator  a,
NodeVector::iterator  b 
)
staticprivate

Static helper function for simplifying Power expressions. If both iterators point to a Power object, see if they can be combined.

Parameters
aFirst iterator.
bSecond iterator.
Returns
True, if node vector was changed.

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