Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

mcMonomialHelpers Class Reference

#include <Monomial.h>

Inheritance diagram for mcMonomialHelpers:

Inheritance graph
[legend]
Collaboration diagram for mcMonomialHelpers:

Collaboration graph
[legend]
List of all members.

Detailed Description

A little class containing the DATA, MATH, GUI and IO sections of this element (as instances and not pointers).

This is entirely defined & implemented through macros.

Definition at line 60 of file Monomial.h.

Public Member Functions

int gui_GetSpaceBetweenRatio () const
 mcPolynomials have different space between ratio from mcPolynomials...
 mcMonomialHelpers ()
virtual ~mcMonomialHelpers ()
void data_Repair ()
 Repairs the array, adding the mcMultOp where they are required (for example, between two mcNumbers), removing them where they must not be present (for example, at the beginning/end of the array), and so on...
void data_TransformDivOp ()
 Transforms mcDivOps to mcFractions: 24ax/2*3 becomes ((24ax)/2)*3 (brackets have been added only to increase readability) Unlike mcMonomial::math_TransformDivOp(), this function does not use the mcElement::math_MakeReciprocal() function; it creates directly mcFractions that are then filled with the elements placed before & after the old mcDivOp.
wxXml2Node io_GetMathML (bool bGetPresentation) const
 Returns the MathML code for this element as presentation markup (http://www.w3.org/TR/MathML2/chapter3.html) or as content markup (http://www.w3.org/TR/MathML2/chapter4.html).
bool io_ImportPresentationMathML (wxXml2Node tag, wxString &pErr)
 Imports presentation MathML reading the contents of the given XML node (without modifying it).
bool io_ImportInlinedExpr (const wxString &, int *, wxString &pErr)
 Imports an inlined expression.
void io_PostProcess ()
 If the 'auto convert mcDivOp(s) to mcFraction(s)' feature is enabled (through #bAutoConvertDivOpToFractions) this function will remove all divop replacing them with mcFraction...
Array handlers
Functions which manipulates the mcElementArray.

int gui_AddNewElement (mcElementType type, const mcKey &key, int pos=-1)
 Creates a new element of the type & subtype, sends it the given start key and adds it to the array in the specified position.
void gui_CheckCursorPos () const
 Checks the cursor position.
void gui_ScanArrayForFunctions ()
 Scans the array for mcSymbol sequences that matches the name of a mcFunction.
void gui_ReplaceSymbolsWithFunction (int idx, int fnc)
 After a function has been recognized inside a sequence of mcSymbols, the container of the mcSymbol classes should call the following function to create the recognized mcFunction.
mcElement overloaded functions
Implements abstract mcElement functions.

bool gui_isBeginKey (const mcKey &) const
 This class cannot be allocated (directly) by the user; this is why it *always* returns a FALSE value...
bool gui_isArrEndKey (const mcKey &key) const
 See io_isBeginChar function.
int gui_Draw (wxDC &dc, int x, int y, long flags, const wxPoint &pt, int cl) const
 Like mcElement::gui_Draw, but you can specify a center line to use to calculate the cursor position.
int gui_DeleteFirstOp ()
 A little helper funcitons to be used in some rare situations.
mcInputRes gui_Input (const mcKey &ev, mcElement *newelem)
 This function is called when the cursor is inside the element and the user presses a key (which is not the element's end tag).
mcInputRes gui_BackInput (const mcKey &key, mcElement *pnewelem, int n)
 Replies to the return flag of the gui_Input() function of the subelement called by the mcElementArray::gui_Input() function.
mcInsertRes gui_Insert (const mcElement *toinsert, int n)
mcInsertRes gui_Insert (const mcElement &toinsert, mcElement *)
 Inserts the given element at the right of the cursor position.
void gui_Replace (mcElement *)
bool gui_Split (mcElement *)
 gui_Splits this element in two parts.
void gui_DoSplit (mcElementType type, const mcKey &key)
 gui_Splits the currently focused elements in two parts, inserting a new element of the given type and subtype between those two parts
bool gui_MergeWith (const mcElement &)
 Merges the given element with this object.
int gui_Draw (wxDC &dc, int x, int y, long flags, const wxPoint &pt) const
 element must be drawn with mcElementHelpers::sgui_m_pActivationBrush background brush; if this pointer is equal to mcDRW_NONACTIVE, the function must simply draw everything with default transparent mode; if the pointer is not one of the previous values, the function must use the pointer to find the subelement where it lies.
mcElementArrayMath abstract functions
Implementation of those functions defined as pure virtual in parent class.

int math_MathToDataIdx (int dataindex) const
 Converts from math to data index.
int math_DataToMathIdx (int mathindex) const
 Converts from data to math index.
void math_PrepareForComparison (mcElementArray &p) const
mcElementType math_GetNeutralOpType () const
double math_GetNeutralValue () const
mcPolynomial math_GetPolynomialWrapper () const
 Returns a new mcPolynomial containing *this array.
mcArrayEntry math_WrapMonomial (const mcMonomial &)
mcArrayEntry math_WrapSimple (const mcElement &)
mcBasicOpRes math_RaiseTo (const mcPolynomial &p)
 Raises *this element to the given polynomial.
Math engine functions
Implements math calculus.

void math_Abs ()
 Modifies this monomial replacing the first operator with a mcAddOp; in this way, the monomial's sign is changed if the monomial was negative; it will remain untouched if it was positive.
bool math_isSimilarTo (const mcMonomial &) const
 Returns TRUE if the given monomial can be summed with this monomial; that is, both the two monomials have the same factors which contains symbols or functions.
void math_TransformDivOp ()
 Using the mcElement::math_MakeReciprocal function, replaces mcDivOp with mcMultOp and then transform the element(s) following it in their reciprocals.
void math_RemoveAllOp ()
 Removes all mcDivOp using #TransformDivOp and then removes all remaining mcMultOp from the array.
mcMonomial math_DetachNonCommonFactors (const mcMonomial &)
 Returns a new monomial containing the factors non-common to *this and the given monomial.
mcIntegerValue math_GetMaxDegreeFor (const mcSymbolProperties *) const
 Returns the maximum degree of the given symbol for this monomial.
mcIntegerValue math_GetMaxDegreeForSymbolArray (const mcSymbolArray *p) const
 Returns the sum of the maximum degrees for all the symbols in the given array.
Coefficient-related functions
Functions working on the coefficient of this monomial.

void math_SimplifyCoeff ()
void math_RemoveCoeff ()
void math_SetCoeff (const mcNumber &)
void math_ChangeCoeffSign ()
mcRealValue math_GetCoeff () const
mcElementMath abstract functions
Implements some common math functions.

bool math_CanBeAddedWith (const mcElement &p) const
 Returns TRUE if this element can be added with the given element.
mcBasicOpRes math_Add (const mcElement &, mcElement *p, bool add)
 Sums or subtracts this element with the given e element.
mcBasicOpRes math_MultiplyBy (const mcElement &, mcElement *p)
 Multiplies two mcElements of the same type and stores the result in this object.
mcBasicOpRes math_DivideBy (const mcElement &, mcElement *p)
 Divides two mcElements of the same type and stores the result in this object.
int math_GetOrderPos () const
 Computes a value which is used to reorder this monomial.
mcMonomial math_GetLCM (const mcElement &) const
 Returns the LCM between *this and the given element.
mcMonomial math_GetGCD (const mcElement &) const

Static Public Attributes

static bool sgui_bEmptyBoxReplacing = TRUE
 If TRUE, when a monomial which doesn' contain an empty box, is deleted, then it is replaced with a monomial containing an empty box.
static bool sgui_bFunctionScanEnabled = TRUE
 If TRUE, when the user edits the contents of a mcMonomial class, all mcSymbol sequences are automatically scanned searching for function names; for example, if three mcSymbol containing "s", wxT("i"), "n" are found to be contiguos or separated only by mcMultOps, then those three mcSymbol are replaced by a mcFunction representing the SIN function.
static bool sgui_bTransformDivInFractions = TRUE
 If TRUE, when the user creates a mcDivOp, all the factors which are placed *before* the operator, become the numerator of a new fraction whose denominator are the elements placed *after* the operator.
static int sgui_nSpaceBetween = 1
 A value that, divided by the exponent depth of this element, gives the number of pixels to leave between all elements.
static mcMonomialsmath_pZero = NULL
static mcMonomialsmath_pOne = NULL
static bool sio_bAutoConvertDivOpToFractions = TRUE
 If TRUE, just *after* (see io_PostProcess) each import process, all the div ops will be converted to fractions using mcMonomial::data_TransformDivOp().

Protected Member Functions

int data_GetIdxFromEntry (const mcArrayEntry *p) const
mcElementdata_GetRefFromEntry (const mcArrayEntry *p)
virtual mcExpSimRes math_HandleExpSimFlag (mcExpSimRes r, mcElement *newelem, int i)
 Handles a little mcMonomial-specific exception.
mcExpSimRes math_Reorder ()
 Reorders the elements contained in this monomial collapsing all the elements which can be simplified and reordering them.
virtual mcExpSimRes math_BeginSimSteps ()
 Removes all the mcDivOp using the TransformDivOp function.
virtual void math_EndSimSteps ()
 math_Adds eventually missing mcMultOp.

Private Member Functions

 mcDEFINE_REFERENCE_DATA (mcMonomial, mcET_MONOMIAL)


Constructor & Destructor Documentation

mcMonomialHelpers::mcMonomialHelpers  )  [inline]
 

Definition at line 120 of file Monomial.h.

virtual mcMonomialHelpers::~mcMonomialHelpers  )  [inline, virtual]
 

Definition at line 121 of file Monomial.h.


Member Function Documentation

int mcMonomialHelpers::data_GetIdxFromEntry const mcArrayEntry p  )  const [inline, protected, virtual]
 

