KPlotObject

Search for usage in LXR

KPlotObject Class Reference

#include <kplotobject.h>

Public Types

enum  PlotType { UnknownType = 0, Points = 1, Lines = 2, Bars = 4 }
 
typedef QFlags< PlotTypePlotTypes
 
enum  PointStyle {
  NoPoints = 0, Circle = 1, Letter = 2, Triangle = 3,
  Square = 4, Pentagon = 5, Hexagon = 6, Asterisk = 7,
  Star = 8, UnknownPoint
}
 

Public Member Functions

 KPlotObject (const QColor &color=Qt::white, PlotType otype=Points, double size=2.0, PointStyle ps=Circle)
 
 ~KPlotObject ()
 
void addPoint (const QPointF &p, const QString &label=QString(), double barWidth=0.0)
 
void addPoint (double x, double y, const QString &label=QString(), double barWidth=0.0)
 
void addPoint (KPlotPoint *p)
 
const QBrush barBrush () const
 
const QPenbarPen () const
 
const QBrush brush () const
 
void clearPoints ()
 
void draw (QPainter *p, KPlotWidget *pw)
 
const QPenlabelPen () const
 
const QPenlinePen () const
 
const QPenpen () const
 
PlotTypes plotTypes () const
 
QList< KPlotPoint * > points () const
 
PointStyle pointStyle () const
 
void removePoint (int index)
 
void setBarBrush (const QBrush &b)
 
void setBarPen (const QPen &p)
 
void setBrush (const QBrush &b)
 
void setLabelPen (const QPen &p)
 
void setLinePen (const QPen &p)
 
void setPen (const QPen &p)
 
void setPointStyle (PointStyle p)
 
void setShowBars (bool b)
 
void setShowLines (bool b)
 
void setShowPoints (bool b)
 
void setSize (double s)
 
double size () const
 

Detailed Description

Encapsulates a data set to be plotted in a KPlotWidget.

Think of a KPlotObject as a set of data displayed as a group in the plot. Each KPlotObject consists of a list of KPlotPoints, a "type" controlling how the data points are displayed (some combination of Points, Lines, or Bars), a color, and a size. There is also a parameter which controls the shape of the points used to display the KPlotObject.

Note
KPlotObject will take care of the points added to it, so when clearing the points list (eg with clearPoints()) any previous reference to a KPlotPoint already added to a KPlotObject will be invalid.
Author
Jason Harris
Version
1.1

Definition at line 40 of file kplotobject.h.

Member Enumeration Documentation

◆ PlotType

The type classification of the KPlotObject.

These are bitmask values that can be OR'd together, so that a set of points can be represented in the plot in multiple ways.

Note
points should be added in order of increasing x-coordinate when using Bars.
Enumerator
Points 

each KPlotPoint is represented with a drawn point

Lines 

each KPlotPoint is connected with a line

Bars 

each KPlotPoint is shown as a vertical bar

Definition at line 52 of file kplotobject.h.

◆ PointStyle

The available shape styles for plotted points.

Definition at line 63 of file kplotobject.h.

Constructor & Destructor Documentation

◆ KPlotObject()

KPlotObject::KPlotObject ( const QColor color = Qt::white,
PlotType  otype = Points,
double  size = 2.0,
PointStyle  ps = Circle 
)
explicit

Constructor.

Parameters
colorThe color for plotting this object. By default this sets the color for Points, Lines and Bars, but there are functions to override any of these.
otypethe PlotType for this object (Points, Lines or Bars)
sizethe size to use for plotted points, in pixels
psThe PointStyle describing the shape for plotted points

Definition at line 40 of file kplotobject.cpp.

◆ ~KPlotObject()

KPlotObject::~KPlotObject ( )

Destructor.

Definition at line 56 of file kplotobject.cpp.

Member Function Documentation

◆ addPoint() [1/3]

void KPlotObject::addPoint ( const QPointF p,
const QString label = QString(),
double  barWidth = 0.0 
)

Add a point to the object's list of points, using input data to construct a KPlotPoint.

Parameters
pthe QPointF to add.
labelthe optional text label for this point
barWidththe width of the bar, if this object is to be drawn with bars
Note
if
Parameters
barWidthis left at its default value of 0.0, then the width will be automatically set to the distance between this point and the one to its right.

Definition at line 178 of file kplotobject.cpp.

◆ addPoint() [2/3]

void KPlotObject::addPoint ( double  x,
double  y,
const QString label = QString(),
double  barWidth = 0.0 
)

Add a point to the object's list of points, using input data to construct a KPlotPoint.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
xthe X-coordinate of the point to add.
ythe Y-coordinate of the point to add.
labelthe optional text label
barWidththe width of the bar, if this object is to be drawn with bars
Note
if
Parameters
barWidthis left at its default value of 0.0, then the width will be automatically set to the distance between this point and the one to its right.

Definition at line 191 of file kplotobject.cpp.

◆ addPoint() [3/3]

