示例#1
0
	static string consToFormula(const Model & model, const SpecieID ID) {
		string formula; // Resulting formula specifying all the constraints
		
		formula = "tt";

		for (const string constraint : model.species[ID].par_cons) {
			formula.append(" & " + addParenthesis(formatConstraint(constraint, model, ID)));
		}
		
		return addParenthesis(formula);
	}
示例#2
0
/** 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());
    }
}