Implements mcElementArrayHelpers.

Definition at line 128 of file Monomial.h.

mcElement& mcMonomialHelpers::data_GetRefFromEntry const mcArrayEntry p  )  [inline, protected, virtual]
 

Implements mcElementArrayHelpers.

Definition at line 131 of file Monomial.h.

void mcMonomialHelpers::data_Repair  )  [virtual]
 

Repairs the array, adding the mcMultOp where they are required (for example, between two mcNumbers), removing them where they must not be present (for example, at the beginning/end of the array), and so on...

Note:
Use this function rarely not only because it's quite slow, but also because all the manipulations on the array should be done in a controlled way and no errors should be introduced: if you call often this function, you will auto-correct those errors, thus leaving incorrect code scattered in the library.

Reimplemented from mcElementArrayHelpers.

Definition at line 129 of file Monomial.cpp.

References mcElementArrayHelpers::data_AddNewOp(), mcElementHelpers::data_Check(), mcElementArrayHelpers::data_Delete(), mcElementArrayHelpers::data_DeleteLast(), mcElementArrayHelpers::data_Get(), mcElementArrayHelpers::data_GetCount(), mcElementHelpers::data_GetType(), mcElementHelpers::data_isAllowedAfter(), mcElementHelpers::data_isAllowedBefore(), mcElementArrayHelpers::data_isArrayEmpty(), mcElementArrayHelpers::data_isOp(), mcElementArrayHelpers::data_MoveElemLeft(), mcElementArrayHelpers::data_MoveElemRight(), and mcET_MULTOP.

Referenced by gui_BackInput(), gui_MergeWith(), gui_Split(), io_ImportInlinedExpr(), math_Add(), math_BeginSimSteps(), math_EndSimSteps(), math_MultiplyBy(), and math_Reorder().

void mcMonomialHelpers::data_TransformDivOp  ) 
 

Transforms mcDivOps to mcFractions: 24ax/2*3 becomes ((24ax)/2)*3 (brackets have been added only to increase readability) Unlike mcMonomial::math_TransformDivOp(), this function does not use the mcElement::math_MakeReciprocal() function; it creates directly mcFractions that are then filled with the elements placed before & after the old mcDivOp.

Definition at line 186 of file Monomial.cpp.

