Circle.h 1.31 KB
Newer Older
1 2 3 4 5 6
#pragma once

#include <QObject>
#include <QPointF>
#include <QPolygonF>

7 8
#include <cmath>

9 10
#include "PlanimetryCalculus.h"

11
class Circle : public QObject
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
{
    Q_OBJECT
public:
    Circle(QObject *parent = nullptr);
    Circle(double radius = 0, QObject *parent = nullptr);
    Circle(double radius = 0, QPointF origin = QPointF(0,0), QObject *parent = nullptr);
    Circle(const Circle &other, QObject *parent = nullptr);
    Circle &operator=(const Circle &other);

    // Property setters
    void setRadius(double radius);
    void setOrigin(const QPointF &origin);

    // Property getters
    double radius() const;
    QPointF origin() const;

    // Member methodes
30 31 32 33
    QVector<QPointF> approximate      (int numberOfCorners) const;
    QVector<QPointF> approximate      (double angleDiscretisation) const;
    QVector<QPointF> approximateSektor(int numberOfCorners, double alpha1, double alpha2) const;
    QVector<QPointF> approximateSektor(double angleDiscretisation, double alpha1, double alpha2) const;
34 35
    void           toCoordinate     (QPointF &toCoordinate, double alpha) const;
    QPointF        toCoordinate     (double alpha) const;
36
    bool isNull() const;
37 38 39 40 41 42 43 44 45 46

signals:
    void radiusChanged(double radius);
    void originChanged(QPointF origin);

private:
    double  _circleRadius;
    QPointF _circleOrigin;
};