From 2ba6957f9369f485f77c0f5c3b21707743941fa4 Mon Sep 17 00:00:00 2001 From: thepra Date: Mon, 28 Aug 2017 13:08:42 +0200 Subject: [PATCH] up --- QtCurvesCpp.pro.user | 19 ++++++++----------- mainwindow.cpp | 6 ++++++ mainwindow.h | 2 ++ mainwindow.ui | 12 ++++++++++++ renderarea.cpp | 27 ++++++++++++++++++++------- renderarea.h | 4 +++- 6 files changed, 51 insertions(+), 19 deletions(-) diff --git a/QtCurvesCpp.pro.user b/QtCurvesCpp.pro.user index 33e13c9..3ff9845 100644 --- a/QtCurvesCpp.pro.user +++ b/QtCurvesCpp.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {9311c877-cd31-4d5b-986a-ff7eaf9ec7ed} + {cc43eb28-2519-4f1e-b7c4-4119ef119db4} ProjectExplorer.Project.ActiveTarget @@ -282,17 +282,14 @@ 13 14 - 2 + -1 - QtCurvesCpp + + + %{buildDir} + Custom Executable - Qt4ProjectManager.Qt4RunConfiguration:C:/DEVEL/QtCurvesCpp/QtCurvesCpp.pro - true - - QtCurvesCpp.pro - false - - C:/DEVEL/build-QtCurvesCpp-Desktop_Qt_5_9_1_MinGW_32bit-Debug + ProjectExplorer.CustomExecutableRunConfiguration 3768 false true diff --git a/mainwindow.cpp b/mainwindow.cpp index 247f569..1f838f1 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -43,3 +43,9 @@ void MainWindow::on_btnHypo_clicked() this->ui->renderArea->setShape(RenderArea::HypoCycloid); this->ui->renderArea->repaint(); } + +void MainWindow::on_btnLine_clicked() +{ + this->ui->renderArea->setShape(RenderArea::Line); + this->ui->renderArea->repaint(); +} diff --git a/mainwindow.h b/mainwindow.h index 9299792..f5b0d40 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -27,6 +27,8 @@ class MainWindow : public QMainWindow void on_btnHypo_clicked(); + void on_btnLine_clicked(); + private: constexpr static QWidget* root = 0; Ui::MainWindow *ui; diff --git a/mainwindow.ui b/mainwindow.ui index b0905c4..5f451d2 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -236,6 +236,18 @@ border-color: rgb(255, 255, 255); + + + + color: rgb(255, 255, 255); +background-color: rgb(36, 35, 35); +border-color: rgb(255, 255, 255); + + + Line + + + diff --git a/renderarea.cpp b/renderarea.cpp index 6c242b8..ba92eef 100644 --- a/renderarea.cpp +++ b/renderarea.cpp @@ -13,7 +13,7 @@ RenderArea::RenderArea(QWidget *parent) : QPointF RenderArea::ComputeAstroid(double t){ return QPointF{ 2*pow(cos(t),3), - 2*pow(sin(t),3) + 2*pow(sin(t),3) }; } @@ -21,7 +21,7 @@ QPointF RenderArea::ComputeCycloid(double t) { return QPointF{ 1.5 * (1 - cos(t)), - 1.5 * (t - sin(t)) + 1.5 * (t - sin(t)) }; } @@ -29,7 +29,7 @@ QPointF RenderArea::ComputeHuygens(double t) { return QPointF{ 4 * (3 * cos(t) - cos(3 * t)), - 4 * (3 * sin(t) - sin(3 * t)) + 4 * (3 * sin(t) - sin(3 * t)) }; } @@ -37,10 +37,15 @@ QPointF RenderArea::ComputeHypo(double t) { return QPointF{ 1.5 * (2 * cos(t) + cos(2 * t)), - 1.5 * (2 * sin(t) - sin(2 * t)) + 1.5 * (2 * sin(t) - sin(2 * t)) }; } +QPointF RenderArea::ComputeLine(double t) +{ + return QPointF{1-t,1-t}; +} + QSize RenderArea::minimumSizeHint() const { return QSize(100,100); @@ -98,6 +103,11 @@ void RenderArea::OnShapeChanged() mIntervalLenght=2*M_PI; mStepCount=256; break; + case Line: + mScale=50; + mIntervalLenght=1; + mStepCount=128; + break; default: break; } @@ -110,13 +120,16 @@ QPointF RenderArea::Compute(double t) return ComputeAstroid(t); break; case Cycloid: - return ComputeCycloid(t); + return ComputeCycloid(t); break; case HuygensCycloid: - return ComputeHuygens(t); + return ComputeHuygens(t); break; case HypoCycloid: - return ComputeHypo(t); + return ComputeHypo(t); + break; + case Line: + return ComputeLine(t); break; default: break; diff --git a/renderarea.h b/renderarea.h index d62bef1..5663fea 100644 --- a/renderarea.h +++ b/renderarea.h @@ -16,7 +16,8 @@ class RenderArea : public QWidget Astroid, Cycloid, HuygensCycloid, - HypoCycloid + HypoCycloid, + Line }; void setBackgroundColor(QColor color) { mBackgroundColour = color; } @@ -38,6 +39,7 @@ class RenderArea : public QWidget QPointF ComputeCycloid(double t); QPointF ComputeHuygens(double t); QPointF ComputeHypo(double t); + QPointF ComputeLine(double t); QPointF Compute(double t); QColor mBackgroundColour,mShapeColour; ShapesType mShape;