Progress :D

This commit is contained in:
thepra 2017-09-09 21:43:16 +02:00
parent 1a9d8e5e7b
commit c152ff4dec
6 changed files with 440 additions and 318 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.4.0, 2017-09-05T20:42:14. --> <!-- Written by QtCreator 4.4.0, 2017-09-06T18:37:05. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

View File

@ -1,12 +1,14 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include <QPainter> #include <QPainter>
#include <QColorDialog>
MainWindow::MainWindow(QWidget *parent) : MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::MainWindow) ui(new Ui::MainWindow)
{ {
ui->setupUi(this); ui->setupUi(this);
UpdateUi();
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -14,6 +16,13 @@ MainWindow::~MainWindow()
delete ui; delete ui;
} }
void MainWindow::UpdateUi()
{
this->ui->scaleInput->setValue(this->ui->renderArea->scale());
this->ui->intervalInput->setValue(this->ui->renderArea->intervalLenght());
this->ui->stepInput->setValue(this->ui->renderArea->stepCount());
}
void MainWindow::paintEvent(QPaintEvent* event) void MainWindow::paintEvent(QPaintEvent* event)
{ {
QPainter painter{this}; QPainter painter{this};
@ -24,46 +33,61 @@ void MainWindow::on_btnAstroid_clicked()
{ {
this->ui->renderArea->setShape(RenderArea::Astroid); this->ui->renderArea->setShape(RenderArea::Astroid);
this->ui->renderArea->repaint(); this->ui->renderArea->repaint();
UpdateUi();
} }
void MainWindow::on_btnCicloid_clicked() void MainWindow::on_btnCicloid_clicked()
{ {
this->ui->renderArea->setShape(RenderArea::Cycloid); this->ui->renderArea->setShape(RenderArea::Cycloid);
this->ui->renderArea->repaint(); this->ui->renderArea->repaint();
UpdateUi();
} }
void MainWindow::on_btnHuygens_clicked() void MainWindow::on_btnHuygens_clicked()
{ {
this->ui->renderArea->setShape(RenderArea::HuygensCycloid); this->ui->renderArea->setShape(RenderArea::HuygensCycloid);
this->ui->renderArea->repaint(); this->ui->renderArea->repaint();
UpdateUi();
} }
void MainWindow::on_btnHypo_clicked() void MainWindow::on_btnHypo_clicked()
{ {
this->ui->renderArea->setShape(RenderArea::HypoCycloid); this->ui->renderArea->setShape(RenderArea::HypoCycloid);
this->ui->renderArea->repaint(); this->ui->renderArea->repaint();
UpdateUi();
} }
void MainWindow::on_btnLine_clicked() void MainWindow::on_btnLine_clicked()
{ {
this->ui->renderArea->setShape(RenderArea::Line); this->ui->renderArea->setShape(RenderArea::Line);
this->ui->renderArea->repaint(); this->ui->renderArea->repaint();
UpdateUi();
} }
void MainWindow::on_intervalInput_valueChanged(double arg1) void MainWindow::on_intervalInput_valueChanged(double interval)
{ {
this->ui->renderArea->setInternalLenght(arg1); this->ui->renderArea->setInternalLenght(interval);
this->ui->renderArea->repaint();
} }
void MainWindow::on_scaleInput_valueChanged(double arg1) void MainWindow::on_scaleInput_valueChanged(double scale)
{ {
this->ui->renderArea->setScale(arg1); this->ui->renderArea->setScale(scale);
this->ui->renderArea->repaint();
} }
void MainWindow::on_stepInput_valueChanged(double arg1) void MainWindow::on_stepInput_valueChanged(int count)
{ {
this->ui->renderArea->setStepCount(arg1); this->ui->renderArea->setStepCount(count);
this->ui->renderArea->repaint(); }
void MainWindow::on_btnBackgroundColor_clicked()
{
auto color{QColorDialog::getColor(this->ui->renderArea->backgroundColor(),this,"Select Color")};
ui->renderArea->setBackgroundColor(color);
}
void MainWindow::on_btnLineColor_clicked()
{
auto color{QColorDialog::getColor(this->ui->renderArea->shapeColor(),this,"Select Color")};
ui->renderArea->setShapeColor(color);
} }

View File

@ -33,9 +33,14 @@ class MainWindow : public QMainWindow
void on_scaleInput_valueChanged(double arg1); void on_scaleInput_valueChanged(double arg1);
void on_stepInput_valueChanged(double arg1); void on_stepInput_valueChanged(int arg1);
void on_btnBackgroundColor_clicked();
void on_btnLineColor_clicked();
private: private:
void UpdateUi();
constexpr static QWidget* root = 0; constexpr static QWidget* root = 0;
Ui::MainWindow *ui; Ui::MainWindow *ui;
}; };

