-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderarea.h
84 lines (66 loc) · 2.16 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
75
76
77
78
79
80
81
82
83
84
#ifndef RENDERAREA_H
#define RENDERAREA_H
#include <QWidget>
#include <QColor>
#include <QPen>
#include <math.h>
class RenderArea : public QWidget
{
Q_OBJECT
public:
explicit RenderArea(QWidget *parent = nullptr);
QSize minimumSizeHint() const Q_DECL_OVERRIDE;
QSize sizeHint() const Q_DECL_OVERRIDE;
enum ShapeType {
Astroid,
Cycloid,
HuygensCycloid,
HypoCycloid,
Line,
Circle,
Ellipse,
Fancy,
Starfish,
Cloud1,
Cloud2
};
void setBackgroundColor (QColor color) { mBackgroundColor = color; } // setter
QColor backgroundColor () const { return mBackgroundColor; } // getter
void setShapeColor (QColor color) { mPen.setColor(color); }
QColor shapeColor () const { return mPen.color(); }
void setShape (ShapeType shape) { mShape = shape; on_shape_changed (); }
ShapeType shape () const { return mShape; }
void setScale (float scale) { mScale = scale; repaint (); }
float scale () const { return mScale; }
void setIntervalLength (float length) { mIntervalLength = length; repaint(); }
float intervalLength () const { return mIntervalLength; }
void setStepCount (int count) { mStepCount = count; repaint(); }
int stepCount () const { return mStepCount; }
signals:
protected:
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
private:
void on_shape_changed ();
QPointF compute (float t); // dispatch function based on mShape's type
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);
QPointF compute_cloud1 (float t);
QPointF compute_cloud2 (float t);
QPointF compute_cloud_with_sign (float t, float sign);
private:
QColor mBackgroundColor;
QPen mPen;
ShapeType mShape;
double mIntervalLength;
double mScale;
int mStepCount;
public slots:
};
#endif // RENDERAREA_H