void KPlotObject::addPoint ( KPlotPoint p)

Add a given KPlotPoint to the object's list of points.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
ppointer to the KPlotPoint to add.

Definition at line 183 of file kplotobject.cpp.

◆ barBrush()

const QBrush KPlotObject::barBrush ( ) const
Returns
the brush to use for filling bars for this Object.

Definition at line 163 of file kplotobject.cpp.

◆ barPen()

const QPen & KPlotObject::barPen ( ) const
Returns
the pen to use for drawing bars for this Object.

Definition at line 133 of file kplotobject.cpp.

◆ brush()

const QBrush KPlotObject::brush ( ) const
Returns
the default Brush to use for this Object.

Definition at line 153 of file kplotobject.cpp.

◆ clearPoints()

void KPlotObject::clearPoints ( )

Remove and destroy the points of this object.

Definition at line 206 of file kplotobject.cpp.

◆ draw()

void KPlotObject::draw ( QPainter p,
KPlotWidget pw 
)

Draw this KPlotObject on the given QPainter.

Parameters
pThe QPainter to draw on
pwthe KPlotWidget to draw on (this is needed for the KPlotWidget::mapToWidget() function)

Definition at line 212 of file kplotobject.cpp.

◆ labelPen()

const QPen & KPlotObject::labelPen ( ) const
Returns
the pen to use for drawing labels for this Object.

Definition at line 143 of file kplotobject.cpp.

◆ linePen()

const QPen & KPlotObject::linePen ( ) const
Returns
the pen to use for drawing lines for this Object.

Definition at line 123 of file kplotobject.cpp.

◆ pen()

const QPen & KPlotObject::pen ( ) const
Returns
the default pen for this Object. If no other pens are set, this pen will be used for points, lines, bars and labels (this pen is always used for points).

Definition at line 113 of file kplotobject.cpp.

◆ plotTypes()

KPlotObject::PlotTypes KPlotObject::plotTypes ( ) const
Returns
the plot flags of the object

Definition at line 61 of file kplotobject.cpp.

◆ points()

QList< KPlotPoint * > KPlotObject::points ( ) const
Returns
the list of KPlotPoints that make up this object

Definition at line 173 of file kplotobject.cpp.

◆ pointStyle()

KPlotObject::PointStyle KPlotObject::pointStyle ( ) const
Returns
the style used for drawing the points in this object

Definition at line 103 of file kplotobject.cpp.

◆ removePoint()

void KPlotObject::removePoint ( int  index)

Remove the QPointF at position index from the list of points.

Parameters
indexthe index of the point to be removed.

Definition at line 196 of file kplotobject.cpp.

◆ setBarBrush()

void KPlotObject::setBarBrush ( const QBrush b)

Set the brush to use for drawing bars for this object The brush to use.

Definition at line 168 of file kplotobject.cpp.

◆ setBarPen()

void KPlotObject::setBarPen ( const QPen p)

Set the pen to use for drawing bars for this object The pen to use.

Definition at line 138 of file kplotobject.cpp.

◆ setBrush()

void KPlotObject::setBrush ( const QBrush b)

Set the default brush to use for this object The brush to use.

Definition at line 158 of file kplotobject.cpp.

◆ setLabelPen()

void KPlotObject::setLabelPen ( const QPen p)

Set the pen to use for labels for this object The pen to use.

Definition at line 148 of file kplotobject.cpp.

◆ setLinePen()

void KPlotObject::setLinePen ( const QPen p)

Set the pen to use for drawing lines for this object The pen to use.

Definition at line 128 of file kplotobject.cpp.

◆ setPen()

void KPlotObject::setPen ( const QPen p)

Set the default pen for this object The pen to use.

Definition at line 118 of file kplotobject.cpp.

◆ setPointStyle()

void KPlotObject::setPointStyle ( PointStyle  p)

Set a new style for drawing the points in this object.

Parameters
pthe new style

Definition at line 108 of file kplotobject.cpp.

◆ setShowBars()

void KPlotObject::setShowBars ( bool  b)

Set whether bars will be drawn for this object.

Parameters
bif true, bars will be drawn

Definition at line 84 of file kplotobject.cpp.

◆ setShowLines()

void KPlotObject::setShowLines ( bool  b)

Set whether lines will be drawn for this object.

Parameters
bif true, lines will be drawn

Definition at line 75 of file kplotobject.cpp.

◆ setShowPoints()

void KPlotObject::setShowPoints ( bool  b)

Set whether points will be drawn for this object.

Parameters
bif true, points will be drawn

Definition at line 66 of file kplotobject.cpp.

◆ setSize()

void KPlotObject::setSize ( double  s)

Set the size for plotted points in this object, in pixels.

Parameters
sthe new size

Definition at line 98 of file kplotobject.cpp.

◆ size()

double KPlotObject::size ( ) const
Returns
the size of the plotted points in this object, in pixels

Definition at line 93 of file kplotobject.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Sep 29 2023 03:50:57 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.