References mcElementArrayHelpers::data_AddElements(), mcElementArray::data_AddElements(), mcPolynomial::data_AddNewMonomial(), mcPolynomial::data_AddNewMonomialContaining(), mcElementArrayHelpers::data_Delete(), mcElementArray::data_DeleteAll(), mcElementArrayHelpers::data_Get(), mcElementArrayHelpers::data_GetArray(), mcElementArrayHelpers::data_GetCount(), mcFraction::data_GetDen(), mcFraction::data_GetNum(), mcElementHelpers::data_GetType(), mcElementArrayHelpers::data_isOp(), mcElementArrayHelpers::data_MoveElemLeft(), mcET_DIVOP, mcET_MULTOP, mcLOG, and mcTXTTHIS.

Referenced by io_PostProcess().

int mcMonomialHelpers::gui_AddNewElement mcElementType  type,
const mcKey key,
int  pos = -1
[virtual]
 

Creates a new element of the type & subtype, sends it the given start key and adds it to the array in the specified position.

Parameters:
type The class ID of the new element to add
subtype The subclass ID of the new element to add
key The first key the new element will receive
pos The position of the new element; the element (eventually) present in the pos-th entry of the array is deleted and then replaced by this new element. Use -1 to add the new element at the end of the array.
Returns:
The index of the new element in the array (this can be different from the given 'pos' variable).

Reimplemented from mcElementArrayHelpers.

Definition at line 321 of file Monomial.cpp.

References mcElementArrayHelpers::data_AddElements(), mcFraction::data_AddElements(), mcElementHelpers::data_Check(), mcElement::data_Check(), mcElementArrayHelpers::data_DeleteAll(), mcElementArray::data_DeleteFirst(), mcElementArray::data_DeleteLast(), mcElementArray::data_GetCount(), mcElementArrayHelpers::data_GetCount(), mcFraction::data_GetDen(), mcFraction::data_GetNum(), mcElementArrayHelpers::data_isOp(), mcElementArrayHelpers::data_MoveElemRight(), mcElementArrayHelpers::gui_AddNewElement(), mcElementArrayHelpers::gui_AddNewEmptyBox(), mcElementHelpers::gui_RecalcSize(), mcFraction::gui_SetCursorOnDen(), mcET_DIVOP, and sgui_bTransformDivInFractions.

Referenced by gui_DoSplit().

mcInputRes mcMonomialHelpers::gui_BackInput const mcKey key,
mcElement pnewelem,
int  n
[virtual]
 

Replies to the return flag of the gui_Input() function of the subelement called by the mcElementArray::gui_Input() function.

Implements mcElementArrayHelpers.

Definition at line 386 of file Monomial.cpp.

References mcElementArrayHelpers::data_AddNewEmptyBox(), mcElementArrayHelpers::data_Delete(), mcElementArrayHelpers::data_Get(), mcElementArrayHelpers::data_GetCount(), mcElementHelpers::data_GetType(), mcElementHelpers::data_isAllowedBefore(), mcElementArrayHelpers::data_isOp(), mcElementArrayHelpers::data_MoveElemLeft(), data_Repair(), mcMathCore::Get(), mcKey::GetEvent(), mcElementArrayHelpers::gui_DeleteNextOp(), mcElementArrayHelpers::gui_DeletePreviousOp(), gui_Input(), mcElement::gui_MergeWith(), mcElementArrayHelpers::gui_MoveCursorLeft(), mcElementArrayHelpers::gui_MoveCursorRight(), gui_Replace(), mcElementArrayHelpers::gui_SetCursorPos(), mcElement::gui_SetCursorPos(), mcMathCore::m_pCancelKey, mcMathCore::m_pDeleteKey, mcASSERT, mcCP_BEGIN, mcCP_END, mcIR_DELETE_NEXT, mcIR_DELETE_PREVIOUS, mcIR_DELETE_THIS, mcIR_DIRECT_DELETE, mcIR_DISTRIBUTE, mcIR_OKAY, mcIR_REPLACE_THIS, sgui_bEmptyBoxReplacing, and mcMathCore::SyntaxError().

void mcMonomialHelpers::gui_CheckCursorPos  )  const [virtual]
 

Checks the cursor position.

If the cursor is not in the right position, the program stops.

Implements mcElementArrayHelpers.

Definition at line 312 of file Monomial.cpp.

References mcElementArrayHelpers::data_GetCount(), mcElementArrayHelpers::data_isOp(), and mcASSERT.

int mcMonomialHelpers::gui_DeleteFirstOp  ) 
 

A little helper funcitons to be used in some rare situations.

You should NEVER use it: it's just some code which would be repeated 2-3 times in the gui_BackInput() function.

void mcMonomialHelpers::gui_DoSplit mcElementType  type,
const mcKey key
[virtual]
 

gui_Splits the currently focused elements in two parts, inserting a new element of the given type and subtype between those two parts

Implements mcElementArrayHelpers.

Definition at line 680 of file Monomial.cpp.

References mcElementArrayHelpers::data_Get(), mcElementArrayHelpers::data_MoveElemRight(), mcElementArrayHelpers::data_Set(), gui_AddNewElement(), gui_Split(), mcASSERT, and mcEmptyElement.

int mcMonomialHelpers::gui_Draw wxDC &  dc,
int  x,
int  y,
long  flags,
const wxPoint &  pt
const [inline, virtual]
 

element must be drawn with mcElementHelpers::sgui_m_pActivationBrush background brush; if this pointer is equal to mcDRW_NONACTIVE, the function must simply draw everything with default transparent mode; if the pointer is not one of the previous values, the function must use the pointer to find the subelement where it lies.

Then, only the subelement's gui_Draw() function must be called with the initial pointer. The subelements must be called with mcDRW_ALLACTIVE flag only for special reasons.

Returns:
The ID of the element marked as active (the element which is drawn with mcElementHelpers::sgui_m_pActivationBrush as background), or mcDRW_NOACTIVEELEM flag if this element does not contain the mouse cursor.

Reimplemented from mcElementArrayHelpers.

Definition at line 238 of file Monomial.h.

References mcElement::gui_Draw().

int mcMonomialHelpers::gui_Draw wxDC &  dc,
int  x,
int  y,
long  flags,
const wxPoint &  pt,
int  cl
const
 

Like mcElement::gui_Draw, but you can specify a center line to use to calculate the cursor position.

Parameters:
dc The dc where this element will be drawn
x,y The coordinates where this element will be drawn
pt The mouse cursor position or one of the mcDRW_*** flags
cl The center line to use, or -1 to let the function calculate it

