#include "kplotobject.h"
#include "kplotwidget.h"
+class KPlotPoint::Private
+{
+ public:
+ Private( KPlotPoint * qq, const QPointF &p, const QString &l, double bw )
+ : q( qq ), point( p ), label( l ), barWidth( bw )
+ {
+ }
+
+ KPlotPoint *q;
+
+ QPointF point;
+ QString label;
+ double barWidth;
+};
+
+
class KPlotObject::Private
{
public:
KPlotPoint::KPlotPoint()
- : X(0), Y(0), Label(QString()), BarWidth(0.0)
+ : d( new Private( this, QPointF(), QString(), 0.0 ) )
{
}
-KPlotPoint::KPlotPoint( double x, double y, const QString &label, double barWidth )
- : X( x ), Y( y ), Label( label ), BarWidth( barWidth )
+KPlotPoint::KPlotPoint( double x, double y, const QString &label, double barWidth )
+ : d( new Private( this, QPointF( x, y ), label, barWidth ) )
{
}
KPlotPoint::KPlotPoint( const QPointF &p, const QString &label, double barWidth )
- : X( p.x() ), Y( p.y() ), Label( label ), BarWidth( barWidth )
+ : d( new Private( this, p, label, barWidth ) )
{
}
-KPlotPoint::~KPlotPoint()
+KPlotPoint::~KPlotPoint()
{
+ delete d;
}
+QPointF KPlotPoint::position() const
+{
+ return d->point;
+}
+
+void KPlotPoint::setPosition( const QPointF &pos )
+{
+ d->point = pos;
+}
+
+double KPlotPoint::x() const
+{
+ return d->point.x();
+}
+
+void KPlotPoint::setX( double x )
+{
+ d->point.setX( x );
+}
+
+double KPlotPoint::y() const
+{
+ return d->point.y();
+}
+
+void KPlotPoint::setY( double y )
+{
+ d->point.setY( y );
+}
+
+QString KPlotPoint::label() const
+{
+ return d->label;
+}
+
+void KPlotPoint::setLabel( const QString &label )
+{
+ d->label = label;
+}
+
+double KPlotPoint::barWidth() const
+{
+ return d->barWidth;
+}
+
+void KPlotPoint::setBarWidth( double w )
+{
+ d->barWidth = w;
+}
+
+
KPlotObject::KPlotObject( const QColor &c, PlotType t, double size, PointStyle ps )
: d( new Private( this ) )
{
/**
*Default constructor.
*/
- KPlotPoint();
+ explicit KPlotPoint();
/**
* Constructor. Sets the KPlotPoint according to the given arguments
* @param x the X-position for the point, in Data units
* @param width the BarWidth to use for this point (only used for
* plots of type KPlotObject::BARS)
*/
- KPlotPoint( double x, double y, const QString &label="", double width=0.0 );
+ KPlotPoint( double x, double y, const QString &label = QString(), double width = 0.0 );
/**
* Constructor. Sets the KPlotPoint according to the given arguments
* @param p the position for the point, in Data units
* @param width the BarWidth to use for this point (only used for
* plots of type KPlotObject::BARS)
*/
- KPlotPoint( const QPointF &p, const QString &label="", double width=0.0 );
+ explicit KPlotPoint( const QPointF &p, const QString &label = QString(), double width = 0.0 );
/**
* Destructor
*/
/**
* @return the position of the point, in data units
*/
- QPointF position() const { return QPointF( X, Y ); }
+ QPointF position() const;
/**
* Set the position of the point, in data units
* @param pos the new position for the point.
*/
- void setPosition( const QPointF &pos ) { X = pos.x(); Y = pos.y(); }
+ void setPosition( const QPointF &pos );
/**
* @return the X-position of the point, in data units
*/
- double x() const { return X; }
+ double x() const;
/**
* Set the X-position of the point, in Data units
*/
- void setX( double x ) { X = x; }
+ void setX( double x );
/**
* @return the Y-position of the point, in data units
*/
- double y() const { return Y; }
+ double y() const;
/**
* Set the Y-position of the point, in Data units
*/
- void setY( double y ) { Y = y; }
+ void setY( double y );
/**
* @return the label for the point
*/
- const QString& label() const { return Label; }
+ QString label() const;
/**
* Set the label for the point
*/
- void setLabel( const QString &label ) { Label = label; }
+ void setLabel( const QString &label );
/**
* @return the bar-width for the point
*/
- double barWidth() const { return BarWidth; }
+ double barWidth() const;
/**
* Set the bar-width for the point
*/
- void setBarWidth( double w ) { BarWidth = w; }
+ void setBarWidth( double w );
private:
- double X, Y;
- QString Label;
- double BarWidth;
+ class Private;
+ Private * const d;
+
+ Q_DISABLE_COPY( KPlotPoint )
};
/**