1/* -*- C++ -*-
2 This file is part of the KDE libraries
3 Copyright (C) 2003 Jason Harris <kstars@30doradus.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KPLOTPOINT_H
22#define KPLOTPOINT_H
23
24#include <kdeui_export.h>
25
26#include <QtCore/QString>
27
28class QPointF;
29
30/**
31 * @class KPlotPoint
32 * @short Encapsulates a point in the plot.
33 * A KPlotPoint consists of X and Y coordinates (in Data units),
34 * an optional label string, and an optional bar-width,
35 * The bar-width is only used for plots of type KPlotObject::Bars,
36 * and it allows the width of each bar to be set manually. If
37 * bar-widths are omitted, then the widths will be set automatically,
38 * based on the halfway-mark between adjacent points.
39 */
40class KDEUI_EXPORT KPlotPoint {
41public:
42 /**
43 * Default constructor.
44 */
45 explicit KPlotPoint();
46
47 /**
48 * Constructor. Sets the KPlotPoint according to the given arguments
49 * @param x the X-position for the point, in Data units
50 * @param y the Y-position for the point, in Data units
51 * @param label the label string for the point. If the string
52 * is defined, the point will be labeled in the plot.
53 * @param width the bar width to use for this point (only used for
54 * plots of type KPlotObject::Bars)
55 */
56 KPlotPoint( double x, double y, const QString &label = QString(), double width = 0.0 );
57
58 /**
59 * Constructor. Sets the KPlotPoint according to the given arguments
60 * @param p the position for the point, in Data units
61 * @param label the label string for the point. If the string
62 * is defined, the point will be labeled in the plot.
63 * @param width the bar width to use for this point (only used for
64 * plots of type KPlotObject::Bars)
65 */
66 explicit KPlotPoint( const QPointF &p, const QString &label = QString(), double width = 0.0 );
67
68 /**
69 * Destructor
70 */
71 ~KPlotPoint();
72
73 /**
74 * @return the position of the point, in data units
75 */
76 QPointF position() const;
77
78 /**
79 * Set the position of the point, in data units
80 * @param pos the new position for the point.
81 */
82 void setPosition( const QPointF &pos );
83
84 /**
85 * @return the X-position of the point, in data units
86 */
87 double x() const;
88
89 /**
90 * Set the X-position of the point, in Data units
91 */
92 void setX( double x );
93
94 /**
95 * @return the Y-position of the point, in data units
96 */
97 double y() const;
98
99 /**
100 * Set the Y-position of the point, in Data units
101 */
102 void setY( double y );
103
104 /**
105 * @return the label for the point
106 */
107 QString label() const;
108
109 /**
110 * Set the label for the point
111 */
112 void setLabel( const QString &label );
113
114 /**
115 * @return the bar-width for the point
116 */
117 double barWidth() const;
118
119 /**
120 * Set the bar-width for the point
121 */
122 void setBarWidth( double w );
123
124private:
125 class Private;
126 Private * const d;
127
128 Q_DISABLE_COPY( KPlotPoint )
129};
130
131#endif
132