Definition at line 278 of file Monomial.cpp.

References mcElementArrayHelpers::gui_DrawSelection(), mcElementArrayHelpers::gui_ExDraw(), mcDRW_ALLOW_TOTAL_SELECTION, mcDRW_NOACTIVEELEM, and mcGUILOG.

int mcMonomialHelpers::gui_GetSpaceBetweenRatio  )  const [inline, virtual]
 

mcPolynomials have different space between ratio from mcPolynomials...

Reimplemented from mcElementArrayHelpers.

Definition at line 92 of file Monomial.h.

mcInputRes mcMonomialHelpers::gui_Input const mcKey ev,
mcElement newelem
[virtual]
 

This function is called when the cursor is inside the element and the user presses a key (which is not the element's end tag).

The way the element should process the given character is dependent to the element type: a mcNumber will insert vk next to the cursor position if vk is a digit. If vk is not acceptable, the function should call the MathCore error-handler function, mcMathCore::Get()->SyntaxError. This function should return one of the values defined for mcInputRes: mcIR_OKAY, mcIR_DELETE_THIS, mcIR_DIRECT_DELETE, mcIR_DELETE_NEXT.

Parameters:
ev The wxWidgets key event for the keypress. It contains the untraslated code for the input key; see wxWidgets KeyCodes for more info.
newelem If the function returns mcIR_REPLACE_THIS, the caller will use this pointer as a substitute for this element (which will be deleted).

Reimplemented from mcElementArrayHelpers.

Definition at line 807 of file Monomial.cpp.

References mcElementArrayHelpers::gui_Input(), gui_ScanArrayForFunctions(), and sgui_bFunctionScanEnabled.

Referenced by gui_BackInput().

mcInsertRes mcMonomialHelpers::gui_Insert const mcElement toinsert,
mcElement
[virtual]
 

Inserts the given element at the right of the cursor position.

Implements mcElementHelpers.

Definition at line 902 of file Monomial.cpp.

References mcElementArrayHelpers::data_Get(), mcElementArrayHelpers::gui_GetCursorPos(), mcElement::gui_Insert(), gui_Replace(), mcINSR_OKAY, and mcINSR_REPLACE_THIS.

mcInsertRes mcMonomialHelpers::gui_Insert const mcElement toinsert,
int  n
 

Definition at line 941 of file Monomial.cpp.

References mcINSR_OKAY.

bool mcMonomialHelpers::gui_isArrEndKey const mcKey key  )  const [inline, virtual]
 

See io_isBeginChar function.

Implements mcElementArrayHelpers.

Definition at line 204 of file Monomial.h.

References mcElementHelpers::gui_isKeyBeginKey(), mcET_ADDOP, and mcET_SUBOP.

bool mcMonomialHelpers::gui_isBeginKey const mcKey  )  const [inline, virtual]
 

This class cannot be allocated (directly) by the user; this is why it *always* returns a FALSE value...

Implements mcElementHelpers.

Definition at line 201 of file Monomial.h.

bool mcMonomialHelpers::gui_MergeWith const mcElement p  )  [virtual]
 

Merges the given element with this object.

Like splitting, very few elements support merging, but those elements which handles splitting, should also handle merging... see gui_Split(). The function should merge the given element in *this and return TRUE if everything was okay; FALSE if the merging could not be done (because, for example, the given element is not of the right type...).

Reimplemented from mcElementHelpers.

Definition at line 767 of file Monomial.cpp.

References mcElementArray::data_Delete(), mcElementArray::data_Get(), mcElementArray::data_GetLast(), mcElementArrayHelpers::data_GetLast(), mcElement::data_GetType(), mcElement::data_isAllowedBefore(), mcElementArray::data_isArrayEmpty(), mcElementArray::data_isOp(), mcElementArrayHelpers::data_Merge(), mcElementArray::data_MoveElemLeft(), data_Repair(), mcElement::gui_isSplittable(), mcElementHelpers::gui_isSplittable(), mcElement::gui_MergeWith(), mcElementHelpers::gui_RecalcSize(), and mcET_MONOMIAL.

void mcMonomialHelpers::gui_Replace mcElement  ) 
 

Definition at line 862 of file Monomial.cpp.

References mcElementArrayHelpers::data_AddElements(), mcElementArrayHelpers::data_AddNewEmptyBox(), mcElementArrayHelpers::data_isElementAllowed(), mcElementArrayHelpers::data_isValidElem(), mcMathCore::Get(), mcASSERT, mcET_ADDOP, mcET_DIVOP, mcET_MULTOP, mcET_SUBOP, and mcMathCore::SyntaxError().

Referenced by gui_BackInput(), and gui_Insert().

void mcMonomialHelpers::gui_ReplaceSymbolsWithFunction int  idx,
int  fnc
 

After a function has been recognized inside a sequence of mcSymbols, the container of the mcSymbol classes should call the following function to create the recognized mcFunction.

Definition at line 841 of file Monomial.cpp.

References mcElementArrayHelpers::data_AddElements(), mcElementArrayHelpers::data_Delete(), mcFunction::data_GetName(), mcElementArrayHelpers::data_MoveElemLeft(), mcElementHelpers::gui_RecalcSize(), and mcFunction::gui_Setup().

Referenced by gui_ScanArrayForFunctions().

void mcMonomialHelpers::gui_ScanArrayForFunctions  ) 
 

Scans the array for mcSymbol sequences that matches the name of a mcFunction.

Definition at line 819 of file Monomial.cpp.

References mcElementArrayHelpers::data_Get(), mcElementArrayHelpers::data_GetArray(), mcElementArrayHelpers::data_GetCount(), mcFunction::data_GetFunctionType(), mcElementHelpers::data_GetType(), gui_ReplaceSymbolsWithFunction(), mcET_SYMBOL, and mcFUNCTION_TYPE_NOTFOUND.

Referenced by gui_Input().

bool mcMonomialHelpers::gui_Split mcElement p  )  [virtual]
 

gui_Splits this element in two parts.

