| 39 | } |
| 40 | |
| 41 | void plot::execComm(Document_Interface *doc, QWidget *parent, QString cmd) |
| 42 | { |
| 43 | Q_UNUSED(doc); |
| 44 | Q_UNUSED(cmd); |
| 45 | |
| 46 | QString equation1; |
| 47 | QString equation2; |
| 48 | QString startValue; |
| 49 | QString endValue; |
| 50 | double stepSize; |
| 51 | |
| 52 | QList<double> xValues; |
| 53 | QList<double> yValues1; |
| 54 | QList<double> yValues2; |
| 55 | plotDialog::EntityType lineType=plotDialog::Polyline; |
| 56 | |
| 57 | plotDialog plotDlg(parent); |
| 58 | int result = plotDlg.exec(); |
| 59 | if (result == QDialog::Accepted) |
| 60 | { |
| 61 | double equationVariable = 0.0; |
| 62 | double startVal = 0.0; |
| 63 | double endVal = 0.0; |
| 64 | plotDlg.getValues(equation1, equation2, startValue, endValue, stepSize); |
| 65 | lineType=plotDlg.getEntityType(); |
| 66 | |
| 67 | try{ |
| 68 | mu::Parser p; |
| 69 | p.DefineConst(_T("pi"),M_PI); |
| 70 | p.DefineConst(_T("e"),M_E); |
| 71 | p.DefineVar(_T("x"), &equationVariable); |
| 72 | p.DefineVar(_T("t"), &equationVariable); |
| 73 | p.SetExpr(toMUPString(startValue)); |
| 74 | startVal = p.Eval(); |
| 75 | |
| 76 | p.SetExpr(toMUPString(endValue)); |
| 77 | endVal = p.Eval(); |
| 78 | |
| 79 | p.SetExpr(toMUPString(equation1)); |
| 80 | |
| 81 | for(equationVariable = startVal; equationVariable <= endVal; equationVariable += stepSize) |
| 82 | {//calculate the values of the first equation |
| 83 | xValues.append(equationVariable); |
| 84 | yValues1.append(p.Eval()); |
| 85 | } |
| 86 | |
| 87 | if(!equation2.isEmpty()) |
| 88 | {//calculate the values of the second equation |
| 89 | p.SetExpr(toMUPString(equation2)); |
| 90 | for(int i = 0; i < xValues.size(); ++i) |
| 91 | { |
| 92 | equationVariable = xValues.at(i); |
| 93 | yValues2.append(p.Eval()); |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | catch (mu::Parser::exception_type &e) |
| 98 | { |
nothing calls this directly
no test coverage detected