QtCurvesCpp/renderarea.h

72 lines
1.7 KiB
C
Raw Normal View History

2017-08-28 10:07:22 +02:00
#ifndef RENDERAREA_H
#define RENDERAREA_H
#include <QWidget>
2017-09-09 22:41:29 +02:00
#include <QPen>
2017-08-28 10:07:22 +02:00
class RenderArea : public QWidget
{
Q_OBJECT
public:
explicit RenderArea(QWidget *parent = nullptr);
QSize minimumSizeHint() const Q_DECL_OVERRIDE;
QSize sizeHint() const Q_DECL_OVERRIDE;
2017-08-28 11:07:50 +02:00
enum ShapesType{
Astroid,
Cycloid,
HuygensCycloid,
2017-08-28 13:08:42 +02:00
HypoCycloid,
2017-09-09 22:28:27 +02:00
Line,
Circle,
Ellipse,
Fancy,
Starfish
2017-08-28 11:07:50 +02:00
};
void setBackgroundColor(QColor color) { mBackgroundColour = color; }
QColor backgroundColor() const { return mBackgroundColour; }
2017-09-09 21:43:16 +02:00
2017-09-09 22:41:29 +02:00
void setShapeColor(QColor color) { mPen.setColor(color); }
QColor shapeColor() const { return mPen.color(); }
2017-09-09 21:43:16 +02:00
2017-08-28 12:32:05 +02:00
void setShape(ShapesType shape) { mShape = shape; OnShapeChanged(); }
2017-08-28 11:07:50 +02:00
ShapesType shape() const { return mShape; }
2017-09-09 21:43:16 +02:00
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;}
2017-08-28 11:07:50 +02:00
2017-08-28 10:07:22 +02:00
signals:
protected:
void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE;
public slots:
private:
2017-08-28 12:32:05 +02:00
void OnShapeChanged();
2017-09-09 22:28:27 +02:00
QPointF Compute(double t);
2017-08-28 12:32:05 +02:00
QPointF ComputeAstroid(double t);
QPointF ComputeCycloid(double t);
QPointF ComputeHuygens(double t);
QPointF ComputeHypo(double t);
2017-08-28 13:08:42 +02:00
QPointF ComputeLine(double t);
2017-09-09 22:28:27 +02:00
QPointF ComputeCircle(double t);
QPointF ComputeEllipse(double t);
QPointF ComputeFancy(double t);
QPointF ComputeStarfish(double t);
2017-09-09 22:41:29 +02:00
QColor mBackgroundColour;
2017-08-28 11:07:50 +02:00
ShapesType mShape;
2017-09-09 22:41:29 +02:00
QPen mPen;
2017-08-28 12:32:05 +02:00
double mScale,mIntervalLenght;
int mStepCount;
2017-08-28 10:07:22 +02:00
};
#endif // RENDERAREA_H