File indexing completed on 2024-04-28 15:29:29
0001 /* -*- C++ -*- 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2003 Jason Harris <kstars@30doradus.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KPLOTPOINT_H 0009 #define KPLOTPOINT_H 0010 0011 #include <kplotting_export.h> 0012 0013 #include <QString> 0014 0015 class QPointF; 0016 0017 /** 0018 * @class KPlotPoint 0019 * @short Encapsulates a point in the plot. 0020 * A KPlotPoint consists of X and Y coordinates (in Data units), 0021 * an optional label string, and an optional bar-width, 0022 * The bar-width is only used for plots of type KPlotObject::Bars, 0023 * and it allows the width of each bar to be set manually. If 0024 * bar-widths are omitted, then the widths will be set automatically, 0025 * based on the halfway-mark between adjacent points. 0026 */ 0027 class KPLOTTING_EXPORT KPlotPoint 0028 { 0029 public: 0030 /** 0031 * Default constructor. 0032 */ 0033 explicit KPlotPoint(); 0034 0035 /** 0036 * Constructor. Sets the KPlotPoint according to the given arguments 0037 * @param x the X-position for the point, in Data units 0038 * @param y the Y-position for the point, in Data units 0039 * @param label the label string for the point. If the string 0040 * is defined, the point will be labeled in the plot. 0041 * @param width the bar width to use for this point (only used for 0042 * plots of type KPlotObject::Bars) 0043 */ 0044 KPlotPoint(double x, double y, const QString &label = QString(), double width = 0.0); 0045 0046 /** 0047 * Constructor. Sets the KPlotPoint according to the given arguments 0048 * @param p the position for the point, in Data units 0049 * @param label the label string for the point. If the string 0050 * is defined, the point will be labeled in the plot. 0051 * @param width the bar width to use for this point (only used for 0052 * plots of type KPlotObject::Bars) 0053 */ 0054 explicit KPlotPoint(const QPointF &p, const QString &label = QString(), double width = 0.0); 0055 0056 /** 0057 * Destructor 0058 */ 0059 ~KPlotPoint(); 0060 0061 /** 0062 * @return the position of the point, in data units 0063 */ 0064 QPointF position() const; 0065 0066 /** 0067 * Set the position of the point, in data units 0068 * @param pos the new position for the point. 0069 */ 0070 void setPosition(const QPointF &pos); 0071 0072 /** 0073 * @return the X-position of the point, in data units 0074 */ 0075 double x() const; 0076 0077 /** 0078 * Set the X-position of the point, in Data units 0079 */ 0080 void setX(double x); 0081 0082 /** 0083 * @return the Y-position of the point, in data units 0084 */ 0085 double y() const; 0086 0087 /** 0088 * Set the Y-position of the point, in Data units 0089 */ 0090 void setY(double y); 0091 0092 /** 0093 * @return the label for the point 0094 */ 0095 QString label() const; 0096 0097 /** 0098 * Set the label for the point 0099 */ 0100 void setLabel(const QString &label); 0101 0102 /** 0103 * @return the bar-width for the point 0104 */ 0105 double barWidth() const; 0106 0107 /** 0108 * Set the bar-width for the point 0109 */ 0110 void setBarWidth(double w); 0111 0112 private: 0113 class Private; 0114 Private *const d; 0115 0116 Q_DISABLE_COPY(KPlotPoint) 0117 }; 0118 0119 #endif