The first is stored in this element, the second is returned as a pointer (the caller must then delete it when it's no longer necessary). The split point must be determined using the current cursor position. This function has a sense only for few elements, see as an example mcNumber::gui_Split: when the user tries to insert a new operator like '/' and the cursor is inside a number, the number is split in two parts and this function is used to get the second half. If the cursor is placed in at the leftmost/rightmost point of the element and, thus, the first/second half of the element would be empty, then the function should return NULL. The classes that cannot be splitted should return NULL. This is what the standard implementation does.

Returns:
TRUE if *this must be deleted; FALSE if it must be kept.

Reimplemented from mcElementHelpers.

Definition at line 716 of file Monomial.cpp.

References mcElementArray::data_AddElements(), mcElementArrayHelpers::data_Delete(), mcElementArrayHelpers::data_DetachLastElem(), mcElementArray::data_Get(), mcElementArrayHelpers::data_Get(), mcElementArrayHelpers::data_GetArray(), mcElementArrayHelpers::data_GetCount(), mcElementArrayHelpers::data_MoveElemLeft(), mcElementArray::data_Repair(), data_Repair(), mcElementHelpers::gui_RecalcSize(), mcElement::gui_SetCursorPos(), mcElement::gui_Split(), mcCP_BEGIN, mcCP_END, and mcEmptyElement.

Referenced by gui_DoSplit().

wxXml2Node mcMonomialHelpers::io_GetMathML bool  bGetPresentation  )  const [virtual]
 

Returns the MathML code for this element as presentation markup (http://www.w3.org/TR/MathML2/chapter3.html) or as content markup (http://www.w3.org/TR/MathML2/chapter4.html).

Parameters:
bGetPresentation TRUE if you want to get the presentation markup, FALSE if you want the content MathML.
Returns:
The XML tree containing the MathML code for this element.

Implements mcElementHelpers.

Definition at line 972 of file Monomial.cpp.

References mcElementArrayHelpers::data_Get(), mcElementArrayHelpers::data_GetCount(), mcElementArrayHelpers::data_isOp(), and mcElement::io_GetMathML().

bool mcMonomialHelpers::io_ImportInlinedExpr const wxString &  ,
int *  ,
wxString &  pErr
[virtual]
 

Imports an inlined expression.

"Inlined expression" means a string containing an encoded representation of math data: 234^2*ax+6y/2=0 is an inlined expression. This is the form which is used to input and output math data by a lot of math programs. Compability with these programs is crucial. However, because of the nature of this representation, the algorithm which recognizes (through io_isBeginChar functions) the elements to create, needs to know the lenght of the token which encodes this element; this is accomplished with the count parameter which must *absolutely* be set by this function.

Parameters:
str The string containing the inlined expression to import.
count A pointer where is stored the number of characters of str imported by this function.
pErr The string where the error description is placed, if the function returns FALSE.
Returns:
TRUE on success: the first (and eventually the following) characters of the given string represent an encoded inline expression of this element and they were successfully recognized and imported.

Implements mcElementHelpers.

Definition at line 1085 of file Monomial.cpp.

References mcElementArrayHelpers::data_AddElements(), mcElementArrayHelpers::data_DeleteAll(), mcElementHelpers::data_NewElem(), data_Repair(), mcElement::io_ImportInlinedExpr(), mcElementHelpers::io_isCharBeginChar(), mcFunctionHelpers::io_isFunctionBeginChar(), mcRadicalHelpers::io_isRadicalBeginChar(), mcElementHelpers::io_PostProcessChildren(), mcET_ADDOP, mcET_FUNCTION, mcET_INVALID, mcET_RADICAL, mcET_SUBOP, mcIOLOG, and mcTXTTHIS.

bool mcMonomialHelpers::io_ImportPresentationMathML wxXml2Node  tag,
wxString &  pErr
[virtual]
 

Imports presentation MathML reading the contents of the given XML node (without modifying it).

This function is called only if io_isBeginTag function returns a positive value for the name of parent tag of pTag.

Parameters:
pTag The wxXML_***_NODE class to parse.
pErr The string where the error description is placed, if the function returns FALSE.
Returns:
TRUE on success (no mismatched or invalid tags).

Implements mcElementHelpers.

Definition at line 1001 of file Monomial.cpp.

References mcElementArrayHelpers::data_AddElements(), mcElementArrayHelpers::data_DeleteAll(), mcElementArrayHelpers::data_Get(), mcElementArrayHelpers::data_GetCount(), mcElementHelpers::data_GetType(), mcElementHelpers::data_NewElem(), mcElement::io_ImportPresentationMathML(), mcElementHelpers::io_isTagBeginTag(), mcElementHelpers::io_PostProcessChildren(), mcASSERT, mcET_ADDOP, and mcET_SUBOP.

void mcMonomialHelpers::io_PostProcess  )  [virtual]
 

If the 'auto convert mcDivOp(s) to mcFraction(s)' feature is enabled (through #bAutoConvertDivOpToFractions) this function will remove all divop replacing them with mcFraction...

Reimplemented from mcElementHelpers.

Definition at line 1152 of file Monomial.cpp.

References data_TransformDivOp(), and sio_bAutoConvertDivOpToFractions.

void mcMonomialHelpers::math_Abs  ) 
 

Modifies this monomial replacing the first operator with a mcAddOp; in this way, the monomial's sign is changed if the monomial was negative; it will remain untouched if it was positive.

This function needs a mcET_POLYNOMIAL as parent to work.

Definition at line 1287 of file Monomial.cpp.

References mcNumber::math_Abs(), math_GetCoeff(), and math_SetCoeff().

mcBasicOpRes mcMonomialHelpers::math_Add const mcElement ,
mcElement p,
bool  add
[virtual]
 

Sums or subtracts this element with the given e element.

A unique function for add/subtract operations is used because the algorithms used to handle this two operations are usually almost identic and thus this avoids a lot of repetitions.

If the two elements cannot be summed, then an ASSERT should fail since before using this function, the caller should always use the math_CanBeAddedWith() function.

The function returns one of mcBasicOpRes values, eventually using the pp pointer to store the replacement element which will be used by the caller in case this function returns mcBOR_REPLACE_OPERAND or mcBOR_REPLACE_BOTH.

Implements mcElementHelpers.

Definition at line 1509 of file Monomial.cpp.

