-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderarea.h
74 lines (58 loc) · 1.96 KB
/
renderarea.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef RENDERAREA_H
#define RENDERAREA_H
#include <QWidget>
#include <QColor>
class RenderArea : public QWidget
{
Q_OBJECT
public:
explicit RenderArea(QWidget *parent = nullptr);
QSize minimumSizeHint() const override;
QSize sizeHint() const override;
enum ShapesType {
Astroid,
Cycloid,
HuygensCycloid,
HypoCycloid,
Line,
Circle,
Ellipse,
Fancy,
Starfish
};
QColor backgroundColor() const {return mBackgroundColor;}
void setBackgroundColor(const QColor &backgroundColor) {mBackgroundColor = backgroundColor; repaint();}
QColor shapeColor() const{return mShapeColor;}
void setShapeColor(const QColor &shapeColor) {mShapeColor = shapeColor; repaint();}
ShapesType shape() const {return mShape;}
void setShape(const ShapesType &shape) {mShape = shape; on_shape_changed(); repaint();}
void setScale(float scale) {mScale = scale; repaint();}
float scale() const {return mScale;}
float intervalLength() const {return mIntervalLength;}
void setIntervalLength(float intervalLength) {mIntervalLength = intervalLength; repaint();}
int stepCount() const {return mStepCount;}
void setStepCount(int stepCount) {mStepCount = stepCount; repaint();}
protected:
void paintEvent(QPaintEvent *event) override;
signals:
private:
void on_shape_changed();
QPointF compute(float t);
QPointF compute_astroid(float t);
QPointF compute_cycloid(float t);
QPointF compute_huygens(float t);
QPointF compute_hypo(float t);
QPointF compute_line(float t);
QPointF compute_circle(float t);
QPointF compute_ellipse(float t);
QPointF compute_fancy(float t);
QPointF compute_starfish(float t);
private:
QColor mBackgroundColor = qRgb(160,160,160);
QColor mShapeColor = qRgb(255,255,255);
ShapesType mShape = Astroid;
float mIntervalLength = 2*M_PI;
float mScale = 1;
int mStepCount = 64;
};
#endif // RENDERAREA_H