File indexing completed on 2024-04-28 03:56:42
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 #include <memory> 0016 0017 class QPointF; 0018 0019 /** 0020 * @class KPlotPoint 0021 * @short Encapsulates a point in the plot. 0022 * A KPlotPoint consists of X and Y coordinates (in Data units), 0023 * an optional label string, and an optional bar-width, 0024 * The bar-width is only used for plots of type KPlotObject::Bars, 0025 * and it allows the width of each bar to be set manually. If 0026 * bar-widths are omitted, then the widths will be set automatically, 0027 * based on the halfway-mark between adjacent points. 0028 */ 0029 class KPLOTTING_EXPORT KPlotPoint 0030 { 0031 public: 0032 /** 0033 * Default constructor. 0034 */ 0035 explicit KPlotPoint(); 0036 0037 /** 0038 * Constructor. Sets the KPlotPoint according to the given arguments 0039 * @param x the X-position for the point, in Data units 0040 * @param y the Y-position for the point, in Data units 0041 * @param label the label string for the point. If the string 0042 * is defined, the point will be labeled in the plot. 0043 * @param width the bar width to use for this point (only used for 0044 * plots of type KPlotObject::Bars) 0045 */ 0046 KPlotPoint(double x, double y, const QString &label = QString(), double width = 0.0); 0047 0048 /** 0049 * Constructor. Sets the KPlotPoint according to the given arguments 0050 * @param p the position for the point, in Data units 0051 * @param label the label string for the point. If the string 0052 * is defined, the point will be labeled in the plot. 0053 * @param width the bar width to use for this point (only used for 0054 * plots of type KPlotObject::Bars) 0055 */ 0056 explicit KPlotPoint(const QPointF &p, const QString &label = QString(), double width = 0.0); 0057 0058 /** 0059 * Destructor 0060 */ 0061 ~KPlotPoint(); 0062 0063 /** 0064 * @return the position of the point, in data units 0065 */ 0066 QPointF position() const; 0067 0068 /** 0069 * Set the position of the point, in data units 0070 * @param pos the new position for the point. 0071 */ 0072 void setPosition(const QPointF &pos); 0073 0074 /** 0075 * @return the X-position of the point, in data units 0076 */ 0077 double x() const; 0078 0079 /** 0080 * Set the X-position of the point, in Data units 0081 */ 0082 void setX(double x); 0083 0084 /** 0085 * @return the Y-position of the point, in data units 0086 */ 0087 double y() const; 0088 0089 /** 0090 * Set the Y-position of the point, in Data units 0091 */ 0092 void setY(double y); 0093 0094 /** 0095 * @return the label for the point 0096 */ 0097 QString label() const; 0098 0099 /** 0100 * Set the label for the point 0101 */ 0102 void setLabel(const QString &label); 0103 0104 /** 0105 * @return the bar-width for the point 0106 */ 0107 double barWidth() const; 0108 0109 /** 0110 * Set the bar-width for the point 0111 */ 0112 void setBarWidth(double w); 0113 0114 private: 0115 class Private; 0116 std::unique_ptr<Private> const d; 0117 0118 Q_DISABLE_COPY(KPlotPoint) 0119 }; 0120 0121 #endif