References data_Repair(), mcElement::math_Add(), math_CanBeAddedWith(), mcElementArrayHelpers::math_Get(), mcElementArray::math_Get(), mcMonomial::math_GetCoeff(), math_GetCoeff(), mcElementArray::math_GetCount(), mcElementArrayHelpers::math_GetCount(), math_isSimilarTo(), math_RemoveAllOp(), math_SetCoeff(), mcASSERT, mcBOR_REMOVE_OPERAND, mcET_MONOMIAL, mcMATHLOG, mcTXT, and mcTXTV.

mcExpSimRes mcMonomialHelpers::math_BeginSimSteps  )  [protected, virtual]
 

Removes all the mcDivOp using the TransformDivOp function.

The comparison function used is mcSymbol::math_isBeforeInOrderListOf.

Reimplemented from mcElementArrayHelpers.

Definition at line 1445 of file Monomial.cpp.

References data_Repair(), math_TransformDivOp(), and mcESR_DONE.

bool mcMonomialHelpers::math_CanBeAddedWith const mcElement p  )  const [virtual]
 

Returns TRUE if this element can be added with the given element.

If the function returns TRUE, then the math_Add() function should return one of mcBOR_REMOVE_OPERAND, mcBOR_REPLACE_BOTH or mcBOR_REPLACE_OPERAND.

Reimplemented from mcElementArrayHelpers.

Definition at line 1470 of file Monomial.cpp.

References mcElementArrayHelpers::data_Get(), mcElement::math_CanBeAddedWith(), mcElementArray::math_Get(), mcElementArray::math_GetCount(), mcElementArrayHelpers::math_GetCount(), math_isSimilarTo(), and mcET_MONOMIAL.

Referenced by math_Add().

void mcMonomialHelpers::math_ChangeCoeffSign  ) 
 

Definition at line 1869 of file Monomial.cpp.

References math_GetCoeff(), and math_SetCoeff().

int mcMonomialHelpers::math_DataToMathIdx int  mathindex  )  const [virtual]
 

Converts from data to math index.

See #mcElementArrayMath general description for more info.

Implements mcElementArrayHelpers.

Definition at line 1221 of file Monomial.cpp.

References mcElementArrayHelpers::data_CheckIndex(), and mcElementArrayHelpers::data_isOp().

mcMonomial mcMonomialHelpers::math_DetachNonCommonFactors const mcMonomial  ) 
 

Returns a new monomial containing the factors non-common to *this and the given monomial.

Definition at line 1710 of file Monomial.cpp.

References mcElementArray::data_AddElements(), mcElementArrayHelpers::data_Delete(), mcElementArrayHelpers::data_Get(), mcElementArrayHelpers::data_GetArray(), mcElementArrayHelpers::data_GetCount(), mcElement::data_GetType(), mcElementArrayHelpers::data_MoveElemLeft(), and mcElementArrayHelpers::math_Compare().

mcBasicOpRes mcMonomialHelpers::math_DivideBy const mcElement ,
mcElement p
[virtual]
 

Divides two mcElements of the same type and stores the result in this object.

Parameters:
p A pointer to a mcElement of the same type of this mcElement, which will be used to divide this mcElement.

Implements mcElementHelpers.

Definition at line 1598 of file Monomial.cpp.

References mcElementArray::data_DeleteAll(), mcFraction::data_GetDen(), mcArrayEntry::data_GetFraction(), mcElementArrayHelpers::math_EmbedInFraction(), mcElementArray::math_WrapMonomial(), mcASSERT, mcBOR_REMOVE_OPERAND, and mcET_MONOMIAL.

void mcMonomialHelpers::math_EndSimSteps  )  [protected, virtual]
 

math_Adds eventually missing mcMultOp.

Reimplemented from mcElementArrayHelpers.

Definition at line 1457 of file Monomial.cpp.

References data_Repair().

mcRealValue mcMonomialHelpers::math_GetCoeff  )  const
 

Definition at line 1788 of file Monomial.cpp.

References mcElementArray::data_AddElements(), mcElementArray::data_Get(), mcElementArrayHelpers::data_Get(), mcElementArray::data_GetCount(), mcElementArrayHelpers::data_GetCount(), mcElementArray::data_GetElemOfType(), mcElementArray::data_GetNumOfElemType(), mcElementArrayHelpers::data_GetNumOfElemType(), mcElement::data_Ref(), mcElement::math_ContainsUnknowns(), mcMonomial::math_SimplifyCoeff(), mcASSERT, mcET_NUMBER, and mcNewMonomial.

Referenced by math_Abs(), math_Add(), and math_ChangeCoeffSign().

mcMonomial mcMonomialHelpers::math_GetGCD const mcElement  )  const [virtual]
 

Implements mcElementHelpers.

Definition at line 1945 of file Monomial.cpp.

References mcElement::data_GetType(), mcElementArrayHelpers::math_Get(), mcElementArray::math_Get(), mcElementArrayHelpers::math_GetCount(), mcElementArray::math_GetCount(), mcElement::math_GetGCD(), mcElementArrayHelpers::math_isWrappingOnly(), mcElementArray::math_ResetToOne(), mcElement::math_SimpleMultiplyBy(), mcMATHLOG, mcTXT, mcTXTTHIS, and smath_pOne.

mcMonomial mcMonomialHelpers::math_GetLCM const mcElement  )  const [virtual]
 

Returns the LCM between *this and the given element.

Implements mcElementHelpers.

Definition at line 1883 of file Monomial.cpp.

References mcElementArrayHelpers::math_Get(), mcElementArray::math_Get(), mcElementArrayHelpers::math_GetCount(), mcElementArray::math_GetCount(), mcElementArray::math_GetIndexOf(), mcElement::math_GetLCM(), mcElementArray::math_Remove(), mcElement::math_SimpleMultiplyBy(), mcASSERT, mcMATHLOG, mcTXT, and mcTXTTHIS.

mcIntegerValue mcMonomialHelpers::math_GetMaxDegreeFor const mcSymbolProperties  )  const
 

Returns the maximum degree of the given symbol for this monomial.

If this monomial does not contain the given symbol, then the return value is zero; if this monomial contains a mcSymbol linked with the given mcSymbolProperties but not containing a simple mcNumber, then the return value is mcIntegerValue::pNAN.

Definition at line 1338 of file Monomial.cpp.

References mcSymbol::data_isLinkedWith(), mcIntegerValue::GetMax(), mcIntegerValue::GetStr(), mcValue::isValid(), mcElementHelpers::math_Find(), mcExpElement::math_GetConstExp(), mcElementHelpers::math_GetCountOf(), mcElementArray::math_GetWrappedNumber(), mcASSERT, mcEmptyElement, mcMATHLOG, mcTXT, and mcTXTTHIS.

Referenced by math_GetMaxDegreeForSymbolArray().

mcIntegerValue mcMonomialHelpers::math_GetMaxDegreeForSymbolArray const mcSymbolArray p  )  const
 

Returns the sum of the maximum degrees for all the symbols in the given array.

Definition at line 1373 of file Monomial.cpp.

References mcElementArrayHelpers::data_GetCount(), and math_GetMaxDegreeFor().

Referenced by math_GetOrderPos().

mcElementType mcMonomialHelpers::math_GetNeutralOpType  )  const [inline, virtual]
 

Implements mcElementArrayHelpers.

Definition at line 291 of file Monomial.h.

References mcET_MULTOP.

double mcMonomialHelpers::math_GetNeutralValue  )  const [inline, virtual]
 

Implements mcElementArrayHelpers.

Definition at line 292 of file Monomial.h.

int mcMonomialHelpers::math_GetOrderPos  )  const [virtual]
 

Computes a value which is used to reorder this monomial.

Implements mcElementHelpers.

Definition at line 1315 of file Monomial.cpp.

References mcValue::GetInt(), math_GetMaxDegreeForSymbolArray(), mcMATHLOG, and mcTXTTHIS.

mcPolynomial mcMonomialHelpers::math_GetPolynomialWrapper  )  const [virtual]
 

Returns a new mcPolynomial containing *this array.

mcPolynomial returns a copy of themselves, mcMonomial returns a mcPolynomial containing itself.

Implements mcElementArrayHelpers.

Definition at line 1396 of file Monomial.cpp.

References mcElementArray::data_AddElements(), and mcElement::data_MakePrivateCopy().

mcExpSimRes mcMonomialHelpers::math_HandleExpSimFlag mcExpSimRes  r,
mcElement newelem,
int  i
[protected, virtual]
 

Handles a little mcMonomial-specific exception.

Reimplemented from mcElementArrayHelpers.

Definition at line 1256 of file Monomial.cpp.

References mcElementArrayHelpers::math_HandleExpSimFlag(), mcESR_CHANGE_SIGN, mcESR_DISTRIBUTE, mcESR_REPLACE_THIS, and mcET_POLYNOMIAL.

bool mcMonomialHelpers::math_isSimilarTo const mcMonomial  )  const
 

Returns TRUE if the given monomial can be summed with this monomial; that is, both the two monomials have the same factors which contains symbols or functions.

Definition at line 1624 of file Monomial.cpp.

References mcElement::math_Compare(), mcMonomial::math_RemoveCoeff(), mcFIND_NOFLAGS, mcMATHLOG, and mcTXT.

Referenced by math_Add(), and math_CanBeAddedWith().

int mcMonomialHelpers::math_MathToDataIdx int  dataindex  )  const [virtual]
 

Converts from math to data index.

See #mcElementArrayMath general description for more info.

Implements mcElementArrayHelpers.

Definition at line 1209 of file Monomial.cpp.

References mcElementArrayHelpers::data_GetNonOpElemIndex(), mcElementArrayHelpers::math_GetCount(), mcMATHLOG, and mcTXTTHIS.

mcBasicOpRes mcMonomialHelpers::math_MultiplyBy const mcElement ,
mcElement p
[virtual]
 

Multiplies two mcElements of the same type and stores the result in this object.

Parameters:
p A pointer to a mcElement of the same type of this mcElement, which will be multiplied with this mcElement.

Implements mcElementHelpers.

Definition at line 1569 of file Monomial.cpp.

References mcElementArrayHelpers::data_DeleteAll(), mcElementArrayHelpers::data_Get(), mcElementArrayHelpers::data_GetWrapped(), mcElementArrayHelpers::data_Merge(), data_Repair(), mcASSERT, mcBOR_REMOVE_OPERAND, mcEmptyElement, mcET_MONOMIAL, and mcET_NUMBER.

void mcMonomialHelpers::math_PrepareForComparison mcElementArray p  )  const [virtual]
 

Reimplemented from mcElementArrayHelpers.

Definition at line 1430 of file Monomial.cpp.

References mcET_MONOMIAL, and mcEXPSIM_NOFLAGS.

mcBasicOpRes mcMonomialHelpers::math_RaiseTo const mcPolynomial p  )  [virtual]
 

Raises *this element to the given polynomial.

Returns mcBOR_INVALID if the operation could not be performed (this is typically because the base is negative), or mcBOR_REMOVE_OPERAND if the operation was okay.

Note:
All MathCore elements must implement this function, not only mcExpElement-derived classes because this operation *must* be feasible on every element: those elements which do not hold an exponent, must raise their children directly. mcFraction, for example, must implement this operation directly raising the numerator & denominator.

Implements mcElementHelpers.

Definition at line 1233 of file Monomial.cpp.

References mcElementArrayHelpers::math_Get(), mcElementArrayHelpers::math_GetCount(), mcElement::math_RaiseTo(), mcASSERT, mcBOR_INVALID, mcBOR_REMOVE_OPERAND, mcMATHLOG, mcTXT, and mcTXTTHIS.

void mcMonomialHelpers::math_RemoveAllOp  ) 
 

Removes all mcDivOp using #TransformDivOp and then removes all remaining mcMultOp from the array.

Definition at line 1672 of file Monomial.cpp.

References mcElementArrayHelpers::data_Delete(), mcElementArrayHelpers::data_GetCount(), mcElementArrayHelpers::data_isOp(), mcElementArrayHelpers::data_MoveElemLeft(), and math_TransformDivOp().

Referenced by math_Add(), and math_Reorder().

void mcMonomialHelpers::math_RemoveCoeff  ) 
 

Definition at line 1688 of file Monomial.cpp.