View File

@ -6,13 +6,22 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>670</width> <width>669</width>
<height>612</height> <height>611</height>
</rect> </rect>
</property> </property>
<property name="palette"> <property name="palette">
<palette> <palette>
<active> <active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>251</red>
<green>250</green>
<blue>250</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button"> <colorrole role="Button">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
<color alpha="255"> <color alpha="255">
@ -31,6 +40,24 @@
</color> </color>
</brush> </brush>
</colorrole> </colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>251</red>
<green>250</green>
<blue>250</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>251</red>
<green>250</green>
<blue>250</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base"> <colorrole role="Base">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
<color alpha="255"> <color alpha="255">
@ -51,6 +78,15 @@
</colorrole> </colorrole>
</active> </active>
<inactive> <inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>251</red>
<green>250</green>
<blue>250</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button"> <colorrole role="Button">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
<color alpha="255"> <color alpha="255">
@ -69,6 +105,24 @@
</color> </color>
</brush> </brush>
</colorrole> </colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>251</red>
<green>250</green>
<blue>250</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>251</red>
<green>250</green>
<blue>250</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base"> <colorrole role="Base">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
<color alpha="255"> <color alpha="255">
@ -89,6 +143,15 @@
</colorrole> </colorrole>
</inactive> </inactive>
<disabled> <disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>251</red>
<green>250</green>
<blue>250</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button"> <colorrole role="Button">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
<color alpha="255"> <color alpha="255">
@ -107,6 +170,24 @@
</color> </color>
</brush> </brush>
</colorrole> </colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>251</red>
<green>250</green>
<blue>250</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>251</red>
<green>250</green>
<blue>250</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base"> <colorrole role="Base">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
<color alpha="255"> <color alpha="255">
@ -135,265 +216,282 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(11,10,10);</string> <string notr="true">background-color: rgb(11,10,10);
color: rgb(251, 250, 250);</string>
</property> </property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="centralWidget">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(16, 15, 15);</string> <string notr="true">background-color: rgb(16, 15, 15);</string>
</property> </property>
<widget class="RenderArea" name="renderArea" native="true"> <layout class="QGridLayout" name="gridLayout">
<property name="enabled"> <item row="0" column="0">
<bool>true</bool> <layout class="QVBoxLayout" name="verticalLayout_2">
</property> <item>
<property name="geometry"> <widget class="RenderArea" name="renderArea" native="true">
<rect> <property name="enabled">
<x>11</x> <bool>true</bool>
<y>11</y> </property>
<width>491</width> </widget>
<height>481</height> </item>
</rect> <item>
</property> <layout class="QHBoxLayout" name="horizontalLayout_4">
</widget> <item>
<widget class="QPushButton" name="btnLine_2"> <widget class="QPushButton" name="btnBackgroundColor">
<property name="geometry"> <property name="styleSheet">
<rect> <string notr="true">color: rgb(255, 255, 255);
<x>10</x>
<y>560</y>
<width>101</width>
<height>21</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgb(36, 35, 35); background-color: rgb(36, 35, 35);
border-color: rgb(255, 255, 255);</string> border-color: rgb(255, 255, 255);</string>
</property> </property>
<property name="text"> <property name="text">
<string>Background colour</string> <string>Background colour</string>
</property> </property>
</widget> </widget>
<widget class="QPushButton" name="btnLine_3"> </item>
<property name="geometry"> <item>
<rect> <widget class="QPushButton" name="btnLineColor">
<x>120</x> <property name="styleSheet">
<y>560</y> <string notr="true">color: rgb(255, 255, 255);
<width>61</width>
<height>21</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgb(36, 35, 35); background-color: rgb(36, 35, 35);
border-color: rgb(255, 255, 255);</string> border-color: rgb(255, 255, 255);</string>
</property> </property>
<property name="text"> <property name="text">
<string> Line colour</string> <string> Line colour</string>
</property> </property>
</widget> </widget>
<widget class="QWidget" name=""> </item>
<property name="geometry"> <item>
<rect> <spacer name="horizontalSpacer">
<x>510</x> <property name="orientation">
<y>150</y> <enum>Qt::Horizontal</enum>
<width>151</width> </property>
<height>86</height> <property name="sizeHint" stdset="0">
</rect> <size>
</property> <width>318</width>
<layout class="QVBoxLayout" name="verticalLayout"> <height>20</height>
<item> </size>
<layout class="QHBoxLayout" name="horizontalLayout_3"> </property>
<item> </spacer>
<widget class="QLabel" name="label"> </item>
<property name="styleSheet"> </layout>
<string notr="true">color: rgb(255, 255, 255);</string> </item>
</property> </layout>
<property name="text"> </item>
<string>Scale</string> <item row="0" column="1">
</property> <layout class="QVBoxLayout" name="verticalLayout">
<property name="textFormat"> <item>
<enum>Qt::PlainText</enum> <widget class="QPushButton" name="btnAstroid">
</property> <property name="sizePolicy">
<property name="scaledContents"> <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<bool>false</bool> <horstretch>0</horstretch>
</property> <verstretch>0</verstretch>
<property name="alignment"> </sizepolicy>
<set>Qt::AlignCenter</set> </property>
</property> <property name="styleSheet">
</widget> <string notr="true">color: rgb(255, 255, 255);
</item> background-color: rgb(36, 35, 35);
<item> border-color: rgb(255, 255, 255);</string>
<widget class="QDoubleSpinBox" name="scaleInput"> </property>
<property name="styleSheet"> <property name="text">
<string notr="true">color: rgb(255, 255, 255); <string>Astroid</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnCicloid">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgb(36, 35, 35);
border-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>Cicloid</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnHuygens">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgb(36, 35, 35);
border-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>Huygens</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnHypo">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgb(36, 35, 35);
border-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>Hypo Cycloid</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnLine">
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgb(36, 35, 35);
border-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>Line</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>Scale:</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="scaleInput">
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgb(36, 35, 35);</string> background-color: rgb(36, 35, 35);</string>
</property> </property>
</widget> <property name="decimals">
</item> <number>1</number>
</layout> </property>
</item> <property name="maximum">
<item> <double>100.000000000000000</double>
<layout class="QHBoxLayout" name="horizontalLayout_2"> </property>
<item> <property name="singleStep">
<widget class="QLabel" name="label_2"> <double>0.100000000000000</double>
<property name="styleSheet"> </property>
<string notr="true">color: rgb(255, 255, 255);</string> </widget>
</property> </item>
<property name="text"> </layout>
<string>Interval lenght</string> </item>
</property> <item>
<property name="textFormat"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<enum>Qt::PlainText</enum> <item>
</property> <widget class="QLabel" name="label_2">
<property name="scaledContents"> <property name="styleSheet">
<bool>false</bool> <string notr="true">color: rgb(255, 255, 255);</string>
</property> </property>
<property name="alignment"> <property name="text">
<set>Qt::AlignCenter</set> <string>Interval lenght:</string>
</property> </property>
</widget> <property name="textFormat">
</item> <enum>Qt::PlainText</enum>
<item> </property>
<widget class="QDoubleSpinBox" name="intervalInput"> <property name="scaledContents">
<property name="styleSheet"> <bool>false</bool>
<string notr="true">color: rgb(255, 255, 255); </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="intervalInput">
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgb(36, 35, 35);</string> background-color: rgb(36, 35, 35);</string>
</property> </property>
</widget> <property name="maximum">
</item> <double>100.000000000000000</double>
</layout> </property>
</item> <property name="singleStep">
<item> <double>0.100000000000000</double>
<layout class="QHBoxLayout" name="horizontalLayout"> </property>
<item> </widget>
<widget class="QLabel" name="label_3"> </item>
<property name="styleSheet"> </layout>
<string notr="true">color: rgb(255, 255, 255);</string> </item>
</property> <item>
<property name="text"> <layout class="QHBoxLayout" name="horizontalLayout">
<string>Step count</string> <item>
</property> <widget class="QLabel" name="label_3">
<property name="textFormat"> <property name="styleSheet">
<enum>Qt::PlainText</enum> <string notr="true">color: rgb(255, 255, 255);</string>
</property> </property>
<property name="scaledContents"> <property name="text">
<bool>false</bool> <string>Step count:</string>
</property> </property>
<property name="alignment"> <property name="textFormat">
<set>Qt::AlignCenter</set> <enum>Qt::PlainText</enum>
</property> </property>
</widget> <property name="scaledContents">
</item> <bool>false</bool>
<item> </property>
<widget class="QDoubleSpinBox" name="stepInput"> <property name="alignment">
<property name="styleSheet"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<string notr="true">color: rgb(255, 255, 255); </property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="stepInput">
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgb(36, 35, 35);</string> background-color: rgb(36, 35, 35);</string>
</property> </property>
</widget> <property name="maximum">
</item> <number>1024</number>
</layout> </property>
</item> </widget>
</layout> </item>
</widget> </layout>
<widget class="QWidget" name=""> </item>
<property name="geometry"> <item>
<rect> <spacer name="verticalSpacer">
<x>509</x> <property name="orientation">
<y>12</y> <enum>Qt::Vertical</enum>
<width>151</width> </property>
<height>131</height> <property name="sizeHint" stdset="0">
</rect> <size>
</property> <width>20</width>
<layout class="QVBoxLayout" name="verticalLayout_2"> <height>40</height>
<item> </size>
<widget class="QPushButton" name="btnAstroid"> </property>
<property name="sizePolicy"> </spacer>
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> </item>
<horstretch>0</horstretch> </layout>
<verstretch>0</verstretch> </item>
</sizepolicy> </layout>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgb(36, 35, 35);
border-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>Astroid</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnCicloid">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgb(36, 35, 35);
border-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>Cicloid</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnHuygens">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgb(36, 35, 35);
border-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>Huygens</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnHypo">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgb(36, 35, 35);
border-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>Hypo Cycloid</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnLine">
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgb(36, 35, 35);
border-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>Line</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
<widget class="QStatusBar" name="statusBar"/> <widget class="QStatusBar" name="statusBar"/>
</widget> </widget>

