From 06bf51ef309f08bb58afbe667e0767ffdfddb855 Mon Sep 17 00:00:00 2001 From: Adel KS Date: Mon, 6 Mar 2017 17:42:52 +0100 Subject: [PATCH] Corrected bugs - Regression polynomial had the wrong coefficients - ZeGrapher wasn't parsing correctly x(1-x) --- Calculus/exprcalculator.cpp | 4 ---- Calculus/exprcalculator.h | 4 ---- Calculus/polynomial.cpp | 8 +++----- Calculus/polynomialregression.cpp | 2 +- Calculus/treecreator.cpp | 11 +++++------ Structures.h | 4 ++-- Widgets/pareqcontroller.cpp | 2 +- Widgets/pareqwidget.cpp | 6 ++++++ Windows/updatecheck.cpp | 2 +- Windows/updatecheck.h | 2 ++ 10 files changed, 21 insertions(+), 24 deletions(-) diff --git a/Calculus/exprcalculator.cpp b/Calculus/exprcalculator.cpp index 0faff07..03cfad4 100644 --- a/Calculus/exprcalculator.cpp +++ b/Calculus/exprcalculator.cpp @@ -18,10 +18,6 @@ ** ****************************************************************************/ - - - - #include "Calculus/exprcalculator.h" static double tenPower(double x) diff --git a/Calculus/exprcalculator.h b/Calculus/exprcalculator.h index 480efc0..24ec201 100644 --- a/Calculus/exprcalculator.h +++ b/Calculus/exprcalculator.h @@ -18,10 +18,6 @@ ** ****************************************************************************/ - - - - #ifndef EXPRCALCULATOR_H #define EXPRCALCULATOR_H diff --git a/Calculus/polynomial.cpp b/Calculus/polynomial.cpp index 9af064d..137b11d 100755 --- a/Calculus/polynomial.cpp +++ b/Calculus/polynomial.cpp @@ -84,11 +84,9 @@ double Polynomial::getXTranslation() const void Polynomial::translateX(double Dx) { - translation += -Dx; + translation -= Dx; - translatedCoefficients.clear(); - - Dx = -Dx; + translatedCoefficients.clear(); QList DxPowTable; DxPowTable.reserve(coefficients.size()); @@ -99,7 +97,7 @@ void Polynomial::translateX(double Dx) { translatedCoefficients << 0; DxPowTable << DxPow; - DxPow *= Dx; + DxPow *= translation; } for(int n = 0 ; n < coefficients.size() ; n++) diff --git a/Calculus/polynomialregression.cpp b/Calculus/polynomialregression.cpp index 3f0f0a2..a086e79 100755 --- a/Calculus/polynomialregression.cpp +++ b/Calculus/polynomialregression.cpp @@ -160,7 +160,7 @@ void PolynomialRegression::calculateRegressionPolynomials() continuousPol.translateX(1); continuousPol.expand(xamp/2); - continuousPol.translateX(xmin); + continuousPol.translateX(xmin); continuousPol.translateY(1); continuousPol *= yamp/2; diff --git a/Calculus/treecreator.cpp b/Calculus/treecreator.cpp index d7f2e3c..e831fbc 100644 --- a/Calculus/treecreator.cpp +++ b/Calculus/treecreator.cpp @@ -99,8 +99,7 @@ void TreeCreator::insertMultiplySigns(QString &formula) (formula[i].isLetter() && formula[i+1].isDigit()) || (formula[i].isDigit() && formula[i+1] == '(') || (formula[i] == ')' && formula[i+1] == '(') || - (formula[i] == ')' && (formula[i+1].isDigit() || formula[i+1].isLetter())) || - (i != 0 && !formula[i-1].isLetter() && vars.contains(QString(formula[i])) && formula[i+1] == '(')) + (formula[i] == ')' && (formula[i+1].isDigit() || formula[i+1].isLetter()))) { formula.insert(i+1, QString("*")); i++; @@ -228,8 +227,8 @@ bool TreeCreator::check(QString formula) if(!ok) return false; - openingParenthesis = varOrFunc = numberSign = false; - digit = ope = closingParenthesis = canEnd = true; + digit = openingParenthesis = varOrFunc = numberSign = false; + ope = closingParenthesis = canEnd = true; } else if(formula[i].isLetter() && varOrFunc) { @@ -280,8 +279,8 @@ bool TreeCreator::check(QString formula) else if(constants.contains(name) || customVars.contains(name) || vars.contains(name)) { - varOrFunc = numberSign = false; - openingParenthesis = digit = ope = closingParenthesis = canEnd = true; + varOrFunc = numberSign = openingParenthesis = digit = false; + ope = closingParenthesis = canEnd = true; if(customVars.contains(name)) /* customVars comes at first because of overriding policy, customvars come from dataplot, and user can redefine n t or x or k */ diff --git a/Structures.h b/Structures.h index ee9d524..53632c6 100755 --- a/Structures.h +++ b/Structures.h @@ -23,10 +23,10 @@ #define STRUCTURES_H #include - - #include +#define SOFTWARE_VERSION 3.01 + #define FROM_CURRENT_GRAPHIC 0 #define MANUAL_ENTRY 1 diff --git a/Widgets/pareqcontroller.cpp b/Widgets/pareqcontroller.cpp index 7866c34..c3cfa32 100644 --- a/Widgets/pareqcontroller.cpp +++ b/Widgets/pareqcontroller.cpp @@ -42,7 +42,7 @@ void ParEqController::nextAnimationFrame() { bool update = false; - for(int i = 0; i < parEqs->size(); i++) + for(int i = 0 ; i < parEqs->size(); i++) { if(parEqs->at(i)->isAnimated() && parEqs->at(i)->isPlaying()) { diff --git a/Widgets/pareqwidget.cpp b/Widgets/pareqwidget.cpp index cfd4912..b837695 100644 --- a/Widgets/pareqwidget.cpp +++ b/Widgets/pareqwidget.cpp @@ -88,7 +88,10 @@ void ParEqWidget::setRatio(double r) if(tWidget->isAnimateChecked() && valid) { if(2*trunc(tRange.step * ratio) > trunc(tRange.end - tRange.start)) + { blockAnimation = true; + parCurrentValLineEdit->setText(tr("Increment period too small for the animation to be seen.")); + } else { blockAnimation = false; @@ -101,7 +104,10 @@ void ParEqWidget::setRatio(double r) else if(kWidget->isAnimateChecked() && valid) { if(2*trunc(kRange.step * ratio) > trunc(kRange.end - kRange.start)) + { blockAnimation = true; + parCurrentValLineEdit->setText(tr("Increment period too small for the animation to be seen.")); + } else { blockAnimation = false; diff --git a/Windows/updatecheck.cpp b/Windows/updatecheck.cpp index 800b606..9b8cbf7 100644 --- a/Windows/updatecheck.cpp +++ b/Windows/updatecheck.cpp @@ -70,7 +70,7 @@ void UpdateCheck::downloadFinished(QNetworkReply *reply) } else { - if(latestVersion > 3.0) + if(latestVersion > SOFTWARE_VERSION) { statusLabel->setTextFormat(Qt::RichText); statusLabel->setText(tr("A new version is available!

To download it, visit zegrapher.com")); diff --git a/Windows/updatecheck.h b/Windows/updatecheck.h index bcfd81d..925447d 100644 --- a/Windows/updatecheck.h +++ b/Windows/updatecheck.h @@ -10,6 +10,8 @@ #include #include +#include + class UpdateCheck : public QDialog {