References mcElementArrayHelpers::data_Get(), mcElementHelpers::data_GetType(), mcElementHelpers::math_ContainsUnknowns(), mcElementArrayHelpers::math_Get(), mcElementArrayHelpers::math_GetCount(), mcElementArrayHelpers::math_Remove(), and mcET_NUMBER.

Referenced by math_SetCoeff().

mcExpSimRes mcMonomialHelpers::math_Reorder  )  [protected, virtual]
 

Reorders the elements contained in this monomial collapsing all the elements which can be simplified and reordering them.

The function puts the element in this order:

  • mcNumber(s)
  • mcFraction(s)
  • mcBracket(s)
  • mcRadical(s)
  • mcFunctions(s)

VERY IMPORTANT: this function can be called only if mcDivOp are not present in the array.

Implements mcElementArrayHelpers.

Definition at line 1297 of file Monomial.cpp.

References mcElementArrayHelpers::data_GetArray(), mcElementArrayHelpers::data_GetCount(), mcElementArrayHelpers::data_GetNumOfElemType(), data_Repair(), math_RemoveAllOp(), mcElementArrayHelpers::math_ReorderElements(), mcASSERT, mcESR_DONE, mcESR_NOTFINISHED, and mcET_DIVOP.

void mcMonomialHelpers::math_SetCoeff const mcNumber  ) 
 

Definition at line 1841 of file Monomial.cpp.

References mcElementArrayHelpers::data_AddElements(), mcElementArrayHelpers::data_Get(), mcElementArrayHelpers::data_GetCount(), mcElementHelpers::data_GetType(), math_RemoveCoeff(), and mcET_NUMBER.

Referenced by math_Abs(), math_Add(), math_ChangeCoeffSign(), and math_SimplifyCoeff().

void mcMonomialHelpers::math_SimplifyCoeff  ) 
 

Definition at line 1745 of file Monomial.cpp.

References mcElementArrayHelpers::data_Get(), mcElementArrayHelpers::data_GetElemIndexOfType(), mcElementArrayHelpers::data_GetNumOfElemType(), mcElement::data_GetType(), mcElementArrayHelpers::data_isOp(), mcElementArrayHelpers::math_ApplyOpSimple(), math_SetCoeff(), mcElement::math_SimpleMultiplyBy(), mcET_DIVOP, mcET_MULTOP, mcET_NUMBER, mcMATHLOG, and mcTXTTHIS.

void mcMonomialHelpers::math_TransformDivOp  ) 
 

Using the mcElement::math_MakeReciprocal function, replaces mcDivOp with mcMultOp and then transform the element(s) following it in their reciprocals.

A fast and safe way to remove mcDivOps.

Definition at line 1648 of file Monomial.cpp.

References mcElementArrayHelpers::data_AddElements(), mcElementArrayHelpers::data_AddNewOp(), mcElementArrayHelpers::data_Get(), mcElementArrayHelpers::data_GetCount(), mcElementHelpers::data_GetType(), mcElement::math_MakeReciprocal(), mcEmptyElement, mcET_DIVOP, and mcET_MULTOP.

Referenced by math_BeginSimSteps(), and math_RemoveAllOp().

mcArrayEntry mcMonomialHelpers::math_WrapMonomial const mcMonomial  )  [virtual]
 

Implements mcElementArrayHelpers.

Definition at line 1410 of file Monomial.cpp.

References mcElementArrayHelpers::data_DeepCopy(), mcElementArrayHelpers::mcArrayEntry, and mcASSERT.

mcArrayEntry mcMonomialHelpers::math_WrapSimple const mcElement  )  [virtual]
 

Implements mcElementArrayHelpers.

Definition at line 1421 of file Monomial.cpp.

References mcElementArrayHelpers::data_AddElements(), mcElementArrayHelpers::mcArrayEntry, mcASSERT, mcET_MONOMIAL, and mcET_POLYNOMIAL.

mcMonomialHelpers::mcDEFINE_REFERENCE_DATA mcMonomial  ,
mcET_MONOMIAL 
[private]
 


Member Data Documentation

bool mcMonomialHelpers::sgui_bEmptyBoxReplacing = TRUE [static]
 

If TRUE, when a monomial which doesn' contain an empty box, is deleted, then it is replaced with a monomial containing an empty box.

If FALSE, the monomial is immediately deleted with his previous operator.

Definition at line 70 of file Monomial.cpp.

Referenced by gui_BackInput().

bool mcMonomialHelpers::sgui_bFunctionScanEnabled = TRUE [static]
 

If TRUE, when the user edits the contents of a mcMonomial class, all mcSymbol sequences are automatically scanned searching for function names; for example, if three mcSymbol containing "s", wxT("i"), "n" are found to be contiguos or separated only by mcMultOps, then those three mcSymbol are replaced by a mcFunction representing the SIN function.

Definition at line 71 of file Monomial.cpp.

Referenced by gui_Input().

bool mcMonomialHelpers::sgui_bTransformDivInFractions = TRUE [static]
 

If TRUE, when the user creates a mcDivOp, all the factors which are placed *before* the operator, become the numerator of a new fraction whose denominator are the elements placed *after* the operator.

The new fraction then replaces the entire content of this element.

Definition at line 72 of file Monomial.cpp.

Referenced by gui_AddNewElement().

int mcMonomialHelpers::sgui_nSpaceBetween = 1 [static]
 

A value that, divided by the exponent depth of this element, gives the number of pixels to leave between all elements.

Definition at line 65 of file Monomial.cpp.

bool mcMonomialHelpers::sio_bAutoConvertDivOpToFractions = TRUE [static]
 

If TRUE, just *after* (see io_PostProcess) each import process, all the div ops will be converted to fractions using mcMonomial::data_TransformDivOp().

Definition at line 73 of file Monomial.cpp.

Referenced by io_PostProcess().

mcMonomial * mcMonomialHelpers::smath_pOne = NULL [static]
 

Definition at line 67 of file Monomial.cpp.

Referenced by math_GetGCD().

mcMonomial * mcMonomialHelpers::smath_pZero = NULL [static]
 

Definition at line 68 of file Monomial.cpp.


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

Documentation generated with Doxygen on Sun Feb 6 17:12:55 2005
Visit MathStudio home page for more info

[ Top ]