View File

@ -1,6 +1,47 @@
#include "renderarea.h" #include "renderarea.h"
#include <QPainter> #include <QPainter>
QSize RenderArea::minimumSizeHint() const
{
return QSize{491,481};
}
QSize RenderArea::sizeHint() const
{
return QSize{491,481};
}
void RenderArea::paintEvent(QPaintEvent* event)
{
Q_UNUSED(event);
QPainter painter{this};
painter.setRenderHint(QPainter::Antialiasing,true);
painter.setBrush(mBackgroundColour);
painter.setPen(mShapeColour);
painter.drawRect(this->rect());
QPointF prevPoint{Compute(0)};
QPoint center{this->rect().center()},prevPixel;
prevPixel.setX(prevPoint.x() * mScale + center.x());
prevPixel.setY(prevPoint.y() * mScale + center.y());
double step{ mIntervalLenght / mStepCount };
for(double t{0}; t < mIntervalLenght; t += step){
QPointF point = Compute(t);
QPoint pixel{};
pixel.setX(point.x() * mScale + center.x());
pixel.setY(point.y() * mScale + center.y());
painter.drawLine(pixel, prevPixel);
prevPixel=pixel;
}
}
RenderArea::RenderArea(QWidget *parent) : RenderArea::RenderArea(QWidget *parent) :
QWidget{parent}, QWidget{parent},
mBackgroundColour{36,35,35}, mBackgroundColour{36,35,35},
@ -46,61 +87,6 @@ QPointF RenderArea::ComputeLine(double t)
return QPointF{1-t,1-t}; return QPointF{1-t,1-t};
} }
QSize RenderArea::minimumSizeHint() const
{
return QSize(100,100);
}
QSize RenderArea::sizeHint() const
{
return QSize(400,200);
}
void RenderArea::setInternalLenght(double l)
{
mIntervalLenght = l;
}
void RenderArea::setScale(double s)
{
mScale = s;
}
void RenderArea::setStepCount(double s)
{
mStepCount = s;
}
void RenderArea::paintEvent(QPaintEvent* event)
{
QPainter painter{this};
painter.setRenderHint(QPainter::Antialiasing,true);
painter.setBrush(mBackgroundColour);
painter.setPen(mShapeColour);
painter.drawRect(this->rect());
QPointF prevPoint{Compute(0)};
QPoint center{this->rect().center()},prevPixel;
prevPixel.setX(prevPoint.x() * mScale + center.x());
prevPixel.setY(prevPoint.y() * mScale + center.y());
double step{ mIntervalLenght / mStepCount };
for(float t = 0; t < mIntervalLenght; t += step){
QPointF point = Compute(t);
QPoint pixel;
pixel.setX(point.x() * mScale + center.x());
pixel.setY(point.y() * mScale + center.y());
painter.drawLine(pixel, prevPixel);
prevPixel=pixel;
}
}
void RenderArea::OnShapeChanged() void RenderArea::OnShapeChanged()
{ {
switch (mShape) { switch (mShape) {

View File

@ -22,12 +22,21 @@ class RenderArea : public QWidget
void setBackgroundColor(QColor color) { mBackgroundColour = color; } void setBackgroundColor(QColor color) { mBackgroundColour = color; }
QColor backgroundColor() const { return mBackgroundColour; } QColor backgroundColor() const { return mBackgroundColour; }
void setShapeColor(QColor color) { mShapeColour = color; }
QColor shapeColor() const { return mShapeColour; }
void setShape(ShapesType shape) { mShape = shape; OnShapeChanged(); } void setShape(ShapesType shape) { mShape = shape; OnShapeChanged(); }
ShapesType shape() const { return mShape; } ShapesType shape() const { return mShape; }
void setInternalLenght(double l);
void setScale(double s);
void setStepCount(double s);
void setInternalLenght(double l){mIntervalLenght=l;repaint();}
double intervalLenght() const {return mIntervalLenght;}
void setScale(double s){mScale=s;repaint();}
double scale() const {return mScale;}
void setStepCount(int s){mStepCount=s;repaint();}
int stepCount() const {return mStepCount;}
signals: signals: