Functions::Functions( char angleMode, QObject * parent ) : QObject( parent ), d( new Functions::Private ) { d->p = this; setAngleMode( angleMode ); d->createBuiltInFunctions(); retranslateText(); }
PostfixEvaluator::PostfixEvaluator(MemoryBank& mbref) : mBank(mbref) { setAngleMode(MathUtil::DEGREES); }
/** Append text to Expression. Overwrites a trailing operator with the new one, if a sequence of * two operators is input. * Recognizes and executes C, AC and = commands. */ void Calculator::addToExpressionText(const QString & buttonText) { QString text = buttonText; try{ if(text == "C") clearLast(); else if(text == "AC") clearAll(); else if(text == "+/-") changeSign(); else if(text == m_TextRad) setAngleMode(text); else if(text == m_TextDeg) setAngleMode(text); else if(text == "=") { if(isPlotExpression()) createPlot(); else parseExpression(); } else if(text=="x") addVariable(text); else if(text.startsWith("Plot")) plotter.processPlotCommand(text); else{ //we have a digit, operator or function //no clear or evaluate command if(text == "x^y") //convert to operator text = "^"; if(isNumber(text)){ //No parenthesis, we have a digit or a decimal separator addDigit(text); emit guiStateSuggested(STATE_STANDARD); //return to std page, if on Fn Page for entering E } else if(isOperator(text)) //operator or digit { addOperator(text); } else if(isParenthesis(text)) //we have a parenthesis { addParenthesis(text); } else if(isFunction(text)) //we have a function { addFunctionCall(text); } else if(isVariable(text)) //we have a variable { addVariable(text); } else throw ExExpressionError(tr("Unknown command:") + text); } //end digit operator or function m_ExpressionText = m_ExpressionParts.join(""); if(isPlotExpression()) emit expressionTextChanged("y=" + m_ExpressionText); else emit expressionTextChanged(m_ExpressionText); } //end try catch(ExExpressionError e) { emit guiStateSuggested(STATE_STANDARD); emit errorMessage(tr("Input Error"),e.what()); } catch(std::exception e) { emit guiStateSuggested(STATE_STANDARD); emit errorMessage(tr("Unknown Input Error"),e.what()); } }