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#ifndef KPLOTPOINT_H
9#define KPLOTPOINT_H
10
11#include <kplotting_export.h>
12
13#include <QString>
14
15#include <memory>
16
17class QPointF;
18
19/*!
20 * \class KPlotPoint
21 * \inmodule KPlotting
22 *
23 * \brief Encapsulates a point in the plot.
24 *
25 * A KPlotPoint consists of X and Y coordinates (in Data units),
26 * an optional label string, and an optional bar-width,
27 * The bar-width is only used for plots of type KPlotObject::Bars,
28 * and it allows the width of each bar to be set manually. If
29 * bar-widths are omitted, then the widths will be set automatically,
30 * based on the halfway-mark between adjacent points.
31 */
32class KPLOTTING_EXPORT KPlotPoint
33{
34public:
35 /*!
36 * Default constructor.
37 */
38 explicit KPlotPoint();
39
40 /*!
41 * Constructor.
42 *
43 * Sets the KPlotPoint according to the given arguments
44 *
45 * \a x the X-position for the point, in Data units
46 *
47 * \a y the Y-position for the point, in Data units
48 *
49 * \a label the label string for the point. If the string
50 * is defined, the point will be labeled in the plot.
51 *
52 * \a width the bar width to use for this point (only used for
53 * plots of type KPlotObject::Bars)
54 */
55 KPlotPoint(double x, double y, const QString &label = QString(), double width = 0.0);
56
57 /*!
58 * Constructor.
59 *
60 * Sets the KPlotPoint according to the given arguments
61 *
62 * \a p the position for the point, in Data units
63 *
64 * \a label the label string for the point. If the string
65 * is defined, the point will be labeled in the plot.
66 *
67 * \a width the bar width to use for this point (only used for
68 * plots of type KPlotObject::Bars)
69 */
70 explicit KPlotPoint(const QPointF &p, const QString &label = QString(), double width = 0.0);
71
72 ~KPlotPoint();
73
74 /*!
75 * Returns the position of the point, in data units
76 */
77 QPointF position() const;
78
79 /*!
80 * Set the position of the point, in data units
81 *
82 * \a pos the new position for the point.
83 */
84 void setPosition(const QPointF &pos);
85
86 /*!
87 * Returns the X-position of the point, in data units
88 */
89 double x() const;
90
91 /*!
92 * Set the X-position of the point, in Data units
93 */
94 void setX(double x);
95
96 /*!
97 * Returns the Y-position of the point, in data units
98 */
99 double y() const;
100
101 /*!
102 * Set the Y-position of the point, in Data units
103 */
104 void setY(double y);
105
106 /*!
107 * Returns the label for the point
108 */
109 QString label() const;
110
111 /*!
112 * Set the label for the point
113 */
114 void setLabel(const QString &label);
115
116 /*!
117 * Returns the bar-width for the point
118 */
119 double barWidth() const;
120
121 /*!
122 * Set the bar-width for the point
123 */
124 void setBarWidth(double w);
125
126private:
127 class Private;
128 std::unique_ptr<Private> const d;
129
130 Q_DISABLE_COPY(KPlotPoint)
131};
132
133#endif
134

source code of kplotting/src/kplotpoint.h