| 1 | /* -*- C++ -*- |
| 2 | This file is part of the KDE libraries |
| 3 | SPDX-FileCopyrightText: 2003 Jason Harris <kstars@30doradus.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #include "kplotpoint.h" |
| 9 | |
| 10 | #include <QPointF> |
| 11 | #include <QtAlgorithms> |
| 12 | |
| 13 | class KPlotPoint::Private |
| 14 | { |
| 15 | public: |
| 16 | Private(KPlotPoint *qq, const QPointF &p, const QString &l, double bw) |
| 17 | : q(qq) |
| 18 | , point(p) |
| 19 | , label(l) |
| 20 | , barWidth(bw) |
| 21 | { |
| 22 | } |
| 23 | |
| 24 | KPlotPoint *q; |
| 25 | |
| 26 | QPointF point; |
| 27 | QString label; |
| 28 | double barWidth; |
| 29 | }; |
| 30 | |
| 31 | KPlotPoint::KPlotPoint() |
| 32 | : d(new Private(this, QPointF(), QString(), 0.0)) |
| 33 | { |
| 34 | } |
| 35 | |
| 36 | KPlotPoint::KPlotPoint(double x, double y, const QString &label, double barWidth) |
| 37 | : d(new Private(this, QPointF(x, y), label, barWidth)) |
| 38 | { |
| 39 | } |
| 40 | |
| 41 | KPlotPoint::KPlotPoint(const QPointF &p, const QString &label, double barWidth) |
| 42 | : d(new Private(this, p, label, barWidth)) |
| 43 | { |
| 44 | } |
| 45 | |
| 46 | KPlotPoint::~KPlotPoint() = default; |
| 47 | |
| 48 | QPointF KPlotPoint::position() const |
| 49 | { |
| 50 | return d->point; |
| 51 | } |
| 52 | |
| 53 | void KPlotPoint::setPosition(const QPointF &pos) |
| 54 | { |
| 55 | d->point = pos; |
| 56 | } |
| 57 | |
| 58 | double KPlotPoint::x() const |
| 59 | { |
| 60 | return d->point.x(); |
| 61 | } |
| 62 | |
| 63 | void KPlotPoint::setX(double x) |
| 64 | { |
| 65 | d->point.setX(x); |
| 66 | } |
| 67 | |
| 68 | double KPlotPoint::y() const |
| 69 | { |
| 70 | return d->point.y(); |
| 71 | } |
| 72 | |
| 73 | void KPlotPoint::setY(double y) |
| 74 | { |
| 75 | d->point.setY(y); |
| 76 | } |
| 77 | |
| 78 | QString KPlotPoint::label() const |
| 79 | { |
| 80 | return d->label; |
| 81 | } |
| 82 | |
| 83 | void KPlotPoint::setLabel(const QString &label) |
| 84 | { |
| 85 | d->label = label; |
| 86 | } |
| 87 | |
| 88 | double KPlotPoint::barWidth() const |
| 89 | { |
| 90 | return d->barWidth; |
| 91 | } |
| 92 | |
| 93 | void KPlotPoint::setBarWidth(double w) |
| 94 | { |
| 95 | d->barWidth = w; |
| 96 | } |
| 97 | |